Commit | Line | Data |
---|---|---|
782d1091 WD |
1 | #!/usr/bin/perl |
2 | # This script outputs some perl code that parses all possible options | |
3 | # that the code in options.c might send to the server. This perl code | |
4 | # is included in the rrsync script. | |
5 | use strict; | |
782d1091 | 6 | |
b8a47c9b | 7 | our(%short_no_arg, %short_with_num, %long_opt); |
782d1091 WD |
8 | our $last_long_opt; |
9 | ||
10 | open(IN, '../options.c') or die "Unable to open ../options.c: $!\n"; | |
11 | ||
12 | while (<IN>) { | |
13 | if (/\Qargstr[x++]\E = '(.)'/) { | |
14 | $short_no_arg{$1} = 1; | |
15 | undef $last_long_opt; | |
16 | } elsif (/\Qasprintf(\E[^,]+, "-([a-zA-Z0-9])\%l?[ud]"/) { | |
17 | $short_with_num{$1} = 1; | |
18 | undef $last_long_opt; | |
19 | } elsif (/\Qargs[ac++]\E = "--([^"=]+)"/) { | |
20 | $last_long_opt = $1; | |
b8a47c9b | 21 | $long_opt{$1} = 0; |
782d1091 WD |
22 | } elsif (defined($last_long_opt) |
23 | && /\Qargs[ac++]\E = ([^["\s]+);/ && $1 ne 'dest_option') { | |
b8a47c9b | 24 | $long_opt{$last_long_opt} = 2; |
782d1091 | 25 | undef $last_long_opt; |
b8a47c9b WD |
26 | } elsif (/dest_option = "--([^"]+)"/) { |
27 | $long_opt{$1} = 2; | |
782d1091 WD |
28 | undef $last_long_opt; |
29 | } elsif (/\Qasprintf(\E[^,]+, "--([^"=]+)=/ || /\Qargs[ac++]\E = "--([^"=]+)=/) { | |
b8a47c9b | 30 | $long_opt{$1} = 1; |
782d1091 WD |
31 | undef $last_long_opt; |
32 | } | |
33 | } | |
34 | close IN; | |
35 | ||
ef1233cb WD |
36 | my $short_no_arg = join('', sort keys %short_no_arg); |
37 | my $short_with_num = join('', sort keys %short_with_num); | |
38 | ||
39 | print <<EOT; | |
40 | ||
41 | # These options are the only options that rsync might send to the server, | |
ea9b2add | 42 | # and only in the option format that the stock rsync produces. |
555bc0e3 | 43 | |
ef1233cb | 44 | # To disable a short-named option, add its letter to this string: |
2e8259bb | 45 | our \$short_disabled = 's'; |
555bc0e3 WD |
46 | |
47 | our \$short_no_arg = '$short_no_arg'; # DO NOT REMOVE ANY | |
48 | our \$short_with_num = '$short_with_num'; # DO NOT REMOVE ANY | |
49 | ||
b8a47c9b WD |
50 | # To disable a long-named option, change its value to a -1. The values mean: |
51 | # 0 = the option has no arg; 1 = the arg doesn't need any checking; 2 = only | |
52 | # check the arg when receiving; and 3 = always check the arg. | |
53 | our \%long_opt = ( | |
ef1233cb | 54 | EOT |
782d1091 | 55 | |
b8a47c9b WD |
56 | foreach my $opt (sort keys %long_opt) { |
57 | my $val = $long_opt{$opt}; | |
30cd7ec1 | 58 | $val = 1 if $opt =~ /^(max-|min-)/; |
b8a47c9b WD |
59 | $val = 3 if $opt eq 'files-from'; |
60 | $val = '$ro ? -1 : ' . $val if $opt =~ /^remove-/; | |
61 | print " '$opt' => $val,\n"; | |
782d1091 | 62 | } |
b3181708 | 63 | |
b8a47c9b | 64 | print ");\n\n"; |