16 #define TVINSERTSTRUCT TV_INSERTSTRUCT
17 #define TVITEM TV_ITEM
21 static char **events = NULL;
22 static int nevents = 0, negsize = 0;
25 static int sesslist_has_focus;
26 static int requested_help;
28 static struct prefslist cipherlist;
30 #define PRINTER_DISABLED_STRING "None (printing disabled)"
32 void force_normal(HWND hwnd)
34 static int recurse = 0;
42 wp.length = sizeof(wp);
43 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
44 wp.showCmd = SW_SHOWNORMAL;
45 SetWindowPlacement(hwnd, &wp);
50 static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
54 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
59 static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
63 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
65 *result = (int) (scale * atof(text));
68 static void MySetDlgItemFlt(HWND hwnd, int id, double value)
71 sprintf(text, "%g", value);
72 SetDlgItemText(hwnd, id, text);
75 static int CALLBACK LogProc(HWND hwnd, UINT msg,
76 WPARAM wParam, LPARAM lParam)
83 static int tabs[4] = { 78, 108 };
84 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
87 for (i = 0; i < nevents; i++)
88 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
89 0, (LPARAM) events[i]);
92 switch (LOWORD(wParam)) {
96 SetActiveWindow(GetParent(hwnd));
100 if (HIWORD(wParam) == BN_CLICKED ||
101 HIWORD(wParam) == BN_DOUBLECLICKED) {
104 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
105 LB_GETSELCOUNT, 0, 0);
106 if (selcount == 0) { /* don't even try to copy zero items */
111 selitems = smalloc(selcount * sizeof(int));
113 int count = SendDlgItemMessage(hwnd, IDN_LIST,
120 static unsigned char sel_nl[] = SEL_NL;
122 if (count == 0) { /* can't copy zero stuff */
128 for (i = 0; i < count; i++)
130 strlen(events[selitems[i]]) + sizeof(sel_nl);
132 clipdata = smalloc(size);
135 for (i = 0; i < count; i++) {
136 char *q = events[selitems[i]];
137 int qlen = strlen(q);
140 memcpy(p, sel_nl, sizeof(sel_nl));
143 write_aclip(clipdata, size, TRUE);
148 for (i = 0; i < nevents; i++)
149 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
158 SetActiveWindow(GetParent(hwnd));
165 static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
166 WPARAM wParam, LPARAM lParam)
172 switch (LOWORD(wParam)) {
185 static int CALLBACK AboutProc(HWND hwnd, UINT msg,
186 WPARAM wParam, LPARAM lParam)
190 SetDlgItemText(hwnd, IDA_VERSION, ver);
193 switch (LOWORD(wParam)) {
196 EndDialog(hwnd, TRUE);
199 EnableWindow(hwnd, 0);
200 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
202 EnableWindow(hwnd, 1);
203 SetActiveWindow(hwnd);
207 /* Load web browser */
208 ShellExecute(hwnd, "open",
209 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
210 0, 0, SW_SHOWDEFAULT);
215 EndDialog(hwnd, TRUE);
222 * Null dialog procedure.
224 static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
225 WPARAM wParam, LPARAM lParam)
230 static char savedsession[2048];
233 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
386 IDC_SCROLLBARFULLSCREEN,
401 IDC_FULLSCREENONALTENTER,
404 appearancepanelstart,
405 IDC_TITLE_APPEARANCE,
427 connectionpanelstart,
428 IDC_TITLE_CONNECTION,
453 IDC_PROXYEXCLUDESTATIC,
454 IDC_PROXYEXCLUDEEDIT,
460 IDC_PROXYTELNETCMDSTATIC,
461 IDC_PROXYTELNETCMDEDIT,
462 IDC_PROXYSOCKSVERSTATIC,
574 translationpanelstart,
575 IDC_TITLE_TRANSLATION,
576 IDC_BOX_TRANSLATION1,
577 IDC_BOX_TRANSLATION2,
578 IDC_BOX_TRANSLATION3,
616 static const char *const colours[] = {
617 "Default Foreground", "Default Bold Foreground",
618 "Default Background", "Default Bold Background",
619 "Cursor Text", "Cursor Colour",
620 "ANSI Black", "ANSI Black Bold",
621 "ANSI Red", "ANSI Red Bold",
622 "ANSI Green", "ANSI Green Bold",
623 "ANSI Yellow", "ANSI Yellow Bold",
624 "ANSI Blue", "ANSI Blue Bold",
625 "ANSI Magenta", "ANSI Magenta Bold",
626 "ANSI Cyan", "ANSI Cyan Bold",
627 "ANSI White", "ANSI White Bold"
629 static const int permcolour[] = {
630 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
631 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
632 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
635 static void fmtfont(char *buf)
637 sprintf(buf, "Font: %s, ", cfg.font);
639 strcat(buf, "bold, ");
640 if (cfg.fontheight == 0)
641 strcat(buf, "default height");
643 sprintf(buf + strlen(buf), "%d-point",
644 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
647 char *help_context_cmd(int id)
659 return "JI(`',`session.hostname')";
666 return "JI(`',`session.saved')";
671 return "JI(`',`session.coe')";
672 case IDC_LSTATSTATIC:
676 case IDC_LSTATPACKET:
677 return "JI(`',`logging.main')";
682 return "JI(`',`logging.filename')";
687 return "JI(`',`logging.exists')";
692 return "JI(`',`keyboard.backspace')";
696 return "JI(`',`keyboard.homeend')";
704 return "JI(`',`keyboard.funkeys')";
708 return "JI(`',`keyboard.appkeypad')";
712 return "JI(`',`keyboard.appcursor')";
714 return "JI(`',`keyboard.nethack')";
716 return "JI(`',`keyboard.compose')";
717 case IDC_CTRLALTKEYS:
718 return "JI(`',`keyboard.ctrlalt')";
722 return "JI(`',`features.application')";
724 return "JI(`',`features.mouse')";
726 return "JI(`',`features.resize')";
727 case IDC_NOALTSCREEN:
728 return "JI(`',`features.altscreen')";
730 return "JI(`',`features.retitle')";
731 case IDC_NODBACKSPACE:
732 return "JI(`',`features.dbackspace')";
734 return "JI(`',`features.charset')";
737 return "JI(`',`terminal.autowrap')";
739 return "JI(`',`terminal.decom')";
741 return "JI(`',`terminal.lfhascr')";
743 return "JI(`',`terminal.bce')";
745 return "JI(`',`terminal.blink')";
748 return "JI(`',`terminal.answerback')";
750 case IDC_ECHOBACKEND:
753 return "JI(`',`terminal.localecho')";
755 case IDC_EDITBACKEND:
758 return "JI(`',`terminal.localedit')";
759 case IDC_PRINTERSTATIC:
761 return "JI(`',`terminal.printing')";
764 case IDC_BELL_DISABLED:
765 case IDC_BELL_DEFAULT:
766 case IDC_BELL_WAVEFILE:
767 case IDC_BELL_VISUAL:
768 case IDC_BELL_WAVESTATIC:
769 case IDC_BELL_WAVEEDIT:
770 case IDC_BELL_WAVEBROWSE:
771 return "JI(`',`bell.style')";
772 case IDC_B_IND_STATIC:
773 case IDC_B_IND_DISABLED:
774 case IDC_B_IND_FLASH:
775 case IDC_B_IND_STEADY:
776 return "JI(`',`bell.taskbar')";
778 case IDC_BELLOVLNSTATIC:
780 case IDC_BELLOVLTSTATIC:
782 case IDC_BELLOVLEXPLAIN:
783 case IDC_BELLOVLSSTATIC:
785 return "JI(`',`bell.overload')";
791 return "JI(`',`window.size')";
792 case IDC_RESIZESTATIC:
796 case IDC_RESIZEEITHER:
797 return "JI(`',`window.resize')";
799 case IDC_SCROLLBARFULLSCREEN:
804 return "JI(`',`window.scrollback')";
807 return "JI(`',`behaviour.closewarn')";
809 return "JI(`',`behaviour.altf4')";
811 return "JI(`',`behaviour.altspace')";
813 return "JI(`',`behaviour.altonly')";
814 case IDC_ALWAYSONTOP:
815 return "JI(`',`behaviour.alwaysontop')";
816 case IDC_FULLSCREENONALTENTER:
817 return "JI(`',`behaviour.altenter')";
819 case IDC_CURSORSTATIC:
824 return "JI(`',`appearance.cursor')";
827 return "JI(`',`appearance.font')";
831 return "JI(`',`appearance.title')";
833 return "JI(`',`appearance.hidemouse')";
837 return "JI(`',`appearance.border')";
841 return "JI(`',`connection.termtype')";
844 return "JI(`',`connection.username')";
847 return "JI(`',`connection.keepalive')";
849 return "JI(`',`connection.nodelay')";
853 return "JI(`',`telnet.termspeed')";
862 return "JI(`',`telnet.environ')";
866 return "JI(`',`telnet.oldenviron')";
870 return "JI(`',`telnet.passive')";
872 return "JI(`',`telnet.specialkeys')";
874 return "JI(`',`telnet.newline')";
878 return "JI(`',`rlogin.termspeed')";
879 case IDC_RLLUSERSTATIC:
880 case IDC_RLLUSEREDIT:
881 return "JI(`',`rlogin.localuser')";
884 return "JI(`',`ssh.nopty')";
885 case IDC_CIPHERSTATIC2:
890 return "JI(`',`ssh.ciphers')";
892 return "JI(`',`ssh.buggymac')";
893 case IDC_SSHPROTSTATIC:
896 case IDC_SSHPROT2ONLY:
897 return "JI(`',`ssh.protocol')";
900 return "JI(`',`ssh.command')";
902 return "JI(`',`ssh.compress')";
907 return "JI(`',`ssh.auth.privkey')";
909 return "JI(`',`ssh.auth.agentfwd')";
911 return "JI(`',`ssh.auth.changeuser')";
913 return "JI(`',`ssh.auth.tis')";
915 return "JI(`',`ssh.auth.ki')";
920 return "JI(`',`selection.buttons')";
921 case IDC_MOUSEOVERRIDE:
922 return "JI(`',`selection.shiftdrag')";
923 case IDC_SELTYPESTATIC:
925 case IDC_SELTYPERECT:
926 return "JI(`',`selection.rect')";
932 return "JI(`',`selection.charclasses')";
934 return "JI(`',`selection.linedraw')";
936 return "JI(`',`selection.rtf')";
939 return "JI(`',`colours.bold')";
941 return "JI(`',`colours.logpal')";
942 case IDC_COLOURSTATIC:
951 return "JI(`',`colours.config')";
953 case IDC_CODEPAGESTATIC:
955 return "JI(`',`translation.codepage')";
956 case IDC_CAPSLOCKCYR:
957 return "JI(`',`translation.cyrillic')";
964 return "JI(`',`translation.linedraw')";
966 case IDC_X11_FORWARD:
967 case IDC_X11_DISPSTATIC:
968 case IDC_X11_DISPLAY:
969 return "JI(`',`ssh.tunnels.x11')";
971 case IDC_PFWDSTATIC2:
975 case IDC_SPORTSTATIC:
977 case IDC_DPORTSTATIC:
981 return "JI(`',`ssh.tunnels.portfwd')";
984 return "JI(`',`ssh.tunnels.portfwd.localhost')";
991 /* 2nd arg: NZ => don't redraw session list (use when loading
993 static void init_dlg_ctrls(HWND hwnd, int keepsess)
996 char fontstatic[256];
998 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
999 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
1002 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
1003 for (i = n; i-- > 0;)
1004 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
1005 for (i = 0; i < nsessions; i++)
1006 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
1007 0, (LPARAM) (sessions[i]));
1009 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1010 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
1011 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
1012 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
1014 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
1015 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
1016 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
1018 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
1019 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
1020 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
1021 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
1022 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
1023 cfg.funky_type == 0 ? IDC_FUNCTILDE :
1024 cfg.funky_type == 1 ? IDC_FUNCLINUX :
1025 cfg.funky_type == 2 ? IDC_FUNCXTERM :
1026 cfg.funky_type == 3 ? IDC_FUNCVT400 :
1027 cfg.funky_type == 4 ? IDC_FUNCVT100P :
1028 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
1029 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
1030 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
1031 CheckDlgButton(hwnd, IDC_NOMOUSEREP, cfg.no_mouse_rep);
1032 CheckDlgButton(hwnd, IDC_NORESIZE, cfg.no_remote_resize);
1033 CheckDlgButton(hwnd, IDC_NOALTSCREEN, cfg.no_alt_screen);
1034 CheckDlgButton(hwnd, IDC_NOWINTITLE, cfg.no_remote_wintitle);
1035 CheckDlgButton(hwnd, IDC_NODBACKSPACE, cfg.no_dbackspace);
1036 CheckDlgButton(hwnd, IDC_NOCHARSET, cfg.no_remote_charset);
1037 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
1038 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
1039 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
1040 cfg.nethack_keypad ? IDC_KPNH :
1041 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
1042 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
1043 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
1044 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
1045 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
1046 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
1047 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
1048 CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
1049 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
1050 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
1051 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
1052 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
1053 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
1054 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
1055 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
1056 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
1057 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
1058 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
1059 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
1061 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
1062 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
1063 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
1064 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
1065 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
1066 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
1067 fmtfont(fontstatic);
1068 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1069 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
1070 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
1071 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
1072 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
1074 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
1075 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
1077 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
1078 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
1079 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
1080 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1081 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1082 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1083 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1084 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1086 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1087 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1089 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1090 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
1091 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1092 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
1093 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
1094 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1095 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1096 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1097 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1098 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
1099 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
1100 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
1101 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1102 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
1103 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
1105 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1106 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
1107 cfg.close_on_exit ==
1108 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
1109 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1111 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1112 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1113 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1114 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1115 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1116 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
1117 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
1118 cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
1119 cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
1120 cfg.logtype == LGTYP_DEBUG ? IDC_LSTATRAW :
1122 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1123 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1124 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1127 char *p = cfg.environmt;
1128 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
1130 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1136 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1141 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1142 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
1143 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1144 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
1146 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1147 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1148 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1149 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1150 CheckDlgButton(hwnd, IDC_BUGGYMAC, cfg.buggymac);
1151 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
1152 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
1153 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
1154 CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2ONLY,
1155 cfg.sshprot == 1 ? IDC_SSHPROT1 :
1156 cfg.sshprot == 2 ? IDC_SSHPROT2 : IDC_SSHPROT2ONLY);
1157 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
1158 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
1159 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1160 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1164 static const struct { char *s; int c; } ciphers[] = {
1165 { "3DES", CIPHER_3DES },
1166 { "Blowfish", CIPHER_BLOWFISH },
1167 { "DES", CIPHER_DES },
1168 { "AES (SSH 2 only)", CIPHER_AES },
1169 { "-- warn below here --", CIPHER_WARN }
1172 /* Set up the "selected ciphers" box. */
1173 /* (cipherlist assumed to contain all ciphers) */
1174 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1175 for (i = 0; i < CIPHER_MAX; i++) {
1176 int c = cfg.ssh_cipherlist[i];
1179 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1180 if (ciphers[j].c == c) {
1181 cstr = ciphers[j].s;
1185 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1187 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1193 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1194 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
1195 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1196 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
1197 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
1198 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
1199 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
1201 static int tabs[4] = { 25, 61, 96, 128 };
1202 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1205 for (i = 0; i < 128; i++) {
1207 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1208 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1209 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1213 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1214 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
1217 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1218 for (i = n; i-- > 0;)
1219 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1220 LB_DELETESTRING, i, 0);
1221 for (i = 0; i < 22; i++)
1222 if (cfg.bold_colour || permcolour[i])
1223 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1224 (LPARAM) colours[i]);
1226 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1227 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1228 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1229 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1234 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1235 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1236 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1237 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1238 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1241 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1247 pe = printer_start_enum(&nprinters);
1248 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_RESETCONTENT, 0, 0);
1249 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1250 0, (LPARAM) PRINTER_DISABLED_STRING);
1251 for (i = 0; i < nprinters; i++) {
1252 char *printer_name = printer_get_name(pe, i);
1253 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1254 0, (LPARAM) printer_name);
1256 printer_finish_enum(pe);
1257 SetDlgItemText(hwnd, IDC_PRINTER,
1258 *cfg.printer ? cfg.printer : PRINTER_DISABLED_STRING);
1261 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1262 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1263 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1264 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1265 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1268 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1269 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1271 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1272 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1273 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1276 CheckRadioButton(hwnd, IDC_PROXYTYPENONE, IDC_PROXYTYPETELNET,
1277 cfg.proxy_type == PROXY_HTTP ? IDC_PROXYTYPEHTTP :
1278 cfg.proxy_type == PROXY_SOCKS ? IDC_PROXYTYPESOCKS :
1279 cfg.proxy_type == PROXY_TELNET ? IDC_PROXYTYPETELNET : IDC_PROXYTYPENONE);
1280 SetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host);
1281 SetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, cfg.proxy_port, FALSE);
1282 SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
1283 SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
1284 SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
1285 SetDlgItemText(hwnd, IDC_PROXYPASSEDIT, cfg.proxy_password);
1286 CheckRadioButton(hwnd, IDC_PROXYSOCKSVER5, IDC_PROXYSOCKSVER4,
1287 cfg.proxy_socks_version == 4 ? IDC_PROXYSOCKSVER4 : IDC_PROXYSOCKSVER5);
1290 struct treeview_faff {
1292 HTREEITEM lastat[4];
1295 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1296 int level, char *text)
1301 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1302 ins.hInsertAfter = faff->lastat[level];
1303 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1304 #define INSITEM DUMMYUNIONNAME.item
1306 #define INSITEM item
1308 ins.INSITEM.mask = TVIF_TEXT;
1309 ins.INSITEM.pszText = text;
1310 newitem = TreeView_InsertItem(faff->treeview, &ins);
1312 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1314 faff->lastat[level] = newitem;
1315 for (i = level + 1; i < 4; i++)
1316 faff->lastat[i] = NULL;
1321 * Create the panelfuls of controls in the configuration box.
1323 static void create_controls(HWND hwnd, int dlgtype, int panel)
1325 if (panel == sessionpanelstart) {
1326 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1328 ctlposinit(&cp, hwnd, 80, 3, 13);
1329 bartitle(&cp, "Basic options for your PuTTY session",
1332 beginbox(&cp, "Specify your connection by host name or IP address",
1335 "Host &Name (or IP address)",
1336 IDC_HOSTSTATIC, IDC_HOST, 75,
1337 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1338 if (backends[3].backend == NULL) {
1339 /* this is PuTTYtel, so only three protocols available */
1340 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1341 "&Raw", IDC_PROTRAW,
1342 "&Telnet", IDC_PROTTELNET,
1343 "Rlog&in", IDC_PROTRLOGIN, NULL);
1345 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1346 "&Raw", IDC_PROTRAW,
1347 "&Telnet", IDC_PROTTELNET,
1348 "Rlog&in", IDC_PROTRLOGIN,
1357 beginbox(&cp, "Load, save or delete a stored session",
1359 sesssaver(&cp, "Sav&ed Sessions",
1360 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1361 "&Load", IDC_SESSLOAD,
1362 "Sa&ve", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1365 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1366 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1367 "Always", IDC_COEALWAYS,
1368 "Never", IDC_COENEVER,
1369 "Only on clean exit", IDC_COENORMAL, NULL);
1373 if (panel == loggingpanelstart) {
1374 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1376 ctlposinit(&cp, hwnd, 80, 3, 13);
1377 bartitle(&cp, "Options controlling session logging",
1379 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1381 "Session logging:", IDC_LSTATSTATIC,
1382 "Logging &turned off completely", IDC_LSTATOFF,
1383 "Log &printable output only", IDC_LSTATASCII,
1384 "&Log all session output", IDC_LSTATRAW,
1385 "Log &SSH packet data", IDC_LSTATPACKET,
1387 editbutton(&cp, "Log &file name:",
1388 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1390 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1391 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1393 "What to do if the log file already &exists:",
1394 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1395 "Always append to the end of it", IDC_LSTATXAPN,
1396 "Ask the user every time", IDC_LSTATXASK, NULL);
1400 if (panel == terminalpanelstart) {
1401 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1403 ctlposinit(&cp, hwnd, 80, 3, 13);
1404 bartitle(&cp, "Options controlling the terminal emulation",
1405 IDC_TITLE_TERMINAL);
1406 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1407 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1408 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1409 checkbox(&cp, "Implicit C&R in every LF", IDC_LFHASCR);
1410 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1411 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1413 "An&swerback to ^E:", IDC_ANSWERBACK,
1414 IDC_ANSWEREDIT, 100, NULL);
1417 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1418 radioline(&cp, "&Local echo:", IDC_ECHOSTATIC, 3,
1419 "Auto", IDC_ECHOBACKEND,
1420 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1421 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1422 "Auto", IDC_EDITBACKEND,
1423 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1426 beginbox(&cp, "Remote-controlled printing", IDC_BOX_TERMINAL3);
1427 combobox(&cp, "&Printer to send ANSI printer output to:",
1428 IDC_PRINTERSTATIC, IDC_PRINTER);
1432 if (panel == featurespanelstart) {
1433 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1435 ctlposinit(&cp, hwnd, 80, 3, 13);
1436 bartitle(&cp, "Enabling and disabling advanced terminal features ",
1437 IDC_TITLE_FEATURES);
1438 beginbox(&cp, NULL, IDC_BOX_FEATURES1);
1439 checkbox(&cp, "Disable application c&ursor keys mode", IDC_NOAPPLICC);
1440 checkbox(&cp, "Disable application &keypad mode", IDC_NOAPPLICK);
1441 checkbox(&cp, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP);
1442 checkbox(&cp, "Disable remote-controlled terminal re&sizing",
1444 checkbox(&cp, "Disable s&witching to alternate terminal screen",
1446 checkbox(&cp, "Disable remote-controlled window &title changing",
1448 checkbox(&cp, "Disable destructive &backspace on server sending ^?",
1450 checkbox(&cp, "Disable remote-controlled cha&racter set configuration",
1455 if (panel == bellpanelstart) {
1456 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1458 ctlposinit(&cp, hwnd, 80, 3, 13);
1459 bartitle(&cp, "Options controlling the terminal bell",
1461 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1463 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1464 "None (bell disabled)", IDC_BELL_DISABLED,
1465 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1466 "Play a custom sound file", IDC_BELL_WAVEFILE,
1467 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1468 editbutton(&cp, "Custom sound file to play as a bell:",
1469 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1470 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1471 radioline(&cp, "Taskbar/caption &indication on bell:",
1472 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1473 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1476 beginbox(&cp, "Control the bell overload behaviour",
1478 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1480 staticedit(&cp, "Over-use means this &many bells...",
1481 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1482 staticedit(&cp, "... in &this many seconds",
1483 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1485 "The bell is re-enabled after a few seconds of silence.",
1486 1, IDC_BELLOVLEXPLAIN);
1487 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1492 if (panel == keyboardpanelstart) {
1493 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1495 ctlposinit(&cp, hwnd, 80, 3, 13);
1496 bartitle(&cp, "Options controlling the effects of keys",
1497 IDC_TITLE_KEYBOARD);
1498 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1499 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1500 "Control-H", IDC_DEL008,
1501 "Control-? (127)", IDC_DEL127, NULL);
1502 radioline(&cp, "The Home and &End keys", IDC_HOMESTATIC, 2,
1503 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1504 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1505 "ESC[n~", IDC_FUNCTILDE,
1506 "Linux", IDC_FUNCLINUX,
1507 "Xterm R6", IDC_FUNCXTERM,
1508 "VT400", IDC_FUNCVT400,
1509 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1511 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1512 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1513 "Normal", IDC_CURNORMAL,
1514 "Application", IDC_CURAPPLIC, NULL);
1515 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1516 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1517 "NetHack", IDC_KPNH, NULL);
1519 beginbox(&cp, "Enable extra keyboard features:",
1521 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1522 checkbox(&cp, "Control-Alt is &different from AltGr",
1527 if (panel == windowpanelstart) {
1528 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1530 ctlposinit(&cp, hwnd, 80, 3, 13);
1531 bartitle(&cp, "Options controlling PuTTY's window",
1533 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1535 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1536 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1537 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1538 "Change the number of rows and columns", IDC_RESIZETERM,
1539 "Change the size of the font", IDC_RESIZEFONT,
1540 "Change font size only when maximised", IDC_RESIZEEITHER,
1541 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1543 beginbox(&cp, "Control the scrollback in the window",
1545 staticedit(&cp, "Lines of &scrollback",
1546 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1547 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1548 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1549 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1550 checkbox(&cp, "Reset scrollback on dis&play activity",
1555 if (panel == appearancepanelstart) {
1556 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1558 ctlposinit(&cp, hwnd, 80, 3, 13);
1559 bartitle(&cp, "Configure the appearance of PuTTY's window",
1560 IDC_TITLE_APPEARANCE);
1561 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1562 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1563 "B&lock", IDC_CURBLOCK,
1564 "&Underline", IDC_CURUNDER,
1565 "&Vertical line", IDC_CURVERT, NULL);
1566 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1568 beginbox(&cp, "Set the font used in the terminal window",
1569 IDC_BOX_APPEARANCE2);
1570 staticbtn(&cp, "", IDC_FONTSTATIC, "Cha&nge...", IDC_CHOOSEFONT);
1572 beginbox(&cp, "Adjust the use of the window title",
1573 IDC_BOX_APPEARANCE3);
1575 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1576 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1578 beginbox(&cp, "Adjust the use of the mouse pointer",
1579 IDC_BOX_APPEARANCE4);
1580 checkbox(&cp, "Hide mouse &pointer when typing in window",
1583 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1584 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1586 staticedit(&cp, "Gap between text and window edge",
1587 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1591 if (panel == behaviourpanelstart) {
1592 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1594 ctlposinit(&cp, hwnd, 80, 3, 13);
1595 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1597 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1598 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1599 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1600 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1601 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1602 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1603 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1607 if (panel == translationpanelstart) {
1608 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1610 ctlposinit(&cp, hwnd, 80, 3, 13);
1611 bartitle(&cp, "Options controlling character set translation",
1612 IDC_TITLE_TRANSLATION);
1613 beginbox(&cp, "Character set translation on received data",
1614 IDC_BOX_TRANSLATION1);
1615 combobox(&cp, "&Received data assumed to be in which character set:",
1616 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1618 beginbox(&cp, "Enable character set translation on input data",
1619 IDC_BOX_TRANSLATION2);
1620 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1623 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1624 IDC_BOX_TRANSLATION3);
1626 "Handling of line drawing characters:", IDC_VTSTATIC,
1627 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1628 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1629 "Use font in O&EM mode only", IDC_VTOEMONLY,
1630 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1631 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1635 if (panel == selectionpanelstart) {
1636 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1638 ctlposinit(&cp, hwnd, 80, 3, 13);
1639 bartitle(&cp, "Options controlling copy and paste",
1640 IDC_TITLE_SELECTION);
1641 beginbox(&cp, "Translation of pasted characters",
1642 IDC_BOX_SELECTION1);
1644 "&Don't translate line drawing chars into +, - and |",
1647 "Paste to clipboard in RT&F as well as plain text",
1650 beginbox(&cp, "Control which mouse button does which thing",
1651 IDC_BOX_SELECTION2);
1652 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1653 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1654 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1657 "Shift overrides a&pplication's use of mouse",
1660 "Default selection mode (Alt+drag does the other one):",
1661 IDC_SELTYPESTATIC, 2,
1662 "&Normal", IDC_SELTYPELEX,
1663 "&Rectangular block", IDC_SELTYPERECT, NULL);
1665 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1666 IDC_BOX_SELECTION3);
1667 charclass(&cp, "Charact&er classes:", IDC_CCSTATIC, IDC_CCLIST,
1668 "&Set", IDC_CCSET, IDC_CCEDIT,
1669 "&to class", IDC_CCSTATIC2);
1673 if (panel == colourspanelstart) {
1674 /* The Colours panel. Accelerators used: [acgoh] blum */
1676 ctlposinit(&cp, hwnd, 80, 3, 13);
1677 bartitle(&cp, "Options controlling use of colours",
1679 beginbox(&cp, "General options for colour usage",
1681 checkbox(&cp, "&Bolded text is a different colour",
1683 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1685 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1687 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1688 IDC_COLOURSTATIC, IDC_COLOURLIST,
1689 "&Modify...", IDC_CHANGE,
1690 "Red:", IDC_RSTATIC, IDC_RVALUE,
1691 "Green:", IDC_GSTATIC, IDC_GVALUE,
1692 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1696 if (panel == connectionpanelstart) {
1697 /* The Connection panel. Accelerators used: [acgoh] tukn */
1699 ctlposinit(&cp, hwnd, 80, 3, 13);
1700 bartitle(&cp, "Options controlling the connection",
1701 IDC_TITLE_CONNECTION);
1703 beginbox(&cp, "Data to send to the server",
1704 IDC_BOX_CONNECTION1);
1705 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1707 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1711 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1712 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1714 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1718 beginbox(&cp, "Sending of null packets to keep session active",
1719 IDC_BOX_CONNECTION2);
1720 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1721 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1724 beginbox(&cp, "Low-level TCP connection options",
1725 IDC_BOX_CONNECTION3);
1726 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1732 if (panel == proxypanelstart) {
1733 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmv */
1735 ctlposinit(&cp, hwnd, 80, 3, 13);
1737 bartitle(&cp, "Options controlling proxy usage",
1739 beginbox(&cp, "Proxy basics", IDC_BOX_PROXY1);
1740 radioline(&cp, "Proxy type:", IDC_PROXYTYPESTATIC, 4,
1741 "&None", IDC_PROXYTYPENONE,
1742 "H&TTP", IDC_PROXYTYPEHTTP,
1743 "&SOCKS", IDC_PROXYTYPESOCKS,
1744 "Te&lnet", IDC_PROXYTYPETELNET, NULL);
1746 "Prox&y Host", IDC_PROXYHOSTSTATIC, IDC_PROXYHOSTEDIT, 80,
1747 "&Port", IDC_PROXYPORTSTATIC, IDC_PROXYPORTEDIT, 20, NULL);
1749 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC,
1750 IDC_PROXYEXCLUDEEDIT, 100, NULL);
1751 staticedit(&cp, "&Username", IDC_PROXYUSERSTATIC,
1752 IDC_PROXYUSEREDIT, 60);
1753 staticedit(&cp, "Pass&word", IDC_PROXYPASSSTATIC,
1754 IDC_PROXYPASSEDIT, 60);
1756 beginbox(&cp, "Misc. proxy settings", IDC_BOX_PROXY2);
1758 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC,
1759 IDC_PROXYTELNETCMDEDIT, 100, NULL);
1760 radioline(&cp, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC,
1761 2, "Version 5", IDC_PROXYSOCKSVER5, "Version 4",
1762 IDC_PROXYSOCKSVER4, NULL);
1767 if (panel == telnetpanelstart) {
1768 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1770 ctlposinit(&cp, hwnd, 80, 3, 13);
1772 bartitle(&cp, "Options controlling Telnet connections",
1774 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1775 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1777 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1778 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1779 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1780 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1782 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1783 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1784 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1785 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1786 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1787 "Passive", IDC_TPASSIVE, "Active",
1789 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1791 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1797 if (panel == rloginpanelstart) {
1798 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1800 ctlposinit(&cp, hwnd, 80, 3, 13);
1802 bartitle(&cp, "Options controlling Rlogin connections",
1804 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1805 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1807 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1808 IDC_RLLUSEREDIT, 50);
1813 if (panel == sshpanelstart) {
1814 /* The SSH panel. Accelerators used: [acgoh] r pe12ni sd */
1816 ctlposinit(&cp, hwnd, 80, 3, 13);
1818 bartitle(&cp, "Options controlling SSH connections",
1820 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1822 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1825 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1826 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1827 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1828 radioline(&cp, "Preferred SSH protocol version:",
1829 IDC_SSHPROTSTATIC, 3,
1830 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2,
1831 "2 o&nly", IDC_SSHPROT2ONLY, NULL);
1832 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1835 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1836 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1837 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1839 checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
1845 if (panel == sshauthpanelstart) {
1846 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1848 ctlposinit(&cp, hwnd, 80, 3, 13);
1850 bartitle(&cp, "Options controlling SSH authentication",
1852 beginbox(&cp, "Authentication methods",
1854 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1856 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
1857 " (SSH2)", IDC_AUTHKI);
1859 beginbox(&cp, "Authentication parameters",
1861 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1862 checkbox(&cp, "Allow attempted changes of &username in SSH2",
1864 editbutton(&cp, "Private &key file for authentication:",
1865 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1871 if (panel == tunnelspanelstart) {
1872 /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
1874 ctlposinit(&cp, hwnd, 80, 3, 13);
1876 bartitle(&cp, "Options controlling SSH tunnelling",
1878 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
1879 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1880 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1881 IDC_X11_DISPLAY, 50, NULL);
1883 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1884 checkbox(&cp, "Local ports accept connections from o&ther hosts",
1886 checkbox(&cp, "Remote &ports do the same (SSH v2 only)",
1888 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1889 "&Remove", IDC_PFWDREMOVE);
1890 fwdsetter(&cp, IDC_PFWDLIST,
1891 "Add new forwarded port:", IDC_PFWDSTATIC2,
1892 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1893 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1894 "A&dd", IDC_PFWDADD);
1895 bareradioline(&cp, 2,
1896 "&Local", IDC_PFWDLOCAL,
1897 "Re&mote", IDC_PFWDREMOTE, NULL);
1905 * Helper function to load the session selected in SESSLIST
1906 * if any, as this is done in more than one place in
1907 * GenericMainDlgProc(). 0 => failure.
1909 static int load_selected_session(HWND hwnd)
1911 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1912 LB_GETCURSEL, 0, 0);
1918 isdef = !strcmp(sessions[n], "Default Settings");
1919 load_settings(sessions[n], !isdef, &cfg);
1920 init_dlg_ctrls(hwnd, TRUE);
1922 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1924 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1925 /* Restore the selection, which will have been clobbered by
1926 * SESSEDIT handling. */
1927 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
1932 * This function is the configuration box.
1934 static int GenericMainDlgProc(HWND hwnd, UINT msg,
1935 WPARAM wParam, LPARAM lParam, int dlgtype)
1938 struct treeview_faff tvfaff;
1941 char filename[sizeof(cfg.keyfile)];
1944 char fontstatic[256];
1946 struct servent *service;
1948 static UINT draglistmsg = WM_NULL;
1953 SetWindowLong(hwnd, GWL_USERDATA, 0);
1955 SetWindowLong(hwnd, GWL_EXSTYLE,
1956 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
1958 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
1960 DestroyWindow(item);
1962 requested_help = FALSE;
1963 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
1964 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
1966 * Centre the window.
1968 { /* centre the window */
1971 hw = GetDesktopWindow();
1972 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
1974 (rs.right + rs.left + rd.left - rd.right) / 2,
1975 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
1976 rd.right - rd.left, rd.bottom - rd.top, TRUE);
1980 * Create the tree view.
1988 r.right = r.left + 75;
1990 r.bottom = r.top + 10;
1991 MapDialogRect(hwnd, &r);
1992 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1993 WS_CHILD | WS_VISIBLE,
1995 r.right - r.left, r.bottom - r.top,
1996 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
1998 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1999 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2002 r.right = r.left + 75;
2004 r.bottom = r.top + 219;
2005 MapDialogRect(hwnd, &r);
2006 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
2007 WS_CHILD | WS_VISIBLE |
2008 WS_TABSTOP | TVS_HASLINES |
2009 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
2011 TVS_SHOWSELALWAYS, r.left, r.top,
2012 r.right - r.left, r.bottom - r.top,
2013 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
2015 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2016 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2017 tvfaff.treeview = treeview;
2018 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
2022 * Set up the tree view contents.
2024 hsession = treeview_insert(&tvfaff, 0, "Session");
2025 treeview_insert(&tvfaff, 1, "Logging");
2026 treeview_insert(&tvfaff, 0, "Terminal");
2027 treeview_insert(&tvfaff, 1, "Keyboard");
2028 treeview_insert(&tvfaff, 1, "Bell");
2029 treeview_insert(&tvfaff, 1, "Features");
2030 treeview_insert(&tvfaff, 0, "Window");
2031 treeview_insert(&tvfaff, 1, "Appearance");
2032 treeview_insert(&tvfaff, 1, "Behaviour");
2033 treeview_insert(&tvfaff, 1, "Translation");
2034 treeview_insert(&tvfaff, 1, "Selection");
2035 treeview_insert(&tvfaff, 1, "Colours");
2036 treeview_insert(&tvfaff, 0, "Connection");
2038 treeview_insert(&tvfaff, 1, "Proxy");
2039 treeview_insert(&tvfaff, 1, "Telnet");
2040 treeview_insert(&tvfaff, 1, "Rlogin");
2041 if (backends[3].backend != NULL) {
2042 treeview_insert(&tvfaff, 1, "SSH");
2043 /* XXX long name is ugly */
2044 /* XXX make it closed by default? */
2045 treeview_insert(&tvfaff, 2, "Auth");
2046 treeview_insert(&tvfaff, 2, "Tunnels");
2051 * Put the treeview selection on to the Session panel. This
2052 * should also cause creation of the relevant controls.
2054 TreeView_SelectItem(treeview, hsession);
2057 * Set focus into the first available control.
2061 ctl = GetDlgItem(hwnd, IDC_HOST);
2063 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
2067 SetWindowLong(hwnd, GWL_USERDATA, 1);
2068 sesslist_has_focus = 0;
2072 * Button release should trigger WM_OK if there was a
2073 * previous double click on the session list.
2077 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
2080 if (LOWORD(wParam) == IDCX_TREEVIEW &&
2081 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
2083 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
2088 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
2091 item.pszText = buffer;
2092 item.cchTextMax = sizeof(buffer);
2093 item.mask = TVIF_TEXT;
2094 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
2095 for (j = controlstartvalue; j < controlendvalue; j++) {
2096 HWND item = GetDlgItem(hwnd, j);
2098 DestroyWindow(item);
2100 if (!strcmp(buffer, "Session"))
2101 create_controls(hwnd, dlgtype, sessionpanelstart);
2102 if (!strcmp(buffer, "Logging"))
2103 create_controls(hwnd, dlgtype, loggingpanelstart);
2104 if (!strcmp(buffer, "Keyboard"))
2105 create_controls(hwnd, dlgtype, keyboardpanelstart);
2106 if (!strcmp(buffer, "Terminal"))
2107 create_controls(hwnd, dlgtype, terminalpanelstart);
2108 if (!strcmp(buffer, "Bell"))
2109 create_controls(hwnd, dlgtype, bellpanelstart);
2110 if (!strcmp(buffer, "Features"))
2111 create_controls(hwnd, dlgtype, featurespanelstart);
2112 if (!strcmp(buffer, "Window"))
2113 create_controls(hwnd, dlgtype, windowpanelstart);
2114 if (!strcmp(buffer, "Appearance"))
2115 create_controls(hwnd, dlgtype, appearancepanelstart);
2116 if (!strcmp(buffer, "Behaviour"))
2117 create_controls(hwnd, dlgtype, behaviourpanelstart);
2118 if (!strcmp(buffer, "Tunnels"))
2119 create_controls(hwnd, dlgtype, tunnelspanelstart);
2120 if (!strcmp(buffer, "Connection"))
2121 create_controls(hwnd, dlgtype, connectionpanelstart);
2122 if (!strcmp(buffer, "Proxy"))
2123 create_controls(hwnd, dlgtype, proxypanelstart);
2124 if (!strcmp(buffer, "Telnet"))
2125 create_controls(hwnd, dlgtype, telnetpanelstart);
2126 if (!strcmp(buffer, "Rlogin"))
2127 create_controls(hwnd, dlgtype, rloginpanelstart);
2128 if (!strcmp(buffer, "SSH"))
2129 create_controls(hwnd, dlgtype, sshpanelstart);
2130 if (!strcmp(buffer, "Auth"))
2131 create_controls(hwnd, dlgtype, sshauthpanelstart);
2132 if (!strcmp(buffer, "Selection"))
2133 create_controls(hwnd, dlgtype, selectionpanelstart);
2134 if (!strcmp(buffer, "Colours"))
2135 create_controls(hwnd, dlgtype, colourspanelstart);
2136 if (!strcmp(buffer, "Translation"))
2137 create_controls(hwnd, dlgtype, translationpanelstart);
2139 init_dlg_ctrls(hwnd, FALSE);
2141 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
2142 InvalidateRect (hwnd, NULL, TRUE);
2144 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
2150 * Only process WM_COMMAND once the dialog is fully formed.
2152 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
2153 switch (LOWORD(wParam)) {
2155 /* Behaviour of the "Open" button is different if the
2156 * session list has focus, *unless* the user just
2157 * double-clicked... */
2158 if (sesslist_has_focus && !readytogo) {
2159 if (!load_selected_session(hwnd)) {
2164 /* If at this point we have a valid session, go! */
2166 if (requested_help) {
2167 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2168 requested_help = FALSE;
2175 if (HIWORD(wParam) == BN_CLICKED ||
2176 HIWORD(wParam) == BN_DOUBLECLICKED) {
2178 WinHelp(hwnd, help_path,
2179 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2181 requested_help = TRUE;
2186 if (requested_help) {
2187 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2188 requested_help = FALSE;
2192 case IDC_PROTTELNET:
2193 case IDC_PROTRLOGIN:
2196 if (HIWORD(wParam) == BN_CLICKED ||
2197 HIWORD(wParam) == BN_DOUBLECLICKED) {
2198 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2199 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2200 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2202 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2205 * When switching using the arrow keys, we
2206 * appear to get two of these messages, both
2207 * mentioning the target button in
2208 * LOWORD(wParam), but one of them called while
2209 * the previous button is still checked. This
2210 * causes an unnecessary reset of the port
2211 * number field, which we fix by ensuring here
2212 * that the button selected is indeed the one
2215 if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) &&
2216 ((cfg.protocol == PROT_SSH && cfg.port != 22)
2217 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2218 || (cfg.protocol == PROT_RLOGIN
2219 && cfg.port != 513))) {
2220 cfg.port = i ? 22 : j ? 23 : 513;
2221 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2226 if (HIWORD(wParam) == EN_CHANGE)
2227 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2228 sizeof(cfg.host) - 1);
2231 if (HIWORD(wParam) == EN_CHANGE) {
2232 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2233 if (isdigit(portname[0]))
2234 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2236 service = getservbyname(portname, NULL);
2238 cfg.port = ntohs(service->s_port);
2245 if (HIWORD(wParam) == EN_CHANGE) {
2246 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2248 GetDlgItemText(hwnd, IDC_SESSEDIT,
2249 savedsession, sizeof(savedsession) - 1);
2250 savedsession[sizeof(savedsession) - 1] = '\0';
2254 if (HIWORD(wParam) == BN_CLICKED ||
2255 HIWORD(wParam) == BN_DOUBLECLICKED) {
2260 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2263 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2264 LB_GETCURSEL, 0, 0);
2269 strcpy(str, sessions[n]);
2271 save_settings(str, !!strcmp(str, "Default Settings"),
2273 get_sesslist(FALSE);
2275 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2277 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2279 for (i = 0; i < nsessions; i++)
2280 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2282 (LPARAM) (sessions[i]));
2283 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2285 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2287 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2293 if (LOWORD(wParam) == IDC_SESSLIST) {
2294 if (HIWORD(wParam) == LBN_SETFOCUS)
2295 sesslist_has_focus = 1;
2296 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2297 sesslist_has_focus = 0;
2299 if (LOWORD(wParam) == IDC_SESSLOAD &&
2300 HIWORD(wParam) != BN_CLICKED &&
2301 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2302 if (LOWORD(wParam) == IDC_SESSLIST &&
2303 HIWORD(wParam) != LBN_DBLCLK) break;
2304 /* Load the session selected in SESSLIST. */
2305 if (load_selected_session(hwnd) &&
2306 LOWORD(wParam) == IDC_SESSLIST) {
2308 * A double-click on a saved session should
2309 * actually start the session, not just load it.
2310 * Unless it's Default Settings or some other
2311 * host-less set of saved settings.
2320 if (HIWORD(wParam) == BN_CLICKED ||
2321 HIWORD(wParam) == BN_DOUBLECLICKED) {
2322 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2323 LB_GETCURSEL, 0, 0);
2324 if (n == LB_ERR || n == 0) {
2328 del_settings(sessions[n]);
2329 get_sesslist(FALSE);
2331 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2333 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2335 for (i = 0; i < nsessions; i++)
2336 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2338 (LPARAM) (sessions[i]));
2339 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2341 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2343 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2347 if (HIWORD(wParam) == EN_CHANGE)
2348 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2349 &cfg.ping_interval);
2352 if (HIWORD(wParam) == BN_CLICKED ||
2353 HIWORD(wParam) == BN_DOUBLECLICKED)
2355 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2359 if (HIWORD(wParam) == BN_CLICKED ||
2360 HIWORD(wParam) == BN_DOUBLECLICKED)
2361 cfg.bksp_is_delete =
2362 IsDlgButtonChecked(hwnd, IDC_DEL127);
2366 if (HIWORD(wParam) == BN_CLICKED ||
2367 HIWORD(wParam) == BN_DOUBLECLICKED)
2369 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2375 case IDC_FUNCVT100P:
2377 if (HIWORD(wParam) == BN_CLICKED ||
2378 HIWORD(wParam) == BN_DOUBLECLICKED)
2379 switch (LOWORD(wParam)) {
2392 case IDC_FUNCVT100P:
2402 if (HIWORD(wParam) == BN_CLICKED ||
2403 HIWORD(wParam) == BN_DOUBLECLICKED) {
2405 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2406 cfg.nethack_keypad = FALSE;
2410 if (HIWORD(wParam) == BN_CLICKED ||
2411 HIWORD(wParam) == BN_DOUBLECLICKED) {
2412 cfg.app_keypad = FALSE;
2413 cfg.nethack_keypad = TRUE;
2418 if (HIWORD(wParam) == BN_CLICKED ||
2419 HIWORD(wParam) == BN_DOUBLECLICKED)
2421 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2424 if (HIWORD(wParam) == BN_CLICKED ||
2425 HIWORD(wParam) == BN_DOUBLECLICKED)
2427 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2430 if (HIWORD(wParam) == BN_CLICKED ||
2431 HIWORD(wParam) == BN_DOUBLECLICKED)
2433 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2435 case IDC_NOMOUSEREP:
2436 if (HIWORD(wParam) == BN_CLICKED ||
2437 HIWORD(wParam) == BN_DOUBLECLICKED)
2439 IsDlgButtonChecked(hwnd, IDC_NOMOUSEREP);
2442 if (HIWORD(wParam) == BN_CLICKED ||
2443 HIWORD(wParam) == BN_DOUBLECLICKED)
2444 cfg.no_remote_resize =
2445 IsDlgButtonChecked(hwnd, IDC_NORESIZE);
2447 case IDC_NOALTSCREEN:
2448 if (HIWORD(wParam) == BN_CLICKED ||
2449 HIWORD(wParam) == BN_DOUBLECLICKED)
2451 IsDlgButtonChecked(hwnd, IDC_NOALTSCREEN);
2453 case IDC_NOWINTITLE:
2454 if (HIWORD(wParam) == BN_CLICKED ||
2455 HIWORD(wParam) == BN_DOUBLECLICKED)
2456 cfg.no_remote_wintitle =
2457 IsDlgButtonChecked(hwnd, IDC_NOWINTITLE);
2459 case IDC_NODBACKSPACE:
2460 if (HIWORD(wParam) == BN_CLICKED ||
2461 HIWORD(wParam) == BN_DOUBLECLICKED)
2463 IsDlgButtonChecked(hwnd, IDC_NODBACKSPACE);
2466 if (HIWORD(wParam) == BN_CLICKED ||
2467 HIWORD(wParam) == BN_DOUBLECLICKED)
2468 cfg.no_remote_charset =
2469 IsDlgButtonChecked(hwnd, IDC_NOCHARSET);
2472 if (HIWORD(wParam) == BN_CLICKED ||
2473 HIWORD(wParam) == BN_DOUBLECLICKED)
2474 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2477 if (HIWORD(wParam) == BN_CLICKED ||
2478 HIWORD(wParam) == BN_DOUBLECLICKED)
2480 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2483 if (HIWORD(wParam) == BN_CLICKED ||
2484 HIWORD(wParam) == BN_DOUBLECLICKED)
2486 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2488 case IDC_ECHOBACKEND:
2491 if (HIWORD(wParam) == BN_CLICKED ||
2492 HIWORD(wParam) == BN_DOUBLECLICKED) {
2493 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2494 cfg.localecho = LD_BACKEND;
2495 if (LOWORD(wParam) == IDC_ECHOYES)
2496 cfg.localecho = LD_YES;
2497 if (LOWORD(wParam) == IDC_ECHONO)
2498 cfg.localecho = LD_NO;
2501 case IDC_EDITBACKEND:
2504 if (HIWORD(wParam) == BN_CLICKED ||
2505 HIWORD(wParam) == BN_DOUBLECLICKED) {
2506 if (LOWORD(wParam) == IDC_EDITBACKEND)
2507 cfg.localedit = LD_BACKEND;
2508 if (LOWORD(wParam) == IDC_EDITYES)
2509 cfg.localedit = LD_YES;
2510 if (LOWORD(wParam) == IDC_EDITNO)
2511 cfg.localedit = LD_NO;
2514 case IDC_ANSWEREDIT:
2515 if (HIWORD(wParam) == EN_CHANGE)
2516 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2517 sizeof(cfg.answerback) - 1);
2519 case IDC_ALWAYSONTOP:
2520 if (HIWORD(wParam) == BN_CLICKED ||
2521 HIWORD(wParam) == BN_DOUBLECLICKED)
2523 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2525 case IDC_FULLSCREENONALTENTER:
2526 if (HIWORD(wParam) == BN_CLICKED ||
2527 HIWORD(wParam) == BN_DOUBLECLICKED)
2528 cfg.fullscreenonaltenter =
2529 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2532 if (HIWORD(wParam) == BN_CLICKED ||
2533 HIWORD(wParam) == BN_DOUBLECLICKED)
2535 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2537 case IDC_SCROLLDISP:
2538 if (HIWORD(wParam) == BN_CLICKED ||
2539 HIWORD(wParam) == BN_DOUBLECLICKED)
2540 cfg.scroll_on_disp =
2541 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2543 case IDC_COMPOSEKEY:
2544 if (HIWORD(wParam) == BN_CLICKED ||
2545 HIWORD(wParam) == BN_DOUBLECLICKED)
2547 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2549 case IDC_CTRLALTKEYS:
2550 if (HIWORD(wParam) == BN_CLICKED ||
2551 HIWORD(wParam) == BN_DOUBLECLICKED)
2553 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2556 if (HIWORD(wParam) == BN_CLICKED ||
2557 HIWORD(wParam) == BN_DOUBLECLICKED)
2558 cfg.telnet_keyboard =
2559 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2562 if (HIWORD(wParam) == BN_CLICKED ||
2563 HIWORD(wParam) == BN_DOUBLECLICKED)
2564 cfg.telnet_newline =
2565 IsDlgButtonChecked(hwnd, IDC_TELNETRET);
2568 if (HIWORD(wParam) == BN_CLICKED ||
2569 HIWORD(wParam) == BN_DOUBLECLICKED)
2571 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2574 if (HIWORD(wParam) == BN_CLICKED ||
2575 HIWORD(wParam) == BN_DOUBLECLICKED)
2576 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2579 if (HIWORD(wParam) == BN_CLICKED ||
2580 HIWORD(wParam) == BN_DOUBLECLICKED)
2582 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2585 if (HIWORD(wParam) == EN_CHANGE)
2586 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2589 if (HIWORD(wParam) == EN_CHANGE)
2590 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2593 if (HIWORD(wParam) == EN_CHANGE)
2594 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2596 case IDC_CHOOSEFONT:
2599 lf.lfHeight = -MulDiv(cfg.fontheight,
2600 GetDeviceCaps(hdc, LOGPIXELSY),
2604 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2605 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2606 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2607 lf.lfCharSet = cfg.fontcharset;
2608 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2609 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2610 lf.lfQuality = DEFAULT_QUALITY;
2611 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2612 strncpy(lf.lfFaceName, cfg.font,
2613 sizeof(lf.lfFaceName) - 1);
2614 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2616 cf.lStructSize = sizeof(cf);
2617 cf.hwndOwner = hwnd;
2619 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2620 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2622 if (ChooseFont(&cf)) {
2623 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2624 cfg.font[sizeof(cfg.font) - 1] = '\0';
2625 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2626 cfg.fontcharset = lf.lfCharSet;
2627 cfg.fontheight = cf.iPointSize / 10;
2628 fmtfont(fontstatic);
2629 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2632 case IDC_BELL_DISABLED:
2633 case IDC_BELL_DEFAULT:
2634 case IDC_BELL_WAVEFILE:
2635 case IDC_BELL_VISUAL:
2636 if (HIWORD(wParam) == BN_CLICKED ||
2637 HIWORD(wParam) == BN_DOUBLECLICKED) {
2638 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2639 cfg.beep = BELL_DISABLED;
2640 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2641 cfg.beep = BELL_DEFAULT;
2642 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2643 cfg.beep = BELL_WAVEFILE;
2644 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2645 cfg.beep = BELL_VISUAL;
2648 case IDC_B_IND_DISABLED:
2649 case IDC_B_IND_FLASH:
2650 case IDC_B_IND_STEADY:
2651 if (HIWORD(wParam) == BN_CLICKED ||
2652 HIWORD(wParam) == BN_DOUBLECLICKED) {
2653 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2654 cfg.beep_ind = B_IND_DISABLED;
2655 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2656 cfg.beep_ind = B_IND_FLASH;
2657 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2658 cfg.beep_ind = B_IND_STEADY;
2661 case IDC_BELL_WAVEBROWSE:
2662 memset(&of, 0, sizeof(of));
2663 #ifdef OPENFILENAME_SIZE_VERSION_400
2664 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2666 of.lStructSize = sizeof(of);
2668 of.hwndOwner = hwnd;
2669 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2670 of.lpstrCustomFilter = NULL;
2671 of.nFilterIndex = 1;
2672 of.lpstrFile = filename;
2673 strcpy(filename, cfg.bell_wavefile);
2674 of.nMaxFile = sizeof(filename);
2675 of.lpstrFileTitle = NULL;
2676 of.lpstrInitialDir = NULL;
2677 of.lpstrTitle = "Select Bell Sound File";
2679 if (GetOpenFileName(&of)) {
2680 strcpy(cfg.bell_wavefile, filename);
2681 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2685 case IDC_BELL_WAVEEDIT:
2686 if (HIWORD(wParam) == EN_CHANGE)
2687 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2689 sizeof(cfg.bell_wavefile) - 1);
2692 if (HIWORD(wParam) == BN_CLICKED ||
2693 HIWORD(wParam) == BN_DOUBLECLICKED)
2695 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2698 if (HIWORD(wParam) == EN_CHANGE)
2699 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2702 if (HIWORD(wParam) == EN_CHANGE)
2703 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2707 if (HIWORD(wParam) == EN_CHANGE)
2708 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2712 if (HIWORD(wParam) == BN_CLICKED ||
2713 HIWORD(wParam) == BN_DOUBLECLICKED)
2715 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2718 if (HIWORD(wParam) == BN_CLICKED ||
2719 HIWORD(wParam) == BN_DOUBLECLICKED)
2720 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2723 if (HIWORD(wParam) == BN_CLICKED ||
2724 HIWORD(wParam) == BN_DOUBLECLICKED)
2725 cfg.win_name_always =
2726 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2729 if (HIWORD(wParam) == BN_CLICKED ||
2730 HIWORD(wParam) == BN_DOUBLECLICKED)
2732 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2734 case IDC_SUNKENEDGE:
2735 if (HIWORD(wParam) == BN_CLICKED ||
2736 HIWORD(wParam) == BN_DOUBLECLICKED)
2738 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2741 if (HIWORD(wParam) == EN_CHANGE)
2742 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2743 &cfg.window_border);
2744 if (cfg.window_border > 32)
2745 cfg.window_border = 32;
2748 if (HIWORD(wParam) == BN_CLICKED ||
2749 HIWORD(wParam) == BN_DOUBLECLICKED)
2750 cfg.cursor_type = 0;
2753 if (HIWORD(wParam) == BN_CLICKED ||
2754 HIWORD(wParam) == BN_DOUBLECLICKED)
2755 cfg.cursor_type = 1;
2758 if (HIWORD(wParam) == BN_CLICKED ||
2759 HIWORD(wParam) == BN_DOUBLECLICKED)
2760 cfg.cursor_type = 2;
2763 if (HIWORD(wParam) == BN_CLICKED ||
2764 HIWORD(wParam) == BN_DOUBLECLICKED)
2766 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2769 if (HIWORD(wParam) == BN_CLICKED ||
2770 HIWORD(wParam) == BN_DOUBLECLICKED)
2772 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2774 case IDC_SCROLLBARFULLSCREEN:
2775 if (HIWORD(wParam) == BN_CLICKED ||
2776 HIWORD(wParam) == BN_DOUBLECLICKED)
2777 cfg.scrollbar_in_fullscreen =
2778 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2780 case IDC_RESIZETERM:
2781 case IDC_RESIZEFONT:
2782 case IDC_RESIZENONE:
2783 case IDC_RESIZEEITHER:
2784 if (HIWORD(wParam) == BN_CLICKED ||
2785 HIWORD(wParam) == BN_DOUBLECLICKED) {
2787 IsDlgButtonChecked(hwnd,
2788 IDC_RESIZETERM) ? RESIZE_TERM :
2789 IsDlgButtonChecked(hwnd,
2790 IDC_RESIZEFONT) ? RESIZE_FONT :
2791 IsDlgButtonChecked(hwnd,
2792 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2797 if (HIWORD(wParam) == EN_CHANGE)
2798 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2799 sizeof(cfg.wintitle) - 1);
2804 if (HIWORD(wParam) == BN_CLICKED ||
2805 HIWORD(wParam) == BN_DOUBLECLICKED) {
2807 IsDlgButtonChecked(hwnd,
2808 IDC_COEALWAYS) ? COE_ALWAYS :
2809 IsDlgButtonChecked(hwnd,
2810 IDC_COENEVER) ? COE_NEVER :
2815 if (HIWORD(wParam) == BN_CLICKED ||
2816 HIWORD(wParam) == BN_DOUBLECLICKED)
2818 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2821 if (HIWORD(wParam) == EN_CHANGE)
2822 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2823 sizeof(cfg.termtype) - 1);
2827 case IDC_PROXYHOSTEDIT:
2828 if (HIWORD(wParam) == EN_CHANGE)
2829 GetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host,
2830 sizeof(cfg.proxy_host) - 1);
2832 case IDC_PROXYPORTEDIT:
2833 if (HIWORD(wParam) == EN_CHANGE) {
2834 GetDlgItemText(hwnd, IDC_PROXYPORTEDIT, portname, 31);
2835 if (isdigit(portname[0]))
2836 MyGetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, &cfg.proxy_port);
2838 service = getservbyname(portname, NULL);
2840 cfg.proxy_port = ntohs(service->s_port);
2846 case IDC_PROXYEXCLUDEEDIT:
2847 if (HIWORD(wParam) == EN_CHANGE)
2848 GetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT,
2849 cfg.proxy_exclude_list,
2850 sizeof(cfg.proxy_exclude_list) - 1);
2852 case IDC_PROXYUSEREDIT:
2853 if (HIWORD(wParam) == EN_CHANGE)
2854 GetDlgItemText(hwnd, IDC_PROXYUSEREDIT,
2856 sizeof(cfg.proxy_username) - 1);
2858 case IDC_PROXYPASSEDIT:
2859 if (HIWORD(wParam) == EN_CHANGE)
2860 GetDlgItemText(hwnd, IDC_PROXYPASSEDIT,
2862 sizeof(cfg.proxy_password) - 1);
2864 case IDC_PROXYTELNETCMDEDIT:
2865 if (HIWORD(wParam) == EN_CHANGE)
2866 GetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT,
2867 cfg.proxy_telnet_command,
2868 sizeof(cfg.proxy_telnet_command) - 1);
2870 case IDC_PROXYSOCKSVER5:
2871 case IDC_PROXYSOCKSVER4:
2872 if (HIWORD(wParam) == BN_CLICKED ||
2873 HIWORD(wParam) == BN_DOUBLECLICKED) {
2874 cfg.proxy_socks_version =
2875 IsDlgButtonChecked(hwnd, IDC_PROXYSOCKSVER4) ? 4 : 5;
2878 case IDC_PROXYTYPENONE:
2879 case IDC_PROXYTYPEHTTP:
2880 case IDC_PROXYTYPESOCKS:
2881 case IDC_PROXYTYPETELNET:
2882 if (HIWORD(wParam) == BN_CLICKED ||
2883 HIWORD(wParam) == BN_DOUBLECLICKED) {
2885 IsDlgButtonChecked(hwnd, IDC_PROXYTYPEHTTP) ? PROXY_HTTP :
2886 IsDlgButtonChecked(hwnd, IDC_PROXYTYPESOCKS) ? PROXY_SOCKS :
2887 IsDlgButtonChecked(hwnd, IDC_PROXYTYPETELNET) ? PROXY_TELNET :
2893 if (HIWORD(wParam) == EN_CHANGE)
2894 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
2895 sizeof(cfg.logfilename) - 1);
2898 memset(&of, 0, sizeof(of));
2899 #ifdef OPENFILENAME_SIZE_VERSION_400
2900 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2902 of.lStructSize = sizeof(of);
2904 of.hwndOwner = hwnd;
2905 of.lpstrFilter = "All Files\0*\0\0\0";
2906 of.lpstrCustomFilter = NULL;
2907 of.nFilterIndex = 1;
2908 of.lpstrFile = filename;
2909 strcpy(filename, cfg.logfilename);
2910 of.nMaxFile = sizeof(filename);
2911 of.lpstrFileTitle = NULL;
2912 of.lpstrInitialDir = NULL;
2913 of.lpstrTitle = "Select session log file";
2915 if (GetSaveFileName(&of)) {
2916 strcpy(cfg.logfilename, filename);
2917 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
2921 case IDC_LSTATASCII:
2923 case IDC_LSTATPACKET:
2924 if (HIWORD(wParam) == BN_CLICKED ||
2925 HIWORD(wParam) == BN_DOUBLECLICKED) {
2926 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
2927 cfg.logtype = LGTYP_NONE;
2928 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
2929 cfg.logtype = LGTYP_ASCII;
2930 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
2931 cfg.logtype = LGTYP_DEBUG;
2932 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
2933 cfg.logtype = LGTYP_PACKETS;
2939 if (HIWORD(wParam) == BN_CLICKED ||
2940 HIWORD(wParam) == BN_DOUBLECLICKED) {
2941 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
2942 cfg.logxfovr = LGXF_ASK;
2943 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
2944 cfg.logxfovr = LGXF_APN;
2945 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
2946 cfg.logxfovr = LGXF_OVR;
2951 if (HIWORD(wParam) == EN_CHANGE)
2952 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
2953 sizeof(cfg.termspeed) - 1);
2956 if (HIWORD(wParam) == EN_CHANGE)
2957 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
2958 sizeof(cfg.username) - 1);
2960 case IDC_RLLUSEREDIT:
2961 if (HIWORD(wParam) == EN_CHANGE)
2962 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
2964 sizeof(cfg.localusername) - 1);
2968 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
2972 cfg.passive_telnet =
2973 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
2976 if (HIWORD(wParam) == BN_CLICKED ||
2977 HIWORD(wParam) == BN_DOUBLECLICKED) {
2978 char str[sizeof(cfg.environmt)];
2980 GetDlgItemText(hwnd, IDC_VAREDIT, str,
2986 p = str + strlen(str);
2988 GetDlgItemText(hwnd, IDC_VALEDIT, p,
2989 sizeof(str) - 1 - (p - str));
3000 if ((p - cfg.environmt) + strlen(str) + 2 <
3001 sizeof(cfg.environmt)) {
3003 p[strlen(str) + 1] = '\0';
3004 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
3006 SetDlgItemText(hwnd, IDC_VAREDIT, "");
3007 SetDlgItemText(hwnd, IDC_VALEDIT, "");
3009 MessageBox(hwnd, "Environment too big",
3010 "PuTTY Error", MB_OK | MB_ICONERROR);
3015 if (HIWORD(wParam) != BN_CLICKED &&
3016 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3018 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
3025 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
3052 if (HIWORD(wParam) == BN_CLICKED ||
3053 HIWORD(wParam) == BN_DOUBLECLICKED)
3054 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
3057 if (HIWORD(wParam) == BN_CLICKED ||
3058 HIWORD(wParam) == BN_DOUBLECLICKED)
3060 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
3063 if (HIWORD(wParam) == BN_CLICKED ||
3064 HIWORD(wParam) == BN_DOUBLECLICKED)
3066 IsDlgButtonChecked(hwnd, IDC_BUGGYMAC);
3069 if (HIWORD(wParam) == BN_CLICKED ||
3070 HIWORD(wParam) == BN_DOUBLECLICKED)
3072 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
3075 if (HIWORD(wParam) == BN_CLICKED ||
3076 HIWORD(wParam) == BN_DOUBLECLICKED)
3078 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
3080 case IDC_CHANGEUSER:
3081 if (HIWORD(wParam) == BN_CLICKED ||
3082 HIWORD(wParam) == BN_DOUBLECLICKED)
3083 cfg.change_username =
3084 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
3086 case IDC_CIPHERLIST:
3089 handle_prefslist(&cipherlist,
3090 cfg.ssh_cipherlist, CIPHER_MAX,
3091 0, hwnd, wParam, lParam);
3095 case IDC_SSHPROT2ONLY:
3096 if (HIWORD(wParam) == BN_CLICKED ||
3097 HIWORD(wParam) == BN_DOUBLECLICKED) {
3098 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
3100 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
3102 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2ONLY))
3107 if (HIWORD(wParam) == BN_CLICKED ||
3108 HIWORD(wParam) == BN_DOUBLECLICKED)
3110 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
3113 if (HIWORD(wParam) == BN_CLICKED ||
3114 HIWORD(wParam) == BN_DOUBLECLICKED)
3116 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
3119 if (HIWORD(wParam) == EN_CHANGE)
3120 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
3121 sizeof(cfg.keyfile) - 1);
3124 if (HIWORD(wParam) == EN_CHANGE)
3125 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
3126 sizeof(cfg.remote_cmd) - 1);
3129 memset(&of, 0, sizeof(of));
3130 #ifdef OPENFILENAME_SIZE_VERSION_400
3131 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3133 of.lStructSize = sizeof(of);
3135 of.hwndOwner = hwnd;
3136 of.lpstrFilter = "PuTTY Private Key Files\0*.PPK\0"
3137 "AllFiles\0*\0\0\0";
3138 of.lpstrCustomFilter = NULL;
3139 of.nFilterIndex = 1;
3140 of.lpstrFile = filename;
3141 strcpy(filename, cfg.keyfile);
3142 of.nMaxFile = sizeof(filename);
3143 of.lpstrFileTitle = NULL;
3144 of.lpstrInitialDir = NULL;
3145 of.lpstrTitle = "Select Private Key File";
3147 if (GetOpenFileName(&of)) {
3148 strcpy(cfg.keyfile, filename);
3149 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
3153 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
3156 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
3160 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
3162 case IDC_SELTYPELEX:
3163 case IDC_SELTYPERECT:
3164 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
3166 case IDC_MOUSEOVERRIDE:
3167 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
3173 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
3178 for (i = 0; i < 128; i++)
3179 if (SendDlgItemMessage
3180 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
3182 cfg.wordness[i] = n;
3183 SendDlgItemMessage(hwnd, IDC_CCLIST,
3184 LB_DELETESTRING, i, 0);
3185 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
3186 (i >= 0x21 && i != 0x7F) ? i : ' ',
3188 SendDlgItemMessage(hwnd, IDC_CCLIST,
3195 case IDC_BOLDCOLOUR:
3196 if (HIWORD(wParam) == BN_CLICKED ||
3197 HIWORD(wParam) == BN_DOUBLECLICKED) {
3200 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
3201 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3204 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3206 if (n != 12 + 10 * cfg.bold_colour) {
3207 for (i = n; i-- > 0;)
3208 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3209 LB_DELETESTRING, i, 0);
3210 for (i = 0; i < 22; i++)
3211 if (cfg.bold_colour || permcolour[i])
3212 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3214 (LPARAM) colours[i]);
3216 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3218 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
3223 if (HIWORD(wParam) == BN_CLICKED ||
3224 HIWORD(wParam) == BN_DOUBLECLICKED)
3226 IsDlgButtonChecked(hwnd, IDC_PALETTE);
3228 case IDC_COLOURLIST:
3229 if (HIWORD(wParam) == LBN_DBLCLK ||
3230 HIWORD(wParam) == LBN_SELCHANGE) {
3232 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3235 if (!cfg.bold_colour)
3236 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3237 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3239 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3241 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3246 if (HIWORD(wParam) == BN_CLICKED ||
3247 HIWORD(wParam) == BN_DOUBLECLICKED) {
3248 static CHOOSECOLOR cc;
3249 static DWORD custom[16] = { 0 }; /* zero initialisers */
3251 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3254 if (!cfg.bold_colour)
3255 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3256 cc.lStructSize = sizeof(cc);
3257 cc.hwndOwner = hwnd;
3258 cc.hInstance = (HWND) hinst;
3259 cc.lpCustColors = custom;
3261 RGB(cfg.colours[i][0], cfg.colours[i][1],
3263 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
3264 if (ChooseColor(&cc)) {
3266 (unsigned char) (cc.rgbResult & 0xFF);
3268 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
3270 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
3271 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3273 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3275 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3281 if (HIWORD(wParam) == CBN_SELCHANGE) {
3282 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
3283 CB_GETCURSEL, 0, 0);
3284 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
3285 index, (LPARAM)cfg.line_codepage);
3286 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3287 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
3288 sizeof(cfg.line_codepage) - 1);
3289 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
3290 strcpy(cfg.line_codepage,
3291 cp_name(decode_codepage(cfg.line_codepage)));
3292 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
3296 if (HIWORD(wParam) == CBN_SELCHANGE) {
3297 int index = SendDlgItemMessage(hwnd, IDC_PRINTER,
3298 CB_GETCURSEL, 0, 0);
3299 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_GETLBTEXT,
3300 index, (LPARAM)cfg.printer);
3301 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3302 GetDlgItemText(hwnd, IDC_PRINTER, cfg.printer,
3303 sizeof(cfg.printer) - 1);
3305 if (!strcmp(cfg.printer, PRINTER_DISABLED_STRING))
3306 *cfg.printer = '\0';
3308 case IDC_CAPSLOCKCYR:
3309 if (HIWORD(wParam) == BN_CLICKED ||
3310 HIWORD(wParam) == BN_DOUBLECLICKED) {
3311 cfg.xlat_capslockcyr =
3312 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3315 case IDC_VTXWINDOWS:
3321 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3322 : IsDlgButtonChecked(hwnd,
3323 IDC_VTOEMANSI) ? VT_OEMANSI :
3324 IsDlgButtonChecked(hwnd,
3325 IDC_VTOEMONLY) ? VT_OEMONLY :
3326 IsDlgButtonChecked(hwnd,
3327 IDC_VTUNICODE) ? VT_UNICODE :
3330 case IDC_X11_FORWARD:
3331 if (HIWORD(wParam) == BN_CLICKED ||
3332 HIWORD(wParam) == BN_DOUBLECLICKED)
3334 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3337 if (HIWORD(wParam) == BN_CLICKED ||
3338 HIWORD(wParam) == BN_DOUBLECLICKED)
3339 cfg.lport_acceptall =
3340 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3343 if (HIWORD(wParam) == BN_CLICKED ||
3344 HIWORD(wParam) == BN_DOUBLECLICKED)
3345 cfg.rport_acceptall =
3346 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3348 case IDC_X11_DISPLAY:
3349 if (HIWORD(wParam) == EN_CHANGE)
3350 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3351 sizeof(cfg.x11_display) - 1);
3354 if (HIWORD(wParam) == BN_CLICKED ||
3355 HIWORD(wParam) == BN_DOUBLECLICKED) {
3356 char str[sizeof(cfg.portfwd)];
3358 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3362 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3366 "You need to specify a source port number",
3367 "PuTTY Error", MB_OK | MB_ICONERROR);
3370 p = str + strlen(str);
3372 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3373 sizeof(str) - 1 - (p - str));
3374 if (!*p || !strchr(p, ':')) {
3376 "You need to specify a destination address\n"
3377 "in the form \"host.name:port\"",
3378 "PuTTY Error", MB_OK | MB_ICONERROR);
3387 if ((p - cfg.portfwd) + strlen(str) + 2 <
3388 sizeof(cfg.portfwd)) {
3390 p[strlen(str) + 1] = '\0';
3391 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3393 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3394 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3396 MessageBox(hwnd, "Too many forwardings",
3397 "PuTTY Error", MB_OK | MB_ICONERROR);
3401 case IDC_PFWDREMOVE:
3402 if (HIWORD(wParam) != BN_CLICKED &&
3403 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3404 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3405 LB_GETCURSEL, 0, 0);
3411 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3441 int id = ((LPHELPINFO)lParam)->iCtrlId;
3442 char *cmd = help_context_cmd(id);
3444 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3445 requested_help = TRUE;
3452 if (requested_help) {
3453 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3454 requested_help = FALSE;
3459 /* Grrr Explorer will maximize Dialogs! */
3461 if (wParam == SIZE_MAXIMIZED)
3467 * Handle application-defined messages eg. DragListBox
3469 /* First find out what the number is (once). */
3470 if (draglistmsg == WM_NULL)
3471 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3473 if (msg == draglistmsg) {
3474 /* Only process once dialog is fully formed. */
3475 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3476 case IDC_CIPHERLIST:
3477 return handle_prefslist(&cipherlist,
3478 cfg.ssh_cipherlist, CIPHER_MAX,
3479 1, hwnd, wParam, lParam);
3488 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3489 WPARAM wParam, LPARAM lParam)
3491 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3493 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3494 EnableWindow(hwnd, 0);
3495 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3496 EnableWindow(hwnd, 1);
3497 SetActiveWindow(hwnd);
3499 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3502 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3503 WPARAM wParam, LPARAM lParam)
3505 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3508 void defuse_showwindow(void)
3511 * Work around the fact that the app's first call to ShowWindow
3512 * will ignore the default in favour of the shell-provided
3517 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3519 ShowWindow(hwnd, SW_HIDE);
3520 SetActiveWindow(hwnd);
3521 DestroyWindow(hwnd);
3530 savedsession[0] = '\0';
3532 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3533 get_sesslist(FALSE);
3538 int do_reconfig(HWND hwnd)
3543 backup_cfg = cfg; /* structure copy */
3545 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3547 cfg = backup_cfg; /* structure copy */
3552 void logevent(char *string)
3557 if (nevents >= negsize) {
3559 events = srealloc(events, negsize * sizeof(*events));
3563 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3566 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3567 strcpy(events[nevents], timebuf);
3568 strcat(events[nevents], string);
3571 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3572 0, (LPARAM) events[nevents]);
3573 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3574 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3579 void showeventlog(HWND hwnd)
3582 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3584 ShowWindow(logbox, SW_SHOWNORMAL);
3586 SetActiveWindow(logbox);
3589 void showabout(HWND hwnd)
3591 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3594 void verify_ssh_host_key(char *host, int port, char *keytype,
3595 char *keystr, char *fingerprint)
3599 static const char absentmsg[] =
3600 "The server's host key is not cached in the registry. You\n"
3601 "have no guarantee that the server is the computer you\n"
3603 "The server's key fingerprint is:\n"
3605 "If you trust this host, hit Yes to add the key to\n"
3606 "PuTTY's cache and carry on connecting.\n"
3607 "If you want to carry on connecting just once, without\n"
3608 "adding the key to the cache, hit No.\n"
3609 "If you do not trust this host, hit Cancel to abandon the\n"
3612 static const char wrongmsg[] =
3613 "WARNING - POTENTIAL SECURITY BREACH!\n"
3615 "The server's host key does not match the one PuTTY has\n"
3616 "cached in the registry. This means that either the\n"
3617 "server administrator has changed the host key, or you\n"
3618 "have actually connected to another computer pretending\n"
3619 "to be the server.\n"
3620 "The new key fingerprint is:\n"
3622 "If you were expecting this change and trust the new key,\n"
3623 "hit Yes to update PuTTY's cache and continue connecting.\n"
3624 "If you want to carry on connecting but without updating\n"
3625 "the cache, hit No.\n"
3626 "If you want to abandon the connection completely, hit\n"
3627 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3629 static const char mbtitle[] = "PuTTY Security Alert";
3632 /* sensible fingerprint max size */
3633 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3634 sizeof(absentmsg) : sizeof(wrongmsg))];
3637 * Verify the key against the registry.
3639 ret = verify_host_key(host, port, keytype, keystr);
3641 if (ret == 0) /* success - key matched OK */
3643 if (ret == 2) { /* key was different */
3645 sprintf(message, wrongmsg, fingerprint);
3646 mbret = MessageBox(NULL, message, mbtitle,
3647 MB_ICONWARNING | MB_YESNOCANCEL);
3649 store_host_key(host, port, keytype, keystr);
3650 if (mbret == IDCANCEL)
3653 if (ret == 1) { /* key was absent */
3655 sprintf(message, absentmsg, fingerprint);
3656 mbret = MessageBox(NULL, message, mbtitle,
3657 MB_ICONWARNING | MB_YESNOCANCEL);
3659 store_host_key(host, port, keytype, keystr);
3660 if (mbret == IDCANCEL)
3666 * Ask whether the selected cipher is acceptable (since it was
3667 * below the configured 'warn' threshold).
3668 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3670 void askcipher(char *ciphername, int cs)
3672 static const char mbtitle[] = "PuTTY Security Alert";
3673 static const char msg[] =
3674 "The first %.35scipher supported by the server\n"
3675 "is %.64s, which is below the configured\n"
3676 "warning threshold.\n"
3677 "Do you want to continue with this connection?\n";
3678 /* guessed cipher name + type max length */
3679 char message[100 + sizeof(msg)];
3682 sprintf(message, msg,
3684 (cs == 1) ? "client-to-server " :
3685 "server-to-client ",
3687 mbret = MessageBox(NULL, message, mbtitle,
3688 MB_ICONWARNING | MB_YESNO);
3696 * Ask whether to wipe a session log file before writing to it.
3697 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3699 int askappend(char *filename)
3701 static const char mbtitle[] = "PuTTY Log to File";
3702 static const char msgtemplate[] =
3703 "The session log file \"%.*s\" already exists.\n"
3704 "You can overwrite it with a new session log,\n"
3705 "append your session log to the end of it,\n"
3706 "or disable session logging for this session.\n"
3707 "Hit Yes to wipe the file, No to append to it,\n"
3708 "or Cancel to disable logging.";
3709 char message[sizeof(msgtemplate) + FILENAME_MAX];
3711 if (cfg.logxfovr != LGXF_ASK) {
3712 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
3714 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3716 mbret = MessageBox(NULL, message, mbtitle,
3717 MB_ICONQUESTION | MB_YESNOCANCEL);
3720 else if (mbret == IDNO)
3727 * Warn about the obsolescent key file format.
3729 void old_keyfile_warning(void)
3731 static const char mbtitle[] = "PuTTY Key File Warning";
3732 static const char message[] =
3733 "You are loading an SSH 2 private key which has an\n"
3734 "old version of the file format. This means your key\n"
3735 "file is not fully tamperproof. Future versions of\n"
3736 "PuTTY may stop supporting this private key format,\n"
3737 "so we recommend you convert your key to the new\n"
3740 "You can perform this conversion by loading the key\n"
3741 "into PuTTYgen and then saving it again.";
3743 MessageBox(NULL, message, mbtitle, MB_OK);