- fprintf(f,"rsync version %s Copyright Andrew Tridgell and Paul Mackerras\n\n",
- VERSION);
- fprintf(f,"Usage:\t%s [options] src user@host:dest\nOR",RSYNC_NAME);
- fprintf(f,"\t%s [options] user@host:src dest\n\n",RSYNC_NAME);
- fprintf(f,"Options:\n");
- fprintf(f,"-v, --verbose increase verbosity\n");
- fprintf(f,"-c, --checksum always checksum\n");
- fprintf(f,"-a, --archive archive mode (same as -rlptDog)\n");
- fprintf(f,"-r, --recursive recurse into directories\n");
- fprintf(f,"-b, --backup make backups (default ~ extension)\n");
- fprintf(f,"-u, --update update only (don't overwrite newer files)\n");
- fprintf(f,"-l, --links preserve soft links\n");
- fprintf(f,"-H, --hard-links preserve hard links\n");
- fprintf(f,"-p, --perms preserve permissions\n");
- fprintf(f,"-o, --owner preserve owner (root only)\n");
- fprintf(f,"-g, --group preserve group\n");
- fprintf(f,"-D, --devices preserve devices (root only)\n");
- fprintf(f,"-t, --times preserve times\n");
- fprintf(f,"-S, --sparse handle sparse files efficiently\n");
- fprintf(f,"-n, --dry-run show what would have been transferred\n");
- fprintf(f,"-x, --one-file-system don't cross filesystem boundaries\n");
- fprintf(f,"-B, --block-size SIZE checksum blocking size\n");
- fprintf(f,"-e, --rsh COMMAND specify rsh replacement\n");
- fprintf(f," --rsync-path PATH specify path to rsync on the remote machine\n");
- fprintf(f,"-C, --cvs-exclude auto ignore files in the same way CVS does\n");
- fprintf(f," --delete delete files that don't exist on the sending side\n");
- fprintf(f,"-I, --ignore-times don't exclude files that match length and time\n");
- fprintf(f," --exclude FILE exclude file FILE\n");
- fprintf(f," --exclude-from FILE exclude files listed in FILE\n");
- fprintf(f," --suffix SUFFIX override backup suffix\n");
- fprintf(f," --csum-length LENGTH set the checksum length\n");
- fprintf(f," --version print version number\n");
-
- fprintf(f,"\n");
- fprintf(f,"the backup suffix defaults to %s\n",BACKUP_SUFFIX);
- fprintf(f,"the block size defaults to %d\n",BLOCK_SIZE);
+ 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;
+ if (cvs_exclude)
+ add_cvs_excludes();
+ if (delete_mode)
+ send_exclude_list(f_out);
+ flist = send_file_list(f_out,argc,argv);
+ if (verbose > 3)
+ rprintf(FINFO,"file list sent\n");
+
+ set_nonblocking(f_out);
+ if (f_in != f_out)
+ set_nonblocking(f_in);
+
+ 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;