1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-05-28 23:34:49 -05:00

Add the ability to do ssh by default: using -ssh command line option,

or by manually adding protocol and port settings to Default Settings in the
Registry, or by compiling with -DSSH_DEFAULT

[originally from svn r260]
This commit is contained in:
Simon Tatham 1999-10-27 14:28:11 +00:00
parent 3992fc48f1
commit a019c66786
3 changed files with 44 additions and 13 deletions

13
putty.h
View File

@ -130,7 +130,20 @@ typedef struct {
short wordness[256]; short wordness[256];
} Config; } 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 Config cfg;
GLOBAL int default_protocol;
GLOBAL int default_port;
/* /*
* Exports from window.c. * Exports from window.c.

View File

@ -210,6 +210,7 @@ static void load_settings (char *section, int do_host) {
int i; int i;
HKEY subkey1, sesskey; HKEY subkey1, sesskey;
char *p; char *p;
char prot[10];
p = malloc(3*strlen(section)+1); p = malloc(3*strlen(section)+1);
mungestr(section, p); mungestr(section, p);
@ -225,20 +226,16 @@ static void load_settings (char *section, int do_host) {
free(p); free(p);
if (do_host) { gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host));
char prot[10]; gppi (sesskey, "PortNumber", default_port, &cfg.port);
gpps (sesskey, "HostName", "", cfg.host, sizeof(cfg.host)); gpps (sesskey, "Protocol", "default", prot, 10);
gppi (sesskey, "PortNumber", 23, &cfg.port); if (!strcmp(prot, "ssh"))
gpps (sesskey, "Protocol", "telnet", prot, 10); cfg.protocol = PROT_SSH;
if (!strcmp(prot, "ssh")) else if (!strcmp(prot, "telnet"))
cfg.protocol = PROT_SSH;
else
cfg.protocol = PROT_TELNET;
} else {
cfg.protocol = PROT_TELNET; cfg.protocol = PROT_TELNET;
cfg.port = 23; else
*cfg.host = '\0'; cfg.protocol = default_protocol;
}
gppi (sesskey, "CloseOnExit", 1, &cfg.close_on_exit); gppi (sesskey, "CloseOnExit", 1, &cfg.close_on_exit);
gpps (sesskey, "TerminalType", "xterm", cfg.termtype, gpps (sesskey, "TerminalType", "xterm", cfg.termtype,
sizeof(cfg.termtype)); sizeof(cfg.termtype));

View File

@ -100,11 +100,32 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
{ {
char *p; char *p;
default_protocol = DEFAULT_PROTOCOL;
default_port = DEFAULT_PORT;
do_defaults(NULL); do_defaults(NULL);
p = cmdline; p = cmdline;
while (*p && isspace(*p)) p++; 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. * An initial @ means to activate a saved session.
*/ */