- /*
- * 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",
- 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) /* Skip source directory on cmdline */
- continue;
- /*
- * FIXME:
- * I think directly manipulating argv[] is probably bogus
- */
- if (!strncmp(argv[i], "--write-batch",
- strlen("--write-batch"))) {
- /* Safer to change it here than script */
- /*
- * 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));
- }
-
- 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",
- filename, strerror(errno));
- close(fdb);
- exit_cleanup(1);
- }
- close(fdb);
-}
-
-struct file_list *create_flist_from_batch(void)
-{
- 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");
- }
-
- 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;
- char filename[MAXPATHLEN];
-
- if (fdb_open) {
- /* 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(filename, O_RDONLY, 0);
- if (fdb == -1) {
- rprintf(FERROR, "Batch file %s open error: %s\n",
- filename, 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;