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