2 * Some usage & version related functions.
4 * Copyright (C) 2002-2022 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
142 #ifndef USE_ROLL_SIMD
165 for (line_len = 0, j = 0; ; j++) {
166 char *str = info_flags[j], *next_nfo = str ? info_flags[j+1] : NULL;
167 int str_len = str && *str != '*' ? strlen(str) : 1000;
168 int need_comma = next_nfo && *next_nfo != '*' ? 1 : 0;
169 if (line_len && line_len + 1 + str_len + need_comma >= (int)sizeof line_buf) {
170 rprintf(f, " %s\n", line_buf);
176 rprintf(f, "%s:\n", str+1);
179 line_len += snprintf(line_buf+line_len, sizeof line_buf - line_len, " %s%s", str, need_comma ? "," : "");
183 void print_rsync_version(enum logcode f)
185 char tmpbuf[256], *subprotocol = "";
187 #if SUBPROTOCOL_VERSION != 0
188 subprotocol = istring(".PR%d", SUBPROTOCOL_VERSION);
190 rprintf(f, "%s version %s protocol version %d%s\n",
191 RSYNC_NAME, rsync_version(), PROTOCOL_VERSION, subprotocol);
193 rprintf(f, "Copyright (C) 1996-" LATEST_YEAR " by Andrew Tridgell, Wayne Davison, and others.\n");
194 rprintf(f, "Web site: https://rsync.samba.org/\n");
198 init_checksum_choices();
200 rprintf(f, "Checksum list:\n");
201 get_default_nno_list(&valid_checksums, tmpbuf, sizeof tmpbuf, '(');
202 rprintf(f, " %s\n", tmpbuf);
204 rprintf(f, "Compress list:\n");
205 get_default_nno_list(&valid_compressions, tmpbuf, sizeof tmpbuf, '(');
206 rprintf(f, " %s\n", tmpbuf);
208 #ifdef MAINTAINER_MODE
209 rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
213 rprintf(f, "WARNING: no 64-bit integers on this platform!\n");
215 if (sizeof (int64) != SIZEOF_INT64) {
217 "WARNING: size mismatch in SIZEOF_INT64 define (%d != %d)\n",
218 (int) SIZEOF_INT64, (int) sizeof (int64));
222 rprintf(f,"rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n");
223 rprintf(f,"are welcome to redistribute it under certain conditions. See the GNU\n");
224 rprintf(f,"General Public Licence for details.\n");
227 void usage(enum logcode F)
229 print_rsync_version(F);
232 rprintf(F,"rsync is a file transfer program capable of efficient remote update\n");
233 rprintf(F,"via a fast differencing algorithm.\n");
236 rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... DEST\n");
237 rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n");
238 rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n");
239 rprintf(F," or rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST\n");
240 rprintf(F," or rsync [OPTION]... [USER@]HOST:SRC [DEST]\n");
241 rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n");
242 rprintf(F," or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n");
243 rprintf(F,"The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect\n");
244 rprintf(F,"to an rsync daemon, and require SRC or DEST to start with a module name.\n");
246 rprintf(F,"Options\n");
247 #include "help-rsync.h"
249 rprintf(F,"Use \"rsync --daemon --help\" to see the daemon-mode command-line options.\n");
250 rprintf(F,"Please see the rsync(1) and rsyncd.conf(5) manpages for full documentation.\n");
251 rprintf(F,"See https://rsync.samba.org/ for updates, bug reports, and answers\n");
254 void daemon_usage(enum logcode F)
256 print_rsync_version(F);
259 rprintf(F,"Usage: rsync --daemon [OPTION]...\n");
260 #include "help-rsyncd.h"
262 rprintf(F,"If you were not trying to invoke rsync as a daemon, avoid using any of the\n");
263 rprintf(F,"daemon-specific rsync options. See also the rsyncd.conf(5) manpage.\n");
266 const char *rsync_version(void)
271 return RSYNC_VERSION;
275 const char *default_cvsignore(void)
277 return DEFAULT_CVSIGNORE;