Commit | Line | Data |
---|---|---|
7a6421fa AT |
1 | /* |
2 | Copyright (C) Andrew Tridgell 1998 | |
3 | ||
4 | This program is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU General Public License as published by | |
6 | the Free Software Foundation; either version 2 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
15 | along with this program; if not, write to the Free Software | |
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
17 | */ | |
18 | ||
19 | /* options parsing code */ | |
20 | ||
21 | #include "rsync.h" | |
22 | ||
23 | ||
24 | int make_backups = 0; | |
25 | int whole_file = 0; | |
26 | int copy_links = 0; | |
27 | int preserve_links = 0; | |
28 | int preserve_hard_links = 0; | |
29 | int preserve_perms = 0; | |
30 | int preserve_devices = 0; | |
31 | int preserve_uid = 0; | |
32 | int preserve_gid = 0; | |
33 | int preserve_times = 0; | |
34 | int update_only = 0; | |
35 | int cvs_exclude = 0; | |
36 | int dry_run=0; | |
37 | int local_server=0; | |
38 | int ignore_times=0; | |
39 | int delete_mode=0; | |
b33b791e | 40 | int delete_excluded=0; |
7a6421fa AT |
41 | int one_file_system=0; |
42 | int remote_version=0; | |
43 | int sparse_files=0; | |
44 | int do_compression=0; | |
45 | int am_root=0; | |
46 | int orig_umask=0; | |
47 | int relative_paths=0; | |
48 | int numeric_ids = 0; | |
49 | int force_delete = 0; | |
50 | int io_timeout = 0; | |
51 | int io_error = 0; | |
52 | int read_only = 0; | |
53 | int module_id = -1; | |
54 | int am_server = 0; | |
55 | int am_sender=0; | |
56 | int recurse = 0; | |
57 | int am_daemon=0; | |
8d9dc9f9 | 58 | int am_client=0; |
a800434a | 59 | int do_stats=0; |
eb86d661 | 60 | int do_progress=0; |
c95da96a | 61 | int keep_partial=0; |
d853783f | 62 | int safe_symlinks=0; |
b5313607 | 63 | int copy_unsafe_links=0; |
7a6421fa | 64 | int block_size=BLOCK_SIZE; |
f83f0548 | 65 | int size_only=0; |
7a6421fa AT |
66 | |
67 | char *backup_suffix = BACKUP_SUFFIX; | |
68 | char *tmpdir = NULL; | |
375a4556 | 69 | char *compare_dest = NULL; |
7a6421fa AT |
70 | char *config_file = RSYNCD_CONF; |
71 | char *shell_cmd = NULL; | |
b6062654 | 72 | char *log_format = NULL; |
65575e96 | 73 | char *password_file = NULL; |
7a6421fa AT |
74 | char *rsync_path = RSYNC_NAME; |
75 | int rsync_port = RSYNC_PORT; | |
76 | ||
77 | int verbose = 0; | |
b86f0cef | 78 | int quiet = 0; |
7a6421fa | 79 | int always_checksum = 0; |
f7632fc6 | 80 | int list_only = 0; |
7a6421fa AT |
81 | |
82 | void usage(int F) | |
83 | { | |
84 | rprintf(F,"rsync version %s Copyright Andrew Tridgell and Paul Mackerras\n\n", | |
85 | VERSION); | |
704f908e AT |
86 | |
87 | rprintf(F,"rsync is a file transfer program capable of efficient remote update\nvia a fast differencing algorithm.\n\n"); | |
88 | ||
9ef53907 | 89 | rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n"); |
704f908e | 90 | rprintf(F," or rsync [OPTION]... [USER@]HOST:SRC DEST\n"); |
9ef53907 | 91 | rprintf(F," or rsync [OPTION]... SRC [SRC]... DEST\n"); |
14d43f1f | 92 | rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n"); |
9ef53907 | 93 | rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n"); |
14d43f1f | 94 | rprintf(F," or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n"); |
9ef53907 DD |
95 | rprintf(F,"SRC on single-colon remote HOST will be expanded by remote shell\n"); |
96 | rprintf(F,"SRC on server remote HOST may contain shell wildcards or multiple\n"); | |
97 | rprintf(F," sources separated by space as long as they have same top-level\n"); | |
704f908e AT |
98 | rprintf(F,"\nOptions\n"); |
99 | rprintf(F," -v, --verbose increase verbosity\n"); | |
b86f0cef | 100 | rprintf(F," -q, --quiet decrease verbosity\n"); |
704f908e AT |
101 | rprintf(F," -c, --checksum always checksum\n"); |
102 | rprintf(F," -a, --archive archive mode\n"); | |
103 | rprintf(F," -r, --recursive recurse into directories\n"); | |
104 | rprintf(F," -R, --relative use relative path names\n"); | |
9ef53907 DD |
105 | rprintf(F," -b, --backup make backups (default %s suffix)\n",BACKUP_SUFFIX); |
106 | rprintf(F," --suffix=SUFFIX override backup suffix\n"); | |
704f908e AT |
107 | rprintf(F," -u, --update update only (don't overwrite newer files)\n"); |
108 | rprintf(F," -l, --links preserve soft links\n"); | |
109 | rprintf(F," -L, --copy-links treat soft links like regular files\n"); | |
b5313607 | 110 | rprintf(F," --copy-unsafe-links copy links outside the source tree\n"); |
d853783f | 111 | rprintf(F," --safe-links ignore links outside the destination tree\n"); |
704f908e AT |
112 | rprintf(F," -H, --hard-links preserve hard links\n"); |
113 | rprintf(F," -p, --perms preserve permissions\n"); | |
114 | rprintf(F," -o, --owner preserve owner (root only)\n"); | |
115 | rprintf(F," -g, --group preserve group\n"); | |
116 | rprintf(F," -D, --devices preserve devices (root only)\n"); | |
117 | rprintf(F," -t, --times preserve times\n"); | |
118 | rprintf(F," -S, --sparse handle sparse files efficiently\n"); | |
119 | rprintf(F," -n, --dry-run show what would have been transferred\n"); | |
120 | rprintf(F," -W, --whole-file copy whole files, no incremental checks\n"); | |
121 | rprintf(F," -x, --one-file-system don't cross filesystem boundaries\n"); | |
9ef53907 | 122 | rprintf(F," -B, --block-size=SIZE checksum blocking size (default %d)\n",BLOCK_SIZE); |
704f908e AT |
123 | rprintf(F," -e, --rsh=COMMAND specify rsh replacement\n"); |
124 | rprintf(F," --rsync-path=PATH specify path to rsync on the remote machine\n"); | |
125 | rprintf(F," -C, --cvs-exclude auto ignore files in the same way CVS does\n"); | |
126 | rprintf(F," --delete delete files that don't exist on the sending side\n"); | |
b33b791e | 127 | rprintf(F," --delete-excluded also delete excluded files on the receiving side\n"); |
c95da96a | 128 | rprintf(F," --partial keep partially transferred files\n"); |
704f908e AT |
129 | rprintf(F," --force force deletion of directories even if not empty\n"); |
130 | rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n"); | |
131 | rprintf(F," --timeout=TIME set IO timeout in seconds\n"); | |
132 | rprintf(F," -I, --ignore-times don't exclude files that match length and time\n"); | |
f83f0548 | 133 | rprintf(F," --size-only only use file size when determining if a file should be transferred\n"); |
704f908e | 134 | rprintf(F," -T --temp-dir=DIR create temporary files in directory DIR\n"); |
375a4556 | 135 | rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n"); |
704f908e | 136 | rprintf(F," -z, --compress compress file data\n"); |
2acf81eb | 137 | rprintf(F," --exclude=PATTERN exclude files matching PATTERN\n"); |
858fb9eb | 138 | rprintf(F," --exclude-from=FILE exclude patterns listed in FILE\n"); |
2acf81eb | 139 | rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n"); |
858fb9eb | 140 | rprintf(F," --include-from=FILE don't exclude patterns listed in FILE\n"); |
704f908e AT |
141 | rprintf(F," --version print version number\n"); |
142 | rprintf(F," --daemon run as a rsync daemon\n"); | |
143 | rprintf(F," --config=FILE specify alternate rsyncd.conf file\n"); | |
144 | rprintf(F," --port=PORT specify alternate rsyncd port number\n"); | |
145 | rprintf(F," --stats give some file transfer stats\n"); | |
eb86d661 | 146 | rprintf(F," --progress show progress during transfer\n"); |
b6062654 | 147 | rprintf(F," --log-format=FORMAT log file transfers using specified format\n"); |
65575e96 | 148 | rprintf(F," --password-file=FILE get password from FILE\n"); |
704f908e | 149 | rprintf(F," -h, --help show this help screen\n"); |
7a6421fa AT |
150 | |
151 | rprintf(F,"\n"); | |
b72f24c7 AT |
152 | |
153 | rprintf(F,"\nPlease see the rsync(1) and rsyncd.conf(5) man pages for full documentation\n"); | |
9e3c856a | 154 | rprintf(F,"See http://rsync.samba.org/ for updates and bug reports\n"); |
7a6421fa AT |
155 | } |
156 | ||
b33b791e DD |
157 | enum {OPT_VERSION, OPT_SUFFIX, OPT_SENDER, OPT_SERVER, OPT_EXCLUDE, |
158 | OPT_EXCLUDE_FROM, OPT_DELETE, OPT_DELETE_EXCLUDED, OPT_NUMERIC_IDS, | |
159 | OPT_RSYNC_PATH, OPT_FORCE, OPT_TIMEOUT, OPT_DAEMON, OPT_CONFIG, OPT_PORT, | |
d853783f | 160 | OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS, OPT_PARTIAL, OPT_PROGRESS, |
b5313607 | 161 | OPT_COPY_UNSAFE_LINKS, OPT_SAFE_LINKS, OPT_COMPARE_DEST, |
f83f0548 | 162 | OPT_LOG_FORMAT, OPT_PASSWORD_FILE, OPT_SIZE_ONLY}; |
7a6421fa | 163 | |
b86f0cef | 164 | static char *short_options = "oblLWHpguDCtcahvqrRIxnSe:B:T:z"; |
7a6421fa AT |
165 | |
166 | static struct option long_options[] = { | |
167 | {"version", 0, 0, OPT_VERSION}, | |
168 | {"server", 0, 0, OPT_SERVER}, | |
169 | {"sender", 0, 0, OPT_SENDER}, | |
170 | {"delete", 0, 0, OPT_DELETE}, | |
b33b791e | 171 | {"delete-excluded", 0, 0, OPT_DELETE_EXCLUDED}, |
7a6421fa AT |
172 | {"force", 0, 0, OPT_FORCE}, |
173 | {"numeric-ids", 0, 0, OPT_NUMERIC_IDS}, | |
174 | {"exclude", 1, 0, OPT_EXCLUDE}, | |
175 | {"exclude-from",1, 0, OPT_EXCLUDE_FROM}, | |
2b6b4d53 AT |
176 | {"include", 1, 0, OPT_INCLUDE}, |
177 | {"include-from",1, 0, OPT_INCLUDE_FROM}, | |
7a6421fa | 178 | {"rsync-path", 1, 0, OPT_RSYNC_PATH}, |
65575e96 | 179 | {"password-file", 1, 0, OPT_PASSWORD_FILE}, |
7a6421fa AT |
180 | {"one-file-system",0, 0, 'x'}, |
181 | {"ignore-times",0, 0, 'I'}, | |
f83f0548 | 182 | {"size-only", 0, 0, OPT_SIZE_ONLY}, |
7a6421fa AT |
183 | {"help", 0, 0, 'h'}, |
184 | {"dry-run", 0, 0, 'n'}, | |
185 | {"sparse", 0, 0, 'S'}, | |
186 | {"cvs-exclude", 0, 0, 'C'}, | |
187 | {"archive", 0, 0, 'a'}, | |
188 | {"checksum", 0, 0, 'c'}, | |
189 | {"backup", 0, 0, 'b'}, | |
190 | {"update", 0, 0, 'u'}, | |
191 | {"verbose", 0, 0, 'v'}, | |
b86f0cef | 192 | {"quiet", 0, 0, 'q'}, |
7a6421fa AT |
193 | {"recursive", 0, 0, 'r'}, |
194 | {"relative", 0, 0, 'R'}, | |
195 | {"devices", 0, 0, 'D'}, | |
196 | {"perms", 0, 0, 'p'}, | |
197 | {"links", 0, 0, 'l'}, | |
198 | {"copy-links", 0, 0, 'L'}, | |
b5313607 | 199 | {"copy-unsafe-links", 0, 0, OPT_COPY_UNSAFE_LINKS}, |
d853783f | 200 | {"safe-links", 0, 0, OPT_SAFE_LINKS}, |
7a6421fa AT |
201 | {"whole-file", 0, 0, 'W'}, |
202 | {"hard-links", 0, 0, 'H'}, | |
203 | {"owner", 0, 0, 'o'}, | |
204 | {"group", 0, 0, 'g'}, | |
205 | {"times", 0, 0, 't'}, | |
206 | {"rsh", 1, 0, 'e'}, | |
207 | {"suffix", 1, 0, OPT_SUFFIX}, | |
208 | {"block-size", 1, 0, 'B'}, | |
209 | {"timeout", 1, 0, OPT_TIMEOUT}, | |
210 | {"temp-dir", 1, 0, 'T'}, | |
375a4556 | 211 | {"compare-dest", 1, 0, OPT_COMPARE_DEST}, |
7a6421fa AT |
212 | {"compress", 0, 0, 'z'}, |
213 | {"daemon", 0, 0, OPT_DAEMON}, | |
a800434a | 214 | {"stats", 0, 0, OPT_STATS}, |
eb86d661 | 215 | {"progress", 0, 0, OPT_PROGRESS}, |
c95da96a | 216 | {"partial", 0, 0, OPT_PARTIAL}, |
7a6421fa AT |
217 | {"config", 1, 0, OPT_CONFIG}, |
218 | {"port", 1, 0, OPT_PORT}, | |
b6062654 | 219 | {"log-format", 1, 0, OPT_LOG_FORMAT}, |
7a6421fa AT |
220 | {0,0,0,0}}; |
221 | ||
b11ed3b1 | 222 | |
cd8185f2 AT |
223 | static char err_buf[100]; |
224 | ||
225 | void option_error(void) | |
226 | { | |
227 | if (err_buf[0]) { | |
228 | rprintf(FLOG,"%s", err_buf); | |
229 | rprintf(FERROR,"%s", err_buf); | |
230 | } else { | |
231 | rprintf(FLOG,"Error parsing options - unsupported option?\n"); | |
232 | rprintf(FERROR,"Error parsing options - unsupported option?\n"); | |
233 | } | |
234 | exit_cleanup(RERR_UNSUPPORTED); | |
235 | } | |
236 | ||
237 | /* check to see if we should refuse this option */ | |
238 | static int check_refuse_options(char *ref, int opt) | |
239 | { | |
240 | int i, len; | |
241 | char *p; | |
242 | const char *name; | |
243 | ||
244 | for (i=0; long_options[i].name; i++) { | |
245 | if (long_options[i].val == opt) break; | |
246 | } | |
247 | ||
248 | if (!long_options[i].name) return 0; | |
249 | ||
250 | name = long_options[i].name; | |
251 | len = strlen(name); | |
252 | ||
253 | while ((p = strstr(ref,name))) { | |
055af776 AT |
254 | if ((p==ref || p[-1]==' ') && |
255 | (p[len] == ' ' || p[len] == 0)) { | |
cd8185f2 AT |
256 | slprintf(err_buf,sizeof(err_buf), |
257 | "The '%s' option is not supported by this server\n", name); | |
258 | return 1; | |
259 | } | |
260 | ref += len; | |
261 | } | |
262 | return 0; | |
263 | } | |
264 | ||
265 | ||
b86f0cef | 266 | int parse_arguments(int argc, char *argv[], int frommain) |
7a6421fa | 267 | { |
d853783f AT |
268 | int opt; |
269 | int option_index; | |
cd8185f2 | 270 | char *ref = lp_refuse_options(module_id); |
d853783f AT |
271 | |
272 | while ((opt = getopt_long(argc, argv, | |
273 | short_options, long_options, &option_index)) | |
274 | != -1) { | |
cd8185f2 AT |
275 | |
276 | if (ref) { | |
277 | if (check_refuse_options(ref, opt)) return 0; | |
278 | } | |
279 | ||
d853783f AT |
280 | switch (opt) { |
281 | case OPT_VERSION: | |
282 | rprintf(FINFO,"rsync version %s protocol version %d\n\n", | |
283 | VERSION,PROTOCOL_VERSION); | |
284 | rprintf(FINFO,"Written by Andrew Tridgell and Paul Mackerras\n"); | |
285 | exit_cleanup(0); | |
286 | ||
287 | case OPT_SUFFIX: | |
288 | backup_suffix = optarg; | |
289 | break; | |
290 | ||
291 | case OPT_RSYNC_PATH: | |
292 | rsync_path = optarg; | |
293 | break; | |
65575e96 AT |
294 | |
295 | case OPT_PASSWORD_FILE: | |
296 | password_file =optarg; | |
297 | break; | |
f83f0548 | 298 | |
d853783f AT |
299 | case 'I': |
300 | ignore_times = 1; | |
301 | break; | |
302 | ||
f83f0548 AT |
303 | case OPT_SIZE_ONLY: |
304 | size_only = 1; | |
305 | break; | |
306 | ||
d853783f AT |
307 | case 'x': |
308 | one_file_system=1; | |
309 | break; | |
310 | ||
311 | case OPT_DELETE: | |
312 | delete_mode = 1; | |
313 | break; | |
314 | ||
b33b791e DD |
315 | case OPT_DELETE_EXCLUDED: |
316 | delete_excluded = 1; | |
317 | delete_mode = 1; | |
318 | break; | |
319 | ||
d853783f AT |
320 | case OPT_FORCE: |
321 | force_delete = 1; | |
322 | break; | |
323 | ||
324 | case OPT_NUMERIC_IDS: | |
325 | numeric_ids = 1; | |
326 | break; | |
327 | ||
328 | case OPT_EXCLUDE: | |
329 | add_exclude(optarg, 0); | |
330 | break; | |
331 | ||
332 | case OPT_INCLUDE: | |
333 | add_exclude(optarg, 1); | |
334 | break; | |
335 | ||
336 | case OPT_EXCLUDE_FROM: | |
337 | add_exclude_file(optarg,1, 0); | |
338 | break; | |
339 | ||
340 | case OPT_INCLUDE_FROM: | |
341 | add_exclude_file(optarg,1, 1); | |
342 | break; | |
343 | ||
b5313607 DD |
344 | case OPT_COPY_UNSAFE_LINKS: |
345 | copy_unsafe_links=1; | |
346 | break; | |
347 | ||
d853783f AT |
348 | case OPT_SAFE_LINKS: |
349 | safe_symlinks=1; | |
350 | break; | |
351 | ||
352 | case 'h': | |
353 | usage(FINFO); | |
354 | exit_cleanup(0); | |
355 | ||
356 | case 'b': | |
357 | make_backups=1; | |
358 | break; | |
359 | ||
360 | case 'n': | |
361 | dry_run=1; | |
362 | break; | |
363 | ||
364 | case 'S': | |
365 | sparse_files=1; | |
366 | break; | |
367 | ||
368 | case 'C': | |
369 | cvs_exclude=1; | |
370 | break; | |
371 | ||
372 | case 'u': | |
373 | update_only=1; | |
374 | break; | |
375 | ||
376 | case 'l': | |
377 | preserve_links=1; | |
378 | break; | |
379 | ||
380 | case 'L': | |
381 | copy_links=1; | |
382 | break; | |
383 | ||
384 | case 'W': | |
385 | whole_file=1; | |
386 | break; | |
387 | ||
388 | case 'H': | |
7a6421fa | 389 | #if SUPPORT_HARD_LINKS |
d853783f | 390 | preserve_hard_links=1; |
7a6421fa | 391 | #else |
cd8185f2 | 392 | slprintf(err_buf,sizeof(err_buf),"hard links are not supported on this server\n"); |
d853783f | 393 | rprintf(FERROR,"ERROR: hard links not supported on this platform\n"); |
b11ed3b1 | 394 | return 0; |
7a6421fa | 395 | #endif |
d853783f | 396 | break; |
7a6421fa | 397 | |
d853783f AT |
398 | case 'p': |
399 | preserve_perms=1; | |
400 | break; | |
7a6421fa | 401 | |
d853783f AT |
402 | case 'o': |
403 | preserve_uid=1; | |
404 | break; | |
7a6421fa | 405 | |
d853783f AT |
406 | case 'g': |
407 | preserve_gid=1; | |
408 | break; | |
7a6421fa | 409 | |
d853783f AT |
410 | case 'D': |
411 | preserve_devices=1; | |
412 | break; | |
7a6421fa | 413 | |
d853783f AT |
414 | case 't': |
415 | preserve_times=1; | |
416 | break; | |
7a6421fa | 417 | |
d853783f AT |
418 | case 'c': |
419 | always_checksum=1; | |
420 | break; | |
7a6421fa | 421 | |
d853783f AT |
422 | case 'v': |
423 | verbose++; | |
424 | break; | |
7a6421fa | 425 | |
b86f0cef DD |
426 | case 'q': |
427 | if (frommain) quiet++; | |
428 | break; | |
429 | ||
d853783f AT |
430 | case 'a': |
431 | recurse=1; | |
7a6421fa | 432 | #if SUPPORT_LINKS |
d853783f | 433 | preserve_links=1; |
7a6421fa | 434 | #endif |
d853783f AT |
435 | preserve_perms=1; |
436 | preserve_times=1; | |
437 | preserve_gid=1; | |
438 | if (am_root) { | |
439 | preserve_devices=1; | |
440 | preserve_uid=1; | |
441 | } | |
442 | break; | |
443 | ||
444 | case OPT_SERVER: | |
445 | am_server = 1; | |
446 | break; | |
447 | ||
448 | case OPT_SENDER: | |
449 | if (!am_server) { | |
450 | usage(FERROR); | |
65417579 | 451 | exit_cleanup(RERR_SYNTAX); |
d853783f AT |
452 | } |
453 | am_sender = 1; | |
454 | break; | |
455 | ||
456 | case 'r': | |
457 | recurse = 1; | |
458 | break; | |
459 | ||
460 | case 'R': | |
461 | relative_paths = 1; | |
462 | break; | |
463 | ||
464 | case 'e': | |
465 | shell_cmd = optarg; | |
466 | break; | |
467 | ||
468 | case 'B': | |
469 | block_size = atoi(optarg); | |
470 | break; | |
471 | ||
472 | case OPT_TIMEOUT: | |
473 | io_timeout = atoi(optarg); | |
474 | break; | |
475 | ||
476 | case 'T': | |
477 | tmpdir = optarg; | |
478 | break; | |
479 | ||
375a4556 DD |
480 | case OPT_COMPARE_DEST: |
481 | compare_dest = optarg; | |
482 | break; | |
483 | ||
d853783f AT |
484 | case 'z': |
485 | do_compression = 1; | |
486 | break; | |
487 | ||
488 | case OPT_DAEMON: | |
489 | am_daemon = 1; | |
490 | break; | |
491 | ||
492 | case OPT_STATS: | |
493 | do_stats = 1; | |
494 | break; | |
495 | ||
496 | case OPT_PROGRESS: | |
497 | do_progress = 1; | |
498 | break; | |
499 | ||
500 | case OPT_PARTIAL: | |
501 | keep_partial = 1; | |
502 | break; | |
503 | ||
504 | case OPT_CONFIG: | |
505 | config_file = optarg; | |
506 | break; | |
507 | ||
508 | case OPT_PORT: | |
509 | rsync_port = atoi(optarg); | |
510 | break; | |
511 | ||
b6062654 AT |
512 | case OPT_LOG_FORMAT: |
513 | log_format = optarg; | |
514 | break; | |
515 | ||
d853783f | 516 | default: |
cd8185f2 | 517 | slprintf(err_buf,sizeof(err_buf),"unrecognised option\n"); |
b11ed3b1 | 518 | return 0; |
d853783f | 519 | } |
7a6421fa | 520 | } |
b11ed3b1 | 521 | return 1; |
7a6421fa AT |
522 | } |
523 | ||
524 | ||
525 | void server_options(char **args,int *argc) | |
526 | { | |
d853783f AT |
527 | int ac = *argc; |
528 | static char argstr[50]; | |
529 | static char bsize[30]; | |
530 | static char iotime[30]; | |
531 | int i, x; | |
532 | ||
533 | args[ac++] = "--server"; | |
534 | ||
535 | if (!am_sender) | |
536 | args[ac++] = "--sender"; | |
537 | ||
538 | x = 1; | |
539 | argstr[0] = '-'; | |
540 | for (i=0;i<verbose;i++) | |
541 | argstr[x++] = 'v'; | |
b86f0cef | 542 | /* the -q option is intentionally left out */ |
d853783f AT |
543 | if (make_backups) |
544 | argstr[x++] = 'b'; | |
545 | if (update_only) | |
546 | argstr[x++] = 'u'; | |
547 | if (dry_run) | |
548 | argstr[x++] = 'n'; | |
549 | if (preserve_links) | |
550 | argstr[x++] = 'l'; | |
551 | if (copy_links) | |
552 | argstr[x++] = 'L'; | |
553 | if (whole_file) | |
554 | argstr[x++] = 'W'; | |
555 | if (preserve_hard_links) | |
556 | argstr[x++] = 'H'; | |
557 | if (preserve_uid) | |
558 | argstr[x++] = 'o'; | |
559 | if (preserve_gid) | |
560 | argstr[x++] = 'g'; | |
561 | if (preserve_devices) | |
562 | argstr[x++] = 'D'; | |
563 | if (preserve_times) | |
564 | argstr[x++] = 't'; | |
565 | if (preserve_perms) | |
566 | argstr[x++] = 'p'; | |
567 | if (recurse) | |
568 | argstr[x++] = 'r'; | |
569 | if (always_checksum) | |
570 | argstr[x++] = 'c'; | |
571 | if (cvs_exclude) | |
572 | argstr[x++] = 'C'; | |
573 | if (ignore_times) | |
574 | argstr[x++] = 'I'; | |
575 | if (relative_paths) | |
576 | argstr[x++] = 'R'; | |
577 | if (one_file_system) | |
578 | argstr[x++] = 'x'; | |
579 | if (sparse_files) | |
580 | argstr[x++] = 'S'; | |
581 | if (do_compression) | |
582 | argstr[x++] = 'z'; | |
583 | argstr[x] = 0; | |
584 | ||
585 | if (x != 1) args[ac++] = argstr; | |
586 | ||
587 | if (block_size != BLOCK_SIZE) { | |
588 | sprintf(bsize,"-B%d",block_size); | |
589 | args[ac++] = bsize; | |
590 | } | |
591 | ||
592 | if (io_timeout) { | |
593 | sprintf(iotime,"--timeout=%d",io_timeout); | |
594 | args[ac++] = iotime; | |
595 | } | |
596 | ||
597 | if (strcmp(backup_suffix, BACKUP_SUFFIX)) { | |
598 | args[ac++] = "--suffix"; | |
599 | args[ac++] = backup_suffix; | |
600 | } | |
601 | ||
b33b791e | 602 | if (delete_mode && !delete_excluded) |
d853783f AT |
603 | args[ac++] = "--delete"; |
604 | ||
b33b791e DD |
605 | if (delete_excluded) |
606 | args[ac++] = "--delete-excluded"; | |
607 | ||
f83f0548 AT |
608 | if (size_only) |
609 | args[ac++] = "--size-only"; | |
610 | ||
d853783f AT |
611 | if (keep_partial) |
612 | args[ac++] = "--partial"; | |
613 | ||
614 | if (force_delete) | |
615 | args[ac++] = "--force"; | |
616 | ||
b5313607 DD |
617 | if (copy_unsafe_links) |
618 | args[ac++] = "--copy-unsafe-links"; | |
619 | ||
d853783f AT |
620 | if (safe_symlinks) |
621 | args[ac++] = "--safe-links"; | |
622 | ||
623 | if (numeric_ids) | |
624 | args[ac++] = "--numeric-ids"; | |
625 | ||
626 | if (tmpdir) { | |
627 | args[ac++] = "--temp-dir"; | |
628 | args[ac++] = tmpdir; | |
629 | } | |
630 | ||
375a4556 DD |
631 | if (compare_dest && am_sender) { |
632 | /* the server only needs this option if it is not the sender, | |
633 | * and it may be an older version that doesn't know this | |
634 | * option, so don't send it if client is the sender. | |
635 | */ | |
636 | args[ac++] = "--compare-dest"; | |
637 | args[ac++] = compare_dest; | |
638 | } | |
639 | ||
640 | ||
d853783f | 641 | *argc = ac; |
7a6421fa AT |
642 | } |
643 |