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]
#include <stdio.h>
#include "putty.h"
#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},
struct backend_list backends[] = {
{PROT_SSH, "ssh", &ssh_backend},
{PROT_TELNET, "telnet", &telnet_backend},
#include <stdio.h>
#include "putty.h"
#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},
struct backend_list backends[] = {
{PROT_TELNET, "telnet", &telnet_backend},
{PROT_RLOGIN, "rlogin", &rlogin_backend},
-/* $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.
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
windows.about = NULL;
windows.licence = NULL;
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;
{
flags = FLAG_INTERACTIVE;
{
Backend *backend;
} backends[];
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];
struct config_tag {
/* Basic options */
char host[512];
-/*
- * 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.
*
/*
* Some global flags denoting the type of application.
*
char *p;
int got_host = 0;
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);
cfg.logtype = LGTYP_NONE;
do_defaults(NULL, &cfg);