X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/09798031be7e32fec05058a4ab56b59688ce1aa4..4d331a77f20f321f867f5907e2ffc06249378881:/window.c diff --git a/window.c b/window.c index 6a59fd9b..9c973faf 100644 --- a/window.c +++ b/window.c @@ -1,6 +1,12 @@ #include #include +#ifndef AUTO_WINSOCK +#ifdef WINSOCK_TWO +#include +#else #include +#endif +#endif #include #include #include @@ -82,6 +88,12 @@ static Mouse_Button lastbtn; static char *window_name, *icon_name; +static Ldisc *real_ldisc; + +void begin_session(void) { + ldisc = real_ldisc; +} + int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { static char appname[] = "PuTTY"; WORD winsock_ver; @@ -239,7 +251,10 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { } } - ldisc = (cfg.ldisc_term ? &ldisc_term : &ldisc_simple); + real_ldisc = (cfg.ldisc_term ? &ldisc_term : &ldisc_simple); + /* To start with, we use the simple line discipline, so we can + * type passwords etc without fear of them being echoed... */ + ldisc = &ldisc_simple; if (!prev) { wndclass.style = 0; @@ -521,6 +536,25 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { } /* + * Print a message box and close the connection. + */ +void connection_fatal(char *fmt, ...) { + va_list ap; + char stuff[200]; + + va_start(ap, fmt); + vsprintf(stuff, fmt, ap); + va_end(ap); + MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK); + if (cfg.close_on_exit) + PostQuitMessage(1); + else { + session_closed = TRUE; + SetWindowText (hwnd, "PuTTY (inactive)"); + } +} + +/* * Actually do the job requested by a WM_NETEVENT */ static void enact_pending_netevent(void) { @@ -546,10 +580,9 @@ static void enact_pending_netevent(void) { sprintf(buf, "Unexpected network error %d", -i); break; } - MessageBox(hwnd, buf, "PuTTY Fatal Error", - MB_ICONERROR | MB_OK); - PostQuitMessage(1); - } else if (i == 0) { + connection_fatal(buf); + } + if (i <= 0) { if (cfg.close_on_exit) PostQuitMessage(0); else { @@ -1798,7 +1831,7 @@ static WPARAM compose_key = 0; if ( cfg.funky_type == 0 || ( cfg.funky_type == 1 && app_keypad_keys)) switch(wParam) { - case VK_EXECUTE: xkey = 'P'; break; + case VK_EXECUTE: if (app_keypad_keys) xkey = 'P'; break; case VK_DIVIDE: xkey = 'Q'; break; case VK_MULTIPLY:xkey = 'R'; break; case VK_SUBTRACT:xkey = 'S'; break;