X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/e5708bc76a893af69cd1bfac5e213aa61559f1e7..89e97516fedf1d0a7fe9c569bb569fa7ea872afa:/unix/uxplink.c diff --git a/unix/uxplink.c b/unix/uxplink.c index 735d297b..b4fa6da1 100644 --- a/unix/uxplink.c +++ b/unix/uxplink.c @@ -25,6 +25,8 @@ #define MAX_STDIN_BACKLOG 4096 +void *logctx; + void fatalbox(char *p, ...) { va_list ap; @@ -33,6 +35,10 @@ void fatalbox(char *p, ...) vfprintf(stderr, p, ap); va_end(ap); fputc('\n', stderr); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void modalfatalbox(char *p, ...) @@ -43,6 +49,10 @@ void modalfatalbox(char *p, ...) vfprintf(stderr, p, ap); va_end(ap); fputc('\n', stderr); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void connection_fatal(void *frontend, char *p, ...) @@ -53,6 +63,10 @@ void connection_fatal(void *frontend, char *p, ...) vfprintf(stderr, p, ap); va_end(ap); fputc('\n', stderr); + if (logctx) { + log_free(logctx); + logctx = NULL; + } cleanup_exit(1); } void cmdline_error(char *p, ...) @@ -82,6 +96,8 @@ char *platform_default_s(const char *name) return dupstr(getenv("TERM")); if (!strcmp(name, "UserName")) return get_username(); + if (!strcmp(name, "SerialLine")) + return dupstr("/dev/ttyS0"); return NULL; } @@ -532,6 +548,8 @@ static void usage(void) printf(" -m file read remote command(s) from file\n"); printf(" -s remote command is an SSH subsystem (SSH-2 only)\n"); printf(" -N don't start a shell/command (SSH-2 only)\n"); + printf(" -nc host:port\n"); + printf(" open tunnel in place of session (SSH-2 only)\n"); exit(1); } @@ -552,7 +570,7 @@ int main(int argc, char **argv) int exitcode; int errors; int use_subsystem = 0; - void *ldisc, *logctx; + void *ldisc; long now; fdlist = NULL; @@ -627,7 +645,7 @@ int main(int argc, char **argv) errors = 1; } } else if (*p) { - if (!*cfg.host) { + if (!cfg_launchable(&cfg)) { char *q = p; /* @@ -701,7 +719,7 @@ int main(int argc, char **argv) { Config cfg2; do_defaults(host, &cfg2); - if (loaded_session || cfg2.host[0] == '\0') { + if (loaded_session || !cfg_launchable(&cfg2)) { /* No settings for this host; use defaults */ /* (or session was already loaded with -load) */ strncpy(cfg.host, host, sizeof(cfg.host) - 1); @@ -755,7 +773,7 @@ int main(int argc, char **argv) if (errors) return 1; - if (!*cfg.host) { + if (!cfg_launchable(&cfg)) { usage(); } @@ -811,7 +829,7 @@ int main(int argc, char **argv) cfg.host[p1] = '\0'; } - if (!cfg.remote_cmd_ptr && !*cfg.remote_cmd) + if (!cfg.remote_cmd_ptr && !*cfg.remote_cmd && !*cfg.ssh_nc_host) flags |= FLAG_INTERACTIVE; /* @@ -899,7 +917,7 @@ int main(int argc, char **argv) FD_SET_MAX(signalpipe[0], maxfd, rset); if (connopen && !sending && - back->socket(backhandle) != NULL && + back->connected(backhandle) && back->sendok(backhandle) && back->sendbuffer(backhandle) < MAX_STDIN_BACKLOG) { /* If we're OK to send, then try to read from stdin. */ @@ -1014,7 +1032,7 @@ int main(int argc, char **argv) char buf[4096]; int ret; - if (connopen && back->socket(backhandle) != NULL) { + if (connopen && back->connected(backhandle)) { ret = read(0, buf, sizeof(buf)); if (ret < 0) { perror("stdin: read"); @@ -1039,7 +1057,7 @@ int main(int argc, char **argv) try_output(1); } - if ((!connopen || back->socket(backhandle) == NULL) && + if ((!connopen || !back->connected(backhandle)) && bufchain_size(&stdout_data) == 0 && bufchain_size(&stderr_data) == 0) break; /* we closed the connection */