X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/7d2c1789c5a8ccf8a767fb11082bff34c1b7c5aa..d37c2d8198de28cc4076c560dff9a94f8452fe7c:/psftp.c diff --git a/psftp.c b/psftp.c index ae509f37..4657091f 100644 --- a/psftp.c +++ b/psftp.c @@ -1457,6 +1457,19 @@ void fatalbox(char *fmt, ...) cleanup_exit(1); } +void modalfatalbox(char *fmt, ...) +{ + char str[0x100]; /* Make the size big enough */ + va_list ap; + va_start(ap, fmt); + strcpy(str, "Fatal:"); + vsprintf(str + strlen(str), fmt, ap); + va_end(ap); + strcat(str, "\n"); + fputs(str, stderr); + + cleanup_exit(1); +} void connection_fatal(char *fmt, ...) { char str[0x100]; /* Make the size big enough */ @@ -1650,8 +1663,14 @@ static void usage(void) printf(" -bc output batchfile commands\n"); printf(" -be don't stop batchfile processing if errors\n"); printf(" -v show verbose messages\n"); + printf(" -load sessname Load settings from saved session\n"); + printf(" -l user connect with specified username\n"); printf(" -P port connect to specified port\n"); printf(" -pw passw login with specified password\n"); + printf(" -1 -2 force use of particular SSH protocol version\n"); + printf(" -C enable compression\n"); + printf(" -i key private key file for authentication\n"); + printf(" -batch disable all interactive prompts\n"); cleanup_exit(1); } @@ -1684,10 +1703,23 @@ static int psftp_connect(char *userhost, char *user, int portnumber) do_defaults(NULL, &cfg); strncpy(cfg.host, host, sizeof(cfg.host) - 1); cfg.host[sizeof(cfg.host) - 1] = '\0'; - cfg.port = 22; } /* + * Force use of SSH. (If they got the protocol wrong we assume the + * port is useless too.) + */ + if (cfg.protocol != PROT_SSH) { + cfg.protocol = PROT_SSH; + cfg.port = 22; + } + + /* + * Enact command-line overrides. + */ + cmdline_run_saved(); + + /* * Trim leading whitespace off the hostname if it's there. */ { @@ -1730,9 +1762,6 @@ static int psftp_connect(char *userhost, char *user, int portnumber) } } - if (cfg.protocol != PROT_SSH) - cfg.port = 22; - if (portnumber) cfg.port = portnumber; @@ -1789,6 +1818,17 @@ static int psftp_connect(char *userhost, char *user, int portnumber) return 0; } +void cmdline_error(char *p, ...) +{ + va_list ap; + fprintf(stderr, "pscp: "); + va_start(ap, p); + vfprintf(stderr, p, ap); + va_end(ap); + fputc('\n', stderr); + exit(1); +} + /* * Main program. Parse arguments etc. */ @@ -1802,6 +1842,7 @@ int main(int argc, char *argv[]) char *batchfile = NULL; flags = FLAG_STDERR | FLAG_INTERACTIVE; + cmdline_tooltype = TOOLTYPE_FILETRANSFER; ssh_get_line = &console_get_line; init_winsock(); sk_init(); @@ -1809,29 +1850,33 @@ int main(int argc, char *argv[]) userhost = user = NULL; for (i = 1; i < argc; i++) { + int ret; if (argv[i][0] != '-') { - if (userhost) - usage(); - else - userhost = dupstr(argv[i]); - } else if (strcmp(argv[i], "-v") == 0) { - verbose = 1, flags |= FLAG_VERBOSE; + if (userhost) + usage(); + else + userhost = dupstr(argv[i]); + continue; + } + ret = cmdline_process_param(argv[i], i+1