-enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
- OPT_EXCLUDE_FROM,OPT_DELETE,OPT_NUMERIC_IDS,OPT_RSYNC_PATH,
- OPT_FORCE,OPT_TIMEOUT};
-
-static char *short_options = "oblLWHpguDCtcahvrRIxnSe:B:T:z";
-
-static struct option long_options[] = {
- {"version", 0, 0, OPT_VERSION},
- {"server", 0, 0, OPT_SERVER},
- {"sender", 0, 0, OPT_SENDER},
- {"delete", 0, 0, OPT_DELETE},
- {"force", 0, 0, OPT_FORCE},
- {"numeric-ids", 0, 0, OPT_NUMERIC_IDS},
- {"exclude", 1, 0, OPT_EXCLUDE},
- {"exclude-from",1, 0, OPT_EXCLUDE_FROM},
- {"rsync-path", 1, 0, OPT_RSYNC_PATH},
- {"one-file-system",0, 0, 'x'},
- {"ignore-times",0, 0, 'I'},
- {"help", 0, 0, 'h'},
- {"dry-run", 0, 0, 'n'},
- {"sparse", 0, 0, 'S'},
- {"cvs-exclude", 0, 0, 'C'},
- {"archive", 0, 0, 'a'},
- {"checksum", 0, 0, 'c'},
- {"backup", 0, 0, 'b'},
- {"update", 0, 0, 'u'},
- {"verbose", 0, 0, 'v'},
- {"recursive", 0, 0, 'r'},
- {"relative", 0, 0, 'R'},
- {"devices", 0, 0, 'D'},
- {"perms", 0, 0, 'p'},
- {"links", 0, 0, 'l'},
- {"copy-links", 0, 0, 'L'},
- {"whole-file", 0, 0, 'W'},
- {"hard-links", 0, 0, 'H'},
- {"owner", 0, 0, 'o'},
- {"group", 0, 0, 'g'},
- {"times", 0, 0, 't'},
- {"rsh", 1, 0, 'e'},
- {"suffix", 1, 0, OPT_SUFFIX},
- {"block-size", 1, 0, 'B'},
- {"timeout", 1, 0, OPT_TIMEOUT},
- {"temp-dir", 1, 0, 'T'},
- {"compress", 0, 0, 'z'},
- {0,0,0,0}};
-
-RETSIGTYPE sigusr1_handler(int val) {
- exit_cleanup(1);
+int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
+{
+ struct file_list *flist;
+ int status = 0, status2 = 0;
+ char *local_name = NULL;
+ extern int am_sender;
+ extern int list_only;
+
+ setup_protocol(f_out,f_in);
+
+ if (am_sender) {
+ extern int cvs_exclude;
+ extern int delete_mode;
+ extern int delete_excluded;
+ if (cvs_exclude)
+ add_cvs_excludes();
+ if (delete_mode && !delete_excluded)
+ send_exclude_list(f_out);
+ flist = send_file_list(f_out,argc,argv);
+ if (verbose > 3)
+ rprintf(FINFO,"file list sent\n");
+
+ send_files(flist,f_out,f_in);
+ if (pid != -1) {
+ if (verbose > 3)
+ rprintf(FINFO,"client_run waiting on %d\n",pid);
+ io_flush();
+ waitpid(pid, &status, 0);
+ }
+ report(-1);
+ exit_cleanup(status);
+ }
+
+ if (argc == 0) list_only = 1;
+
+ send_exclude_list(f_out);
+
+ flist = recv_file_list(f_in);
+ if (!flist || flist->count == 0) {
+ rprintf(FINFO,"client: nothing to do\n");
+ exit_cleanup(0);
+ }
+
+ local_name = get_local_name(flist,argv[0]);
+
+ status2 = do_recv(f_in,f_out,flist,local_name);
+
+ if (pid != -1) {
+ if (verbose > 3)
+ rprintf(FINFO,"client_run2 waiting on %d\n",pid);
+ io_flush();
+ waitpid(pid, &status, 0);
+ }
+
+ return status | status2;