X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/8f203108d91b3aef5a379a6d49f6cb2a546eebbc..ab21de779596591471529758bbf6d54b3176ea29:/window.c diff --git a/window.c b/window.c index 8a87584f..aa6fda5d 100644 --- a/window.c +++ b/window.c @@ -173,16 +173,39 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { } } else if (*p) { char *q = p; - while (*p && !isspace(*p)) p++; - if (*p) - *p++ = '\0'; - strncpy (cfg.host, q, sizeof(cfg.host)-1); - cfg.host[sizeof(cfg.host)-1] = '\0'; - while (*p && isspace(*p)) p++; - if (*p) - cfg.port = atoi(p); - else - cfg.port = -1; + /* + * If the hostname starts with "telnet://", set the + * protocol to Telnet and process the string as a + * Telnet URL. + */ + if (!strncmp(q, "telnet://", 9)) { + char c; + + q += 9; + cfg.protocol = PROT_TELNET; + p = q; + while (*p && *p != ':' && *p != '/') p++; + c = *p; + if (*p) + *p++ = '\0'; + if (c == ':') + cfg.port = atoi(p); + else + cfg.port = -1; + strncpy (cfg.host, q, sizeof(cfg.host)-1); + cfg.host[sizeof(cfg.host)-1] = '\0'; + } else { + while (*p && !isspace(*p)) p++; + if (*p) + *p++ = '\0'; + strncpy (cfg.host, q, sizeof(cfg.host)-1); + cfg.host[sizeof(cfg.host)-1] = '\0'; + while (*p && isspace(*p)) p++; + if (*p) + cfg.port = atoi(p); + else + cfg.port = -1; + } } else { if (!do_config()) { WSACleanup();