]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - psftp.c
first pass
[PuTTY.git] / psftp.c
diff --git a/psftp.c b/psftp.c
index d8c4d071f0c3b4c42be646a8aa3d481d4ee71696..5394c1fbb9150007422c8f9d0b39da66ff8aa37e 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -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 = 0, 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);
@@ -712,7 +713,12 @@ 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);
 
@@ -1044,6 +1050,7 @@ int sftp_cmd_ls(struct sftp_command *cmd)
 
     if (dirh == NULL) {
        printf("Unable to open %s: %s\n", dir, fxp_error());
+       return 0;
     } else {
        nnames = namesize = 0;
        ournames = NULL;
@@ -2651,6 +2658,8 @@ static void usage(void)
     printf("  -hostkey aa:bb:cc:...\n");
     printf("            manually specify a host key (may be repeated)\n");
     printf("  -batch    disable all interactive prompts\n");
+    printf("  -proxycmd command\n");
+    printf("            use 'command' as local proxy\n");
     printf("  -sshlog file\n");
     printf("  -sshrawlog file\n");
     printf("            log protocol details to a file\n");
@@ -2659,8 +2668,10 @@ static void usage(void)
 
 static void version(void)
 {
-  printf("psftp: %s\n", ver);
-  cleanup_exit(1);
+  char *buildinfo_text = buildinfo("\n");
+  printf("psftp: %s\n%s\n", ver, buildinfo_text);
+  sfree(buildinfo_text);
+  exit(0);
 }
 
 /*
@@ -2829,6 +2840,11 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
 
     back = &ssh_backend;
 
+    logctx = log_init(NULL, conf);
+    console_provide_logctx(logctx);
+
+    platform_psftp_pre_conn_setup();
+
     err = back->init(NULL, &backhandle, conf,
                     conf_get_str(conf, CONF_host),
                     conf_get_int(conf, CONF_port),
@@ -2838,9 +2854,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
        fprintf(stderr, "ssh_init: %s\n", err);
        return 1;
     }
-    logctx = log_init(NULL, conf);
     back->provide_logctx(backhandle, logctx);
-    console_provide_logctx(logctx);
     while (!back->sendok(backhandle)) {
        if (back->exitcode(backhandle) >= 0)
            return 1;
@@ -2945,8 +2959,6 @@ 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