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

Stop having a global Conf.

It's now a static in the main source file of each application that
uses it, and isn't accessible from any other source file unless the
main one passes it by reference.

In fact, there were almost no instances of the latter: only the
config-box functions in windlg.c were using 'conf' by virtue of its
globalness, and it's easy to make those take it as a parameter.
This commit is contained in:
Simon Tatham 2020-02-02 10:00:42 +00:00
parent 866f8e2d96
commit ad0c7c99f8
7 changed files with 15 additions and 14 deletions

2
pscp.c
View File

@ -43,7 +43,7 @@ static bool using_sftp = false;
static bool uploading = false;
static Backend *backend;
Conf *conf;
static Conf *conf;
bool sent_eof = false;
static void source(const char *src);

View File

@ -35,7 +35,7 @@ static void do_sftp_cleanup(void);
char *pwd, *homedir;
static LogContext *psftp_logctx = NULL;
static Backend *backend;
Conf *conf;
static Conf *conf;
bool sent_eof = false;
/* ------------------------------------------------------------

View File

@ -39,7 +39,7 @@ void cmdline_error(const char *fmt, ...)
static bool local_tty = false; /* do we have a local tty? */
static Backend *backend;
Conf *conf;
static Conf *conf;
/*
* Default settings that are specific to Unix plink.

View File

@ -694,7 +694,7 @@ void defuse_showwindow(void)
}
}
bool do_config(void)
bool do_config(Conf *conf)
{
bool ret;
@ -724,7 +724,7 @@ bool do_config(void)
return ret;
}
bool do_reconfig(HWND hwnd, int protcfginfo)
bool do_reconfig(HWND hwnd, Conf *conf, int protcfginfo)
{
Conf *backup_conf;
bool ret;

View File

@ -145,6 +145,8 @@ static struct {
enum { SYSMENU, CTXMENU };
static HMENU savedsess_menu;
static Conf *conf;
struct wm_netevent_params {
/* Used to pass data to wm_netevent_callback */
WPARAM wParam;
@ -577,7 +579,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
i--;
p[i] = '\0';
do_defaults(p + 1, conf);
if (!conf_launchable(conf) && !do_config()) {
if (!conf_launchable(conf) && !do_config(conf)) {
cleanup_exit(0);
}
special_launchable_argument = true;
@ -600,7 +602,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
modalfatalbox("Serialised configuration data was invalid");
UnmapViewOfFile(cp);
CloseHandle(filemap);
} else if (!do_config()) {
} else if (!do_config(conf)) {
cleanup_exit(0);
}
special_launchable_argument = true;
@ -672,7 +674,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
* (explicitly) specified a launchable configuration.
*/
if (!(special_launchable_argument || cmdline_host_ok(conf))) {
if (!do_config())
if (!do_config(conf))
cleanup_exit(0);
}
@ -2326,8 +2328,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
prev_conf = conf_copy(conf);
reconfig_result =
do_reconfig(hwnd, backend ? backend_cfg_info(backend) : 0);
reconfig_result = do_reconfig(
hwnd, conf, backend ? backend_cfg_info(backend) : 0);
reconfiguring = false;
if (!reconfig_result) {
conf_free(prev_conf);

View File

@ -30,7 +30,7 @@ BinarySink *stdout_bs, *stderr_bs;
DWORD orig_console_mode;
static Backend *backend;
Conf *conf;
static Conf *conf;
static void plink_echoedit_update(Seat *seat, bool echo, bool edit)
{

View File

@ -235,7 +235,6 @@ int has_embedded_chm(void); /* 1 = yes, 0 = no, -1 = N/A */
*/
GLOBAL Terminal *term;
GLOBAL LogContext *logctx;
GLOBAL Conf *conf;
/*
* GUI seat methods in windlg.c, so that the vtable definition in
@ -569,8 +568,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, bool has_help,
* Exports from windlg.c.
*/
void defuse_showwindow(void);
bool do_config(void);
bool do_reconfig(HWND, int);
bool do_config(Conf *);
bool do_reconfig(HWND, Conf *, int);
void showeventlog(HWND);
void showabout(HWND);
void force_normal(HWND hwnd);