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,
573 translationpanelstart,
574 IDC_TITLE_TRANSLATION,
575 IDC_BOX_TRANSLATION1,
576 IDC_BOX_TRANSLATION2,
577 IDC_BOX_TRANSLATION3,
615 static const char *const colours[] = {
616 "Default Foreground", "Default Bold Foreground",
617 "Default Background", "Default Bold Background",
618 "Cursor Text", "Cursor Colour",
619 "ANSI Black", "ANSI Black Bold",
620 "ANSI Red", "ANSI Red Bold",
621 "ANSI Green", "ANSI Green Bold",
622 "ANSI Yellow", "ANSI Yellow Bold",
623 "ANSI Blue", "ANSI Blue Bold",
624 "ANSI Magenta", "ANSI Magenta Bold",
625 "ANSI Cyan", "ANSI Cyan Bold",
626 "ANSI White", "ANSI White Bold"
628 static const int permcolour[] = {
629 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
630 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
631 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
634 static void fmtfont(char *buf)
636 sprintf(buf, "Font: %s, ", cfg.font);
638 strcat(buf, "bold, ");
639 if (cfg.fontheight == 0)
640 strcat(buf, "default height");
642 sprintf(buf + strlen(buf), "%d-point",
643 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
646 char *help_context_cmd(int id)
658 return "JI(`',`session.hostname')";
665 return "JI(`',`session.saved')";
670 return "JI(`',`session.coe')";
671 case IDC_LSTATSTATIC:
675 case IDC_LSTATPACKET:
676 return "JI(`',`logging.main')";
681 return "JI(`',`logging.filename')";
686 return "JI(`',`logging.exists')";
691 return "JI(`',`keyboard.backspace')";
695 return "JI(`',`keyboard.homeend')";
703 return "JI(`',`keyboard.funkeys')";
707 return "JI(`',`keyboard.appkeypad')";
711 return "JI(`',`keyboard.appcursor')";
713 return "JI(`',`keyboard.nethack')";
715 return "JI(`',`keyboard.compose')";
716 case IDC_CTRLALTKEYS:
717 return "JI(`',`keyboard.ctrlalt')";
721 return "JI(`',`features.application')";
723 return "JI(`',`features.mouse')";
725 return "JI(`',`features.resize')";
726 case IDC_NOALTSCREEN:
727 return "JI(`',`features.altscreen')";
729 return "JI(`',`features.retitle')";
730 case IDC_NODBACKSPACE:
731 return "JI(`',`features.dbackspace')";
733 return "JI(`',`features.charset')";
736 return "JI(`',`terminal.autowrap')";
738 return "JI(`',`terminal.decom')";
740 return "JI(`',`terminal.lfhascr')";
742 return "JI(`',`terminal.bce')";
744 return "JI(`',`terminal.blink')";
747 return "JI(`',`terminal.answerback')";
749 case IDC_ECHOBACKEND:
752 return "JI(`',`terminal.localecho')";
754 case IDC_EDITBACKEND:
757 return "JI(`',`terminal.localedit')";
758 case IDC_PRINTERSTATIC:
760 return "JI(`',`terminal.printing')";
763 case IDC_BELL_DISABLED:
764 case IDC_BELL_DEFAULT:
765 case IDC_BELL_WAVEFILE:
766 case IDC_BELL_VISUAL:
767 case IDC_BELL_WAVESTATIC:
768 case IDC_BELL_WAVEEDIT:
769 case IDC_BELL_WAVEBROWSE:
770 return "JI(`',`bell.style')";
771 case IDC_B_IND_STATIC:
772 case IDC_B_IND_DISABLED:
773 case IDC_B_IND_FLASH:
774 case IDC_B_IND_STEADY:
775 return "JI(`',`bell.taskbar')";
777 case IDC_BELLOVLNSTATIC:
779 case IDC_BELLOVLTSTATIC:
781 case IDC_BELLOVLEXPLAIN:
782 case IDC_BELLOVLSSTATIC:
784 return "JI(`',`bell.overload')";
790 return "JI(`',`window.size')";
791 case IDC_RESIZESTATIC:
795 case IDC_RESIZEEITHER:
796 return "JI(`',`window.resize')";
798 case IDC_SCROLLBARFULLSCREEN:
803 return "JI(`',`window.scrollback')";
806 return "JI(`',`behaviour.closewarn')";
808 return "JI(`',`behaviour.altf4')";
810 return "JI(`',`behaviour.altspace')";
812 return "JI(`',`behaviour.altonly')";
813 case IDC_ALWAYSONTOP:
814 return "JI(`',`behaviour.alwaysontop')";
815 case IDC_FULLSCREENONALTENTER:
816 return "JI(`',`behaviour.altenter')";
818 case IDC_CURSORSTATIC:
823 return "JI(`',`appearance.cursor')";
826 return "JI(`',`appearance.font')";
830 return "JI(`',`appearance.title')";
832 return "JI(`',`appearance.hidemouse')";
836 return "JI(`',`appearance.border')";
840 return "JI(`',`connection.termtype')";
843 return "JI(`',`connection.username')";
846 return "JI(`',`connection.keepalive')";
848 return "JI(`',`connection.nodelay')";
852 return "JI(`',`telnet.termspeed')";
861 return "JI(`',`telnet.environ')";
865 return "JI(`',`telnet.oldenviron')";
869 return "JI(`',`telnet.passive')";
871 return "JI(`',`telnet.specialkeys')";
873 return "JI(`',`telnet.newline')";
877 return "JI(`',`rlogin.termspeed')";
878 case IDC_RLLUSERSTATIC:
879 case IDC_RLLUSEREDIT:
880 return "JI(`',`rlogin.localuser')";
883 return "JI(`',`ssh.nopty')";
884 case IDC_CIPHERSTATIC2:
889 return "JI(`',`ssh.ciphers')";
891 return "JI(`',`ssh.buggymac')";
892 case IDC_SSHPROTSTATIC:
895 return "JI(`',`ssh.protocol')";
898 return "JI(`',`ssh.command')";
900 return "JI(`',`ssh.compress')";
905 return "JI(`',`ssh.auth.privkey')";
907 return "JI(`',`ssh.auth.agentfwd')";
909 return "JI(`',`ssh.auth.changeuser')";
911 return "JI(`',`ssh.auth.tis')";
913 return "JI(`',`ssh.auth.ki')";
918 return "JI(`',`selection.buttons')";
919 case IDC_MOUSEOVERRIDE:
920 return "JI(`',`selection.shiftdrag')";
921 case IDC_SELTYPESTATIC:
923 case IDC_SELTYPERECT:
924 return "JI(`',`selection.rect')";
930 return "JI(`',`selection.charclasses')";
932 return "JI(`',`selection.linedraw')";
934 return "JI(`',`selection.rtf')";
937 return "JI(`',`colours.bold')";
939 return "JI(`',`colours.logpal')";
940 case IDC_COLOURSTATIC:
949 return "JI(`',`colours.config')";
951 case IDC_CODEPAGESTATIC:
953 return "JI(`',`translation.codepage')";
954 case IDC_CAPSLOCKCYR:
955 return "JI(`',`translation.cyrillic')";
962 return "JI(`',`translation.linedraw')";
964 case IDC_X11_FORWARD:
965 case IDC_X11_DISPSTATIC:
966 case IDC_X11_DISPLAY:
967 return "JI(`',`ssh.tunnels.x11')";
969 case IDC_PFWDSTATIC2:
973 case IDC_SPORTSTATIC:
975 case IDC_DPORTSTATIC:
979 return "JI(`',`ssh.tunnels.portfwd')";
982 return "JI(`',`ssh.tunnels.portfwd.localhost')";
989 /* 2nd arg: NZ => don't redraw session list (use when loading
991 static void init_dlg_ctrls(HWND hwnd, int keepsess)
994 char fontstatic[256];
996 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
997 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
1000 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
1001 for (i = n; i-- > 0;)
1002 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
1003 for (i = 0; i < nsessions; i++)
1004 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
1005 0, (LPARAM) (sessions[i]));
1007 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1008 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
1009 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
1010 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
1012 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
1013 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
1014 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
1016 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
1017 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
1018 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
1019 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
1020 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
1021 cfg.funky_type == 0 ? IDC_FUNCTILDE :
1022 cfg.funky_type == 1 ? IDC_FUNCLINUX :
1023 cfg.funky_type == 2 ? IDC_FUNCXTERM :
1024 cfg.funky_type == 3 ? IDC_FUNCVT400 :
1025 cfg.funky_type == 4 ? IDC_FUNCVT100P :
1026 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
1027 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
1028 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
1029 CheckDlgButton(hwnd, IDC_NOMOUSEREP, cfg.no_mouse_rep);
1030 CheckDlgButton(hwnd, IDC_NORESIZE, cfg.no_remote_resize);
1031 CheckDlgButton(hwnd, IDC_NOALTSCREEN, cfg.no_alt_screen);
1032 CheckDlgButton(hwnd, IDC_NOWINTITLE, cfg.no_remote_wintitle);
1033 CheckDlgButton(hwnd, IDC_NODBACKSPACE, cfg.no_dbackspace);
1034 CheckDlgButton(hwnd, IDC_NOCHARSET, cfg.no_remote_charset);
1035 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
1036 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
1037 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
1038 cfg.nethack_keypad ? IDC_KPNH :
1039 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
1040 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
1041 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
1042 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
1043 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
1044 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
1045 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
1046 CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
1047 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
1048 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
1049 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
1050 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
1051 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
1052 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
1053 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
1054 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
1055 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
1056 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
1057 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
1059 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
1060 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
1061 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
1062 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
1063 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
1064 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
1065 fmtfont(fontstatic);
1066 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1067 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
1068 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
1069 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
1070 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
1072 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
1073 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
1075 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
1076 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
1077 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
1078 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1079 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1080 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1081 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1082 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1084 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1085 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1087 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1088 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
1089 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1090 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
1091 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
1092 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1093 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1094 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1095 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1096 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
1097 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
1098 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
1099 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1100 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
1101 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
1103 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1104 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
1105 cfg.close_on_exit ==
1106 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
1107 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1109 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1110 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1111 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1112 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1113 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1114 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
1115 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
1116 cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
1117 cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
1118 cfg.logtype == LGTYP_DEBUG ? IDC_LSTATRAW :
1120 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1121 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1122 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1125 char *p = cfg.environmt;
1126 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
1128 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1134 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1139 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1140 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
1141 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1142 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
1144 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1145 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1146 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1147 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1148 CheckDlgButton(hwnd, IDC_BUGGYMAC, cfg.buggymac);
1149 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
1150 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
1151 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
1152 CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
1153 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
1154 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
1155 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
1156 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1157 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1161 static const struct { char *s; int c; } ciphers[] = {
1162 { "3DES", CIPHER_3DES },
1163 { "Blowfish", CIPHER_BLOWFISH },
1164 { "DES", CIPHER_DES },
1165 { "AES (SSH 2 only)", CIPHER_AES },
1166 { "-- warn below here --", CIPHER_WARN }
1169 /* Set up the "selected ciphers" box. */
1170 /* (cipherlist assumed to contain all ciphers) */
1171 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1172 for (i = 0; i < CIPHER_MAX; i++) {
1173 int c = cfg.ssh_cipherlist[i];
1176 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1177 if (ciphers[j].c == c) {
1178 cstr = ciphers[j].s;
1182 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1184 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1190 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1191 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
1192 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1193 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
1194 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
1195 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
1196 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
1198 static int tabs[4] = { 25, 61, 96, 128 };
1199 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1202 for (i = 0; i < 128; i++) {
1204 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1205 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1206 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1210 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1211 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
1214 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1215 for (i = n; i-- > 0;)
1216 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1217 LB_DELETESTRING, i, 0);
1218 for (i = 0; i < 22; i++)
1219 if (cfg.bold_colour || permcolour[i])
1220 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1221 (LPARAM) colours[i]);
1223 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1224 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1225 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1226 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1231 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1232 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1233 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1234 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1235 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1238 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1244 pe = printer_start_enum(&nprinters);
1245 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_RESETCONTENT, 0, 0);
1246 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1247 0, (LPARAM) PRINTER_DISABLED_STRING);
1248 for (i = 0; i < nprinters; i++) {
1249 char *printer_name = printer_get_name(pe, i);
1250 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1251 0, (LPARAM) printer_name);
1253 printer_finish_enum(pe);
1254 SetDlgItemText(hwnd, IDC_PRINTER,
1255 *cfg.printer ? cfg.printer : PRINTER_DISABLED_STRING);
1258 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1259 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1260 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1261 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1262 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1265 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1266 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1268 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1269 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1270 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1273 CheckRadioButton(hwnd, IDC_PROXYTYPENONE, IDC_PROXYTYPETELNET,
1274 cfg.proxy_type == PROXY_HTTP ? IDC_PROXYTYPEHTTP :
1275 cfg.proxy_type == PROXY_SOCKS ? IDC_PROXYTYPESOCKS :
1276 cfg.proxy_type == PROXY_TELNET ? IDC_PROXYTYPETELNET : IDC_PROXYTYPENONE);
1277 SetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host);
1278 SetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, cfg.proxy_port, FALSE);
1279 SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
1280 SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
1281 SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
1282 SetDlgItemText(hwnd, IDC_PROXYPASSEDIT, cfg.proxy_password);
1283 CheckRadioButton(hwnd, IDC_PROXYSOCKSVER5, IDC_PROXYSOCKSVER4,
1284 cfg.proxy_socks_version == 4 ? IDC_PROXYSOCKSVER4 : IDC_PROXYSOCKSVER5);
1287 struct treeview_faff {
1289 HTREEITEM lastat[4];
1292 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1293 int level, char *text)
1298 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1299 ins.hInsertAfter = faff->lastat[level];
1300 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1301 #define INSITEM DUMMYUNIONNAME.item
1303 #define INSITEM item
1305 ins.INSITEM.mask = TVIF_TEXT;
1306 ins.INSITEM.pszText = text;
1307 newitem = TreeView_InsertItem(faff->treeview, &ins);
1309 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1311 faff->lastat[level] = newitem;
1312 for (i = level + 1; i < 4; i++)
1313 faff->lastat[i] = NULL;
1318 * Create the panelfuls of controls in the configuration box.
1320 static void create_controls(HWND hwnd, int dlgtype, int panel)
1322 if (panel == sessionpanelstart) {
1323 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1325 ctlposinit(&cp, hwnd, 80, 3, 13);
1326 bartitle(&cp, "Basic options for your PuTTY session",
1329 beginbox(&cp, "Specify your connection by host name or IP address",
1332 "Host &Name (or IP address)",
1333 IDC_HOSTSTATIC, IDC_HOST, 75,
1334 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1335 if (backends[3].backend == NULL) {
1336 /* this is PuTTYtel, so only three protocols available */
1337 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1338 "&Raw", IDC_PROTRAW,
1339 "&Telnet", IDC_PROTTELNET,
1340 "Rlog&in", IDC_PROTRLOGIN, NULL);
1342 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1343 "&Raw", IDC_PROTRAW,
1344 "&Telnet", IDC_PROTTELNET,
1345 "Rlog&in", IDC_PROTRLOGIN,
1354 beginbox(&cp, "Load, save or delete a stored session",
1356 sesssaver(&cp, "Sav&ed Sessions",
1357 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1358 "&Load", IDC_SESSLOAD,
1359 "Sa&ve", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1362 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1363 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1364 "Always", IDC_COEALWAYS,
1365 "Never", IDC_COENEVER,
1366 "Only on clean exit", IDC_COENORMAL, NULL);
1370 if (panel == loggingpanelstart) {
1371 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1373 ctlposinit(&cp, hwnd, 80, 3, 13);
1374 bartitle(&cp, "Options controlling session logging",
1376 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1378 "Session logging:", IDC_LSTATSTATIC,
1379 "Logging &turned off completely", IDC_LSTATOFF,
1380 "Log &printable output only", IDC_LSTATASCII,
1381 "&Log all session output", IDC_LSTATRAW,
1382 "Log &SSH packet data", IDC_LSTATPACKET,
1384 editbutton(&cp, "Log &file name:",
1385 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1387 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1388 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1390 "What to do if the log file already &exists:",
1391 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1392 "Always append to the end of it", IDC_LSTATXAPN,
1393 "Ask the user every time", IDC_LSTATXASK, NULL);
1397 if (panel == terminalpanelstart) {
1398 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1400 ctlposinit(&cp, hwnd, 80, 3, 13);
1401 bartitle(&cp, "Options controlling the terminal emulation",
1402 IDC_TITLE_TERMINAL);
1403 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1404 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1405 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1406 checkbox(&cp, "Implicit C&R in every LF", IDC_LFHASCR);
1407 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1408 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1410 "An&swerback to ^E:", IDC_ANSWERBACK,
1411 IDC_ANSWEREDIT, 100, NULL);
1414 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1415 radioline(&cp, "&Local echo:", IDC_ECHOSTATIC, 3,
1416 "Auto", IDC_ECHOBACKEND,
1417 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1418 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1419 "Auto", IDC_EDITBACKEND,
1420 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1423 beginbox(&cp, "Remote-controlled printing", IDC_BOX_TERMINAL3);
1424 combobox(&cp, "&Printer to send ANSI printer output to:",
1425 IDC_PRINTERSTATIC, IDC_PRINTER);
1429 if (panel == featurespanelstart) {
1430 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1432 ctlposinit(&cp, hwnd, 80, 3, 13);
1433 bartitle(&cp, "Enabling and disabling advanced terminal features ",
1434 IDC_TITLE_FEATURES);
1435 beginbox(&cp, NULL, IDC_BOX_FEATURES1);
1436 checkbox(&cp, "Disable application c&ursor keys mode", IDC_NOAPPLICC);
1437 checkbox(&cp, "Disable application &keypad mode", IDC_NOAPPLICK);
1438 checkbox(&cp, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP);
1439 checkbox(&cp, "Disable remote-controlled terminal re&sizing",
1441 checkbox(&cp, "Disable s&witching to alternate terminal screen",
1443 checkbox(&cp, "Disable remote-controlled window &title changing",
1445 checkbox(&cp, "Disable destructive &backspace on server sending ^?",
1447 checkbox(&cp, "Disable remote-controlled cha&racter set configuration",
1452 if (panel == bellpanelstart) {
1453 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1455 ctlposinit(&cp, hwnd, 80, 3, 13);
1456 bartitle(&cp, "Options controlling the terminal bell",
1458 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1460 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1461 "None (bell disabled)", IDC_BELL_DISABLED,
1462 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1463 "Play a custom sound file", IDC_BELL_WAVEFILE,
1464 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1465 editbutton(&cp, "Custom sound file to play as a bell:",
1466 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1467 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1468 radioline(&cp, "Taskbar/caption &indication on bell:",
1469 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1470 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1473 beginbox(&cp, "Control the bell overload behaviour",
1475 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1477 staticedit(&cp, "Over-use means this &many bells...",
1478 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1479 staticedit(&cp, "... in &this many seconds",
1480 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1482 "The bell is re-enabled after a few seconds of silence.",
1483 1, IDC_BELLOVLEXPLAIN);
1484 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1489 if (panel == keyboardpanelstart) {
1490 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1492 ctlposinit(&cp, hwnd, 80, 3, 13);
1493 bartitle(&cp, "Options controlling the effects of keys",
1494 IDC_TITLE_KEYBOARD);
1495 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1496 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1497 "Control-H", IDC_DEL008,
1498 "Control-? (127)", IDC_DEL127, NULL);
1499 radioline(&cp, "The Home and &End keys", IDC_HOMESTATIC, 2,
1500 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1501 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1502 "ESC[n~", IDC_FUNCTILDE,
1503 "Linux", IDC_FUNCLINUX,
1504 "Xterm R6", IDC_FUNCXTERM,
1505 "VT400", IDC_FUNCVT400,
1506 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1508 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1509 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1510 "Normal", IDC_CURNORMAL,
1511 "Application", IDC_CURAPPLIC, NULL);
1512 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1513 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1514 "NetHack", IDC_KPNH, NULL);
1516 beginbox(&cp, "Enable extra keyboard features:",
1518 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1519 checkbox(&cp, "Control-Alt is &different from AltGr",
1524 if (panel == windowpanelstart) {
1525 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1527 ctlposinit(&cp, hwnd, 80, 3, 13);
1528 bartitle(&cp, "Options controlling PuTTY's window",
1530 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1532 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1533 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1534 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1535 "Change the number of rows and columns", IDC_RESIZETERM,
1536 "Change the size of the font", IDC_RESIZEFONT,
1537 "Change font size only when maximised", IDC_RESIZEEITHER,
1538 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1540 beginbox(&cp, "Control the scrollback in the window",
1542 staticedit(&cp, "Lines of &scrollback",
1543 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1544 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1545 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1546 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1547 checkbox(&cp, "Reset scrollback on dis&play activity",
1552 if (panel == appearancepanelstart) {
1553 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1555 ctlposinit(&cp, hwnd, 80, 3, 13);
1556 bartitle(&cp, "Configure the appearance of PuTTY's window",
1557 IDC_TITLE_APPEARANCE);
1558 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1559 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1560 "B&lock", IDC_CURBLOCK,
1561 "&Underline", IDC_CURUNDER,
1562 "&Vertical line", IDC_CURVERT, NULL);
1563 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1565 beginbox(&cp, "Set the font used in the terminal window",
1566 IDC_BOX_APPEARANCE2);
1567 staticbtn(&cp, "", IDC_FONTSTATIC, "Cha&nge...", IDC_CHOOSEFONT);
1569 beginbox(&cp, "Adjust the use of the window title",
1570 IDC_BOX_APPEARANCE3);
1572 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1573 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1575 beginbox(&cp, "Adjust the use of the mouse pointer",
1576 IDC_BOX_APPEARANCE4);
1577 checkbox(&cp, "Hide mouse &pointer when typing in window",
1580 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1581 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1583 staticedit(&cp, "Gap between text and window edge",
1584 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1588 if (panel == behaviourpanelstart) {
1589 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1591 ctlposinit(&cp, hwnd, 80, 3, 13);
1592 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1594 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1595 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1596 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1597 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1598 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1599 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1600 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1604 if (panel == translationpanelstart) {
1605 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1607 ctlposinit(&cp, hwnd, 80, 3, 13);
1608 bartitle(&cp, "Options controlling character set translation",
1609 IDC_TITLE_TRANSLATION);
1610 beginbox(&cp, "Character set translation on received data",
1611 IDC_BOX_TRANSLATION1);
1612 combobox(&cp, "&Received data assumed to be in which character set:",
1613 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1615 beginbox(&cp, "Enable character set translation on input data",
1616 IDC_BOX_TRANSLATION2);
1617 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1620 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1621 IDC_BOX_TRANSLATION3);
1623 "Handling of line drawing characters:", IDC_VTSTATIC,
1624 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1625 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1626 "Use font in O&EM mode only", IDC_VTOEMONLY,
1627 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1628 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1632 if (panel == selectionpanelstart) {
1633 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1635 ctlposinit(&cp, hwnd, 80, 3, 13);
1636 bartitle(&cp, "Options controlling copy and paste",
1637 IDC_TITLE_SELECTION);
1638 beginbox(&cp, "Translation of pasted characters",
1639 IDC_BOX_SELECTION1);
1641 "&Don't translate line drawing chars into +, - and |",
1644 "Paste to clipboard in RT&F as well as plain text",
1647 beginbox(&cp, "Control which mouse button does which thing",
1648 IDC_BOX_SELECTION2);
1649 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1650 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1651 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1654 "Shift overrides a&pplication's use of mouse",
1657 "Default selection mode (Alt+drag does the other one):",
1658 IDC_SELTYPESTATIC, 2,
1659 "&Normal", IDC_SELTYPELEX,
1660 "&Rectangular block", IDC_SELTYPERECT, NULL);
1662 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1663 IDC_BOX_SELECTION3);
1664 charclass(&cp, "Charact&er classes:", IDC_CCSTATIC, IDC_CCLIST,
1665 "&Set", IDC_CCSET, IDC_CCEDIT,
1666 "&to class", IDC_CCSTATIC2);
1670 if (panel == colourspanelstart) {
1671 /* The Colours panel. Accelerators used: [acgoh] blum */
1673 ctlposinit(&cp, hwnd, 80, 3, 13);
1674 bartitle(&cp, "Options controlling use of colours",
1676 beginbox(&cp, "General options for colour usage",
1678 checkbox(&cp, "&Bolded text is a different colour",
1680 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1682 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1684 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1685 IDC_COLOURSTATIC, IDC_COLOURLIST,
1686 "&Modify...", IDC_CHANGE,
1687 "Red:", IDC_RSTATIC, IDC_RVALUE,
1688 "Green:", IDC_GSTATIC, IDC_GVALUE,
1689 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1693 if (panel == connectionpanelstart) {
1694 /* The Connection panel. Accelerators used: [acgoh] tukn */
1696 ctlposinit(&cp, hwnd, 80, 3, 13);
1697 bartitle(&cp, "Options controlling the connection",
1698 IDC_TITLE_CONNECTION);
1700 beginbox(&cp, "Data to send to the server",
1701 IDC_BOX_CONNECTION1);
1702 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1704 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1708 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1709 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1711 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1715 beginbox(&cp, "Sending of null packets to keep session active",
1716 IDC_BOX_CONNECTION2);
1717 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1718 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1721 beginbox(&cp, "Low-level TCP connection options",
1722 IDC_BOX_CONNECTION3);
1723 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1729 if (panel == proxypanelstart) {
1730 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmv */
1732 ctlposinit(&cp, hwnd, 80, 3, 13);
1734 bartitle(&cp, "Options controlling proxy usage",
1736 beginbox(&cp, "Proxy basics", IDC_BOX_PROXY1);
1737 radioline(&cp, "Proxy type:", IDC_PROXYTYPESTATIC, 4,
1738 "&None", IDC_PROXYTYPENONE,
1739 "H&TTP", IDC_PROXYTYPEHTTP,
1740 "&SOCKS", IDC_PROXYTYPESOCKS,
1741 "Te&lnet", IDC_PROXYTYPETELNET, NULL);
1743 "Prox&y Host", IDC_PROXYHOSTSTATIC, IDC_PROXYHOSTEDIT, 80,
1744 "&Port", IDC_PROXYPORTSTATIC, IDC_PROXYPORTEDIT, 20, NULL);
1746 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC,
1747 IDC_PROXYEXCLUDEEDIT, 100, NULL);
1748 staticedit(&cp, "&Username", IDC_PROXYUSERSTATIC,
1749 IDC_PROXYUSEREDIT, 60);
1750 staticedit(&cp, "Pass&word", IDC_PROXYPASSSTATIC,
1751 IDC_PROXYPASSEDIT, 60);
1753 beginbox(&cp, "Misc. proxy settings", IDC_BOX_PROXY2);
1755 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC,
1756 IDC_PROXYTELNETCMDEDIT, 100, NULL);
1757 radioline(&cp, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC,
1758 2, "Version 5", IDC_PROXYSOCKSVER5, "Version 4",
1759 IDC_PROXYSOCKSVER4, NULL);
1764 if (panel == telnetpanelstart) {
1765 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1767 ctlposinit(&cp, hwnd, 80, 3, 13);
1769 bartitle(&cp, "Options controlling Telnet connections",
1771 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1772 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1774 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1775 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1776 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1777 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1779 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1780 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1781 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1782 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1783 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1784 "Passive", IDC_TPASSIVE, "Active",
1786 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1788 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1794 if (panel == rloginpanelstart) {
1795 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1797 ctlposinit(&cp, hwnd, 80, 3, 13);
1799 bartitle(&cp, "Options controlling Rlogin connections",
1801 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1802 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1804 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1805 IDC_RLLUSEREDIT, 50);
1810 if (panel == sshpanelstart) {
1811 /* The SSH panel. Accelerators used: [acgoh] r pe12i sd */
1813 ctlposinit(&cp, hwnd, 80, 3, 13);
1815 bartitle(&cp, "Options controlling SSH connections",
1817 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1819 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1822 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1823 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1824 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1825 radioline(&cp, "Preferred SSH protocol version:",
1826 IDC_SSHPROTSTATIC, 2,
1827 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
1828 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1831 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1832 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1833 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1835 checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
1841 if (panel == sshauthpanelstart) {
1842 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1844 ctlposinit(&cp, hwnd, 80, 3, 13);
1846 bartitle(&cp, "Options controlling SSH authentication",
1848 beginbox(&cp, "Authentication methods",
1850 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1852 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
1853 " (SSH2)", IDC_AUTHKI);
1855 beginbox(&cp, "Authentication parameters",
1857 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1858 checkbox(&cp, "Allow attempted changes of &username in SSH2",
1860 editbutton(&cp, "Private &key file for authentication:",
1861 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1867 if (panel == tunnelspanelstart) {
1868 /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
1870 ctlposinit(&cp, hwnd, 80, 3, 13);
1872 bartitle(&cp, "Options controlling SSH tunnelling",
1874 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
1875 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1876 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1877 IDC_X11_DISPLAY, 50, NULL);
1879 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1880 checkbox(&cp, "Local ports accept connections from o&ther hosts",
1882 checkbox(&cp, "Remote &ports do the same (SSH v2 only)",
1884 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1885 "&Remove", IDC_PFWDREMOVE);
1886 fwdsetter(&cp, IDC_PFWDLIST,
1887 "Add new forwarded port:", IDC_PFWDSTATIC2,
1888 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1889 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1890 "A&dd", IDC_PFWDADD);
1891 bareradioline(&cp, 2,
1892 "&Local", IDC_PFWDLOCAL,
1893 "Re&mote", IDC_PFWDREMOTE, NULL);
1901 * Helper function to load the session selected in SESSLIST
1902 * if any, as this is done in more than one place in
1903 * GenericMainDlgProc(). 0 => failure.
1905 static int load_selected_session(HWND hwnd)
1907 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1908 LB_GETCURSEL, 0, 0);
1914 isdef = !strcmp(sessions[n], "Default Settings");
1915 load_settings(sessions[n], !isdef, &cfg);
1916 init_dlg_ctrls(hwnd, TRUE);
1918 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1920 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1921 /* Restore the selection, which will have been clobbered by
1922 * SESSEDIT handling. */
1923 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
1928 * This function is the configuration box.
1930 static int GenericMainDlgProc(HWND hwnd, UINT msg,
1931 WPARAM wParam, LPARAM lParam, int dlgtype)
1934 struct treeview_faff tvfaff;
1937 char filename[sizeof(cfg.keyfile)];
1940 char fontstatic[256];
1942 struct servent *service;
1944 static UINT draglistmsg = WM_NULL;
1949 SetWindowLong(hwnd, GWL_USERDATA, 0);
1951 SetWindowLong(hwnd, GWL_EXSTYLE,
1952 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
1954 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
1956 DestroyWindow(item);
1958 requested_help = FALSE;
1959 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
1960 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
1962 * Centre the window.
1964 { /* centre the window */
1967 hw = GetDesktopWindow();
1968 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
1970 (rs.right + rs.left + rd.left - rd.right) / 2,
1971 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
1972 rd.right - rd.left, rd.bottom - rd.top, TRUE);
1976 * Create the tree view.
1984 r.right = r.left + 75;
1986 r.bottom = r.top + 10;
1987 MapDialogRect(hwnd, &r);
1988 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1989 WS_CHILD | WS_VISIBLE,
1991 r.right - r.left, r.bottom - r.top,
1992 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
1994 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1995 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1998 r.right = r.left + 75;
2000 r.bottom = r.top + 219;
2001 MapDialogRect(hwnd, &r);
2002 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
2003 WS_CHILD | WS_VISIBLE |
2004 WS_TABSTOP | TVS_HASLINES |
2005 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
2007 TVS_SHOWSELALWAYS, r.left, r.top,
2008 r.right - r.left, r.bottom - r.top,
2009 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
2011 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2012 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2013 tvfaff.treeview = treeview;
2014 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
2018 * Set up the tree view contents.
2020 hsession = treeview_insert(&tvfaff, 0, "Session");
2021 treeview_insert(&tvfaff, 1, "Logging");
2022 treeview_insert(&tvfaff, 0, "Terminal");
2023 treeview_insert(&tvfaff, 1, "Keyboard");
2024 treeview_insert(&tvfaff, 1, "Bell");
2025 treeview_insert(&tvfaff, 1, "Features");
2026 treeview_insert(&tvfaff, 0, "Window");
2027 treeview_insert(&tvfaff, 1, "Appearance");
2028 treeview_insert(&tvfaff, 1, "Behaviour");
2029 treeview_insert(&tvfaff, 1, "Translation");
2030 treeview_insert(&tvfaff, 1, "Selection");
2031 treeview_insert(&tvfaff, 1, "Colours");
2032 treeview_insert(&tvfaff, 0, "Connection");
2034 treeview_insert(&tvfaff, 1, "Proxy");
2035 treeview_insert(&tvfaff, 1, "Telnet");
2036 treeview_insert(&tvfaff, 1, "Rlogin");
2037 if (backends[3].backend != NULL) {
2038 treeview_insert(&tvfaff, 1, "SSH");
2039 /* XXX long name is ugly */
2040 /* XXX make it closed by default? */
2041 treeview_insert(&tvfaff, 2, "Auth");
2042 treeview_insert(&tvfaff, 2, "Tunnels");
2047 * Put the treeview selection on to the Session panel. This
2048 * should also cause creation of the relevant controls.
2050 TreeView_SelectItem(treeview, hsession);
2053 * Set focus into the first available control.
2057 ctl = GetDlgItem(hwnd, IDC_HOST);
2059 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
2063 SetWindowLong(hwnd, GWL_USERDATA, 1);
2064 sesslist_has_focus = 0;
2068 * Button release should trigger WM_OK if there was a
2069 * previous double click on the session list.
2073 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
2076 if (LOWORD(wParam) == IDCX_TREEVIEW &&
2077 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
2079 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
2084 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
2087 item.pszText = buffer;
2088 item.cchTextMax = sizeof(buffer);
2089 item.mask = TVIF_TEXT;
2090 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
2091 for (j = controlstartvalue; j < controlendvalue; j++) {
2092 HWND item = GetDlgItem(hwnd, j);
2094 DestroyWindow(item);
2096 if (!strcmp(buffer, "Session"))
2097 create_controls(hwnd, dlgtype, sessionpanelstart);
2098 if (!strcmp(buffer, "Logging"))
2099 create_controls(hwnd, dlgtype, loggingpanelstart);
2100 if (!strcmp(buffer, "Keyboard"))
2101 create_controls(hwnd, dlgtype, keyboardpanelstart);
2102 if (!strcmp(buffer, "Terminal"))
2103 create_controls(hwnd, dlgtype, terminalpanelstart);
2104 if (!strcmp(buffer, "Bell"))
2105 create_controls(hwnd, dlgtype, bellpanelstart);
2106 if (!strcmp(buffer, "Features"))
2107 create_controls(hwnd, dlgtype, featurespanelstart);
2108 if (!strcmp(buffer, "Window"))
2109 create_controls(hwnd, dlgtype, windowpanelstart);
2110 if (!strcmp(buffer, "Appearance"))
2111 create_controls(hwnd, dlgtype, appearancepanelstart);
2112 if (!strcmp(buffer, "Behaviour"))
2113 create_controls(hwnd, dlgtype, behaviourpanelstart);
2114 if (!strcmp(buffer, "Tunnels"))
2115 create_controls(hwnd, dlgtype, tunnelspanelstart);
2116 if (!strcmp(buffer, "Connection"))
2117 create_controls(hwnd, dlgtype, connectionpanelstart);
2118 if (!strcmp(buffer, "Proxy"))
2119 create_controls(hwnd, dlgtype, proxypanelstart);
2120 if (!strcmp(buffer, "Telnet"))
2121 create_controls(hwnd, dlgtype, telnetpanelstart);
2122 if (!strcmp(buffer, "Rlogin"))
2123 create_controls(hwnd, dlgtype, rloginpanelstart);
2124 if (!strcmp(buffer, "SSH"))
2125 create_controls(hwnd, dlgtype, sshpanelstart);
2126 if (!strcmp(buffer, "Auth"))
2127 create_controls(hwnd, dlgtype, sshauthpanelstart);
2128 if (!strcmp(buffer, "Selection"))
2129 create_controls(hwnd, dlgtype, selectionpanelstart);
2130 if (!strcmp(buffer, "Colours"))
2131 create_controls(hwnd, dlgtype, colourspanelstart);
2132 if (!strcmp(buffer, "Translation"))
2133 create_controls(hwnd, dlgtype, translationpanelstart);
2135 init_dlg_ctrls(hwnd, FALSE);
2137 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
2138 InvalidateRect (hwnd, NULL, TRUE);
2140 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
2146 * Only process WM_COMMAND once the dialog is fully formed.
2148 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
2149 switch (LOWORD(wParam)) {
2151 /* Behaviour of the "Open" button is different if the
2152 * session list has focus, *unless* the user just
2153 * double-clicked... */
2154 if (sesslist_has_focus && !readytogo) {
2155 if (!load_selected_session(hwnd)) {
2160 /* If at this point we have a valid session, go! */
2162 if (requested_help) {
2163 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2164 requested_help = FALSE;
2171 if (HIWORD(wParam) == BN_CLICKED ||
2172 HIWORD(wParam) == BN_DOUBLECLICKED) {
2174 WinHelp(hwnd, help_path,
2175 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2177 requested_help = TRUE;
2182 if (requested_help) {
2183 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2184 requested_help = FALSE;
2188 case IDC_PROTTELNET:
2189 case IDC_PROTRLOGIN:
2192 if (HIWORD(wParam) == BN_CLICKED ||
2193 HIWORD(wParam) == BN_DOUBLECLICKED) {
2194 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2195 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2196 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2198 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2201 * When switching using the arrow keys, we
2202 * appear to get two of these messages, both
2203 * mentioning the target button in
2204 * LOWORD(wParam), but one of them called while
2205 * the previous button is still checked. This
2206 * causes an unnecessary reset of the port
2207 * number field, which we fix by ensuring here
2208 * that the button selected is indeed the one
2211 if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) &&
2212 ((cfg.protocol == PROT_SSH && cfg.port != 22)
2213 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2214 || (cfg.protocol == PROT_RLOGIN
2215 && cfg.port != 513))) {
2216 cfg.port = i ? 22 : j ? 23 : 513;
2217 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2222 if (HIWORD(wParam) == EN_CHANGE)
2223 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2224 sizeof(cfg.host) - 1);
2227 if (HIWORD(wParam) == EN_CHANGE) {
2228 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2229 if (isdigit(portname[0]))
2230 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2232 service = getservbyname(portname, NULL);
2234 cfg.port = ntohs(service->s_port);
2241 if (HIWORD(wParam) == EN_CHANGE) {
2242 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2244 GetDlgItemText(hwnd, IDC_SESSEDIT,
2245 savedsession, sizeof(savedsession) - 1);
2246 savedsession[sizeof(savedsession) - 1] = '\0';
2250 if (HIWORD(wParam) == BN_CLICKED ||
2251 HIWORD(wParam) == BN_DOUBLECLICKED) {
2256 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2259 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2260 LB_GETCURSEL, 0, 0);
2265 strcpy(str, sessions[n]);
2267 save_settings(str, !!strcmp(str, "Default Settings"),
2269 get_sesslist(FALSE);
2271 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2273 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2275 for (i = 0; i < nsessions; i++)
2276 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2278 (LPARAM) (sessions[i]));
2279 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2281 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2283 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2289 if (LOWORD(wParam) == IDC_SESSLIST) {
2290 if (HIWORD(wParam) == LBN_SETFOCUS)
2291 sesslist_has_focus = 1;
2292 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2293 sesslist_has_focus = 0;
2295 if (LOWORD(wParam) == IDC_SESSLOAD &&
2296 HIWORD(wParam) != BN_CLICKED &&
2297 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2298 if (LOWORD(wParam) == IDC_SESSLIST &&
2299 HIWORD(wParam) != LBN_DBLCLK) break;
2300 /* Load the session selected in SESSLIST. */
2301 if (load_selected_session(hwnd) &&
2302 LOWORD(wParam) == IDC_SESSLIST) {
2304 * A double-click on a saved session should
2305 * actually start the session, not just load it.
2306 * Unless it's Default Settings or some other
2307 * host-less set of saved settings.
2316 if (HIWORD(wParam) == BN_CLICKED ||
2317 HIWORD(wParam) == BN_DOUBLECLICKED) {
2318 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2319 LB_GETCURSEL, 0, 0);
2320 if (n == LB_ERR || n == 0) {
2324 del_settings(sessions[n]);
2325 get_sesslist(FALSE);
2327 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2329 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2331 for (i = 0; i < nsessions; i++)
2332 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2334 (LPARAM) (sessions[i]));
2335 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2337 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2339 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2343 if (HIWORD(wParam) == EN_CHANGE)
2344 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2345 &cfg.ping_interval);
2348 if (HIWORD(wParam) == BN_CLICKED ||
2349 HIWORD(wParam) == BN_DOUBLECLICKED)
2351 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2355 if (HIWORD(wParam) == BN_CLICKED ||
2356 HIWORD(wParam) == BN_DOUBLECLICKED)
2357 cfg.bksp_is_delete =
2358 IsDlgButtonChecked(hwnd, IDC_DEL127);
2362 if (HIWORD(wParam) == BN_CLICKED ||
2363 HIWORD(wParam) == BN_DOUBLECLICKED)
2365 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2371 case IDC_FUNCVT100P:
2373 if (HIWORD(wParam) == BN_CLICKED ||
2374 HIWORD(wParam) == BN_DOUBLECLICKED)
2375 switch (LOWORD(wParam)) {
2388 case IDC_FUNCVT100P:
2398 if (HIWORD(wParam) == BN_CLICKED ||
2399 HIWORD(wParam) == BN_DOUBLECLICKED) {
2401 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2402 cfg.nethack_keypad = FALSE;
2406 if (HIWORD(wParam) == BN_CLICKED ||
2407 HIWORD(wParam) == BN_DOUBLECLICKED) {
2408 cfg.app_keypad = FALSE;
2409 cfg.nethack_keypad = TRUE;
2414 if (HIWORD(wParam) == BN_CLICKED ||
2415 HIWORD(wParam) == BN_DOUBLECLICKED)
2417 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2420 if (HIWORD(wParam) == BN_CLICKED ||
2421 HIWORD(wParam) == BN_DOUBLECLICKED)
2423 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2426 if (HIWORD(wParam) == BN_CLICKED ||
2427 HIWORD(wParam) == BN_DOUBLECLICKED)
2429 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2431 case IDC_NOMOUSEREP:
2432 if (HIWORD(wParam) == BN_CLICKED ||
2433 HIWORD(wParam) == BN_DOUBLECLICKED)
2435 IsDlgButtonChecked(hwnd, IDC_NOMOUSEREP);
2438 if (HIWORD(wParam) == BN_CLICKED ||
2439 HIWORD(wParam) == BN_DOUBLECLICKED)
2440 cfg.no_remote_resize =
2441 IsDlgButtonChecked(hwnd, IDC_NORESIZE);
2443 case IDC_NOALTSCREEN:
2444 if (HIWORD(wParam) == BN_CLICKED ||
2445 HIWORD(wParam) == BN_DOUBLECLICKED)
2447 IsDlgButtonChecked(hwnd, IDC_NOALTSCREEN);
2449 case IDC_NOWINTITLE:
2450 if (HIWORD(wParam) == BN_CLICKED ||
2451 HIWORD(wParam) == BN_DOUBLECLICKED)
2452 cfg.no_remote_wintitle =
2453 IsDlgButtonChecked(hwnd, IDC_NOWINTITLE);
2455 case IDC_NODBACKSPACE:
2456 if (HIWORD(wParam) == BN_CLICKED ||
2457 HIWORD(wParam) == BN_DOUBLECLICKED)
2459 IsDlgButtonChecked(hwnd, IDC_NODBACKSPACE);
2462 if (HIWORD(wParam) == BN_CLICKED ||
2463 HIWORD(wParam) == BN_DOUBLECLICKED)
2464 cfg.no_remote_charset =
2465 IsDlgButtonChecked(hwnd, IDC_NOCHARSET);
2468 if (HIWORD(wParam) == BN_CLICKED ||
2469 HIWORD(wParam) == BN_DOUBLECLICKED)
2470 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2473 if (HIWORD(wParam) == BN_CLICKED ||
2474 HIWORD(wParam) == BN_DOUBLECLICKED)
2476 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2479 if (HIWORD(wParam) == BN_CLICKED ||
2480 HIWORD(wParam) == BN_DOUBLECLICKED)
2482 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2484 case IDC_ECHOBACKEND:
2487 if (HIWORD(wParam) == BN_CLICKED ||
2488 HIWORD(wParam) == BN_DOUBLECLICKED) {
2489 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2490 cfg.localecho = LD_BACKEND;
2491 if (LOWORD(wParam) == IDC_ECHOYES)
2492 cfg.localecho = LD_YES;
2493 if (LOWORD(wParam) == IDC_ECHONO)
2494 cfg.localecho = LD_NO;
2497 case IDC_EDITBACKEND:
2500 if (HIWORD(wParam) == BN_CLICKED ||
2501 HIWORD(wParam) == BN_DOUBLECLICKED) {
2502 if (LOWORD(wParam) == IDC_EDITBACKEND)
2503 cfg.localedit = LD_BACKEND;
2504 if (LOWORD(wParam) == IDC_EDITYES)
2505 cfg.localedit = LD_YES;
2506 if (LOWORD(wParam) == IDC_EDITNO)
2507 cfg.localedit = LD_NO;
2510 case IDC_ANSWEREDIT:
2511 if (HIWORD(wParam) == EN_CHANGE)
2512 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2513 sizeof(cfg.answerback) - 1);
2515 case IDC_ALWAYSONTOP:
2516 if (HIWORD(wParam) == BN_CLICKED ||
2517 HIWORD(wParam) == BN_DOUBLECLICKED)
2519 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2521 case IDC_FULLSCREENONALTENTER:
2522 if (HIWORD(wParam) == BN_CLICKED ||
2523 HIWORD(wParam) == BN_DOUBLECLICKED)
2524 cfg.fullscreenonaltenter =
2525 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2528 if (HIWORD(wParam) == BN_CLICKED ||
2529 HIWORD(wParam) == BN_DOUBLECLICKED)
2531 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2533 case IDC_SCROLLDISP:
2534 if (HIWORD(wParam) == BN_CLICKED ||
2535 HIWORD(wParam) == BN_DOUBLECLICKED)
2536 cfg.scroll_on_disp =
2537 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2539 case IDC_COMPOSEKEY:
2540 if (HIWORD(wParam) == BN_CLICKED ||
2541 HIWORD(wParam) == BN_DOUBLECLICKED)
2543 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2545 case IDC_CTRLALTKEYS:
2546 if (HIWORD(wParam) == BN_CLICKED ||
2547 HIWORD(wParam) == BN_DOUBLECLICKED)
2549 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2552 if (HIWORD(wParam) == BN_CLICKED ||
2553 HIWORD(wParam) == BN_DOUBLECLICKED)
2554 cfg.telnet_keyboard =
2555 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2558 if (HIWORD(wParam) == BN_CLICKED ||
2559 HIWORD(wParam) == BN_DOUBLECLICKED)
2560 cfg.telnet_newline =
2561 IsDlgButtonChecked(hwnd, IDC_TELNETRET);
2564 if (HIWORD(wParam) == BN_CLICKED ||
2565 HIWORD(wParam) == BN_DOUBLECLICKED)
2567 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2570 if (HIWORD(wParam) == BN_CLICKED ||
2571 HIWORD(wParam) == BN_DOUBLECLICKED)
2572 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2575 if (HIWORD(wParam) == BN_CLICKED ||
2576 HIWORD(wParam) == BN_DOUBLECLICKED)
2578 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2581 if (HIWORD(wParam) == EN_CHANGE)
2582 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2585 if (HIWORD(wParam) == EN_CHANGE)
2586 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2589 if (HIWORD(wParam) == EN_CHANGE)
2590 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2592 case IDC_CHOOSEFONT:
2595 lf.lfHeight = -MulDiv(cfg.fontheight,
2596 GetDeviceCaps(hdc, LOGPIXELSY),
2600 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2601 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2602 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2603 lf.lfCharSet = cfg.fontcharset;
2604 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2605 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2606 lf.lfQuality = DEFAULT_QUALITY;
2607 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2608 strncpy(lf.lfFaceName, cfg.font,
2609 sizeof(lf.lfFaceName) - 1);
2610 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2612 cf.lStructSize = sizeof(cf);
2613 cf.hwndOwner = hwnd;
2615 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2616 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2618 if (ChooseFont(&cf)) {
2619 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2620 cfg.font[sizeof(cfg.font) - 1] = '\0';
2621 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2622 cfg.fontcharset = lf.lfCharSet;
2623 cfg.fontheight = cf.iPointSize / 10;
2624 fmtfont(fontstatic);
2625 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2628 case IDC_BELL_DISABLED:
2629 case IDC_BELL_DEFAULT:
2630 case IDC_BELL_WAVEFILE:
2631 case IDC_BELL_VISUAL:
2632 if (HIWORD(wParam) == BN_CLICKED ||
2633 HIWORD(wParam) == BN_DOUBLECLICKED) {
2634 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2635 cfg.beep = BELL_DISABLED;
2636 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2637 cfg.beep = BELL_DEFAULT;
2638 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2639 cfg.beep = BELL_WAVEFILE;
2640 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2641 cfg.beep = BELL_VISUAL;
2644 case IDC_B_IND_DISABLED:
2645 case IDC_B_IND_FLASH:
2646 case IDC_B_IND_STEADY:
2647 if (HIWORD(wParam) == BN_CLICKED ||
2648 HIWORD(wParam) == BN_DOUBLECLICKED) {
2649 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2650 cfg.beep_ind = B_IND_DISABLED;
2651 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2652 cfg.beep_ind = B_IND_FLASH;
2653 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2654 cfg.beep_ind = B_IND_STEADY;
2657 case IDC_BELL_WAVEBROWSE:
2658 memset(&of, 0, sizeof(of));
2659 #ifdef OPENFILENAME_SIZE_VERSION_400
2660 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2662 of.lStructSize = sizeof(of);
2664 of.hwndOwner = hwnd;
2665 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2666 of.lpstrCustomFilter = NULL;
2667 of.nFilterIndex = 1;
2668 of.lpstrFile = filename;
2669 strcpy(filename, cfg.bell_wavefile);
2670 of.nMaxFile = sizeof(filename);
2671 of.lpstrFileTitle = NULL;
2672 of.lpstrInitialDir = NULL;
2673 of.lpstrTitle = "Select Bell Sound File";
2675 if (GetOpenFileName(&of)) {
2676 strcpy(cfg.bell_wavefile, filename);
2677 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2681 case IDC_BELL_WAVEEDIT:
2682 if (HIWORD(wParam) == EN_CHANGE)
2683 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2685 sizeof(cfg.bell_wavefile) - 1);
2688 if (HIWORD(wParam) == BN_CLICKED ||
2689 HIWORD(wParam) == BN_DOUBLECLICKED)
2691 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2694 if (HIWORD(wParam) == EN_CHANGE)
2695 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2698 if (HIWORD(wParam) == EN_CHANGE)
2699 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2703 if (HIWORD(wParam) == EN_CHANGE)
2704 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2708 if (HIWORD(wParam) == BN_CLICKED ||
2709 HIWORD(wParam) == BN_DOUBLECLICKED)
2711 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2714 if (HIWORD(wParam) == BN_CLICKED ||
2715 HIWORD(wParam) == BN_DOUBLECLICKED)
2716 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2719 if (HIWORD(wParam) == BN_CLICKED ||
2720 HIWORD(wParam) == BN_DOUBLECLICKED)
2721 cfg.win_name_always =
2722 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2725 if (HIWORD(wParam) == BN_CLICKED ||
2726 HIWORD(wParam) == BN_DOUBLECLICKED)
2728 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2730 case IDC_SUNKENEDGE:
2731 if (HIWORD(wParam) == BN_CLICKED ||
2732 HIWORD(wParam) == BN_DOUBLECLICKED)
2734 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2737 if (HIWORD(wParam) == EN_CHANGE)
2738 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2739 &cfg.window_border);
2740 if (cfg.window_border > 32)
2741 cfg.window_border = 32;
2744 if (HIWORD(wParam) == BN_CLICKED ||
2745 HIWORD(wParam) == BN_DOUBLECLICKED)
2746 cfg.cursor_type = 0;
2749 if (HIWORD(wParam) == BN_CLICKED ||
2750 HIWORD(wParam) == BN_DOUBLECLICKED)
2751 cfg.cursor_type = 1;
2754 if (HIWORD(wParam) == BN_CLICKED ||
2755 HIWORD(wParam) == BN_DOUBLECLICKED)
2756 cfg.cursor_type = 2;
2759 if (HIWORD(wParam) == BN_CLICKED ||
2760 HIWORD(wParam) == BN_DOUBLECLICKED)
2762 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2765 if (HIWORD(wParam) == BN_CLICKED ||
2766 HIWORD(wParam) == BN_DOUBLECLICKED)
2768 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2770 case IDC_SCROLLBARFULLSCREEN:
2771 if (HIWORD(wParam) == BN_CLICKED ||
2772 HIWORD(wParam) == BN_DOUBLECLICKED)
2773 cfg.scrollbar_in_fullscreen =
2774 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2776 case IDC_RESIZETERM:
2777 case IDC_RESIZEFONT:
2778 case IDC_RESIZENONE:
2779 case IDC_RESIZEEITHER:
2780 if (HIWORD(wParam) == BN_CLICKED ||
2781 HIWORD(wParam) == BN_DOUBLECLICKED) {
2783 IsDlgButtonChecked(hwnd,
2784 IDC_RESIZETERM) ? RESIZE_TERM :
2785 IsDlgButtonChecked(hwnd,
2786 IDC_RESIZEFONT) ? RESIZE_FONT :
2787 IsDlgButtonChecked(hwnd,
2788 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2793 if (HIWORD(wParam) == EN_CHANGE)
2794 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2795 sizeof(cfg.wintitle) - 1);
2800 if (HIWORD(wParam) == BN_CLICKED ||
2801 HIWORD(wParam) == BN_DOUBLECLICKED) {
2803 IsDlgButtonChecked(hwnd,
2804 IDC_COEALWAYS) ? COE_ALWAYS :
2805 IsDlgButtonChecked(hwnd,
2806 IDC_COENEVER) ? COE_NEVER :
2811 if (HIWORD(wParam) == BN_CLICKED ||
2812 HIWORD(wParam) == BN_DOUBLECLICKED)
2814 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2817 if (HIWORD(wParam) == EN_CHANGE)
2818 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2819 sizeof(cfg.termtype) - 1);
2823 case IDC_PROXYHOSTEDIT:
2824 if (HIWORD(wParam) == EN_CHANGE)
2825 GetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host,
2826 sizeof(cfg.proxy_host) - 1);
2828 case IDC_PROXYPORTEDIT:
2829 if (HIWORD(wParam) == EN_CHANGE) {
2830 GetDlgItemText(hwnd, IDC_PROXYPORTEDIT, portname, 31);
2831 if (isdigit(portname[0]))
2832 MyGetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, &cfg.proxy_port);
2834 service = getservbyname(portname, NULL);
2836 cfg.proxy_port = ntohs(service->s_port);
2842 case IDC_PROXYEXCLUDEEDIT:
2843 if (HIWORD(wParam) == EN_CHANGE)
2844 GetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT,
2845 cfg.proxy_exclude_list,
2846 sizeof(cfg.proxy_exclude_list) - 1);
2848 case IDC_PROXYUSEREDIT:
2849 if (HIWORD(wParam) == EN_CHANGE)
2850 GetDlgItemText(hwnd, IDC_PROXYUSEREDIT,
2852 sizeof(cfg.proxy_username) - 1);
2854 case IDC_PROXYPASSEDIT:
2855 if (HIWORD(wParam) == EN_CHANGE)
2856 GetDlgItemText(hwnd, IDC_PROXYPASSEDIT,
2858 sizeof(cfg.proxy_password) - 1);
2860 case IDC_PROXYTELNETCMDEDIT:
2861 if (HIWORD(wParam) == EN_CHANGE)
2862 GetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT,
2863 cfg.proxy_telnet_command,
2864 sizeof(cfg.proxy_telnet_command) - 1);
2866 case IDC_PROXYSOCKSVER5:
2867 case IDC_PROXYSOCKSVER4:
2868 if (HIWORD(wParam) == BN_CLICKED ||
2869 HIWORD(wParam) == BN_DOUBLECLICKED) {
2870 cfg.proxy_socks_version =
2871 IsDlgButtonChecked(hwnd, IDC_PROXYSOCKSVER4) ? 4 : 5;
2874 case IDC_PROXYTYPENONE:
2875 case IDC_PROXYTYPEHTTP:
2876 case IDC_PROXYTYPESOCKS:
2877 case IDC_PROXYTYPETELNET:
2878 if (HIWORD(wParam) == BN_CLICKED ||
2879 HIWORD(wParam) == BN_DOUBLECLICKED) {
2881 IsDlgButtonChecked(hwnd, IDC_PROXYTYPEHTTP) ? PROXY_HTTP :
2882 IsDlgButtonChecked(hwnd, IDC_PROXYTYPESOCKS) ? PROXY_SOCKS :
2883 IsDlgButtonChecked(hwnd, IDC_PROXYTYPETELNET) ? PROXY_TELNET :
2889 if (HIWORD(wParam) == EN_CHANGE)
2890 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
2891 sizeof(cfg.logfilename) - 1);
2894 memset(&of, 0, sizeof(of));
2895 #ifdef OPENFILENAME_SIZE_VERSION_400
2896 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2898 of.lStructSize = sizeof(of);
2900 of.hwndOwner = hwnd;
2901 of.lpstrFilter = "All Files\0*\0\0\0";
2902 of.lpstrCustomFilter = NULL;
2903 of.nFilterIndex = 1;
2904 of.lpstrFile = filename;
2905 strcpy(filename, cfg.logfilename);
2906 of.nMaxFile = sizeof(filename);
2907 of.lpstrFileTitle = NULL;
2908 of.lpstrInitialDir = NULL;
2909 of.lpstrTitle = "Select session log file";
2911 if (GetSaveFileName(&of)) {
2912 strcpy(cfg.logfilename, filename);
2913 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
2917 case IDC_LSTATASCII:
2919 case IDC_LSTATPACKET:
2920 if (HIWORD(wParam) == BN_CLICKED ||
2921 HIWORD(wParam) == BN_DOUBLECLICKED) {
2922 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
2923 cfg.logtype = LGTYP_NONE;
2924 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
2925 cfg.logtype = LGTYP_ASCII;
2926 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
2927 cfg.logtype = LGTYP_DEBUG;
2928 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
2929 cfg.logtype = LGTYP_PACKETS;
2935 if (HIWORD(wParam) == BN_CLICKED ||
2936 HIWORD(wParam) == BN_DOUBLECLICKED) {
2937 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
2938 cfg.logxfovr = LGXF_ASK;
2939 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
2940 cfg.logxfovr = LGXF_APN;
2941 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
2942 cfg.logxfovr = LGXF_OVR;
2947 if (HIWORD(wParam) == EN_CHANGE)
2948 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
2949 sizeof(cfg.termspeed) - 1);
2952 if (HIWORD(wParam) == EN_CHANGE)
2953 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
2954 sizeof(cfg.username) - 1);
2956 case IDC_RLLUSEREDIT:
2957 if (HIWORD(wParam) == EN_CHANGE)
2958 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
2960 sizeof(cfg.localusername) - 1);
2964 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
2968 cfg.passive_telnet =
2969 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
2972 if (HIWORD(wParam) == BN_CLICKED ||
2973 HIWORD(wParam) == BN_DOUBLECLICKED) {
2974 char str[sizeof(cfg.environmt)];
2976 GetDlgItemText(hwnd, IDC_VAREDIT, str,
2982 p = str + strlen(str);
2984 GetDlgItemText(hwnd, IDC_VALEDIT, p,
2985 sizeof(str) - 1 - (p - str));
2996 if ((p - cfg.environmt) + strlen(str) + 2 <
2997 sizeof(cfg.environmt)) {
2999 p[strlen(str) + 1] = '\0';
3000 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
3002 SetDlgItemText(hwnd, IDC_VAREDIT, "");
3003 SetDlgItemText(hwnd, IDC_VALEDIT, "");
3005 MessageBox(hwnd, "Environment too big",
3006 "PuTTY Error", MB_OK | MB_ICONERROR);
3011 if (HIWORD(wParam) != BN_CLICKED &&
3012 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3014 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
3021 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
3048 if (HIWORD(wParam) == BN_CLICKED ||
3049 HIWORD(wParam) == BN_DOUBLECLICKED)
3050 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
3053 if (HIWORD(wParam) == BN_CLICKED ||
3054 HIWORD(wParam) == BN_DOUBLECLICKED)
3056 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
3059 if (HIWORD(wParam) == BN_CLICKED ||
3060 HIWORD(wParam) == BN_DOUBLECLICKED)
3062 IsDlgButtonChecked(hwnd, IDC_BUGGYMAC);
3065 if (HIWORD(wParam) == BN_CLICKED ||
3066 HIWORD(wParam) == BN_DOUBLECLICKED)
3068 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
3071 if (HIWORD(wParam) == BN_CLICKED ||
3072 HIWORD(wParam) == BN_DOUBLECLICKED)
3074 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
3076 case IDC_CHANGEUSER:
3077 if (HIWORD(wParam) == BN_CLICKED ||
3078 HIWORD(wParam) == BN_DOUBLECLICKED)
3079 cfg.change_username =
3080 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
3082 case IDC_CIPHERLIST:
3085 handle_prefslist(&cipherlist,
3086 cfg.ssh_cipherlist, CIPHER_MAX,
3087 0, hwnd, wParam, lParam);
3091 if (HIWORD(wParam) == BN_CLICKED ||
3092 HIWORD(wParam) == BN_DOUBLECLICKED) {
3093 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
3095 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
3100 if (HIWORD(wParam) == BN_CLICKED ||
3101 HIWORD(wParam) == BN_DOUBLECLICKED)
3103 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
3106 if (HIWORD(wParam) == BN_CLICKED ||
3107 HIWORD(wParam) == BN_DOUBLECLICKED)
3109 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
3112 if (HIWORD(wParam) == EN_CHANGE)
3113 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
3114 sizeof(cfg.keyfile) - 1);
3117 if (HIWORD(wParam) == EN_CHANGE)
3118 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
3119 sizeof(cfg.remote_cmd) - 1);
3122 memset(&of, 0, sizeof(of));
3123 #ifdef OPENFILENAME_SIZE_VERSION_400
3124 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3126 of.lStructSize = sizeof(of);
3128 of.hwndOwner = hwnd;
3129 of.lpstrFilter = "All Files\0*\0\0\0";
3130 of.lpstrCustomFilter = NULL;
3131 of.nFilterIndex = 1;
3132 of.lpstrFile = filename;
3133 strcpy(filename, cfg.keyfile);
3134 of.nMaxFile = sizeof(filename);
3135 of.lpstrFileTitle = NULL;
3136 of.lpstrInitialDir = NULL;
3137 of.lpstrTitle = "Select Private Key File";
3139 if (GetOpenFileName(&of)) {
3140 strcpy(cfg.keyfile, filename);
3141 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
3145 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
3148 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
3152 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
3154 case IDC_SELTYPELEX:
3155 case IDC_SELTYPERECT:
3156 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
3158 case IDC_MOUSEOVERRIDE:
3159 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
3165 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
3170 for (i = 0; i < 128; i++)
3171 if (SendDlgItemMessage
3172 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
3174 cfg.wordness[i] = n;
3175 SendDlgItemMessage(hwnd, IDC_CCLIST,
3176 LB_DELETESTRING, i, 0);
3177 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
3178 (i >= 0x21 && i != 0x7F) ? i : ' ',
3180 SendDlgItemMessage(hwnd, IDC_CCLIST,
3187 case IDC_BOLDCOLOUR:
3188 if (HIWORD(wParam) == BN_CLICKED ||
3189 HIWORD(wParam) == BN_DOUBLECLICKED) {
3192 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
3193 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3196 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3198 if (n != 12 + 10 * cfg.bold_colour) {
3199 for (i = n; i-- > 0;)
3200 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3201 LB_DELETESTRING, i, 0);
3202 for (i = 0; i < 22; i++)
3203 if (cfg.bold_colour || permcolour[i])
3204 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3206 (LPARAM) colours[i]);
3208 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3210 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
3215 if (HIWORD(wParam) == BN_CLICKED ||
3216 HIWORD(wParam) == BN_DOUBLECLICKED)
3218 IsDlgButtonChecked(hwnd, IDC_PALETTE);
3220 case IDC_COLOURLIST:
3221 if (HIWORD(wParam) == LBN_DBLCLK ||
3222 HIWORD(wParam) == LBN_SELCHANGE) {
3224 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3227 if (!cfg.bold_colour)
3228 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3229 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3231 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3233 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3238 if (HIWORD(wParam) == BN_CLICKED ||
3239 HIWORD(wParam) == BN_DOUBLECLICKED) {
3240 static CHOOSECOLOR cc;
3241 static DWORD custom[16] = { 0 }; /* zero initialisers */
3243 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3246 if (!cfg.bold_colour)
3247 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3248 cc.lStructSize = sizeof(cc);
3249 cc.hwndOwner = hwnd;
3250 cc.hInstance = (HWND) hinst;
3251 cc.lpCustColors = custom;
3253 RGB(cfg.colours[i][0], cfg.colours[i][1],
3255 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
3256 if (ChooseColor(&cc)) {
3258 (unsigned char) (cc.rgbResult & 0xFF);
3260 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
3262 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
3263 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3265 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3267 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3273 if (HIWORD(wParam) == CBN_SELCHANGE) {
3274 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
3275 CB_GETCURSEL, 0, 0);
3276 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
3277 index, (LPARAM)cfg.line_codepage);
3278 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3279 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
3280 sizeof(cfg.line_codepage) - 1);
3281 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
3282 strcpy(cfg.line_codepage,
3283 cp_name(decode_codepage(cfg.line_codepage)));
3284 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
3288 if (HIWORD(wParam) == CBN_SELCHANGE) {
3289 int index = SendDlgItemMessage(hwnd, IDC_PRINTER,
3290 CB_GETCURSEL, 0, 0);
3291 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_GETLBTEXT,
3292 index, (LPARAM)cfg.printer);
3293 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3294 GetDlgItemText(hwnd, IDC_PRINTER, cfg.printer,
3295 sizeof(cfg.printer) - 1);
3297 if (!strcmp(cfg.printer, PRINTER_DISABLED_STRING))
3298 *cfg.printer = '\0';
3300 case IDC_CAPSLOCKCYR:
3301 if (HIWORD(wParam) == BN_CLICKED ||
3302 HIWORD(wParam) == BN_DOUBLECLICKED) {
3303 cfg.xlat_capslockcyr =
3304 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3307 case IDC_VTXWINDOWS:
3313 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3314 : IsDlgButtonChecked(hwnd,
3315 IDC_VTOEMANSI) ? VT_OEMANSI :
3316 IsDlgButtonChecked(hwnd,
3317 IDC_VTOEMONLY) ? VT_OEMONLY :
3318 IsDlgButtonChecked(hwnd,
3319 IDC_VTUNICODE) ? VT_UNICODE :
3322 case IDC_X11_FORWARD:
3323 if (HIWORD(wParam) == BN_CLICKED ||
3324 HIWORD(wParam) == BN_DOUBLECLICKED)
3326 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3329 if (HIWORD(wParam) == BN_CLICKED ||
3330 HIWORD(wParam) == BN_DOUBLECLICKED)
3331 cfg.lport_acceptall =
3332 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3335 if (HIWORD(wParam) == BN_CLICKED ||
3336 HIWORD(wParam) == BN_DOUBLECLICKED)
3337 cfg.rport_acceptall =
3338 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3340 case IDC_X11_DISPLAY:
3341 if (HIWORD(wParam) == EN_CHANGE)
3342 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3343 sizeof(cfg.x11_display) - 1);
3346 if (HIWORD(wParam) == BN_CLICKED ||
3347 HIWORD(wParam) == BN_DOUBLECLICKED) {
3348 char str[sizeof(cfg.portfwd)];
3350 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3354 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3358 "You need to specify a source port number",
3359 "PuTTY Error", MB_OK | MB_ICONERROR);
3362 p = str + strlen(str);
3364 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3365 sizeof(str) - 1 - (p - str));
3366 if (!*p || !strchr(p, ':')) {
3368 "You need to specify a destination address\n"
3369 "in the form \"host.name:port\"",
3370 "PuTTY Error", MB_OK | MB_ICONERROR);
3379 if ((p - cfg.portfwd) + strlen(str) + 2 <
3380 sizeof(cfg.portfwd)) {
3382 p[strlen(str) + 1] = '\0';
3383 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3385 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3386 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3388 MessageBox(hwnd, "Too many forwardings",
3389 "PuTTY Error", MB_OK | MB_ICONERROR);
3393 case IDC_PFWDREMOVE:
3394 if (HIWORD(wParam) != BN_CLICKED &&
3395 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3396 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3397 LB_GETCURSEL, 0, 0);
3403 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3433 int id = ((LPHELPINFO)lParam)->iCtrlId;
3434 char *cmd = help_context_cmd(id);
3436 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3437 requested_help = TRUE;
3444 if (requested_help) {
3445 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3446 requested_help = FALSE;
3451 /* Grrr Explorer will maximize Dialogs! */
3453 if (wParam == SIZE_MAXIMIZED)
3459 * Handle application-defined messages eg. DragListBox
3461 /* First find out what the number is (once). */
3462 if (draglistmsg == WM_NULL)
3463 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3465 if (msg == draglistmsg) {
3466 /* Only process once dialog is fully formed. */
3467 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3468 case IDC_CIPHERLIST:
3469 return handle_prefslist(&cipherlist,
3470 cfg.ssh_cipherlist, CIPHER_MAX,
3471 1, hwnd, wParam, lParam);
3480 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3481 WPARAM wParam, LPARAM lParam)
3483 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3485 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3486 EnableWindow(hwnd, 0);
3487 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3488 EnableWindow(hwnd, 1);
3489 SetActiveWindow(hwnd);
3491 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3494 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3495 WPARAM wParam, LPARAM lParam)
3497 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3500 void defuse_showwindow(void)
3503 * Work around the fact that the app's first call to ShowWindow
3504 * will ignore the default in favour of the shell-provided
3509 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3511 ShowWindow(hwnd, SW_HIDE);
3512 SetActiveWindow(hwnd);
3513 DestroyWindow(hwnd);
3522 savedsession[0] = '\0';
3524 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3525 get_sesslist(FALSE);
3530 int do_reconfig(HWND hwnd)
3535 backup_cfg = cfg; /* structure copy */
3537 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3539 cfg = backup_cfg; /* structure copy */
3544 void logevent(char *string)
3549 if (nevents >= negsize) {
3551 events = srealloc(events, negsize * sizeof(*events));
3555 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3558 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3559 strcpy(events[nevents], timebuf);
3560 strcat(events[nevents], string);
3563 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3564 0, (LPARAM) events[nevents]);
3565 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3566 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3571 void showeventlog(HWND hwnd)
3574 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3576 ShowWindow(logbox, SW_SHOWNORMAL);
3578 SetActiveWindow(logbox);
3581 void showabout(HWND hwnd)
3583 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3586 void verify_ssh_host_key(char *host, int port, char *keytype,
3587 char *keystr, char *fingerprint)
3591 static const char absentmsg[] =
3592 "The server's host key is not cached in the registry. You\n"
3593 "have no guarantee that the server is the computer you\n"
3595 "The server's key fingerprint is:\n"
3597 "If you trust this host, hit Yes to add the key to\n"
3598 "PuTTY's cache and carry on connecting.\n"
3599 "If you want to carry on connecting just once, without\n"
3600 "adding the key to the cache, hit No.\n"
3601 "If you do not trust this host, hit Cancel to abandon the\n"
3604 static const char wrongmsg[] =
3605 "WARNING - POTENTIAL SECURITY BREACH!\n"
3607 "The server's host key does not match the one PuTTY has\n"
3608 "cached in the registry. This means that either the\n"
3609 "server administrator has changed the host key, or you\n"
3610 "have actually connected to another computer pretending\n"
3611 "to be the server.\n"
3612 "The new key fingerprint is:\n"
3614 "If you were expecting this change and trust the new key,\n"
3615 "hit Yes to update PuTTY's cache and continue connecting.\n"
3616 "If you want to carry on connecting but without updating\n"
3617 "the cache, hit No.\n"
3618 "If you want to abandon the connection completely, hit\n"
3619 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3621 static const char mbtitle[] = "PuTTY Security Alert";
3624 /* sensible fingerprint max size */
3625 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3626 sizeof(absentmsg) : sizeof(wrongmsg))];
3629 * Verify the key against the registry.
3631 ret = verify_host_key(host, port, keytype, keystr);
3633 if (ret == 0) /* success - key matched OK */
3635 if (ret == 2) { /* key was different */
3637 sprintf(message, wrongmsg, fingerprint);
3638 mbret = MessageBox(NULL, message, mbtitle,
3639 MB_ICONWARNING | MB_YESNOCANCEL);
3641 store_host_key(host, port, keytype, keystr);
3642 if (mbret == IDCANCEL)
3645 if (ret == 1) { /* key was absent */
3647 sprintf(message, absentmsg, fingerprint);
3648 mbret = MessageBox(NULL, message, mbtitle,
3649 MB_ICONWARNING | MB_YESNOCANCEL);
3651 store_host_key(host, port, keytype, keystr);
3652 if (mbret == IDCANCEL)
3658 * Ask whether the selected cipher is acceptable (since it was
3659 * below the configured 'warn' threshold).
3660 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3662 void askcipher(char *ciphername, int cs)
3664 static const char mbtitle[] = "PuTTY Security Alert";
3665 static const char msg[] =
3666 "The first %.35scipher supported by the server\n"
3667 "is %.64s, which is below the configured\n"
3668 "warning threshold.\n"
3669 "Do you want to continue with this connection?\n";
3670 /* guessed cipher name + type max length */
3671 char message[100 + sizeof(msg)];
3674 sprintf(message, msg,
3676 (cs == 1) ? "client-to-server " :
3677 "server-to-client ",
3679 mbret = MessageBox(NULL, message, mbtitle,
3680 MB_ICONWARNING | MB_YESNO);
3688 * Ask whether to wipe a session log file before writing to it.
3689 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3691 int askappend(char *filename)
3693 static const char mbtitle[] = "PuTTY Log to File";
3694 static const char msgtemplate[] =
3695 "The session log file \"%.*s\" already exists.\n"
3696 "You can overwrite it with a new session log,\n"
3697 "append your session log to the end of it,\n"
3698 "or disable session logging for this session.\n"
3699 "Hit Yes to wipe the file, No to append to it,\n"
3700 "or Cancel to disable logging.";
3701 char message[sizeof(msgtemplate) + FILENAME_MAX];
3703 if (cfg.logxfovr != LGXF_ASK) {
3704 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
3706 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3708 mbret = MessageBox(NULL, message, mbtitle,
3709 MB_ICONQUESTION | MB_YESNOCANCEL);
3712 else if (mbret == IDNO)
3719 * Warn about the obsolescent key file format.
3721 void old_keyfile_warning(void)
3723 static const char mbtitle[] = "PuTTY Key File Warning";
3724 static const char message[] =
3725 "You are loading an SSH 2 private key which has an\n"
3726 "old version of the file format. This means your key\n"
3727 "file is not fully tamperproof. Future versions of\n"
3728 "PuTTY may stop supporting this private key format,\n"
3729 "so we recommend you convert your key to the new\n"
3732 "You can perform this conversion by loading the key\n"
3733 "into PuTTYgen and then saving it again.";
3735 MessageBox(NULL, message, mbtitle, MB_OK);