The patches for 3.0.0pre9.
[rsync/rsync-patches.git] / stdout.diff
CommitLineData
f2863bc0
WD
1This patch adds a --stdout=line|unbuf option that lets the
2user change the buffering of stdout.
3
4To 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
10diff --git a/options.c b/options.c
11--- a/options.c
12+++ b/options.c
13@@ -203,6 +203,7 @@ static int refused_delete, refused_archive_part, refused_compress;
14 static int refused_partial, refused_progress, refused_delete_before;
15 static int refused_delete_during;
16 static int refused_inplace;
17+static char *stdout_buffering;
18 static char *max_size_arg, *min_size_arg;
19 static char tmp_partialdir[] = ".~tmp~";
20
21@@ -419,6 +420,7 @@ void usage(enum logcode F)
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");
29@@ -623,6 +625,7 @@ static struct poptOption long_options[] = {
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 },
37@@ -1241,6 +1244,13 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
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+
48 if (human_readable && argc == 2) {
49 /* Allow the old meaning of 'h' (--help) on its own. */
50 usage(FINFO);