short wordness[256];
} Config;
+/*
+ * You can compile with -DSSH_DEFAULT to have ssh by default.
+ */
+#ifndef SSH_DEFAULT
+#define DEFAULT_PROTOCOL PROT_TELNET
+#define DEFAULT_PORT 23
+#else
+#define DEFAULT_PROTOCOL PROT_SSH
+#define DEFAULT_PORT 22
+#endif
+
GLOBAL Config cfg;
+GLOBAL int default_protocol;
+GLOBAL int default_port;
/*
* Exports from window.c.
int i;
HKEY subkey1, sesskey;
char *p;
+ char prot[10];
p = malloc(3*strlen(section)+1);
mungestr(section, p);
free(p);
- if (do_host) {
- char prot[10];
- gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host));
- gppi (sesskey, "PortNumber", 23, &cfg.port);
- gpps (sesskey, "Protocol", "telnet", prot, 10);
- if (!strcmp(prot, "ssh"))
- cfg.protocol = PROT_SSH;
- else
- cfg.protocol = PROT_TELNET;
- } else {
+ gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host));
+ gppi (sesskey, "PortNumber", default_port, &cfg.port);
+ gpps (sesskey, "Protocol", "default", prot, 10);
+ if (!strcmp(prot, "ssh"))
+ cfg.protocol = PROT_SSH;
+ else if (!strcmp(prot, "telnet"))
cfg.protocol = PROT_TELNET;
- cfg.port = 23;
- *cfg.host = '\0';
- }
+ else
+ cfg.protocol = default_protocol;
+
gppi (sesskey, "CloseOnExit", 1, &cfg.close_on_exit);
gpps (sesskey, "TerminalType", "xterm", cfg.termtype,
sizeof(cfg.termtype));
{
char *p;
+ default_protocol = DEFAULT_PROTOCOL;
+ default_port = DEFAULT_PORT;
+
do_defaults(NULL);
p = cmdline;
while (*p && isspace(*p)) p++;
+ /*
+ * Process command line options first. Yes, this can be
+ * done better, and it will be as soon as I have the
+ * energy...
+ */
+ while (*p == '-') {
+ char *q = p + strcspn(p, " \t");
+ p++;
+ if (q == p + 3 &&
+ tolower(p[0]) == 's' &&
+ tolower(p[1]) == 's' &&
+ tolower(p[2]) == 'h') {
+ default_protocol = cfg.protocol = PROT_SSH;
+ default_port = cfg.port = 22;
+ }
+ p = q + strspn(q, " \t");
+ }
+
/*
* An initial @ means to activate a saved session.
*/