summaryrefslogtreecommitdiff
path: root/packaging/cull_options
blob: 388d33f0dbd8e6b00576b3506e93a26087212580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/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;
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,
);
our $last_long_opt;

open(IN, '../options.c') or die "Unable to open ../options.c: $!\n";

while (<IN>) {
    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]+);/ && $1 ne 'dest_option') {
	$long_opt{$last_long_opt} = 2;
	undef $last_long_opt;
    } elsif (/dest_option = "--([^"]+)"/) {
	$long_opt{$1} = 2;
	undef $last_long_opt;
    } elsif (/\Qasprintf(\E[^,]+, "--([^"=]+)=/ || /\Qargs[ac++]\E = "--([^"=]+)=/) {
	$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 <<EOT;

# These options are the only options that rsync might send to the server,
# and only in the option format that the stock rsync produces.

# To disable a short-named option, add its letter to this string:
our \$short_disabled = 's';

our \$short_no_arg = '$short_no_arg'; # DO NOT REMOVE ANY
our \$short_with_num = '$short_with_num'; # DO NOT REMOVE ANY

# To disable a long-named option, change its value to a -1.  The values mean:
# 0 = the option has no arg; 1 = the arg doesn't need any checking; 2 = only
# check the arg when receiving; and 3 = always check the arg.
our \%long_opt = (
EOT

foreach my $opt (sort keys %long_opt) {
    my $val = $long_opt{$opt};
    $val = 1 if $opt =~ /^(max-|min-)/;
    $val = 3 if $opt eq 'files-from';
    $val = '$ro ? -1 : ' . $val if $opt =~ /^remove-/;
    print "  '$opt' => $val,\n";
}

print ");\n\n";