mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -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:
@ -70,8 +70,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
"Control the scrollback in the window");
|
||||
ctrl_checkbox(s, "Display scrollbar in full screen mode", 'i',
|
||||
HELPCTX(window_scrollback),
|
||||
dlg_stdcheckbox_handler,
|
||||
I(offsetof(Config,scrollbar_in_fullscreen)));
|
||||
conf_checkbox_handler,
|
||||
I(CONF_scrollbar_in_fullscreen));
|
||||
/*
|
||||
* Really this wants to go just after `Display scrollbar'. See
|
||||
* if we can find that control, and do some shuffling.
|
||||
@ -81,7 +81,7 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
for (i = 0; i < s->ncontrols; i++) {
|
||||
c = s->ctrls[i];
|
||||
if (c->generic.type == CTRL_CHECKBOX &&
|
||||
c->generic.context.i == offsetof(Config,scrollbar)) {
|
||||
c->generic.context.i == CONF_scrollbar) {
|
||||
/*
|
||||
* Control i is the scrollbar checkbox.
|
||||
* Control s->ncontrols-1 is the scrollbar-in-FS one.
|
||||
@ -105,10 +105,10 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
"Enable extra keyboard features:");
|
||||
ctrl_checkbox(s, "AltGr acts as Compose key", 't',
|
||||
HELPCTX(keyboard_compose),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,compose_key)));
|
||||
conf_checkbox_handler, I(CONF_compose_key));
|
||||
ctrl_checkbox(s, "Control-Alt is different from AltGr", 'd',
|
||||
HELPCTX(keyboard_ctrlalt),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,ctrlaltkeys)));
|
||||
conf_checkbox_handler, I(CONF_ctrlaltkeys));
|
||||
|
||||
/*
|
||||
* Windows allows an arbitrary .WAV to be played as a bell, and
|
||||
@ -133,8 +133,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
for (i = 0; i < s->ncontrols; i++) {
|
||||
c = s->ctrls[i];
|
||||
if (c->generic.type == CTRL_RADIO &&
|
||||
c->generic.context.i == offsetof(Config, beep)) {
|
||||
assert(c->generic.handler == dlg_stdradiobutton_handler);
|
||||
c->generic.context.i == CONF_beep) {
|
||||
assert(c->generic.handler == conf_radiobutton_handler);
|
||||
c->radio.nbuttons += 2;
|
||||
c->radio.buttons =
|
||||
sresize(c->radio.buttons, c->radio.nbuttons, char *);
|
||||
@ -159,7 +159,7 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
ctrl_filesel(s, "Custom sound file to play as a bell:", NO_SHORTCUT,
|
||||
FILTER_WAVE_FILES, FALSE, "Select bell sound file",
|
||||
HELPCTX(bell_style),
|
||||
dlg_stdfilesel_handler, I(offsetof(Config, bell_wavefile)));
|
||||
conf_filesel_handler, I(CONF_bell_wavefile));
|
||||
|
||||
/*
|
||||
* While we've got this box open, taskbar flashing on a bell is
|
||||
@ -167,8 +167,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
*/
|
||||
ctrl_radiobuttons(s, "Taskbar/caption indication on bell:", 'i', 3,
|
||||
HELPCTX(bell_taskbar),
|
||||
dlg_stdradiobutton_handler,
|
||||
I(offsetof(Config, beep_ind)),
|
||||
conf_radiobutton_handler,
|
||||
I(CONF_beep_ind),
|
||||
"Disabled", I(B_IND_DISABLED),
|
||||
"Flashing", I(B_IND_FLASH),
|
||||
"Steady", I(B_IND_STEADY), NULL);
|
||||
@ -180,7 +180,7 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
"Adjust the window border");
|
||||
ctrl_checkbox(s, "Sunken-edge border (slightly thicker)", 's',
|
||||
HELPCTX(appearance_border),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,sunken_edge)));
|
||||
conf_checkbox_handler, I(CONF_sunken_edge));
|
||||
|
||||
/*
|
||||
* Configurable font quality settings for Windows.
|
||||
@ -191,8 +191,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
HELPCTX(appearance_font), variable_pitch_handler, I(0));
|
||||
ctrl_radiobuttons(s, "Font quality:", 'q', 2,
|
||||
HELPCTX(appearance_font),
|
||||
dlg_stdradiobutton_handler,
|
||||
I(offsetof(Config, font_quality)),
|
||||
conf_radiobutton_handler,
|
||||
I(CONF_font_quality),
|
||||
"Antialiased", I(FQ_ANTIALIASED),
|
||||
"Non-Antialiased", I(FQ_NONANTIALIASED),
|
||||
"ClearType", I(FQ_CLEARTYPE),
|
||||
@ -206,8 +206,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
s = ctrl_getset(b, "Window/Translation", "tweaks", NULL);
|
||||
ctrl_checkbox(s, "Caps Lock acts as Cyrillic switch", 's',
|
||||
HELPCTX(translation_cyrillic),
|
||||
dlg_stdcheckbox_handler,
|
||||
I(offsetof(Config,xlat_capslockcyr)));
|
||||
conf_checkbox_handler,
|
||||
I(CONF_xlat_capslockcyr));
|
||||
|
||||
/*
|
||||
* On Windows we can use but not enumerate translation tables
|
||||
@ -232,8 +232,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
for (i = 0; i < s->ncontrols; i++) {
|
||||
c = s->ctrls[i];
|
||||
if (c->generic.type == CTRL_RADIO &&
|
||||
c->generic.context.i == offsetof(Config, vtmode)) {
|
||||
assert(c->generic.handler == dlg_stdradiobutton_handler);
|
||||
c->generic.context.i == CONF_vtmode) {
|
||||
assert(c->generic.handler == conf_radiobutton_handler);
|
||||
c->radio.nbuttons += 3;
|
||||
c->radio.buttons =
|
||||
sresize(c->radio.buttons, c->radio.nbuttons, char *);
|
||||
@ -272,7 +272,7 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
"Formatting of pasted characters");
|
||||
ctrl_checkbox(s, "Paste to clipboard in RTF as well as plain text", 'f',
|
||||
HELPCTX(selection_rtf),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,rtf_paste)));
|
||||
conf_checkbox_handler, I(CONF_rtf_paste));
|
||||
|
||||
/*
|
||||
* Windows often has no middle button, so we supply a selection
|
||||
@ -283,8 +283,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
"Control use of mouse");
|
||||
ctrl_radiobuttons(s, "Action of mouse buttons:", 'm', 1,
|
||||
HELPCTX(selection_buttons),
|
||||
dlg_stdradiobutton_handler,
|
||||
I(offsetof(Config, mouse_is_xterm)),
|
||||
conf_radiobutton_handler,
|
||||
I(CONF_mouse_is_xterm),
|
||||
"Windows (Middle extends, Right brings up menu)", I(2),
|
||||
"Compromise (Middle extends, Right pastes)", I(0),
|
||||
"xterm (Right extends, Middle pastes)", I(1), NULL);
|
||||
@ -304,10 +304,10 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
"General options for colour usage");
|
||||
ctrl_checkbox(s, "Attempt to use logical palettes", 'l',
|
||||
HELPCTX(colours_logpal),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,try_palette)));
|
||||
conf_checkbox_handler, I(CONF_try_palette));
|
||||
ctrl_checkbox(s, "Use system colours", 's',
|
||||
HELPCTX(colours_system),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,system_colour)));
|
||||
conf_checkbox_handler, I(CONF_system_colour));
|
||||
|
||||
|
||||
/*
|
||||
@ -316,8 +316,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
s = ctrl_getset(b, "Window", "size", "Set the size of the window");
|
||||
ctrl_radiobuttons(s, "When window is resized:", 'z', 1,
|
||||
HELPCTX(window_resize),
|
||||
dlg_stdradiobutton_handler,
|
||||
I(offsetof(Config, resize_action)),
|
||||
conf_radiobutton_handler,
|
||||
I(CONF_resize_action),
|
||||
"Change the number of rows and columns", I(RESIZE_TERM),
|
||||
"Change the size of the font", I(RESIZE_FONT),
|
||||
"Change font size only when maximised", I(RESIZE_EITHER),
|
||||
@ -331,20 +331,20 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
s = ctrl_getset(b, "Window/Behaviour", "main", NULL);
|
||||
ctrl_checkbox(s, "Window closes on ALT-F4", '4',
|
||||
HELPCTX(behaviour_altf4),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,alt_f4)));
|
||||
conf_checkbox_handler, I(CONF_alt_f4));
|
||||
ctrl_checkbox(s, "System menu appears on ALT-Space", 'y',
|
||||
HELPCTX(behaviour_altspace),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,alt_space)));
|
||||
conf_checkbox_handler, I(CONF_alt_space));
|
||||
ctrl_checkbox(s, "System menu appears on ALT alone", 'l',
|
||||
HELPCTX(behaviour_altonly),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,alt_only)));
|
||||
conf_checkbox_handler, I(CONF_alt_only));
|
||||
ctrl_checkbox(s, "Ensure window is always on top", 'e',
|
||||
HELPCTX(behaviour_alwaysontop),
|
||||
dlg_stdcheckbox_handler, I(offsetof(Config,alwaysontop)));
|
||||
conf_checkbox_handler, I(CONF_alwaysontop));
|
||||
ctrl_checkbox(s, "Full screen on Alt-Enter", 'f',
|
||||
HELPCTX(behaviour_altenter),
|
||||
dlg_stdcheckbox_handler,
|
||||
I(offsetof(Config,fullscreenonaltenter)));
|
||||
conf_checkbox_handler,
|
||||
I(CONF_fullscreenonaltenter));
|
||||
|
||||
/*
|
||||
* Windows supports a local-command proxy. This also means we
|
||||
@ -356,8 +356,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
for (i = 0; i < s->ncontrols; i++) {
|
||||
c = s->ctrls[i];
|
||||
if (c->generic.type == CTRL_RADIO &&
|
||||
c->generic.context.i == offsetof(Config, proxy_type)) {
|
||||
assert(c->generic.handler == dlg_stdradiobutton_handler);
|
||||
c->generic.context.i == CONF_proxy_type) {
|
||||
assert(c->generic.handler == conf_radiobutton_handler);
|
||||
c->radio.nbuttons++;
|
||||
c->radio.buttons =
|
||||
sresize(c->radio.buttons, c->radio.nbuttons, char *);
|
||||
@ -373,9 +373,8 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
for (i = 0; i < s->ncontrols; i++) {
|
||||
c = s->ctrls[i];
|
||||
if (c->generic.type == CTRL_EDITBOX &&
|
||||
c->generic.context.i ==
|
||||
offsetof(Config, proxy_telnet_command)) {
|
||||
assert(c->generic.handler == dlg_stdeditbox_handler);
|
||||
c->generic.context.i == CONF_proxy_telnet_command) {
|
||||
assert(c->generic.handler == conf_editbox_handler);
|
||||
sfree(c->generic.label);
|
||||
c->generic.label = dupstr("Telnet command, or local"
|
||||
" proxy command");
|
||||
@ -399,6 +398,6 @@ void win_setup_config_box(struct controlbox *b, HWND *hwndp, int has_help,
|
||||
ctrl_filesel(s, "X authority file for local display", 't',
|
||||
NULL, FALSE, "Select X authority file",
|
||||
HELPCTX(ssh_tunnels_xauthority),
|
||||
dlg_stdfilesel_handler, I(offsetof(Config, xauthfile)));
|
||||
conf_filesel_handler, I(CONF_xauthfile));
|
||||
}
|
||||
}
|
||||
|
@ -2100,13 +2100,23 @@ void dlg_editbox_set(union control *ctrl, void *dlg, char const *text)
|
||||
SetDlgItemText(dp->hwnd, c->base_id+1, text);
|
||||
}
|
||||
|
||||
void dlg_editbox_get(union control *ctrl, void *dlg, char *buffer, int length)
|
||||
char *dlg_editbox_get(union control *ctrl, void *dlg)
|
||||
{
|
||||
struct dlgparam *dp = (struct dlgparam *)dlg;
|
||||
struct winctrl *c = dlg_findbyctrl(dp, ctrl);
|
||||
char *ret;
|
||||
int size;
|
||||
assert(c && c->ctrl->generic.type == CTRL_EDITBOX);
|
||||
GetDlgItemText(dp->hwnd, c->base_id+1, buffer, length);
|
||||
buffer[length-1] = '\0';
|
||||
|
||||
size = 0;
|
||||
ret = NULL;
|
||||
do {
|
||||
size = size * 4 / 3 + 512;
|
||||
ret = sresize(ret, size, char);
|
||||
GetDlgItemText(dp->hwnd, c->base_id+1, ret, size);
|
||||
} while (!memchr(ret, '\0', size-1));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* The `listbox' functions can also apply to combo boxes. */
|
||||
@ -2471,8 +2481,10 @@ int dlg_coloursel_results(union control *ctrl, void *dlg,
|
||||
void dlg_auto_set_fixed_pitch_flag(void *dlg)
|
||||
{
|
||||
struct dlgparam *dp = (struct dlgparam *)dlg;
|
||||
Config *cfg = (Config *)dp->data;
|
||||
HFONT font;
|
||||
Conf *conf = (Conf *)dp->data;
|
||||
FontSpec *font;
|
||||
int quality;
|
||||
HFONT hfont;
|
||||
HDC hdc;
|
||||
TEXTMETRIC tm;
|
||||
int is_var;
|
||||
@ -2483,16 +2495,19 @@ void dlg_auto_set_fixed_pitch_flag(void *dlg)
|
||||
* dialog box as false.
|
||||
*
|
||||
* We assume here that any client of the dlg_* mechanism which is
|
||||
* using font selectors at all is also using a normal 'Config *'
|
||||
* using font selectors at all is also using a normal 'Conf *'
|
||||
* as dp->data.
|
||||
*/
|
||||
|
||||
font = CreateFont(0, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
|
||||
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS, FONT_QUALITY(cfg->font_quality),
|
||||
FIXED_PITCH | FF_DONTCARE, cfg->font.name);
|
||||
quality = conf_get_int(conf, CONF_font_quality);
|
||||
font = conf_get_fontspec(conf, CONF_font);
|
||||
|
||||
hfont = CreateFont(0, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
|
||||
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS, FONT_QUALITY(quality),
|
||||
FIXED_PITCH | FF_DONTCARE, font->name);
|
||||
hdc = GetDC(NULL);
|
||||
if (font && hdc && SelectObject(hdc, font) && GetTextMetrics(hdc, &tm)) {
|
||||
if (font && hdc && SelectObject(hdc, hfont) && GetTextMetrics(hdc, &tm)) {
|
||||
/* Note that the TMPF_FIXED_PITCH bit is defined upside down :-( */
|
||||
is_var = (tm.tmPitchAndFamily & TMPF_FIXED_PITCH);
|
||||
} else {
|
||||
@ -2500,8 +2515,8 @@ void dlg_auto_set_fixed_pitch_flag(void *dlg)
|
||||
}
|
||||
if (hdc)
|
||||
ReleaseDC(NULL, hdc);
|
||||
if (font)
|
||||
DeleteObject(font);
|
||||
if (hfont)
|
||||
DeleteObject(hfont);
|
||||
|
||||
if (is_var)
|
||||
dp->fixed_pitch_fonts = FALSE;
|
||||
|
@ -44,7 +44,7 @@ static struct dlgparam dp;
|
||||
static char **events = NULL;
|
||||
static int nevents = 0, negsize = 0;
|
||||
|
||||
extern Config cfg; /* defined in window.c */
|
||||
extern Conf *conf; /* defined in window.c */
|
||||
|
||||
#define PRINTER_DISABLED_STRING "None (printing disabled)"
|
||||
|
||||
@ -648,7 +648,7 @@ int do_config(void)
|
||||
dp_add_tree(&dp, &ctrls_panel);
|
||||
dp.wintitle = dupprintf("%s Configuration", appname);
|
||||
dp.errtitle = dupprintf("%s Error", appname);
|
||||
dp.data = &cfg;
|
||||
dp.data = conf;
|
||||
dlg_auto_set_fixed_pitch_flag(&dp);
|
||||
dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */
|
||||
|
||||
@ -666,15 +666,15 @@ int do_config(void)
|
||||
|
||||
int do_reconfig(HWND hwnd, int protcfginfo)
|
||||
{
|
||||
Config backup_cfg;
|
||||
int ret;
|
||||
Conf *backup_conf;
|
||||
int ret, protocol;
|
||||
|
||||
backup_cfg = cfg; /* structure copy */
|
||||
backup_conf = conf_copy(conf);
|
||||
|
||||
ctrlbox = ctrl_new_box();
|
||||
setup_config_box(ctrlbox, TRUE, cfg.protocol, protcfginfo);
|
||||
win_setup_config_box(ctrlbox, &dp.hwnd, has_help(), TRUE,
|
||||
cfg.protocol);
|
||||
protocol = conf_get_int(conf, CONF_protocol);
|
||||
setup_config_box(ctrlbox, TRUE, protocol, protcfginfo);
|
||||
win_setup_config_box(ctrlbox, &dp.hwnd, has_help(), TRUE, protocol);
|
||||
dp_init(&dp);
|
||||
winctrl_init(&ctrls_base);
|
||||
winctrl_init(&ctrls_panel);
|
||||
@ -682,7 +682,7 @@ int do_reconfig(HWND hwnd, int protcfginfo)
|
||||
dp_add_tree(&dp, &ctrls_panel);
|
||||
dp.wintitle = dupprintf("%s Reconfiguration", appname);
|
||||
dp.errtitle = dupprintf("%s Error", appname);
|
||||
dp.data = &cfg;
|
||||
dp.data = conf;
|
||||
dlg_auto_set_fixed_pitch_flag(&dp);
|
||||
dp.shortcuts['g'] = TRUE; /* the treeview: `Cate&gory' */
|
||||
|
||||
@ -695,7 +695,9 @@ int do_reconfig(HWND hwnd, int protcfginfo)
|
||||
dp_cleanup(&dp);
|
||||
|
||||
if (!ret)
|
||||
cfg = backup_cfg; /* structure copy */
|
||||
conf_copy_into(conf, backup_conf);
|
||||
|
||||
conf_free(backup_conf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
642
windows/window.c
642
windows/window.c
File diff suppressed because it is too large
Load Diff
@ -65,11 +65,12 @@ const char *gsslogmsg = NULL;
|
||||
|
||||
static void ssh_sspi_bind_fns(struct ssh_gss_library *lib);
|
||||
|
||||
struct ssh_gss_liblist *ssh_gss_setup(const Config *cfg)
|
||||
struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
|
||||
{
|
||||
HMODULE module;
|
||||
HKEY regkey;
|
||||
struct ssh_gss_liblist *list = snew(struct ssh_gss_liblist);
|
||||
char *path;
|
||||
|
||||
list->libraries = snewn(3, struct ssh_gss_library);
|
||||
list->nlibraries = 0;
|
||||
@ -148,8 +149,9 @@ struct ssh_gss_liblist *ssh_gss_setup(const Config *cfg)
|
||||
* Custom GSSAPI DLL.
|
||||
*/
|
||||
module = NULL;
|
||||
if (cfg->ssh_gss_custom.path[0]) {
|
||||
module = LoadLibrary(cfg->ssh_gss_custom.path);
|
||||
path = conf_get_filename(conf, CONF_ssh_gss_custom)->path;
|
||||
if (*path) {
|
||||
module = LoadLibrary(path);
|
||||
}
|
||||
if (module) {
|
||||
struct ssh_gss_library *lib =
|
||||
@ -157,7 +159,7 @@ struct ssh_gss_liblist *ssh_gss_setup(const Config *cfg)
|
||||
|
||||
lib->id = 2;
|
||||
lib->gsslogmsg = dupprintf("Using GSSAPI from user-specified"
|
||||
" library '%s'", cfg->ssh_gss_custom.path);
|
||||
" library '%s'", path);
|
||||
lib->handle = (void *)module;
|
||||
|
||||
#define BIND_GSS_FN(name) \
|
||||
|
@ -83,7 +83,7 @@ WSAEVENT netevent;
|
||||
|
||||
static Backend *back;
|
||||
static void *backhandle;
|
||||
static Config cfg;
|
||||
static Conf *conf;
|
||||
|
||||
int term_ldisc(Terminal *term, int mode)
|
||||
{
|
||||
@ -298,10 +298,11 @@ int main(int argc, char **argv)
|
||||
/*
|
||||
* Process the command line.
|
||||
*/
|
||||
do_defaults(NULL, &cfg);
|
||||
conf = conf_new();
|
||||
do_defaults(NULL, conf);
|
||||
loaded_session = FALSE;
|
||||
default_protocol = cfg.protocol;
|
||||
default_port = cfg.port;
|
||||
default_protocol = conf_get_int(conf, CONF_protocol);
|
||||
default_port = conf_get_int(conf, CONF_port);
|
||||
errors = 0;
|
||||
{
|
||||
/*
|
||||
@ -311,8 +312,10 @@ int main(int argc, char **argv)
|
||||
if (p) {
|
||||
const Backend *b = backend_from_name(p);
|
||||
if (b) {
|
||||
default_protocol = cfg.protocol = b->protocol;
|
||||
default_port = cfg.port = b->default_port;
|
||||
default_protocol = b->protocol;
|
||||
default_port = b->default_port;
|
||||
conf_set_int(conf, CONF_protocol, default_protocol);
|
||||
conf_set_int(conf, CONF_port, default_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,7 +323,7 @@ int main(int argc, char **argv)
|
||||
char *p = *++argv;
|
||||
if (*p == '-') {
|
||||
int ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL),
|
||||
1, &cfg);
|
||||
1, conf);
|
||||
if (ret == -2) {
|
||||
fprintf(stderr,
|
||||
"plink: option \"%s\" requires an argument\n", p);
|
||||
@ -332,7 +335,7 @@ int main(int argc, char **argv)
|
||||
} else if (!strcmp(p, "-batch")) {
|
||||
console_batch_mode = 1;
|
||||
} else if (!strcmp(p, "-s")) {
|
||||
/* Save status to write to cfg later. */
|
||||
/* Save status to write to conf later. */
|
||||
use_subsystem = 1;
|
||||
} else if (!strcmp(p, "-V")) {
|
||||
version();
|
||||
@ -344,7 +347,7 @@ int main(int argc, char **argv)
|
||||
errors = 1;
|
||||
}
|
||||
} else if (*p) {
|
||||
if (!cfg_launchable(&cfg) || !(got_host || loaded_session)) {
|
||||
if (!conf_launchable(conf) || !(got_host || loaded_session)) {
|
||||
char *q = p;
|
||||
/*
|
||||
* If the hostname starts with "telnet:", set the
|
||||
@ -357,7 +360,7 @@ int main(int argc, char **argv)
|
||||
q += 7;
|
||||
if (q[0] == '/' && q[1] == '/')
|
||||
q += 2;
|
||||
cfg.protocol = PROT_TELNET;
|
||||
conf_set_int(conf, CONF_protocol, PROT_TELNET);
|
||||
p = q;
|
||||
while (*p && *p != ':' && *p != '/')
|
||||
p++;
|
||||
@ -365,11 +368,10 @@ int main(int argc, char **argv)
|
||||
if (*p)
|
||||
*p++ = '\0';
|
||||
if (c == ':')
|
||||
cfg.port = atoi(p);
|
||||
conf_set_int(conf, CONF_port, atoi(p));
|
||||
else
|
||||
cfg.port = -1;
|
||||
strncpy(cfg.host, q, sizeof(cfg.host) - 1);
|
||||
cfg.host[sizeof(cfg.host) - 1] = '\0';
|
||||
conf_set_int(conf, CONF_port, -1);
|
||||
conf_set_str(conf, CONF_host, q);
|
||||
got_host = TRUE;
|
||||
} else {
|
||||
char *r, *user, *host;
|
||||
@ -384,7 +386,9 @@ int main(int argc, char **argv)
|
||||
*r = '\0';
|
||||
b = backend_from_name(p);
|
||||
if (b) {
|
||||
default_protocol = cfg.protocol = b->protocol;
|
||||
default_protocol = b->protocol;
|
||||
conf_set_int(conf, CONF_protocol,
|
||||
default_protocol);
|
||||
portnumber = b->default_port;
|
||||
}
|
||||
p = r + 1;
|
||||
@ -411,26 +415,24 @@ int main(int argc, char **argv)
|
||||
* same name as the hostname.
|
||||
*/
|
||||
{
|
||||
Config cfg2;
|
||||
do_defaults(host, &cfg2);
|
||||
if (loaded_session || !cfg_launchable(&cfg2)) {
|
||||
Conf *conf2 = conf_new();
|
||||
do_defaults(host, conf2);
|
||||
if (loaded_session || !conf_launchable(conf2)) {
|
||||
/* No settings for this host; use defaults */
|
||||
/* (or session was already loaded with -load) */
|
||||
strncpy(cfg.host, host, sizeof(cfg.host) - 1);
|
||||
cfg.host[sizeof(cfg.host) - 1] = '\0';
|
||||
cfg.port = default_port;
|
||||
conf_set_str(conf, CONF_host, host);
|
||||
conf_set_int(conf, CONF_port, default_port);
|
||||
got_host = TRUE;
|
||||
} else {
|
||||
cfg = cfg2;
|
||||
conf_copy_into(conf, conf2);
|
||||
loaded_session = TRUE;
|
||||
}
|
||||
conf_free(conf2);
|
||||
}
|
||||
|
||||
if (user) {
|
||||
/* Patch in specified username. */
|
||||
strncpy(cfg.username, user,
|
||||
sizeof(cfg.username) - 1);
|
||||
cfg.username[sizeof(cfg.username) - 1] = '\0';
|
||||
conf_set_str(conf, CONF_username, user);
|
||||
}
|
||||
|
||||
}
|
||||
@ -457,9 +459,9 @@ int main(int argc, char **argv)
|
||||
}
|
||||
if (cmdlen) command[--cmdlen]='\0';
|
||||
/* change trailing blank to NUL */
|
||||
cfg.remote_cmd_ptr = command;
|
||||
cfg.remote_cmd_ptr2 = NULL;
|
||||
cfg.nopty = TRUE; /* command => no terminal */
|
||||
conf_set_str(conf, CONF_remote_cmd, command);
|
||||
conf_set_str(conf, CONF_remote_cmd2, "");
|
||||
conf_set_int(conf, CONF_nopty, TRUE); /* command => no tty */
|
||||
|
||||
break; /* done with cmdline */
|
||||
}
|
||||
@ -469,70 +471,78 @@ int main(int argc, char **argv)
|
||||
if (errors)
|
||||
return 1;
|
||||
|
||||
if (!cfg_launchable(&cfg) || !(got_host || loaded_session)) {
|
||||
if (!conf_launchable(conf) || !(got_host || loaded_session)) {
|
||||
usage();
|
||||
}
|
||||
|
||||
/*
|
||||
* Trim leading whitespace off the hostname if it's there.
|
||||
* Muck about with the hostname in various ways.
|
||||
*/
|
||||
{
|
||||
int space = strspn(cfg.host, " \t");
|
||||
memmove(cfg.host, cfg.host+space, 1+strlen(cfg.host)-space);
|
||||
}
|
||||
char *hostbuf = dupstr(conf_get_str(conf, CONF_host));
|
||||
char *host = hostbuf;
|
||||
char *p, *q;
|
||||
|
||||
/* See if host is of the form user@host */
|
||||
if (cfg_launchable(&cfg)) {
|
||||
char *atsign = strrchr(cfg.host, '@');
|
||||
/* Make sure we're not overflowing the user field */
|
||||
if (atsign) {
|
||||
if (atsign - cfg.host < sizeof cfg.username) {
|
||||
strncpy(cfg.username, cfg.host, atsign - cfg.host);
|
||||
cfg.username[atsign - cfg.host] = '\0';
|
||||
/*
|
||||
* Trim leading whitespace.
|
||||
*/
|
||||
host += strspn(host, " \t");
|
||||
|
||||
/*
|
||||
* See if host is of the form user@host, and separate out
|
||||
* the username if so.
|
||||
*/
|
||||
if (host[0] != '\0') {
|
||||
char *atsign = strrchr(host, '@');
|
||||
if (atsign) {
|
||||
*atsign = '\0';
|
||||
conf_set_str(conf, CONF_username, host);
|
||||
host = atsign + 1;
|
||||
}
|
||||
memmove(cfg.host, atsign + 1, 1 + strlen(atsign + 1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Trim off a colon suffix if it's there.
|
||||
*/
|
||||
host[strcspn(host, ":")] = '\0';
|
||||
|
||||
/*
|
||||
* Remove any remaining whitespace.
|
||||
*/
|
||||
p = hostbuf;
|
||||
q = host;
|
||||
while (*q) {
|
||||
if (*q != ' ' && *q != '\t')
|
||||
*p++ = *q;
|
||||
q++;
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
conf_set_str(conf, CONF_host, hostbuf);
|
||||
sfree(hostbuf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform command-line overrides on session configuration.
|
||||
*/
|
||||
cmdline_run_saved(&cfg);
|
||||
cmdline_run_saved(conf);
|
||||
|
||||
/*
|
||||
* Apply subsystem status.
|
||||
*/
|
||||
if (use_subsystem)
|
||||
cfg.ssh_subsys = TRUE;
|
||||
conf_set_int(conf, CONF_ssh_subsys, TRUE);
|
||||
|
||||
/*
|
||||
* Trim a colon suffix off the hostname if it's there.
|
||||
*/
|
||||
cfg.host[strcspn(cfg.host, ":")] = '\0';
|
||||
|
||||
/*
|
||||
* Remove any remaining whitespace from the hostname.
|
||||
*/
|
||||
{
|
||||
int p1 = 0, p2 = 0;
|
||||
while (cfg.host[p2] != '\0') {
|
||||
if (cfg.host[p2] != ' ' && cfg.host[p2] != '\t') {
|
||||
cfg.host[p1] = cfg.host[p2];
|
||||
p1++;
|
||||
}
|
||||
p2++;
|
||||
}
|
||||
cfg.host[p1] = '\0';
|
||||
}
|
||||
|
||||
if (!cfg.remote_cmd_ptr && !*cfg.remote_cmd && !*cfg.ssh_nc_host)
|
||||
if (!*conf_get_str(conf, CONF_remote_cmd) &&
|
||||
!*conf_get_str(conf, CONF_remote_cmd2) &&
|
||||
!*conf_get_str(conf, CONF_ssh_nc_host))
|
||||
flags |= FLAG_INTERACTIVE;
|
||||
|
||||
/*
|
||||
* Select protocol. This is farmed out into a table in a
|
||||
* separate file to enable an ssh-free variant.
|
||||
*/
|
||||
back = backend_from_proto(cfg.protocol);
|
||||
back = backend_from_proto(conf_get_int(conf, CONF_protocol));
|
||||
if (back == NULL) {
|
||||
fprintf(stderr,
|
||||
"Internal fault: Unsupported protocol found\n");
|
||||
@ -543,7 +553,7 @@ int main(int argc, char **argv)
|
||||
* Select port.
|
||||
*/
|
||||
if (portnumber != -1)
|
||||
cfg.port = portnumber;
|
||||
conf_set_int(conf, CONF_port, portnumber);
|
||||
|
||||
sk_init();
|
||||
if (p_WSAEventSelect == NULL) {
|
||||
@ -551,7 +561,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
logctx = log_init(NULL, &cfg);
|
||||
logctx = log_init(NULL, conf);
|
||||
console_provide_logctx(logctx);
|
||||
|
||||
/*
|
||||
@ -562,11 +572,14 @@ int main(int argc, char **argv)
|
||||
const char *error;
|
||||
char *realhost;
|
||||
/* nodelay is only useful if stdin is a character device (console) */
|
||||
int nodelay = cfg.tcp_nodelay &&
|
||||
int nodelay = conf_get_int(conf, CONF_tcp_nodelay) &&
|
||||
(GetFileType(GetStdHandle(STD_INPUT_HANDLE)) == FILE_TYPE_CHAR);
|
||||
|
||||
error = back->init(NULL, &backhandle, &cfg, cfg.host, cfg.port,
|
||||
&realhost, nodelay, cfg.tcp_keepalives);
|
||||
error = back->init(NULL, &backhandle, conf,
|
||||
conf_get_str(conf, CONF_host),
|
||||
conf_get_int(conf, CONF_port),
|
||||
&realhost, nodelay,
|
||||
conf_get_int(conf, CONF_tcp_keepalives));
|
||||
if (error) {
|
||||
fprintf(stderr, "Unable to open connection:\n%s", error);
|
||||
return 1;
|
||||
|
@ -123,7 +123,7 @@ static const char *sk_localproxy_socket_error(Socket s)
|
||||
Socket platform_new_connection(SockAddr addr, char *hostname,
|
||||
int port, int privport,
|
||||
int oobinline, int nodelay, int keepalive,
|
||||
Plug plug, const Config *cfg)
|
||||
Plug plug, Conf *conf)
|
||||
{
|
||||
char *cmd;
|
||||
|
||||
@ -145,10 +145,10 @@ Socket platform_new_connection(SockAddr addr, char *hostname,
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
if (cfg->proxy_type != PROXY_CMD)
|
||||
if (conf_get_int(conf, CONF_proxy_type) != PROXY_CMD)
|
||||
return NULL;
|
||||
|
||||
cmd = format_telnet_command(addr, port, cfg);
|
||||
cmd = format_telnet_command(addr, port, conf);
|
||||
|
||||
{
|
||||
char *msg = dupprintf("Starting local proxy command: %s", cmd);
|
||||
|
@ -87,7 +87,7 @@ static void serial_sentdata(struct handle *h, int new_backlog)
|
||||
}
|
||||
}
|
||||
|
||||
static const char *serial_configure(Serial serial, HANDLE serport, Config *cfg)
|
||||
static const char *serial_configure(Serial serial, HANDLE serport, Conf *conf)
|
||||
{
|
||||
DCB dcb;
|
||||
COMMTIMEOUTS timeouts;
|
||||
@ -121,17 +121,17 @@ static const char *serial_configure(Serial serial, HANDLE serport, Config *cfg)
|
||||
/*
|
||||
* Configurable parameters.
|
||||
*/
|
||||
dcb.BaudRate = cfg->serspeed;
|
||||
msg = dupprintf("Configuring baud rate %d", cfg->serspeed);
|
||||
dcb.BaudRate = conf_get_int(conf, CONF_serspeed);
|
||||
msg = dupprintf("Configuring baud rate %d", dcb.BaudRate);
|
||||
logevent(serial->frontend, msg);
|
||||
sfree(msg);
|
||||
|
||||
dcb.ByteSize = cfg->serdatabits;
|
||||
msg = dupprintf("Configuring %d data bits", cfg->serdatabits);
|
||||
dcb.ByteSize = conf_get_int(conf, CONF_serdatabits);
|
||||
msg = dupprintf("Configuring %d data bits", dcb.ByteSize);
|
||||
logevent(serial->frontend, msg);
|
||||
sfree(msg);
|
||||
|
||||
switch (cfg->serstopbits) {
|
||||
switch (conf_get_int(conf, CONF_serstopbits)) {
|
||||
case 2: dcb.StopBits = ONESTOPBIT; str = "1"; break;
|
||||
case 3: dcb.StopBits = ONE5STOPBITS; str = "1.5"; break;
|
||||
case 4: dcb.StopBits = TWOSTOPBITS; str = "2"; break;
|
||||
@ -141,7 +141,7 @@ static const char *serial_configure(Serial serial, HANDLE serport, Config *cfg)
|
||||
logevent(serial->frontend, msg);
|
||||
sfree(msg);
|
||||
|
||||
switch (cfg->serparity) {
|
||||
switch (conf_get_int(conf, CONF_serparity)) {
|
||||
case SER_PAR_NONE: dcb.Parity = NOPARITY; str = "no"; break;
|
||||
case SER_PAR_ODD: dcb.Parity = ODDPARITY; str = "odd"; break;
|
||||
case SER_PAR_EVEN: dcb.Parity = EVENPARITY; str = "even"; break;
|
||||
@ -152,7 +152,7 @@ static const char *serial_configure(Serial serial, HANDLE serport, Config *cfg)
|
||||
logevent(serial->frontend, msg);
|
||||
sfree(msg);
|
||||
|
||||
switch (cfg->serflow) {
|
||||
switch (conf_get_int(conf, CONF_serflow)) {
|
||||
case SER_FLOW_NONE:
|
||||
str = "no";
|
||||
break;
|
||||
@ -199,13 +199,13 @@ static const char *serial_configure(Serial serial, HANDLE serport, Config *cfg)
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *serial_init(void *frontend_handle, void **backend_handle,
|
||||
Config *cfg,
|
||||
char *host, int port, char **realhost, int nodelay,
|
||||
int keepalive)
|
||||
Conf *conf, char *host, int port,
|
||||
char **realhost, int nodelay, int keepalive)
|
||||
{
|
||||
Serial serial;
|
||||
HANDLE serport;
|
||||
const char *err;
|
||||
char *serline;
|
||||
|
||||
serial = snew(struct serial_backend_data);
|
||||
serial->port = INVALID_HANDLE_VALUE;
|
||||
@ -216,8 +216,9 @@ static const char *serial_init(void *frontend_handle, void **backend_handle,
|
||||
|
||||
serial->frontend = frontend_handle;
|
||||
|
||||
serline = conf_get_str(conf, CONF_serline);
|
||||
{
|
||||
char *msg = dupprintf("Opening serial device %s", cfg->serline);
|
||||
char *msg = dupprintf("Opening serial device %s", serline);
|
||||
logevent(serial->frontend, msg);
|
||||
}
|
||||
|
||||
@ -246,9 +247,7 @@ static const char *serial_init(void *frontend_handle, void **backend_handle,
|
||||
* existing configurations using \\.\ continue working.)
|
||||
*/
|
||||
char *serfilename =
|
||||
dupprintf("%s%s",
|
||||
strchr(cfg->serline, '\\') ? "" : "\\\\.\\",
|
||||
cfg->serline);
|
||||
dupprintf("%s%s", strchr(serline, '\\') ? "" : "\\\\.\\", serline);
|
||||
serport = CreateFile(serfilename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||
OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
||||
sfree(serfilename);
|
||||
@ -257,7 +256,7 @@ static const char *serial_init(void *frontend_handle, void **backend_handle,
|
||||
if (serport == INVALID_HANDLE_VALUE)
|
||||
return "Unable to open serial port";
|
||||
|
||||
err = serial_configure(serial, serport, cfg);
|
||||
err = serial_configure(serial, serport, conf);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -269,7 +268,7 @@ static const char *serial_init(void *frontend_handle, void **backend_handle,
|
||||
HANDLE_FLAG_IGNOREEOF |
|
||||
HANDLE_FLAG_UNITBUFFER);
|
||||
|
||||
*realhost = dupstr(cfg->serline);
|
||||
*realhost = dupstr(serline);
|
||||
|
||||
/*
|
||||
* Specials are always available.
|
||||
@ -288,12 +287,12 @@ static void serial_free(void *handle)
|
||||
sfree(serial);
|
||||
}
|
||||
|
||||
static void serial_reconfig(void *handle, Config *cfg)
|
||||
static void serial_reconfig(void *handle, Conf *conf)
|
||||
{
|
||||
Serial serial = (Serial) handle;
|
||||
const char *err;
|
||||
|
||||
err = serial_configure(serial, serial->port, cfg);
|
||||
err = serial_configure(serial, serial->port, conf);
|
||||
|
||||
/*
|
||||
* FIXME: what should we do if err returns something?
|
||||
|
@ -20,7 +20,7 @@ int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void platform_get_x11_auth(struct X11Display *display, const Config *cfg)
|
||||
void platform_get_x11_auth(struct X11Display *display, Conf *conf)
|
||||
{
|
||||
/* Do nothing, therefore no auth. */
|
||||
}
|
||||
|
@ -150,17 +150,26 @@ void *open_settings_r(const char *sessionname)
|
||||
return (void *) sesskey;
|
||||
}
|
||||
|
||||
char *read_setting_s(void *handle, const char *key, char *buffer, int buflen)
|
||||
char *read_setting_s(void *handle, const char *key)
|
||||
{
|
||||
DWORD type, size;
|
||||
size = buflen;
|
||||
char *ret;
|
||||
|
||||
if (!handle ||
|
||||
RegQueryValueEx((HKEY) handle, key, 0,
|
||||
&type, buffer, &size) != ERROR_SUCCESS ||
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
/* Find out the type and size of the data. */
|
||||
if (RegQueryValueEx((HKEY) handle, key, 0,
|
||||
&type, NULL, &size) != ERROR_SUCCESS ||
|
||||
type != REG_SZ)
|
||||
return NULL;
|
||||
|
||||
ret = snewn(size+1, char);
|
||||
if (RegQueryValueEx((HKEY) handle, key, 0,
|
||||
&type, ret, &size) != ERROR_SUCCESS ||
|
||||
type != REG_SZ) return NULL;
|
||||
else
|
||||
return buffer;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int read_setting_i(void *handle, const char *key, int defvalue)
|
||||
@ -181,17 +190,25 @@ int read_setting_fontspec(void *handle, const char *name, FontSpec *result)
|
||||
{
|
||||
char *settingname;
|
||||
FontSpec ret;
|
||||
char *fontname;
|
||||
|
||||
if (!read_setting_s(handle, name, ret.name, sizeof(ret.name)))
|
||||
fontname = read_setting_s(handle, name);
|
||||
if (!fontname)
|
||||
return 0;
|
||||
strncpy(ret.name, fontname, sizeof(ret.name)-1);
|
||||
ret.name[sizeof(ret.name)-1] = '\0';
|
||||
sfree(fontname);
|
||||
|
||||
settingname = dupcat(name, "IsBold", NULL);
|
||||
ret.isbold = read_setting_i(handle, settingname, -1);
|
||||
sfree(settingname);
|
||||
if (ret.isbold == -1) return 0;
|
||||
|
||||
settingname = dupcat(name, "CharSet", NULL);
|
||||
ret.charset = read_setting_i(handle, settingname, -1);
|
||||
sfree(settingname);
|
||||
if (ret.charset == -1) return 0;
|
||||
|
||||
settingname = dupcat(name, "Height", NULL);
|
||||
ret.height = read_setting_i(handle, settingname, INT_MIN);
|
||||
sfree(settingname);
|
||||
@ -218,7 +235,14 @@ void write_setting_fontspec(void *handle, const char *name, FontSpec font)
|
||||
|
||||
int read_setting_filename(void *handle, const char *name, Filename *result)
|
||||
{
|
||||
return !!read_setting_s(handle, name, result->path, sizeof(result->path));
|
||||
char *tmp = read_setting_s(handle, name);
|
||||
if (tmp) {
|
||||
strncpy(result->path, tmp, sizeof(result->path)-1);
|
||||
result->path[sizeof(result->path)-1] = '\0';
|
||||
sfree(tmp);
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void write_setting_filename(void *handle, const char *name, Filename result)
|
||||
|
@ -115,7 +115,7 @@ struct FontSpec {
|
||||
|
||||
#ifndef DONE_TYPEDEFS
|
||||
#define DONE_TYPEDEFS
|
||||
typedef struct config_tag Config;
|
||||
typedef struct conf_tag Conf;
|
||||
typedef struct backend_tag Backend;
|
||||
typedef struct terminal_tag Terminal;
|
||||
#endif
|
||||
@ -473,7 +473,7 @@ void EnableSizeTip(int bEnable);
|
||||
* Exports from unicode.c.
|
||||
*/
|
||||
struct unicode_data;
|
||||
void init_ucs(Config *, struct unicode_data *);
|
||||
void init_ucs(Conf *, struct unicode_data *);
|
||||
|
||||
/*
|
||||
* Exports from winhandl.c.
|
||||
|
@ -436,24 +436,27 @@ static const struct cp_list_item cp_list[] = {
|
||||
|
||||
static void link_font(WCHAR * line_tbl, WCHAR * font_tbl, WCHAR attr);
|
||||
|
||||
void init_ucs(Config *cfg, struct unicode_data *ucsdata)
|
||||
void init_ucs(Conf *conf, struct unicode_data *ucsdata)
|
||||
{
|
||||
int i, j;
|
||||
int used_dtf = 0;
|
||||
char tbuf[256];
|
||||
int vtmode;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
tbuf[i] = i;
|
||||
|
||||
/* Decide on the Line and Font codepages */
|
||||
ucsdata->line_codepage = decode_codepage(cfg->line_codepage);
|
||||
ucsdata->line_codepage = decode_codepage(conf_get_str(conf,
|
||||
CONF_line_codepage));
|
||||
|
||||
if (ucsdata->font_codepage <= 0) {
|
||||
ucsdata->font_codepage=0;
|
||||
ucsdata->dbcs_screenfont=0;
|
||||
}
|
||||
|
||||
if (cfg->vtmode == VT_OEMONLY) {
|
||||
vtmode = conf_get_int(conf, CONF_vtmode);
|
||||
if (vtmode == VT_OEMONLY) {
|
||||
ucsdata->font_codepage = 437;
|
||||
ucsdata->dbcs_screenfont = 0;
|
||||
if (ucsdata->line_codepage <= 0)
|
||||
@ -473,7 +476,7 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata)
|
||||
if (ucsdata->font_codepage == 437)
|
||||
ucsdata->unitab_font[0] = ucsdata->unitab_font[255] = 0xFFFF;
|
||||
}
|
||||
if (cfg->vtmode == VT_XWINDOWS)
|
||||
if (vtmode == VT_XWINDOWS)
|
||||
memcpy(ucsdata->unitab_font + 1, unitab_xterm_std,
|
||||
sizeof(unitab_xterm_std));
|
||||
|
||||
@ -481,7 +484,7 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata)
|
||||
get_unitab(CP_OEMCP, ucsdata->unitab_oemcp, 1);
|
||||
|
||||
/* Collect CP437 ucs table for SCO acs */
|
||||
if (cfg->vtmode == VT_OEMANSI || cfg->vtmode == VT_XWINDOWS)
|
||||
if (vtmode == VT_OEMANSI || vtmode == VT_XWINDOWS)
|
||||
memcpy(ucsdata->unitab_scoacs, ucsdata->unitab_oemcp,
|
||||
sizeof(ucsdata->unitab_scoacs));
|
||||
else
|
||||
@ -490,7 +493,7 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata)
|
||||
/* Collect line set ucs table */
|
||||
if (ucsdata->line_codepage == ucsdata->font_codepage &&
|
||||
(ucsdata->dbcs_screenfont ||
|
||||
cfg->vtmode == VT_POORMAN || ucsdata->font_codepage==0)) {
|
||||
vtmode == VT_POORMAN || ucsdata->font_codepage==0)) {
|
||||
|
||||
/* For DBCS and POOR fonts force direct to font */
|
||||
used_dtf = 1;
|
||||
@ -560,14 +563,14 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata)
|
||||
ucsdata->unitab_ctrl[i] = 0xFF;
|
||||
|
||||
/* Generate line->screen direct conversion links. */
|
||||
if (cfg->vtmode == VT_OEMANSI || cfg->vtmode == VT_XWINDOWS)
|
||||
if (vtmode == VT_OEMANSI || vtmode == VT_XWINDOWS)
|
||||
link_font(ucsdata->unitab_scoacs, ucsdata->unitab_oemcp, CSET_OEMCP);
|
||||
|
||||
link_font(ucsdata->unitab_line, ucsdata->unitab_font, CSET_ACP);
|
||||
link_font(ucsdata->unitab_scoacs, ucsdata->unitab_font, CSET_ACP);
|
||||
link_font(ucsdata->unitab_xterm, ucsdata->unitab_font, CSET_ACP);
|
||||
|
||||
if (cfg->vtmode == VT_OEMANSI || cfg->vtmode == VT_XWINDOWS) {
|
||||
if (vtmode == VT_OEMANSI || vtmode == VT_XWINDOWS) {
|
||||
link_font(ucsdata->unitab_line, ucsdata->unitab_oemcp, CSET_OEMCP);
|
||||
link_font(ucsdata->unitab_xterm, ucsdata->unitab_oemcp, CSET_OEMCP);
|
||||
}
|
||||
@ -581,7 +584,7 @@ void init_ucs(Config *cfg, struct unicode_data *ucsdata)
|
||||
}
|
||||
|
||||
/* Last chance, if !unicode then try poorman links. */
|
||||
if (cfg->vtmode != VT_UNICODE) {
|
||||
if (vtmode != VT_UNICODE) {
|
||||
static const char poorman_scoacs[] =
|
||||
"CueaaaaceeeiiiAAE**ooouuyOUc$YPsaiounNao?++**!<>###||||++||++++++--|-+||++--|-+----++++++++##||#aBTPEsyt******EN=+><++-=... n2* ";
|
||||
static const char poorman_latin1[] =
|
||||
|
@ -9,10 +9,11 @@
|
||||
#include "putty.h"
|
||||
#include "ssh.h"
|
||||
|
||||
void platform_get_x11_auth(struct X11Display *disp, const Config *cfg)
|
||||
void platform_get_x11_auth(struct X11Display *disp, Conf *conf)
|
||||
{
|
||||
if (cfg->xauthfile.path[0])
|
||||
x11_get_auth_from_authfile(disp, cfg->xauthfile.path);
|
||||
char *xauthpath = conf_get_filename(conf, CONF_xauthfile)->path;
|
||||
if (xauthpath[0])
|
||||
x11_get_auth_from_authfile(disp, xauthpath);
|
||||
}
|
||||
|
||||
const int platform_uses_x11_unix_by_default = FALSE;
|
||||
|
Reference in New Issue
Block a user