On Wed, Jan 23, 2002 at 03:41:36PM -0800, Jos Backus wrote:
> Fwiw, I'm currently working on getting rid of the automatically generated
> filenames --write-batch creates, instead --write-batch should accept a suffix,
> just like --read-batch. With that working I'll convert the suffix into a
> prefix, per Dave's excellent suggestion.
 
The patch below implements the following:
- --write-batch now accepts a prefix as a parameter instead of generating a
  timestamp suffix. --read-batch has also been changed to treat its argument
  as a prefix. Updated the documentation regarding this change.
- the rsync_argvs file created now optionally uses the first parameter
  supplied as the target directory.
  Btw, I have not seen --read-batch with a target directory different from the
  one supplied to --write-batch fail.
- In batch.c, staticized some variables.
- Shortened the code in a few places.
- Added/modified a few comments.
- Fixed a few function prototypes.
- In main.c, removed some now unused variables.

Also, see the test script and sample session below.

lizzy:~/src/rsync/batch-test% cat x
#!/bin/sh
PATH=../rsync:$PATH
prefix=foo

#rm -rf s
#mkdir s
#echo "rev 1" > s/f1
#echo "rev 1" > s/f2
rm -rf d1
rm -rf d222
rm -f $prefix.rsync_*
ls -l
mkdir d1
mkdir d222
echo s:
ls -l s
echo write-batch:
rsync -av --write-batch=$prefix s/ d1/
echo read-batch d1:
rsync -av --read-batch=$prefix d1/
echo read-batch d222:
rsync -av --read-batch=$prefix d222/
ls -l
echo d1:
ls -l d1
echo d222:
ls -l d222
lizzy:~/src/rsync/batch-test% ./x
total 2
drwxr-xr-x  2 jos  staff  512 Jan 17 15:08 s
-rwxr-xr-x  1 jos  staff  406 Jan 24 17:14 x
s:
total 2
-rw-r--r--  1 jos  staff  6 Jan 17 15:08 f1
-rw-r--r--  1 jos  staff  6 Jan 17 15:08 f2
write-batch:
rsync: building file list...
rsync: 3 files to consider.
./
f1
f2
wrote 178 bytes  read 52 bytes  460.00 bytes/sec
total size is 12  speedup is 0.05
read-batch d1:
wrote 12 bytes  read 20 bytes  64.00 bytes/sec
total size is 0  speedup is 0.00
read-batch d222:
./
f1
f2
wrote 104 bytes  read 52 bytes  312.00 bytes/sec
total size is 0  speedup is 0.00
total 8
drwxr-xr-x  2 jos  staff  512 Jan 17 15:08 d1
drwxr-xr-x  2 jos  staff  512 Jan 17 15:08 d222
-rwx------  1 jos  staff   38 Jan 24 17:15 foo.rsync_argvs
-rw-------  1 jos  staff   16 Jan 24 17:15 foo.rsync_csums
-rw-------  1 jos  staff   68 Jan 24 17:15 foo.rsync_delta
-rw-------  1 jos  staff  218 Jan 24 17:15 foo.rsync_flist
drwxr-xr-x  2 jos  staff  512 Jan 17 15:08 s
-rwxr-xr-x  1 jos  staff  406 Jan 24 17:14 x
d1:
total 2
-rw-r--r--  1 jos  staff  6 Jan 17 15:08 f1
-rw-r--r--  1 jos  staff  6 Jan 17 15:08 f2
d222:
total 2
-rw-r--r--  1 jos  staff  6 Jan 17 15:08 f1
-rw-r--r--  1 jos  staff  6 Jan 17 15:08 f2

The patch:

Index: batch.c
===================================================================
RCS file: /cvsroot/rsync/batch.c,v
retrieving revision 1.12
diff -u -r1.12 batch.c
--- batch.c     24 Jan 2002 08:09:46 -0000      1.12
+++ batch.c     25 Jan 2002 01:25:28 -0000
@@ -8,55 +8,38 @@
 #include "rsync.h"
 #include <time.h>
 
-char rsync_flist_file[27] = "rsync_flist.";
-char rsync_csums_file[27] = "rsync_csums.";
-char rsync_delta_file[27] = "rsync_delta.";
-char rsync_argvs_file[27] = "rsync_argvs.";
-
-char batch_file_ext[15];
-
-int fdb;
-int fdb_delta;
-int fdb_open;
-int fdb_close;
+extern char *batch_prefix;
 
 struct file_list *batch_flist;
 
-void create_batch_file_ext()
-{
-       struct tm *timeptr;
-       time_t elapsed_seconds;
-
-       /* Save run date and time to use for batch file extensions */
-       time(&elapsed_seconds);
-       timeptr = localtime(&elapsed_seconds);
-
-       sprintf(batch_file_ext, "%4d%02d%02d%02d%02d%02d",
-               timeptr->tm_year + 1900, timeptr->tm_mon + 1,
-               timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min,
-               timeptr->tm_sec);
-       rprintf(FINFO,"batch file extension: %s\n", batch_file_ext);
-}
-
-void set_batch_file_ext(char *ext)
-{
-       strcpy(batch_file_ext, ext);
-}
+static char rsync_flist_file[] = ".rsync_flist";
+static char rsync_csums_file[] = ".rsync_csums";
+static char rsync_delta_file[] = ".rsync_delta";
+static char rsync_argvs_file[] = ".rsync_argvs";
+
+static int fdb;
+static int fdb_delta;
+static int fdb_open;
+static int fdb_close;
 
 void write_batch_flist_file(char *buff, int bytes_to_write)
 {
+       char filename[MAXPATHLEN];
 
        if (fdb_open) {
                /* Set up file extension */
-               strcat(rsync_flist_file, batch_file_ext);
+               strlcpy(filename, batch_prefix, sizeof(filename));
+               strlcat(filename, rsync_flist_file, sizeof(filename));
 
-               /* Open batch flist file for writing; create it if it doesn't exist */
-               fdb =
-                   do_open(rsync_flist_file, O_WRONLY | O_CREAT | O_TRUNC,
+               /*
+                * Open batch flist file for writing;
+                * create it if it doesn't exist
+                */
+               fdb = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
                            S_IREAD | S_IWRITE);
                if (fdb == -1) {
                        rprintf(FERROR, "Batch file %s open error: %s\n",
-                               rsync_flist_file, strerror(errno));
+                               filename, strerror(errno));
                        close(fdb);
                        exit_cleanup(1);
                }
@@ -67,12 +50,11 @@
 
        if (write(fdb, buff, bytes_to_write) == -1) {
                rprintf(FERROR, "Batch file %s write error: %s\n",
-                       rsync_flist_file, strerror(errno));
+                       filename, strerror(errno));
                close(fdb);
                exit_cleanup(1);
        }
 
-
        if (fdb_close) {
                close(fdb);
        }
@@ -110,7 +92,6 @@
                }
                write_char_bufs(fptr[i]->sum);
        }
-
 }
 
 void write_char_bufs(char *buf)
@@ -118,11 +99,8 @@
        /* Write the size of the string which will follow  */
 
        char b[4];
-       if (buf != NULL)
-               SIVAL(b, 0, strlen(buf));
-       else {
-               SIVAL(b, 0, 0);
-       }
+
+       SIVAL(b, 0, buf != NULL ? strlen(buf) : 0);
 
        write_batch_flist_file(b, sizeof(int));
 
@@ -137,25 +115,32 @@
 {
        int fdb;
        int i;
-       char buff[256];
-
-       strcat(rsync_argvs_file, batch_file_ext);
-
-
-       /* Open batch argvs file for writing; create it if it doesn't exist */
-       fdb = do_open(rsync_argvs_file, O_WRONLY | O_CREAT | O_TRUNC,
+       char buff[256]; /* XXX */
+       char buff2[MAXPATHLEN + 6];
+       char filename[MAXPATHLEN];
+
+       /* Set up file extension */
+       strlcpy(filename, batch_prefix, sizeof(filename));
+       strlcat(filename, rsync_argvs_file, sizeof(filename));
+
+       /*
+        * Open batch argvs file for writing;
+        * create it if it doesn't exist
+        */
+       fdb = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
                      S_IREAD | S_IWRITE | S_IEXEC);
        if (fdb == -1) {
                rprintf(FERROR, "Batch file %s open error: %s\n",
-                       rsync_argvs_file, strerror(errno));
+                       filename, strerror(errno));
                close(fdb);
                exit_cleanup(1);
        }
        buff[0] = '\0';
+
        /* Write argvs info to batch file */
 
        for (i = 0; i < argc; ++i) {
-               if (i == argc - 2)
+               if (i == argc - 2) /* Skip source directory on cmdline */
                    continue;
                /*
                 * FIXME:
@@ -163,10 +148,18 @@
                 */
                if (!strcmp(argv[i], "--write-batch")) {
                        /* Safer to change it here than script */
-                       /* Change to --read-batch + ext * to get ready for remote */
-                       strlcat(buff, "--read-batch ", sizeof(buff));
-                       strlcat(buff, batch_file_ext, sizeof(buff));
-               } else {
+                       /*
+                        * Change to --read-batch=prefix
+                        * to get ready for remote
+                        */
+                       strlcat(buff, "--read-batch=", sizeof(buff));
+                       strlcat(buff, batch_prefix, sizeof(buff));
+               } else
+               if (i == argc - 1) {
+                   snprintf(buff2, sizeof(buff2), "${1:-%s}", argv[i]);
+                   strlcat(buff, buff2, sizeof(buff));
+               }
+               else {
                        strlcat(buff, argv[i], sizeof(buff));
                }
 
@@ -177,14 +170,14 @@
        strlcat(buff, "\n", sizeof(buff));
        if (!write(fdb, buff, strlen(buff))) {
                rprintf(FERROR, "Batch file %s write error: %s\n",
-                       rsync_argvs_file, strerror(errno));
+                       filename, strerror(errno));
                close(fdb);
                exit_cleanup(1);
        }
        close(fdb);
 }
 
-struct file_list *create_flist_from_batch()
+struct file_list *create_flist_from_batch(void)
 {
        unsigned char flags;
 
@@ -201,7 +194,7 @@
            (struct file_struct **) malloc(sizeof(batch_flist->files[0]) *
                                           batch_flist->malloced);
        if (!batch_flist->files) {
-               out_of_memory("create_flist_from_batch");       /* dw -- will exit */
+               out_of_memory("create_flist_from_batch");
        }
 
        for (flags = read_batch_flags(); flags; flags = read_batch_flags()) {
@@ -231,23 +224,23 @@
        }
 
        return batch_flist;
-
 }
 
 int read_batch_flist_file(char *buff, int len)
 {
        int bytes_read;
+       char filename[MAXPATHLEN];
 
        if (fdb_open) {
-
-               /*  Set up file extension  */
-               strcat(rsync_flist_file, batch_file_ext);
+               /* Set up file extension */
+               strlcpy(filename, batch_prefix, sizeof(filename));
+               strlcat(filename, rsync_flist_file, sizeof(filename));
 
                /* Open batch flist file for reading */
-               fdb = do_open(rsync_flist_file, O_RDONLY, 0);
+               fdb = do_open(filename, O_RDONLY, 0);
                if (fdb == -1) {
                        rprintf(FERROR, "Batch file %s open error: %s\n",
-                               rsync_flist_file, strerror(errno));
+                               filename, strerror(errno));
                        close(fdb);
                        exit_cleanup(1);
                }
@@ -256,17 +249,17 @@
 
        /* Read flist batch file */
 
-       bytes_read = read(fdb, buff, len);
-
-       if (bytes_read == -1) {
+       switch (bytes_read = read(fdb, buff, len)) {
+           case -1:
                rprintf(FERROR, "Batch file %s read error: %s\n",
-                       rsync_flist_file, strerror(errno));
+                       filename, strerror(errno));
                close(fdb);
                exit_cleanup(1);
-       }
-       if (bytes_read == 0) {  /* EOF */
+               break;
+           case 0:     /* EOF */
                close(fdb);
        }
+
        return bytes_read;
 }
 
@@ -293,8 +286,12 @@
                out_of_memory("read_batch_flist_info");
        memset((char *) file, 0, sizeof(*file));
 
-       (*fptr) = file;
+       *fptr = file;
 
+       /*
+        * Keep these in sync with bytes_to_write assignment
+        * in write_batch_flist_info()
+        */
        read_batch_flist_file((char *) &file->modtime, sizeof(time_t));
        read_batch_flist_file((char *) &file->length, sizeof(OFF_T));
        read_batch_flist_file((char *) &file->mode, sizeof(mode_t));
@@ -356,20 +353,23 @@
 
 void write_batch_csums_file(void *buff, int bytes_to_write)
 {
-
        static int fdb_open = 1;
+       char filename[MAXPATHLEN];
 
        if (fdb_open) {
                /* Set up file extension */
-               strcat(rsync_csums_file, batch_file_ext);
+               strlcpy(filename, batch_prefix, sizeof(filename));
+               strlcat(filename, rsync_csums_file, sizeof(filename));
 
-               /* Open batch csums file for writing; create it if it doesn't exist */
-               fdb =
-                   do_open(rsync_csums_file, O_WRONLY | O_CREAT | O_TRUNC,
+               /*
+                * Open batch csums file for writing;
+                * create it if it doesn't exist
+                */
+               fdb = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
                            S_IREAD | S_IWRITE);
                if (fdb == -1) {
                        rprintf(FERROR, "Batch file %s open error: %s\n",
-                               rsync_csums_file, strerror(errno));
+                               filename, strerror(errno));
                        close(fdb);
                        exit_cleanup(1);
                }
@@ -380,16 +380,15 @@
 
        if (write(fdb, buff, bytes_to_write) == -1) {
                rprintf(FERROR, "Batch file %s write error: %s\n",
-                       rsync_csums_file, strerror(errno));
+                       filename, strerror(errno));
                close(fdb);
                exit_cleanup(1);
        }
 }
 
-void close_batch_csums_file()
+void close_batch_csums_file(void)
 {
        close(fdb);
-
 }
 
 void write_batch_csum_info(int *flist_entry, int flist_count,
@@ -405,10 +404,7 @@
 
        /* FIXME: This will break if s->count is ever not exactly an int. */
        write_batch_csums_file(flist_entry, sizeof(int));
-       if (s)
-               write_batch_csums_file(&s->count, sizeof(int));
-       else
-               write_batch_csums_file(&int_zero, sizeof (int));
+       write_batch_csums_file(s ? &s->count : &int_zero, sizeof(int));
        
        if (s) {
                for (i = 0; i < s->count; i++) {
@@ -417,8 +413,7 @@
                            && (i == s->count - 1)) {
                                fdb_close = 1;
                        }
-                       write_batch_csums_file(s->sums[i].sum2,
-                                              csum_length);
+                       write_batch_csums_file(s->sums[i].sum2, csum_length);
                }
        }
 }
@@ -427,17 +422,18 @@
 {
        static int fdb_open = 1;
        int bytes_read;
+       char filename[MAXPATHLEN];
 
        if (fdb_open) {
-
-               /*  Set up file extension  */
-               strcat(rsync_csums_file, batch_file_ext);
+               /* Set up file extension */
+               strlcpy(filename, batch_prefix, sizeof(filename));
+               strlcat(filename, rsync_csums_file, sizeof(filename));
 
                /* Open batch flist file for reading */
-               fdb = do_open(rsync_csums_file, O_RDONLY, 0);
+               fdb = do_open(filename, O_RDONLY, 0);
                if (fdb == -1) {
                        rprintf(FERROR, "Batch file %s open error: %s\n",
-                               rsync_csums_file, strerror(errno));
+                               filename, strerror(errno));
                        close(fdb);
                        exit_cleanup(1);
                }
@@ -450,14 +446,14 @@
 
        if (bytes_read == -1) {
                rprintf(FERROR, "Batch file %s read error: %s\n",
-                       rsync_csums_file, strerror(errno));
+                       filename, strerror(errno));
                close(fdb);
                exit_cleanup(1);
        }
+
        return bytes_read;
 }
 
-
 void read_batch_csum_info(int flist_entry, struct sum_struct *s,
                          int *checksums_match)
 {
@@ -468,7 +464,6 @@
        char file_sum2[SUM_LENGTH];
        extern int csum_length;
 
-
        read_batch_csums_file((char *) &file_flist_entry, sizeof(int));
        if (file_flist_entry != flist_entry) {
                rprintf(FINFO, "file_list_entry NE flist_entry\n");
@@ -488,31 +483,33 @@
                        read_batch_csums_file(file_sum2, csum_length);
 
                        if ((s->sums[i].sum1 != file_sum1) ||
-                           (memcmp
-                            (s->sums[i].sum2, file_sum2,
-                             csum_length) != 0)) {
+                           (memcmp(s->sums[i].sum2, file_sum2, csum_length)
+                               != 0)) {
                                *checksums_match = 0;
                        }
                }               /*  end for  */
        }
-
 }
 
 void write_batch_delta_file(char *buff, int bytes_to_write)
 {
        static int fdb_delta_open = 1;
+       char filename[MAXPATHLEN];
 
        if (fdb_delta_open) {
                /* Set up file extension */
-               strcat(rsync_delta_file, batch_file_ext);
+               strlcpy(filename, batch_prefix, sizeof(filename));
+               strlcat(filename, rsync_delta_file, sizeof(filename));
 
-               /* Open batch delta file for writing; create it if it doesn't exist */
-               fdb_delta =
-                   do_open(rsync_delta_file, O_WRONLY | O_CREAT | O_TRUNC,
+               /*
+                * Open batch delta file for writing;
+                * create it if it doesn't exist
+                */
+               fdb_delta = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
                            S_IREAD | S_IWRITE);
                if (fdb_delta == -1) {
                        rprintf(FERROR, "Batch file %s open error: %s\n",
-                               rsync_delta_file, strerror(errno));
+                               filename, strerror(errno));
                        close(fdb_delta);
                        exit_cleanup(1);
                }
@@ -523,32 +520,33 @@
 
        if (write(fdb_delta, buff, bytes_to_write) == -1) {
                rprintf(FERROR, "Batch file %s write error: %s\n",
-                       rsync_delta_file, strerror(errno));
+                       filename, strerror(errno));
                close(fdb_delta);
                exit_cleanup(1);
        }
 }
-void close_batch_delta_file()
+
+void close_batch_delta_file(void)
 {
        close(fdb_delta);
-
 }
 
 int read_batch_delta_file(char *buff, int len)
 {
        static int fdb_delta_open = 1;
        int bytes_read;
+       char filename[MAXPATHLEN];
 
        if (fdb_delta_open) {
-
-               /*  Set up file extension  */
-               strcat(rsync_delta_file, batch_file_ext);
+               /* Set up file extension */
+               strlcpy(filename, batch_prefix, sizeof(filename));
+               strlcat(filename, rsync_delta_file, sizeof(filename));
 
                /* Open batch flist file for reading */
-               fdb_delta = do_open(rsync_delta_file, O_RDONLY, 0);
+               fdb_delta = do_open(filename, O_RDONLY, 0);
                if (fdb_delta == -1) {
                        rprintf(FERROR, "Batch file %s open error: %s\n",
-                               rsync_delta_file, strerror(errno));
+                               filename, strerror(errno));
                        close(fdb_delta);
                        exit_cleanup(1);
                }
@@ -561,13 +559,13 @@
 
        if (bytes_read == -1) {
                rprintf(FERROR, "Batch file %s read error: %s\n",
-                       rsync_delta_file, strerror(errno));
+                       filename, strerror(errno));
                close(fdb_delta);
                exit_cleanup(1);
        }
+
        return bytes_read;
 }
-
 
 void show_flist(int index, struct file_struct **fptr)
 {
Index: main.c
===================================================================
RCS file: /cvsroot/rsync/main.c,v
retrieving revision 1.137
diff -u -r1.137 main.c
--- main.c      23 Jan 2002 05:51:07 -0000      1.137
+++ main.c      25 Jan 2002 01:25:29 -0000
@@ -228,7 +228,7 @@
 
        if (local_server) {
                if (read_batch)
-                   create_flist_from_batch();
+                   create_flist_from_batch(); /* sets batch_flist */
                ret = local_child(argc, args, f_in, f_out);
        } else {
                ret = piped_child(args,f_in,f_out);
@@ -799,9 +799,7 @@
        extern int am_daemon;
        extern int am_server;
        int ret;
-       extern int read_batch;   /*  dw */
        extern int write_batch;  /*  dw */
-       extern char *batch_ext;   /*  dw */
        int orig_argc;  /* dw */
        char **orig_argv;
 
@@ -844,15 +842,10 @@
           that implement getcwd that way "pwd" can't be found after chroot. */
        push_dir(NULL,0);
 
-       if (write_batch) { /* dw */
-           create_batch_file_ext();
+       if (write_batch) {
            write_batch_argvs_file(orig_argc, orig_argv);
        }
 
-       if (read_batch) { /* dw */
-           set_batch_file_ext(batch_ext);
-       }
-
        if (am_daemon) {
                return daemon_main();
        }
@@ -882,4 +875,3 @@
        exit_cleanup(ret);
        return ret;
 }
-
Index: options.c
===================================================================
RCS file: /cvsroot/rsync/options.c,v
retrieving revision 1.76
diff -u -r1.76 options.c
--- options.c   23 Jan 2002 05:51:07 -0000      1.76
+++ options.c   25 Jan 2002 01:25:29 -0000
@@ -106,7 +106,7 @@
 int always_checksum = 0;
 int list_only = 0;
 
-char *batch_ext = NULL;
+char *batch_prefix = NULL;
 
 static int modify_window_set;
 
@@ -240,8 +240,8 @@
   rprintf(F,"     --log-format=FORMAT     log file transfers using specified 
format\n");  
   rprintf(F,"     --password-file=FILE    get password from FILE\n");
   rprintf(F,"     --bwlimit=KBPS          limit I/O bandwidth, KBytes per second\n");
-  rprintf(F,"     --read-batch=EXT        read batch file\n");
-  rprintf(F,"     --write-batch           write batch file\n");
+  rprintf(F,"     --read-batch=PREFIX     read batch file\n");
+  rprintf(F,"     --write-batch=PREFIX    write batch file\n");
   rprintf(F," -h, --help                  show this help screen\n");
 #ifdef INET6
   rprintf(F," -4                          prefer IPv4\n");
@@ -331,8 +331,8 @@
   {"address",          0,  POPT_ARG_STRING, &bind_address, 0},
   {"backup-dir",       0,  POPT_ARG_STRING, &backup_dir},
   {"hard-links",      'H', POPT_ARG_NONE,   &preserve_hard_links},
-  {"read-batch",       0,  POPT_ARG_STRING, &batch_ext, OPT_READ_BATCH},
-  {"write-batch",      0,  POPT_ARG_NONE,   &write_batch},
+  {"read-batch",       0,  POPT_ARG_STRING, &batch_prefix, OPT_READ_BATCH},
+  {"write-batch",      0,  POPT_ARG_STRING, &batch_prefix, OPT_WRITE_BATCH},
 #ifdef INET6
   {0,                '4', POPT_ARG_VAL,    &default_af_hint,   AF_INET },
   {0,                '6', POPT_ARG_VAL,    &default_af_hint,   AF_INET6 },
@@ -512,10 +512,15 @@
                        break;
 
                case OPT_READ_BATCH:
-                       /* The filename is stored in batch_ext for us by popt */
+                       /* popt stores the filename in batch_prefix for us */
                        read_batch = 1;
                        break;
 
+               case OPT_WRITE_BATCH:
+                       /* popt stores the filename in batch_prefix for us */
+                       write_batch = 1;
+                       break;
+
                default:
                         /* FIXME: If --daemon is specified, then errors for later
                          * parameters seem to disappear. */
@@ -528,6 +533,14 @@
                }
        }
 
+       if (write_batch && read_batch) {
+           snprintf(err_buf,sizeof(err_buf),
+               "write-batch and read-batch can not be used together\n");
+           rprintf(FERROR,"ERROR: write-batch and read-batch"
+               " can not be used together\n");
+           return 0;
+       }
+
         *argv = poptGetArgs(pc);
         if (*argv)
                 *argc = count_args(*argv);
@@ -549,8 +562,8 @@
        static char mdelete[30];
        static char mwindow[30];
        static char bw[50];
-       static char fext[20];
-       static char wbatch[14];
+       /* Leave room for ``--(write|read)-batch='' */
+       static char fext[MAXPATHLEN + 15];
 
        int i, x;
 
@@ -627,13 +640,14 @@
                args[ac++] = mdelete;
        }    
        
-       if (write_batch) {
-               snprintf(wbatch,sizeof(wbatch),"--write-batch");
-               args[ac++] = wbatch;
-       }
-
-       if (batch_ext != NULL) {
-               snprintf(fext,sizeof(fext),"--read-batch=%s",batch_ext);
+       if (batch_prefix != NULL) {
+               char *fmt = "";
+               if (read_batch)
+                   fmt = "--read-batch=%s";
+               else
+               if (write_batch)
+                   fmt = "--write-batch=%s";
+               snprintf(fext,sizeof(fext),fmt,batch_prefix);
                args[ac++] = fext;
        }
 
Index: proto.h
===================================================================
RCS file: /cvsroot/rsync/proto.h,v
retrieving revision 1.138
diff -u -r1.138 proto.h
--- proto.h     24 Jan 2002 08:18:35 -0000      1.138
+++ proto.h     25 Jan 2002 01:25:30 -0000
@@ -4,25 +4,23 @@
 char *auth_server(int fd, int module, char *addr, char *leader);
 void auth_client(int fd, char *user, char *challenge);
 int make_backup(char *fname);
-void create_batch_file_ext();
-void set_batch_file_ext(char *ext);
 void write_batch_flist_file(char *buff, int bytes_to_write);
 void write_batch_flist_info(int flist_count, struct file_struct **fptr);
 void write_char_bufs(char *buf);
 void write_batch_argvs_file(int argc, char *argv[]);
-struct file_list *create_flist_from_batch();
+struct file_list *create_flist_from_batch(void);
 int read_batch_flist_file(char *buff, int len);
 unsigned char read_batch_flags();
 void read_batch_flist_info(struct file_struct **fptr);
 void write_batch_csums_file(void *buff, int bytes_to_write);
-void close_batch_csums_file();
+void close_batch_csums_file(void);
 void write_batch_csum_info(int *flist_entry, int flist_count,
                           struct sum_struct *s);
 int read_batch_csums_file(char *buff, int len);
 void read_batch_csum_info(int flist_entry, struct sum_struct *s,
                          int *checksums_match);
 void write_batch_delta_file(char *buff, int bytes_to_write);
-void close_batch_delta_file();
+void close_batch_delta_file(void);
 int read_batch_delta_file(char *buff, int len);
 void show_flist(int index, struct file_struct **fptr);
 void show_argvs(int argc, char *argv[]);
Index: rsync.1
===================================================================
RCS file: /cvsroot/rsync/rsync.1,v
retrieving revision 1.104
diff -u -r1.104 rsync.1
--- rsync.1     23 Jan 2002 05:59:10 -0000      1.104
+++ rsync.1     25 Jan 2002 01:25:31 -0000
@@ -306,8 +306,8 @@
      --log-format=FORMAT     log file transfers using specified format
      --password-file=FILE    get password from FILE
      --bwlimit=KBPS          limit I/O bandwidth, KBytes per second
-     --read-batch=FILE       read batch file
-     --write-batch           write batch file
+     --read-batch=PREFIX     read batch file
+     --write-batch=PREFIX    write batch file
  -h, --help                  show this help screen
 
 
@@ -921,21 +921,21 @@
 \fBsrc_dir\fP
 .PP 
 .RS 
-$ rsync --write-batch [other rsync options here] \e
+$ rsync --write-batch=<prefix> [other rsync options here] \e
 .br 
 /somewhere/src_dir /somewhere/target_dir
 .RE 
 .PP 
-The generated files are labeled with a common timestamp:
+The generated files are labeled with a common prefix:
 .PP 
 .IP o 
-\fBrsync_argvs\&.<timestamp>\fP command-line arguments
+<prefix>\fB.rsync_argvs\fP command-line arguments
 .IP o 
-\fBrsync_flist\&.<timestamp>\fP rsync internal file metadata
+<prefix>\fB.rsync_flist\fP rsync internal file metadata
 .IP o 
-\fBrsync_csums\&.<timestamp>\fP rsync checksums
+<prefix>\fB.rsync_csums\fP rsync checksums
 .IP o 
-\fBrsync_delta\&.<timestamp>\fP data blocks for file update & change
+<prefix>\fB.rsync_delta\fP data blocks for file update & change
 .PP 
 See \fBhttp://www\&.ils\&.unc\&.edu/i2dsi/unc_rsync+\&.html\fP for papers and 
technical
 reports\&.
Index: rsync.yo
===================================================================
RCS file: /cvsroot/rsync/rsync.yo,v
retrieving revision 1.89
diff -u -r1.89 rsync.yo
--- rsync.yo    23 Jan 2002 05:59:10 -0000      1.89
+++ rsync.yo    25 Jan 2002 01:25:32 -0000
@@ -277,8 +277,8 @@
      --log-format=FORMAT     log file transfers using specified format
      --password-file=FILE    get password from FILE
      --bwlimit=KBPS          limit I/O bandwidth, KBytes per second
-     --read-batch=FILE       read batch file
-     --write-batch           write batch file
+     --read-batch=PREFIX     read batch file
+     --write-batch=PREFIX    write batch file
  -h, --help                  show this help screen
 
 
@@ -801,17 +801,17 @@
 bf(src_dir)
 
 quote(
-$ rsync --write-batch [other rsync options here] \nl()
+$ rsync --write-batch=<prefix> [other rsync options here] \nl()
            /somewhere/src_dir /somewhere/target_dir
 )
 
 The generated files are labeled with a common timestamp:
 
 itemize(
-it() bf(rsync_argvs.<timestamp>) command-line arguments
-it() bf(rsync_flist.<timestamp>) rsync internal file metadata
-it() bf(rsync_csums.<timestamp>) rsync checksums
-it() bf(rsync_delta.<timestamp>) data blocks for file update & change
+it() bf(<prefix>.rsync_argvs) command-line arguments
+it() bf(<prefix>.rsync_flist) rsync internal file metadata
+it() bf(<prefix>.rsync_csums) rsync checksums
+it() bf(<prefix>.rsync_delta) data blocks for file update & change
 )
 
 See bf(http://www.ils.unc.edu/i2dsi/unc_rsync+.html) for papers and technical

Feedback welcomed.

-- 
Jos Backus                 _/  _/_/_/        Santa Clara, CA
                          _/  _/   _/
                         _/  _/_/_/             
                    _/  _/  _/    _/
[EMAIL PROTECTED]     _/_/   _/_/_/            use Std::Disclaimer;

Reply via email to