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