Add --bwlimit option contributed by Matthew Demicco and Jamie Gritton.
[rsync.git] / options.c
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;
40 int delete_excluded=0;
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;
58 int do_stats=0;
59 int do_progress=0;
60 int keep_partial=0;
61 int safe_symlinks=0;
62 int copy_unsafe_links=0;
63 int block_size=BLOCK_SIZE;
64 int size_only=0;
65 int bwlimit=0;
66 int delete_after=0;
67 int only_existing=0;
68 int max_delete=0;
69 int ignore_errors=0;
70
71 char *backup_suffix = BACKUP_SUFFIX;
72 char *tmpdir = NULL;
73 char *compare_dest = NULL;
74 char *config_file = RSYNCD_CONF;
75 char *shell_cmd = NULL;
76 char *log_format = NULL;
77 char *password_file = NULL;
78 char *rsync_path = RSYNC_NAME;
79 char *backup_dir = NULL;
80 int rsync_port = RSYNC_PORT;
81
82 int verbose = 0;
83 int quiet = 0;
84 int always_checksum = 0;
85 int list_only = 0;
86
87 struct in_addr socket_address = {INADDR_ANY};
88
89 void usage(enum logcode F)
90 {
91   rprintf(F,"rsync version %s Copyright Andrew Tridgell and Paul Mackerras\n\n",
92           VERSION);
93
94   rprintf(F,"rsync is a file transfer program capable of efficient remote update\nvia a fast differencing algorithm.\n\n");
95
96   rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n");
97   rprintf(F,"  or   rsync [OPTION]... [USER@]HOST:SRC DEST\n");
98   rprintf(F,"  or   rsync [OPTION]... SRC [SRC]... DEST\n");
99   rprintf(F,"  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]\n");
100   rprintf(F,"  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n");
101   rprintf(F,"  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]\n");
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");
105   rprintf(F,"\nOptions\n");
106   rprintf(F," -v, --verbose               increase verbosity\n");
107   rprintf(F," -q, --quiet                 decrease verbosity\n");
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");
112   rprintf(F," -b, --backup                make backups (default %s suffix)\n",BACKUP_SUFFIX);
113   rprintf(F,"     --backup-dir            make backups into this directory\n");
114   rprintf(F,"     --suffix=SUFFIX         override backup suffix\n");  
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");
118   rprintf(F,"     --copy-unsafe-links     copy links outside the source tree\n");
119   rprintf(F,"     --safe-links            ignore links outside the destination tree\n");
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");
130   rprintf(F," -B, --block-size=SIZE       checksum blocking size (default %d)\n",BLOCK_SIZE);  
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");
134   rprintf(F,"     --existing              only update files that already exist\n");
135   rprintf(F,"     --delete                delete files that don't exist on the sending side\n");
136   rprintf(F,"     --delete-excluded       also delete excluded files on the receiving side\n");
137   rprintf(F,"     --delete-after          delete after transferring, not before\n");
138   rprintf(F,"     --ignore-errors         delete even if there are IO errors\n");
139   rprintf(F,"     --max-delete=NUM        don't delete more than NUM files\n");
140   rprintf(F,"     --partial               keep partially transferred files\n");
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");
145   rprintf(F,"     --size-only             only use file size when determining if a file should be transferred\n");
146   rprintf(F," -T  --temp-dir=DIR          create temporary files in directory DIR\n");
147   rprintf(F,"     --compare-dest=DIR      also compare destination files relative to DIR\n");
148   rprintf(F," -P                          equivalent to --partial --progress\n");
149   rprintf(F," -z, --compress              compress file data\n");
150   rprintf(F,"     --exclude=PATTERN       exclude files matching PATTERN\n");
151   rprintf(F,"     --exclude-from=FILE     exclude patterns listed in FILE\n");
152   rprintf(F,"     --include=PATTERN       don't exclude files matching PATTERN\n");
153   rprintf(F,"     --include-from=FILE     don't exclude patterns listed in FILE\n");
154   rprintf(F,"     --version               print version number\n");  
155   rprintf(F,"     --daemon                run as a rsync daemon\n");  
156   rprintf(F,"     --address               bind to the specified address\n");  
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");  
160   rprintf(F,"     --progress              show progress during transfer\n");  
161   rprintf(F,"     --log-format=FORMAT     log file transfers using specified format\n");  
162   rprintf(F,"     --password-file=FILE    get password from FILE\n");
163   rprintf(F,"     --bwlimit=KBPS          limit I/O bandwidth, KBytes per second\n");
164   rprintf(F," -h, --help                  show this help screen\n");
165
166   rprintf(F,"\n");
167
168   rprintf(F,"\nPlease see the rsync(1) and rsyncd.conf(5) man pages for full documentation\n");
169   rprintf(F,"See http://rsync.samba.org/ for updates and bug reports\n");
170 }
171
172 enum {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,
175       OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS, OPT_PARTIAL, OPT_PROGRESS,
176       OPT_COPY_UNSAFE_LINKS, OPT_SAFE_LINKS, OPT_COMPARE_DEST,
177       OPT_LOG_FORMAT, OPT_PASSWORD_FILE, OPT_SIZE_ONLY, OPT_ADDRESS,
178       OPT_DELETE_AFTER, OPT_EXISTING, OPT_MAX_DELETE, OPT_BACKUP_DIR, 
179       OPT_IGNORE_ERRORS, OPT_BWLIMIT};
180
181 static char *short_options = "oblLWHpguDCtcahvqrRIxnSe:B:T:zP";
182
183 static struct option long_options[] = {
184   {"version",     0,     0,    OPT_VERSION},
185   {"server",      0,     0,    OPT_SERVER},
186   {"sender",      0,     0,    OPT_SENDER},
187   {"existing",    0,     0,    OPT_EXISTING},
188   {"delete",      0,     0,    OPT_DELETE},
189   {"delete-excluded", 0, 0,    OPT_DELETE_EXCLUDED},
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},
194   {"include",     1,     0,    OPT_INCLUDE},
195   {"include-from",1,     0,    OPT_INCLUDE_FROM},
196   {"rsync-path",  1,     0,    OPT_RSYNC_PATH},
197   {"password-file", 1,  0,     OPT_PASSWORD_FILE},
198   {"one-file-system",0,  0,    'x'},
199   {"ignore-times",0,     0,    'I'},
200   {"size-only",   0,     0,    OPT_SIZE_ONLY},
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'},
210   {"quiet",       0,     0,    'q'},
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'},
217   {"copy-unsafe-links", 0, 0,  OPT_COPY_UNSAFE_LINKS},
218   {"safe-links",  0,     0,    OPT_SAFE_LINKS},
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'},
229   {"compare-dest", 1,    0,    OPT_COMPARE_DEST},
230   {"compress",    0,     0,    'z'},
231   {"daemon",      0,     0,    OPT_DAEMON},
232   {"stats",       0,     0,    OPT_STATS},
233   {"progress",    0,     0,    OPT_PROGRESS},
234   {"partial",     0,     0,    OPT_PARTIAL},
235   {"delete-after",0,     0,    OPT_DELETE_AFTER},
236   {"ignore-errors",0,     0,   OPT_IGNORE_ERRORS},
237   {"config",      1,     0,    OPT_CONFIG},
238   {"port",        1,     0,    OPT_PORT},
239   {"log-format",  1,     0,    OPT_LOG_FORMAT},
240   {"bwlimit",     1,     0,    OPT_BWLIMIT},
241   {"address",     1,     0,    OPT_ADDRESS},
242   {"max-delete",  1,     0,    OPT_MAX_DELETE},
243   {"backup-dir",  1,     0,    OPT_BACKUP_DIR},
244   {0,0,0,0}};
245
246
247 static char err_buf[100];
248
249 void 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 */
262 static 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))) {
278                 if ((p==ref || p[-1]==' ') &&
279                     (p[len] == ' ' || p[len] == 0)) {
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
290 int parse_arguments(int argc, char *argv[], int frommain)
291 {
292         int opt;
293         int option_index;
294         char *ref = lp_refuse_options(module_id);
295
296         while ((opt = getopt_long(argc, argv, 
297                                   short_options, long_options, &option_index)) 
298                != -1) {
299
300                 if (ref) {
301                         if (check_refuse_options(ref, opt)) return 0;
302                 }
303
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;
318         
319                 case OPT_PASSWORD_FILE:
320                         password_file =optarg;
321                         break;          
322
323                 case 'I':
324                         ignore_times = 1;
325                         break;
326
327                 case OPT_SIZE_ONLY:
328                         size_only = 1;
329                         break;
330
331                 case 'x':
332                         one_file_system=1;
333                         break;
334
335                 case OPT_DELETE:
336                         delete_mode = 1;
337                         break;
338
339                 case OPT_EXISTING:
340                         only_existing = 1;
341                         break;
342
343                 case OPT_DELETE_AFTER:
344                         delete_after = 1;
345                         break;
346
347                 case OPT_DELETE_EXCLUDED:
348                         delete_excluded = 1;
349                         delete_mode = 1;
350                         break;
351
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
376                 case OPT_COPY_UNSAFE_LINKS:
377                         copy_unsafe_links=1;
378                         break;
379
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':
421 #if SUPPORT_HARD_LINKS
422                         preserve_hard_links=1;
423 #else 
424                         slprintf(err_buf,sizeof(err_buf),"hard links are not supported on this server\n");
425                         rprintf(FERROR,"ERROR: hard links not supported on this platform\n");
426                         return 0;
427 #endif
428                         break;
429
430                 case 'p':
431                         preserve_perms=1;
432                         break;
433
434                 case 'o':
435                         preserve_uid=1;
436                         break;
437
438                 case 'g':
439                         preserve_gid=1;
440                         break;
441
442                 case 'D':
443                         preserve_devices=1;
444                         break;
445
446                 case 't':
447                         preserve_times=1;
448                         break;
449
450                 case 'c':
451                         always_checksum=1;
452                         break;
453
454                 case 'v':
455                         verbose++;
456                         break;
457
458                 case 'q':
459                         if (frommain) quiet++;
460                         break;
461
462                 case 'a':
463                         recurse=1;
464 #if SUPPORT_LINKS
465                         preserve_links=1;
466 #endif
467                         preserve_perms=1;
468                         preserve_times=1;
469                         preserve_gid=1;
470                         preserve_uid=1;
471                         preserve_devices=1;
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);
481                                 exit_cleanup(RERR_SYNTAX);
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
502                 case OPT_MAX_DELETE:
503                         max_delete = atoi(optarg);
504                         break;
505
506                 case OPT_TIMEOUT:
507                         io_timeout = atoi(optarg);
508                         break;
509
510                 case 'T':
511                         tmpdir = optarg;
512                         break;
513
514                 case OPT_COMPARE_DEST:
515                         compare_dest = optarg;
516                         break;
517
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
538                 case OPT_IGNORE_ERRORS:
539                         ignore_errors = 1;
540                         break;
541
542                 case 'P':
543                         do_progress = 1;
544                         keep_partial = 1;
545                         break;
546
547                 case OPT_CONFIG:
548                         config_file = optarg;
549                         break;
550
551                 case OPT_PORT:
552                         rsync_port = atoi(optarg);
553                         break;
554
555                 case OPT_LOG_FORMAT:
556                         log_format = optarg;
557                         break;
558         
559                 case OPT_BWLIMIT:
560                         bwlimit = atoi(optarg);
561                         break;
562
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
572                 case OPT_BACKUP_DIR:
573                         backup_dir = optarg;
574                         break;
575
576                 default:
577                         slprintf(err_buf,sizeof(err_buf),"unrecognised option\n");
578                         return 0;
579                 }
580         }
581         return 1;
582 }
583
584
585 /* need to pass all the valid options from the client to the server */
586
587 void server_options(char **args,int *argc)
588 {
589         int ac = *argc;
590         static char argstr[50];
591         static char bsize[30];
592         static char iotime[30];
593         static char mdelete[30];
594         static char bw[50];
595
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';
607         /* the -q option is intentionally left out */
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) {
653                 slprintf(bsize,sizeof(bsize),"-B%d",block_size);
654                 args[ac++] = bsize;
655         }    
656
657         if (max_delete && am_sender) {
658                 slprintf(mdelete,sizeof(mdelete),"--max-delete=%d",max_delete);
659                 args[ac++] = mdelete;
660         }    
661
662         if (io_timeout) {
663                 slprintf(iotime,sizeof(iotime),"--timeout=%d",io_timeout);
664                 args[ac++] = iotime;
665         }    
666
667         if (bwlimit) {
668                 slprintf(bw,sizeof(bw),"--bwlimit=%d",bwlimit);
669                 args[ac++] = bw;
670         }
671
672         if (strcmp(backup_suffix, BACKUP_SUFFIX)) {
673                 args[ac++] = "--suffix";
674                 args[ac++] = backup_suffix;
675         }
676
677         if (delete_mode && !delete_excluded)
678                 args[ac++] = "--delete";
679
680         if (delete_excluded)
681                 args[ac++] = "--delete-excluded";
682
683         if (size_only)
684                 args[ac++] = "--size-only";
685
686         if (keep_partial)
687                 args[ac++] = "--partial";
688
689         if (force_delete)
690                 args[ac++] = "--force";
691
692         if (delete_after)
693                 args[ac++] = "--delete-after";
694
695         if (ignore_errors)
696                 args[ac++] = "--ignore-errors";
697
698         if (copy_unsafe_links)
699                 args[ac++] = "--copy-unsafe-links";
700
701         if (safe_symlinks)
702                 args[ac++] = "--safe-links";
703
704         if (numeric_ids)
705                 args[ac++] = "--numeric-ids";
706
707         if (only_existing && am_sender)
708                 args[ac++] = "--existing";
709
710         if (tmpdir) {
711                 args[ac++] = "--temp-dir";
712                 args[ac++] = tmpdir;
713         }
714
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
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
733         *argc = ac;
734 }
735