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