]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Implement Simon's suggestion of moving DEFAULT_PROTOCOL into a per-backend-
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Wed, 15 Jan 2003 20:47:50 +0000 (20:47 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Wed, 15 Jan 2003 20:47:50 +0000 (20:47 +0000)
link-module const variable `be_default_protocol' which suggests a sensible
default to the front end (which can ignore it). (DEFAULT_PORT is replaced by a
lookup in the backend[] table.)
Still not pretty, but it does mean that the recent fix for `ssh-default'
doesn't break PuTTYtel.

[originally from svn r2613]

be_all.c
be_nossh.c
mac/mac.c
putty.h
window.c

index 96dac532b6aa8f8bcb6f828036a259d743f512c0..a48cc7076f4b154b9fdfefabbc06342d7cca9990 100644 (file)
--- a/be_all.c
+++ b/be_all.c
@@ -6,6 +6,12 @@
 #include <stdio.h>
 #include "putty.h"
 
+#ifdef TELNET_DEFAULT
+const int be_default_protocol = PROT_TELNET;
+#else
+const int be_default_protocol = PROT_SSH;
+#endif
+
 struct backend_list backends[] = {
     {PROT_SSH, "ssh", &ssh_backend},
     {PROT_TELNET, "telnet", &telnet_backend},
index 76355cba0b1a4f3e187ef6270a9dc693589302b0..ceef3cf2396a47bbbafa0bd0305c11207217cd85 100644 (file)
@@ -7,6 +7,8 @@
 #include <stdio.h>
 #include "putty.h"
 
+const int be_default_protocol = PROT_TELNET;
+
 struct backend_list backends[] = {
     {PROT_TELNET, "telnet", &telnet_backend},
     {PROT_RLOGIN, "rlogin", &rlogin_backend},
index 6335aabef2430c45fa106f1f5b55cdf41ae72f2a..fa2ec2fe4c2aadf78f666d2f74a3980cba09a03e 100644 (file)
--- a/mac/mac.c
+++ b/mac/mac.c
@@ -1,4 +1,4 @@
-/* $Id: mac.c,v 1.29 2003/01/14 19:42:00 ben Exp $ */
+/* $Id: mac.c,v 1.30 2003/01/15 20:47:50 jacob Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -200,8 +200,17 @@ static void mac_startup(void) {
     windows.about = NULL;
     windows.licence = NULL;
 
-    default_protocol = DEFAULT_PROTOCOL;
-    default_port = DEFAULT_PORT;
+    default_protocol = be_default_protocol;
+    /* Find the appropriate default port. */
+    {
+       default_port = 0; /* illegal */
+       int i;
+       for (i = 0; backends[i].backend != NULL; i++)
+           if (backends[i].protocol == default_protocol) {
+               default_port = backends[i].backend->default_port;
+               break;
+           }
+    }
     flags = FLAG_INTERACTIVE;
 
     {
diff --git a/putty.h b/putty.h
index 28320de003abd71e1b01cb0b772df9ad0401f04a..516760aeeb95d0ddfa29dc67cdd687e742d85597 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -217,6 +217,12 @@ extern struct backend_list {
     Backend *backend;
 } backends[];
 
+/*
+ * Suggested default protocol provided by the backend link module.
+ * The application is free to ignore this.
+ */
+extern const int be_default_protocol;
+
 struct config_tag {
     /* Basic options */
     char host[512];
@@ -370,18 +376,6 @@ struct config_tag {
     int shadowboldoffset;
 };
 
-/*
- * You can compile with -DTELNET_DEFAULT to have telnet by default
- * (otherwise SSH is the default).
- */
-#ifdef TELNET_DEFAULT
-#define DEFAULT_PROTOCOL PROT_TELNET
-#define DEFAULT_PORT 23
-#else
-#define DEFAULT_PROTOCOL PROT_SSH
-#define DEFAULT_PORT 22
-#endif
-
 /*
  * Some global flags denoting the type of application.
  * 
index ac8ac85c870cc8658e7ee750e710899f9f280fc6..04d3d61f0f92b65806a6ed3ec7be4fc42cde9f6d 100644 (file)
--- a/window.c
+++ b/window.c
@@ -272,8 +272,17 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
        char *p;
        int got_host = 0;
 
-       default_protocol = DEFAULT_PROTOCOL;
-       default_port = DEFAULT_PORT;
+       default_protocol = be_default_protocol;
+       /* Find the appropriate default port. */
+       {
+           default_port = 0; /* illegal */
+           int i;
+           for (i = 0; backends[i].backend != NULL; i++)
+               if (backends[i].protocol == default_protocol) {
+                   default_port = backends[i].backend->default_port;
+                   break;
+               }
+       }
        cfg.logtype = LGTYP_NONE;
 
        do_defaults(NULL, &cfg);