+my($last_protocol_version, %pdate);
+while (<IN>) {
+ if (my($ver,$pdate,$pver) = /^\s+\S\S\s\S\S\S\s\d\d\d\d\s+(\d+\.\d+\.\d+)\s+(\d\d \w\w\w \d\d\d\d\s+)?(\d+)$/) {
+ $pdate{$ver} = $pdate if defined $pdate;
+ $last_protocol_version = $pver if $ver eq $lastversion;
+ }
+}
+close IN;
+die "Unable to determine protocol_version for $lastversion.\n" unless defined $last_protocol_version;
+
+my $protocol_version;
+open(IN, '<', 'rsync.h') or die $!;
+while (<IN>) {
+ if (/^#define\s+PROTOCOL_VERSION\s+(\d+)/) {
+ $protocol_version = $1;
+ last;
+ }
+}
+close IN;
+die "Unable to determine the current PROTOCOL_VERSION.\n" unless defined $protocol_version;