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