列挙型 | |
enum | { OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM, OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP, OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD, OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE, OPT_NO_D, OPT_SERVER, OPT_REFUSED_BASE = 9000 } |
関数 | |
static void | print_rsync_version (enum logcode f) |
void | usage (enum logcode F) |
static void | daemon_usage (enum logcode F) |
void | option_error (void) |
Store the option error message, if any, so that we can log the connection attempt (which requires parsing the options), and then show the error later on. | |
static void | set_refuse_options (char *bp) |
Tweak the option table to disable all options that the rsyncd.conf file has told us to refuse. | |
static int | count_args (const char **argv) |
static OFF_T | parse_size_arg (char **size_arg, char def_suf) |
static void | create_refuse_error (int which) |
int | parse_arguments (int *argc, const char ***argv, int frommain) |
Process command line arguments. | |
void | server_options (char **args, int *argc) |
Construct a filtered list of options to pass through from the client to the server. | |
char * | check_for_hostspec (char *s, char **host_ptr, int *port_ptr) |
変数 | |
int | module_id |
int | sanitize_paths |
filter_list_struct | filter_list |
filter_list_struct | server_filter_list |
int | make_backups = 0 |
int | whole_file = -1 |
If 1, send the whole file as literal data rather than trying to create an incremental diff. | |
int | append_mode = 0 |
int | keep_dirlinks = 0 |
int | copy_dirlinks = 0 |
int | copy_links = 0 |
int | preserve_links = 0 |
int | preserve_hard_links = 0 |
int | preserve_acls = 0 |
int | preserve_xattrs = 0 |
int | preserve_perms = 0 |
int | preserve_executability = 0 |
int | preserve_devices = 0 |
int | preserve_specials = 0 |
int | preserve_uid = 0 |
int | preserve_gid = 0 |
int | preserve_times = 0 |
int | omit_dir_times = 0 |
int | update_only = 0 |
int | cvs_exclude = 0 |
int | dry_run = 0 |
int | do_xfers = 1 |
int | ignore_times = 0 |
int | delete_mode = 0 |
int | delete_during = 0 |
int | delete_before = 0 |
int | delete_after = 0 |
int | delete_excluded = 0 |
int | remove_sent_files = 0 |
int | one_file_system = 0 |
int | protocol_version = PROTOCOL_VERSION |
int | sparse_files = 0 |
int | do_compression = 0 |
int | def_compress_level = Z_DEFAULT_COMPRESSION |
int | am_root = 0 |
int | am_server = 0 |
int | am_sender = 0 |
int | am_generator = 0 |
int | am_starting_up = 1 |
int | relative_paths = -1 |
int | implied_dirs = 1 |
int | numeric_ids = 0 |
int | allow_8bit_chars = 0 |
int | force_delete = 0 |
int | io_timeout = 0 |
int | allowed_lull = 0 |
int | prune_empty_dirs = 0 |
char * | files_from = NULL |
int | filesfrom_fd = -1 |
char * | filesfrom_host = NULL |
int | eol_nulls = 0 |
int | human_readable = 0 |
int | recurse = 0 |
int | xfer_dirs = -1 |
int | am_daemon = 0 |
int | daemon_over_rsh = 0 |
int | do_stats = 0 |
int | do_progress = 0 |
int | keep_partial = 0 |
int | safe_symlinks = 0 |
int | copy_unsafe_links = 0 |
int | size_only = 0 |
int | daemon_bwlimit = 0 |
int | bwlimit = 0 |
int | fuzzy_basis = 0 |
size_t | bwlimit_writemax = 0 |
int | ignore_existing = 0 |
int | ignore_non_existing = 0 |
int | need_messages_from_generator = 0 |
int | max_delete = 0 |
OFF_T | max_size = 0 |
OFF_T | min_size = 0 |
int | ignore_errors = 0 |
int | modify_window = 0 |
int | blocking_io = -1 |
int | checksum_seed = 0 |
int | inplace = 0 |
int | delay_updates = 0 |
long | block_size = 0 |
int | default_af_hint = 0 |
Network address family. | |
int | default_af_hint = AF_INET |
Network address family. | |
int | no_detach = 1 |
Do not go into the background when run as --daemon. | |
int | write_batch = 0 0 |
int | read_batch = 0 |
int | backup_dir_len = 0 |
int | backup_suffix_len |
unsigned int | backup_dir_remainder |
char * | backup_suffix = NULL |
char * | tmpdir = NULL |
char * | partial_dir = NULL |
char * | basis_dir [MAX_BASIS_DIRS+1] |
char * | config_file = NULL |
char * | shell_cmd = NULL |
char * | log_format = NULL |
char * | password_file = NULL |
char * | rsync_path = RSYNC_PATH |
char * | backup_dir = NULL |
char | backup_dir_buf [MAXPATHLEN] |
char * | sockopts = NULL |
int | rsync_port = 0 |
int | compare_dest = 0 |
int | copy_dest = 0 |
int | link_dest = 0 |
int | basis_dir_cnt = 0 |
char * | dest_option = NULL |
int | verbose = 0 |
int | quiet = 0 |
int | log_before_transfer = 0 |
int | log_format_has_i = 0 |
int | log_format_has_o_or_i = 0 |
int | always_checksum = 0 |
int | list_only = 0 |
char * | batch_name = NULL |
chmod_mode_struct * | chmod_modes = NULL |
static int | daemon_opt |
static int | F_option_cnt = 0 |
static int | modify_window_set |
static int | itemize_changes = 0 |
static int | refused_delete |
static int | refused_archive_part |
static int | refused_compress |
static int | refused_partial |
static int | refused_progress |
static int | refused_delete_before |
static int | refused_inplace |
static char * | max_size_arg |
static char * | min_size_arg |
static char | tmp_partialdir [] = ".~tmp~" |
char * | bind_address |
Local address to bind. | |
static struct poptOption | long_options [] |
static struct poptOption | long_daemon_options [] |
static char | err_buf [200] |
anonymous enum |
00398 {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM, 00399 OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP, 00400 OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD, 00401 OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE, 00402 OPT_NO_D, 00403 OPT_SERVER, OPT_REFUSED_BASE = 9000};
static void print_rsync_version | ( | enum logcode | f | ) | [static] |
参照先 get_panic_action()・rprintf().
参照元 daemon_usage()・parse_arguments()・usage().
00193 { 00194 char const *got_socketpair = "no "; 00195 char const *have_inplace = "no "; 00196 char const *hardlinks = "no "; 00197 char const *acls = "no "; 00198 char const *xattrs = "no "; 00199 char const *links = "no "; 00200 char const *ipv6 = "no "; 00201 STRUCT_STAT *dumstat; 00202 00203 #ifdef HAVE_SOCKETPAIR 00204 got_socketpair = ""; 00205 #endif 00206 00207 #ifdef HAVE_FTRUNCATE 00208 have_inplace = ""; 00209 #endif 00210 00211 #ifdef SUPPORT_HARD_LINKS 00212 hardlinks = ""; 00213 #endif 00214 00215 #ifdef SUPPORT_ACLS 00216 acls = ""; 00217 #endif 00218 #ifdef SUPPORT_XATTRS 00219 xattrs = ""; 00220 #endif 00221 #ifdef SUPPORT_LINKS 00222 links = ""; 00223 #endif 00224 00225 #ifdef INET6 00226 ipv6 = ""; 00227 #endif 00228 00229 rprintf(f, "%s version %s protocol version %d\n", 00230 RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION); 00231 rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n"); 00232 rprintf(f, "<http://rsync.samba.org/>\n"); 00233 rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, " 00234 "%shard links, %sACLs, %sxattrs, %ssymlinks, batchfiles,\n", 00235 (int) (sizeof (OFF_T) * 8), 00236 got_socketpair, hardlinks, acls, xattrs, links); 00237 00238 /* Note that this field may not have type ino_t. It depends 00239 * on the complicated interaction between largefile feature 00240 * macros. */ 00241 rprintf(f, " %sinplace, %sIPv6, " 00242 "%d-bit system inums, %d-bit internal inums\n", 00243 have_inplace, ipv6, 00244 (int) (sizeof dumstat->st_ino * 8), 00245 (int) (sizeof (int64) * 8)); 00246 #ifdef MAINTAINER_MODE 00247 rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); 00248 #endif 00249 00250 #if SIZEOF_INT64 < 8 00251 rprintf(f, "WARNING: no 64-bit integers on this platform!\n"); 00252 #endif 00253 if (sizeof (int64) != SIZEOF_INT64) { 00254 rprintf(f, 00255 "WARNING: size mismatch in SIZEOF_INT64 define (%d != %d)\n", 00256 (int) SIZEOF_INT64, (int) sizeof (int64)); 00257 } 00258 00259 rprintf(f,"\nrsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"); 00260 rprintf(f,"are welcome to redistribute it under certain conditions. See the GNU\n"); 00261 rprintf(f,"General Public Licence for details.\n"); 00262 }
void usage | ( | enum logcode | F | ) |
参照先 print_rsync_version()・rprintf().
参照元 main()・parse_arguments()・start_client().
00266 { 00267 print_rsync_version(F); 00268 00269 rprintf(F,"\nrsync is a file transfer program capable of efficient remote update\n"); 00270 rprintf(F,"via a fast differencing algorithm.\n"); 00271 00272 rprintf(F,"\nUsage: rsync [OPTION]... SRC [SRC]... DEST\n"); 00273 rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n"); 00274 rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n"); 00275 rprintf(F," or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST\n"); 00276 rprintf(F," or rsync [OPTION]... [USER@]HOST:SRC [DEST]\n"); 00277 rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n"); 00278 rprintf(F," or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n"); 00279 rprintf(F,"The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect\n"); 00280 rprintf(F,"to an rsync daemon, and require SRC or DEST to start with a module name.\n"); 00281 rprintf(F,"\nOptions\n"); 00282 rprintf(F," -v, --verbose increase verbosity\n"); 00283 rprintf(F," -q, --quiet suppress non-error messages\n"); 00284 rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n"); 00285 rprintf(F," -a, --archive archive mode; same as -rlptgoD (no -H)\n"); 00286 rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n"); 00287 rprintf(F," -r, --recursive recurse into directories\n"); 00288 rprintf(F," -R, --relative use relative path names\n"); 00289 rprintf(F," --no-implied-dirs don't send implied dirs with --relative\n"); 00290 rprintf(F," -b, --backup make backups (see --suffix & --backup-dir)\n"); 00291 rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n"); 00292 rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX); 00293 rprintf(F," -u, --update skip files that are newer on the receiver\n"); 00294 rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n"); 00295 rprintf(F," --append append data onto shorter files\n"); 00296 rprintf(F," -d, --dirs transfer directories without recursing\n"); 00297 rprintf(F," -l, --links copy symlinks as symlinks\n"); 00298 rprintf(F," -L, --copy-links transform symlink into referent file/dir\n"); 00299 rprintf(F," --copy-unsafe-links only \"unsafe\" symlinks are transformed\n"); 00300 rprintf(F," --safe-links ignore symlinks that point outside the source tree\n"); 00301 rprintf(F," -k, --copy-dirlinks transform symlink to a dir into referent dir\n"); 00302 rprintf(F," -K, --keep-dirlinks treat symlinked dir on receiver as dir\n"); 00303 rprintf(F," -H, --hard-links preserve hard links\n"); 00304 rprintf(F," -p, --perms preserve permissions\n"); 00305 rprintf(F," -E, --executability preserve the file's executability\n"); 00306 #ifdef SUPPORT_ACLS 00307 rprintf(F," -A, --acls preserve ACLs (implies --perms)\n"); 00308 #endif 00309 #ifdef SUPPORT_XATTRS 00310 rprintf(F," -X, --xattrs preserve extended attributes (implies --perms)\n"); 00311 #endif 00312 rprintf(F," --chmod=CHMOD change destination permissions\n"); 00313 rprintf(F," -o, --owner preserve owner (super-user only)\n"); 00314 rprintf(F," -g, --group preserve group\n"); 00315 rprintf(F," --devices preserve device files (super-user only)\n"); 00316 rprintf(F," --specials preserve special files\n"); 00317 rprintf(F," -D same as --devices --specials\n"); 00318 rprintf(F," -t, --times preserve times\n"); 00319 rprintf(F," -O, --omit-dir-times omit directories when preserving times\n"); 00320 rprintf(F," --super receiver attempts super-user activities\n"); 00321 rprintf(F," -S, --sparse handle sparse files efficiently\n"); 00322 rprintf(F," -n, --dry-run show what would have been transferred\n"); 00323 rprintf(F," -W, --whole-file copy files whole (without rsync algorithm)\n"); 00324 rprintf(F," -x, --one-file-system don't cross filesystem boundaries\n"); 00325 rprintf(F," -B, --block-size=SIZE force a fixed checksum block-size\n"); 00326 rprintf(F," -e, --rsh=COMMAND specify the remote shell to use\n"); 00327 rprintf(F," --rsync-path=PROGRAM specify the rsync to run on the remote machine\n"); 00328 rprintf(F," --existing ignore non-existing files on receiving side\n"); 00329 rprintf(F," --ignore-existing ignore files that already exist on receiving side\n"); 00330 rprintf(F," --remove-sent-files sent files/symlinks are removed from sending side\n"); 00331 rprintf(F," --del an alias for --delete-during\n"); 00332 rprintf(F," --delete delete files that don't exist on the sending side\n"); 00333 rprintf(F," --delete-before receiver deletes before transfer (default)\n"); 00334 rprintf(F," --delete-during receiver deletes during transfer, not before\n"); 00335 rprintf(F," --delete-after receiver deletes after transfer, not before\n"); 00336 rprintf(F," --delete-excluded also delete excluded files on the receiving side\n"); 00337 rprintf(F," --ignore-errors delete even if there are I/O errors\n"); 00338 rprintf(F," --force force deletion of directories even if not empty\n"); 00339 rprintf(F," --max-delete=NUM don't delete more than NUM files\n"); 00340 rprintf(F," --max-size=SIZE don't transfer any file larger than SIZE\n"); 00341 rprintf(F," --min-size=SIZE don't transfer any file smaller than SIZE\n"); 00342 rprintf(F," --partial keep partially transferred files\n"); 00343 rprintf(F," --partial-dir=DIR put a partially transferred file into DIR\n"); 00344 rprintf(F," --delay-updates put all updated files into place at transfer's end\n"); 00345 rprintf(F," -m, --prune-empty-dirs prune empty directory chains from the file-list\n"); 00346 rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n"); 00347 rprintf(F," --timeout=TIME set I/O timeout in seconds\n"); 00348 rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n"); 00349 rprintf(F," --size-only skip files that match in size\n"); 00350 rprintf(F," --modify-window=NUM compare mod-times with reduced accuracy\n"); 00351 rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n"); 00352 rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n"); 00353 rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n"); 00354 rprintf(F," --copy-dest=DIR ... and include copies of unchanged files\n"); 00355 rprintf(F," --link-dest=DIR hardlink to files in DIR when unchanged\n"); 00356 rprintf(F," -z, --compress compress file data during the transfer\n"); 00357 rprintf(F," --compress-level=NUM explicitly set compression level\n"); 00358 rprintf(F," -C, --cvs-exclude auto-ignore files the same way CVS does\n"); 00359 rprintf(F," -f, --filter=RULE add a file-filtering RULE\n"); 00360 rprintf(F," -F same as --filter='dir-merge /.rsync-filter'\n"); 00361 rprintf(F," repeated: --filter='- .rsync-filter'\n"); 00362 rprintf(F," --exclude=PATTERN exclude files matching PATTERN\n"); 00363 rprintf(F," --exclude-from=FILE read exclude patterns from FILE\n"); 00364 rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n"); 00365 rprintf(F," --include-from=FILE read include patterns from FILE\n"); 00366 rprintf(F," --files-from=FILE read list of source-file names from FILE\n"); 00367 rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n"); 00368 rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n"); 00369 rprintf(F," --port=PORT specify double-colon alternate port number\n"); 00370 rprintf(F," --sockopts=OPTIONS specify custom TCP options\n"); 00371 rprintf(F," --blocking-io use blocking I/O for the remote shell\n"); 00372 rprintf(F," --stats give some file-transfer stats\n"); 00373 rprintf(F," -8, --8-bit-output leave high-bit chars unescaped in output\n"); 00374 rprintf(F," -h, --human-readable output numbers in a human-readable format\n"); 00375 rprintf(F," --progress show progress during transfer\n"); 00376 rprintf(F," -P same as --partial --progress\n"); 00377 rprintf(F," -i, --itemize-changes output a change-summary for all updates\n"); 00378 rprintf(F," --log-format=FORMAT output filenames using the specified format\n"); 00379 rprintf(F," --password-file=FILE read password from FILE\n"); 00380 rprintf(F," --list-only list the files instead of copying them\n"); 00381 rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); 00382 rprintf(F," --write-batch=FILE write a batched update to FILE\n"); 00383 rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); 00384 rprintf(F," --read-batch=FILE read a batched update from FILE\n"); 00385 rprintf(F," --protocol=NUM force an older protocol version to be used\n"); 00386 #ifdef INET6 00387 rprintf(F," -4, --ipv4 prefer IPv4\n"); 00388 rprintf(F," -6, --ipv6 prefer IPv6\n"); 00389 #endif 00390 rprintf(F," --version print version number\n"); 00391 rprintf(F,"(-h) --help show this help (-h works with no other options)\n"); 00392 00393 rprintf(F,"\nUse \"rsync --daemon --help\" to see the daemon-mode command-line options.\n"); 00394 rprintf(F,"Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.\n"); 00395 rprintf(F,"See http://rsync.samba.org/ for updates, bug reports, and answers\n"); 00396 }
static void daemon_usage | ( | enum logcode | F | ) | [static] |
参照先 print_rsync_version()・rprintf().
参照元 parse_arguments().
00558 { 00559 print_rsync_version(F); 00560 00561 rprintf(F,"\nUsage: rsync --daemon [OPTION]...\n"); 00562 rprintf(F," --address=ADDRESS bind to the specified address\n"); 00563 rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); 00564 rprintf(F," --config=FILE specify alternate rsyncd.conf file\n"); 00565 rprintf(F," --no-detach do not detach from the parent\n"); 00566 rprintf(F," --port=PORT listen on alternate port number\n"); 00567 rprintf(F," --sockopts=OPTIONS specify custom TCP options\n"); 00568 rprintf(F," -v, --verbose increase verbosity\n"); 00569 #ifdef INET6 00570 rprintf(F," -4, --ipv4 prefer IPv4\n"); 00571 rprintf(F," -6, --ipv6 prefer IPv6\n"); 00572 #endif 00573 rprintf(F," --help show this help screen\n"); 00574 00575 rprintf(F,"\nIf you were not trying to invoke rsync as a daemon, avoid using any of the\n"); 00576 rprintf(F,"daemon-specific rsync options. See also the rsyncd.conf(5) man page.\n"); 00577 }
void option_error | ( | void | ) |
Store the option error message, if any, so that we can log the connection attempt (which requires parsing the options), and then show the error later on.
参照先 err_buf・FERROR・msleep()・rprintf().
参照元 main()・rsync_module().
00613 { 00614 if (!err_buf[0]) { 00615 strcpy(err_buf, "Error parsing options: " 00616 "option may be supported on client but not on server?\n"); 00617 } 00618 00619 rprintf(FERROR, RSYNC_NAME ": %s", err_buf); 00620 msleep(20); 00621 }
static void set_refuse_options | ( | char * | bp | ) | [static] |
Tweak the option table to disable all options that the rsyncd.conf file has told us to refuse.
参照先 FLOG・long_options・OPT_DAEMON・OPT_REFUSED_BASE・refused_archive_part・refused_compress・refused_delete・refused_delete_before・refused_inplace・refused_partial・refused_progress・rprintf()・strpbrk()・wildmatch().
参照元 parse_arguments().
00629 { 00630 struct poptOption *op; 00631 char *cp, shortname[2]; 00632 int is_wild, found_match; 00633 00634 shortname[1] = '\0'; 00635 00636 while (1) { 00637 while (*bp == ' ') bp++; 00638 if (!*bp) 00639 break; 00640 if ((cp = strchr(bp, ' ')) != NULL) 00641 *cp= '\0'; 00642 is_wild = strpbrk(bp, "*?[") != NULL; 00643 found_match = 0; 00644 for (op = long_options; ; op++) { 00645 *shortname = op->shortName; 00646 if (!op->longName && !*shortname) 00647 break; 00648 if ((op->longName && wildmatch(bp, op->longName)) 00649 || (*shortname && wildmatch(bp, shortname))) { 00650 if (op->argInfo == POPT_ARG_VAL) 00651 op->argInfo = POPT_ARG_NONE; 00652 op->val = (op - long_options) + OPT_REFUSED_BASE; 00653 found_match = 1; 00654 /* These flags are set to let us easily check 00655 * an implied option later in the code. */ 00656 switch (*shortname) { 00657 case 'r': case 'd': case 'l': case 'p': 00658 case 't': case 'g': case 'o': case 'D': 00659 refused_archive_part = op->val; 00660 break; 00661 case 'z': 00662 refused_compress = op->val; 00663 break; 00664 case '\0': 00665 if (wildmatch("delete", op->longName)) 00666 refused_delete = op->val; 00667 else if (wildmatch("delete-before", op->longName)) 00668 refused_delete_before = op->val; 00669 else if (wildmatch("partial", op->longName)) 00670 refused_partial = op->val; 00671 else if (wildmatch("progress", op->longName)) 00672 refused_progress = op->val; 00673 else if (wildmatch("inplace", op->longName)) 00674 refused_inplace = op->val; 00675 break; 00676 } 00677 if (!is_wild) 00678 break; 00679 } 00680 } 00681 if (!found_match) { 00682 rprintf(FLOG, "No match for refuse-options string \"%s\"\n", 00683 bp); 00684 } 00685 if (!cp) 00686 break; 00687 *cp = ' '; 00688 bp = cp + 1; 00689 } 00690 00691 for (op = long_options; ; op++) { 00692 *shortname = op->shortName; 00693 if (!op->longName && !*shortname) 00694 break; 00695 if (op->val == OPT_DAEMON) { 00696 if (op->argInfo == POPT_ARG_VAL) 00697 op->argInfo = POPT_ARG_NONE; 00698 op->val = (op - long_options) + OPT_REFUSED_BASE; 00699 } 00700 } 00701 }
static int count_args | ( | const char ** | argv | ) | [static] |
参照元 parse_arguments().
00705 { 00706 int i = 0; 00707 00708 if (argv) { 00709 while (argv[i] != NULL) 00710 i++; 00711 } 00712 00713 return i; 00714 }
static OFF_T parse_size_arg | ( | char ** | size_arg, | |
char | def_suf | |||
) | [static] |
参照先 buf・out_of_memory()・strdup().
参照元 parse_arguments().
00718 { 00719 int reps, mult, make_compatible = 0; 00720 const char *arg; 00721 OFF_T size = 1; 00722 00723 for (arg = *size_arg; isdigit(*(uchar*)arg); arg++) {} 00724 if (*arg == '.') 00725 for (arg++; isdigit(*(uchar*)arg); arg++) {} 00726 switch (*arg && *arg != '+' && *arg != '-' ? *arg++ : def_suf) { 00727 case 'b': case 'B': 00728 reps = 0; 00729 break; 00730 case 'k': case 'K': 00731 reps = 1; 00732 break; 00733 case 'm': case 'M': 00734 reps = 2; 00735 break; 00736 case 'g': case 'G': 00737 reps = 3; 00738 break; 00739 default: 00740 return -1; 00741 } 00742 if (*arg == 'b' || *arg == 'B') 00743 mult = 1000, make_compatible = 1, arg++; 00744 else if (!*arg || *arg == '+' || *arg == '-') 00745 mult = 1024; 00746 else if (strncasecmp(arg, "ib", 2) == 0) 00747 mult = 1024, arg += 2; 00748 else 00749 return -1; 00750 while (reps--) 00751 size *= mult; 00752 size *= atof(*size_arg); 00753 if ((*arg == '+' || *arg == '-') && arg[1] == '1') 00754 size += atoi(arg), make_compatible = 1, arg += 2; 00755 if (*arg) 00756 return -1; 00757 if (size > 0 && make_compatible) { 00758 /* We convert this manually because we may need %lld precision, 00759 * and that's not a portable sprintf() escape. */ 00760 char buf[128], *s = buf + sizeof buf - 1; 00761 OFF_T num = size; 00762 *s = '\0'; 00763 while (num) { 00764 *--s = (num % 10) + '0'; 00765 num /= 10; 00766 } 00767 if (!(*size_arg = strdup(s))) 00768 out_of_memory("parse_size_arg"); 00769 } 00770 return size; 00771 }
static void create_refuse_error | ( | int | which | ) | [static] |
参照先 err_buf・long_options・OPT_REFUSED_BASE・snprintf().
参照元 parse_arguments().
00775 { 00776 /* The "which" value is the index + OPT_REFUSED_BASE. */ 00777 struct poptOption *op = &long_options[which - OPT_REFUSED_BASE]; 00778 int n = snprintf(err_buf, sizeof err_buf, 00779 "The server is configured to refuse --%s\n", 00780 op->longName) - 1; 00781 if (op->shortName) { 00782 snprintf(err_buf + n, sizeof err_buf - n, 00783 " (-%c)\n", op->shortName); 00784 } 00785 }
int parse_arguments | ( | int * | argc, | |
const char *** | argv, | |||
int | frommain | |||
) |
Process command line arguments.
Called on both local and remote.
1 | if all options are OK; with globals set to appropriate values | |
0 | on error, with err_buf containing an explanation |
参照先 am_daemon・am_sender・am_server・am_starting_up・backup_dir・basis_dir・basis_dir_cnt・batch_name・check_filter()・chmod_modes・clean_fname()・compare_dest・copy_dest・count_args()・create_refuse_error()・daemon_opt・daemon_usage()・def_compress_level・delete_after・delete_before・delete_during・delete_excluded・delete_mode・dest_option・do_compression・do_progress・dry_run・err_buf・F_option_cnt・FERROR・files_from・filter_list・FINFO・filter_list_struct::head・human_readable・implied_dirs・itemize_changes・keep_partial・link_dest・list_only・long_daemon_options・long_options・max_size・max_size_arg・min_size・min_size_arg・modify_window_set・module_id・need_messages_from_generator・one_file_system・OPT_CHMOD・OPT_COMPARE_DEST・OPT_COPY_DEST・OPT_DAEMON・OPT_EXCLUDE・OPT_EXCLUDE_FROM・OPT_FILTER・OPT_HELP・OPT_INCLUDE・OPT_INCLUDE_FROM・OPT_LINK_DEST・OPT_MAX_SIZE・OPT_MIN_SIZE・OPT_MODIFY_WINDOW・OPT_NO_D・OPT_ONLY_WRITE_BATCH・OPT_READ_BATCH・OPT_REFUSED_BASE・OPT_SENDER・OPT_SERVER・OPT_VERSION・OPT_WRITE_BATCH・parse_chmod()・parse_filter_file()・parse_rule()・parse_size_arg()・partial_dir・preserve_acls・preserve_devices・preserve_gid・preserve_hard_links・preserve_links・preserve_perms・preserve_specials・preserve_times・preserve_uid・preserve_xattrs・print_rsync_version()・quiet・read_batch・recurse・refused_archive_part・refused_compress・refused_delete・refused_delete_before・refused_partial・refused_progress・relative_paths・remove_sent_files・rprintf()・sanitize_path()・sanitize_paths・server_filter_list・set_refuse_options()・snprintf()・tmpdir・usage()・verbose・write_batch・xfer_dirs.
参照元 main()・rsync_module().
00797 { 00798 int opt; 00799 char *ref = lp_refuse_options(module_id); 00800 const char *arg; 00801 poptContext pc; 00802 00803 if (ref && *ref) 00804 set_refuse_options(ref); 00805 00806 /* TODO: Call poptReadDefaultConfig; handle errors. */ 00807 00808 /* The context leaks in case of an error, but if there's a 00809 * problem we always exit anyhow. */ 00810 pc = poptGetContext(RSYNC_NAME, *argc, *argv, long_options, 0); 00811 poptReadDefaultConfig(pc, 0); 00812 00813 while ((opt = poptGetNextOpt(pc)) != -1) { 00814 /* most options are handled automatically by popt; 00815 * only special cases are returned and listed here. */ 00816 00817 switch (opt) { 00818 case OPT_VERSION: 00819 print_rsync_version(FINFO); 00820 exit_cleanup(0); 00821 00822 case OPT_SERVER: 00823 if (!am_server) { 00824 /* Disable popt aliases on the server side and 00825 * then start parsing the options again. */ 00826 poptFreeContext(pc); 00827 pc = poptGetContext(RSYNC_NAME, *argc, *argv, 00828 long_options, 0); 00829 am_server = 1; 00830 } 00831 break; 00832 00833 case OPT_SENDER: 00834 if (!am_server) { 00835 usage(FERROR); 00836 exit_cleanup(RERR_SYNTAX); 00837 } 00838 am_sender = 1; 00839 break; 00840 00841 case OPT_DAEMON: 00842 if (am_daemon) { 00843 strcpy(err_buf, "Attempt to hack rsync thwarted!\n"); 00844 return 0; 00845 } 00846 poptFreeContext(pc); 00847 pc = poptGetContext(RSYNC_NAME, *argc, *argv, 00848 long_daemon_options, 0); 00849 while ((opt = poptGetNextOpt(pc)) != -1) { 00850 switch (opt) { 00851 case 'h': 00852 daemon_usage(FINFO); 00853 exit_cleanup(0); 00854 00855 case 'v': 00856 verbose++; 00857 break; 00858 00859 default: 00860 rprintf(FERROR, 00861 "rsync: %s: %s (in daemon mode)\n", 00862 poptBadOption(pc, POPT_BADOPTION_NOALIAS), 00863 poptStrerror(opt)); 00864 goto daemon_error; 00865 } 00866 } 00867 00868 if (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) { 00869 snprintf(err_buf, sizeof err_buf, 00870 "the --temp-dir path is WAY too long.\n"); 00871 return 0; 00872 } 00873 00874 if (!daemon_opt) { 00875 rprintf(FERROR, "Daemon option(s) used without --daemon.\n"); 00876 daemon_error: 00877 rprintf(FERROR, 00878 "(Type \"rsync --daemon --help\" for assistance with daemon mode.)\n"); 00879 exit_cleanup(RERR_SYNTAX); 00880 } 00881 00882 *argv = poptGetArgs(pc); 00883 *argc = count_args(*argv); 00884 am_starting_up = 0; 00885 daemon_opt = 0; 00886 am_daemon = 1; 00887 return 1; 00888 00889 case OPT_MODIFY_WINDOW: 00890 /* The value has already been set by popt, but 00891 * we need to remember that we're using a 00892 * non-default setting. */ 00893 modify_window_set = 1; 00894 break; 00895 00896 case OPT_FILTER: 00897 parse_rule(&filter_list, poptGetOptArg(pc), 0, 0); 00898 break; 00899 00900 case OPT_EXCLUDE: 00901 parse_rule(&filter_list, poptGetOptArg(pc), 00902 0, XFLG_OLD_PREFIXES); 00903 break; 00904 00905 case OPT_INCLUDE: 00906 parse_rule(&filter_list, poptGetOptArg(pc), 00907 MATCHFLG_INCLUDE, XFLG_OLD_PREFIXES); 00908 break; 00909 00910 case OPT_EXCLUDE_FROM: 00911 case OPT_INCLUDE_FROM: 00912 arg = poptGetOptArg(pc); 00913 if (sanitize_paths) 00914 arg = sanitize_path(NULL, arg, NULL, 0); 00915 if (server_filter_list.head) { 00916 char *cp = (char *)arg; 00917 if (!*cp) 00918 goto options_rejected; 00919 clean_fname(cp, 1); 00920 if (check_filter(&server_filter_list, cp, 0) < 0) 00921 goto options_rejected; 00922 } 00923 parse_filter_file(&filter_list, arg, 00924 opt == OPT_INCLUDE_FROM ? MATCHFLG_INCLUDE : 0, 00925 XFLG_FATAL_ERRORS | XFLG_OLD_PREFIXES); 00926 break; 00927 00928 case 'a': 00929 if (refused_archive_part) { 00930 create_refuse_error(refused_archive_part); 00931 return 0; 00932 } 00933 if (!recurse) /* preserve recurse == 2 */ 00934 recurse = 1; 00935 #ifdef SUPPORT_LINKS 00936 preserve_links = 1; 00937 #endif 00938 preserve_perms = 1; 00939 preserve_times = 1; 00940 preserve_gid = 1; 00941 preserve_uid = 1; 00942 preserve_devices = 1; 00943 preserve_specials = 1; 00944 break; 00945 00946 case 'D': 00947 preserve_devices = preserve_specials = 1; 00948 break; 00949 00950 case OPT_NO_D: 00951 preserve_devices = preserve_specials = 0; 00952 break; 00953 00954 case 'h': 00955 human_readable++; 00956 break; 00957 00958 case 'i': 00959 itemize_changes++; 00960 break; 00961 00962 case 'v': 00963 verbose++; 00964 break; 00965 00966 case 'q': 00967 if (frommain) 00968 quiet++; 00969 break; 00970 00971 case 'x': 00972 one_file_system++; 00973 break; 00974 00975 case 'F': 00976 switch (++F_option_cnt) { 00977 case 1: 00978 parse_rule(&filter_list,": /.rsync-filter",0,0); 00979 break; 00980 case 2: 00981 parse_rule(&filter_list,"- .rsync-filter",0,0); 00982 break; 00983 } 00984 break; 00985 00986 case 'P': 00987 if (refused_partial || refused_progress) { 00988 create_refuse_error(refused_partial 00989 ? refused_partial : refused_progress); 00990 return 0; 00991 } 00992 do_progress = 1; 00993 keep_partial = 1; 00994 break; 00995 00996 case 'z': 00997 if (def_compress_level < Z_DEFAULT_COMPRESSION 00998 || def_compress_level > Z_BEST_COMPRESSION) { 00999 snprintf(err_buf, sizeof err_buf, 01000 "--compress-level value is invalid: %d\n", 01001 def_compress_level); 01002 return 0; 01003 } 01004 do_compression = def_compress_level != Z_NO_COMPRESSION; 01005 if (do_compression && refused_compress) { 01006 create_refuse_error(refused_compress); 01007 return 0; 01008 } 01009 break; 01010 01011 case OPT_WRITE_BATCH: 01012 /* batch_name is already set */ 01013 write_batch = 1; 01014 break; 01015 01016 case OPT_ONLY_WRITE_BATCH: 01017 /* batch_name is already set */ 01018 write_batch = -1; 01019 break; 01020 01021 case OPT_READ_BATCH: 01022 /* batch_name is already set */ 01023 read_batch = 1; 01024 break; 01025 01026 case OPT_MAX_SIZE: 01027 if ((max_size = parse_size_arg(&max_size_arg, 'b')) <= 0) { 01028 snprintf(err_buf, sizeof err_buf, 01029 "--max-size value is invalid: %s\n", 01030 max_size_arg); 01031 return 0; 01032 } 01033 break; 01034 01035 case OPT_MIN_SIZE: 01036 if ((min_size = parse_size_arg(&min_size_arg, 'b')) <= 0) { 01037 snprintf(err_buf, sizeof err_buf, 01038 "--min-size value is invalid: %s\n", 01039 min_size_arg); 01040 return 0; 01041 } 01042 break; 01043 01044 case OPT_LINK_DEST: 01045 #ifdef HAVE_LINK 01046 link_dest = 1; 01047 dest_option = "--link-dest"; 01048 goto set_dest_dir; 01049 #else 01050 snprintf(err_buf, sizeof err_buf, 01051 "hard links are not supported on this %s\n", 01052 am_server ? "server" : "client"); 01053 return 0; 01054 #endif 01055 01056 case OPT_COPY_DEST: 01057 copy_dest = 1; 01058 dest_option = "--copy-dest"; 01059 goto set_dest_dir; 01060 01061 case OPT_COMPARE_DEST: 01062 compare_dest = 1; 01063 dest_option = "--compare-dest"; 01064 set_dest_dir: 01065 if (basis_dir_cnt >= MAX_BASIS_DIRS) { 01066 snprintf(err_buf, sizeof err_buf, 01067 "ERROR: at most %d %s args may be specified\n", 01068 MAX_BASIS_DIRS, dest_option); 01069 return 0; 01070 } 01071 arg = poptGetOptArg(pc); 01072 if (sanitize_paths) 01073 arg = sanitize_path(NULL, arg, NULL, 0); 01074 basis_dir[basis_dir_cnt++] = (char *)arg; 01075 break; 01076 01077 case OPT_CHMOD: 01078 arg = poptGetOptArg(pc); 01079 if (!parse_chmod(arg, &chmod_modes)) { 01080 snprintf(err_buf, sizeof err_buf, 01081 "Invalid argument passed to --chmod (%s)\n", 01082 arg); 01083 return 0; 01084 } 01085 break; 01086 01087 case OPT_HELP: 01088 usage(FINFO); 01089 exit_cleanup(0); 01090 01091 case 'A': 01092 #ifdef SUPPORT_ACLS 01093 preserve_acls++; 01094 preserve_perms = 1; 01095 break; 01096 #else 01097 /* FIXME: this should probably be ignored with a 01098 * warning and then countermeasures taken to 01099 * restrict group and other access in the presence 01100 * of any more restrictive ACLs, but this is safe 01101 * for now */ 01102 snprintf(err_buf,sizeof(err_buf), 01103 "ACLs are not supported on this %s\n", 01104 am_server ? "server" : "client"); 01105 return 0; 01106 #endif 01107 01108 case 'X': 01109 #ifdef SUPPORT_XATTRS 01110 preserve_xattrs = 1; 01111 preserve_perms = 1; 01112 break; 01113 #else 01114 snprintf(err_buf,sizeof(err_buf), 01115 "extended attributes are not supported on this %s\n", 01116 am_server ? "server" : "client"); 01117 return 0; 01118 #endif /* SUPPORT_XATTRS */ 01119 01120 default: 01121 /* A large opt value means that set_refuse_options() 01122 * turned this option off. */ 01123 if (opt >= OPT_REFUSED_BASE) { 01124 create_refuse_error(opt); 01125 return 0; 01126 } 01127 snprintf(err_buf, sizeof err_buf, "%s%s: %s\n", 01128 am_server ? "on remote machine: " : "", 01129 poptBadOption(pc, POPT_BADOPTION_NOALIAS), 01130 poptStrerror(opt)); 01131 return 0; 01132 } 01133 } 01134 01135 if (human_readable && *argc == 2) { 01136 /* Allow the old meaning of 'h' (--help) on its own. */ 01137 usage(FINFO); 01138 exit_cleanup(0); 01139 } 01140 01141 #ifndef SUPPORT_LINKS 01142 if (preserve_links && !am_sender) { 01143 snprintf(err_buf, sizeof err_buf, 01144 "symlinks are not supported on this %s\n", 01145 am_server ? "server" : "client"); 01146 return 0; 01147 } 01148 #endif 01149 01150 #ifndef SUPPORT_HARD_LINKS 01151 if (preserve_hard_links) { 01152 snprintf(err_buf, sizeof err_buf, 01153 "hard links are not supported on this %s\n", 01154 am_server ? "server" : "client"); 01155 return 0; 01156 } 01157 #endif 01158 01159 if (write_batch && read_batch) { 01160 snprintf(err_buf, sizeof err_buf, 01161 "--write-batch and --read-batch can not be used together\n"); 01162 return 0; 01163 } 01164 if (write_batch > 0 || read_batch) { 01165 if (am_server) { 01166 rprintf(FINFO, 01167 "ignoring --%s-batch option sent to server\n", 01168 write_batch ? "write" : "read"); 01169 /* We don't actually exit_cleanup(), so that we can 01170 * still service older version clients that still send 01171 * batch args to server. */ 01172 read_batch = write_batch = 0; 01173 batch_name = NULL; 01174 } else if (dry_run) 01175 write_batch = 0; 01176 } 01177 if (read_batch && files_from) { 01178 snprintf(err_buf, sizeof err_buf, 01179 "--read-batch cannot be used with --files-from\n"); 01180 return 0; 01181 } 01182 if (batch_name && strlen(batch_name) > MAX_BATCH_NAME_LEN) { 01183 snprintf(err_buf, sizeof err_buf, 01184 "the batch-file name must be %d characters or less.\n", 01185 MAX_BATCH_NAME_LEN); 01186 return 0; 01187 } 01188 01189 if (tmpdir && strlen(tmpdir) >= MAXPATHLEN - 10) { 01190 snprintf(err_buf, sizeof err_buf, 01191 "the --temp-dir path is WAY too long.\n"); 01192 return 0; 01193 } 01194 01195 if (compare_dest + copy_dest + link_dest > 1) { 01196 snprintf(err_buf, sizeof err_buf, 01197 "You may not mix --compare-dest, --copy-dest, and --link-dest.\n"); 01198 return 0; 01199 } 01200 01201 if (files_from) { 01202 if (recurse == 1) /* preserve recurse == 2 */ 01203 recurse = 0; 01204 if (xfer_dirs < 0) 01205 xfer_dirs = 1; 01206 } 01207 01208 if (xfer_dirs < 1) 01209 xfer_dirs = recurse || list_only; 01210 01211 if (relative_paths < 0) 01212 relative_paths = files_from? 1 : 0; 01213 if (!relative_paths) 01214 implied_dirs = 0; 01215 01216 if (!!delete_before + delete_during + delete_after > 1) { 01217 snprintf(err_buf, sizeof err_buf, 01218 "You may not combine multiple --delete-WHEN options.\n"); 01219 return 0; 01220 } 01221 if (delete_before || delete_during || delete_after) 01222 delete_mode = 1; 01223 else if (delete_mode || delete_excluded) { 01224 if (refused_delete_before) { 01225 create_refuse_error(refused_delete_before); 01226 return 0; 01227 } 01228 delete_mode = delete_before = 1; 01229 } 01230 if (!xfer_dirs && delete_mode) { 01231 snprintf(err_buf, sizeof err_buf, 01232 "--delete does not work without -r or -d.\n"); 01233 return 0; 01234 } 01235 01236 if (delete_mode && refused_delete) { 01237 create_refuse_error(refused_delete); 01238 return 0; 01239 } 01240 01241 if (remove_sent_files) { 01242 /* We only want to infer this refusal of --remove-sent-files 01243 * via the refusal of "delete", not any of the "delete-FOO" 01244 * options. */ 01245 if (refused_delete && am_sender) { 01246 create_refuse_error(refused_delete); 01247 return 0; 01248 } 01249 need_messages_from_generator = 1; 01250 } 01251 01252 *argv = poptGetArgs(pc); 01253 *argc = count_args(*argv); 01254 01255 if (sanitize_paths) { 01256 int i; 01257 for (i = *argc; i-- > 0; ) 01258 (*argv)[i] = sanitize_path(NULL, (*argv)[i], "", 0); 01259 if (tmpdir) 01260 tmpdir = sanitize_path(NULL, tmpdir, NULL, 0); 01261 if (partial_dir) 01262 partial_dir = sanitize_path(NULL, partial_dir, NULL, 0); 01263 if (backup_dir) 01264 backup_dir = sanitize_path(NULL, backup_dir, NULL, 0); 01265 } 01266 if (server_filter_list.head && !am_sender) { 01267 struct filter_list_struct *elp = &server_filter_list; 01268 int i; 01269 if (tmpdir) { 01270 if (!*tmpdir) 01271 goto options_rejected; 01272 clean_fname(tmpdir, 1); 01273 if (check_filter(elp, tmpdir, 1) < 0) 01274 goto options_rejected; 01275 } 01276 if (partial_dir && *partial_dir) { 01277 clean_fname(partial_dir, 1); 01278 if (check_filter(elp, partial_dir, 1) < 0) 01279 goto options_rejected; 01280 } 01281 for (i = 0; i < basis_dir_cnt; i++) { 01282 if (!*basis_dir[i]) 01283 goto options_rejected; 01284 clean_fname(basis_dir[i], 1); 01285 if (check_filter(elp, basis_dir[i], 1) < 0) 01286 goto options_rejected; 01287 } 01288 if (backup_dir) { 01289 if (!*backup_dir) 01290 goto options_rejected; 01291 clean_fname(backup_dir, 1); 01292 if (check_filter(elp, backup_dir, 1) < 0) { 01293 options_rejected: 01294 snprintf(err_buf, sizeof err_buf, 01295 "Your options have been rejected by the server.\n"); 01296 return 0; 01297 } 01298 } 01299 } 01300 01301 if (!backup_suffix) 01302 backup_suffix = backup_dir ? "" : BACKUP_SUFFIX; 01303 backup_suffix_len = strlen(backup_suffix); 01304 if (strchr(backup_suffix, '/') != NULL) { 01305 snprintf(err_buf, sizeof err_buf, 01306 "--suffix cannot contain slashes: %s\n", 01307 backup_suffix); 01308 return 0; 01309 } 01310 if (backup_dir) { 01311 backup_dir_len = strlcpy(backup_dir_buf, backup_dir, sizeof backup_dir_buf); 01312 backup_dir_remainder = sizeof backup_dir_buf - backup_dir_len; 01313 if (backup_dir_remainder < 32) { 01314 snprintf(err_buf, sizeof err_buf, 01315 "the --backup-dir path is WAY too long.\n"); 01316 return 0; 01317 } 01318 if (backup_dir_buf[backup_dir_len - 1] != '/') { 01319 backup_dir_buf[backup_dir_len++] = '/'; 01320 backup_dir_buf[backup_dir_len] = '\0'; 01321 } 01322 if (verbose > 1 && !am_sender) 01323 rprintf(FINFO, "backup_dir is %s\n", backup_dir_buf); 01324 } else if (!backup_suffix_len && (!am_server || !am_sender)) { 01325 snprintf(err_buf, sizeof err_buf, 01326 "--suffix cannot be a null string without --backup-dir\n"); 01327 return 0; 01328 } else if (make_backups && delete_mode && !delete_excluded) { 01329 snprintf(backup_dir_buf, sizeof backup_dir_buf, 01330 "P *%s", backup_suffix); 01331 parse_rule(&filter_list, backup_dir_buf, 0, 0); 01332 } 01333 if (make_backups && !backup_dir) 01334 omit_dir_times = 1; 01335 01336 if (log_format) { 01337 if (am_server && log_format_has(log_format, 'I')) 01338 log_format_has_i = 2; 01339 else if (log_format_has(log_format, 'i')) 01340 log_format_has_i = itemize_changes | 1; 01341 if (!log_format_has(log_format, 'b') 01342 && !log_format_has(log_format, 'c')) 01343 log_before_transfer = !am_server; 01344 } else if (itemize_changes) { 01345 log_format = "%i %n%L"; 01346 log_format_has_i = itemize_changes; 01347 log_before_transfer = !am_server; 01348 } 01349 01350 if (do_progress && !verbose && !log_before_transfer && !am_server) 01351 verbose = 1; 01352 01353 if (dry_run) 01354 do_xfers = 0; 01355 01356 set_io_timeout(io_timeout); 01357 01358 if (verbose && !log_format) { 01359 log_format = "%n%L"; 01360 log_before_transfer = !am_server; 01361 } 01362 if (log_format_has_i || log_format_has(log_format, 'o')) 01363 log_format_has_o_or_i = 1; 01364 01365 if (daemon_bwlimit && (!bwlimit || bwlimit > daemon_bwlimit)) 01366 bwlimit = daemon_bwlimit; 01367 if (bwlimit) { 01368 bwlimit_writemax = (size_t)bwlimit * 128; 01369 if (bwlimit_writemax < 512) 01370 bwlimit_writemax = 512; 01371 } 01372 01373 if (sparse_files && inplace) { 01374 /* Note: we don't check for this below, because --append is 01375 * OK with --sparse (as long as redos are handled right). */ 01376 snprintf(err_buf, sizeof err_buf, 01377 "--sparse cannot be used with --inplace\n"); 01378 return 0; 01379 } 01380 01381 if (append_mode) { 01382 if (whole_file > 0) { 01383 snprintf(err_buf, sizeof err_buf, 01384 "--append cannot be used with --whole-file\n"); 01385 return 0; 01386 } 01387 if (refused_inplace) { 01388 create_refuse_error(refused_inplace); 01389 return 0; 01390 } 01391 inplace = 1; 01392 } 01393 01394 if (delay_updates && !partial_dir) 01395 partial_dir = tmp_partialdir; 01396 01397 if (inplace) { 01398 #ifdef HAVE_FTRUNCATE 01399 if (partial_dir) { 01400 snprintf(err_buf, sizeof err_buf, 01401 "--%s cannot be used with --%s\n", 01402 append_mode ? "append" : "inplace", 01403 delay_updates ? "delay-updates" : "partial-dir"); 01404 return 0; 01405 } 01406 /* --inplace implies --partial for refusal purposes, but we 01407 * clear the keep_partial flag for internal logic purposes. */ 01408 if (refused_partial) { 01409 create_refuse_error(refused_partial); 01410 return 0; 01411 } 01412 keep_partial = 0; 01413 #else 01414 snprintf(err_buf, sizeof err_buf, 01415 "--%s is not supported on this %s\n", 01416 append_mode ? "append" : "inplace", 01417 am_server ? "server" : "client"); 01418 return 0; 01419 #endif 01420 } else { 01421 if (keep_partial && !partial_dir && !am_server) { 01422 if ((arg = getenv("RSYNC_PARTIAL_DIR")) != NULL && *arg) 01423 partial_dir = strdup(arg); 01424 } 01425 if (partial_dir) { 01426 if (*partial_dir) 01427 clean_fname(partial_dir, 1); 01428 if (!*partial_dir || strcmp(partial_dir, ".") == 0) 01429 partial_dir = NULL; 01430 else if (*partial_dir != '/') { 01431 parse_rule(&filter_list, partial_dir, 01432 MATCHFLG_NO_PREFIXES|MATCHFLG_DIRECTORY, 0); 01433 } 01434 if (!partial_dir && refused_partial) { 01435 create_refuse_error(refused_partial); 01436 return 0; 01437 } 01438 keep_partial = 1; 01439 } 01440 } 01441 01442 if (files_from) { 01443 char *h, *p; 01444 int q; 01445 if (*argc > 2 || (!am_daemon && *argc == 1)) { 01446 usage(FERROR); 01447 exit_cleanup(RERR_SYNTAX); 01448 } 01449 if (strcmp(files_from, "-") == 0) { 01450 filesfrom_fd = 0; 01451 if (am_server) 01452 filesfrom_host = ""; /* reading from socket */ 01453 } else if ((p = check_for_hostspec(files_from, &h, &q)) != 0) { 01454 if (am_server) { 01455 snprintf(err_buf, sizeof err_buf, 01456 "The --files-from sent to the server cannot specify a host.\n"); 01457 return 0; 01458 } 01459 files_from = p; 01460 filesfrom_host = h; 01461 if (strcmp(files_from, "-") == 0) { 01462 snprintf(err_buf, sizeof err_buf, 01463 "Invalid --files-from remote filename\n"); 01464 return 0; 01465 } 01466 } else { 01467 if (sanitize_paths) 01468 files_from = sanitize_path(NULL, files_from, NULL, 0); 01469 if (server_filter_list.head) { 01470 if (!*files_from) 01471 goto options_rejected; 01472 clean_fname(files_from, 1); 01473 if (check_filter(&server_filter_list, files_from, 0) < 0) 01474 goto options_rejected; 01475 } 01476 filesfrom_fd = open(files_from, O_RDONLY|O_BINARY); 01477 if (filesfrom_fd < 0) { 01478 snprintf(err_buf, sizeof err_buf, 01479 "failed to open files-from file %s: %s\n", 01480 files_from, strerror(errno)); 01481 return 0; 01482 } 01483 } 01484 } 01485 01486 am_starting_up = 0; 01487 01488 return 1; 01489 }
void server_options | ( | char ** | args, | |
int * | argc | |||
) |
Construct a filtered list of options to pass through from the client to the server.
This involves setting options that will tell the server how to behave, and also filtering out options that are processed only locally.
参照先 always_checksum・am_root・am_sender・append_mode・asprintf()・backup_dir・backup_suffix・basis_dir・basis_dir_cnt・block_size・blocking_io・bwlimit・checksum_seed・copy_dirlinks・copy_links・copy_unsafe_links・cvs_exclude・daemon_over_rsh・def_compress_level・delay_updates・delete_after・delete_before・delete_during・delete_excluded・delete_mode・dest_option・do_compression・do_xfers・eol_nulls・files_from・filesfrom_host・force_delete・fuzzy_basis・ignore_errors・ignore_existing・ignore_non_existing・ignore_times・implied_dirs・inplace・io_timeout・keep_dirlinks・keep_partial・list_only・log_format・log_format_has_i・log_format_has_o_or_i・make_backups・max_delete・max_size・max_size_arg・min_size・min_size_arg・modify_window・modify_window_set・numeric_ids・omit_dir_times・one_file_system・out_of_memory()・preserve_acls・preserve_devices・preserve_executability・preserve_gid・preserve_hard_links・preserve_links・preserve_perms・preserve_specials・preserve_times・preserve_uid・preserve_xattrs・prune_empty_dirs・recurse・relative_paths・remove_sent_files・safe_symlinks・size_only・sparse_files・tmp_partialdir・tmpdir・update_only・verbose・whole_file・write_batch・xfer_dirs.
参照元 do_cmd()・start_inband_exchange().
01501 { 01502 static char argstr[64]; 01503 int ac = *argc; 01504 char *arg; 01505 01506 int i, x; 01507 01508 if (blocking_io == -1) 01509 blocking_io = 0; 01510 01511 /* This should always remain first on the server's command-line. */ 01512 args[ac++] = "--server"; 01513 01514 if (daemon_over_rsh) { 01515 args[ac++] = "--daemon"; 01516 *argc = ac; 01517 /* if we're passing --daemon, we're done */ 01518 return; 01519 } 01520 01521 if (!am_sender) 01522 args[ac++] = "--sender"; 01523 01524 x = 1; 01525 argstr[0] = '-'; 01526 for (i = 0; i < verbose; i++) 01527 argstr[x++] = 'v'; 01528 01529 /* the -q option is intentionally left out */ 01530 if (make_backups) 01531 argstr[x++] = 'b'; 01532 if (update_only) 01533 argstr[x++] = 'u'; 01534 if (!do_xfers) /* Note: NOT "dry_run"! */ 01535 argstr[x++] = 'n'; 01536 if (preserve_links) 01537 argstr[x++] = 'l'; 01538 if (xfer_dirs > (recurse || !delete_mode || !am_sender)) 01539 argstr[x++] = 'd'; 01540 if (am_sender) { 01541 if (keep_dirlinks) 01542 argstr[x++] = 'K'; 01543 if (prune_empty_dirs) 01544 argstr[x++] = 'm'; 01545 if (omit_dir_times == 2) 01546 argstr[x++] = 'O'; 01547 } else { 01548 if (copy_links) 01549 argstr[x++] = 'L'; 01550 if (copy_dirlinks) 01551 argstr[x++] = 'k'; 01552 } 01553 01554 if (whole_file > 0) 01555 argstr[x++] = 'W'; 01556 /* We don't need to send --no-whole-file, because it's the 01557 * default for remote transfers, and in any case old versions 01558 * of rsync will not understand it. */ 01559 01560 if (preserve_hard_links) 01561 argstr[x++] = 'H'; 01562 #ifdef SUPPORT_ACLS 01563 if (preserve_acls) 01564 argstr[x++] = 'A'; 01565 #endif 01566 #ifdef SUPPORT_XATTRS 01567 if (preserve_xattrs) 01568 argstr[x++] = 'X'; 01569 #endif 01570 if (preserve_uid) 01571 argstr[x++] = 'o'; 01572 if (preserve_gid) 01573 argstr[x++] = 'g'; 01574 if (preserve_devices) /* ignore preserve_specials here */ 01575 argstr[x++] = 'D'; 01576 if (preserve_times) 01577 argstr[x++] = 't'; 01578 if (preserve_perms) 01579 argstr[x++] = 'p'; 01580 else if (preserve_executability && am_sender) 01581 argstr[x++] = 'E'; 01582 if (recurse) 01583 argstr[x++] = 'r'; 01584 if (always_checksum) 01585 argstr[x++] = 'c'; 01586 if (cvs_exclude) 01587 argstr[x++] = 'C'; 01588 if (ignore_times) 01589 argstr[x++] = 'I'; 01590 if (relative_paths) 01591 argstr[x++] = 'R'; 01592 if (one_file_system) { 01593 argstr[x++] = 'x'; 01594 if (one_file_system > 1) 01595 argstr[x++] = 'x'; 01596 } 01597 if (sparse_files) 01598 argstr[x++] = 'S'; 01599 if (do_compression) 01600 argstr[x++] = 'z'; 01601 01602 /* This is a complete hack - blame Rusty. FIXME! 01603 * This hack is only needed for older rsync versions that 01604 * don't understand the --list-only option. */ 01605 if (list_only == 1 && !recurse) 01606 argstr[x++] = 'r'; 01607 01608 argstr[x] = '\0'; 01609 01610 if (x != 1) 01611 args[ac++] = argstr; 01612 01613 if (list_only > 1) 01614 args[ac++] = "--list-only"; 01615 01616 /* This makes sure that the remote rsync can handle deleting with -d 01617 * sans -r because the --no-r option was added at the same time. */ 01618 if (xfer_dirs && !recurse && delete_mode && am_sender) 01619 args[ac++] = "--no-r"; 01620 01621 if (do_compression && def_compress_level != Z_DEFAULT_COMPRESSION) { 01622 if (asprintf(&arg, "--compress-level=%d", def_compress_level) < 0) 01623 goto oom; 01624 args[ac++] = arg; 01625 } 01626 01627 if (preserve_devices) { 01628 /* Note: sending "--devices" would not be backward-compatible. */ 01629 if (!preserve_specials) 01630 args[ac++] = "--no-specials"; /* -D is already set. */ 01631 } else if (preserve_specials) 01632 args[ac++] = "--specials"; 01633 01634 /* The server side doesn't use our log-format, but in certain 01635 * circumstances they need to know a little about the option. */ 01636 if (log_format && am_sender) { 01637 if (log_format_has_i > 1) 01638 args[ac++] = "--log-format=%i%I"; 01639 else if (log_format_has_i) 01640 args[ac++] = "--log-format=%i"; 01641 else if (log_format_has_o_or_i) 01642 args[ac++] = "--log-format=%o"; 01643 else if (!verbose) 01644 args[ac++] = "--log-format=X"; 01645 } 01646 01647 if (block_size) { 01648 if (asprintf(&arg, "-B%lu", block_size) < 0) 01649 goto oom; 01650 args[ac++] = arg; 01651 } 01652 01653 if (max_delete && am_sender) { 01654 if (asprintf(&arg, "--max-delete=%d", max_delete) < 0) 01655 goto oom; 01656 args[ac++] = arg; 01657 } 01658 01659 if (min_size && am_sender) { 01660 args[ac++] = "--min-size"; 01661 args[ac++] = min_size_arg; 01662 } 01663 01664 if (max_size && am_sender) { 01665 args[ac++] = "--max-size"; 01666 args[ac++] = max_size_arg; 01667 } 01668 01669 if (io_timeout) { 01670 if (asprintf(&arg, "--timeout=%d", io_timeout) < 0) 01671 goto oom; 01672 args[ac++] = arg; 01673 } 01674 01675 if (bwlimit) { 01676 if (asprintf(&arg, "--bwlimit=%d", bwlimit) < 0) 01677 goto oom; 01678 args[ac++] = arg; 01679 } 01680 01681 if (backup_dir) { 01682 args[ac++] = "--backup-dir"; 01683 args[ac++] = backup_dir; 01684 } 01685 01686 /* Only send --suffix if it specifies a non-default value. */ 01687 if (strcmp(backup_suffix, backup_dir ? "" : BACKUP_SUFFIX) != 0) { 01688 /* We use the following syntax to avoid weirdness with '~'. */ 01689 if (asprintf(&arg, "--suffix=%s", backup_suffix) < 0) 01690 goto oom; 01691 args[ac++] = arg; 01692 } 01693 01694 if (am_sender) { 01695 if (delete_excluded) 01696 args[ac++] = "--delete-excluded"; 01697 else if (delete_before == 1 || delete_after) 01698 args[ac++] = "--delete"; 01699 if (delete_before > 1) 01700 args[ac++] = "--delete-before"; 01701 if (delete_during) 01702 args[ac++] = "--delete-during"; 01703 if (delete_after) 01704 args[ac++] = "--delete-after"; 01705 if (force_delete) 01706 args[ac++] = "--force"; 01707 if (write_batch < 0) 01708 args[ac++] = "--only-write-batch=X"; 01709 if (am_root > 1) 01710 args[ac++] = "--super"; 01711 if (size_only) 01712 args[ac++] = "--size-only"; 01713 } 01714 01715 if (modify_window_set) { 01716 if (asprintf(&arg, "--modify-window=%d", modify_window) < 0) 01717 goto oom; 01718 args[ac++] = arg; 01719 } 01720 01721 if (checksum_seed) { 01722 if (asprintf(&arg, "--checksum-seed=%d", checksum_seed) < 0) 01723 goto oom; 01724 args[ac++] = arg; 01725 } 01726 01727 if (partial_dir && am_sender) { 01728 if (partial_dir != tmp_partialdir) { 01729 args[ac++] = "--partial-dir"; 01730 args[ac++] = partial_dir; 01731 } 01732 if (delay_updates) 01733 args[ac++] = "--delay-updates"; 01734 } else if (keep_partial && am_sender) 01735 args[ac++] = "--partial"; 01736 01737 if (ignore_errors) 01738 args[ac++] = "--ignore-errors"; 01739 01740 if (copy_unsafe_links) 01741 args[ac++] = "--copy-unsafe-links"; 01742 01743 if (safe_symlinks) 01744 args[ac++] = "--safe-links"; 01745 01746 if (numeric_ids) 01747 args[ac++] = "--numeric-ids"; 01748 01749 if (ignore_existing && am_sender) 01750 args[ac++] = "--ignore-existing"; 01751 01752 /* Backward compatibility: send --existing, not --ignore-non-existing. */ 01753 if (ignore_non_existing && am_sender) 01754 args[ac++] = "--existing"; 01755 01756 if (append_mode) 01757 args[ac++] = "--append"; 01758 else if (inplace) 01759 args[ac++] = "--inplace"; 01760 01761 if (tmpdir && am_sender) { 01762 args[ac++] = "--temp-dir"; 01763 args[ac++] = tmpdir; 01764 } 01765 01766 if (basis_dir[0] && am_sender) { 01767 /* the server only needs this option if it is not the sender, 01768 * and it may be an older version that doesn't know this 01769 * option, so don't send it if client is the sender. 01770 */ 01771 int i; 01772 for (i = 0; i < basis_dir_cnt; i++) { 01773 args[ac++] = dest_option; 01774 args[ac++] = basis_dir[i]; 01775 } 01776 } 01777 01778 if (files_from && (!am_sender || filesfrom_host)) { 01779 if (filesfrom_host) { 01780 args[ac++] = "--files-from"; 01781 args[ac++] = files_from; 01782 if (eol_nulls) 01783 args[ac++] = "--from0"; 01784 } else { 01785 args[ac++] = "--files-from=-"; 01786 args[ac++] = "--from0"; 01787 } 01788 if (!relative_paths) 01789 args[ac++] = "--no-relative"; 01790 } 01791 if (relative_paths && !implied_dirs && !am_sender) 01792 args[ac++] = "--no-implied-dirs"; 01793 01794 if (fuzzy_basis && am_sender) 01795 args[ac++] = "--fuzzy"; 01796 01797 if (remove_sent_files) 01798 args[ac++] = "--remove-sent-files"; 01799 01800 *argc = ac; 01801 return; 01802 01803 oom: 01804 out_of_memory("server_options"); 01805 }
char* check_for_hostspec | ( | char * | s, | |
char ** | host_ptr, | |||
int * | port_ptr | |||
) |
参照先 strlcpy().
参照元 start_client()・write_batch_shell_file().
01815 { 01816 char *p; 01817 int not_host; 01818 01819 if (port_ptr && strncasecmp(URL_PREFIX, s, strlen(URL_PREFIX)) == 0) { 01820 char *path; 01821 int hostlen; 01822 s += strlen(URL_PREFIX); 01823 if ((p = strchr(s, '/')) != NULL) { 01824 hostlen = p - s; 01825 path = p + 1; 01826 } else { 01827 hostlen = strlen(s); 01828 path = ""; 01829 } 01830 if (*s == '[' && (p = strchr(s, ']')) != NULL) { 01831 s++; 01832 hostlen = p - s; 01833 if (p[1] == ':') 01834 *port_ptr = atoi(p+2); 01835 } else { 01836 if ((p = strchr(s, ':')) != NULL) { 01837 hostlen = p - s; 01838 *port_ptr = atoi(p+1); 01839 } 01840 } 01841 if (!*port_ptr) 01842 *port_ptr = RSYNC_PORT; 01843 *host_ptr = new_array(char, hostlen + 1); 01844 strlcpy(*host_ptr, s, hostlen + 1); 01845 return path; 01846 } 01847 01848 if (*s == '[' && (p = strchr(s, ']')) != NULL && p[1] == ':') { 01849 s++; 01850 *p = '\0'; 01851 not_host = strchr(s, '/') || !strchr(s, ':'); 01852 *p = ']'; 01853 if (not_host) 01854 return NULL; 01855 p++; 01856 } else { 01857 if (!(p = strchr(s, ':'))) 01858 return NULL; 01859 *p = '\0'; 01860 not_host = strchr(s, '/') != NULL; 01861 *p = ':'; 01862 if (not_host) 01863 return NULL; 01864 } 01865 01866 *host_ptr = new_array(char, p - s + 1); 01867 strlcpy(*host_ptr, s, p - s + 1); 01868 01869 if (p[1] == ':') { 01870 if (port_ptr && !*port_ptr) 01871 *port_ptr = RSYNC_PORT; 01872 return p + 2; 01873 } 01874 if (port_ptr) 01875 *port_ptr = 0; 01876 01877 return p + 1; 01878 }
int module_id |
clientserver.c の 60 行で定義されています。
int sanitize_paths |
struct filter_list_struct filter_list |
int make_backups = 0 |
int whole_file = -1 |
int append_mode = 0 |
int keep_dirlinks = 0 |
int copy_dirlinks = 0 |
int copy_links = 0 |
int preserve_links = 0 |
int preserve_hard_links = 0 |
int preserve_acls = 0 |
int preserve_xattrs = 0 |
int preserve_perms = 0 |
int preserve_executability = 0 |
int preserve_devices = 0 |
int preserve_specials = 0 |
int preserve_uid = 0 |
int preserve_gid = 0 |
int preserve_times = 0 |
int omit_dir_times = 0 |
int update_only = 0 |
int cvs_exclude = 0 |
int ignore_times = 0 |
int delete_mode = 0 |
int delete_before = 0 |
int delete_after = 0 |
int delete_excluded = 0 |
int remove_sent_files = 0 |
int one_file_system = 0 |
int protocol_version = PROTOCOL_VERSION |
int sparse_files = 0 |
int do_compression = 0 |
int def_compress_level = Z_DEFAULT_COMPRESSION |
int am_generator = 0 |
int am_starting_up = 1 |
int relative_paths = -1 |
int implied_dirs = 1 |
int numeric_ids = 0 |
int allow_8bit_chars = 0 |
int force_delete = 0 |
int io_timeout = 0 |
int allowed_lull = 0 |
int prune_empty_dirs = 0 |
char* files_from = NULL |
int filesfrom_fd = -1 |
char* filesfrom_host = NULL |
int human_readable = 0 |
int daemon_over_rsh = 0 |
int do_stats = 0 |
int do_progress = 0 |
int keep_partial = 0 |
int safe_symlinks = 0 |
int copy_unsafe_links = 0 |
int size_only = 0 |
int daemon_bwlimit = 0 |
int bwlimit = 0 |
int fuzzy_basis = 0 |
size_t bwlimit_writemax = 0 |
int ignore_existing = 0 |
int ignore_non_existing = 0 |
int need_messages_from_generator = 0 |
int max_delete = 0 |
OFF_T max_size = 0 |
OFF_T min_size = 0 |
int ignore_errors = 0 |
int modify_window = 0 |
int blocking_io = -1 |
int checksum_seed = 0 |
int delay_updates = 0 |
long block_size = 0 |
int default_af_hint = 0 |
int default_af_hint = AF_INET |
int no_detach = 1 |
Do not go into the background when run as --daemon.
Good for debugging and required for running as a service on W32, or under Unix process-monitors.
参照元 daemon_main().
int write_batch = 0 0 |
int read_batch = 0 |
int backup_dir_len = 0 |
unsigned int backup_dir_remainder |
char* backup_suffix = NULL |
char* partial_dir = NULL |
char* config_file = NULL |
char* shell_cmd = NULL |
char* log_format = NULL |
char* password_file = NULL |
char* rsync_path = RSYNC_PATH |
char* backup_dir = NULL |
char backup_dir_buf[MAXPATHLEN] |
char* sockopts = NULL |
int rsync_port = 0 |
int compare_dest = 0 |
int copy_dest = 0 |
int basis_dir_cnt = 0 |
char* dest_option = NULL |
int log_before_transfer = 0 |
int log_format_has_i = 0 |
int log_format_has_o_or_i = 0 |
int always_checksum = 0 |
char* batch_name = NULL |
struct chmod_mode_struct* chmod_modes = NULL |
int daemon_opt [static] |
int F_option_cnt = 0 [static] |
int modify_window_set [static] |
int itemize_changes = 0 [static] |
int refused_delete [static] |
int refused_archive_part [static] |
int refused_compress [static] |
int refused_partial [static] |
int refused_progress [static] |
int refused_delete_before [static] |
int refused_inplace [static] |
char* max_size_arg [static] |
char * min_size_arg [static] |
char tmp_partialdir[] = ".~tmp~" [static] |
char* bind_address |
struct poptOption long_options[] [static] |
struct poptOption long_daemon_options[] [static] |
初期値:
{ {"address", 0, POPT_ARG_STRING, &bind_address, 0, 0, 0 }, {"bwlimit", 0, POPT_ARG_INT, &daemon_bwlimit, 0, 0, 0 }, {"config", 0, POPT_ARG_STRING, &config_file, 0, 0, 0 }, {"daemon", 0, POPT_ARG_NONE, &daemon_opt, 0, 0, 0 }, #ifdef INET6 {"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 }, {"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 }, #endif {"detach", 0, POPT_ARG_VAL, &no_detach, 0, 0, 0 }, {"no-detach", 0, POPT_ARG_VAL, &no_detach, 1, 0, 0 }, {"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0 }, {"sockopts", 0, POPT_ARG_STRING, &sockopts, 0, 0, 0 }, {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 }, {"server", 0, POPT_ARG_NONE, &am_server, 0, 0, 0 }, {"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 }, {"verbose", 'v', POPT_ARG_NONE, 0, 'v', 0, 0 }, {"no-verbose", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 }, {"no-v", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 }, {"help", 'h', POPT_ARG_NONE, 0, 'h', 0, 0 }, {0,0,0,0, 0, 0, 0} }
参照元 parse_arguments().
char err_buf[200] [static] |