#!/usr/bin/env perl # This script outputs some perl code that parses all possible options # that the code in options.c might send to the server. This perl code # is included in the rrsync script. use strict; our %short_no_arg; our %short_with_num = ( '@' => 1 ); our %long_opt = ( # These include some extra long-args that BackupPC uses: 'block-size' => 1, 'daemon' => -1, 'debug' => 1, 'fake-super' => 0, 'fuzzy' => 0, 'group' => 0, 'hard-links' => 0, 'ignore-times' => 0, 'info' => 1, 'links' => 0, 'log-file' => 3, 'one-file-system' => 0, 'owner' => 0, 'perms' => 0, 'recursive' => 0, 'times' => 0, 'write-devices' => -1, ); our $last_long_opt; open(IN, '../options.c') or die "Unable to open ../options.c: $!\n"; while () { if (/\Qargstr[x++]\E = '([^.ie])'/) { $short_no_arg{$1} = 1; undef $last_long_opt; } elsif (/\Qasprintf(\E[^,]+, "-([a-zA-Z0-9])\%l?[ud]"/) { $short_with_num{$1} = 1; undef $last_long_opt; } elsif (/\Qargs[ac++]\E = "--([^"=]+)"/) { $last_long_opt = $1; $long_opt{$1} = 0 unless exists $long_opt{$1}; } elsif (defined($last_long_opt) && /\Qargs[ac++]\E = ([^["\s]+);/) { $long_opt{$last_long_opt} = 2; undef $last_long_opt; } elsif (/return "--([^"]+-dest)";/) { $long_opt{$1} = 2; undef $last_long_opt; } elsif (/\Qasprintf(\E[^,]+, "--([^"=]+)=/ || /\Qargs[ac++]\E = "--([^"=]+)=/ || /fmt = .*: "--([^"=]+)=/) { $long_opt{$1} = 1; undef $last_long_opt; } } close IN; my $short_no_arg = join('', sort keys %short_no_arg); my $short_with_num = join('', sort keys %short_with_num); print < $val,\n"; } print ");\n\n";