X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=psftp.c;h=513f202b674cd81bd22946eca18746aa49e40750;hb=f6c1c8819b5d90a97124b62ee07b0e06d6bbb6c3;hp=92b57a2f363793b94b95aa9aa2128505dd13b6a0;hpb=3ad0c89feca43af8c4e8ddb913bc232ad4fb5521;p=PuTTY.git diff --git a/psftp.c b/psftp.c index 92b57a2f..513f202b 100644 --- a/psftp.c +++ b/psftp.c @@ -433,7 +433,7 @@ int sftp_get_file(char *fname, char *outfname, int recurse, int restart) xfer = xfer_download_init(fh, offset); while (!xfer_done(xfer)) { void *vbuf; - int ret, len; + int len; int wpos, wlen; xfer_download_queue(xfer); @@ -491,7 +491,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) struct sftp_request *req; uint64 offset; RFile *file; - int ret, err, eof; + int err = 0, eof; struct fxp_attrs attrs; long permissions; @@ -644,6 +644,7 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) if (restart) { char decbuf[30]; struct fxp_attrs attrs; + int ret; req = fxp_fstat_send(fh); pktin = sftp_wait_for_reply(req); @@ -651,11 +652,12 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) if (!ret) { printf("read size of %s: %s\n", outfname, fxp_error()); + err = 1; goto cleanup; } if (!(attrs.flags & SSH_FILEXFER_ATTR_SIZE)) { printf("read size of %s: size was not given\n", outfname); - ret = 0; + err = 1; goto cleanup; } offset = attrs.size; @@ -674,9 +676,8 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) * FIXME: we can use FXP_FSTAT here to get the file size, and * thus put up a progress bar. */ - ret = 1; xfer = xfer_upload_init(fh, offset); - err = eof = 0; + eof = 0; while ((!err && !eof) || !xfer_done(xfer)) { char buffer[4096]; int len, ret; @@ -712,11 +713,16 @@ int sftp_put_file(char *fname, char *outfname, int recurse, int restart) cleanup: req = fxp_close_send(fh); pktin = sftp_wait_for_reply(req); - fxp_close_recv(pktin, req); + if (!fxp_close_recv(pktin, req)) { + if (!err) { + printf("error while closing: %s", fxp_error()); + err = 1; + } + } close_rfile(file); - return ret; + return (err == 0) ? 1 : 0; } /* ---------------------------------------------------------------------- @@ -2618,6 +2624,10 @@ int sftp_senddata(char *buf, int len) back->send(backhandle, buf, len); return 1; } +int sftp_sendbuffer(void) +{ + return back->sendbuffer(backhandle); +} /* * Short description of parameters. @@ -2655,7 +2665,9 @@ static void usage(void) static void version(void) { - printf("psftp: %s\n", ver); + char *buildinfo_text = buildinfo("\n"); + printf("psftp: %s\n%s\n", ver, buildinfo_text); + sfree(buildinfo_text); cleanup_exit(1); } @@ -2941,6 +2953,8 @@ int psftp_main(int argc, char *argv[]) argv += i; back = NULL; + platform_psftp_post_option_setup(); + /* * If the loaded session provides a hostname, and a hostname has not * otherwise been specified, pop it in `userhost' so that