2 * Some usage & version related functions.
4 * Copyright (C) 2002-2020 Wayne Davison
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.
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.
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.
22 #include "latest-year.h"
23 #include "git-version.h"
24 #include "default-cvsignore.h"
26 extern struct name_num_obj valid_checksums;
27 extern struct name_num_obj valid_compressions;
29 static char *istring(const char *fmt, int val)
32 if (asprintf(&str, fmt, val) < 0)
33 out_of_memory("istring");
37 static void print_info_flags(enum logcode f)
42 char *info_flags[] = {
46 istring("%d-bit files", (int)(sizeof (OFF_T) * 8)),
47 istring("%d-bit inums", (int)(sizeof dumstat->st_ino * 8)), /* Don't check ino_t! */
48 istring("%d-bit timestamps", (int)(sizeof (time_t) * 8)),
49 istring("%d-bit long ints", (int)(sizeof (int64) * 8)),
51 #ifndef HAVE_SOCKETPAIR
61 #ifndef CAN_SET_SYMLINK_TIMES
66 #ifndef SUPPORT_HARD_LINKS
71 #ifndef CAN_HARDLINK_SPECIAL
76 #ifndef CAN_HARDLINK_SYMLINK
86 #ifndef SUPPORT_ATIMES
93 #ifndef HAVE_FTRUNCATE
98 #ifndef HAVE_FTRUNCATE
108 #ifndef SUPPORT_XATTRS
113 #ifdef RSYNC_USE_PROTECTED_ARGS
125 #ifndef SUPPORT_PREALLOCATION
135 #ifndef SUPPORT_CRTIMES
160 for (line_len = 0, j = 0; ; j++) {
161 char *str = info_flags[j], *next_nfo = str ? info_flags[j+1] : NULL;
162 int str_len = str && *str != '*' ? strlen(str) : 1000;
163 int need_comma = next_nfo && *next_nfo != '*' ? 1 : 0;
164 if (line_len && line_len + 1 + str_len + need_comma >= (int)sizeof line_buf) {
165 rprintf(f, " %s\n", line_buf);
171 rprintf(f, "%s:\n", str+1);
174 line_len += snprintf(line_buf+line_len, sizeof line_buf - line_len, " %s%s", str, need_comma ? "," : "");
178 void print_rsync_version(enum logcode f)
180 char tmpbuf[256], *subprotocol = "";
182 #if SUBPROTOCOL_VERSION != 0
183 subprotocol = istring(".PR%d", SUBPROTOCOL_VERSION);
185 rprintf(f, "%s version %s protocol version %d%s\n",
186 RSYNC_NAME, rsync_version(), PROTOCOL_VERSION, subprotocol);
188 rprintf(f, "Copyright (C) 1996-" LATEST_YEAR " by Andrew Tridgell, Wayne Davison, and others.\n");
189 rprintf(f, "Web site: https://rsync.samba.org/\n");
193 rprintf(f, "Checksum list:\n");
194 get_default_nno_list(&valid_checksums, tmpbuf, sizeof tmpbuf, '(');
195 rprintf(f, " %s\n", tmpbuf);
197 rprintf(f, "Compress list:\n");
198 get_default_nno_list(&valid_compressions, tmpbuf, sizeof tmpbuf, '(');
199 rprintf(f, " %s\n", tmpbuf);
201 #ifdef MAINTAINER_MODE
202 rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
206 rprintf(f, "WARNING: no 64-bit integers on this platform!\n");
208 if (sizeof (int64) != SIZEOF_INT64) {
210 "WARNING: size mismatch in SIZEOF_INT64 define (%d != %d)\n",
211 (int) SIZEOF_INT64, (int) sizeof (int64));
215 rprintf(f,"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n");
216 rprintf(f,"are welcome to redistribute it under certain conditions. See the GNU\n");
217 rprintf(f,"General Public Licence for details.\n");
220 void usage(enum logcode F)
222 print_rsync_version(F);
225 rprintf(F,"rsync is a file transfer program capable of efficient remote update\n");
226 rprintf(F,"via a fast differencing algorithm.\n");
229 rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... DEST\n");
230 rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n");
231 rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n");
232 rprintf(F," or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST\n");
233 rprintf(F," or rsync [OPTION]... [USER@]HOST:SRC [DEST]\n");
234 rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n");
235 rprintf(F," or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n");
236 rprintf(F,"The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect\n");
237 rprintf(F,"to an rsync daemon, and require SRC or DEST to start with a module name.\n");
239 rprintf(F,"Options\n");
240 #include "help-rsync.h"
242 rprintf(F,"Use \"rsync --daemon --help\" to see the daemon-mode command-line options.\n");
243 rprintf(F,"Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.\n");
244 rprintf(F,"See https://rsync.samba.org/ for updates, bug reports, and answers\n");
247 void daemon_usage(enum logcode F)
249 print_rsync_version(F);
252 rprintf(F,"Usage: rsync --daemon [OPTION]...\n");
253 #include "help-rsyncd.h"
255 rprintf(F,"If you were not trying to invoke rsync as a daemon, avoid using any of the\n");
256 rprintf(F,"daemon-specific rsync options. See also the rsyncd.conf(5) man page.\n");
259 const char *rsync_version(void)
264 return RSYNC_VERSION;
268 const char *default_cvsignore(void)
270 return DEFAULT_CVSIGNORE;