⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 options.c

📁 Rsync 3.0.5 source code
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * Command-line (and received via daemon-socket) option parsing. * * Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org> * Copyright (C) 2000, 2001, 2002 Martin Pool <mbp@samba.org> * Copyright (C) 2002-2008 Wayne Davison * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, visit the http://fsf.org website. */#include "rsync.h"#include "ifuncs.h"#include <popt.h>#include "zlib/zlib.h"extern int module_id;extern int local_server;extern int sanitize_paths;extern int daemon_over_rsh;extern unsigned int module_dirlen;extern struct filter_list_struct filter_list;extern struct filter_list_struct daemon_filter_list;int make_backups = 0;/** * If 1, send the whole file as literal data rather than trying to * create an incremental diff. * * If -1, then look at whether we're local or remote and go by that. * * @sa disable_deltas_p() **/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 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_source_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; /* 0 = normal, 1 = root, 2 = --super, -1 = --fake-super */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;int use_qsort = 0;char *files_from = NULL;int filesfrom_fd = -1;char *filesfrom_host = NULL;int eol_nulls = 0;int protect_args = 0;int human_readable = 0;int recurse = 0;int allow_inc_recurse = 1;int xfer_dirs = -1;int am_daemon = 0;int do_stats = 0;int do_progress = 0;int connect_timeout = 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 = INT_MIN;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; /* "long" because popt can't set an int32. */char *skip_compress = NULL;/** Network address family. **/int default_af_hint#ifdef INET6	= 0;		/* Any protocol */#else	= AF_INET;	/* Must use IPv4 */# ifdef AF_INET6#  undef AF_INET6# endif# define AF_INET6 AF_INET /* make -6 option a no-op */#endif/** 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. **/int no_detach#if defined _WIN32 || defined __WIN32__	= 1;#else	= 0;#endifint write_batch = 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 *logfile_name = NULL;char *logfile_format = NULL;char *stdout_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 output_motd = 1;int log_before_transfer = 0;int stdout_format_has_i = 0;int stdout_format_has_o_or_i = 0;int logfile_format_has_i = 0;int logfile_format_has_o_or_i = 0;int always_checksum = 0;int list_only = 0;#define MAX_BATCH_NAME_LEN 256	/* Must be less than MAXPATHLEN-13 */char *batch_name = NULL;int need_unsorted_flist = 0;#ifdef ICONV_OPTIONchar *iconv_opt = ICONV_OPTION;#endifstruct chmod_mode_struct *chmod_modes = NULL;static int daemon_opt;   /* sets am_daemon after option error-reporting */static int omit_dir_times = 0;static int F_option_cnt = 0;static int modify_window_set;static int itemize_changes = 0;static int refused_delete, refused_archive_part, refused_compress;static int refused_partial, refused_progress, refused_delete_before;static int refused_delete_during;static int refused_inplace, refused_no_iconv;static char *max_size_arg, *min_size_arg;static char tmp_partialdir[] = ".~tmp~";/** Local address to bind.  As a character string because it's * interpreted by the IPv6 layer: should be a numeric IP4 or IP6 * address, or a hostname. **/char *bind_address;static void print_rsync_version(enum logcode f){	char *subprotocol = "";	char const *got_socketpair = "no ";	char const *have_inplace = "no ";	char const *hardlinks = "no ";	char const *symtimes = "no ";	char const *acls = "no ";	char const *xattrs = "no ";	char const *links = "no ";	char const *iconv = "no ";	char const *ipv6 = "no ";	STRUCT_STAT *dumstat;#if SUBPROTOCOL_VERSION != 0	if (asprintf(&subprotocol, ".PR%d", SUBPROTOCOL_VERSION) < 0)		out_of_memory("print_rsync_version");#endif#ifdef HAVE_SOCKETPAIR	got_socketpair = "";#endif#ifdef HAVE_FTRUNCATE	have_inplace = "";#endif#ifdef SUPPORT_HARD_LINKS	hardlinks = "";#endif#ifdef SUPPORT_ACLS	acls = "";#endif#ifdef SUPPORT_XATTRS	xattrs = "";#endif#ifdef SUPPORT_LINKS	links = "";#endif#ifdef INET6	ipv6 = "";#endif#ifdef ICONV_OPTION	iconv = "";#endif#if defined HAVE_LUTIMES && defined HAVE_UTIMES	symtimes = "";#endif	rprintf(f, "%s  version %s  protocol version %d%s\n",		RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);	rprintf(f, "Copyright (C) 1996-2008 by Andrew Tridgell, Wayne Davison, and others.\n");	rprintf(f, "Web site: http://rsync.samba.org/\n");	rprintf(f, "Capabilities:\n");	rprintf(f, "    %d-bit files, %d-bit inums, %d-bit timestamps, %d-bit long ints,\n",		(int)(sizeof (OFF_T) * 8),		(int)(sizeof dumstat->st_ino * 8), /* Don't check ino_t! */		(int)(sizeof (time_t) * 8),		(int)(sizeof (int64) * 8));	rprintf(f, "    %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",		got_socketpair, hardlinks, links, ipv6, have_inplace);	rprintf(f, "    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes\n",		have_inplace, acls, xattrs, iconv, symtimes);#ifdef MAINTAINER_MODE	rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());#endif#if SIZEOF_INT64 < 8	rprintf(f, "WARNING: no 64-bit integers on this platform!\n");#endif	if (sizeof (int64) != SIZEOF_INT64) {		rprintf(f,			"WARNING: size mismatch in SIZEOF_INT64 define (%d != %d)\n",			(int) SIZEOF_INT64, (int) sizeof (int64));	}	rprintf(f,"\n");	rprintf(f,"rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you\n");	rprintf(f,"are welcome to redistribute it under certain conditions.  See the GNU\n");	rprintf(f,"General Public Licence for details.\n");}void usage(enum logcode F){  print_rsync_version(F);  rprintf(F,"\n");  rprintf(F,"rsync is a file transfer program capable of efficient remote update\n");  rprintf(F,"via a fast differencing algorithm.\n");  rprintf(F,"\n");  rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... DEST\n");  rprintf(F,"  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n");  rprintf(F,"  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n");  rprintf(F,"  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST\n");  rprintf(F,"  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]\n");  rprintf(F,"  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]\n");  rprintf(F,"  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n");  rprintf(F,"The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect\n");  rprintf(F,"to an rsync daemon, and require SRC or DEST to start with a module name.\n");  rprintf(F,"\n");  rprintf(F,"Options\n");  rprintf(F," -v, --verbose               increase verbosity\n");  rprintf(F," -q, --quiet                 suppress non-error messages\n");  rprintf(F,"     --no-motd               suppress daemon-mode MOTD (see manpage caveat)\n");  rprintf(F," -c, --checksum              skip based on checksum, not mod-time & size\n");  rprintf(F," -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)\n");  rprintf(F,"     --no-OPTION             turn off an implied OPTION (e.g. --no-D)\n");  rprintf(F," -r, --recursive             recurse into directories\n");  rprintf(F," -R, --relative              use relative path names\n");  rprintf(F,"     --no-implied-dirs       don't send implied dirs with --relative\n");  rprintf(F," -b, --backup                make backups (see --suffix & --backup-dir)\n");  rprintf(F,"     --backup-dir=DIR        make backups into hierarchy based in DIR\n");  rprintf(F,"     --suffix=SUFFIX         set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);  rprintf(F," -u, --update                skip files that are newer on the receiver\n");  rprintf(F,"     --inplace               update destination files in-place (SEE MAN PAGE)\n");  rprintf(F,"     --append                append data onto shorter files\n");  rprintf(F,"     --append-verify         like --append, but with old data in file checksum\n");  rprintf(F," -d, --dirs                  transfer directories without recursing\n");  rprintf(F," -l, --links                 copy symlinks as symlinks\n");  rprintf(F," -L, --copy-links            transform symlink into referent file/dir\n");  rprintf(F,"     --copy-unsafe-links     only \"unsafe\" symlinks are transformed\n");  rprintf(F,"     --safe-links            ignore symlinks that point outside the source tree\n");  rprintf(F," -k, --copy-dirlinks         transform symlink to a dir into referent dir\n");  rprintf(F," -K, --keep-dirlinks         treat symlinked dir on receiver as dir\n");  rprintf(F," -H, --hard-links            preserve hard links\n");  rprintf(F," -p, --perms                 preserve permissions\n");  rprintf(F," -E, --executability         preserve the file's executability\n");  rprintf(F,"     --chmod=CHMOD           affect file and/or directory permissions\n");#ifdef SUPPORT_ACLS  rprintf(F," -A, --acls                  preserve ACLs (implies --perms)\n");#endif#ifdef SUPPORT_XATTRS  rprintf(F," -X, --xattrs                preserve extended attributes\n");#endif  rprintf(F," -o, --owner                 preserve owner (super-user only)\n");  rprintf(F," -g, --group                 preserve group\n");  rprintf(F,"     --devices               preserve device files (super-user only)\n");  rprintf(F,"     --specials              preserve special files\n");  rprintf(F," -D                          same as --devices --specials\n");  rprintf(F," -t, --times                 preserve modification times\n");  rprintf(F," -O, --omit-dir-times        omit directories from --times\n");  rprintf(F,"     --super                 receiver attempts super-user activities\n");#ifdef SUPPORT_XATTRS  rprintf(F,"     --fake-super            store/recover privileged attrs using xattrs\n");#endif  rprintf(F," -S, --sparse                handle sparse files efficiently\n");  rprintf(F," -n, --dry-run               perform a trial run with no changes made\n");  rprintf(F," -W, --whole-file            copy files whole (without delta-xfer algorithm)\n");  rprintf(F," -x, --one-file-system       don't cross filesystem boundaries\n");  rprintf(F," -B, --block-size=SIZE       force a fixed checksum block-size\n");  rprintf(F," -e, --rsh=COMMAND           specify the remote shell to use\n");  rprintf(F,"     --rsync-path=PROGRAM    specify the rsync to run on the remote machine\n");  rprintf(F,"     --existing              skip creating new files on receiver\n");  rprintf(F,"     --ignore-existing       skip updating files that already exist on receiver\n");  rprintf(F,"     --remove-source-files   sender removes synchronized files (non-dirs)\n");  rprintf(F,"     --del                   an alias for --delete-during\n");  rprintf(F,"     --delete                delete extraneous files from destination dirs\n");  rprintf(F,"     --delete-before         receiver deletes before transfer, not during\n");  rprintf(F,"     --delete-during         receiver deletes during transfer (default)\n");  rprintf(F,"     --delete-delay          find deletions during, delete after\n");  rprintf(F,"     --delete-after          receiver deletes after transfer, not during\n");  rprintf(F,"     --delete-excluded       also delete excluded files from destination dirs\n");  rprintf(F,"     --ignore-errors         delete even if there are I/O errors\n");  rprintf(F,"     --force                 force deletion of directories even if not empty\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -