X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/7c4e3b7ce851dea34492cff0d10b96a8a1b125a2..820ebe3b54a21cfb8d42e43c567d952415c1d05d:/plink.c diff --git a/plink.c b/plink.c index 4db0de82..d61bbeb5 100644 --- a/plink.c +++ b/plink.c @@ -62,8 +62,6 @@ void cmdline_error(char *p, ...) exit(1); } -static char *password = NULL; - HANDLE inhandle, outhandle, errhandle; DWORD orig_console_mode; @@ -71,6 +69,7 @@ WSAEVENT netevent; static Backend *back; static void *backhandle; +static Config cfg; int term_ldisc(Terminal *term, int mode) { @@ -167,7 +166,8 @@ void try_output(int is_stderr) } } -int from_backend(void *frontend_handle, int is_stderr, char *data, int len) +int from_backend(void *frontend_handle, int is_stderr, + const char *data, int len) { int osize, esize; @@ -207,6 +207,7 @@ static void usage(void) printf(" -batch disable all interactive prompts\n"); printf("The following options only apply to SSH connections:\n"); printf(" -pw passw login with specified password\n"); + printf(" -D listen-port Dynamic SOCKS-based port forwarding\n"); printf(" -L listen-port:host:port Forward local port to " "remote address\n"); printf(" -R listen-port:host:port Forward remote port to" @@ -296,7 +297,8 @@ int main(int argc, char **argv) while (--argc) { char *p = *++argv; if (*p == '-') { - int ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL), 1); + int ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL), + 1, &cfg); if (ret == -2) { fprintf(stderr, "plink: option \"%s\" requires an argument\n", p); @@ -409,13 +411,13 @@ int main(int argc, char **argv) while (*p) { if (cmdlen >= cmdsize) { cmdsize = cmdlen + 512; - command = srealloc(command, cmdsize); + command = sresize(command, cmdsize, char); } command[cmdlen++]=*p++; } if (cmdlen >= cmdsize) { cmdsize = cmdlen + 512; - command = srealloc(command, cmdsize); + command = sresize(command, cmdsize, char); } command[cmdlen++]=' '; /* always add trailing space */ if (--argc) p = *++argv; @@ -462,7 +464,7 @@ int main(int argc, char **argv) /* * Perform command-line overrides on session configuration. */ - cmdline_run_saved(); + cmdline_run_saved(&cfg); /* * Trim a colon suffix off the hostname if it's there. @@ -540,14 +542,15 @@ int main(int argc, char **argv) int nodelay = cfg.tcp_nodelay && (GetFileType(GetStdHandle(STD_INPUT_HANDLE)) == FILE_TYPE_CHAR); - error = back->init(NULL, &backhandle, cfg.host, cfg.port, + error = back->init(NULL, &backhandle, &cfg, cfg.host, cfg.port, &realhost, nodelay); if (error) { fprintf(stderr, "Unable to open connection:\n%s", error); return 1; } - logctx = log_init(NULL); + logctx = log_init(NULL, &cfg); back->provide_logctx(backhandle, logctx); + console_provide_logctx(logctx); sfree(realhost); } connopen = 1; @@ -649,7 +652,7 @@ int main(int argc, char **argv) /* Expand the buffer if necessary. */ if (i > sksize) { sksize = i + 16; - sklist = srealloc(sklist, sksize * sizeof(*sklist)); + sklist = sresize(sklist, sksize, SOCKET); } /* Retrieve the sockets into sklist. */