X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/93b581bd031b2270deb7f45440e61a1044fe94da..70cd2027d47923b19665b4b1e31f462ec63f8c57:/psftp.c diff --git a/psftp.c b/psftp.c index 6dae40ac..d498b07d 100644 --- a/psftp.c +++ b/psftp.c @@ -188,15 +188,15 @@ int sftp_cmd_quit(struct sftp_command *cmd) */ static int sftp_ls_compare(const void *av, const void *bv) { - const struct fxp_name *a = (const struct fxp_name *) av; - const struct fxp_name *b = (const struct fxp_name *) bv; - return strcmp(a->filename, b->filename); + const struct fxp_name *const *a = (const struct fxp_name *const *) av; + const struct fxp_name *const *b = (const struct fxp_name *const *) bv; + return strcmp((*a)->filename, (*b)->filename); } int sftp_cmd_ls(struct sftp_command *cmd) { struct fxp_handle *dirh; struct fxp_names *names; - struct fxp_name *ournames; + struct fxp_name **ournames; int nnames, namesize; char *dir, *cdir; int i; @@ -247,9 +247,8 @@ int sftp_cmd_ls(struct sftp_command *cmd) } for (i = 0; i < names->nnames; i++) - ournames[nnames++] = names->names[i]; + ournames[nnames++] = fxp_dup_name(&names->names[i]); - names->nnames = 0; /* prevent free_names */ fxp_free_names(names); } fxp_close(dirh); @@ -263,8 +262,11 @@ int sftp_cmd_ls(struct sftp_command *cmd) /* * And print them. */ - for (i = 0; i < nnames; i++) - printf("%s\n", ournames[i].longname); + for (i = 0; i < nnames; i++) { + printf("%s\n", ournames[i]->longname); + fxp_free_name(ournames[i]); + } + sfree(ournames); } sfree(cdir); @@ -1686,6 +1688,11 @@ static int psftp_connect(char *userhost, char *user, int portnumber) } /* + * Enact command-line overrides. + */ + cmdline_run_saved(); + + /* * Trim leading whitespace off the hostname if it's there. */ { @@ -1787,6 +1794,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. */ @@ -1800,6 +1818,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(); @@ -1807,29 +1826,35 @@ 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