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