X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/bfa5400d3e166e1acc25dbe0b7f1fdf74b272568..cdd310bb1a216ee7713926b6cd813016fe5343ee:/scp.c diff --git a/scp.c b/scp.c index 70f13be9..f3aa5e05 100644 --- a/scp.c +++ b/scp.c @@ -290,7 +290,7 @@ static void bump(char *fmt, ...) if (back != NULL && back->socket(backhandle) != NULL) { char ch; back->special(backhandle, TS_EOF); - ssh_scp_recv(&ch, 1); + ssh_scp_recv((unsigned char *) &ch, 1); } if (gui_mode) @@ -455,7 +455,7 @@ static void print_stats(char *name, unsigned long size, unsigned long done, pct = (int) (100 * (done * 1.0 / size)); if (gui_mode) { - gui_update_stats(name, size, pct, elap, done, eta, + gui_update_stats(name, size, pct, elap, done, eta, (unsigned long) ratebs); } else { len = printf("\r%-25.25s | %10ld kB | %5.1f kB/s | ETA: %8s | %3d%%", @@ -466,6 +466,8 @@ static void print_stats(char *name, unsigned long size, unsigned long done, if (done == size) printf("\n"); + + fflush(stdout); } } @@ -529,7 +531,7 @@ static int response(void) char ch, resp, rbuf[2048]; int p; - if (ssh_scp_recv(&resp, 1) <= 0) + if (ssh_scp_recv((unsigned char *) &resp, 1) <= 0) bump("Lost connection"); p = 0; @@ -542,7 +544,7 @@ static int response(void) case 1: /* error */ case 2: /* fatal error */ do { - if (ssh_scp_recv(&ch, 1) <= 0) + if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0) bump("Protocol error: Lost connection"); rbuf[p++] = ch; } while (p < sizeof(rbuf) && ch != '\n'); @@ -558,11 +560,11 @@ static int response(void) int sftp_recvdata(char *buf, int len) { - return ssh_scp_recv(buf, len); + return ssh_scp_recv((unsigned char *) buf, len); } int sftp_senddata(char *buf, int len) { - back->send(backhandle, (unsigned char *) buf, len); + back->send(backhandle, buf, len); return 1; } @@ -1318,14 +1320,14 @@ int scp_get_sink_action(struct scp_sink_action *act) bufsize = 0; while (!done) { - if (ssh_scp_recv(&ch, 1) <= 0) + if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0) return 1; if (ch == '\n') bump("Protocol error: Unexpected newline"); i = 0; action = ch; do { - if (ssh_scp_recv(&ch, 1) <= 0) + if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0) bump("Lost connection"); if (i >= bufsize) { bufsize = i + 128; @@ -1440,7 +1442,7 @@ int scp_recv_filedata(char *data, int len) return actuallen; } else { - return ssh_scp_recv(data, len); + return ssh_scp_recv((unsigned char *) data, len); } } @@ -2032,7 +2034,7 @@ static void get_dir_list(int argc, char *argv[]) if (using_sftp) { scp_sftp_listdir(src); } else { - while (ssh_scp_recv(&c, 1) > 0) + while (ssh_scp_recv((unsigned char *) &c, 1) > 0) tell_char(stdout, c); } } @@ -2047,7 +2049,7 @@ static void usage(void) printf("Usage: pscp [options] [user@]host:source target\n"); printf (" pscp [options] source [source...] [user@]host:target\n"); - printf(" pscp [options] -ls user@host:filespec\n"); + printf(" pscp [options] -ls [user@]host:filespec\n"); printf("Options:\n"); printf(" -p preserve file attributes\n"); printf(" -q quiet, don't show statistics\n"); @@ -2062,6 +2064,7 @@ static void usage(void) printf(" -i key private key file for authentication\n"); printf(" -batch disable all interactive prompts\n"); printf(" -unsafe allow server-side wildcards (DANGEROUS)\n"); + printf(" -V print version information\n"); #if 0 /* * -gui is an internal option, used by GUI front ends to get @@ -2076,6 +2079,12 @@ static void usage(void) cleanup_exit(1); } +void version(void) +{ + printf("pscp: %s\n", ver); + cleanup_exit(1); +} + void cmdline_error(char *p, ...) { va_list ap; @@ -2127,6 +2136,8 @@ int psftp_main(int argc, char *argv[]) statistics = 0; } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-?") == 0) { usage(); + } else if (strcmp(argv[i], "-V") == 0) { + version(); } else if (strcmp(argv[i], "-gui") == 0 && i + 1 < argc) { gui_enable(argv[++i]); gui_mode = 1; @@ -2169,13 +2180,19 @@ int psftp_main(int argc, char *argv[]) if (back != NULL && back->socket(backhandle) != NULL) { char ch; back->special(backhandle, TS_EOF); - ssh_scp_recv(&ch, 1); + ssh_scp_recv((unsigned char *) &ch, 1); } random_save_seed(); if (gui_mode) gui_send_errcount(list, errs); + cmdline_cleanup(); + console_provide_logctx(NULL); + back->free(backhandle); + backhandle = NULL; + back = NULL; + sk_cleanup(); return (errs == 0 ? 0 : 1); }