- for (i = 0; i < argc; ++i) {
- if (i == argc - 2)
- continue;
- /*
- * FIXME:
- * I think directly manipulating argv[] is probably bogus
- */
- 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 {
- strlcat(buff, argv[i], sizeof(buff));
- }
-
- if (i < (argc - 1)) {
- strlcat(buff, " ", sizeof(buff));
- }
- }
- 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));
- close(fdb);
- exit_cleanup(1);
- }
- close(fdb);
-}
-
-struct file_list *create_flist_from_batch()
-{
- unsigned char flags;
-
- fdb_open = 1;
- fdb_close = 0;
-
- batch_flist = (struct file_list *) malloc(sizeof(batch_flist[0]));
- if (!batch_flist) {
- out_of_memory("create_flist_from_batch");
- }
- batch_flist->count = 0;
- batch_flist->malloced = 1000;
- batch_flist->files =
- (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 */
- }
-
- for (flags = read_batch_flags(); flags; flags = read_batch_flags()) {
-
- int i = batch_flist->count;
-
- if (i >= batch_flist->malloced) {
- if (batch_flist->malloced < 1000)
- batch_flist->malloced += 1000;
- else
- batch_flist->malloced *= 2;
- batch_flist->files =
- (struct file_struct **) realloc(batch_flist->
- files,
- sizeof
- (batch_flist->
- files[0]) *
- batch_flist->
- malloced);
- if (!batch_flist->files)
- out_of_memory("create_flist_from_batch");
- }
- read_batch_flist_info(&batch_flist->files[i]);
- batch_flist->files[i]->flags = flags;
-
- batch_flist->count++;
- }
-
- return batch_flist;
-
-}
-
-int read_batch_flist_file(char *buff, int len)
-{
- int bytes_read;
-
- if (fdb_open) {
-
- /* Set up file extension */
- strcat(rsync_flist_file, batch_file_ext);
-
- /* Open batch flist file for reading */
- fdb = do_open(rsync_flist_file, O_RDONLY, 0);
- if (fdb == -1) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- rsync_flist_file, strerror(errno));
- close(fdb);
- exit_cleanup(1);
+ if (protocol_version < 29)
+ flag_ptr[7] = NULL;
+ else if (protocol_version < 30)
+ flag_ptr[9] = NULL;
+ tweaked_append = append_mode == 1;
+ tweaked_append_verify = append_mode == 2;
+#ifdef ICONV_OPTION
+ tweaked_iconv = iconv_opt != NULL;
+#endif
+ for (i = 0; flag_ptr[i]; i++) {
+ int set = batch_stream_flags & (1 << i) ? 1 : 0;
+ if (*flag_ptr[i] != set) {
+ if (i == 9) {
+ rprintf(FERROR,
+ "%s specify the --iconv option to use this batch file.\n",
+ set ? "Please" : "Do not");
+ exit_cleanup(RERR_SYNTAX);
+ }
+ if (INFO_GTE(MISC, 1)) {
+ rprintf(FINFO,
+ "%sing the %s option to match the batchfile.\n",
+ set ? "Sett" : "Clear", flag_name[i]);
+ }
+ *flag_ptr[i] = set;