File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / packaging / cull_options
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Nov 1 09:54:32 2016 UTC (7 years, 9 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_1_2p5, HEAD
rsync 3.1.2

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

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