X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f68363d29c314736cc8023a18d2b424a07c33c6d..2ccb2fc83a62d8ded4b0287b72384ce22a83000c:/psftp.c diff --git a/psftp.c b/psftp.c index 904ddb88..53b6616d 100644 --- a/psftp.c +++ b/psftp.c @@ -189,6 +189,11 @@ static int bare_name_compare(const void *av, const void *bv) return strcmp(*a, *b); } +static void not_connected(void) +{ + printf("psftp: not connected to a host; use \"open host.name\"\n"); +} + /* ---------------------------------------------------------------------- * The meat of the `get' and `put' commands. */ @@ -936,7 +941,7 @@ int sftp_cmd_quit(struct sftp_command *cmd) int sftp_cmd_close(struct sftp_command *cmd) { if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -966,7 +971,7 @@ int sftp_cmd_ls(struct sftp_command *cmd) int i; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1088,7 +1093,7 @@ int sftp_cmd_cd(struct sftp_command *cmd) char *dir; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1131,7 +1136,7 @@ int sftp_cmd_cd(struct sftp_command *cmd) int sftp_cmd_pwd(struct sftp_command *cmd) { if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1155,7 +1160,7 @@ int sftp_general_get(struct sftp_command *cmd, int restart, int multiple) int recurse = FALSE; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1269,7 +1274,7 @@ int sftp_general_put(struct sftp_command *cmd, int restart, int multiple) int recurse = FALSE; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1370,7 +1375,7 @@ int sftp_cmd_mkdir(struct sftp_command *cmd) int i, ret; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1394,7 +1399,6 @@ int sftp_cmd_mkdir(struct sftp_command *cmd) if (!result) { printf("mkdir %s: %s\n", dir, fxp_error()); - sfree(dir); ret = 0; } else printf("mkdir %s: OK\n", dir); @@ -1431,7 +1435,7 @@ int sftp_cmd_rmdir(struct sftp_command *cmd) int i, ret; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1473,7 +1477,7 @@ int sftp_cmd_rm(struct sftp_command *cmd) int i, ret; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1568,7 +1572,7 @@ int sftp_cmd_mv(struct sftp_command *cmd) int i, ret; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -1662,7 +1666,7 @@ int sftp_cmd_chmod(struct sftp_command *cmd) struct sftp_context_chmod actx, *ctx = &actx; if (back == NULL) { - printf("psftp: not connected to a host; use \"open host.name\"\n"); + not_connected(); return 0; } @@ -2568,6 +2572,8 @@ static void usage(void) printf("%s\n", ver); printf("Usage: psftp [options] [user@]host\n"); printf("Options:\n"); + printf(" -V print version information and exit\n"); + printf(" -pgpfp print PGP key fingerprints and exit\n"); printf(" -b file use specified batchfile\n"); printf(" -bc output batchfile commands\n"); printf(" -be don't stop batchfile processing if errors\n"); @@ -2581,7 +2587,6 @@ static void usage(void) printf(" -C enable compression\n"); printf(" -i key private key file for authentication\n"); printf(" -batch disable all interactive prompts\n"); - printf(" -V print version information\n"); cleanup_exit(1); } @@ -2738,7 +2743,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber) cfg.nopty = TRUE; /* - * Set up fallback option, for SSH1 servers or servers with the + * Set up fallback option, for SSH-1 servers or servers with the * sftp subsystem not enabled but the server binary installed * in the usual place. We only support fallback on Unix * systems, and we use a kludgy piece of shellery which should @@ -2845,6 +2850,9 @@ int psftp_main(int argc, char *argv[]) } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-?") == 0) { usage(); + } else if (strcmp(argv[i], "-pgpfp") == 0) { + pgp_fingerprints(); + return 1; } else if (strcmp(argv[i], "-V") == 0) { version(); } else if (strcmp(argv[i], "-batch") == 0) {