Annotation of embedaddon/rsync/packaging/cull_options, revision 1.1.1.3

1.1.1.3 ! misho       1: #!/usr/bin/env perl
1.1       misho       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;
                      6: 
                      7: our %short_no_arg;
1.1.1.3 ! misho       8: our %short_with_num = ( '@' => 1 );
1.1.1.2   misho       9: our %long_opt = ( # These include some extra long-args that BackupPC uses:
                     10:     'block-size' => 1,
1.1       misho      11:     'daemon' => -1,
1.1.1.2   misho      12:     'debug' => 1,
1.1       misho      13:     'fake-super' => 0,
1.1.1.2   misho      14:     'fuzzy' => 0,
                     15:     'group' => 0,
                     16:     'hard-links' => 0,
                     17:     'ignore-times' => 0,
                     18:     'info' => 1,
                     19:     'links' => 0,
1.1       misho      20:     'log-file' => 3,
1.1.1.2   misho      21:     'one-file-system' => 0,
                     22:     'owner' => 0,
                     23:     'perms' => 0,
                     24:     'recursive' => 0,
                     25:     'times' => 0,
1.1.1.3 ! misho      26:     'write-devices' => -1,
1.1       misho      27: );
                     28: our $last_long_opt;
                     29: 
                     30: open(IN, '../options.c') or die "Unable to open ../options.c: $!\n";
                     31: 
                     32: while (<IN>) {
                     33:     if (/\Qargstr[x++]\E = '([^.ie])'/) {
                     34:        $short_no_arg{$1} = 1;
                     35:        undef $last_long_opt;
                     36:     } elsif (/\Qasprintf(\E[^,]+, "-([a-zA-Z0-9])\%l?[ud]"/) {
                     37:        $short_with_num{$1} = 1;
                     38:        undef $last_long_opt;
                     39:     } elsif (/\Qargs[ac++]\E = "--([^"=]+)"/) {
                     40:        $last_long_opt = $1;
                     41:        $long_opt{$1} = 0 unless exists $long_opt{$1};
                     42:     } elsif (defined($last_long_opt)
1.1.1.3 ! misho      43:        && /\Qargs[ac++]\E = ([^["\s]+);/) {
1.1       misho      44:        $long_opt{$last_long_opt} = 2;
                     45:        undef $last_long_opt;
1.1.1.3 ! misho      46:     } elsif (/return "--([^"]+-dest)";/) {
1.1       misho      47:        $long_opt{$1} = 2;
                     48:        undef $last_long_opt;
1.1.1.3 ! misho      49:     } elsif (/\Qasprintf(\E[^,]+, "--([^"=]+)=/ || /\Qargs[ac++]\E = "--([^"=]+)=/ || /fmt = .*: "--([^"=]+)=/) {
1.1       misho      50:        $long_opt{$1} = 1;
                     51:        undef $last_long_opt;
                     52:     }
                     53: }
                     54: close IN;
                     55: 
                     56: my $short_no_arg = join('', sort keys %short_no_arg);
                     57: my $short_with_num = join('', sort keys %short_with_num);
                     58: 
                     59: print <<EOT;
                     60: 
                     61: # These options are the only options that rsync might send to the server,
                     62: # and only in the option format that the stock rsync produces.
                     63: 
                     64: # To disable a short-named option, add its letter to this string:
                     65: our \$short_disabled = 's';
                     66: 
                     67: our \$short_no_arg = '$short_no_arg'; # DO NOT REMOVE ANY
                     68: our \$short_with_num = '$short_with_num'; # DO NOT REMOVE ANY
                     69: 
                     70: # To disable a long-named option, change its value to a -1.  The values mean:
                     71: # 0 = the option has no arg; 1 = the arg doesn't need any checking; 2 = only
                     72: # check the arg when receiving; and 3 = always check the arg.
                     73: our \%long_opt = (
                     74: EOT
                     75: 
                     76: foreach my $opt (sort keys %long_opt) {
                     77:     my $val = $long_opt{$opt};
                     78:     $val = 1 if $opt =~ /^(max-|min-)/;
                     79:     $val = 3 if $opt eq 'files-from';
1.1.1.3 ! misho      80:     $val = q"$only eq 'r' ? -1 : " . $val if $opt =~ /^(remove-|log-file)/;
        !            81:     $val = q"$only eq 'w' ? -1 : " . $val if $opt eq 'sender';
1.1       misho      82:     print "  '$opt' => $val,\n";
                     83: }
                     84: 
                     85: print ");\n\n";

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>