diff --git a/ldisc.c b/ldisc.c index 7b3976ef..d569f112 100644 --- a/ldisc.c +++ b/ldisc.c @@ -12,12 +12,12 @@ #include "terminal.h" #include "ldisc.h" -#define ECHOING (ldisc->cfg->localecho == LD_YES || \ - (ldisc->cfg->localecho == LD_BACKEND && \ +#define ECHOING (ldisc->cfg->localecho == FORCE_ON || \ + (ldisc->cfg->localecho == AUTO && \ (ldisc->back->ldisc(ldisc->backhandle, LD_ECHO) || \ term_ldisc(ldisc->term, LD_ECHO)))) -#define EDITING (ldisc->cfg->localedit == LD_YES || \ - (ldisc->cfg->localedit == LD_BACKEND && \ +#define EDITING (ldisc->cfg->localedit == FORCE_ON || \ + (ldisc->cfg->localedit == AUTO && \ (ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \ term_ldisc(ldisc->term, LD_EDIT)))) diff --git a/proxy.c b/proxy.c index be238c34..0a61741e 100644 --- a/proxy.c +++ b/proxy.c @@ -15,8 +15,8 @@ #include "proxy.h" #define do_proxy_dns(cfg) \ - (cfg->proxy_dns == 2 || \ - (cfg->proxy_dns == 1 && cfg->proxy_type != PROXY_SOCKS)) + (cfg->proxy_dns == FORCE_ON || \ + (cfg->proxy_dns == AUTO && cfg->proxy_type != PROXY_SOCKS)) /* * Call this when proxy negotiation is complete, so that this diff --git a/putty.h b/putty.h index 3782f913..ad845afe 100644 --- a/putty.h +++ b/putty.h @@ -187,9 +187,9 @@ typedef enum { #define PK_ISKEYPAD(k) ((k) >= PK_PF1 && (k) <= PK_KPENTER) #define PK_ISFKEY(k) ((k) >= PK_F1 && (k) <= PK_F20) -typedef enum { +enum { VT_XWINDOWS, VT_OEMANSI, VT_OEMONLY, VT_POORMAN, VT_UNICODE -} VT_Mode; +}; enum { /* @@ -205,9 +205,22 @@ enum { enum { /* - * Line discipline option states: off, on, up to the backend. + * Several different bits of the PuTTY configuration seem to be + * three-way settings whose values are `always yes', `always + * no', and `decide by some more complex automated means'. This + * is true of line discipline options (local echo and line + * editing), proxy DNS, Close On Exit, and SSH server bug + * workarounds. Accordingly I supply a single enum here to deal + * with them all. */ - LD_YES, LD_NO, LD_BACKEND + FORCE_ON, FORCE_OFF, AUTO +}; + +enum { + /* + * Proxy types. + */ + PROXY_NONE, PROXY_HTTP, PROXY_SOCKS, PROXY_TELNET }; enum { @@ -219,12 +232,23 @@ enum { }; enum { - /* - * Close On Exit behaviours. (cfg.close_on_exit) - */ - COE_NEVER, /* Never close the window */ - COE_NORMAL, /* Close window on "normal" (non-error) exits only */ - COE_ALWAYS /* Always close the window */ + /* Protocol back ends. (cfg.protocol) */ + PROT_RAW, PROT_TELNET, PROT_RLOGIN, PROT_SSH +}; + +enum { + /* Bell settings (cfg.beep) */ + BELL_DISABLED, BELL_DEFAULT, BELL_VISUAL, BELL_WAVEFILE +}; + +enum { + /* Taskbar flashing indication on bell (cfg.beep_ind) */ + B_IND_DISABLED, B_IND_FLASH, B_IND_STEADY +}; + +enum { + /* Resize actions (cfg.resize_action) */ + RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT, RESIZE_EITHER }; enum { @@ -275,20 +299,28 @@ extern struct backend_list { */ extern const int be_default_protocol; +/* + * IMPORTANT POLICY POINT: everything in this structure which wants + * to be treated like an integer must be an actual, honest-to- + * goodness `int'. No enum-typed variables. This is because parts + * of the code will want to pass around `int *' pointers to them + * and we can't run the risk of porting to some system on which the + * enum comes out as a different size from int. + */ struct config_tag { /* Basic options */ char host[512]; int port; - enum { PROT_RAW, PROT_TELNET, PROT_RLOGIN, PROT_SSH } protocol; + int protocol; int close_on_exit; int warn_on_close; int ping_interval; /* in seconds */ int tcp_nodelay; /* Proxy options */ char proxy_exclude_list[512]; - enum { PROXYDNS_NO, PROXYDNS_AUTO, PROXYDNS_YES } proxy_dns; + int proxy_dns; int even_proxy_localhost; - enum { PROXY_NONE, PROXY_HTTP, PROXY_SOCKS, PROXY_TELNET } proxy_type; + int proxy_type; char proxy_host[512]; int proxy_port; char proxy_username[32]; @@ -359,12 +391,8 @@ struct config_tag { int lfhascr; int cursor_type; /* 0=block 1=underline 2=vertical */ int blink_cur; - enum { - BELL_DISABLED, BELL_DEFAULT, BELL_VISUAL, BELL_WAVEFILE - } beep; - enum { - B_IND_DISABLED, B_IND_FLASH, B_IND_STEADY - } beep_ind; + int beep; + int beep_ind; int bellovl; /* bell overload protection active? */ int bellovl_n; /* number of bells to cause overload */ int bellovl_t; /* time interval for overload (seconds) */ @@ -372,7 +400,7 @@ struct config_tag { char bell_wavefile[FILENAME_MAX]; int scrollbar; int scrollbar_in_fullscreen; - enum { RESIZE_TERM, RESIZE_DISABLED, RESIZE_FONT, RESIZE_EITHER } resize_action; + int resize_action; int bce; int blinktext; int win_name_always; @@ -401,7 +429,7 @@ struct config_tag { int mouse_override; short wordness[256]; /* translations */ - VT_Mode vtmode; + int vtmode; char line_codepage[128]; int xlat_capslockcyr; /* X11 forwarding */ @@ -413,9 +441,7 @@ struct config_tag { int rport_acceptall; /* same for remote forwarded ports (SSH2 only) */ char portfwd[1024]; /* [LR]localport\thost:port\000[LR]localport\thost:port\000\000 */ /* SSH bug compatibility modes */ - enum { - BUG_AUTO, BUG_OFF, BUG_ON - } sshbug_ignore1, sshbug_plainpw1, sshbug_rsa1, + int sshbug_ignore1, sshbug_plainpw1, sshbug_rsa1, sshbug_hmac2, sshbug_derivekey2, sshbug_rsapad2, sshbug_dhgex2; /* Options for pterm. Should split out into platform-dependent part. */ diff --git a/settings.c b/settings.c index 2c37dce7..8dc31f4d 100644 --- a/settings.c +++ b/settings.c @@ -373,17 +373,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) break; } - /* - * CloseOnExit defaults to closing only on a clean exit - but - * unfortunately not on Unix (pterm). On Unix, the exit code of - * a shell is the last exit code of one of its child processes, - * even if it's an interactive shell - so some pterms will - * close and some will not for no particularly good reason. The - * mode is still useful for specialist purposes (running a - * single command in its own pterm), but I don't think it's a - * sane default, unfortunately. - */ - gppi(sesskey, "CloseOnExit", COE_NORMAL, &cfg->close_on_exit); + gppi(sesskey, "CloseOnExit", AUTO, &cfg->close_on_exit); gppi(sesskey, "WarnOnClose", 1, &cfg->warn_on_close); { /* This is two values for backward compatibility with 0.50/0.51 */ @@ -401,9 +391,9 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) /* proxy settings */ gpps(sesskey, "ProxyExcludeList", "", cfg->proxy_exclude_list, sizeof(cfg->proxy_exclude_list)); - gppi(sesskey, "ProxyDNS", PROXYDNS_AUTO, &i); cfg->proxy_dns = i; + gppi(sesskey, "ProxyDNS", AUTO, &cfg->proxy_dns); gppi(sesskey, "ProxyLocalhost", 0, &cfg->even_proxy_localhost); - gppi(sesskey, "ProxyType", PROXY_NONE, &i); cfg->proxy_type = i; + gppi(sesskey, "ProxyType", PROXY_NONE, &cfg->proxy_type); gpps(sesskey, "ProxyHost", "proxy", cfg->proxy_host, sizeof(cfg->proxy_host)); gppi(sesskey, "ProxyPort", 80, &cfg->proxy_port); @@ -474,8 +464,8 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) gppi(sesskey, "CtrlAltKeys", 1, &cfg->ctrlaltkeys); gppi(sesskey, "TelnetKey", 0, &cfg->telnet_keyboard); gppi(sesskey, "TelnetRet", 1, &cfg->telnet_newline); - gppi(sesskey, "LocalEcho", LD_BACKEND, &cfg->localecho); - gppi(sesskey, "LocalEdit", LD_BACKEND, &cfg->localedit); + gppi(sesskey, "LocalEcho", AUTO, &cfg->localecho); + gppi(sesskey, "LocalEdit", AUTO, &cfg->localedit); gpps(sesskey, "Answerback", "PuTTY", cfg->answerback, sizeof(cfg->answerback)); gppi(sesskey, "AlwaysOnTop", 0, &cfg->alwaysontop); @@ -486,8 +476,8 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) gppi(sesskey, "CurType", 0, &cfg->cursor_type); gppi(sesskey, "BlinkCur", 0, &cfg->blink_cur); /* pedantic compiler tells me I can't use &cfg->beep as an int * :-) */ - gppi(sesskey, "Beep", 1, &i); cfg->beep = i; - gppi(sesskey, "BeepInd", 0, &i); cfg->beep_ind = i; + gppi(sesskey, "Beep", 1, &cfg->beep); + gppi(sesskey, "BeepInd", 0, &cfg->beep_ind); gpps(sesskey, "BellWaveFile", "", cfg->bell_wavefile, sizeof(cfg->bell_wavefile)); gppi(sesskey, "BellOverload", 1, &cfg->bellovl); @@ -583,7 +573,7 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) gppi(sesskey, "ScrollBarFullScreen", 0, &cfg->scrollbar_in_fullscreen); gppi(sesskey, "ScrollOnKey", 0, &cfg->scroll_on_key); gppi(sesskey, "ScrollOnDisp", 1, &cfg->scroll_on_disp); - gppi(sesskey, "LockSize", 0, &i); cfg->resize_action = i; + gppi(sesskey, "LockSize", 0, &cfg->resize_action); gppi(sesskey, "BCE", 1, &cfg->bce); gppi(sesskey, "BlinkText", 0, &cfg->blinktext); gppi(sesskey, "X11Forward", 0, &cfg->x11_forward); @@ -613,21 +603,21 @@ void load_open_settings(void *sesskey, int do_host, Config *cfg) } *q = '\0'; } - gppi(sesskey, "BugIgnore1", BUG_AUTO, &i); cfg->sshbug_ignore1 = i; - gppi(sesskey, "BugPlainPW1", BUG_AUTO, &i); cfg->sshbug_plainpw1 = i; - gppi(sesskey, "BugRSA1", BUG_AUTO, &i); cfg->sshbug_rsa1 = i; + gppi(sesskey, "BugIgnore1", AUTO, &cfg->sshbug_ignore1); + gppi(sesskey, "BugPlainPW1", AUTO, &cfg->sshbug_plainpw1); + gppi(sesskey, "BugRSA1", AUTO, &cfg->sshbug_rsa1); { int i; - gppi(sesskey, "BugHMAC2", BUG_AUTO, &i); cfg->sshbug_hmac2 = i; - if (cfg->sshbug_hmac2 == BUG_AUTO) { + gppi(sesskey, "BugHMAC2", AUTO, &cfg->sshbug_hmac2); + if (cfg->sshbug_hmac2 == AUTO) { gppi(sesskey, "BuggyMAC", 0, &i); if (i == 1) - cfg->sshbug_hmac2 = BUG_ON; + cfg->sshbug_hmac2 = FORCE_ON; } } - gppi(sesskey, "BugDeriveKey2", BUG_AUTO, &i); cfg->sshbug_derivekey2 = i; - gppi(sesskey, "BugRSAPad2", BUG_AUTO, &i); cfg->sshbug_rsapad2 = i; - gppi(sesskey, "BugDHGEx2", BUG_AUTO, &i); cfg->sshbug_dhgex2 = i; + gppi(sesskey, "BugDeriveKey2", AUTO, &cfg->sshbug_derivekey2); + gppi(sesskey, "BugRSAPad2", AUTO, &cfg->sshbug_rsapad2); + gppi(sesskey, "BugDHGEx2", AUTO, &cfg->sshbug_dhgex2); gppi(sesskey, "StampUtmp", 1, &cfg->stamp_utmp); gppi(sesskey, "LoginShell", 1, &cfg->login_shell); gppi(sesskey, "ScrollbarOnLeft", 0, &cfg->scrollbar_on_left); diff --git a/ssh.c b/ssh.c index 4537f38f..a968e60e 100644 --- a/ssh.c +++ b/ssh.c @@ -1719,8 +1719,8 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring) ssh->remote_bugs = 0; - if (ssh->cfg.sshbug_ignore1 == BUG_ON || - (ssh->cfg.sshbug_ignore1 == BUG_AUTO && + if (ssh->cfg.sshbug_ignore1 == FORCE_ON || + (ssh->cfg.sshbug_ignore1 == AUTO && (!strcmp(imp, "1.2.18") || !strcmp(imp, "1.2.19") || !strcmp(imp, "1.2.20") || !strcmp(imp, "1.2.21") || !strcmp(imp, "1.2.22") || !strcmp(imp, "Cisco-1.25")))) { @@ -1733,8 +1733,8 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring) logevent("We believe remote version has SSH1 ignore bug"); } - if (ssh->cfg.sshbug_plainpw1 == BUG_ON || - (ssh->cfg.sshbug_plainpw1 == BUG_AUTO && + if (ssh->cfg.sshbug_plainpw1 == FORCE_ON || + (ssh->cfg.sshbug_plainpw1 == AUTO && (!strcmp(imp, "Cisco-1.25")))) { /* * These versions need a plain password sent; they can't @@ -1745,8 +1745,8 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring) logevent("We believe remote version needs a plain SSH1 password"); } - if (ssh->cfg.sshbug_rsa1 == BUG_ON || - (ssh->cfg.sshbug_rsa1 == BUG_AUTO && + if (ssh->cfg.sshbug_rsa1 == FORCE_ON || + (ssh->cfg.sshbug_rsa1 == AUTO && (!strcmp(imp, "Cisco-1.25")))) { /* * These versions apparently have no clue whatever about @@ -1757,8 +1757,8 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring) logevent("We believe remote version can't handle RSA authentication"); } - if (ssh->cfg.sshbug_hmac2 == BUG_ON || - (ssh->cfg.sshbug_hmac2 == BUG_AUTO && + if (ssh->cfg.sshbug_hmac2 == FORCE_ON || + (ssh->cfg.sshbug_hmac2 == AUTO && (wc_match("2.1.0*", imp) || wc_match("2.0.*", imp) || wc_match("2.2.0*", imp) || wc_match("2.3.0*", imp) || wc_match("2.1 *", imp)))) { @@ -1769,8 +1769,8 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring) logevent("We believe remote version has SSH2 HMAC bug"); } - if (ssh->cfg.sshbug_derivekey2 == BUG_ON || - (ssh->cfg.sshbug_derivekey2 == BUG_AUTO && + if (ssh->cfg.sshbug_derivekey2 == FORCE_ON || + (ssh->cfg.sshbug_derivekey2 == AUTO && (wc_match("2.0.0*", imp) || wc_match("2.0.1[01]*", imp) ))) { /* * These versions have the key-derivation bug (failing to @@ -1781,8 +1781,8 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring) logevent("We believe remote version has SSH2 key-derivation bug"); } - if (ssh->cfg.sshbug_rsapad2 == BUG_ON || - (ssh->cfg.sshbug_rsapad2 == BUG_AUTO && + if (ssh->cfg.sshbug_rsapad2 == FORCE_ON || + (ssh->cfg.sshbug_rsapad2 == AUTO && (wc_match("OpenSSH_2.[5-9]*", imp) || wc_match("OpenSSH_3.[0-2]*", imp)))) { /* @@ -1792,7 +1792,7 @@ static void ssh_detect_bugs(Ssh ssh, char *vstring) logevent("We believe remote version has SSH2 RSA padding bug"); } - if (ssh->cfg.sshbug_dhgex2 == BUG_ON) { + if (ssh->cfg.sshbug_dhgex2 == FORCE_ON) { /* * User specified the SSH2 DH GEX bug. */ diff --git a/unix/pterm.c b/unix/pterm.c index 328f5afd..db8f3a85 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -91,14 +91,14 @@ char *x_get_default(const char *key) char *platform_default_s(const char *name) { if (!strcmp(name, "Font")) - return "fixed"; /* COE_NORMAL works badly in an xterm */ + return "fixed"; return NULL; } int platform_default_i(const char *name, int def) { if (!strcmp(name, "CloseOnExit")) - return COE_ALWAYS; /* COE_NORMAL works badly in an xterm */ + return FORCE_ON; /* AUTO works badly in an xterm */ return def; } @@ -991,8 +991,8 @@ void done_with_pty(struct gui_data *inst) * Terminate now, if the Close On Exit setting is * appropriate. */ - if (inst->cfg.close_on_exit == COE_ALWAYS || - (inst->cfg.close_on_exit == COE_NORMAL && clean)) + if (inst->cfg.close_on_exit == FORCE_ON || + (inst->cfg.close_on_exit == AUTO && clean)) exit(0); /* diff --git a/windlg.c b/windlg.c index bf981297..4a771719 100644 --- a/windlg.c +++ b/windlg.c @@ -1136,11 +1136,11 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard); CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline); CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO, - cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND : - cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO); + cfg.localecho == AUTO ? IDC_ECHOBACKEND : + cfg.localecho == FORCE_ON ? IDC_ECHOYES : IDC_ECHONO); CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO, - cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND : - cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO); + cfg.localedit == AUTO ? IDC_EDITBACKEND : + cfg.localedit == FORCE_ON ? IDC_EDITYES : IDC_EDITNO); SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback); CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop); CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter); @@ -1192,9 +1192,9 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER : IDC_RESIZENONE); CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL, - cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL : + cfg.close_on_exit == AUTO ? IDC_COENORMAL : cfg.close_on_exit == - COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS); + FORCE_OFF ? IDC_COENEVER : IDC_COEALWAYS); CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close); SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype); @@ -1373,8 +1373,8 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list); CheckDlgButton(hwnd, IDC_PROXYLOCALHOST, cfg.even_proxy_localhost); CheckRadioButton(hwnd, IDC_PROXYDNSNO, IDC_PROXYDNSYES, - cfg.proxy_dns == PROXYDNS_NO ? IDC_PROXYDNSNO : - cfg.proxy_dns == PROXYDNS_YES ? IDC_PROXYDNSYES : + cfg.proxy_dns == FORCE_OFF ? IDC_PROXYDNSNO : + cfg.proxy_dns == FORCE_ON ? IDC_PROXYDNSYES : IDC_PROXYDNSAUTO); SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command); SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username); @@ -1388,50 +1388,50 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess) SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Off"); SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"On"); SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_SETCURSEL, - cfg.sshbug_ignore1 == BUG_ON ? 2 : - cfg.sshbug_ignore1 == BUG_OFF ? 1 : 0, 0); + cfg.sshbug_ignore1 == FORCE_ON ? 2 : + cfg.sshbug_ignore1 == FORCE_OFF ? 1 : 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Auto"); SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Off"); SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"On"); SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_SETCURSEL, - cfg.sshbug_plainpw1 == BUG_ON ? 2 : - cfg.sshbug_plainpw1 == BUG_OFF ? 1 : 0, 0); + cfg.sshbug_plainpw1 == FORCE_ON ? 2 : + cfg.sshbug_plainpw1 == FORCE_OFF ? 1 : 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Auto"); SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Off"); SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"On"); SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_SETCURSEL, - cfg.sshbug_rsa1 == BUG_ON ? 2 : - cfg.sshbug_rsa1 == BUG_OFF ? 1 : 0, 0); + cfg.sshbug_rsa1 == FORCE_ON ? 2 : + cfg.sshbug_rsa1 == FORCE_OFF ? 1 : 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Auto"); SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Off"); SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"On"); SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_SETCURSEL, - cfg.sshbug_hmac2 == BUG_ON ? 2 : - cfg.sshbug_hmac2 == BUG_OFF ? 1 : 0, 0); + cfg.sshbug_hmac2 == FORCE_ON ? 2 : + cfg.sshbug_hmac2 == FORCE_OFF ? 1 : 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Auto"); SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Off"); SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"On"); SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_SETCURSEL, - cfg.sshbug_derivekey2 == BUG_ON ? 2 : - cfg.sshbug_derivekey2 == BUG_OFF ? 1 : 0, 0); + cfg.sshbug_derivekey2 == FORCE_ON ? 2 : + cfg.sshbug_derivekey2 == FORCE_OFF ? 1 : 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Auto"); SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Off"); SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"On"); SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_SETCURSEL, - cfg.sshbug_rsapad2 == BUG_ON ? 2 : - cfg.sshbug_rsapad2 == BUG_OFF ? 1 : 0, 0); + cfg.sshbug_rsapad2 == FORCE_ON ? 2 : + cfg.sshbug_rsapad2 == FORCE_OFF ? 1 : 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Auto"); SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Off"); SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"On"); SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_SETCURSEL, - cfg.sshbug_dhgex2 == BUG_ON ? 2 : - cfg.sshbug_dhgex2 == BUG_OFF ? 1 : 0, 0); + cfg.sshbug_dhgex2 == FORCE_ON ? 2 : + cfg.sshbug_dhgex2 == FORCE_OFF ? 1 : 0, 0); } struct treeview_faff { @@ -2678,11 +2678,11 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) { if (LOWORD(wParam) == IDC_ECHOBACKEND) - cfg.localecho = LD_BACKEND; + cfg.localecho = AUTO; if (LOWORD(wParam) == IDC_ECHOYES) - cfg.localecho = LD_YES; + cfg.localecho = FORCE_ON; if (LOWORD(wParam) == IDC_ECHONO) - cfg.localecho = LD_NO; + cfg.localecho = FORCE_OFF; } break; case IDC_EDITBACKEND: @@ -2691,11 +2691,11 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) { if (LOWORD(wParam) == IDC_EDITBACKEND) - cfg.localedit = LD_BACKEND; + cfg.localedit = AUTO; if (LOWORD(wParam) == IDC_EDITYES) - cfg.localedit = LD_YES; + cfg.localedit = FORCE_ON; if (LOWORD(wParam) == IDC_EDITNO) - cfg.localedit = LD_NO; + cfg.localedit = FORCE_OFF; } break; case IDC_ANSWEREDIT: @@ -2992,10 +2992,10 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, HIWORD(wParam) == BN_DOUBLECLICKED) { cfg.close_on_exit = IsDlgButtonChecked(hwnd, - IDC_COEALWAYS) ? COE_ALWAYS : + IDC_COEALWAYS) ? FORCE_ON : IsDlgButtonChecked(hwnd, - IDC_COENEVER) ? COE_NEVER : - COE_NORMAL; + IDC_COENEVER) ? FORCE_OFF : + AUTO; } break; case IDC_CLOSEWARN: @@ -3074,9 +3074,9 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DOUBLECLICKED) { cfg.proxy_dns = - IsDlgButtonChecked(hwnd, IDC_PROXYDNSNO) ? PROXYDNS_NO : - IsDlgButtonChecked(hwnd, IDC_PROXYDNSYES) ? PROXYDNS_YES : - PROXYDNS_AUTO; + IsDlgButtonChecked(hwnd, IDC_PROXYDNSNO) ? FORCE_OFF : + IsDlgButtonChecked(hwnd, IDC_PROXYDNSYES) ? FORCE_ON : + AUTO; } break; case IDC_PROXYTYPENONE: @@ -3649,56 +3649,56 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, if (HIWORD(wParam) == CBN_SELCHANGE) { int index = SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_GETCURSEL, 0, 0); - cfg.sshbug_ignore1 = (index == 0 ? BUG_AUTO : - index == 1 ? BUG_OFF : BUG_ON); + cfg.sshbug_ignore1 = (index == 0 ? AUTO : + index == 1 ? FORCE_OFF : FORCE_ON); } break; case IDC_BUGD_PLAINPW1: if (HIWORD(wParam) == CBN_SELCHANGE) { int index = SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_GETCURSEL, 0, 0); - cfg.sshbug_plainpw1 = (index == 0 ? BUG_AUTO : - index == 1 ? BUG_OFF : BUG_ON); + cfg.sshbug_plainpw1 = (index == 0 ? AUTO : + index == 1 ? FORCE_OFF : FORCE_ON); } break; case IDC_BUGD_RSA1: if (HIWORD(wParam) == CBN_SELCHANGE) { int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_GETCURSEL, 0, 0); - cfg.sshbug_rsa1 = (index == 0 ? BUG_AUTO : - index == 1 ? BUG_OFF : BUG_ON); + cfg.sshbug_rsa1 = (index == 0 ? AUTO : + index == 1 ? FORCE_OFF : FORCE_ON); } break; case IDC_BUGD_HMAC2: if (HIWORD(wParam) == CBN_SELCHANGE) { int index = SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_GETCURSEL, 0, 0); - cfg.sshbug_hmac2 = (index == 0 ? BUG_AUTO : - index == 1 ? BUG_OFF : BUG_ON); + cfg.sshbug_hmac2 = (index == 0 ? AUTO : + index == 1 ? FORCE_OFF : FORCE_ON); } break; case IDC_BUGD_DERIVEKEY2: if (HIWORD(wParam) == CBN_SELCHANGE) { int index = SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_GETCURSEL, 0, 0); - cfg.sshbug_derivekey2 = (index == 0 ? BUG_AUTO : - index == 1 ? BUG_OFF : BUG_ON); + cfg.sshbug_derivekey2 = (index == 0 ? AUTO : + index == 1 ? FORCE_OFF:FORCE_ON); } break; case IDC_BUGD_RSAPAD2: if (HIWORD(wParam) == CBN_SELCHANGE) { int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_GETCURSEL, 0, 0); - cfg.sshbug_rsapad2 = (index == 0 ? BUG_AUTO : - index == 1 ? BUG_OFF : BUG_ON); + cfg.sshbug_rsapad2 = (index == 0 ? AUTO : + index == 1 ? FORCE_OFF : FORCE_ON); } break; case IDC_BUGD_DHGEX2: if (HIWORD(wParam) == CBN_SELCHANGE) { int index = SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_GETCURSEL, 0, 0); - cfg.sshbug_dhgex2 = (index == 0 ? BUG_AUTO : - index == 1 ? BUG_OFF : BUG_ON); + cfg.sshbug_dhgex2 = (index == 0 ? AUTO : + index == 1 ? FORCE_OFF : FORCE_ON); } break; } diff --git a/window.c b/window.c index 0fc7316e..609e3b6c 100644 --- a/window.c +++ b/window.c @@ -912,7 +912,7 @@ void connection_fatal(void *frontend, char *fmt, ...) vsprintf(stuff, fmt, ap); va_end(ap); MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK); - if (cfg.close_on_exit == COE_ALWAYS) + if (cfg.close_on_exit == FORCE_ON) PostQuitMessage(1); else { session_closed = TRUE; @@ -957,8 +957,8 @@ static void enact_pending_netevent(void) if (ret == 0 && !session_closed) { /* Abnormal exits will already have set session_closed and taken * appropriate action. */ - if (cfg.close_on_exit == COE_ALWAYS || - cfg.close_on_exit == COE_NORMAL) PostQuitMessage(0); + if (cfg.close_on_exit == FORCE_ON || + cfg.close_on_exit == AUTO) PostQuitMessage(0); else { session_closed = TRUE; set_icon(NULL, "PuTTY (inactive)");