File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / usage.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:32:36 2021 UTC (3 years, 3 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_2_3, HEAD
rsync 3.2.3

    1: /*
    2:  * Some usage & version related functions.
    3:  *
    4:  * Copyright (C) 2002-2020 Wayne Davison
    5:  *
    6:  * This program is free software; you can redistribute it and/or modify
    7:  * it under the terms of the GNU General Public License as published by
    8:  * the Free Software Foundation; either version 3 of the License, or
    9:  * (at your option) any later version.
   10:  *
   11:  * This program is distributed in the hope that it will be useful,
   12:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14:  * GNU General Public License for more details.
   15:  *
   16:  * You should have received a copy of the GNU General Public License along
   17:  * with this program; if not, visit the http://fsf.org website.
   18:  */
   19: 
   20: #include "rsync.h"
   21: #include "latest-year.h"
   22: #include "git-version.h"
   23: #include "default-cvsignore.h"
   24: 
   25: extern struct name_num_obj valid_checksums;
   26: extern struct name_num_obj valid_compressions;
   27: 
   28: static char *istring(const char *fmt, int val)
   29: {
   30: 	char *str;
   31: 	if (asprintf(&str, fmt, val) < 0)
   32: 		out_of_memory("istring");
   33: 	return str;
   34: }
   35: 
   36: static void print_info_flags(enum logcode f)
   37: {
   38: 	STRUCT_STAT *dumstat;
   39: 	char line_buf[75];
   40: 	int line_len, j;
   41: 	char *info_flags[] = {
   42: 
   43: 	"*Capabilities",
   44: 
   45: 		istring("%d-bit files", (int)(sizeof (OFF_T) * 8)),
   46: 		istring("%d-bit inums", (int)(sizeof dumstat->st_ino * 8)), /* Don't check ino_t! */
   47: 		istring("%d-bit timestamps", (int)(sizeof (time_t) * 8)),
   48: 		istring("%d-bit long ints", (int)(sizeof (int64) * 8)),
   49: 
   50: #ifndef HAVE_SOCKETPAIR
   51: 		"no "
   52: #endif
   53: 			"socketpairs",
   54: 
   55: #ifndef SUPPORT_HARD_LINKS
   56: 		"no "
   57: #endif
   58: 			"hardlinks",
   59: 
   60: #ifndef CAN_HARDLINK_SPECIAL
   61: 		"no "
   62: #endif
   63: 			"hardlink-specials",
   64: 
   65: #ifndef SUPPORT_LINKS
   66: 		"no "
   67: #endif
   68: 			"symlinks",
   69: 
   70: #ifndef INET6
   71: 		"no "
   72: #endif
   73: 			"IPv6",
   74: 
   75: #ifndef SUPPORT_ATIMES
   76: 		"no "
   77: #endif
   78: 			"atimes",
   79: 
   80: 		"batchfiles",
   81: 
   82: #ifndef HAVE_FTRUNCATE
   83: 		"no "
   84: #endif
   85: 			"inplace",
   86: 
   87: #ifndef HAVE_FTRUNCATE
   88: 		"no "
   89: #endif
   90: 			"append",
   91: 
   92: #ifndef SUPPORT_ACLS
   93: 		"no "
   94: #endif
   95: 			"ACLs",
   96: 
   97: #ifndef SUPPORT_XATTRS
   98: 		"no "
   99: #endif
  100: 			"xattrs",
  101: 
  102: #ifdef RSYNC_USE_PROTECTED_ARGS
  103: 		"default "
  104: #else
  105: 		"optional "
  106: #endif
  107: 			"protect-args",
  108: 
  109: #ifndef ICONV_OPTION
  110: 		"no "
  111: #endif
  112: 			"iconv",
  113: 
  114: #ifndef CAN_SET_SYMLINK_TIMES
  115: 		"no "
  116: #endif
  117: 			"symtimes",
  118: 
  119: #ifndef SUPPORT_PREALLOCATION
  120: 		"no "
  121: #endif
  122: 			"prealloc",
  123: 
  124: #ifndef HAVE_MKTIME
  125: 		"no "
  126: #endif
  127: 			"stop-at",
  128: 
  129: #ifndef SUPPORT_CRTIMES
  130: 		"no "
  131: #endif
  132: 			"crtimes",
  133: 
  134: #if !defined HAVE_MYSQL_MYSQL_H || !defined HAVE_LIBMYSQLCLIENT
  135: 		"no "
  136: #endif
  137: 			"MySQL",
  138: 
  139: #if !defined HAVE_SQLITE3_H || !defined HAVE_LIBSQLITE3
  140: 		"no "
  141: #endif
  142: 			"SQLite",
  143: 
  144: #ifndef SUPPORT_FILEFLAGS
  145: 		"no "
  146: #endif
  147: 			"file-flags",
  148: 
  149: #ifndef HAVE_LIBSLP
  150: 		"no "
  151: #endif
  152: 			"SLP",
  153: 
  154: 	"*Optimizations",
  155: 
  156: #ifndef HAVE_SIMD
  157: 		"no "
  158: #endif
  159: 			"SIMD",
  160: 
  161: #ifndef HAVE_ASM
  162: 		"no "
  163: #endif
  164: 			"asm",
  165: 
  166: #ifndef USE_OPENSSL
  167: 		"no "
  168: #endif
  169: 			"openssl-crypto",
  170: 
  171: 		NULL
  172: 	};
  173: 
  174: 	for (line_len = 0, j = 0; ; j++) {
  175: 		char *str = info_flags[j], *next_nfo = str ? info_flags[j+1] : NULL;
  176: 		int str_len = str && *str != '*' ? strlen(str) : 1000;
  177: 		int need_comma = next_nfo && *next_nfo != '*' ? 1 : 0;
  178: 		if (line_len && line_len + 1 + str_len + need_comma >= (int)sizeof line_buf) {
  179: 			rprintf(f, "   %s\n", line_buf);
  180: 			line_len = 0;
  181: 		}
  182: 		if (!str)
  183: 			break;
  184: 		if (*str == '*') {
  185: 			rprintf(f, "%s:\n", str+1);
  186: 			continue;
  187: 		}
  188: 		line_len += snprintf(line_buf+line_len, sizeof line_buf - line_len, " %s%s", str, need_comma ? "," : "");
  189: 	}
  190: }
  191: 
  192: void print_rsync_version(enum logcode f)
  193: {
  194: 	char tmpbuf[256], *subprotocol = "";
  195: 
  196: #if SUBPROTOCOL_VERSION != 0
  197: 	subprotocol = istring(".PR%d", SUBPROTOCOL_VERSION);
  198: #endif
  199: 	rprintf(f, "%s  version %s  protocol version %d%s\n",
  200: 		RSYNC_NAME, rsync_version(), PROTOCOL_VERSION, subprotocol);
  201: 
  202: 	rprintf(f, "Copyright (C) 1996-" LATEST_YEAR " by Andrew Tridgell, Wayne Davison, and others.\n");
  203: 	rprintf(f, "Web site: https://rsync.samba.org/\n");
  204: 
  205: 	print_info_flags(f);
  206: 
  207: 	rprintf(f, "Checksum list:\n");
  208: 	get_default_nno_list(&valid_checksums, tmpbuf, sizeof tmpbuf, '(');
  209: 	rprintf(f, "    %s\n", tmpbuf);
  210: 
  211: 	rprintf(f, "Compress list:\n");
  212: 	get_default_nno_list(&valid_compressions, tmpbuf, sizeof tmpbuf, '(');
  213: 	rprintf(f, "    %s\n", tmpbuf);
  214: 
  215: #ifdef MAINTAINER_MODE
  216: 	rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
  217: #endif
  218: 
  219: #if SIZEOF_INT64 < 8
  220: 	rprintf(f, "WARNING: no 64-bit integers on this platform!\n");
  221: #endif
  222: 	if (sizeof (int64) != SIZEOF_INT64) {
  223: 		rprintf(f,
  224: 			"WARNING: size mismatch in SIZEOF_INT64 define (%d != %d)\n",
  225: 			(int) SIZEOF_INT64, (int) sizeof (int64));
  226: 	}
  227: 
  228: 	rprintf(f,"\n");
  229: 	rprintf(f,"rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you\n");
  230: 	rprintf(f,"are welcome to redistribute it under certain conditions.  See the GNU\n");
  231: 	rprintf(f,"General Public Licence for details.\n");
  232: }
  233: 
  234: void usage(enum logcode F)
  235: {
  236:   print_rsync_version(F);
  237: 
  238:   rprintf(F,"\n");
  239:   rprintf(F,"rsync is a file transfer program capable of efficient remote update\n");
  240:   rprintf(F,"via a fast differencing algorithm.\n");
  241: 
  242:   rprintf(F,"\n");
  243:   rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... DEST\n");
  244:   rprintf(F,"  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n");
  245:   rprintf(F,"  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n");
  246:   rprintf(F,"  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST\n");
  247:   rprintf(F,"  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]\n");
  248:   rprintf(F,"  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]\n");
  249:   rprintf(F,"  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n");
  250:   rprintf(F,"The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect\n");
  251:   rprintf(F,"to an rsync daemon, and require SRC or DEST to start with a module name.\n");
  252:   rprintf(F,"\n");
  253:   rprintf(F,"Options\n");
  254: #include "help-rsync.h"
  255:   rprintf(F,"\n");
  256:   rprintf(F,"Use \"rsync --daemon --help\" to see the daemon-mode command-line options.\n");
  257:   rprintf(F,"Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.\n");
  258:   rprintf(F,"See https://rsync.samba.org/ for updates, bug reports, and answers\n");
  259: }
  260: 
  261: void daemon_usage(enum logcode F)
  262: {
  263:   print_rsync_version(F);
  264: 
  265:   rprintf(F,"\n");
  266:   rprintf(F,"Usage: rsync --daemon [OPTION]...\n");
  267: #include "help-rsyncd.h"
  268:   rprintf(F,"\n");
  269:   rprintf(F,"If you were not trying to invoke rsync as a daemon, avoid using any of the\n");
  270:   rprintf(F,"daemon-specific rsync options.  See also the rsyncd.conf(5) man page.\n");
  271: }
  272: 
  273: void dbonly_usage(enum logcode F)
  274: {
  275:   rprintf(F,"Usage: rsyncdb --db=CONFIG_FILE [OPTIONS] [DIRS]\n");
  276:   rprintf(F,"\n");
  277:   rprintf(F,"Options:\n");
  278: #include "help-rsyncdb.h"
  279: }
  280: 
  281: const char *rsync_version(void)
  282: {
  283: 	return RSYNC_GITVER;
  284: }
  285: 
  286: const char *default_cvsignore(void)
  287: {
  288: 	return DEFAULT_CVSIGNORE;
  289: }

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