15 static char **events
= NULL
;
16 static int nevents
= 0, negsize
= 0;
19 static int sesslist_has_focus
;
21 static struct prefslist cipherlist
;
23 void force_normal(HWND hwnd
)
25 static int recurse
= 0;
33 wp
.length
= sizeof(wp
);
34 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
) {
35 wp
.showCmd
= SW_SHOWNORMAL
;
36 SetWindowPlacement(hwnd
, &wp
);
41 static void MyGetDlgItemInt(HWND hwnd
, int id
, int *result
)
45 n
= GetDlgItemInt(hwnd
, id
, &ok
, FALSE
);
50 static void MyGetDlgItemFlt(HWND hwnd
, int id
, int *result
, int scale
)
54 ok
= GetDlgItemText(hwnd
, id
, text
, sizeof(text
) - 1);
56 *result
= (int) (scale
* atof(text
));
59 static void MySetDlgItemFlt(HWND hwnd
, int id
, double value
)
62 sprintf(text
, "%g", value
);
63 SetDlgItemText(hwnd
, id
, text
);
66 static int CALLBACK
LogProc(HWND hwnd
, UINT msg
,
67 WPARAM wParam
, LPARAM lParam
)
74 static int tabs
[4] = { 78, 108 };
75 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
78 for (i
= 0; i
< nevents
; i
++)
79 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_ADDSTRING
,
80 0, (LPARAM
) events
[i
]);
83 switch (LOWORD(wParam
)) {
87 SetActiveWindow(GetParent(hwnd
));
91 if (HIWORD(wParam
) == BN_CLICKED
||
92 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
95 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
96 LB_GETSELCOUNT
, 0, 0);
97 if (selcount
== 0) { /* don't even try to copy zero items */
102 selitems
= smalloc(selcount
* sizeof(int));
104 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
111 static unsigned char sel_nl
[] = SEL_NL
;
113 if (count
== 0) { /* can't copy zero stuff */
119 for (i
= 0; i
< count
; i
++)
121 strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
123 clipdata
= smalloc(size
);
126 for (i
= 0; i
< count
; i
++) {
127 char *q
= events
[selitems
[i
]];
128 int qlen
= strlen(q
);
131 memcpy(p
, sel_nl
, sizeof(sel_nl
));
134 write_aclip(clipdata
, size
, TRUE
);
139 for (i
= 0; i
< nevents
; i
++)
140 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
149 SetActiveWindow(GetParent(hwnd
));
156 static int CALLBACK
LicenceProc(HWND hwnd
, UINT msg
,
157 WPARAM wParam
, LPARAM lParam
)
163 switch (LOWORD(wParam
)) {
176 static int CALLBACK
AboutProc(HWND hwnd
, UINT msg
,
177 WPARAM wParam
, LPARAM lParam
)
181 SetDlgItemText(hwnd
, IDA_VERSION
, ver
);
184 switch (LOWORD(wParam
)) {
187 EndDialog(hwnd
, TRUE
);
190 EnableWindow(hwnd
, 0);
191 DialogBox(hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
193 EnableWindow(hwnd
, 1);
194 SetActiveWindow(hwnd
);
198 /* Load web browser */
199 ShellExecute(hwnd
, "open",
200 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
201 0, 0, SW_SHOWDEFAULT
);
206 EndDialog(hwnd
, TRUE
);
213 * Null dialog procedure.
215 static int CALLBACK
NullDlgProc(HWND hwnd
, UINT msg
,
216 WPARAM wParam
, LPARAM lParam
)
221 static char savedsession
[2048];
224 IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
369 appearancepanelstart
,
370 IDC_TITLE_APPEARANCE
,
390 connectionpanelstart
,
391 IDC_TITLE_CONNECTION
,
499 translationpanelstart
,
500 IDC_TITLE_TRANSLATION
,
501 IDC_BOX_TRANSLATION1
,
502 IDC_BOX_TRANSLATION2
,
538 static const char *const colours
[] = {
539 "Default Foreground", "Default Bold Foreground",
540 "Default Background", "Default Bold Background",
541 "Cursor Text", "Cursor Colour",
542 "ANSI Black", "ANSI Black Bold",
543 "ANSI Red", "ANSI Red Bold",
544 "ANSI Green", "ANSI Green Bold",
545 "ANSI Yellow", "ANSI Yellow Bold",
546 "ANSI Blue", "ANSI Blue Bold",
547 "ANSI Magenta", "ANSI Magenta Bold",
548 "ANSI Cyan", "ANSI Cyan Bold",
549 "ANSI White", "ANSI White Bold"
551 static const int permcolour
[] = {
552 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
553 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
554 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
557 static void fmtfont(char *buf
)
559 sprintf(buf
, "Font: %s, ", cfg
.font
);
561 strcat(buf
, "bold, ");
562 if (cfg
.fontheight
== 0)
563 strcat(buf
, "default height");
565 sprintf(buf
+ strlen(buf
), "%d-point",
566 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
569 /* 2nd arg: NZ => don't redraw session list (use when loading
571 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
574 char fontstatic
[256];
576 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
577 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
580 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
581 for (i
= n
; i
-- > 0;)
582 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
583 for (i
= 0; i
< nsessions
; i
++)
584 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
585 0, (LPARAM
) (sessions
[i
]));
587 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
588 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
589 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
590 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
592 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
593 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
595 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
596 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
597 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
598 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
599 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
600 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
601 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
602 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
603 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
604 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
605 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
606 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
607 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
608 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
609 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
610 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
611 cfg
.nethack_keypad ? IDC_KPNH
:
612 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
613 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
614 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
615 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
616 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
617 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
618 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
619 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
620 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
621 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
622 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
623 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
624 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
625 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
626 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
627 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
628 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
630 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
631 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
632 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
633 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
634 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
635 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
637 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
638 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
639 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
640 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
641 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
643 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
644 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
646 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
647 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
648 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
649 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
650 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
651 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
652 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
653 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
655 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
656 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
658 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
659 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
660 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
661 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
662 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
663 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
664 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
665 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
666 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
667 CheckDlgButton(hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
668 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
669 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
671 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
672 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
674 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
675 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
676 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
677 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
678 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
679 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
680 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
681 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
682 cfg
.logtype
== 1 ? IDC_LSTATASCII
: IDC_LSTATRAW
);
683 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
684 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
685 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
688 char *p
= cfg
.environmt
;
689 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
691 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
697 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
702 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
703 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
704 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
705 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
707 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
708 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
709 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
710 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
711 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
712 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
713 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
714 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
715 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
716 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
717 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
721 static const struct { char *s
; int c
; } ciphers
[] = {
722 { "3DES", CIPHER_3DES
},
723 { "Blowfish", CIPHER_BLOWFISH
},
724 { "DES (SSH 1 only)", CIPHER_DES
},
725 { "AES (SSH 2 only)", CIPHER_AES
},
726 { "-- warn below here --", CIPHER_WARN
}
729 /* Set up the "selected ciphers" box. */
730 /* (cipherlist assumed to contain all ciphers) */
731 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
732 for (i
= 0; i
< CIPHER_MAX
; i
++) {
733 int c
= cfg
.ssh_cipherlist
[i
];
736 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
737 if (ciphers
[j
].c
== c
) {
742 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
744 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
751 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
752 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
753 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
754 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
756 static int tabs
[4] = { 25, 61, 96, 128 };
757 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
760 for (i
= 0; i
< 128; i
++) {
762 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
763 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
764 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
768 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
769 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
772 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
773 for (i
= n
; i
-- > 0;)
774 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
775 LB_DELETESTRING
, i
, 0);
776 for (i
= 0; i
< 22; i
++)
777 if (cfg
.bold_colour
|| permcolour
[i
])
778 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
779 (LPARAM
) colours
[i
]);
781 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
782 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
783 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
784 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
789 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
790 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
791 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
792 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
795 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
798 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
799 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
800 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
801 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
802 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
805 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
806 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
808 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
809 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
812 struct treeview_faff
{
817 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
818 int level
, char *text
)
823 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
824 ins
.hInsertAfter
= faff
->lastat
[level
];
825 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
826 #define INSITEM DUMMYUNIONNAME.item
830 ins
.INSITEM
.mask
= TVIF_TEXT
;
831 ins
.INSITEM
.pszText
= text
;
832 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
834 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
836 faff
->lastat
[level
] = newitem
;
837 for (i
= level
+ 1; i
< 4; i
++)
838 faff
->lastat
[i
] = NULL
;
843 * Create the panelfuls of controls in the configuration box.
845 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
847 if (panel
== sessionpanelstart
) {
848 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
850 ctlposinit(&cp
, hwnd
, 80, 3, 13);
851 bartitle(&cp
, "Basic options for your PuTTY session",
854 beginbox(&cp
, "Specify your connection by host name or IP address",
857 "Host &Name (or IP address)",
858 IDC_HOSTSTATIC
, IDC_HOST
, 75,
859 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
860 if (backends
[3].backend
== NULL
) {
861 /* this is PuTTYtel, so only three protocols available */
862 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
864 "&Telnet", IDC_PROTTELNET
,
865 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
867 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
869 "&Telnet", IDC_PROTTELNET
,
870 "Rlog&in", IDC_PROTRLOGIN
,
879 beginbox(&cp
, "Load, save or delete a stored session",
881 sesssaver(&cp
, "Sav&ed Sessions",
882 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
883 "&Load", IDC_SESSLOAD
,
884 "&Save", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
887 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
888 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
889 "Always", IDC_COEALWAYS
,
890 "Never", IDC_COENEVER
,
891 "Only on clean exit", IDC_COENORMAL
, NULL
);
895 if (panel
== loggingpanelstart
) {
896 /* The Logging panel. Accelerators used: [acgo] tplfwe */
898 ctlposinit(&cp
, hwnd
, 80, 3, 13);
899 bartitle(&cp
, "Options controlling session logging",
901 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
903 "Session logging:", IDC_LSTATSTATIC
,
904 "Logging &turned off completely", IDC_LSTATOFF
,
905 "Log &printable output only", IDC_LSTATASCII
,
906 "&Log all session output", IDC_LSTATRAW
, NULL
);
907 editbutton(&cp
, "Log &file name:",
908 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
911 "What to do if the log file already &exists:",
912 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
913 "Always append to the end of it", IDC_LSTATXAPN
,
914 "Ask the user every time", IDC_LSTATXASK
, NULL
);
918 if (panel
== terminalpanelstart
) {
919 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
921 ctlposinit(&cp
, hwnd
, 80, 3, 13);
922 bartitle(&cp
, "Options controlling the terminal emulation",
924 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
925 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
926 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
927 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
928 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
929 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
931 "An&swerback to ^E:", IDC_ANSWERBACK
,
932 IDC_ANSWEREDIT
, 100, NULL
);
935 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
936 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
937 "Auto", IDC_ECHOBACKEND
,
938 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
939 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
940 "Auto", IDC_EDITBACKEND
,
941 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
945 if (panel
== bellpanelstart
) {
946 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
948 ctlposinit(&cp
, hwnd
, 80, 3, 13);
949 bartitle(&cp
, "Options controlling the terminal bell",
951 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
953 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
954 "None (bell disabled)", IDC_BELL_DISABLED
,
955 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
956 "Play a custom sound file", IDC_BELL_WAVEFILE
,
957 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
958 editbutton(&cp
, "Custom sound file to play as a bell:",
959 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
960 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
961 radioline(&cp
, "Taskbar/caption &indication on bell:",
962 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
963 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
966 beginbox(&cp
, "Control the bell overload behaviour",
968 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
970 staticedit(&cp
, "Over-use means this &many bells...",
971 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
972 staticedit(&cp
, "... in &this many seconds",
973 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
975 "The bell is re-enabled after a few seconds of silence.",
977 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
982 if (panel
== keyboardpanelstart
) {
983 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
985 ctlposinit(&cp
, hwnd
, 80, 3, 13);
987 bartitle(&cp, "Options controlling the effects of keys",
990 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
991 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
992 "Control-H", IDC_DEL008
,
993 "Control-? (127)", IDC_DEL127
, NULL
);
994 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
995 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
996 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
997 "ESC[n~", IDC_FUNCTILDE
,
998 "Linux", IDC_FUNCLINUX
,
999 "Xterm R6", IDC_FUNCXTERM
,
1000 "VT400", IDC_FUNCVT400
,
1001 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1003 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1005 "Application c&ursor keys totally disabled",
1007 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1008 "Normal", IDC_CURNORMAL
,
1009 "Application", IDC_CURAPPLIC
, NULL
);
1011 "Application ke&ypad keys totally disabled",
1013 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1014 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1015 "NetHack", IDC_KPNH
, NULL
);
1017 beginbox(&cp
, "Enable extra keyboard features:",
1019 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1020 checkbox(&cp
, "Control-Alt is &different from AltGr",
1025 if (panel
== windowpanelstart
) {
1026 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
1028 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1029 bartitle(&cp
, "Options controlling PuTTY's window",
1031 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1033 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1034 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1035 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
1037 beginbox(&cp
, "Control the scrollback in the window",
1039 staticedit(&cp
, "Lines of &scrollback",
1040 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1041 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1042 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1043 checkbox(&cp
, "Reset scrollback on dis&play activity",
1046 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
1047 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1048 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1049 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1050 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1051 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1055 if (panel
== appearancepanelstart
) {
1056 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1058 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1059 bartitle(&cp
, "Options controlling PuTTY's appearance",
1060 IDC_TITLE_APPEARANCE
);
1061 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1062 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1063 "B&lock", IDC_CURBLOCK
,
1064 "&Underline", IDC_CURUNDER
,
1065 "&Vertical line", IDC_CURVERT
, NULL
);
1066 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1068 beginbox(&cp
, "Set the font used in the terminal window",
1069 IDC_BOX_APPEARANCE2
);
1070 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
1072 beginbox(&cp
, "Adjust the use of the window title",
1073 IDC_BOX_APPEARANCE3
);
1075 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1076 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1078 beginbox(&cp
, "Adjust the use of the mouse pointer",
1079 IDC_BOX_APPEARANCE4
);
1080 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1083 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1084 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1089 if (panel
== translationpanelstart
) {
1090 /* The Translation panel. Accelerators used: [acgo] xbep t s */
1092 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1093 bartitle(&cp
, "Options controlling character set translation",
1094 IDC_TITLE_TRANSLATION
);
1095 beginbox(&cp
, "Character set translation on received data",
1096 IDC_BOX_TRANSLATION2
);
1097 combobox(&cp
, "Received data assumed to be in which character set:",
1098 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1100 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1101 IDC_BOX_TRANSLATION1
);
1103 "Handling of line drawing characters:", IDC_VTSTATIC
,
1104 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1105 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1106 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1107 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1108 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1112 if (panel
== selectionpanelstart
) {
1113 /* The Selection panel. Accelerators used: [acgo] d wxp hst */
1115 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1116 bartitle(&cp
, "Options controlling copy and paste",
1117 IDC_TITLE_SELECTION
);
1118 beginbox(&cp
, "Translation of pasted characters",
1119 IDC_BOX_SELECTION1
);
1121 "&Don't translate line drawing chars into +, - and |",
1124 beginbox(&cp
, "Control which mouse button does which thing",
1125 IDC_BOX_SELECTION2
);
1126 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1127 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1128 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1131 "Shift overrides a&pplication's use of mouse",
1134 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1135 IDC_BOX_SELECTION3
);
1136 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1137 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1138 "&to class", IDC_CCSTATIC2
);
1142 if (panel
== colourspanelstart
) {
1143 /* The Colours panel. Accelerators used: [acgo] blum */
1145 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1146 bartitle(&cp
, "Options controlling use of colours",
1148 beginbox(&cp
, "General options for colour usage",
1150 checkbox(&cp
, "&Bolded text is a different colour",
1152 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1154 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1156 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1157 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1158 "&Modify...", IDC_CHANGE
,
1159 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1160 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1161 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1165 if (panel
== connectionpanelstart
) {
1166 /* The Connection panel. Accelerators used: [acgo] tuk */
1168 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1169 bartitle(&cp
, "Options controlling the connection",
1170 IDC_TITLE_CONNECTION
);
1172 beginbox(&cp
, "Data to send to the server",
1173 IDC_BOX_CONNECTION1
);
1174 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1176 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1180 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1181 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1185 beginbox(&cp
, "Sending of null packets to keep session active",
1186 IDC_BOX_CONNECTION2
);
1187 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1188 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1192 if (panel
== telnetpanelstart
) {
1193 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1195 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1197 bartitle(&cp
, "Options controlling Telnet connections",
1199 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1200 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1202 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1203 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1204 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1205 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1207 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1208 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1209 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1210 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1211 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1212 "Passive", IDC_TPASSIVE
, "Active",
1214 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1220 if (panel
== rloginpanelstart
) {
1221 /* The Rlogin panel. Accelerators used: [acgo] sl */
1223 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1225 bartitle(&cp
, "Options controlling Rlogin connections",
1227 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1228 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1230 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1231 IDC_RLLUSEREDIT
, 50);
1236 if (panel
== sshpanelstart
) {
1237 /* The SSH panel. Accelerators used: [acgo] r pe12i sud */
1239 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1241 bartitle(&cp
, "Options controlling SSH connections",
1243 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1245 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1248 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1249 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1250 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1251 radioline(&cp
, "Preferred SSH protocol version:",
1252 IDC_SSHPROTSTATIC
, 2,
1253 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1254 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1257 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1258 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1259 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1265 if (panel
== sshauthpanelstart
) {
1266 /* The SSH authentication panel. Accelerators used: [acgo] m fkw */
1268 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1270 bartitle(&cp
, "Options controlling SSH authentication",
1272 beginbox(&cp
, "Authentication methods",
1274 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1277 beginbox(&cp
, "Authentication parameters",
1279 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1280 editbutton(&cp
, "Private &key file for authentication:",
1281 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1287 if (panel
== tunnelspanelstart
) {
1288 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1290 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1292 bartitle(&cp
, "Options controlling SSH tunnelling",
1294 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1295 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1296 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1297 IDC_X11_DISPLAY
, 50, NULL
);
1299 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1300 checkbox(&cp
, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL
);
1301 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1302 "&Remove", IDC_PFWDREMOVE
);
1303 fwdsetter(&cp
, IDC_PFWDLIST
,
1304 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1305 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1306 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1307 "A&dd", IDC_PFWDADD
);
1308 bareradioline(&cp
, 2,
1309 "&Local", IDC_PFWDLOCAL
, "Re&mote", IDC_PFWDREMOTE
, NULL
);
1317 * Helper function to load the session selected in SESSLIST
1318 * if any, as this is done in more than one place in
1319 * GenericMainDlgProc(). 0 => failure.
1321 static int load_selected_session(HWND hwnd
)
1323 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1324 LB_GETCURSEL
, 0, 0);
1330 isdef
= !strcmp(sessions
[n
], "Default Settings");
1331 load_settings(sessions
[n
], !isdef
, &cfg
);
1332 init_dlg_ctrls(hwnd
, TRUE
);
1334 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1336 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1337 /* Restore the selection, which will have been clobbered by
1338 * SESSEDIT handling. */
1339 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1344 * This function is the configuration box.
1346 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1347 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1350 struct treeview_faff tvfaff
;
1353 char filename
[sizeof(cfg
.keyfile
)];
1356 char fontstatic
[256];
1358 struct servent
*service
;
1360 static UINT draglistmsg
= WM_NULL
;
1365 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1366 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1367 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1369 * Centre the window.
1371 { /* centre the window */
1374 hw
= GetDesktopWindow();
1375 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1377 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1378 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1379 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1383 * Create the tree view.
1391 r
.right
= r
.left
+ 75;
1393 r
.bottom
= r
.top
+ 10;
1394 MapDialogRect(hwnd
, &r
);
1395 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1396 WS_CHILD
| WS_VISIBLE
,
1398 r
.right
- r
.left
, r
.bottom
- r
.top
,
1399 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1401 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1402 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1405 r
.right
= r
.left
+ 75;
1407 r
.bottom
= r
.top
+ 206;
1408 MapDialogRect(hwnd
, &r
);
1409 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1410 WS_CHILD
| WS_VISIBLE
|
1411 WS_TABSTOP
| TVS_HASLINES
|
1412 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1414 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1415 r
.right
- r
.left
, r
.bottom
- r
.top
,
1416 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1418 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1419 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1420 tvfaff
.treeview
= treeview
;
1421 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1425 * Set up the tree view contents.
1427 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1428 treeview_insert(&tvfaff
, 1, "Logging");
1429 treeview_insert(&tvfaff
, 0, "Terminal");
1430 treeview_insert(&tvfaff
, 1, "Keyboard");
1431 treeview_insert(&tvfaff
, 1, "Bell");
1432 treeview_insert(&tvfaff
, 0, "Window");
1433 treeview_insert(&tvfaff
, 1, "Appearance");
1434 treeview_insert(&tvfaff
, 1, "Translation");
1435 treeview_insert(&tvfaff
, 1, "Selection");
1436 treeview_insert(&tvfaff
, 1, "Colours");
1437 treeview_insert(&tvfaff
, 0, "Connection");
1439 treeview_insert(&tvfaff
, 1, "Telnet");
1440 treeview_insert(&tvfaff
, 1, "Rlogin");
1441 if (backends
[3].backend
!= NULL
) {
1442 treeview_insert(&tvfaff
, 1, "SSH");
1443 /* XXX long name is ugly */
1444 /* XXX make it closed by default? */
1445 treeview_insert(&tvfaff
, 2, "Auth");
1446 treeview_insert(&tvfaff
, 2, "Tunnels");
1451 * Put the treeview selection on to the Session panel. This
1452 * should also cause creation of the relevant controls.
1454 TreeView_SelectItem(treeview
, hsession
);
1457 * Set focus into the first available control.
1461 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1463 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1467 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1468 sesslist_has_focus
= 0;
1472 * Button release should trigger WM_OK if there was a
1473 * previous double click on the session list.
1477 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1480 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1481 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1483 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1488 item
.pszText
= buffer
;
1489 item
.cchTextMax
= sizeof(buffer
);
1490 item
.mask
= TVIF_TEXT
;
1491 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1492 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1493 HWND item
= GetDlgItem(hwnd
, j
);
1495 DestroyWindow(item
);
1497 if (!strcmp(buffer
, "Session"))
1498 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1499 if (!strcmp(buffer
, "Logging"))
1500 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1501 if (!strcmp(buffer
, "Keyboard"))
1502 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1503 if (!strcmp(buffer
, "Terminal"))
1504 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1505 if (!strcmp(buffer
, "Bell"))
1506 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1507 if (!strcmp(buffer
, "Window"))
1508 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1509 if (!strcmp(buffer
, "Appearance"))
1510 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1511 if (!strcmp(buffer
, "Tunnels"))
1512 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1513 if (!strcmp(buffer
, "Connection"))
1514 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1515 if (!strcmp(buffer
, "Telnet"))
1516 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1517 if (!strcmp(buffer
, "Rlogin"))
1518 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1519 if (!strcmp(buffer
, "SSH"))
1520 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1521 if (!strcmp(buffer
, "Auth"))
1522 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
1523 if (!strcmp(buffer
, "Selection"))
1524 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1525 if (!strcmp(buffer
, "Colours"))
1526 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1527 if (!strcmp(buffer
, "Translation"))
1528 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1530 init_dlg_ctrls(hwnd
, FALSE
);
1532 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
1538 * Only process WM_COMMAND once the dialog is fully formed.
1540 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
1541 switch (LOWORD(wParam
)) {
1543 /* Behaviour of the "Open" button is different if the
1544 * session list has focus, *unless* the user just
1545 * double-clicked... */
1546 if (sesslist_has_focus
&& !readytogo
) {
1547 if (!load_selected_session(hwnd
)) {
1552 /* If at this point we have a valid session, go! */
1561 case IDC_PROTTELNET
:
1562 case IDC_PROTRLOGIN
:
1565 if (HIWORD(wParam
) == BN_CLICKED
||
1566 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1567 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
1568 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
1569 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
1571 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
1573 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
1574 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
1575 || (cfg
.protocol
== PROT_RLOGIN
1576 && cfg
.port
!= 513)) {
1577 cfg
.port
= i ?
22 : j ?
23 : 513;
1578 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1583 if (HIWORD(wParam
) == EN_CHANGE
)
1584 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
1585 sizeof(cfg
.host
) - 1);
1588 if (HIWORD(wParam
) == EN_CHANGE
) {
1589 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
1590 if (isdigit(portname
[0]))
1591 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
1593 service
= getservbyname(portname
, NULL
);
1595 cfg
.port
= ntohs(service
->s_port
);
1602 if (HIWORD(wParam
) == EN_CHANGE
) {
1603 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1605 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
1606 savedsession
, sizeof(savedsession
) - 1);
1607 savedsession
[sizeof(savedsession
) - 1] = '\0';
1611 if (HIWORD(wParam
) == BN_CLICKED
||
1612 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1617 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
1620 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1621 LB_GETCURSEL
, 0, 0);
1626 strcpy(str
, sessions
[n
]);
1628 save_settings(str
, !!strcmp(str
, "Default Settings"),
1630 get_sesslist(FALSE
);
1632 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1634 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1636 for (i
= 0; i
< nsessions
; i
++)
1637 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1639 (LPARAM
) (sessions
[i
]));
1640 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1642 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1644 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1650 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1651 if (HIWORD(wParam
) == LBN_SETFOCUS
)
1652 sesslist_has_focus
= 1;
1653 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
1654 sesslist_has_focus
= 0;
1656 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1657 HIWORD(wParam
) != BN_CLICKED
&&
1658 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
1659 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1660 HIWORD(wParam
) != LBN_DBLCLK
) break;
1661 /* Load the session selected in SESSLIST. */
1662 if (load_selected_session(hwnd
) &&
1663 LOWORD(wParam
) == IDC_SESSLIST
) {
1665 * A double-click on a saved session should
1666 * actually start the session, not just load it.
1667 * Unless it's Default Settings or some other
1668 * host-less set of saved settings.
1677 if (HIWORD(wParam
) == BN_CLICKED
||
1678 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1679 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1680 LB_GETCURSEL
, 0, 0);
1681 if (n
== LB_ERR
|| n
== 0) {
1685 del_settings(sessions
[n
]);
1686 get_sesslist(FALSE
);
1688 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1690 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1692 for (i
= 0; i
< nsessions
; i
++)
1693 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1695 (LPARAM
) (sessions
[i
]));
1696 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1698 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1700 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1704 if (HIWORD(wParam
) == EN_CHANGE
)
1705 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
1706 &cfg
.ping_interval
);
1710 if (HIWORD(wParam
) == BN_CLICKED
||
1711 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1712 cfg
.bksp_is_delete
=
1713 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
1717 if (HIWORD(wParam
) == BN_CLICKED
||
1718 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1720 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
1726 case IDC_FUNCVT100P
:
1728 if (HIWORD(wParam
) == BN_CLICKED
||
1729 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1730 switch (LOWORD(wParam
)) {
1743 case IDC_FUNCVT100P
:
1753 if (HIWORD(wParam
) == BN_CLICKED
||
1754 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1756 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
1757 cfg
.nethack_keypad
= FALSE
;
1761 if (HIWORD(wParam
) == BN_CLICKED
||
1762 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1763 cfg
.app_keypad
= FALSE
;
1764 cfg
.nethack_keypad
= TRUE
;
1769 if (HIWORD(wParam
) == BN_CLICKED
||
1770 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1772 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
1775 if (HIWORD(wParam
) == BN_CLICKED
||
1776 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1778 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
1781 if (HIWORD(wParam
) == BN_CLICKED
||
1782 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1784 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
1787 if (HIWORD(wParam
) == BN_CLICKED
||
1788 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1789 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
1792 if (HIWORD(wParam
) == BN_CLICKED
||
1793 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1795 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
1798 if (HIWORD(wParam
) == BN_CLICKED
||
1799 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1801 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
1803 case IDC_ECHOBACKEND
:
1806 if (HIWORD(wParam
) == BN_CLICKED
||
1807 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1808 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
1809 cfg
.localecho
= LD_BACKEND
;
1810 if (LOWORD(wParam
) == IDC_ECHOYES
)
1811 cfg
.localecho
= LD_YES
;
1812 if (LOWORD(wParam
) == IDC_ECHONO
)
1813 cfg
.localecho
= LD_NO
;
1816 case IDC_EDITBACKEND
:
1819 if (HIWORD(wParam
) == BN_CLICKED
||
1820 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1821 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
1822 cfg
.localedit
= LD_BACKEND
;
1823 if (LOWORD(wParam
) == IDC_EDITYES
)
1824 cfg
.localedit
= LD_YES
;
1825 if (LOWORD(wParam
) == IDC_EDITNO
)
1826 cfg
.localedit
= LD_NO
;
1829 case IDC_ANSWEREDIT
:
1830 if (HIWORD(wParam
) == EN_CHANGE
)
1831 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1832 sizeof(cfg
.answerback
) - 1);
1834 case IDC_ALWAYSONTOP
:
1835 if (HIWORD(wParam
) == BN_CLICKED
||
1836 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1838 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
1841 if (HIWORD(wParam
) == BN_CLICKED
||
1842 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1844 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
1846 case IDC_SCROLLDISP
:
1847 if (HIWORD(wParam
) == BN_CLICKED
||
1848 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1849 cfg
.scroll_on_disp
=
1850 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
1852 case IDC_COMPOSEKEY
:
1853 if (HIWORD(wParam
) == BN_CLICKED
||
1854 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1856 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
1858 case IDC_CTRLALTKEYS
:
1859 if (HIWORD(wParam
) == BN_CLICKED
||
1860 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1862 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
1865 if (HIWORD(wParam
) == BN_CLICKED
||
1866 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1867 cfg
.telnet_keyboard
=
1868 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
1871 if (HIWORD(wParam
) == BN_CLICKED
||
1872 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1874 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
1877 if (HIWORD(wParam
) == BN_CLICKED
||
1878 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1879 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
1882 if (HIWORD(wParam
) == BN_CLICKED
||
1883 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1885 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
1888 if (HIWORD(wParam
) == EN_CHANGE
)
1889 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1892 if (HIWORD(wParam
) == EN_CHANGE
)
1893 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1896 if (HIWORD(wParam
) == EN_CHANGE
)
1897 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1899 case IDC_CHOOSEFONT
:
1902 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
1903 GetDeviceCaps(hdc
, LOGPIXELSY
),
1907 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1908 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1909 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1910 lf
.lfCharSet
= cfg
.fontcharset
;
1911 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1912 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1913 lf
.lfQuality
= DEFAULT_QUALITY
;
1914 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1915 strncpy(lf
.lfFaceName
, cfg
.font
,
1916 sizeof(lf
.lfFaceName
) - 1);
1917 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
1919 cf
.lStructSize
= sizeof(cf
);
1920 cf
.hwndOwner
= hwnd
;
1922 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1923 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1925 if (ChooseFont(&cf
)) {
1926 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
1927 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
1928 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1929 cfg
.fontcharset
= lf
.lfCharSet
;
1930 cfg
.fontheight
= cf
.iPointSize
/ 10;
1931 fmtfont(fontstatic
);
1932 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1935 case IDC_BELL_DISABLED
:
1936 case IDC_BELL_DEFAULT
:
1937 case IDC_BELL_WAVEFILE
:
1938 case IDC_BELL_VISUAL
:
1939 if (HIWORD(wParam
) == BN_CLICKED
||
1940 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1941 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
1942 cfg
.beep
= BELL_DISABLED
;
1943 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
1944 cfg
.beep
= BELL_DEFAULT
;
1945 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
1946 cfg
.beep
= BELL_WAVEFILE
;
1947 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
1948 cfg
.beep
= BELL_VISUAL
;
1951 case IDC_B_IND_DISABLED
:
1952 case IDC_B_IND_FLASH
:
1953 case IDC_B_IND_STEADY
:
1954 if (HIWORD(wParam
) == BN_CLICKED
||
1955 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1956 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
1957 cfg
.beep_ind
= B_IND_DISABLED
;
1958 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
1959 cfg
.beep_ind
= B_IND_FLASH
;
1960 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
1961 cfg
.beep_ind
= B_IND_STEADY
;
1964 case IDC_BELL_WAVEBROWSE
:
1965 memset(&of
, 0, sizeof(of
));
1966 #ifdef OPENFILENAME_SIZE_VERSION_400
1967 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1969 of
.lStructSize
= sizeof(of
);
1971 of
.hwndOwner
= hwnd
;
1972 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
1973 of
.lpstrCustomFilter
= NULL
;
1974 of
.nFilterIndex
= 1;
1975 of
.lpstrFile
= filename
;
1976 strcpy(filename
, cfg
.bell_wavefile
);
1977 of
.nMaxFile
= sizeof(filename
);
1978 of
.lpstrFileTitle
= NULL
;
1979 of
.lpstrInitialDir
= NULL
;
1980 of
.lpstrTitle
= "Select Bell Sound File";
1982 if (GetOpenFileName(&of
)) {
1983 strcpy(cfg
.bell_wavefile
, filename
);
1984 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
1988 case IDC_BELL_WAVEEDIT
:
1989 if (HIWORD(wParam
) == EN_CHANGE
)
1990 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
1992 sizeof(cfg
.bell_wavefile
) - 1);
1995 if (HIWORD(wParam
) == BN_CLICKED
||
1996 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1998 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2001 if (HIWORD(wParam
) == EN_CHANGE
)
2002 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2005 if (HIWORD(wParam
) == EN_CHANGE
)
2006 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2010 if (HIWORD(wParam
) == EN_CHANGE
)
2011 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2015 if (HIWORD(wParam
) == BN_CLICKED
||
2016 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2018 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2021 if (HIWORD(wParam
) == BN_CLICKED
||
2022 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2023 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2026 if (HIWORD(wParam
) == BN_CLICKED
||
2027 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2028 cfg
.win_name_always
=
2029 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2032 if (HIWORD(wParam
) == BN_CLICKED
||
2033 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2035 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2037 case IDC_SUNKENEDGE
:
2038 if (HIWORD(wParam
) == BN_CLICKED
||
2039 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2041 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2044 if (HIWORD(wParam
) == BN_CLICKED
||
2045 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2046 cfg
.cursor_type
= 0;
2049 if (HIWORD(wParam
) == BN_CLICKED
||
2050 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2051 cfg
.cursor_type
= 1;
2054 if (HIWORD(wParam
) == BN_CLICKED
||
2055 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2056 cfg
.cursor_type
= 2;
2059 if (HIWORD(wParam
) == BN_CLICKED
||
2060 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2062 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2065 if (HIWORD(wParam
) == BN_CLICKED
||
2066 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2068 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2071 if (HIWORD(wParam
) == BN_CLICKED
||
2072 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2074 IsDlgButtonChecked(hwnd
, IDC_LOCKSIZE
);
2077 if (HIWORD(wParam
) == EN_CHANGE
)
2078 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2079 sizeof(cfg
.wintitle
) - 1);
2084 if (HIWORD(wParam
) == BN_CLICKED
||
2085 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2087 IsDlgButtonChecked(hwnd
,
2088 IDC_COEALWAYS
) ? COE_ALWAYS
:
2089 IsDlgButtonChecked(hwnd
,
2090 IDC_COENEVER
) ? COE_NEVER
:
2095 if (HIWORD(wParam
) == BN_CLICKED
||
2096 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2098 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2101 if (HIWORD(wParam
) == EN_CHANGE
)
2102 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2103 sizeof(cfg
.termtype
) - 1);
2106 if (HIWORD(wParam
) == EN_CHANGE
)
2107 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2108 sizeof(cfg
.logfilename
) - 1);
2111 memset(&of
, 0, sizeof(of
));
2112 #ifdef OPENFILENAME_SIZE_VERSION_400
2113 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2115 of
.lStructSize
= sizeof(of
);
2117 of
.hwndOwner
= hwnd
;
2118 of
.lpstrFilter
= "All Files\0*\0\0\0";
2119 of
.lpstrCustomFilter
= NULL
;
2120 of
.nFilterIndex
= 1;
2121 of
.lpstrFile
= filename
;
2122 strcpy(filename
, cfg
.logfilename
);
2123 of
.nMaxFile
= sizeof(filename
);
2124 of
.lpstrFileTitle
= NULL
;
2125 of
.lpstrInitialDir
= NULL
;
2126 of
.lpstrTitle
= "Select session log file";
2128 if (GetSaveFileName(&of
)) {
2129 strcpy(cfg
.logfilename
, filename
);
2130 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2134 case IDC_LSTATASCII
:
2136 if (HIWORD(wParam
) == BN_CLICKED
||
2137 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2138 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2140 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2142 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2149 if (HIWORD(wParam
) == BN_CLICKED
||
2150 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2151 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2152 cfg
.logxfovr
= LGXF_ASK
;
2153 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2154 cfg
.logxfovr
= LGXF_APN
;
2155 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2156 cfg
.logxfovr
= LGXF_OVR
;
2161 if (HIWORD(wParam
) == EN_CHANGE
)
2162 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2163 sizeof(cfg
.termspeed
) - 1);
2166 if (HIWORD(wParam
) == EN_CHANGE
)
2167 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2168 sizeof(cfg
.username
) - 1);
2170 case IDC_RLLUSEREDIT
:
2171 if (HIWORD(wParam
) == EN_CHANGE
)
2172 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2174 sizeof(cfg
.localusername
) - 1);
2178 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2182 cfg
.passive_telnet
=
2183 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2186 if (HIWORD(wParam
) == BN_CLICKED
||
2187 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2188 char str
[sizeof(cfg
.environmt
)];
2190 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2196 p
= str
+ strlen(str
);
2198 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2199 sizeof(str
) - 1 - (p
- str
));
2210 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2211 sizeof(cfg
.environmt
)) {
2213 p
[strlen(str
) + 1] = '\0';
2214 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2216 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2217 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2219 MessageBox(hwnd
, "Environment too big",
2220 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2225 if (HIWORD(wParam
) != BN_CLICKED
&&
2226 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2228 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2235 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2262 if (HIWORD(wParam
) == BN_CLICKED
||
2263 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2264 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2267 if (HIWORD(wParam
) == BN_CLICKED
||
2268 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2270 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2273 if (HIWORD(wParam
) == BN_CLICKED
||
2274 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2276 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2279 if (HIWORD(wParam
) == BN_CLICKED
||
2280 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2282 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2284 case IDC_CIPHERLIST
:
2287 handle_prefslist(&cipherlist
,
2288 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2289 0, hwnd
, wParam
, lParam
);
2293 if (HIWORD(wParam
) == BN_CLICKED
||
2294 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2295 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2297 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2302 if (HIWORD(wParam
) == BN_CLICKED
||
2303 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2305 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2308 if (HIWORD(wParam
) == EN_CHANGE
)
2309 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2310 sizeof(cfg
.keyfile
) - 1);
2313 if (HIWORD(wParam
) == EN_CHANGE
)
2314 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2315 sizeof(cfg
.remote_cmd
) - 1);
2318 memset(&of
, 0, sizeof(of
));
2319 #ifdef OPENFILENAME_SIZE_VERSION_400
2320 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2322 of
.lStructSize
= sizeof(of
);
2324 of
.hwndOwner
= hwnd
;
2325 of
.lpstrFilter
= "All Files\0*\0\0\0";
2326 of
.lpstrCustomFilter
= NULL
;
2327 of
.nFilterIndex
= 1;
2328 of
.lpstrFile
= filename
;
2329 strcpy(filename
, cfg
.keyfile
);
2330 of
.nMaxFile
= sizeof(filename
);
2331 of
.lpstrFileTitle
= NULL
;
2332 of
.lpstrInitialDir
= NULL
;
2333 of
.lpstrTitle
= "Select Public Key File";
2335 if (GetOpenFileName(&of
)) {
2336 strcpy(cfg
.keyfile
, filename
);
2337 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2341 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2345 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2347 case IDC_MOUSEOVERRIDE
:
2348 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
2354 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2359 for (i
= 0; i
< 128; i
++)
2360 if (SendDlgItemMessage
2361 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2363 cfg
.wordness
[i
] = n
;
2364 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2365 LB_DELETESTRING
, i
, 0);
2366 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2367 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2369 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2376 case IDC_BOLDCOLOUR
:
2377 if (HIWORD(wParam
) == BN_CLICKED
||
2378 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2381 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
2382 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2385 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2387 if (n
!= 12 + 10 * cfg
.bold_colour
) {
2388 for (i
= n
; i
-- > 0;)
2389 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2390 LB_DELETESTRING
, i
, 0);
2391 for (i
= 0; i
< 22; i
++)
2392 if (cfg
.bold_colour
|| permcolour
[i
])
2393 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2395 (LPARAM
) colours
[i
]);
2397 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2399 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
2404 if (HIWORD(wParam
) == BN_CLICKED
||
2405 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2407 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
2409 case IDC_COLOURLIST
:
2410 if (HIWORD(wParam
) == LBN_DBLCLK
||
2411 HIWORD(wParam
) == LBN_SELCHANGE
) {
2413 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2416 if (!cfg
.bold_colour
)
2417 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2418 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2420 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2422 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2427 if (HIWORD(wParam
) == BN_CLICKED
||
2428 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2429 static CHOOSECOLOR cc
;
2430 static DWORD custom
[16] = { 0 }; /* zero initialisers */
2432 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2435 if (!cfg
.bold_colour
)
2436 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2437 cc
.lStructSize
= sizeof(cc
);
2438 cc
.hwndOwner
= hwnd
;
2439 cc
.hInstance
= (HWND
) hinst
;
2440 cc
.lpCustColors
= custom
;
2442 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2444 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2445 if (ChooseColor(&cc
)) {
2447 (unsigned char) (cc
.rgbResult
& 0xFF);
2449 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2451 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2452 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2454 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2456 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2462 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
2463 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
2464 CB_GETCURSEL
, 0, 0);
2465 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
2466 index
, (LPARAM
)cfg
.line_codepage
);
2467 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
2468 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
2469 sizeof(cfg
.line_codepage
) - 1);
2470 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
2471 strcpy(cfg
.line_codepage
,
2472 cp_name(decode_codepage(cfg
.line_codepage
)));
2473 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
2476 case IDC_VTXWINDOWS
:
2482 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
2483 : IsDlgButtonChecked(hwnd
,
2484 IDC_VTOEMANSI
) ? VT_OEMANSI
:
2485 IsDlgButtonChecked(hwnd
,
2486 IDC_VTOEMONLY
) ? VT_OEMONLY
:
2487 IsDlgButtonChecked(hwnd
,
2488 IDC_VTUNICODE
) ? VT_UNICODE
:
2491 case IDC_X11_FORWARD
:
2492 if (HIWORD(wParam
) == BN_CLICKED
||
2493 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2495 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
2498 if (HIWORD(wParam
) == BN_CLICKED
||
2499 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2500 cfg
.lport_acceptall
=
2501 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
2503 case IDC_X11_DISPLAY
:
2504 if (HIWORD(wParam
) == EN_CHANGE
)
2505 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2506 sizeof(cfg
.x11_display
) - 1);
2509 if (HIWORD(wParam
) == BN_CLICKED
||
2510 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2511 char str
[sizeof(cfg
.portfwd
)];
2513 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
2517 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
2521 "You need to specify a source port number",
2522 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2525 p
= str
+ strlen(str
);
2527 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
2528 sizeof(str
) - 1 - (p
- str
));
2529 if (!*p
|| !strchr(p
, ':')) {
2531 "You need to specify a destination address\n"
2532 "in the form \"host.name:port\"",
2533 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2542 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
2543 sizeof(cfg
.portfwd
)) {
2545 p
[strlen(str
) + 1] = '\0';
2546 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
2548 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
2549 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
2551 MessageBox(hwnd
, "Too many forwardings",
2552 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2556 case IDC_PFWDREMOVE
:
2557 if (HIWORD(wParam
) != BN_CLICKED
&&
2558 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2559 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
2560 LB_GETCURSEL
, 0, 0);
2566 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
2598 /* Grrr Explorer will maximize Dialogs! */
2600 if (wParam
== SIZE_MAXIMIZED
)
2606 * Handle application-defined messages eg. DragListBox
2608 /* First find out what the number is (once). */
2609 if (draglistmsg
== WM_NULL
)
2610 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
2612 if (msg
== draglistmsg
) {
2613 /* Only process once dialog is fully formed. */
2614 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
2615 case IDC_CIPHERLIST
:
2616 return handle_prefslist(&cipherlist
,
2617 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2618 1, hwnd
, wParam
, lParam
);
2627 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
2628 WPARAM wParam
, LPARAM lParam
)
2630 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2632 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2633 EnableWindow(hwnd
, 0);
2634 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2635 EnableWindow(hwnd
, 1);
2636 SetActiveWindow(hwnd
);
2638 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
2641 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
2642 WPARAM wParam
, LPARAM lParam
)
2644 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
2647 void defuse_showwindow(void)
2650 * Work around the fact that the app's first call to ShowWindow
2651 * will ignore the default in favour of the shell-provided
2656 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2658 ShowWindow(hwnd
, SW_HIDE
);
2659 SetActiveWindow(hwnd
);
2660 DestroyWindow(hwnd
);
2669 savedsession
[0] = '\0';
2671 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2672 get_sesslist(FALSE
);
2677 int do_reconfig(HWND hwnd
)
2682 backup_cfg
= cfg
; /* structure copy */
2684 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2686 cfg
= backup_cfg
; /* structure copy */
2691 void logevent(char *string
)
2696 if (nevents
>= negsize
) {
2698 events
= srealloc(events
, negsize
* sizeof(*events
));
2702 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
2705 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
2706 strcpy(events
[nevents
], timebuf
);
2707 strcat(events
[nevents
], string
);
2710 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
2711 0, (LPARAM
) events
[nevents
]);
2712 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2713 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
2718 void showeventlog(HWND hwnd
)
2721 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2723 ShowWindow(logbox
, SW_SHOWNORMAL
);
2725 SetActiveWindow(logbox
);
2728 void showabout(HWND hwnd
)
2730 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2733 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2734 char *keystr
, char *fingerprint
)
2738 static const char absentmsg
[] =
2739 "The server's host key is not cached in the registry. You\n"
2740 "have no guarantee that the server is the computer you\n"
2742 "The server's key fingerprint is:\n"
2744 "If you trust this host, hit Yes to add the key to\n"
2745 "PuTTY's cache and carry on connecting.\n"
2746 "If you want to carry on connecting just once, without\n"
2747 "adding the key to the cache, hit No.\n"
2748 "If you do not trust this host, hit Cancel to abandon the\n"
2751 static const char wrongmsg
[] =
2752 "WARNING - POTENTIAL SECURITY BREACH!\n"
2754 "The server's host key does not match the one PuTTY has\n"
2755 "cached in the registry. This means that either the\n"
2756 "server administrator has changed the host key, or you\n"
2757 "have actually connected to another computer pretending\n"
2758 "to be the server.\n"
2759 "The new key fingerprint is:\n"
2761 "If you were expecting this change and trust the new key,\n"
2762 "hit Yes to update PuTTY's cache and continue connecting.\n"
2763 "If you want to carry on connecting but without updating\n"
2764 "the cache, hit No.\n"
2765 "If you want to abandon the connection completely, hit\n"
2766 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2768 static const char mbtitle
[] = "PuTTY Security Alert";
2771 /* sensible fingerprint max size */
2772 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2773 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2776 * Verify the key against the registry.
2778 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2780 if (ret
== 0) /* success - key matched OK */
2782 if (ret
== 2) { /* key was different */
2784 sprintf(message
, wrongmsg
, fingerprint
);
2785 mbret
= MessageBox(NULL
, message
, mbtitle
,
2786 MB_ICONWARNING
| MB_YESNOCANCEL
);
2788 store_host_key(host
, port
, keytype
, keystr
);
2789 if (mbret
== IDCANCEL
)
2792 if (ret
== 1) { /* key was absent */
2794 sprintf(message
, absentmsg
, fingerprint
);
2795 mbret
= MessageBox(NULL
, message
, mbtitle
,
2796 MB_ICONWARNING
| MB_YESNOCANCEL
);
2798 store_host_key(host
, port
, keytype
, keystr
);
2799 if (mbret
== IDCANCEL
)
2805 * Ask whether the selected cipher is acceptable (since it was
2806 * below the configured 'warn' threshold).
2807 * cs: 0 = both ways, 1 = client->server, 2 = server->client
2809 void askcipher(char *ciphername
, int cs
)
2811 static const char mbtitle
[] = "PuTTY Security Alert";
2812 static const char msg
[] =
2813 "The first %.35scipher supported by the server\n"
2814 "is %.64s, which is below the configured\n"
2815 "warning threshold.\n"
2816 "Do you want to continue with this connection?\n";
2817 /* guessed cipher name + type max length */
2818 char message
[100 + sizeof(msg
)];
2821 sprintf(message
, msg
,
2823 (cs
== 1) ?
"client-to-server " :
2824 "server-to-client ",
2826 mbret
= MessageBox(NULL
, message
, mbtitle
,
2827 MB_ICONWARNING
| MB_YESNO
);
2835 * Ask whether to wipe a session log file before writing to it.
2836 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2838 int askappend(char *filename
)
2840 static const char mbtitle
[] = "PuTTY Log to File";
2841 static const char msgtemplate
[] =
2842 "The session log file \"%.*s\" already exists.\n"
2843 "You can overwrite it with a new session log,\n"
2844 "append your session log to the end of it,\n"
2845 "or disable session logging for this session.\n"
2846 "Hit Yes to wipe the file, No to append to it,\n"
2847 "or Cancel to disable logging.";
2848 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2850 if (cfg
.logxfovr
!= LGXF_ASK
) {
2851 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
2853 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2855 mbret
= MessageBox(NULL
, message
, mbtitle
,
2856 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2859 else if (mbret
== IDNO
)