Added write_stream_flags() to write the state of certain flags into
authorWayne Davison <wayned@samba.org>
Sat, 24 Jul 2004 16:38:49 +0000 (16:38 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 24 Jul 2004 16:38:49 +0000 (16:38 +0000)
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

diff --git a/batch.c b/batch.c
index 144e694..4c91f82 100644 (file)
--- 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 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;
 
 
 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;
 static void write_arg(int fd, char *arg)
 {
        char *x, *s;