X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/514702987c9252fcb0ab98882a6603b3bd0505ce..2dc6356a02ebe2e5c0428cefc18e64882d85b4a6:/psftp.c diff --git a/psftp.c b/psftp.c index a278260b..94d7364b 100644 --- a/psftp.c +++ b/psftp.c @@ -32,6 +32,8 @@ static int do_sftp_init(void); */ char *pwd, *homedir; +static Backend *back; +static void *backhandle; /* ---------------------------------------------------------------------- * Higher-level helper functions used in commands. @@ -830,7 +832,7 @@ int sftp_cmd_chmod(struct sftp_command *cmd) if (!(subset & 06777) && (perms &~ subset)) { printf("chmod: file mode '%.*s' contains no user/group/other" " specifier and permissions other than 't' \n", - strcspn(modebegin, ","), modebegin, *mode); + strcspn(modebegin, ","), modebegin); return 0; } perms &= subset; @@ -1446,45 +1448,48 @@ static int verbose = 0; */ void fatalbox(char *fmt, ...) { - char str[0x100]; /* Make the size big enough */ + char *str, *str2; va_list ap; va_start(ap, fmt); - strcpy(str, "Fatal:"); - vsprintf(str + strlen(str), fmt, ap); + str = dupvprintf(fmt, ap); + str2 = dupcat("Fatal: ", str, "\n", NULL); + sfree(str); va_end(ap); - strcat(str, "\n"); - fputs(str, stderr); + fputs(str2, stderr); + sfree(str2); cleanup_exit(1); } void modalfatalbox(char *fmt, ...) { - char str[0x100]; /* Make the size big enough */ + char *str, *str2; va_list ap; va_start(ap, fmt); - strcpy(str, "Fatal:"); - vsprintf(str + strlen(str), fmt, ap); + str = dupvprintf(fmt, ap); + str2 = dupcat("Fatal: ", str, "\n", NULL); + sfree(str); va_end(ap); - strcat(str, "\n"); - fputs(str, stderr); + fputs(str2, stderr); + sfree(str2); cleanup_exit(1); } -void connection_fatal(char *fmt, ...) +void connection_fatal(void *frontend, char *fmt, ...) { - char str[0x100]; /* Make the size big enough */ + char *str, *str2; va_list ap; va_start(ap, fmt); - strcpy(str, "Fatal:"); - vsprintf(str + strlen(str), fmt, ap); + str = dupvprintf(fmt, ap); + str2 = dupcat("Fatal: ", str, "\n", NULL); + sfree(str); va_end(ap); - strcat(str, "\n"); - fputs(str, stderr); + fputs(str2, stderr); + sfree(str2); cleanup_exit(1); } -void ldisc_send(char *buf, int len, int interactive) +void ldisc_send(void *handle, char *buf, int len, int interactive) { /* * This is only here because of the calls to ldisc_send(NULL, @@ -1767,6 +1772,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber) } if (!cfg.username[0]) { printf("login as: "); + fflush(stdout); if (!fgets(cfg.username, sizeof(cfg.username), stdin)) { fprintf(stderr, "psftp: aborting\n"); cleanup_exit(1); @@ -1827,6 +1833,8 @@ static int psftp_connect(char *userhost, char *user, int portnumber) fprintf(stderr, "ssh_init: %s\n", err); return 1; } + logctx = log_init(NULL); + back->provide_logctx(backhandle, logctx); ssh_sftp_init(); if (verbose && realhost != NULL) printf("Connected to %s\n", realhost); @@ -1836,11 +1844,11 @@ static int psftp_connect(char *userhost, char *user, int portnumber) void cmdline_error(char *p, ...) { va_list ap; - fprintf(stderr, "pscp: "); + fprintf(stderr, "psftp: "); va_start(ap, p); vfprintf(stderr, p, ap); va_end(ap); - fputc('\n', stderr); + fprintf(stderr, "\n try typing \"psftp -h\" for help\n"); exit(1); } @@ -1855,6 +1863,7 @@ int main(int argc, char *argv[]) int mode = 0; int modeflags = 0; char *batchfile = NULL; + int errors = 0; flags = FLAG_STDERR | FLAG_INTERACTIVE; cmdline_tooltype = TOOLTYPE_FILETRANSFER; @@ -1864,6 +1873,7 @@ int main(int argc, char *argv[]) userhost = user = NULL; + errors = 0; for (i = 1; i < argc; i++) { int ret; if (argv[i][0] != '-') { @@ -1898,7 +1908,7 @@ int main(int argc, char *argv[]) i++; break; } else { - usage(); + cmdline_error("unknown option \"%s\"", argv[i]); } } argc -= i;