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
Родитель 866f8e2d96
Коммит ad0c7c99f8
7 изменённых файлов: 15 добавлений и 14 удалений

2
pscp.c
Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -235,7 +235,6 @@ int has_embedded_chm(void); /* 1 = yes, 0 = no, -1 = N/A */
*/ */
GLOBAL Terminal *term; GLOBAL Terminal *term;
GLOBAL LogContext *logctx; GLOBAL LogContext *logctx;
GLOBAL Conf *conf;
/* /*
* GUI seat methods in windlg.c, so that the vtable definition in * 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. * Exports from windlg.c.
*/ */
void defuse_showwindow(void); void defuse_showwindow(void);
bool do_config(void); bool do_config(Conf *);
bool do_reconfig(HWND, int); bool do_reconfig(HWND, Conf *, int);
void showeventlog(HWND); void showeventlog(HWND);
void showabout(HWND); void showabout(HWND);
void force_normal(HWND hwnd); void force_normal(HWND hwnd);