=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rsync/main.c,v retrieving revision 1.53.2.1 retrieving revision 1.54 diff -c -r1.53.2.1 -r1.54 *** src/usr.bin/rsync/main.c 2021/11/09 13:41:24 1.53.2.1 --- src/usr.bin/rsync/main.c 2021/05/17 12:04:38 1.54 *************** *** 1,4 **** ! /* $Id: main.c,v 1.53.2.1 2021/11/09 13:41:24 benno Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: main.c,v 1.54 2021/05/17 12:04:38 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * *************** *** 26,32 **** #include #include #include - #include #include "extern.h" --- 26,31 ---- *************** *** 270,351 **** return f; } - static struct opts opts; - - #define OP_ADDRESS 1000 - #define OP_PORT 1001 - #define OP_RSYNCPATH 1002 - #define OP_TIMEOUT 1003 - #define OP_VERSION 1004 - #define OP_EXCLUDE 1005 - #define OP_INCLUDE 1006 - #define OP_EXCLUDE_FROM 1007 - #define OP_INCLUDE_FROM 1008 - #define OP_COMP_DEST 1009 - #define OP_COPY_DEST 1010 - #define OP_LINK_DEST 1011 - #define OP_MAX_SIZE 1012 - #define OP_MIN_SIZE 1013 - - const struct option lopts[] = { - { "address", required_argument, NULL, OP_ADDRESS }, - { "archive", no_argument, NULL, 'a' }, - { "compare-dest", required_argument, NULL, OP_COMP_DEST }, - #if 0 - { "copy-dest", required_argument, NULL, OP_COPY_DEST }, - { "link-dest", required_argument, NULL, OP_LINK_DEST }, - #endif - { "compress", no_argument, NULL, 'z' }, - { "del", no_argument, &opts.del, 1 }, - { "delete", no_argument, &opts.del, 1 }, - { "devices", no_argument, &opts.devices, 1 }, - { "no-devices", no_argument, &opts.devices, 0 }, - { "dry-run", no_argument, &opts.dry_run, 1 }, - { "exclude", required_argument, NULL, OP_EXCLUDE }, - { "exclude-from", required_argument, NULL, OP_EXCLUDE_FROM }, - { "group", no_argument, &opts.preserve_gids, 1 }, - { "no-group", no_argument, &opts.preserve_gids, 0 }, - { "help", no_argument, NULL, 'h' }, - { "include", required_argument, NULL, OP_INCLUDE }, - { "include-from", required_argument, NULL, OP_INCLUDE_FROM }, - { "links", no_argument, &opts.preserve_links, 1 }, - { "max-size", required_argument, NULL, OP_MAX_SIZE }, - { "min-size", required_argument, NULL, OP_MIN_SIZE }, - { "no-links", no_argument, &opts.preserve_links, 0 }, - { "no-motd", no_argument, &opts.no_motd, 1 }, - { "numeric-ids", no_argument, &opts.numeric_ids, 1 }, - { "owner", no_argument, &opts.preserve_uids, 1 }, - { "no-owner", no_argument, &opts.preserve_uids, 0 }, - { "perms", no_argument, &opts.preserve_perms, 1 }, - { "no-perms", no_argument, &opts.preserve_perms, 0 }, - { "port", required_argument, NULL, OP_PORT }, - { "recursive", no_argument, &opts.recursive, 1 }, - { "no-recursive", no_argument, &opts.recursive, 0 }, - { "rsh", required_argument, NULL, 'e' }, - { "rsync-path", required_argument, NULL, OP_RSYNCPATH }, - { "sender", no_argument, &opts.sender, 1 }, - { "server", no_argument, &opts.server, 1 }, - { "specials", no_argument, &opts.specials, 1 }, - { "no-specials", no_argument, &opts.specials, 0 }, - { "timeout", required_argument, NULL, OP_TIMEOUT }, - { "times", no_argument, &opts.preserve_times, 1 }, - { "no-times", no_argument, &opts.preserve_times, 0 }, - { "verbose", no_argument, &verbose, 1 }, - { "no-verbose", no_argument, &verbose, 0 }, - { "version", no_argument, NULL, OP_VERSION }, - { NULL, 0, NULL, 0 } - }; - int main(int argc, char *argv[]) { pid_t child; ! int fds[2], sd = -1, rc, c, st, i, lidx; ! size_t basedir_cnt = 0; ! struct sess sess; struct fargs *fargs; char **args; ! const char *errstr; /* Global pledge. */ --- 269,320 ---- return f; } int main(int argc, char *argv[]) { + struct opts opts; pid_t child; ! int fds[2], sd = -1, rc, c, st, i; ! struct sess sess; struct fargs *fargs; char **args; ! const char *errstr; ! const struct option lopts[] = { ! { "port", required_argument, NULL, 3 }, ! { "rsh", required_argument, NULL, 'e' }, ! { "rsync-path", required_argument, NULL, 1 }, ! { "sender", no_argument, &opts.sender, 1 }, ! { "server", no_argument, &opts.server, 1 }, ! { "dry-run", no_argument, &opts.dry_run, 1 }, ! { "version", no_argument, NULL, 2 }, ! { "archive", no_argument, NULL, 'a' }, ! { "help", no_argument, NULL, 'h' }, ! { "compress", no_argument, NULL, 'z' }, ! { "del", no_argument, &opts.del, 1 }, ! { "delete", no_argument, &opts.del, 1 }, ! { "devices", no_argument, &opts.devices, 1 }, ! { "no-devices", no_argument, &opts.devices, 0 }, ! { "group", no_argument, &opts.preserve_gids, 1 }, ! { "no-group", no_argument, &opts.preserve_gids, 0 }, ! { "links", no_argument, &opts.preserve_links, 1 }, ! { "no-links", no_argument, &opts.preserve_links, 0 }, ! { "owner", no_argument, &opts.preserve_uids, 1 }, ! { "no-owner", no_argument, &opts.preserve_uids, 0 }, ! { "perms", no_argument, &opts.preserve_perms, 1 }, ! { "no-perms", no_argument, &opts.preserve_perms, 0 }, ! { "numeric-ids", no_argument, &opts.numeric_ids, 1 }, ! { "recursive", no_argument, &opts.recursive, 1 }, ! { "no-recursive", no_argument, &opts.recursive, 0 }, ! { "specials", no_argument, &opts.specials, 1 }, ! { "no-specials", no_argument, &opts.specials, 0 }, ! { "timeout", required_argument, NULL, 5 }, ! { "times", no_argument, &opts.preserve_times, 1 }, ! { "no-times", no_argument, &opts.preserve_times, 0 }, ! { "verbose", no_argument, &verbose, 1 }, ! { "no-verbose", no_argument, &verbose, 0 }, ! { "address", required_argument, NULL, 4 }, ! { "no-motd", no_argument, NULL, 6 }, ! { NULL, 0, NULL, 0 }}; /* Global pledge. */ *************** *** 353,361 **** NULL) == -1) err(ERR_IPC, "pledge"); ! opts.max_size = opts.min_size = -1; ! while ((c = getopt_long(argc, argv, "Dae:ghlnoprtvxz", lopts, &lidx)) != -1) { switch (c) { case 'D': --- 322,330 ---- NULL) == -1) err(ERR_IPC, "pledge"); ! memset(&opts, 0, sizeof(struct opts)); ! while ((c = getopt_long(argc, argv, "Dae:ghlnoprtvxz", lopts, NULL)) != -1) { switch (c) { case 'D': *************** *** 408,491 **** case 0: /* Non-NULL flag values (e.g., --sender). */ break; ! case OP_ADDRESS: ! opts.address = optarg; break; ! case OP_PORT: opts.port = optarg; break; ! case OP_RSYNCPATH: ! opts.rsync_path = optarg; break; ! case OP_TIMEOUT: poll_timeout = strtonum(optarg, 0, 60*60, &errstr); if (errstr != NULL) errx(ERR_SYNTAX, "timeout is %s: %s", errstr, optarg); break; ! case OP_EXCLUDE: ! if (parse_rule(optarg, RULE_EXCLUDE) == -1) ! errx(ERR_SYNTAX, "syntax error in exclude: %s", ! optarg); break; - case OP_INCLUDE: - if (parse_rule(optarg, RULE_INCLUDE) == -1) - errx(ERR_SYNTAX, "syntax error in include: %s", - optarg); - break; - case OP_EXCLUDE_FROM: - parse_file(optarg, RULE_EXCLUDE); - break; - case OP_INCLUDE_FROM: - parse_file(optarg, RULE_INCLUDE); - break; - case OP_COMP_DEST: - if (opts.alt_base_mode !=0 && - opts.alt_base_mode != BASE_MODE_COMPARE) { - errx(1, "option --%s conflicts with %s", - lopts[lidx].name, - alt_base_mode(opts.alt_base_mode)); - } - opts.alt_base_mode = BASE_MODE_COMPARE; - #if 0 - goto basedir; - case OP_COPY_DEST: - if (opts.alt_base_mode !=0 && - opts.alt_base_mode != BASE_MODE_COPY) { - errx(1, "option --%s conflicts with %s", - lopts[lidx].name, - alt_base_mode(opts.alt_base_mode)); - } - opts.alt_base_mode = BASE_MODE_COPY; - goto basedir; - case OP_LINK_DEST: - if (opts.alt_base_mode !=0 && - opts.alt_base_mode != BASE_MODE_LINK) { - errx(1, "option --%s conflicts with %s", - lopts[lidx].name, - alt_base_mode(opts.alt_base_mode)); - } - opts.alt_base_mode = BASE_MODE_LINK; - - basedir: - #endif - if (basedir_cnt >= MAX_BASEDIR) - errx(1, "too many --%s directories specified", - lopts[lidx].name); - opts.basedir[basedir_cnt++] = optarg; - break; - case OP_MAX_SIZE: - if (scan_scaled(optarg, &opts.max_size) == -1) - err(1, "bad max-size"); - break; - case OP_MIN_SIZE: - if (scan_scaled(optarg, &opts.min_size) == -1) - err(1, "bad min-size"); - break; - case OP_VERSION: - fprintf(stderr, "openrsync: protocol version %u\n", - RSYNC_PROTOCOL); - exit(0); case 'h': default: goto usage; --- 377,404 ---- case 0: /* Non-NULL flag values (e.g., --sender). */ break; ! case 1: ! opts.rsync_path = optarg; break; ! case 2: ! fprintf(stderr, "openrsync: protocol version %u\n", ! RSYNC_PROTOCOL); ! exit(0); ! case 3: opts.port = optarg; break; ! case 4: ! opts.address = optarg; break; ! case 5: poll_timeout = strtonum(optarg, 0, 60*60, &errstr); if (errstr != NULL) errx(ERR_SYNTAX, "timeout is %s: %s", errstr, optarg); break; ! case 6: ! opts.no_motd = 1; break; case 'h': default: goto usage; *************** *** 505,511 **** /* by default and for --timeout=0 disable poll_timeout */ if (poll_timeout == 0) ! poll_timeout = -1; else poll_timeout *= 1000; /* --- 418,425 ---- /* by default and for --timeout=0 disable poll_timeout */ if (poll_timeout == 0) ! poll_timeout = -1; ! else poll_timeout *= 1000; /* *************** *** 613,623 **** exit(rc); usage: fprintf(stderr, "usage: %s" ! " [-aDglnoprtvx] [-e program] [--address=sourceaddr]\n" ! "\t[--compare-dest=dir] [--del] [--exclude] [--exclude-from=file]\n" ! "\t[--include] [--include-from=file] [--no-motd] [--numeric-ids]\n" ! "\t[--port=portnumber] [--rsync-path=program] [--timeout=seconds]\n" ! "\t[--version] source ... directory\n", getprogname()); exit(ERR_SYNTAX); } --- 527,536 ---- exit(rc); usage: fprintf(stderr, "usage: %s" ! " [-aDglnoprtvx] [-e program] [--address=sourceaddr] [--del]\n" ! "\t[--no-motd] [--numeric-ids] [--port=portnumber] " ! "[--rsync-path=program]\n\t[--timeout=seconds] [--version] " ! "source ... directory\n", getprogname()); exit(ERR_SYNTAX); }