X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/32874aeac8dacbca26663777b39a79efc5d8dc4b..2d466ffd08675d26db45e524c2fe6a8cf4628e2b:/scp.c diff --git a/scp.c b/scp.c index f414eb8f..871d01de 100644 --- a/scp.c +++ b/scp.c @@ -46,6 +46,7 @@ #define WM_RET_ERR_CNT ( WM_APP_BASE+406 ) #define WM_LS_RET_ERR_CNT ( WM_APP_BASE+407 ) +static int list = 0; static int verbose = 0; static int recursive = 0; static int preserve = 0; @@ -70,8 +71,6 @@ static void sink(char *targ, char *src); static void tell_char(FILE * stream, char c); static void tell_str(FILE * stream, char *str); static void tell_user(FILE * stream, char *fmt, ...); -static void send_char_msg(unsigned int msg_id, char c); -static void send_str_msg(unsigned int msg_id, char *str); static void gui_update_stats(char *name, unsigned long size, int percentage, unsigned long elapsed); @@ -239,6 +238,16 @@ void fatalbox(char *fmt, ...) va_end(ap); strcat(str, "\n"); tell_str(stderr, str); + errs++; + + if (gui_mode) { + unsigned int msg_id = WM_RET_ERR_CNT; + if (list) + msg_id = WM_LS_RET_ERR_CNT; + while (!PostMessage + ((HWND) atoi(gui_hwnd), msg_id, (WPARAM) errs, + 0 /*lParam */ ))SleepEx(1000, TRUE); + } exit(1); } @@ -252,6 +261,16 @@ void connection_fatal(char *fmt, ...) va_end(ap); strcat(str, "\n"); tell_str(stderr, str); + errs++; + + if (gui_mode) { + unsigned int msg_id = WM_RET_ERR_CNT; + if (list) + msg_id = WM_LS_RET_ERR_CNT; + while (!PostMessage + ((HWND) atoi(gui_hwnd), msg_id, (WPARAM) errs, + 0 /*lParam */ ))SleepEx(1000, TRUE); + } exit(1); } @@ -398,12 +417,23 @@ static void bump(char *fmt, ...) va_end(ap); strcat(str, "\n"); tell_str(stderr, str); + errs++; if (back != NULL && back->socket() != NULL) { char ch; back->special(TS_EOF); ssh_scp_recv(&ch, 1); } + + if (gui_mode) { + unsigned int msg_id = WM_RET_ERR_CNT; + if (list) + msg_id = WM_LS_RET_ERR_CNT; + while (!PostMessage + ((HWND) atoi(gui_hwnd), msg_id, (WPARAM) errs, + 0 /*lParam */ ))SleepEx(1000, TRUE); + } + exit(1); } @@ -517,6 +547,7 @@ static void do_cmd(char *host, char *user, char *cmd) ssh_scp_init(); if (verbose && realhost != NULL) tell_user(stderr, "Connected to %s\n", realhost); + sfree(realhost); } /* @@ -710,11 +741,9 @@ static void source(char *src) if (response()) return; - if (statistics) { - stat_bytes = 0; - stat_starttime = time(NULL); - stat_lasttime = 0; - } + stat_bytes = 0; + stat_starttime = time(NULL); + stat_lasttime = 0; for (i = 0; i < size; i += 4096) { char transbuf[4096]; @@ -905,17 +934,15 @@ static void sink(char *targ, char *src) back->send("", 1); - if (statistics) { - stat_bytes = 0; - stat_starttime = time(NULL); - stat_lasttime = 0; - if ((stat_name = strrchr(namebuf, '/')) == NULL) - stat_name = namebuf; - else - stat_name++; - if (strrchr(stat_name, '\\') != NULL) - stat_name = strrchr(stat_name, '\\') + 1; - } + stat_bytes = 0; + stat_starttime = time(NULL); + stat_lasttime = 0; + if ((stat_name = strrchr(namebuf, '/')) == NULL) + stat_name = namebuf; + else + stat_name++; + if (strrchr(stat_name, '\\') != NULL) + stat_name = strrchr(stat_name, '\\') + 1; for (i = 0; i < size; i += 4096) { char transbuf[4096]; @@ -1235,7 +1262,6 @@ static void usage(void) int main(int argc, char *argv[]) { int i; - int list = 0; default_protocol = PROT_TELNET;