mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Since r7265, a user could not launch a PuTTY session to a specific host by
simply specifying a hostname on the command line -- this would bring up the
config dialog. Use a slightly more sophisticated notion of whether the user
meant to launch a session.
[originally from svn r7321]
[r7265 == 5d76e00dac
]
This commit is contained in:
parent
fe1909e0e2
commit
befd797f97
@ -2408,7 +2408,7 @@ static void help(FILE *fp) {
|
||||
}
|
||||
}
|
||||
|
||||
int do_cmdline(int argc, char **argv, int do_everything,
|
||||
int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
|
||||
struct gui_data *inst, Config *cfg)
|
||||
{
|
||||
int err = 0;
|
||||
@ -2614,7 +2614,8 @@ int do_cmdline(int argc, char **argv, int do_everything,
|
||||
exit(1);
|
||||
|
||||
} else if(p[0] != '-' && (!do_everything ||
|
||||
process_nonoption_arg(p, cfg))) {
|
||||
process_nonoption_arg(p, cfg,
|
||||
allow_launch))) {
|
||||
/* do nothing */
|
||||
|
||||
} else {
|
||||
@ -3477,15 +3478,22 @@ int pt_main(int argc, char **argv)
|
||||
/* Splatter this argument so it doesn't clutter a ps listing */
|
||||
memset(argv[1], 0, strlen(argv[1]));
|
||||
} else {
|
||||
if (do_cmdline(argc, argv, 0, inst, &inst->cfg))
|
||||
/* By default, we bring up the config dialog, rather than launching
|
||||
* a session. This gets set to TRUE if something happens to change
|
||||
* that (e.g., a hostname is specified on the command-line). */
|
||||
int allow_launch = FALSE;
|
||||
if (do_cmdline(argc, argv, 0, &allow_launch, inst, &inst->cfg))
|
||||
exit(1); /* pre-defaults pass to get -class */
|
||||
do_defaults(NULL, &inst->cfg);
|
||||
if (do_cmdline(argc, argv, 1, inst, &inst->cfg))
|
||||
if (do_cmdline(argc, argv, 1, &allow_launch, inst, &inst->cfg))
|
||||
exit(1); /* post-defaults, do everything */
|
||||
|
||||
cmdline_run_saved(&inst->cfg);
|
||||
|
||||
if ((!loaded_session || !cfg_launchable(&inst->cfg)) &&
|
||||
if (loaded_session)
|
||||
allow_launch = TRUE;
|
||||
|
||||
if ((!allow_launch || !cfg_launchable(&inst->cfg)) &&
|
||||
!cfgbox(&inst->cfg))
|
||||
exit(0); /* config box hit Cancel */
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ int reallyclose(void *frontend);
|
||||
|
||||
/* Things pterm.c needs from {ptermm,uxputty}.c */
|
||||
char *make_default_wintitle(char *hostname);
|
||||
int process_nonoption_arg(char *arg, Config *cfg);
|
||||
int process_nonoption_arg(char *arg, Config *cfg, int *allow_launch);
|
||||
|
||||
/* pterm.c needs this special function in xkeysym.c */
|
||||
int keysym_to_unicode(int keysym);
|
||||
|
@ -33,7 +33,7 @@ void cleanup_exit(int code)
|
||||
exit(code);
|
||||
}
|
||||
|
||||
int process_nonoption_arg(char *arg, Config *cfg)
|
||||
int process_nonoption_arg(char *arg, Config *cfg, int *allow_launch)
|
||||
{
|
||||
return 0; /* pterm doesn't have any. */
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ static int got_host = 0;
|
||||
|
||||
const int use_event_log = 1, new_session = 1, saved_sessions = 1;
|
||||
|
||||
int process_nonoption_arg(char *arg, Config *cfg)
|
||||
int process_nonoption_arg(char *arg, Config *cfg, int *allow_launch)
|
||||
{
|
||||
char *p, *q = arg;
|
||||
|
||||
@ -104,6 +104,8 @@ int process_nonoption_arg(char *arg, Config *cfg)
|
||||
cfg->host[sizeof(cfg->host) - 1] = '\0';
|
||||
got_host = 1;
|
||||
}
|
||||
if (got_host)
|
||||
*allow_launch = TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -361,6 +361,10 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
{
|
||||
char *p;
|
||||
int got_host = 0;
|
||||
/* By default, we bring up the config dialog, rather than launching
|
||||
* a session. This gets set to TRUE if something happens to change
|
||||
* that (e.g., a hostname is specified on the command-line). */
|
||||
int allow_launch = FALSE;
|
||||
|
||||
default_protocol = be_default_protocol;
|
||||
/* Find the appropriate default port. */
|
||||
@ -397,7 +401,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
if (!cfg_launchable(&cfg) && !do_config()) {
|
||||
cleanup_exit(0);
|
||||
}
|
||||
loaded_session = TRUE; /* allow it to be launched directly */
|
||||
allow_launch = TRUE; /* allow it to be launched directly */
|
||||
} else if (*p == '&') {
|
||||
/*
|
||||
* An initial & means we've been given a command line
|
||||
@ -413,10 +417,10 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
cfg = *cp;
|
||||
UnmapViewOfFile(cp);
|
||||
CloseHandle(filemap);
|
||||
loaded_session = TRUE;
|
||||
} else if (!do_config()) {
|
||||
cleanup_exit(0);
|
||||
}
|
||||
allow_launch = TRUE;
|
||||
} else {
|
||||
/*
|
||||
* Otherwise, break up the command line and deal with
|
||||
@ -541,8 +545,10 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
|
||||
cmdline_run_saved(&cfg);
|
||||
|
||||
if ((!loaded_session || !cfg_launchable(&cfg)) &&
|
||||
!do_config()) {
|
||||
if (loaded_session || got_host)
|
||||
allow_launch = TRUE;
|
||||
|
||||
if ((!allow_launch || !cfg_launchable(&cfg)) && !do_config()) {
|
||||
cleanup_exit(0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user