mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 03:52:49 -05:00
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an arbitrary length limit on every single one of those settings which is stored in string form. In place of it is 'Conf', an opaque data type everywhere outside the new file conf.c, which stores a list of (key, value) pairs in which every key contains an integer identifying a configuration setting, and for some of those integers the key also contains extra parts (so that, for instance, CONF_environmt is a string-to-string mapping). Everywhere that a Config was previously used, a Conf is now; everywhere there was a Config structure copy, conf_copy() is called; every lookup, adjustment, load and save operation on a Config has been rewritten; and there's a mechanism for serialising a Conf into a binary blob and back for use with Duplicate Session. User-visible effects of this change _should_ be minimal, though I don't doubt I've introduced one or two bugs here and there which will eventually be found. The _intended_ visible effects of this change are that all arbitrary limits on configuration strings and lists (e.g. limit on number of port forwardings) should now disappear; that list boxes in the configuration will now be displayed in a sorted order rather than the arbitrary order in which they were added to the list (since the underlying data structure is now a sorted tree234 rather than an ad-hoc comma-separated string); and one more specific change, which is that local and dynamic port forwardings on the same port number are now mutually exclusive in the configuration (putting 'D' in the key rather than the value was a mistake in the first place). One other reorganisation as a result of this is that I've moved all the dialog.c standard handlers (dlg_stdeditbox_handler and friends) out into config.c, because I can't really justify calling them generic any more. When they took a pointer to an arbitrary structure type and the offset of a field within that structure, they were independent of whether that structure was a Config or something completely different, but now they really do expect to talk to a Conf, which can _only_ be used for PuTTY configuration, so I've renamed them all things like conf_editbox_handler and moved them out of the nominally independent dialog-box management module into the PuTTY-specific config.c. [originally from svn r9214]
This commit is contained in:
47
unix/uxpty.c
47
unix/uxpty.c
@ -76,7 +76,7 @@ typedef struct pty_tag *Pty;
|
||||
static int pty_signal_pipe[2] = { -1, -1 }; /* obviously bogus initial val */
|
||||
|
||||
struct pty_tag {
|
||||
Config cfg;
|
||||
Conf *conf;
|
||||
int master_fd, slave_fd;
|
||||
void *frontend;
|
||||
char name[FILENAME_MAX];
|
||||
@ -588,6 +588,8 @@ int pty_real_select_result(Pty pty, int event, int status)
|
||||
}
|
||||
|
||||
if (finished && !pty->finished) {
|
||||
int close_on_exit;
|
||||
|
||||
uxsel_del(pty->master_fd);
|
||||
pty_close(pty);
|
||||
pty->master_fd = -1;
|
||||
@ -600,8 +602,9 @@ int pty_real_select_result(Pty pty, int event, int status)
|
||||
* Only On Clean and it wasn't a clean exit) do we output a
|
||||
* `terminated' message.
|
||||
*/
|
||||
if (pty->cfg.close_on_exit == FORCE_OFF ||
|
||||
(pty->cfg.close_on_exit == AUTO && pty->exit_code != 0)) {
|
||||
close_on_exit = conf_get_int(pty->conf, CONF_close_on_exit);
|
||||
if (close_on_exit == FORCE_OFF ||
|
||||
(close_on_exit == AUTO && pty->exit_code != 0)) {
|
||||
char message[512];
|
||||
if (WIFEXITED(pty->exit_code))
|
||||
sprintf(message, "\r\n[pterm: process terminated with exit"
|
||||
@ -681,7 +684,7 @@ static void pty_uxsel_setup(Pty pty)
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
|
||||
static const char *pty_init(void *frontend, void **backend_handle, Conf *conf,
|
||||
char *host, int port, char **realhost, int nodelay,
|
||||
int keepalive)
|
||||
{
|
||||
@ -705,9 +708,9 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
|
||||
pty->frontend = frontend;
|
||||
*backend_handle = NULL; /* we can't sensibly use this, sadly */
|
||||
|
||||
pty->cfg = *cfg; /* structure copy */
|
||||
pty->term_width = cfg->width;
|
||||
pty->term_height = cfg->height;
|
||||
pty->conf = conf_copy(conf);
|
||||
pty->term_width = conf_get_int(conf, CONF_width);
|
||||
pty->term_height = conf_get_int(conf, CONF_height);
|
||||
|
||||
if (pty->master_fd < 0)
|
||||
pty_open_master(pty);
|
||||
@ -719,7 +722,8 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
|
||||
{
|
||||
struct termios attrs;
|
||||
tcgetattr(pty->master_fd, &attrs);
|
||||
attrs.c_cc[VERASE] = cfg->bksp_is_delete ? '\177' : '\010';
|
||||
attrs.c_cc[VERASE] = conf_get_int(conf, CONF_bksp_is_delete)
|
||||
? '\177' : '\010';
|
||||
tcsetattr(pty->master_fd, TCSANOW, &attrs);
|
||||
}
|
||||
|
||||
@ -728,7 +732,7 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
|
||||
* Stamp utmp (that is, tell the utmp helper process to do so),
|
||||
* or not.
|
||||
*/
|
||||
if (!cfg->stamp_utmp) {
|
||||
if (!conf_get_int(conf, CONF_stamp_utmp)) {
|
||||
close(pty_utmp_helper_pipe); /* just let the child process die */
|
||||
pty_utmp_helper_pipe = -1;
|
||||
} else {
|
||||
@ -787,7 +791,8 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
|
||||
close(open(pty->name, O_WRONLY, 0));
|
||||
setpgid(pgrp, pgrp);
|
||||
{
|
||||
char *term_env_var = dupprintf("TERM=%s", cfg->termtype);
|
||||
char *term_env_var = dupprintf("TERM=%s",
|
||||
conf_get_str(conf, CONF_termtype));
|
||||
putenv(term_env_var);
|
||||
/* We mustn't free term_env_var, as putenv links it into the
|
||||
* environment in place.
|
||||
@ -803,18 +808,12 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
|
||||
}
|
||||
#endif
|
||||
{
|
||||
char *e = cfg->environmt;
|
||||
char *var, *varend, *val, *varval;
|
||||
while (*e) {
|
||||
var = e;
|
||||
while (*e && *e != '\t') e++;
|
||||
varend = e;
|
||||
if (*e == '\t') e++;
|
||||
val = e;
|
||||
while (*e) e++;
|
||||
e++;
|
||||
char *key, *val;
|
||||
|
||||
varval = dupprintf("%.*s=%s", varend-var, var, val);
|
||||
for (val = conf_get_str_strs(conf, CONF_environmt, NULL, &key);
|
||||
val != NULL;
|
||||
val = conf_get_str_strs(conf, CONF_environmt, key, &key)) {
|
||||
char *varval = dupcat(key, "=", val, NULL);
|
||||
putenv(varval);
|
||||
/*
|
||||
* We must not free varval, since putenv links it
|
||||
@ -841,7 +840,7 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
|
||||
else {
|
||||
char *shell = getenv("SHELL");
|
||||
char *shellname;
|
||||
if (cfg->login_shell) {
|
||||
if (conf_get_int(conf, CONF_login_shell)) {
|
||||
char *p = strrchr(shell, '/');
|
||||
shellname = snewn(2+strlen(shell), char);
|
||||
p = p ? p+1 : shell;
|
||||
@ -884,7 +883,7 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void pty_reconfig(void *handle, Config *cfg)
|
||||
static void pty_reconfig(void *handle, Conf *conf)
|
||||
{
|
||||
Pty pty = (Pty)handle;
|
||||
/*
|
||||
@ -892,7 +891,7 @@ static void pty_reconfig(void *handle, Config *cfg)
|
||||
* unfortunately we do need to pick up the setting of Close On
|
||||
* Exit so we know whether to give a `terminated' message.
|
||||
*/
|
||||
pty->cfg = *cfg; /* structure copy */
|
||||
conf_copy_into(pty->conf, conf);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user