1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

Since we're now able to cope with Default Settings describing a

launchable session without getting confused by it, we can relax the
restriction on storing a host name in DS, which has attracted a
steady stream of complaints over the past six or seven years.

[originally from svn r7266]
This commit is contained in:
Simon Tatham 2007-02-10 17:12:06 +00:00
parent 5d76e00dac
commit 856ed4ae73
4 changed files with 18 additions and 24 deletions

View File

@ -392,7 +392,7 @@ static int load_selected_session(struct sessionsaver_data *ssd,
return 0;
}
isdef = !strcmp(ssd->sesslist.sessions[i], "Default Settings");
load_settings(ssd->sesslist.sessions[i], !isdef, cfg);
load_settings(ssd->sesslist.sessions[i], cfg);
if (!isdef) {
strncpy(savedsession, ssd->sesslist.sessions[i],
SAVEDSESSION_LEN);
@ -501,7 +501,7 @@ static void sessionsaver_handler(union control *ctrl, void *dlg,
}
}
{
char *errmsg = save_settings(savedsession, !isdef, cfg);
char *errmsg = save_settings(savedsession, cfg);
if (errmsg) {
dlg_error_msg(dlg, errmsg);
sfree(errmsg);

View File

@ -237,7 +237,7 @@ static OSErr mac_opensessionfrom(FSSpec *fss)
err = -9999;
goto fail;
}
load_open_settings(sesshandle, TRUE, &s->cfg);
load_open_settings(sesshandle, &s->cfg);
close_settings_r(sesshandle);
mac_startsession(s);
@ -321,7 +321,7 @@ void mac_savesession(void)
assert(s->hasfile);
sesshandle = open_settings_w_fsp(&s->savefile);
if (sesshandle == NULL) return; /* XXX report error */
save_open_settings(sesshandle, TRUE, &s->cfg);
save_open_settings(sesshandle, &s->cfg);
close_settings_w(sesshandle);
}
@ -342,7 +342,7 @@ void mac_savesessionas(void)
}
sesshandle = open_settings_w_fsp(&sfr.sfFile);
if (sesshandle == NULL) return; /* XXX report error */
save_open_settings(sesshandle, TRUE, &s->cfg);
save_open_settings(sesshandle, &s->cfg);
close_settings_w(sesshandle);
s->hasfile = TRUE;
s->savefile = sfr.sfFile;

View File

@ -777,10 +777,10 @@ void random_destroy_seed(void);
/*
* Exports from settings.c.
*/
char *save_settings(char *section, int do_host, Config * cfg);
void save_open_settings(void *sesskey, int do_host, Config *cfg);
void load_settings(char *section, int do_host, Config * cfg);
void load_open_settings(void *sesskey, int do_host, Config *cfg);
char *save_settings(char *section, Config * cfg);
void save_open_settings(void *sesskey, Config *cfg);
void load_settings(char *section, Config * cfg);
void load_open_settings(void *sesskey, Config *cfg);
void get_sesslist(struct sesslist *, int allocate);
void do_defaults(char *, Config *);
void registry_cleanup(void);

View File

@ -231,7 +231,7 @@ static void wprefs(void *sesskey, char *name,
write_setting_s(sesskey, name, buf);
}
char *save_settings(char *section, int do_host, Config * cfg)
char *save_settings(char *section, Config * cfg)
{
void *sesskey;
char *errmsg;
@ -239,20 +239,18 @@ char *save_settings(char *section, int do_host, Config * cfg)
sesskey = open_settings_w(section, &errmsg);
if (!sesskey)
return errmsg;
save_open_settings(sesskey, do_host, cfg);
save_open_settings(sesskey, cfg);
close_settings_w(sesskey);
return NULL;
}
void save_open_settings(void *sesskey, int do_host, Config *cfg)
void save_open_settings(void *sesskey, Config *cfg)
{
int i;
char *p;
write_setting_i(sesskey, "Present", 1);
if (do_host) {
write_setting_s(sesskey, "HostName", cfg->host);
}
write_setting_s(sesskey, "HostName", cfg->host);
write_setting_filename(sesskey, "LogFileName", cfg->logfilename);
write_setting_i(sesskey, "LogType", cfg->logtype);
write_setting_i(sesskey, "LogFileClash", cfg->logxfovr);
@ -447,16 +445,16 @@ void save_open_settings(void *sesskey, int do_host, Config *cfg)
write_setting_i(sesskey, "SerialFlowControl", cfg->serflow);
}
void load_settings(char *section, int do_host, Config * cfg)
void load_settings(char *section, Config * cfg)
{
void *sesskey;
sesskey = open_settings_r(section);
load_open_settings(sesskey, do_host, cfg);
load_open_settings(sesskey, cfg);
close_settings_r(sesskey);
}
void load_open_settings(void *sesskey, int do_host, Config *cfg)
void load_open_settings(void *sesskey, Config *cfg)
{
int i;
char prot[10];
@ -466,11 +464,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg)
cfg->remote_cmd_ptr2 = NULL;
cfg->ssh_nc_host[0] = '\0';
if (do_host) {
gpps(sesskey, "HostName", "", cfg->host, sizeof(cfg->host));
} else {
cfg->host[0] = '\0'; /* blank hostname */
}
gpps(sesskey, "HostName", "", cfg->host, sizeof(cfg->host));
gppfile(sesskey, "LogFileName", &cfg->logfilename);
gppi(sesskey, "LogType", 0, &cfg->logtype);
gppi(sesskey, "LogFileClash", LGXF_ASK, &cfg->logxfovr);
@ -785,7 +779,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg)
void do_defaults(char *session, Config * cfg)
{
load_settings(session, (session != NULL && *session), cfg);
load_settings(session, cfg);
}
static int sessioncmp(const void *av, const void *bv)