Commit | Line | Data |
---|---|---|
f2863bc0 WD |
1 | This patch adds a --stdout=line|unbuf option that lets the |
2 | user change the buffering of stdout. | |
3 | ||
4 | To use this patch, run these commands for a successful build: | |
5 | ||
6 | patch -p1 <patches/stdout.diff | |
7 | ./configure (optional if already run) | |
8 | make | |
9 | ||
10 | diff --git a/options.c b/options.c | |
11 | --- a/options.c | |
12 | +++ b/options.c | |
c0c7984e | 13 | @@ -204,6 +204,7 @@ static int refused_delete, refused_archive_part, refused_compress; |
f2863bc0 WD |
14 | static int refused_partial, refused_progress, refused_delete_before; |
15 | static int refused_delete_during; | |
85096e5e | 16 | static int refused_inplace, refused_no_iconv; |
f2863bc0 WD |
17 | +static char *stdout_buffering; |
18 | static char *max_size_arg, *min_size_arg; | |
19 | static char tmp_partialdir[] = ".~tmp~"; | |
20 | ||
c0c7984e | 21 | @@ -424,6 +425,7 @@ void usage(enum logcode F) |
f2863bc0 WD |
22 | rprintf(F," --password-file=FILE read daemon-access password from FILE\n"); |
23 | rprintf(F," --list-only list the files instead of copying them\n"); | |
24 | rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n"); | |
25 | + rprintf(F," --stdout=line|unbuf change buffering of stdout\n"); | |
26 | rprintf(F," --write-batch=FILE write a batched update to FILE\n"); | |
27 | rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); | |
28 | rprintf(F," --read-batch=FILE read a batched update from FILE\n"); | |
c0c7984e | 29 | @@ -645,6 +647,7 @@ static struct poptOption long_options[] = { |
f2863bc0 WD |
30 | {"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 }, |
31 | {"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0 }, | |
32 | {"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 }, | |
33 | + {"stdout", 0, POPT_ARG_STRING, &stdout_buffering, 0, 0, 0 }, | |
34 | {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 }, | |
35 | {"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 }, | |
36 | {"server", 0, POPT_ARG_NONE, 0, OPT_SERVER, 0, 0 }, | |
c0c7984e | 37 | @@ -1275,6 +1278,13 @@ int parse_arguments(int *argc_p, const char ***argv_p) |
f2863bc0 WD |
38 | } |
39 | } | |
40 | ||
41 | + if (stdout_buffering && !am_server) { | |
42 | + if (*stdout_buffering == 'u') | |
43 | + setvbuf(stdout, NULL, _IONBF, 0); | |
44 | + else | |
45 | + setvbuf(stdout, NULL, _IOLBF, 0); | |
46 | + } | |
47 | + | |
cbdf862c | 48 | if (human_readable && argc == 2 && !am_server) { |
f2863bc0 WD |
49 | /* Allow the old meaning of 'h' (--help) on its own. */ |
50 | usage(FINFO); |