13 static char **events = NULL;
14 static int nevents = 0, negsize = 0;
18 void force_normal(HWND hwnd)
20 static int recurse = 0;
27 wp.length = sizeof(wp);
28 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED)
30 wp.showCmd = SW_SHOWNORMAL;
31 SetWindowPlacement(hwnd, &wp);
36 static void MyGetDlgItemInt (HWND hwnd, int id, int *result) {
39 n = GetDlgItemInt (hwnd, id, &ok, FALSE);
44 static int CALLBACK LogProc (HWND hwnd, UINT msg,
45 WPARAM wParam, LPARAM lParam) {
50 for (i=0; i<nevents; i++)
51 SendDlgItemMessage (hwnd, IDN_LIST, LB_ADDSTRING,
52 0, (LPARAM)events[i]);
55 switch (LOWORD(wParam)) {
59 SetActiveWindow(GetParent(hwnd));
63 if (HIWORD(wParam) == BN_CLICKED ||
64 HIWORD(wParam) == BN_DOUBLECLICKED) {
67 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
68 LB_GETSELCOUNT, 0, 0);
69 selitems = smalloc(selcount * sizeof(int));
71 int count = SendDlgItemMessage(hwnd, IDN_LIST,
73 selcount, (LPARAM)selitems);
77 static unsigned char sel_nl[] = SEL_NL;
79 if (count == 0) { /* can't copy zero stuff */
85 for (i = 0; i < count; i++)
86 size += strlen(events[selitems[i]]) + sizeof(sel_nl);
88 clipdata = smalloc(size);
91 for (i = 0; i < count; i++) {
92 char *q = events[selitems[i]];
96 memcpy(p, sel_nl, sizeof(sel_nl));
99 write_clip(clipdata, size, TRUE);
104 for (i = 0; i < nevents; i++)
105 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
114 SetActiveWindow(GetParent(hwnd));
115 DestroyWindow (hwnd);
121 static int CALLBACK LicenceProc (HWND hwnd, UINT msg,
122 WPARAM wParam, LPARAM lParam) {
127 switch (LOWORD(wParam)) {
140 static int CALLBACK AboutProc (HWND hwnd, UINT msg,
141 WPARAM wParam, LPARAM lParam) {
144 SetDlgItemText (hwnd, IDA_VERSION, ver);
147 switch (LOWORD(wParam)) {
150 EndDialog(hwnd, TRUE);
153 EnableWindow(hwnd, 0);
154 DialogBox (hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
156 EnableWindow(hwnd, 1);
157 SetActiveWindow(hwnd);
162 EndDialog(hwnd, TRUE);
169 * Null dialog procedure.
171 static int CALLBACK NullDlgProc (HWND hwnd, UINT msg,
172 WPARAM wParam, LPARAM lParam) {
176 static char savedsession[2048];
178 enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
284 appearancepanelstart,
285 IDC_TITLE_APPEARANCE,
303 connectionpanelstart,
304 IDC_TITLE_CONNECTION,
399 translationpanelstart,
400 IDC_TITLE_TRANSLATION,
401 IDC_BOX_TRANSLATION1,
402 IDC_BOX_TRANSLATION2,
403 IDC_BOX_TRANSLATION3,
428 static const char *const colours[] = {
429 "Default Foreground", "Default Bold Foreground",
430 "Default Background", "Default Bold Background",
431 "Cursor Text", "Cursor Colour",
432 "ANSI Black", "ANSI Black Bold",
433 "ANSI Red", "ANSI Red Bold",
434 "ANSI Green", "ANSI Green Bold",
435 "ANSI Yellow", "ANSI Yellow Bold",
436 "ANSI Blue", "ANSI Blue Bold",
437 "ANSI Magenta", "ANSI Magenta Bold",
438 "ANSI Cyan", "ANSI Cyan Bold",
439 "ANSI White", "ANSI White Bold"
441 static const int permcolour[] = {
442 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
443 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
444 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
447 static void fmtfont (char *buf) {
448 sprintf (buf, "Font: %s, ", cfg.font);
450 strcat(buf, "bold, ");
451 if (cfg.fontheight == 0)
452 strcat (buf, "default height");
454 sprintf (buf+strlen(buf), "%d-%s",
455 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight),
456 (cfg.fontheight < 0 ? "pixel" : "point"));
459 static void init_dlg_ctrls(HWND hwnd) {
461 char fontstatic[256];
463 SetDlgItemText (hwnd, IDC_HOST, cfg.host);
464 SetDlgItemText (hwnd, IDC_SESSEDIT, savedsession);
467 n = SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
469 SendDlgItemMessage (hwnd, IDC_SESSLIST,
470 LB_DELETESTRING, i, 0);
471 for (i = 0; i < nsessions; i++)
472 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
473 0, (LPARAM) (sessions[i]));
475 SetDlgItemInt (hwnd, IDC_PORT, cfg.port, FALSE);
476 CheckRadioButton (hwnd, IDC_PROTRAW, IDC_PROTSSH,
477 cfg.protocol==PROT_SSH ? IDC_PROTSSH :
478 cfg.protocol==PROT_TELNET ? IDC_PROTTELNET :
479 cfg.protocol==PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW );
480 SetDlgItemInt (hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
482 CheckRadioButton (hwnd, IDC_DEL008, IDC_DEL127,
483 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
484 CheckRadioButton (hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
485 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
486 CheckRadioButton (hwnd, IDC_FUNCTILDE, IDC_FUNCVT400,
487 cfg.funky_type == 0 ? IDC_FUNCTILDE :
488 cfg.funky_type == 1 ? IDC_FUNCLINUX :
489 cfg.funky_type == 2 ? IDC_FUNCXTERM :
490 cfg.funky_type == 3 ? IDC_FUNCVT400 :
492 CheckDlgButton (hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
493 CheckDlgButton (hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
494 CheckRadioButton (hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
495 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
496 CheckRadioButton (hwnd, IDC_KPNORMAL, IDC_KPNH,
497 cfg.nethack_keypad ? IDC_KPNH :
498 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
499 CheckDlgButton (hwnd, IDC_ALTF4, cfg.alt_f4);
500 CheckDlgButton (hwnd, IDC_ALTSPACE, cfg.alt_space);
501 CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only);
502 CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key);
503 CheckRadioButton (hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
504 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND:
505 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
506 CheckRadioButton (hwnd, IDC_EDITBACKEND, IDC_EDITNO,
507 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND:
508 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
509 CheckDlgButton (hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
510 CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
511 CheckDlgButton (hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
513 CheckDlgButton (hwnd, IDC_WRAPMODE, cfg.wrap_mode);
514 CheckDlgButton (hwnd, IDC_DECOM, cfg.dec_om);
515 CheckDlgButton (hwnd, IDC_LFHASCR, cfg.lfhascr);
516 SetDlgItemInt (hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
517 SetDlgItemInt (hwnd, IDC_COLSEDIT, cfg.width, FALSE);
518 SetDlgItemInt (hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
519 fmtfont (fontstatic);
520 SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
521 CheckDlgButton (hwnd, IDC_BEEP, cfg.beep);
522 CheckDlgButton (hwnd, IDC_BCE, cfg.bce);
523 CheckDlgButton (hwnd, IDC_BLINKTEXT, cfg.blinktext);
525 SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle);
526 CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always);
527 CheckDlgButton (hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
528 CheckRadioButton (hwnd, IDC_CURBLOCK, IDC_CURVERT,
529 cfg.cursor_type==0 ? IDC_CURBLOCK :
530 cfg.cursor_type==1 ? IDC_CURUNDER : IDC_CURVERT);
531 CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur);
532 CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar);
533 CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize);
534 CheckDlgButton (hwnd, IDC_CLOSEEXIT, cfg.close_on_exit);
535 CheckDlgButton (hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
537 SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
538 SetDlgItemText (hwnd, IDC_TSEDIT, cfg.termspeed);
539 SetDlgItemText (hwnd, IDC_R_TSEDIT, cfg.termspeed);
540 SetDlgItemText (hwnd, IDC_RLLUSEREDIT, cfg.localusername);
541 SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
542 SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename);
543 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATRAW,
544 cfg.logtype == 0 ? IDC_LSTATOFF :
545 cfg.logtype == 1 ? IDC_LSTATASCII :
548 char *p = cfg.environmt;
550 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
555 CheckRadioButton (hwnd, IDC_EMBSD, IDC_EMRFC,
556 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
558 SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
559 SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
560 CheckDlgButton (hwnd, IDC_NOPTY, cfg.nopty);
561 CheckDlgButton (hwnd, IDC_COMPRESS, cfg.compression);
562 CheckDlgButton (hwnd, IDC_BUGGYMAC, cfg.buggymac);
563 CheckDlgButton (hwnd, IDC_AGENTFWD, cfg.agentfwd);
564 CheckRadioButton (hwnd, IDC_CIPHER3DES, IDC_CIPHERDES,
565 cfg.cipher == CIPHER_BLOWFISH ? IDC_CIPHERBLOWF :
566 cfg.cipher == CIPHER_DES ? IDC_CIPHERDES :
568 CheckRadioButton (hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
569 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
570 CheckDlgButton (hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
571 SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile);
572 SetDlgItemText (hwnd, IDC_CMDEDIT, cfg.remote_cmd);
574 CheckRadioButton (hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
575 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
577 static int tabs[4] = {25, 61, 96, 128};
578 SendDlgItemMessage (hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
581 for (i=0; i<256; i++) {
583 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
584 (i>=0x21 && i != 0x7F) ? i : ' ',
586 SendDlgItemMessage (hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
590 CheckDlgButton (hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
591 CheckDlgButton (hwnd, IDC_PALETTE, cfg.try_palette);
594 n = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
596 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
597 LB_DELETESTRING, i, 0);
599 if (cfg.bold_colour || permcolour[i])
600 SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
601 (LPARAM) colours[i]);
603 SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
604 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
605 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
606 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
608 CheckRadioButton (hwnd, IDC_NOXLAT, IDC_88592CP852,
609 cfg.xlat_88592w1250 ? IDC_88592WIN1250 :
610 cfg.xlat_88592cp852 ? IDC_88592CP852 :
611 cfg.xlat_enablekoiwin ? IDC_KOI8WIN1251 :
613 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
614 CheckRadioButton (hwnd, IDC_VTXWINDOWS, IDC_VTPOORMAN,
615 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
616 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
617 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
620 CheckDlgButton (hwnd, IDC_X11_FORWARD, cfg.x11_forward);
621 SetDlgItemText (hwnd, IDC_X11_DISPLAY, cfg.x11_display);
624 struct treeview_faff {
629 static HTREEITEM treeview_insert(struct treeview_faff *faff,
630 int level, char *text) {
634 ins.hParent = (level > 0 ? faff->lastat[level-1] : TVI_ROOT);
635 ins.hInsertAfter = faff->lastat[level];
636 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
637 #define INSITEM DUMMYUNIONNAME.item
641 ins.INSITEM.mask = TVIF_TEXT;
642 ins.INSITEM.pszText = text;
643 newitem = TreeView_InsertItem(faff->treeview, &ins);
645 TreeView_Expand(faff->treeview, faff->lastat[level-1], TVE_EXPAND);
646 faff->lastat[level] = newitem;
647 for (i = level+1; i < 4; i++) faff->lastat[i] = NULL;
652 * Create the panelfuls of controls in the configuration box.
654 static void create_controls(HWND hwnd, int dlgtype, int panel) {
655 if (panel == sessionpanelstart) {
656 /* The Session panel. Accelerators used: [acgo] nprtih elsd x */
658 ctlposinit(&cp, hwnd, 80, 3, 13);
659 bartitle(&cp, "Basic options for your PuTTY session",
662 beginbox(&cp, "Specify your connection by host name",
665 "Host &Name", IDC_HOSTSTATIC, IDC_HOST, 75,
666 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
667 if (backends[3].backend == NULL) {
668 /* this is PuTTYtel, so only three protocols available */
669 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
671 "&Telnet", IDC_PROTTELNET,
672 "Rlog&in", IDC_PROTRLOGIN, NULL);
674 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
676 "&Telnet", IDC_PROTTELNET,
677 "Rlog&in", IDC_PROTRLOGIN,
686 beginbox(&cp, "Load, save or delete a stored session",
688 sesssaver(&cp, "Sav&ed Sessions",
689 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
690 "&Load", IDC_SESSLOAD,
691 "&Save", IDC_SESSSAVE,
692 "&Delete", IDC_SESSDEL, NULL);
695 beginbox(&cp, NULL, IDC_BOX_SESSION3);
696 checkbox(&cp, "Close Window on E&xit", IDC_CLOSEEXIT);
700 if (panel == loggingpanelstart) {
701 /* The Logging panel. Accelerators used: [acgo] tplfw */
703 ctlposinit(&cp, hwnd, 80, 3, 13);
704 bartitle(&cp, "Options controlling session logging",
706 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
708 "Session logging:", IDC_LSTATSTATIC,
709 "Logging &turned off completely", IDC_LSTATOFF,
710 "Log &printable output only", IDC_LSTATASCII,
711 "&Log all session output", IDC_LSTATRAW, NULL);
712 editbutton(&cp, "Log &file name:",
713 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
718 if (panel == terminalpanelstart) {
719 /* The Terminal panel. Accelerators used: [acgo] wdlben ht */
721 ctlposinit(&cp, hwnd, 80, 3, 13);
722 bartitle(&cp, "Options controlling the terminal emulation",
724 beginbox(&cp, "Set various terminal options",
726 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
727 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
728 checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
729 checkbox(&cp, "&Beep enabled", IDC_BEEP);
730 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
731 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
734 beginbox(&cp, "Line discipline options",
736 radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
737 "Auto", IDC_ECHOBACKEND,
738 "Force on", IDC_ECHOYES,
739 "Force off", IDC_ECHONO, NULL);
740 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
741 "Auto", IDC_EDITBACKEND,
742 "Force on", IDC_EDITYES,
743 "Force off", IDC_EDITNO, NULL);
747 if (panel == keyboardpanelstart) {
748 /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxv unpymie t */
750 ctlposinit(&cp, hwnd, 80, 3, 13);
751 bartitle(&cp, "Options controlling the effects of keys",
753 beginbox(&cp, "Change the sequences sent by:",
755 radioline(&cp, "The Backspace key", IDC_DELSTATIC, 2,
756 "Control-&H", IDC_DEL008,
757 "Control-&? (127)", IDC_DEL127, NULL);
758 radioline(&cp, "The Home and End keys", IDC_HOMESTATIC, 2,
759 "&Standard", IDC_HOMETILDE,
760 "&rxvt", IDC_HOMERXVT, NULL);
761 radioline(&cp, "The Function keys and keypad", IDC_FUNCSTATIC, 4,
762 "ESC[n&~", IDC_FUNCTILDE,
763 "&Linux", IDC_FUNCLINUX,
764 "&Xterm R6", IDC_FUNCXTERM,
765 "&VT400", IDC_FUNCVT400, NULL);
767 beginbox(&cp, "Application keypad settings:",
770 "Application c&ursor keys totally disabled",
772 radioline(&cp, "Initial state of cursor keys:", IDC_CURSTATIC, 2,
773 "&Normal", IDC_CURNORMAL,
774 "A&pplication", IDC_CURAPPLIC, NULL);
776 "Application ke&ypad keys totally disabled",
778 radioline(&cp, "Initial state of numeric keypad:", IDC_KPSTATIC, 3,
779 "Nor&mal", IDC_KPNORMAL,
780 "Appl&ication", IDC_KPAPPLIC,
781 "N&etHack", IDC_KPNH, NULL);
783 beginbox(&cp, "Enable extra keyboard features:",
785 checkbox(&cp, "Application and AltGr ac&t as Compose key",
790 if (panel == windowpanelstart) {
791 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
793 ctlposinit(&cp, hwnd, 80, 3, 13);
794 bartitle(&cp, "Options controlling PuTTY's window",
796 beginbox(&cp, "Set the size of the window",
799 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
800 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50,
802 checkbox(&cp, "Lock window size against resi&zing", IDC_LOCKSIZE);
804 beginbox(&cp, "Control the scrollback in the window",
806 staticedit(&cp, "Lines of &scrollback",
807 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
808 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
809 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
810 checkbox(&cp, "Reset scrollback on dis&play activity",
813 beginbox(&cp, NULL, IDC_BOX_WINDOW3);
814 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
815 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
816 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
817 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
818 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
822 if (panel == appearancepanelstart) {
823 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
825 ctlposinit(&cp, hwnd, 80, 3, 13);
826 bartitle(&cp, "Options controlling PuTTY's appearance",
827 IDC_TITLE_APPEARANCE);
828 beginbox(&cp, "Adjust the use of the cursor",
829 IDC_BOX_APPEARANCE1);
830 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
831 "B&lock", IDC_CURBLOCK,
832 "&Underline", IDC_CURUNDER,
833 "&Vertical line", IDC_CURVERT,
835 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
837 beginbox(&cp, "Set the font used in the terminal window",
838 IDC_BOX_APPEARANCE2);
839 staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT);
841 beginbox(&cp, "Adjust the use of the window title",
842 IDC_BOX_APPEARANCE3);
844 "Window &title:", IDC_WINTITLE,
845 IDC_WINEDIT, 100, NULL);
846 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
848 beginbox(&cp, "Adjust the use of the mouse pointer",
849 IDC_BOX_APPEARANCE4);
850 checkbox(&cp, "Hide mouse &pointer when typing in window",
855 if (panel == translationpanelstart) {
856 /* The Translation panel. Accelerators used: [acgo] xbep t s */
858 ctlposinit(&cp, hwnd, 80, 3, 13);
859 bartitle(&cp, "Options controlling character set translation",
860 IDC_TITLE_TRANSLATION);
861 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
862 IDC_BOX_TRANSLATION1);
864 "Handling of line drawing characters:", IDC_VTSTATIC,
865 "Font has &XWindows encoding", IDC_VTXWINDOWS,
866 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
867 "Use font in O&EM mode only", IDC_VTOEMONLY,
868 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
869 IDC_VTPOORMAN, NULL);
871 beginbox(&cp, "Enable character set translation on received data",
872 IDC_BOX_TRANSLATION2);
874 "Character set &translation:", IDC_XLATSTATIC,
876 "KOI8 / Win-1251", IDC_KOI8WIN1251,
877 "ISO-8859-2 / Win-1250", IDC_88592WIN1250,
878 "ISO-8859-2 / CP852", IDC_88592CP852, NULL);
880 beginbox(&cp, "Enable character set translation on input data",
881 IDC_BOX_TRANSLATION3);
882 checkbox(&cp, "CAP&S LOCK acts as cyrillic switch",
887 if (panel == selectionpanelstart) {
888 /* The Selection panel. Accelerators used: [acgo] wx hst */
890 ctlposinit(&cp, hwnd, 80, 3, 13);
891 bartitle(&cp, "Options controlling copy and paste",
892 IDC_TITLE_SELECTION);
893 beginbox(&cp, "Control which mouse button does which thing",
895 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
896 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
897 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
900 beginbox(&cp, "Control the select-one-word-at-a-time mode",
902 charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
903 "&Set", IDC_CCSET, IDC_CCEDIT,
904 "&to class", IDC_CCSTATIC2);
908 if (panel == colourspanelstart) {
909 /* The Colours panel. Accelerators used: [acgo] blum */
911 ctlposinit(&cp, hwnd, 80, 3, 13);
912 bartitle(&cp, "Options controlling use of colours",
914 beginbox(&cp, "General options for colour usage",
916 checkbox(&cp, "&Bolded text is a different colour", IDC_BOLDCOLOUR);
917 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
919 beginbox(&cp, "Adjust the precise colours PuTTY displays",
921 colouredit(&cp, "Select a colo&ur and then click to modify it:",
922 IDC_COLOURSTATIC, IDC_COLOURLIST,
923 "&Modify...", IDC_CHANGE,
924 "Red:", IDC_RSTATIC, IDC_RVALUE,
925 "Green:", IDC_GSTATIC, IDC_GVALUE,
926 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
930 if (panel == connectionpanelstart) {
931 /* The Connection panel. Accelerators used: [acgo] tuk */
933 ctlposinit(&cp, hwnd, 80, 3, 13);
934 bartitle(&cp, "Options controlling the connection", IDC_TITLE_CONNECTION);
936 beginbox(&cp, "Data to send to the server",
937 IDC_BOX_CONNECTION1);
938 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC, IDC_TTEDIT, 50);
939 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC, IDC_LOGEDIT, 50);
942 beginbox(&cp, "Sending of null packets to keep session active",
943 IDC_BOX_CONNECTION2);
944 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
945 IDC_PINGSTATIC, IDC_PINGEDIT, 25);
949 if (panel == telnetpanelstart) {
950 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
952 ctlposinit(&cp, hwnd, 80, 3, 13);
954 bartitle(&cp, "Options controlling Telnet connections", IDC_TITLE_TELNET);
955 beginbox(&cp, "Data to send to the server",
957 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC, IDC_TSEDIT, 50);
958 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
959 "&Variable", IDC_VARSTATIC, IDC_VAREDIT,
960 "Va&lue", IDC_VALSTATIC, IDC_VALEDIT,
962 "A&dd", IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
964 beginbox(&cp, "Telnet protocol adjustments",
966 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC, 2,
967 "&BSD (commonplace)", IDC_EMBSD,
968 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
973 if (panel == rloginpanelstart) {
974 /* The Rlogin panel. Accelerators used: [acgo] sl */
976 ctlposinit(&cp, hwnd, 80, 3, 13);
978 bartitle(&cp, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN);
979 beginbox(&cp, "Data to send to the server",
981 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC, IDC_R_TSEDIT, 50);
982 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC, IDC_RLLUSEREDIT, 50);
987 if (panel == sshpanelstart) {
988 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bd i */
990 ctlposinit(&cp, hwnd, 80, 3, 13);
992 bartitle(&cp, "Options controlling SSH connections", IDC_TITLE_SSH);
993 beginbox(&cp, "Data to send to the server",
996 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
999 beginbox(&cp, "Authentication options",
1001 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication",
1003 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1004 editbutton(&cp, "Private &key file for authentication:",
1005 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...", IDC_PKBUTTON);
1007 beginbox(&cp, "Protocol options",
1009 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1010 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1011 radioline(&cp, "Preferred SSH protocol version:",
1012 IDC_SSHPROTSTATIC, 2,
1013 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
1014 radioline(&cp, "Preferred encryption algorithm:", IDC_CIPHERSTATIC, 3,
1015 "&3DES", IDC_CIPHER3DES,
1016 "&Blowfish", IDC_CIPHERBLOWF,
1017 "&DES", IDC_CIPHERDES, NULL);
1018 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1024 if (panel == tunnelspanelstart) {
1025 /* The Tunnels panel. Accelerators used: [acgo] ex */
1027 ctlposinit(&cp, hwnd, 80, 3, 13);
1029 bartitle(&cp, "Options controlling SSH tunnelling",
1031 beginbox(&cp, "X11 forwarding options",
1033 checkbox(&cp, "&Enable X11 forwarding",
1035 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1036 IDC_X11_DISPLAY, 50, NULL);
1043 * This function is the configuration box.
1045 static int GenericMainDlgProc (HWND hwnd, UINT msg,
1046 WPARAM wParam, LPARAM lParam,
1049 struct treeview_faff tvfaff;
1052 char filename[sizeof(cfg.keyfile)];
1055 char fontstatic[256];
1057 struct servent * service;
1063 SetWindowLong(hwnd, GWL_USERDATA, 0);
1065 * Centre the window.
1067 { /* centre the window */
1070 hw = GetDesktopWindow();
1071 if (GetWindowRect (hw, &rs) && GetWindowRect (hwnd, &rd))
1072 MoveWindow (hwnd, (rs.right + rs.left + rd.left - rd.right)/2,
1073 (rs.bottom + rs.top + rd.top - rd.bottom)/2,
1074 rd.right-rd.left, rd.bottom-rd.top, TRUE);
1078 * Create the tree view.
1085 r.left = 3; r.right = r.left + 75;
1086 r.top = 3; r.bottom = r.top + 10;
1087 MapDialogRect(hwnd, &r);
1088 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1089 WS_CHILD | WS_VISIBLE,
1091 r.right-r.left, r.bottom-r.top,
1092 hwnd, (HMENU)IDCX_TVSTATIC, hinst, NULL);
1093 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1094 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1096 r.left = 3; r.right = r.left + 75;
1097 r.top = 13; r.bottom = r.top + 206;
1098 MapDialogRect(hwnd, &r);
1099 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1100 WS_CHILD | WS_VISIBLE |
1101 WS_TABSTOP | TVS_HASLINES |
1102 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS |
1103 TVS_LINESATROOT | TVS_SHOWSELALWAYS,
1105 r.right-r.left, r.bottom-r.top,
1106 hwnd, (HMENU)IDCX_TREEVIEW, hinst, NULL);
1107 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1108 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1109 tvfaff.treeview = treeview;
1110 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1114 * Set up the tree view contents.
1116 hsession = treeview_insert(&tvfaff, 0, "Session");
1117 treeview_insert(&tvfaff, 1, "Logging");
1118 treeview_insert(&tvfaff, 0, "Terminal");
1119 treeview_insert(&tvfaff, 1, "Keyboard");
1120 treeview_insert(&tvfaff, 0, "Window");
1121 treeview_insert(&tvfaff, 1, "Appearance");
1122 treeview_insert(&tvfaff, 1, "Translation");
1123 treeview_insert(&tvfaff, 1, "Selection");
1124 treeview_insert(&tvfaff, 1, "Colours");
1125 treeview_insert(&tvfaff, 0, "Connection");
1127 treeview_insert(&tvfaff, 1, "Telnet");
1128 treeview_insert(&tvfaff, 1, "Rlogin");
1129 if (backends[3].backend != NULL) {
1130 treeview_insert(&tvfaff, 1, "SSH");
1131 treeview_insert(&tvfaff, 2, "Tunnels");
1136 * Put the treeview selection on to the Session panel. This
1137 * should also cause creation of the relevant controls.
1139 TreeView_SelectItem(treeview, hsession);
1142 * Set focus into the first available control.
1146 ctl = GetDlgItem(hwnd, IDC_HOST);
1147 if (!ctl) ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1151 SetWindowLong(hwnd, GWL_USERDATA, 1);
1155 * Button release should trigger WM_OK if there was a
1156 * previous double click on the session list.
1160 SendMessage (hwnd, WM_COMMAND, IDOK, 0);
1163 if (LOWORD(wParam) == IDCX_TREEVIEW &&
1164 ((LPNMHDR)lParam)->code == TVN_SELCHANGED) {
1165 HTREEITEM i = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
1170 item.pszText = buffer;
1171 item.cchTextMax = sizeof(buffer);
1172 item.mask = TVIF_TEXT;
1173 TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
1174 for (j = controlstartvalue; j < controlendvalue; j++) {
1175 HWND item = GetDlgItem(hwnd, j);
1177 DestroyWindow(item);
1179 if (!strcmp(buffer, "Session"))
1180 create_controls(hwnd, dlgtype, sessionpanelstart);
1181 if (!strcmp(buffer, "Logging"))
1182 create_controls(hwnd, dlgtype, loggingpanelstart);
1183 if (!strcmp(buffer, "Keyboard"))
1184 create_controls(hwnd, dlgtype, keyboardpanelstart);
1185 if (!strcmp(buffer, "Terminal"))
1186 create_controls(hwnd, dlgtype, terminalpanelstart);
1187 if (!strcmp(buffer, "Window"))
1188 create_controls(hwnd, dlgtype, windowpanelstart);
1189 if (!strcmp(buffer, "Appearance"))
1190 create_controls(hwnd, dlgtype, appearancepanelstart);
1191 if (!strcmp(buffer, "Tunnels"))
1192 create_controls(hwnd, dlgtype, tunnelspanelstart);
1193 if (!strcmp(buffer, "Connection"))
1194 create_controls(hwnd, dlgtype, connectionpanelstart);
1195 if (!strcmp(buffer, "Telnet"))
1196 create_controls(hwnd, dlgtype, telnetpanelstart);
1197 if (!strcmp(buffer, "Rlogin"))
1198 create_controls(hwnd, dlgtype, rloginpanelstart);
1199 if (!strcmp(buffer, "SSH"))
1200 create_controls(hwnd, dlgtype, sshpanelstart);
1201 if (!strcmp(buffer, "Selection"))
1202 create_controls(hwnd, dlgtype, selectionpanelstart);
1203 if (!strcmp(buffer, "Colours"))
1204 create_controls(hwnd, dlgtype, colourspanelstart);
1205 if (!strcmp(buffer, "Translation"))
1206 create_controls(hwnd, dlgtype, translationpanelstart);
1208 init_dlg_ctrls(hwnd);
1210 SetFocus (((LPNMHDR)lParam)->hwndFrom); /* ensure focus stays */
1216 * Only process WM_COMMAND once the dialog is fully formed.
1218 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
1221 EndDialog (hwnd, 1);
1226 EndDialog (hwnd, 0);
1228 case IDC_PROTTELNET:
1229 case IDC_PROTRLOGIN:
1232 if (HIWORD(wParam) == BN_CLICKED ||
1233 HIWORD(wParam) == BN_DOUBLECLICKED) {
1234 int i = IsDlgButtonChecked (hwnd, IDC_PROTSSH);
1235 int j = IsDlgButtonChecked (hwnd, IDC_PROTTELNET);
1236 int k = IsDlgButtonChecked (hwnd, IDC_PROTRLOGIN);
1237 cfg.protocol = i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN : PROT_RAW ;
1238 if ((cfg.protocol == PROT_SSH && cfg.port != 22) ||
1239 (cfg.protocol == PROT_TELNET && cfg.port != 23) ||
1240 (cfg.protocol == PROT_RLOGIN && cfg.port != 513)) {
1241 cfg.port = i ? 22 : j ? 23 : 513;
1242 SetDlgItemInt (hwnd, IDC_PORT, cfg.port, FALSE);
1247 if (HIWORD(wParam) == EN_CHANGE)
1248 GetDlgItemText (hwnd, IDC_HOST, cfg.host,
1249 sizeof(cfg.host)-1);
1252 if (HIWORD(wParam) == EN_CHANGE) {
1253 GetDlgItemText (hwnd, IDC_PORT, portname, 31);
1254 if (isdigit(portname[0]))
1255 MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port);
1257 service = getservbyname(portname, NULL);
1258 if (service) cfg.port = ntohs(service->s_port);
1264 if (HIWORD(wParam) == EN_CHANGE) {
1265 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1267 GetDlgItemText (hwnd, IDC_SESSEDIT,
1268 savedsession, sizeof(savedsession)-1);
1269 savedsession[sizeof(savedsession)-1] = '\0';
1273 if (HIWORD(wParam) == BN_CLICKED ||
1274 HIWORD(wParam) == BN_DOUBLECLICKED) {
1279 GetDlgItemText (hwnd, IDC_SESSEDIT, str, sizeof(str)-1);
1281 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1282 LB_GETCURSEL, 0, 0);
1287 strcpy (str, sessions[n]);
1289 save_settings (str, !!strcmp(str, "Default Settings"), &cfg);
1290 get_sesslist (FALSE);
1291 get_sesslist (TRUE);
1292 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1294 for (i = 0; i < nsessions; i++)
1295 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
1296 0, (LPARAM) (sessions[i]));
1297 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1303 if (LOWORD(wParam) == IDC_SESSLOAD &&
1304 HIWORD(wParam) != BN_CLICKED &&
1305 HIWORD(wParam) != BN_DOUBLECLICKED)
1307 if (LOWORD(wParam) == IDC_SESSLIST &&
1308 HIWORD(wParam) != LBN_DBLCLK)
1311 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1312 LB_GETCURSEL, 0, 0);
1318 isdef = !strcmp(sessions[n], "Default Settings");
1319 load_settings (sessions[n], !isdef, &cfg);
1320 init_dlg_ctrls(hwnd);
1322 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1324 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1326 if (LOWORD(wParam) == IDC_SESSLIST) {
1328 * A double-click on a saved session should
1329 * actually start the session, not just load it.
1330 * Unless it's Default Settings or some other
1331 * host-less set of saved settings.
1340 if (HIWORD(wParam) == BN_CLICKED ||
1341 HIWORD(wParam) == BN_DOUBLECLICKED) {
1342 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1343 LB_GETCURSEL, 0, 0);
1344 if (n == LB_ERR || n == 0) {
1348 del_settings(sessions[n]);
1349 get_sesslist (FALSE);
1350 get_sesslist (TRUE);
1351 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1353 for (i = 0; i < nsessions; i++)
1354 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
1355 0, (LPARAM) (sessions[i]));
1356 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1360 if (HIWORD(wParam) == EN_CHANGE)
1361 MyGetDlgItemInt (hwnd, IDC_PINGEDIT, &cfg.ping_interval);
1365 if (HIWORD(wParam) == BN_CLICKED ||
1366 HIWORD(wParam) == BN_DOUBLECLICKED)
1367 cfg.bksp_is_delete = IsDlgButtonChecked (hwnd, IDC_DEL127);
1371 if (HIWORD(wParam) == BN_CLICKED ||
1372 HIWORD(wParam) == BN_DOUBLECLICKED)
1373 cfg.rxvt_homeend = IsDlgButtonChecked (hwnd, IDC_HOMERXVT);
1376 if (HIWORD(wParam) == BN_CLICKED ||
1377 HIWORD(wParam) == BN_DOUBLECLICKED)
1381 if (HIWORD(wParam) == BN_CLICKED ||
1382 HIWORD(wParam) == BN_DOUBLECLICKED)
1387 if (HIWORD(wParam) == BN_CLICKED ||
1388 HIWORD(wParam) == BN_DOUBLECLICKED)
1389 cfg.funky_type = IsDlgButtonChecked (hwnd, IDC_FUNCLINUX);
1393 if (HIWORD(wParam) == BN_CLICKED ||
1394 HIWORD(wParam) == BN_DOUBLECLICKED) {
1395 cfg.app_keypad = IsDlgButtonChecked (hwnd, IDC_KPAPPLIC);
1396 cfg.nethack_keypad = FALSE;
1400 if (HIWORD(wParam) == BN_CLICKED ||
1401 HIWORD(wParam) == BN_DOUBLECLICKED) {
1402 cfg.app_keypad = FALSE;
1403 cfg.nethack_keypad = TRUE;
1408 if (HIWORD(wParam) == BN_CLICKED ||
1409 HIWORD(wParam) == BN_DOUBLECLICKED)
1410 cfg.app_cursor = IsDlgButtonChecked (hwnd, IDC_CURAPPLIC);
1413 if (HIWORD(wParam) == BN_CLICKED ||
1414 HIWORD(wParam) == BN_DOUBLECLICKED)
1415 cfg.no_applic_c = IsDlgButtonChecked (hwnd, IDC_NOAPPLICC);
1418 if (HIWORD(wParam) == BN_CLICKED ||
1419 HIWORD(wParam) == BN_DOUBLECLICKED)
1420 cfg.no_applic_k = IsDlgButtonChecked (hwnd, IDC_NOAPPLICK);
1423 if (HIWORD(wParam) == BN_CLICKED ||
1424 HIWORD(wParam) == BN_DOUBLECLICKED)
1425 cfg.alt_f4 = IsDlgButtonChecked (hwnd, IDC_ALTF4);
1428 if (HIWORD(wParam) == BN_CLICKED ||
1429 HIWORD(wParam) == BN_DOUBLECLICKED)
1430 cfg.alt_space = IsDlgButtonChecked (hwnd, IDC_ALTSPACE);
1433 if (HIWORD(wParam) == BN_CLICKED ||
1434 HIWORD(wParam) == BN_DOUBLECLICKED)
1435 cfg.alt_only = IsDlgButtonChecked (hwnd, IDC_ALTONLY);
1437 case IDC_ECHOBACKEND:
1440 if (HIWORD(wParam) == BN_CLICKED ||
1441 HIWORD(wParam) == BN_DOUBLECLICKED) {
1442 if (LOWORD(wParam)==IDC_ECHOBACKEND) cfg.localecho=LD_BACKEND;
1443 if (LOWORD(wParam)==IDC_ECHOYES) cfg.localecho=LD_YES;
1444 if (LOWORD(wParam)==IDC_ECHONO) cfg.localecho=LD_NO;
1447 case IDC_EDITBACKEND:
1450 if (HIWORD(wParam) == BN_CLICKED ||
1451 HIWORD(wParam) == BN_DOUBLECLICKED) {
1452 if (LOWORD(wParam)==IDC_EDITBACKEND) cfg.localedit=LD_BACKEND;
1453 if (LOWORD(wParam)==IDC_EDITYES) cfg.localedit=LD_YES;
1454 if (LOWORD(wParam)==IDC_EDITNO) cfg.localedit=LD_NO;
1457 case IDC_ALWAYSONTOP:
1458 if (HIWORD(wParam) == BN_CLICKED ||
1459 HIWORD(wParam) == BN_DOUBLECLICKED)
1460 cfg.alwaysontop = IsDlgButtonChecked (hwnd, IDC_ALWAYSONTOP);
1463 if (HIWORD(wParam) == BN_CLICKED ||
1464 HIWORD(wParam) == BN_DOUBLECLICKED)
1465 cfg.scroll_on_key = IsDlgButtonChecked (hwnd, IDC_SCROLLKEY);
1467 case IDC_SCROLLDISP:
1468 if (HIWORD(wParam) == BN_CLICKED ||
1469 HIWORD(wParam) == BN_DOUBLECLICKED)
1470 cfg.scroll_on_disp = IsDlgButtonChecked (hwnd, IDC_SCROLLDISP);
1472 case IDC_COMPOSEKEY:
1473 if (HIWORD(wParam) == BN_CLICKED ||
1474 HIWORD(wParam) == BN_DOUBLECLICKED)
1475 cfg.compose_key = IsDlgButtonChecked (hwnd, IDC_COMPOSEKEY);
1478 if (HIWORD(wParam) == BN_CLICKED ||
1479 HIWORD(wParam) == BN_DOUBLECLICKED)
1480 cfg.wrap_mode = IsDlgButtonChecked (hwnd, IDC_WRAPMODE);
1483 if (HIWORD(wParam) == BN_CLICKED ||
1484 HIWORD(wParam) == BN_DOUBLECLICKED)
1485 cfg.dec_om = IsDlgButtonChecked (hwnd, IDC_DECOM);
1488 if (HIWORD(wParam) == BN_CLICKED ||
1489 HIWORD(wParam) == BN_DOUBLECLICKED)
1490 cfg.lfhascr = IsDlgButtonChecked (hwnd, IDC_LFHASCR);
1493 if (HIWORD(wParam) == EN_CHANGE)
1494 MyGetDlgItemInt (hwnd, IDC_ROWSEDIT, &cfg.height);
1497 if (HIWORD(wParam) == EN_CHANGE)
1498 MyGetDlgItemInt (hwnd, IDC_COLSEDIT, &cfg.width);
1501 if (HIWORD(wParam) == EN_CHANGE)
1502 MyGetDlgItemInt (hwnd, IDC_SAVEEDIT, &cfg.savelines);
1504 case IDC_CHOOSEFONT:
1505 lf.lfHeight = cfg.fontheight;
1506 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
1507 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
1508 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
1509 lf.lfCharSet = cfg.fontcharset;
1510 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
1511 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1512 lf.lfQuality = DEFAULT_QUALITY;
1513 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
1514 strncpy (lf.lfFaceName, cfg.font, sizeof(lf.lfFaceName)-1);
1515 lf.lfFaceName[sizeof(lf.lfFaceName)-1] = '\0';
1517 cf.lStructSize = sizeof(cf);
1518 cf.hwndOwner = hwnd;
1520 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
1521 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
1523 if (ChooseFont (&cf)) {
1524 strncpy (cfg.font, lf.lfFaceName, sizeof(cfg.font)-1);
1525 cfg.font[sizeof(cfg.font)-1] = '\0';
1526 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
1527 cfg.fontcharset = lf.lfCharSet;
1528 cfg.fontheight = lf.lfHeight;
1529 fmtfont (fontstatic);
1530 SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
1534 if (HIWORD(wParam) == BN_CLICKED ||
1535 HIWORD(wParam) == BN_DOUBLECLICKED)
1536 cfg.beep = IsDlgButtonChecked (hwnd, IDC_BEEP);
1539 if (HIWORD(wParam) == BN_CLICKED ||
1540 HIWORD(wParam) == BN_DOUBLECLICKED)
1541 cfg.blinktext = IsDlgButtonChecked (hwnd, IDC_BLINKTEXT);
1544 if (HIWORD(wParam) == BN_CLICKED ||
1545 HIWORD(wParam) == BN_DOUBLECLICKED)
1546 cfg.bce = IsDlgButtonChecked (hwnd, IDC_BCE);
1549 if (HIWORD(wParam) == BN_CLICKED ||
1550 HIWORD(wParam) == BN_DOUBLECLICKED)
1551 cfg.win_name_always = IsDlgButtonChecked (hwnd, IDC_WINNAME);
1554 if (HIWORD(wParam) == BN_CLICKED ||
1555 HIWORD(wParam) == BN_DOUBLECLICKED)
1556 cfg.hide_mouseptr = IsDlgButtonChecked (hwnd, IDC_HIDEMOUSE);
1559 if (HIWORD(wParam) == BN_CLICKED ||
1560 HIWORD(wParam) == BN_DOUBLECLICKED)
1561 cfg.cursor_type = 0;
1564 if (HIWORD(wParam) == BN_CLICKED ||
1565 HIWORD(wParam) == BN_DOUBLECLICKED)
1566 cfg.cursor_type = 1;
1569 if (HIWORD(wParam) == BN_CLICKED ||
1570 HIWORD(wParam) == BN_DOUBLECLICKED)
1571 cfg.cursor_type = 2;
1574 if (HIWORD(wParam) == BN_CLICKED ||
1575 HIWORD(wParam) == BN_DOUBLECLICKED)
1576 cfg.blink_cur = IsDlgButtonChecked (hwnd, IDC_BLINKCUR);
1579 if (HIWORD(wParam) == BN_CLICKED ||
1580 HIWORD(wParam) == BN_DOUBLECLICKED)
1581 cfg.scrollbar = IsDlgButtonChecked (hwnd, IDC_SCROLLBAR);
1584 if (HIWORD(wParam) == BN_CLICKED ||
1585 HIWORD(wParam) == BN_DOUBLECLICKED)
1586 cfg.locksize = IsDlgButtonChecked (hwnd, IDC_LOCKSIZE);
1589 if (HIWORD(wParam) == EN_CHANGE)
1590 GetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle,
1591 sizeof(cfg.wintitle)-1);
1594 if (HIWORD(wParam) == BN_CLICKED ||
1595 HIWORD(wParam) == BN_DOUBLECLICKED)
1596 cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_CLOSEEXIT);
1599 if (HIWORD(wParam) == BN_CLICKED ||
1600 HIWORD(wParam) == BN_DOUBLECLICKED)
1601 cfg.warn_on_close = IsDlgButtonChecked (hwnd, IDC_CLOSEWARN);
1604 if (HIWORD(wParam) == EN_CHANGE)
1605 GetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype,
1606 sizeof(cfg.termtype)-1);
1609 if (HIWORD(wParam) == EN_CHANGE)
1610 GetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename,
1611 sizeof(cfg.logfilename)-1);
1614 memset(&of, 0, sizeof(of));
1615 #ifdef OPENFILENAME_SIZE_VERSION_400
1616 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
1618 of.lStructSize = sizeof(of);
1620 of.hwndOwner = hwnd;
1621 of.lpstrFilter = "All Files\0*\0\0\0";
1622 of.lpstrCustomFilter = NULL;
1623 of.nFilterIndex = 1;
1624 of.lpstrFile = filename; strcpy(filename, cfg.logfilename);
1625 of.nMaxFile = sizeof(filename);
1626 of.lpstrFileTitle = NULL;
1627 of.lpstrInitialDir = NULL;
1628 of.lpstrTitle = "Select session log file";
1630 if (GetSaveFileName(&of)) {
1631 strcpy(cfg.logfilename, filename);
1632 SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename);
1636 case IDC_LSTATASCII:
1638 if (HIWORD(wParam) == BN_CLICKED ||
1639 HIWORD(wParam) == BN_DOUBLECLICKED) {
1640 if (IsDlgButtonChecked (hwnd, IDC_LSTATOFF)) cfg.logtype = 0;
1641 if (IsDlgButtonChecked (hwnd, IDC_LSTATASCII)) cfg.logtype = 1;
1642 if (IsDlgButtonChecked (hwnd, IDC_LSTATRAW)) cfg.logtype = 2;
1647 if (HIWORD(wParam) == EN_CHANGE)
1648 GetDlgItemText (hwnd, LOWORD(wParam), cfg.termspeed,
1649 sizeof(cfg.termspeed)-1);
1652 if (HIWORD(wParam) == EN_CHANGE)
1653 GetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username,
1654 sizeof(cfg.username)-1);
1656 case IDC_RLLUSEREDIT:
1657 if (HIWORD(wParam) == EN_CHANGE)
1658 GetDlgItemText (hwnd, IDC_RLLUSEREDIT, cfg.localusername,
1659 sizeof(cfg.localusername)-1);
1663 cfg.rfc_environ = IsDlgButtonChecked (hwnd, IDC_EMRFC);
1666 if (HIWORD(wParam) == BN_CLICKED ||
1667 HIWORD(wParam) == BN_DOUBLECLICKED) {
1668 char str[sizeof(cfg.environmt)];
1670 GetDlgItemText (hwnd, IDC_VAREDIT, str, sizeof(str)-1);
1675 p = str + strlen(str);
1677 GetDlgItemText (hwnd, IDC_VALEDIT, p, sizeof(str)-1-(p-str));
1687 if ((p-cfg.environmt) + strlen(str) + 2 < sizeof(cfg.environmt)) {
1689 p[strlen(str)+1] = '\0';
1690 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_ADDSTRING,
1692 SetDlgItemText (hwnd, IDC_VAREDIT, "");
1693 SetDlgItemText (hwnd, IDC_VALEDIT, "");
1695 MessageBox(hwnd, "Environment too big", "PuTTY Error",
1696 MB_OK | MB_ICONERROR);
1701 if (HIWORD(wParam) != BN_CLICKED &&
1702 HIWORD(wParam) != BN_DOUBLECLICKED)
1704 i = SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_GETCURSEL, 0, 0);
1710 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_DELETESTRING,
1735 if (HIWORD(wParam) == BN_CLICKED ||
1736 HIWORD(wParam) == BN_DOUBLECLICKED)
1737 cfg.nopty = IsDlgButtonChecked (hwnd, IDC_NOPTY);
1740 if (HIWORD(wParam) == BN_CLICKED ||
1741 HIWORD(wParam) == BN_DOUBLECLICKED)
1742 cfg.compression = IsDlgButtonChecked (hwnd, IDC_COMPRESS);
1745 if (HIWORD(wParam) == BN_CLICKED ||
1746 HIWORD(wParam) == BN_DOUBLECLICKED)
1747 cfg.buggymac = IsDlgButtonChecked (hwnd, IDC_BUGGYMAC);
1750 if (HIWORD(wParam) == BN_CLICKED ||
1751 HIWORD(wParam) == BN_DOUBLECLICKED)
1752 cfg.agentfwd = IsDlgButtonChecked (hwnd, IDC_AGENTFWD);
1754 case IDC_CIPHER3DES:
1755 case IDC_CIPHERBLOWF:
1757 if (HIWORD(wParam) == BN_CLICKED ||
1758 HIWORD(wParam) == BN_DOUBLECLICKED) {
1759 if (IsDlgButtonChecked (hwnd, IDC_CIPHER3DES))
1760 cfg.cipher = CIPHER_3DES;
1761 else if (IsDlgButtonChecked (hwnd, IDC_CIPHERBLOWF))
1762 cfg.cipher = CIPHER_BLOWFISH;
1763 else if (IsDlgButtonChecked (hwnd, IDC_CIPHERDES))
1764 cfg.cipher = CIPHER_DES;
1769 if (HIWORD(wParam) == BN_CLICKED ||
1770 HIWORD(wParam) == BN_DOUBLECLICKED) {
1771 if (IsDlgButtonChecked (hwnd, IDC_SSHPROT1))
1773 else if (IsDlgButtonChecked (hwnd, IDC_SSHPROT2))
1778 if (HIWORD(wParam) == BN_CLICKED ||
1779 HIWORD(wParam) == BN_DOUBLECLICKED)
1780 cfg.try_tis_auth = IsDlgButtonChecked (hwnd, IDC_AUTHTIS);
1783 if (HIWORD(wParam) == EN_CHANGE)
1784 GetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile,
1785 sizeof(cfg.keyfile)-1);
1788 if (HIWORD(wParam) == EN_CHANGE)
1789 GetDlgItemText (hwnd, IDC_CMDEDIT, cfg.remote_cmd,
1790 sizeof(cfg.remote_cmd)-1);
1793 memset(&of, 0, sizeof(of));
1794 #ifdef OPENFILENAME_SIZE_VERSION_400
1795 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
1797 of.lStructSize = sizeof(of);
1799 of.hwndOwner = hwnd;
1800 of.lpstrFilter = "All Files\0*\0\0\0";
1801 of.lpstrCustomFilter = NULL;
1802 of.nFilterIndex = 1;
1803 of.lpstrFile = filename; strcpy(filename, cfg.keyfile);
1804 of.nMaxFile = sizeof(filename);
1805 of.lpstrFileTitle = NULL;
1806 of.lpstrInitialDir = NULL;
1807 of.lpstrTitle = "Select Public Key File";
1809 if (GetOpenFileName(&of)) {
1810 strcpy(cfg.keyfile, filename);
1811 SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile);
1816 cfg.mouse_is_xterm = IsDlgButtonChecked (hwnd, IDC_MBXTERM);
1822 int n = GetDlgItemInt (hwnd, IDC_CCEDIT, &ok, FALSE);
1827 for (i=0; i<256; i++)
1828 if (SendDlgItemMessage (hwnd, IDC_CCLIST, LB_GETSEL,
1831 cfg.wordness[i] = n;
1832 SendDlgItemMessage (hwnd, IDC_CCLIST,
1833 LB_DELETESTRING, i, 0);
1834 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1835 (i>=0x21 && i != 0x7F) ? i : ' ',
1837 SendDlgItemMessage (hwnd, IDC_CCLIST,
1844 case IDC_BOLDCOLOUR:
1845 if (HIWORD(wParam) == BN_CLICKED ||
1846 HIWORD(wParam) == BN_DOUBLECLICKED) {
1848 cfg.bold_colour = IsDlgButtonChecked (hwnd, IDC_BOLDCOLOUR);
1849 n = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1850 if (n != 12+10*cfg.bold_colour) {
1852 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
1853 LB_DELETESTRING, i, 0);
1854 for (i=0; i<22; i++)
1855 if (cfg.bold_colour || permcolour[i])
1856 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
1858 (LPARAM) colours[i]);
1863 if (HIWORD(wParam) == BN_CLICKED ||
1864 HIWORD(wParam) == BN_DOUBLECLICKED)
1865 cfg.try_palette = IsDlgButtonChecked (hwnd, IDC_PALETTE);
1867 case IDC_COLOURLIST:
1868 if (HIWORD(wParam) == LBN_DBLCLK ||
1869 HIWORD(wParam) == LBN_SELCHANGE) {
1870 int i = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCURSEL,
1872 if (!cfg.bold_colour)
1873 i = (i < 3 ? i*2 : i == 3 ? 5 : i*2-2);
1874 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[i][0], FALSE);
1875 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[i][1], FALSE);
1876 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[i][2], FALSE);
1880 if (HIWORD(wParam) == BN_CLICKED ||
1881 HIWORD(wParam) == BN_DOUBLECLICKED) {
1882 static CHOOSECOLOR cc;
1883 static DWORD custom[16] = {0}; /* zero initialisers */
1884 int i = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCURSEL,
1886 if (!cfg.bold_colour)
1887 i = (i < 3 ? i*2 : i == 3 ? 5 : i*2-2);
1888 cc.lStructSize = sizeof(cc);
1889 cc.hwndOwner = hwnd;
1890 cc.hInstance = (HWND)hinst;
1891 cc.lpCustColors = custom;
1892 cc.rgbResult = RGB (cfg.colours[i][0], cfg.colours[i][1],
1894 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
1895 if (ChooseColor(&cc)) {
1897 (unsigned char) (cc.rgbResult & 0xFF);
1899 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
1901 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
1902 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[i][0],
1904 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[i][1],
1906 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[i][2],
1912 case IDC_KOI8WIN1251:
1913 case IDC_88592WIN1250:
1914 case IDC_88592CP852:
1915 cfg.xlat_enablekoiwin =
1916 IsDlgButtonChecked (hwnd, IDC_KOI8WIN1251);
1917 cfg.xlat_88592w1250 =
1918 IsDlgButtonChecked (hwnd, IDC_88592WIN1250);
1919 cfg.xlat_88592cp852 =
1920 IsDlgButtonChecked (hwnd, IDC_88592CP852);
1922 case IDC_CAPSLOCKCYR:
1923 if (HIWORD(wParam) == BN_CLICKED ||
1924 HIWORD(wParam) == BN_DOUBLECLICKED) {
1925 cfg.xlat_capslockcyr =
1926 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
1929 case IDC_VTXWINDOWS:
1934 (IsDlgButtonChecked (hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS :
1935 IsDlgButtonChecked (hwnd, IDC_VTOEMANSI) ? VT_OEMANSI :
1936 IsDlgButtonChecked (hwnd, IDC_VTOEMONLY) ? VT_OEMONLY :
1939 case IDC_X11_FORWARD:
1940 if (HIWORD(wParam) == BN_CLICKED ||
1941 HIWORD(wParam) == BN_DOUBLECLICKED)
1942 cfg.x11_forward = IsDlgButtonChecked (hwnd, IDC_X11_FORWARD);
1944 case IDC_X11_DISPLAY:
1945 if (HIWORD(wParam) == EN_CHANGE)
1946 GetDlgItemText (hwnd, IDC_X11_DISPLAY, cfg.x11_display,
1947 sizeof(cfg.x11_display)-1);
1952 EndDialog (hwnd, 0);
1955 /* Grrr Explorer will maximize Dialogs! */
1957 if (wParam == SIZE_MAXIMIZED)
1964 static int CALLBACK MainDlgProc (HWND hwnd, UINT msg,
1965 WPARAM wParam, LPARAM lParam) {
1966 static HWND page = NULL;
1968 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
1970 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
1971 EnableWindow(hwnd, 0);
1972 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
1973 GetParent(hwnd), AboutProc);
1974 EnableWindow(hwnd, 1);
1975 SetActiveWindow(hwnd);
1977 return GenericMainDlgProc (hwnd, msg, wParam, lParam, 0);
1980 static int CALLBACK ReconfDlgProc (HWND hwnd, UINT msg,
1981 WPARAM wParam, LPARAM lParam) {
1983 return GenericMainDlgProc (hwnd, msg, wParam, lParam, 1);
1986 void defuse_showwindow(void) {
1988 * Work around the fact that the app's first call to ShowWindow
1989 * will ignore the default in favour of the shell-provided
1994 hwnd = CreateDialog (hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
1996 ShowWindow(hwnd, SW_HIDE);
1997 DestroyWindow(hwnd);
2001 int do_config (void) {
2005 savedsession[0] = '\0';
2006 ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
2007 get_sesslist(FALSE);
2012 int do_reconfig (HWND hwnd) {
2016 backup_cfg = cfg; /* structure copy */
2017 ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
2019 cfg = backup_cfg; /* structure copy */
2024 void logevent (char *string) {
2025 if (nevents >= negsize) {
2027 events = srealloc (events, negsize * sizeof(*events));
2029 events[nevents] = smalloc(1+strlen(string));
2030 strcpy (events[nevents], string);
2034 SendDlgItemMessage (logbox, IDN_LIST, LB_ADDSTRING,
2036 count = SendDlgItemMessage (logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
2037 SendDlgItemMessage (logbox, IDN_LIST, LB_SETTOPINDEX, count-1, 0);
2041 void showeventlog (HWND hwnd) {
2043 logbox = CreateDialog (hinst, MAKEINTRESOURCE(IDD_LOGBOX),
2045 ShowWindow (logbox, SW_SHOWNORMAL);
2047 SetActiveWindow(logbox);
2050 void showabout (HWND hwnd) {
2051 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),hwnd, AboutProc);
2054 void verify_ssh_host_key(char *host, int port, char *keytype,
2055 char *keystr, char *fingerprint) {
2058 static const char absentmsg[] =
2059 "The server's host key is not cached in the registry. You\n"
2060 "have no guarantee that the server is the computer you\n"
2062 "The server's key fingerprint is:\n"
2064 "If you trust this host, hit Yes to add the key to\n"
2065 "PuTTY's cache and carry on connecting.\n"
2066 "If you do not trust this host, hit No to abandon the\n"
2069 static const char wrongmsg[] =
2070 "WARNING - POTENTIAL SECURITY BREACH!\n"
2072 "The server's host key does not match the one PuTTY has\n"
2073 "cached in the registry. This means that either the\n"
2074 "server administrator has changed the host key, or you\n"
2075 "have actually connected to another computer pretending\n"
2076 "to be the server.\n"
2077 "The new key fingerprint is:\n"
2079 "If you were expecting this change and trust the new key,\n"
2080 "hit Yes to update PuTTY's cache and continue connecting.\n"
2081 "If you want to carry on connecting but without updating\n"
2082 "the cache, hit No.\n"
2083 "If you want to abandon the connection completely, hit\n"
2084 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2087 static const char mbtitle[] = "PuTTY Security Alert";
2090 char message[160+ /* sensible fingerprint max size */
2091 (sizeof(absentmsg) > sizeof(wrongmsg) ?
2092 sizeof(absentmsg) : sizeof(wrongmsg))];
2095 * Verify the key against the registry.
2097 ret = verify_host_key(host, port, keytype, keystr);
2099 if (ret == 0) /* success - key matched OK */
2101 if (ret == 2) { /* key was different */
2103 sprintf(message, wrongmsg, fingerprint);
2104 mbret = MessageBox(NULL, message, mbtitle,
2105 MB_ICONWARNING | MB_YESNOCANCEL);
2107 store_host_key(host, port, keytype, keystr);
2108 if (mbret == IDCANCEL)
2111 if (ret == 1) { /* key was absent */
2113 sprintf(message, absentmsg, fingerprint);
2114 mbret = MessageBox(NULL, message, mbtitle,
2115 MB_ICONWARNING | MB_YESNO);
2118 store_host_key(host, port, keytype, keystr);
2123 * Ask whether to wipe a session log file before writing to it.
2124 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2126 int askappend(char *filename) {
2127 static const char mbtitle[] = "PuTTY Log to File";
2128 static const char msgtemplate[] =
2129 "The session log file \"%.*s\" already exists.\n"
2130 "You can overwrite it with a new session log,\n"
2131 "append your session log to the end of it,\n"
2132 "or disable session logging for this session.\n"
2133 "Hit Yes to wipe the file, No to append to it,\n"
2134 "or Cancel to disable logging.";
2135 char message[sizeof(msgtemplate) + FILENAME_MAX];
2137 sprintf(message, msgtemplate, FILENAME_MAX, filename);
2139 mbret = MessageBox(NULL, message, mbtitle,
2140 MB_ICONQUESTION | MB_YESNOCANCEL);
2143 else if (mbret == IDNO)