From 4e8bc59ffaa374198feda6a24058008ea6cdb3af Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 21 Jul 2000 10:53:24 +0000 Subject: [PATCH] Enable handling of telnet:// URLs on command line git-svn-id: svn://svn.tartarus.org/sgt/putty@514 cda61777-01e9-0310-a592-d414129be87e --- window.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/window.c b/window.c index 8a87584f..e9419d79 100644 --- a/window.c +++ b/window.c @@ -173,16 +173,35 @@ 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)) { + q += 9; + cfg.protocol = PROT_TELNET; + p = q; + while (*p && *p != ':') p++; + if (*p) { + *p++ = '\0'; + 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(); -- 2.11.0