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