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