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.
git-svn-id: svn://svn.tartarus.org/sgt/putty@7321
cda61777-01e9-0310-a592-
d414129be87e
-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;
struct gui_data *inst, Config *cfg)
{
int err = 0;
exit(1);
} else if(p[0] != '-' && (!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 {
/* do nothing */
} else {
/* Splatter this argument so it doesn't clutter a ps listing */
memset(argv[1], 0, strlen(argv[1]));
} else {
/* 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);
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);
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 */
}
!cfgbox(&inst->cfg))
exit(0); /* config box hit Cancel */
}
/* Things pterm.c needs from {ptermm,uxputty}.c */
char *make_default_wintitle(char *hostname);
/* 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);
/* pterm.c needs this special function in xkeysym.c */
int keysym_to_unicode(int keysym);
-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. */
}
{
return 0; /* pterm doesn't have any. */
}
const int use_event_log = 1, new_session = 1, saved_sessions = 1;
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)
cfg->host[sizeof(cfg->host) - 1] = '\0';
got_host = 1;
}
cfg->host[sizeof(cfg->host) - 1] = '\0';
got_host = 1;
}
+ if (got_host)
+ *allow_launch = TRUE;
{
char *p;
int got_host = 0;
{
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. */
default_protocol = be_default_protocol;
/* Find the appropriate default port. */
if (!cfg_launchable(&cfg) && !do_config()) {
cleanup_exit(0);
}
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
} else if (*p == '&') {
/*
* An initial & means we've been given a command line
cfg = *cp;
UnmapViewOfFile(cp);
CloseHandle(filemap);
cfg = *cp;
UnmapViewOfFile(cp);
CloseHandle(filemap);
} else if (!do_config()) {
cleanup_exit(0);
}
} else if (!do_config()) {
cleanup_exit(0);
}
} else {
/*
* Otherwise, break up the command line and deal with
} else {
/*
* Otherwise, break up the command line and deal with
- if ((!loaded_session || !cfg_launchable(&cfg)) &&
- !do_config()) {
+ if (loaded_session || got_host)
+ allow_launch = TRUE;
+
+ if ((!allow_launch || !cfg_launchable(&cfg)) && !do_config()) {