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
)) {
62 if (HIWORD(wParam
) == BN_CLICKED
||
63 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
66 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
67 LB_GETSELCOUNT
, 0, 0);
68 selitems
= smalloc(selcount
* sizeof(int));
70 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
72 selcount
, (LPARAM
)selitems
);
76 static unsigned char sel_nl
[] = SEL_NL
;
78 if (count
== 0) { /* can't copy zero stuff */
84 for (i
= 0; i
< count
; i
++)
85 size
+= strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
87 clipdata
= smalloc(size
);
90 for (i
= 0; i
< count
; i
++) {
91 char *q
= events
[selitems
[i
]];
95 memcpy(p
, sel_nl
, sizeof(sel_nl
));
98 write_clip(clipdata
, size
, TRUE
);
103 for (i
= 0; i
< nevents
; i
++)
104 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
113 DestroyWindow (hwnd
);
119 static int CALLBACK
LicenceProc (HWND hwnd
, UINT msg
,
120 WPARAM wParam
, LPARAM lParam
) {
125 switch (LOWORD(wParam
)) {
138 static int CALLBACK
AboutProc (HWND hwnd
, UINT msg
,
139 WPARAM wParam
, LPARAM lParam
) {
142 SetDlgItemText (hwnd
, IDA_VERSION
, ver
);
145 switch (LOWORD(wParam
)) {
148 EndDialog(hwnd
, TRUE
);
151 EnableWindow(hwnd
, 0);
152 DialogBox (hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
154 EnableWindow(hwnd
, 1);
155 SetActiveWindow(hwnd
);
160 EndDialog(hwnd
, TRUE
);
167 * Null dialog procedure.
169 static int CALLBACK
NullDlgProc (HWND hwnd
, UINT msg
,
170 WPARAM wParam
, LPARAM lParam
) {
174 static char savedsession
[2048];
176 enum { IDCX_ABOUT
= IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
271 appearancepanelstart
,
272 IDC_TITLE_APPEARANCE
,
290 connectionpanelstart
,
291 IDC_TITLE_CONNECTION
,
386 translationpanelstart
,
387 IDC_TITLE_TRANSLATION
,
388 IDC_BOX_TRANSLATION1
,
389 IDC_BOX_TRANSLATION2
,
390 IDC_BOX_TRANSLATION3
,
415 static const char *const colours
[] = {
416 "Default Foreground", "Default Bold Foreground",
417 "Default Background", "Default Bold Background",
418 "Cursor Text", "Cursor Colour",
419 "ANSI Black", "ANSI Black Bold",
420 "ANSI Red", "ANSI Red Bold",
421 "ANSI Green", "ANSI Green Bold",
422 "ANSI Yellow", "ANSI Yellow Bold",
423 "ANSI Blue", "ANSI Blue Bold",
424 "ANSI Magenta", "ANSI Magenta Bold",
425 "ANSI Cyan", "ANSI Cyan Bold",
426 "ANSI White", "ANSI White Bold"
428 static const int permcolour
[] = {
429 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
430 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
431 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
434 static void fmtfont (char *buf
) {
435 sprintf (buf
, "Font: %s, ", cfg
.font
);
437 strcat(buf
, "bold, ");
438 if (cfg
.fontheight
== 0)
439 strcat (buf
, "default height");
441 sprintf (buf
+strlen(buf
), "%d-%s",
442 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
),
443 (cfg
.fontheight
< 0 ?
"pixel" : "point"));
446 static void init_dlg_ctrls(HWND hwnd
) {
448 char fontstatic
[256];
450 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
451 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
454 n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
456 SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
457 LB_DELETESTRING
, i
, 0);
458 for (i
= 0; i
< nsessions
; i
++)
459 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
460 0, (LPARAM
) (sessions
[i
]));
462 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
463 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
464 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
465 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
466 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
467 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
469 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
470 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
471 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
472 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
473 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
474 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
475 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
476 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
477 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
479 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
480 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
481 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
482 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
483 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
484 cfg
.nethack_keypad ? IDC_KPNH
:
485 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
486 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
487 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
488 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
489 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
490 CheckDlgButton (hwnd
, IDC_LDISCTERM
, cfg
.ldisc_term
);
491 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
492 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
493 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
495 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
496 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
497 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
498 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
499 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
500 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
501 fmtfont (fontstatic
);
502 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
503 CheckDlgButton (hwnd
, IDC_BEEP
, cfg
.beep
);
504 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
505 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
507 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
508 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
509 CheckDlgButton (hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
510 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
511 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
512 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
513 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
514 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
515 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
516 CheckDlgButton (hwnd
, IDC_CLOSEEXIT
, cfg
.close_on_exit
);
517 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
519 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
520 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
521 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
522 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
523 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
524 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
525 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
526 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
527 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
530 char *p
= cfg
.environmt
;
532 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
537 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
538 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
540 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
541 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
542 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
543 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
544 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
545 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
546 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERDES
,
547 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
548 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
550 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
551 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
552 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
553 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
554 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
556 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
557 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
559 static int tabs
[4] = {25, 61, 96, 128};
560 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
563 for (i
=0; i
<256; i
++) {
565 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
566 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
568 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
572 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
573 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
576 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
578 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
579 LB_DELETESTRING
, i
, 0);
581 if (cfg
.bold_colour
|| permcolour
[i
])
582 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
583 (LPARAM
) colours
[i
]);
585 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
586 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
587 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
588 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
590 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
591 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
592 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
593 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
595 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
596 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
597 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
598 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
599 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
602 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
603 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
606 struct treeview_faff
{
611 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
612 int level
, char *text
) {
616 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
617 ins
.hInsertAfter
= faff
->lastat
[level
];
618 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
619 #define INSITEM DUMMYUNIONNAME.item
623 ins
.INSITEM
.mask
= TVIF_TEXT
;
624 ins
.INSITEM
.pszText
= text
;
625 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
627 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
628 faff
->lastat
[level
] = newitem
;
629 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
634 * Create the panelfuls of controls in the configuration box.
636 static void create_controls(HWND hwnd
, int dlgtype
, int panel
) {
637 if (panel
== sessionpanelstart
) {
638 /* The Session panel. Accelerators used: [acgo] nprthelsdx */
640 ctlposinit(&cp
, hwnd
, 80, 3, 13);
641 bartitle(&cp
, "Basic options for your PuTTY session",
644 beginbox(&cp
, "Specify your connection by host name",
647 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
648 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
649 if (backends
[3].backend
== NULL
) {
650 /* this is PuTTYtel, so only three protocols available */
651 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
653 "&Telnet", IDC_PROTTELNET
,
654 "R&login", IDC_PROTRLOGIN
, NULL
);
656 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
658 "&Telnet", IDC_PROTTELNET
,
659 "R&login", IDC_PROTRLOGIN
,
668 beginbox(&cp
, "Load, save or delete a stored session",
670 sesssaver(&cp
, "Sav&ed Sessions",
671 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
672 "&Load", IDC_SESSLOAD
,
673 "&Save", IDC_SESSSAVE
,
674 "&Delete", IDC_SESSDEL
, NULL
);
677 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
678 checkbox(&cp
, "Close Window on E&xit", IDC_CLOSEEXIT
);
682 if (panel
== terminalpanelstart
) {
683 /* The Terminal panel. Accelerators used: [acgo] &dflbenuw */
685 ctlposinit(&cp
, hwnd
, 80, 3, 13);
686 bartitle(&cp
, "Options controlling the terminal emulation",
688 beginbox(&cp
, "Set various terminal options",
690 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
691 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
692 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
693 checkbox(&cp
, "&Beep enabled", IDC_BEEP
);
694 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
695 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
696 checkbox(&cp
, "&Use local terminal line discipline", IDC_LDISCTERM
);
699 beginbox(&cp
, "Control session logging",
702 "Session logging:", IDC_LSTATSTATIC
,
703 "Logging turned &off completely", IDC_LSTATOFF
,
704 "Log printable output only", IDC_LSTATASCII
,
705 "Log all session output", IDC_LSTATRAW
, NULL
);
706 editbutton(&cp
, "Log &file name:",
707 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
712 if (panel
== keyboardpanelstart
) {
713 /* The Keyboard panel. Accelerators used: [acgo] h?srvlxvnpmietu */
715 ctlposinit(&cp
, hwnd
, 80, 3, 13);
716 bartitle(&cp
, "Options controlling the effects of keys",
718 beginbox(&cp
, "Change the sequences sent by:",
720 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
721 "Control-&H", IDC_DEL008
,
722 "Control-&? (127)", IDC_DEL127
, NULL
);
723 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
724 "&Standard", IDC_HOMETILDE
,
725 "&rxvt", IDC_HOMERXVT
, NULL
);
726 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
727 "ESC[n&~", IDC_FUNCTILDE
,
728 "&Linux", IDC_FUNCLINUX
,
729 "&Xterm R6", IDC_FUNCXTERM
,
730 "&VT400", IDC_FUNCVT400
, NULL
);
732 beginbox(&cp
, "Application keypad settings:",
735 "Application c&ursor keys totally disabled",
737 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
738 "&Normal", IDC_CURNORMAL
,
739 "A&pplication", IDC_CURAPPLIC
, NULL
);
741 "Application ke&ypad keys totally disabled",
743 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
744 "Nor&mal", IDC_KPNORMAL
,
745 "Appl&ication", IDC_KPAPPLIC
,
746 "N&etHack", IDC_KPNH
, NULL
);
748 beginbox(&cp
, "Enable extra keyboard features:",
750 checkbox(&cp
, "Application and AltGr ac&t as Compose key",
755 if (panel
== windowpanelstart
) {
756 /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */
758 ctlposinit(&cp
, hwnd
, 80, 3, 13);
759 bartitle(&cp
, "Options controlling PuTTY's window",
761 beginbox(&cp
, "Set the size of the window",
764 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
765 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
767 checkbox(&cp
, "Loc&k window size against resizing", IDC_LOCKSIZE
);
769 beginbox(&cp
, "Control the scrollback in the window",
771 staticedit(&cp
, "Lines of &scrollback",
772 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
773 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
774 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
775 checkbox(&cp
, "Reset scrollback on dis&play activity",
778 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
779 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
780 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
781 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
782 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
783 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
787 if (panel
== appearancepanelstart
) {
788 /* The Appearance panel. Accelerators used: [acgo] rmkhtibluv */
790 ctlposinit(&cp
, hwnd
, 80, 3, 13);
791 bartitle(&cp
, "Options controlling PuTTY's appearance",
792 IDC_TITLE_APPEARANCE
);
793 beginbox(&cp
, "Adjust the use of the cursor",
794 IDC_BOX_APPEARANCE1
);
795 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
796 "B&lock", IDC_CURBLOCK
,
797 "&Underline", IDC_CURUNDER
,
798 "&Vertical line", IDC_CURVERT
,
800 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
802 beginbox(&cp
, "Set the font used in the terminal window",
803 IDC_BOX_APPEARANCE2
);
804 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
806 beginbox(&cp
, "Adjust the use of the window title",
807 IDC_BOX_APPEARANCE3
);
809 "Window &title:", IDC_WINTITLE
,
810 IDC_WINEDIT
, 100, NULL
);
811 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
813 beginbox(&cp
, "Adjust the use of the mouse pointer",
814 IDC_BOX_APPEARANCE4
);
815 checkbox(&cp
, "Hide mouse &pointer when typing in window",
820 if (panel
== translationpanelstart
) {
821 /* The Translation panel. Accelerators used: [acgo] xbepnkis */
823 ctlposinit(&cp
, hwnd
, 80, 3, 13);
824 bartitle(&cp
, "Options controlling character set translation",
825 IDC_TITLE_TRANSLATION
);
826 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
827 IDC_BOX_TRANSLATION1
);
829 "Handling of line drawing characters:", IDC_VTSTATIC
,
830 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
831 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
832 "Use font in O&EM mode only", IDC_VTOEMONLY
,
833 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
834 IDC_VTPOORMAN
, NULL
);
836 beginbox(&cp
, "Enable character set translation on received data",
837 IDC_BOX_TRANSLATION2
);
839 "Character set translation:", IDC_XLATSTATIC
,
841 "&KOI8 / Win-1251", IDC_KOI8WIN1251
,
842 "&ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
843 "&ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
845 beginbox(&cp
, "Enable character set translation on input data",
846 IDC_BOX_TRANSLATION3
);
847 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
852 if (panel
== selectionpanelstart
) {
853 /* The Selection panel. Accelerators used: [acgo] wxst */
855 ctlposinit(&cp
, hwnd
, 80, 3, 13);
856 bartitle(&cp
, "Options controlling copy and paste",
857 IDC_TITLE_SELECTION
);
858 beginbox(&cp
, "Control which mouse button does which thing",
860 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
861 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
862 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
865 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
867 charclass(&cp
, "Character classes:", IDC_CCSTATIC
, IDC_CCLIST
,
868 "&Set", IDC_CCSET
, IDC_CCEDIT
,
869 "&to class", IDC_CCSTATIC2
);
873 if (panel
== colourspanelstart
) {
874 /* The Colours panel. Accelerators used: [acgo] blum */
876 ctlposinit(&cp
, hwnd
, 80, 3, 13);
877 bartitle(&cp
, "Options controlling use of colours",
879 beginbox(&cp
, "General options for colour usage",
881 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
882 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
884 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
886 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
887 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
888 "&Modify...", IDC_CHANGE
,
889 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
890 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
891 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
895 if (panel
== connectionpanelstart
) {
896 /* The Connection panel. Accelerators used: [acgo] tuk */
898 ctlposinit(&cp
, hwnd
, 80, 3, 13);
899 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
901 beginbox(&cp
, "Data to send to the server",
902 IDC_BOX_CONNECTION1
);
903 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
904 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
907 beginbox(&cp
, "Sending of null packets to keep session active",
908 IDC_BOX_CONNECTION2
);
909 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
910 IDC_PINGSTATIC
, IDC_PINGEDIT
, 25);
914 if (panel
== telnetpanelstart
) {
915 /* The Telnet panel. Accelerators used: [acgo] svldrbf */
917 ctlposinit(&cp
, hwnd
, 80, 3, 13);
919 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
920 beginbox(&cp
, "Data to send to the server",
922 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
923 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
924 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
925 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
927 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
929 beginbox(&cp
, "Telnet protocol adjustments",
931 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
932 "&BSD (commonplace)", IDC_EMBSD
,
933 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
938 if (panel
== rloginpanelstart
) {
939 /* The Rlogin panel. Accelerators used: [acgo] sl */
941 ctlposinit(&cp
, hwnd
, 80, 3, 13);
943 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
944 beginbox(&cp
, "Data to send to the server",
946 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
947 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
952 if (panel
== sshpanelstart
) {
953 /* The SSH panel. Accelerators used: [acgo] rmakwp123bd */
955 ctlposinit(&cp
, hwnd
, 80, 3, 13);
957 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
958 beginbox(&cp
, "Data to send to the server",
961 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
964 beginbox(&cp
, "Authentication options",
966 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
968 checkbox(&cp
, "Allow &agent forwarding", IDC_AGENTFWD
);
969 editbutton(&cp
, "Private &key file for authentication:",
970 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
972 beginbox(&cp
, "Protocol options",
974 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
975 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
976 radioline(&cp
, "Preferred SSH protocol version:",
977 IDC_SSHPROTSTATIC
, 2,
978 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
979 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 3,
980 "&3DES", IDC_CIPHER3DES
,
981 "&Blowfish", IDC_CIPHERBLOWF
,
982 "&DES", IDC_CIPHERDES
, NULL
);
983 checkbox(&cp
, "Imitate SSH 2 MAC bug in commercial <= v2.3.x",
989 if (panel
== tunnelspanelstart
) {
990 /* The Tunnels panel. Accelerators used: [acgo] ex */
992 ctlposinit(&cp
, hwnd
, 80, 3, 13);
994 bartitle(&cp
, "Options controlling SSH tunnelling",
996 beginbox(&cp
, "X11 forwarding options",
998 checkbox(&cp
, "&Enable X11 forwarding",
1000 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1001 IDC_X11_DISPLAY
, 50, NULL
);
1008 * This function is the configuration box.
1010 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
1011 WPARAM wParam
, LPARAM lParam
,
1014 struct treeview_faff tvfaff
;
1017 char filename
[sizeof(cfg
.keyfile
)];
1020 char fontstatic
[256];
1022 struct servent
* service
;
1028 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1030 * Centre the window.
1032 { /* centre the window */
1035 hw
= GetDesktopWindow();
1036 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
1037 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
1038 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
1039 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
1043 * Create the tree view.
1050 r
.left
= 3; r
.right
= r
.left
+ 75;
1051 r
.top
= 3; r
.bottom
= r
.top
+ 10;
1052 MapDialogRect(hwnd
, &r
);
1053 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1054 WS_CHILD
| WS_VISIBLE
,
1056 r
.right
-r
.left
, r
.bottom
-r
.top
,
1057 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
1058 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1059 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1061 r
.left
= 3; r
.right
= r
.left
+ 75;
1062 r
.top
= 13; r
.bottom
= r
.top
+ 206;
1063 MapDialogRect(hwnd
, &r
);
1064 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1065 WS_CHILD
| WS_VISIBLE
|
1066 WS_TABSTOP
| TVS_HASLINES
|
1067 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
1068 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
1070 r
.right
-r
.left
, r
.bottom
-r
.top
,
1071 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
1072 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1073 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1074 tvfaff
.treeview
= treeview
;
1075 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1079 * Set up the tree view contents.
1081 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1082 treeview_insert(&tvfaff
, 0, "Terminal");
1083 treeview_insert(&tvfaff
, 1, "Keyboard");
1084 treeview_insert(&tvfaff
, 0, "Window");
1085 treeview_insert(&tvfaff
, 1, "Appearance");
1086 treeview_insert(&tvfaff
, 1, "Translation");
1087 treeview_insert(&tvfaff
, 1, "Selection");
1088 treeview_insert(&tvfaff
, 1, "Colours");
1089 treeview_insert(&tvfaff
, 0, "Connection");
1091 treeview_insert(&tvfaff
, 1, "Telnet");
1092 treeview_insert(&tvfaff
, 1, "Rlogin");
1093 if (backends
[3].backend
!= NULL
) {
1094 treeview_insert(&tvfaff
, 1, "SSH");
1095 treeview_insert(&tvfaff
, 2, "Tunnels");
1100 * Put the treeview selection on to the Session panel. This
1101 * should also cause creation of the relevant controls.
1103 TreeView_SelectItem(treeview
, hsession
);
1106 * Set focus into the first available control.
1110 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1111 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1115 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1119 * Button release should trigger WM_OK if there was a
1120 * previous double click on the session list.
1124 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1127 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1128 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1129 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1134 item
.pszText
= buffer
;
1135 item
.cchTextMax
= sizeof(buffer
);
1136 item
.mask
= TVIF_TEXT
;
1137 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1138 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1139 HWND item
= GetDlgItem(hwnd
, j
);
1141 DestroyWindow(item
);
1143 if (!strcmp(buffer
, "Session"))
1144 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1145 if (!strcmp(buffer
, "Keyboard"))
1146 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1147 if (!strcmp(buffer
, "Terminal"))
1148 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1149 if (!strcmp(buffer
, "Window"))
1150 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1151 if (!strcmp(buffer
, "Appearance"))
1152 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1153 if (!strcmp(buffer
, "Tunnels"))
1154 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1155 if (!strcmp(buffer
, "Connection"))
1156 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1157 if (!strcmp(buffer
, "Telnet"))
1158 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1159 if (!strcmp(buffer
, "Rlogin"))
1160 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1161 if (!strcmp(buffer
, "SSH"))
1162 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1163 if (!strcmp(buffer
, "Selection"))
1164 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1165 if (!strcmp(buffer
, "Colours"))
1166 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1167 if (!strcmp(buffer
, "Translation"))
1168 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1170 init_dlg_ctrls(hwnd
);
1172 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1178 * Only process WM_COMMAND once the dialog is fully formed.
1180 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1183 EndDialog (hwnd
, 1);
1188 EndDialog (hwnd
, 0);
1190 case IDC_PROTTELNET
:
1191 case IDC_PROTRLOGIN
:
1194 if (HIWORD(wParam
) == BN_CLICKED
||
1195 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1196 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1197 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1198 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1199 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1200 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1201 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1202 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1203 cfg
.port
= i ?
22 : j ?
23 : 513;
1204 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1209 if (HIWORD(wParam
) == EN_CHANGE
)
1210 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1211 sizeof(cfg
.host
)-1);
1214 if (HIWORD(wParam
) == EN_CHANGE
) {
1215 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1216 if (isdigit(portname
[0]))
1217 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1219 service
= getservbyname(portname
, NULL
);
1220 if (service
) cfg
.port
= ntohs(service
->s_port
);
1226 if (HIWORD(wParam
) == EN_CHANGE
) {
1227 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1229 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1230 savedsession
, sizeof(savedsession
)-1);
1231 savedsession
[sizeof(savedsession
)-1] = '\0';
1235 if (HIWORD(wParam
) == BN_CLICKED
||
1236 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1241 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1243 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1244 LB_GETCURSEL
, 0, 0);
1249 strcpy (str
, sessions
[n
]);
1251 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1252 get_sesslist (FALSE
);
1253 get_sesslist (TRUE
);
1254 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1256 for (i
= 0; i
< nsessions
; i
++)
1257 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1258 0, (LPARAM
) (sessions
[i
]));
1259 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1265 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1266 HIWORD(wParam
) != BN_CLICKED
&&
1267 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1269 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1270 HIWORD(wParam
) != LBN_DBLCLK
)
1273 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1274 LB_GETCURSEL
, 0, 0);
1280 isdef
= !strcmp(sessions
[n
], "Default Settings");
1281 load_settings (sessions
[n
], !isdef
, &cfg
);
1282 init_dlg_ctrls(hwnd
);
1284 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1286 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1288 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1290 * A double-click on a saved session should
1291 * actually start the session, not just load it.
1292 * Unless it's Default Settings or some other
1293 * host-less set of saved settings.
1302 if (HIWORD(wParam
) == BN_CLICKED
||
1303 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1304 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1305 LB_GETCURSEL
, 0, 0);
1306 if (n
== LB_ERR
|| n
== 0) {
1310 del_settings(sessions
[n
]);
1311 get_sesslist (FALSE
);
1312 get_sesslist (TRUE
);
1313 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1315 for (i
= 0; i
< nsessions
; i
++)
1316 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1317 0, (LPARAM
) (sessions
[i
]));
1318 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1322 if (HIWORD(wParam
) == EN_CHANGE
)
1323 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1327 if (HIWORD(wParam
) == BN_CLICKED
||
1328 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1329 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1333 if (HIWORD(wParam
) == BN_CLICKED
||
1334 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1335 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1338 if (HIWORD(wParam
) == BN_CLICKED
||
1339 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1343 if (HIWORD(wParam
) == BN_CLICKED
||
1344 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1349 if (HIWORD(wParam
) == BN_CLICKED
||
1350 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1351 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1355 if (HIWORD(wParam
) == BN_CLICKED
||
1356 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1357 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1358 cfg
.nethack_keypad
= FALSE
;
1362 if (HIWORD(wParam
) == BN_CLICKED
||
1363 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1364 cfg
.app_keypad
= FALSE
;
1365 cfg
.nethack_keypad
= TRUE
;
1370 if (HIWORD(wParam
) == BN_CLICKED
||
1371 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1372 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1375 if (HIWORD(wParam
) == BN_CLICKED
||
1376 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1377 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1380 if (HIWORD(wParam
) == BN_CLICKED
||
1381 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1382 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1385 if (HIWORD(wParam
) == BN_CLICKED
||
1386 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1387 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1390 if (HIWORD(wParam
) == BN_CLICKED
||
1391 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1392 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1395 if (HIWORD(wParam
) == BN_CLICKED
||
1396 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1397 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1400 if (HIWORD(wParam
) == BN_CLICKED
||
1401 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1402 cfg
.ldisc_term
= IsDlgButtonChecked (hwnd
, IDC_LDISCTERM
);
1404 case IDC_ALWAYSONTOP
:
1405 if (HIWORD(wParam
) == BN_CLICKED
||
1406 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1407 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1410 if (HIWORD(wParam
) == BN_CLICKED
||
1411 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1412 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1414 case IDC_SCROLLDISP
:
1415 if (HIWORD(wParam
) == BN_CLICKED
||
1416 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1417 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1419 case IDC_COMPOSEKEY
:
1420 if (HIWORD(wParam
) == BN_CLICKED
||
1421 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1422 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1425 if (HIWORD(wParam
) == BN_CLICKED
||
1426 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1427 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1430 if (HIWORD(wParam
) == BN_CLICKED
||
1431 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1432 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1435 if (HIWORD(wParam
) == BN_CLICKED
||
1436 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1437 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1440 if (HIWORD(wParam
) == EN_CHANGE
)
1441 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1444 if (HIWORD(wParam
) == EN_CHANGE
)
1445 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1448 if (HIWORD(wParam
) == EN_CHANGE
)
1449 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1451 case IDC_CHOOSEFONT
:
1452 lf
.lfHeight
= cfg
.fontheight
;
1453 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1454 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1455 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1456 lf
.lfCharSet
= cfg
.fontcharset
;
1457 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1458 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1459 lf
.lfQuality
= DEFAULT_QUALITY
;
1460 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1461 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1462 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1464 cf
.lStructSize
= sizeof(cf
);
1465 cf
.hwndOwner
= hwnd
;
1467 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1468 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1470 if (ChooseFont (&cf
)) {
1471 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1472 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1473 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1474 cfg
.fontcharset
= lf
.lfCharSet
;
1475 cfg
.fontheight
= lf
.lfHeight
;
1476 fmtfont (fontstatic
);
1477 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1481 if (HIWORD(wParam
) == BN_CLICKED
||
1482 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1483 cfg
.beep
= IsDlgButtonChecked (hwnd
, IDC_BEEP
);
1486 if (HIWORD(wParam
) == BN_CLICKED
||
1487 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1488 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1491 if (HIWORD(wParam
) == BN_CLICKED
||
1492 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1493 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1496 if (HIWORD(wParam
) == BN_CLICKED
||
1497 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1498 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1501 if (HIWORD(wParam
) == BN_CLICKED
||
1502 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1503 cfg
.hide_mouseptr
= IsDlgButtonChecked (hwnd
, IDC_HIDEMOUSE
);
1506 if (HIWORD(wParam
) == BN_CLICKED
||
1507 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1508 cfg
.cursor_type
= 0;
1511 if (HIWORD(wParam
) == BN_CLICKED
||
1512 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1513 cfg
.cursor_type
= 1;
1516 if (HIWORD(wParam
) == BN_CLICKED
||
1517 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1518 cfg
.cursor_type
= 2;
1521 if (HIWORD(wParam
) == BN_CLICKED
||
1522 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1523 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1526 if (HIWORD(wParam
) == BN_CLICKED
||
1527 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1528 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1531 if (HIWORD(wParam
) == BN_CLICKED
||
1532 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1533 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1536 if (HIWORD(wParam
) == EN_CHANGE
)
1537 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1538 sizeof(cfg
.wintitle
)-1);
1541 if (HIWORD(wParam
) == BN_CLICKED
||
1542 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1543 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_CLOSEEXIT
);
1546 if (HIWORD(wParam
) == BN_CLICKED
||
1547 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1548 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1551 if (HIWORD(wParam
) == EN_CHANGE
)
1552 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1553 sizeof(cfg
.termtype
)-1);
1556 if (HIWORD(wParam
) == EN_CHANGE
)
1557 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1558 sizeof(cfg
.logfilename
)-1);
1561 memset(&of
, 0, sizeof(of
));
1562 #ifdef OPENFILENAME_SIZE_VERSION_400
1563 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1565 of
.lStructSize
= sizeof(of
);
1567 of
.hwndOwner
= hwnd
;
1568 of
.lpstrFilter
= "All Files\0*\0\0\0";
1569 of
.lpstrCustomFilter
= NULL
;
1570 of
.nFilterIndex
= 1;
1571 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1572 of
.nMaxFile
= sizeof(filename
);
1573 of
.lpstrFileTitle
= NULL
;
1574 of
.lpstrInitialDir
= NULL
;
1575 of
.lpstrTitle
= "Select session log file";
1577 if (GetSaveFileName(&of
)) {
1578 strcpy(cfg
.keyfile
, filename
);
1579 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.keyfile
);
1583 case IDC_LSTATASCII
:
1585 if (HIWORD(wParam
) == BN_CLICKED
||
1586 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1587 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1588 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1589 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1594 if (HIWORD(wParam
) == EN_CHANGE
)
1595 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1596 sizeof(cfg
.termspeed
)-1);
1599 if (HIWORD(wParam
) == EN_CHANGE
)
1600 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1601 sizeof(cfg
.username
)-1);
1603 case IDC_RLLUSEREDIT
:
1604 if (HIWORD(wParam
) == EN_CHANGE
)
1605 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1606 sizeof(cfg
.localusername
)-1);
1610 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1613 if (HIWORD(wParam
) == BN_CLICKED
||
1614 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1615 char str
[sizeof(cfg
.environmt
)];
1617 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1622 p
= str
+ strlen(str
);
1624 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1634 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1636 p
[strlen(str
)+1] = '\0';
1637 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1639 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1640 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1642 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1643 MB_OK
| MB_ICONERROR
);
1648 if (HIWORD(wParam
) != BN_CLICKED
&&
1649 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1651 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1657 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1682 if (HIWORD(wParam
) == BN_CLICKED
||
1683 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1684 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1687 if (HIWORD(wParam
) == BN_CLICKED
||
1688 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1689 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1692 if (HIWORD(wParam
) == BN_CLICKED
||
1693 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1694 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1697 if (HIWORD(wParam
) == BN_CLICKED
||
1698 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1699 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1701 case IDC_CIPHER3DES
:
1702 case IDC_CIPHERBLOWF
:
1704 if (HIWORD(wParam
) == BN_CLICKED
||
1705 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1706 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1707 cfg
.cipher
= CIPHER_3DES
;
1708 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1709 cfg
.cipher
= CIPHER_BLOWFISH
;
1710 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1711 cfg
.cipher
= CIPHER_DES
;
1716 if (HIWORD(wParam
) == BN_CLICKED
||
1717 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1718 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1720 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1725 if (HIWORD(wParam
) == BN_CLICKED
||
1726 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1727 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1730 if (HIWORD(wParam
) == EN_CHANGE
)
1731 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1732 sizeof(cfg
.keyfile
)-1);
1735 if (HIWORD(wParam
) == EN_CHANGE
)
1736 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1737 sizeof(cfg
.remote_cmd
)-1);
1740 memset(&of
, 0, sizeof(of
));
1741 #ifdef OPENFILENAME_SIZE_VERSION_400
1742 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1744 of
.lStructSize
= sizeof(of
);
1746 of
.hwndOwner
= hwnd
;
1747 of
.lpstrFilter
= "All Files\0*\0\0\0";
1748 of
.lpstrCustomFilter
= NULL
;
1749 of
.nFilterIndex
= 1;
1750 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1751 of
.nMaxFile
= sizeof(filename
);
1752 of
.lpstrFileTitle
= NULL
;
1753 of
.lpstrInitialDir
= NULL
;
1754 of
.lpstrTitle
= "Select Public Key File";
1756 if (GetOpenFileName(&of
)) {
1757 strcpy(cfg
.keyfile
, filename
);
1758 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1763 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
1769 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
1774 for (i
=0; i
<256; i
++)
1775 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
1778 cfg
.wordness
[i
] = n
;
1779 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1780 LB_DELETESTRING
, i
, 0);
1781 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1782 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
1784 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1791 case IDC_BOLDCOLOUR
:
1792 if (HIWORD(wParam
) == BN_CLICKED
||
1793 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1795 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
1796 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1797 if (n
!= 12+10*cfg
.bold_colour
) {
1799 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1800 LB_DELETESTRING
, i
, 0);
1801 for (i
=0; i
<22; i
++)
1802 if (cfg
.bold_colour
|| permcolour
[i
])
1803 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1805 (LPARAM
) colours
[i
]);
1810 if (HIWORD(wParam
) == BN_CLICKED
||
1811 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1812 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
1814 case IDC_COLOURLIST
:
1815 if (HIWORD(wParam
) == LBN_DBLCLK
||
1816 HIWORD(wParam
) == LBN_SELCHANGE
) {
1817 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1819 if (!cfg
.bold_colour
)
1820 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1821 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
1822 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
1823 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
1827 if (HIWORD(wParam
) == BN_CLICKED
||
1828 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1829 static CHOOSECOLOR cc
;
1830 static DWORD custom
[16] = {0}; /* zero initialisers */
1831 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1833 if (!cfg
.bold_colour
)
1834 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1835 cc
.lStructSize
= sizeof(cc
);
1836 cc
.hwndOwner
= hwnd
;
1837 cc
.hInstance
= (HWND
)hinst
;
1838 cc
.lpCustColors
= custom
;
1839 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
1841 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
1842 if (ChooseColor(&cc
)) {
1844 (unsigned char) (cc
.rgbResult
& 0xFF);
1846 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
1848 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
1849 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
1851 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
1853 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
1859 case IDC_KOI8WIN1251
:
1860 case IDC_88592WIN1250
:
1861 case IDC_88592CP852
:
1862 cfg
.xlat_enablekoiwin
=
1863 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
1864 cfg
.xlat_88592w1250
=
1865 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
1866 cfg
.xlat_88592cp852
=
1867 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
1869 case IDC_CAPSLOCKCYR
:
1870 if (HIWORD(wParam
) == BN_CLICKED
||
1871 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1872 cfg
.xlat_capslockcyr
=
1873 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
1876 case IDC_VTXWINDOWS
:
1881 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
1882 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
1883 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
1886 case IDC_X11_FORWARD
:
1887 if (HIWORD(wParam
) == BN_CLICKED
||
1888 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1889 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
1891 case IDC_X11_DISPLAY
:
1892 if (HIWORD(wParam
) == EN_CHANGE
)
1893 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
1894 sizeof(cfg
.x11_display
)-1);
1899 EndDialog (hwnd
, 0);
1902 /* Grrr Explorer will maximize Dialogs! */
1904 if (wParam
== SIZE_MAXIMIZED
)
1911 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
1912 WPARAM wParam
, LPARAM lParam
) {
1913 static HWND page
= NULL
;
1915 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
1917 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
1918 EnableWindow(hwnd
, 0);
1919 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1920 GetParent(hwnd
), AboutProc
);
1921 EnableWindow(hwnd
, 1);
1922 SetActiveWindow(hwnd
);
1924 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
1927 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
1928 WPARAM wParam
, LPARAM lParam
) {
1930 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
1933 void defuse_showwindow(void) {
1935 * Work around the fact that the app's first call to ShowWindow
1936 * will ignore the default in favour of the shell-provided
1941 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1943 ShowWindow(hwnd
, SW_HIDE
);
1944 DestroyWindow(hwnd
);
1948 int do_config (void) {
1952 savedsession
[0] = '\0';
1953 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
1954 get_sesslist(FALSE
);
1959 int do_reconfig (HWND hwnd
) {
1963 backup_cfg
= cfg
; /* structure copy */
1964 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
1966 cfg
= backup_cfg
; /* structure copy */
1971 void logevent (char *string
) {
1972 if (nevents
>= negsize
) {
1974 events
= srealloc (events
, negsize
* sizeof(*events
));
1976 events
[nevents
] = smalloc(1+strlen(string
));
1977 strcpy (events
[nevents
], string
);
1981 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
1983 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
1984 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
1988 void showeventlog (HWND hwnd
) {
1990 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
1992 ShowWindow (logbox
, SW_SHOWNORMAL
);
1996 void showabout (HWND hwnd
) {
1997 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),hwnd
, AboutProc
);
2000 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2001 char *keystr
, char *fingerprint
) {
2004 static const char absentmsg
[] =
2005 "The server's host key is not cached in the registry. You\n"
2006 "have no guarantee that the server is the computer you\n"
2008 "The server's key fingerprint is:\n"
2010 "If you trust this host, hit Yes to add the key to\n"
2011 "PuTTY's cache and carry on connecting.\n"
2012 "If you do not trust this host, hit No to abandon the\n"
2015 static const char wrongmsg
[] =
2016 "WARNING - POTENTIAL SECURITY BREACH!\n"
2018 "The server's host key does not match the one PuTTY has\n"
2019 "cached in the registry. This means that either the\n"
2020 "server administrator has changed the host key, or you\n"
2021 "have actually connected to another computer pretending\n"
2022 "to be the server.\n"
2023 "The new key fingerprint is:\n"
2025 "If you were expecting this change and trust the new key,\n"
2026 "hit Yes to update PuTTY's cache and continue connecting.\n"
2027 "If you want to carry on connecting but without updating\n"
2028 "the cache, hit No.\n"
2029 "If you want to abandon the connection completely, hit\n"
2030 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2033 static const char mbtitle
[] = "PuTTY Security Alert";
2036 char message
[160+ /* sensible fingerprint max size */
2037 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2038 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2041 * Verify the key against the registry.
2043 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2045 if (ret
== 0) /* success - key matched OK */
2047 if (ret
== 2) { /* key was different */
2049 sprintf(message
, wrongmsg
, fingerprint
);
2050 mbret
= MessageBox(NULL
, message
, mbtitle
,
2051 MB_ICONWARNING
| MB_YESNOCANCEL
);
2053 store_host_key(host
, port
, keytype
, keystr
);
2054 if (mbret
== IDCANCEL
)
2057 if (ret
== 1) { /* key was absent */
2059 sprintf(message
, absentmsg
, fingerprint
);
2060 mbret
= MessageBox(NULL
, message
, mbtitle
,
2061 MB_ICONWARNING
| MB_YESNO
);
2064 store_host_key(host
, port
, keytype
, keystr
);
2069 * Ask whether to wipe a session log file before writing to it.
2070 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2072 int askappend(char *filename
) {
2073 static const char mbtitle
[] = "PuTTY Log to File";
2074 static const char msgtemplate
[] =
2075 "The session log file \"%.*s\" already exists.\n"
2076 "You can overwrite it with a new session log,\n"
2077 "append your session log to the end of it,\n"
2078 "or disable session logging for this session.\n"
2079 "Hit Yes to wipe the file, No to append to it,\n"
2080 "or Cancel to disable logging.";
2081 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2083 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2085 mbret
= MessageBox(NULL
, message
, mbtitle
,
2086 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2089 else if (mbret
== IDNO
)