From d3e182af0976f35cad31bd3aa08c8deaa20509b3 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 24 Jul 2004 16:38:49 +0000 Subject: [PATCH] Added write_stream_flags() to write the state of certain flags into the batchfile and read_stream_flags() to read and twiddle the same flags. This ensures that the batchfile reading doesn't get confused about what data to expect from the socket. --- batch.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/batch.c b/batch.c index 144e6943..4c91f82f 100644 --- a/batch.c +++ b/batch.c @@ -12,9 +12,66 @@ extern char *batch_name; extern int delete_mode; extern int delete_excluded; extern int eol_nulls; +extern int recurse; +extern int preserve_links; +extern int preserve_hard_links; +extern int preserve_devices; +extern int preserve_uid; +extern int preserve_gid; +extern int always_checksum; extern struct exclude_list_struct exclude_list; +static int *flag_ptr[] = { + &recurse, + &preserve_uid, + &preserve_gid, + &preserve_links, + &preserve_devices, + &preserve_hard_links, + &always_checksum, + NULL +}; + +static char *flag_name[] = { + "--recurse (-r)", + "--owner (-o)", + "--group (-g)", + "--links (-l)", + "--devices (-D)", + "--hard-links (-H)", + "--checksum (-c)", + NULL +}; + +void write_stream_flags(int fd) +{ + int i, flags; + + /* Start the batch file with a bitmap of data-stream-affecting + * flags. */ + for (i = 0, flags = 0; flag_ptr[i]; i++) { + if (*flag_ptr[i]) + flags |= 1 << i; + } + write_int(fd, flags); +} + +void read_stream_flags(int fd) +{ + int i, flags; + + for (i = 0, flags = read_int(fd); flag_ptr[i]; i++) { + int set = flags & (1 << i) ? 1 : 0; + if (*flag_ptr[i] != set) { + rprintf(FINFO, + "%sing the %s option to match the batchfile.\n", + set ? "Sett" : "Clear", flag_name[i]); + *flag_ptr[i] = set; + } + } +} + static void write_arg(int fd, char *arg) { char *x, *s; -- 2.34.1