1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

load_settings, do_defaults: return a boolean success flag.

Now the caller of one of those functions can tell whether the session
it loaded actually existed at all, or whether it was made up by
settings.c.
This commit is contained in:
Simon Tatham 2019-02-27 20:30:47 +00:00
parent 69b216c116
commit 55123b105d
2 changed files with 13 additions and 6 deletions

View File

@ -1516,16 +1516,20 @@ void random_destroy_seed(void);
/*
* Exports from settings.c.
*
* load_settings() and do_defaults() return false if the provided
* session name didn't actually exist. But they still fill in the
* provided Conf with _something_.
*/
const struct BackendVtable *backend_vt_from_name(const char *name);
const struct BackendVtable *backend_vt_from_proto(int proto);
char *get_remote_username(Conf *conf); /* dynamically allocated */
char *save_settings(const char *section, Conf *conf);
void save_open_settings(settings_w *sesskey, Conf *conf);
void load_settings(const char *section, Conf *conf);
bool load_settings(const char *section, Conf *conf);
void load_open_settings(settings_r *sesskey, Conf *conf);
void get_sesslist(struct sesslist *, bool allocate);
void do_defaults(const char *, Conf *);
bool do_defaults(const char *, Conf *);
void registry_cleanup(void);
/*

View File

@ -780,16 +780,19 @@ void save_open_settings(settings_w *sesskey, Conf *conf)
wmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys, false);
}
void load_settings(const char *section, Conf *conf)
bool load_settings(const char *section, Conf *conf)
{
settings_r *sesskey;
sesskey = open_settings_r(section);
bool exists = (sesskey != NULL);
load_open_settings(sesskey, conf);
close_settings_r(sesskey);
if (conf_launchable(conf))
if (exists && conf_launchable(conf))
add_session_to_jumplist(section);
return exists;
}
void load_open_settings(settings_r *sesskey, Conf *conf)
@ -1242,9 +1245,9 @@ void load_open_settings(settings_r *sesskey, Conf *conf)
gppmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys);
}
void do_defaults(const char *session, Conf *conf)
bool do_defaults(const char *session, Conf *conf)
{
load_settings(session, conf);
return load_settings(session, conf);
}
static int sessioncmp(const void *av, const void *bv)