1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 19:41:01 -05:00

Centralise defaults for non-saved options.

These are now specified in conf.h and filled in by automated code,
which means test_conf can make sure we didn't forget to provide them.

The default for a mapping type (not that we currently have any unsaved
ones) is expected to be empty.

Also, while adding test_conf checks, I realised I hadn't filled in the
rest of the comment in conf.h. Belatedly updated that.
This commit is contained in:
Simon Tatham
2023-09-22 16:30:24 +01:00
parent b29758c1b6
commit 4ec4892124
3 changed files with 56 additions and 11 deletions

View File

@ -670,15 +670,27 @@ void load_open_settings(settings_r *sesskey, Conf *conf)
int i;
char *prot;
conf_set_bool(conf, CONF_ssh_subsys, false); /* FIXME: load this properly */
conf_set_str(conf, CONF_remote_cmd, "");
conf_set_str(conf, CONF_remote_cmd2, "");
conf_set_str(conf, CONF_ssh_nc_host, "");
/* Load the settings simple enough to handle automatically */
for (size_t key = 0; key < N_CONFIG_OPTIONS; key++) {
const ConfKeyInfo *info = &conf_key_info[key];
if (!info->load_custom && !info->not_saved) {
if (info->not_saved) {
/* Mappings are assumed to default to empty */
if (info->subkey_type == CONF_TYPE_NONE) {
switch (info->value_type) {
case CONF_TYPE_STR:
conf_set_str(conf, key, info->default_value.sval);
break;
case CONF_TYPE_INT:
conf_set_int(conf, key, info->default_value.ival);
break;
case CONF_TYPE_BOOL:
conf_set_bool(conf, key, info->default_value.bval);
break;
default:
unreachable("bad key type in load_open_settings");
}
}
} else if (!info->load_custom) {
/* Mappings are handled individually below */
assert(info->subkey_type == CONF_TYPE_NONE);
switch (info->value_type) {
@ -994,7 +1006,6 @@ void load_open_settings(settings_r *sesskey, Conf *conf)
conf_set_int(conf, CONF_sshbug_hmac2, FORCE_ON);
}
}
conf_set_bool(conf, CONF_ssh_simple, false);
gppmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys);
}