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.
8 our(%short_no_arg, %short_with_num);
9 our(%long_no_arg, %long_before_arg, %long_with_arg);
12 open(IN, '../options.c') or die "Unable to open ../options.c: $!\n";
15 if (/\Qargstr[x++]\E = '(.)'/) {
16 $short_no_arg{$1} = 1;
18 } elsif (/\Qasprintf(\E[^,]+, "-([a-zA-Z0-9])\%l?[ud]"/) {
19 $short_with_num{$1} = 1;
21 } elsif (/\Qargs[ac++]\E = "--([^"=]+)"/) {
24 } elsif (defined($last_long_opt)
25 && /\Qargs[ac++]\E = ([^["\s]+);/ && $1 ne 'dest_option') {
26 delete $long_no_arg{$last_long_opt};
27 $long_before_arg{$last_long_opt} = 1;
29 } elsif (/dest_option = "--([^"])"/) {
30 $long_before_arg{$1} = 1;
32 } elsif (/\Qasprintf(\E[^,]+, "--([^"=]+)=/ || /\Qargs[ac++]\E = "--([^"=]+)=/) {
33 $long_with_arg{$1} = 1;
39 print "our \$short_no_arg = '", sort(keys %short_no_arg), "';\n",
40 "our \$short_with_num = '", sort(keys %short_with_num), "';\n",
41 "# To disable a short-named option, add its letter to this string:\n",
42 "our \$short_disabled = '';\n",
43 "# To disable a long-named option, change its value to a 0. A value of -1\n",
44 "# means the arg doesn't need checking, a 2 means only check when receiving.\n";
46 foreach my $name (qw( long_no_arg long_with_arg long_before_arg )) {
47 $_ = "our \%$name = (\n '" . join("' => 1,\n '", sort keys %$name) . "' => 1,\n);\n";
48 if ($name eq 'long_before_arg') {
50 s/('files-from' =>) 2,/$1 1,/;
51 s/('max-.* =>) 2,/$1 -1,/g;
54 s/('files-from' =>) -1,/$1 1,/;
56 s/('remove-.* =>) (-?\d),/$1 \$ro ? 0 : $2,/g;