/* just gets the file SRC and store in local file DEST * doesn't parse any LIST output * returns 0 on success, else -1 */ static int do_the_get(const char *src, const char *dest, putmode_t how, unsigned opt) { char *fulldest; char *tmp; transfer_mode_t type; type = ascii_transfer(src) ? tmAscii : gvDefaultType; if(test(opt, GET_ASCII)) type = tmAscii; else if(test(opt, GET_BINARY)) type = tmBinary; tmp = getcwd(NULL, 0); if (tmp == (char *)NULL) return -1; fulldest = path_absolute(dest, tmp, 0); #if 0 && (defined(HAVE_SETPROCTITLE) || defined(linux)) if(gvUseEnvString && ftp_connected()) setproctitle("%s, get %s", ftp->url->hostname, src); #endif int r = ftp_getfile(src, dest, how, type, test(opt, GET_VERBOSE) && !gvSighupReceived && !test(opt, GET_NOHUP) ? transfer : 0); if(r == 0 && (test(opt, GET_NOHUP) || gvSighupReceived)) { fprintf(stderr, "%s [%sb of ", src, human_size(ftp->ti.size)); fprintf(stderr, "%sb]\n", human_size(ftp->ti.total_size)); } if(test(opt, GET_NOHUP)) { if(r == 0) transfer_mail_msg(_("received %s\n"), src); else transfer_mail_msg(_("failed to receive %s: %s\n"), src, ftp_getreply(false)); } free(fulldest); #if 0 && (defined(HAVE_SETPROCTITLE) || defined(linux)) if(gvUseEnvString && ftp_connected()) setproctitle("%s", ftp->url->hostname); #endif free(tmp); return r; }
static int do_the_fxp(Ftp *srcftp, const char *src, Ftp *destftp, const char *dest, fxpmode_t how, unsigned opt) { transfer_mode_t type; if(test(opt, FXP_NOHUP)) fprintf(stderr, "%s\n", src); type = ascii_transfer(src) ? tmAscii : gvDefaultType; if(test(opt, FXP_ASCII)) type = tmAscii; else if(test(opt, FXP_BINARY)) type = tmBinary; #if 0 && (defined(HAVE_SETPROCTITLE) || defined(linux)) if(gvUseEnvString && ftp_connected()) setproctitle("%s, fxp %s", srcftp->url->hostname, src); #endif if(test(opt, FXP_VERBOSE)) { printf("%s\n", src); } const int r = ftp_fxpfile(srcftp, src, destftp, dest, how, type); #if 0 && (defined(HAVE_SETPROCTITLE) || defined(linux)) if(gvUseEnvString && ftp_connected()) setproctitle("%s", srcftp->url->hostname); #endif if(test(opt, FXP_NOHUP)) { if(r == 0) transfer_mail_msg(_("sent %s\n"), src); else transfer_mail_msg(_("failed to send %s: %s\n"), src, ftp_getreply(false)); } return r; }