зеркало из https://github.com/github/putty.git
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:
Родитель
3992fc48f1
Коммит
a019c66786
13
putty.h
13
putty.h
|
@ -130,7 +130,20 @@ typedef struct {
|
|||
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.
|
||||
|
|
23
windlg.c
23
windlg.c
|
@ -210,6 +210,7 @@ static void load_settings (char *section, int do_host) {
|
|||
int i;
|
||||
HKEY subkey1, sesskey;
|
||||
char *p;
|
||||
char prot[10];
|
||||
|
||||
p = malloc(3*strlen(section)+1);
|
||||
mungestr(section, p);
|
||||
|
@ -225,20 +226,16 @@ static void load_settings (char *section, int do_host) {
|
|||
|
||||
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));
|
||||
|
|
21
window.c
21
window.c
|
@ -100,11 +100,32 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
|
|||
{
|
||||
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.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче