Enable PuTTY command line to deal with "user@host" format
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 25 Sep 2000 09:27:26 +0000 (09:27 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 25 Sep 2000 09:27:26 +0000 (09:27 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@620 cda61777-01e9-0310-a592-d414129be87e

window.c

index 6dba5b1..d94c23b 100644 (file)
--- a/window.c
+++ b/window.c
@@ -229,6 +229,19 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
                return 0;
            }
        }
+
+       /* See if host is of the form user@host */
+       if (cfg.host[0] != '\0') {
+           char *atsign = strchr(cfg.host, '@');
+           /* Make sure we're not overflowing the user field */
+           if (atsign) {
+               if (atsign-cfg.host < sizeof cfg.username) {
+                   strncpy (cfg.username, cfg.host, atsign-cfg.host);
+                   cfg.username[atsign-cfg.host] = '\0';
+               }
+               memmove(cfg.host, atsign+1, 1+strlen(atsign+1));
+           }
+       }
     }
 
     /*