1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00
putty-source/windows/winselgui.c
Simon Tatham 58e2a35bdf Const-correctness in do_select() return value.
The error message it returns on failure is a string literal, so it
shouldn't be returned as a mutable 'char *'.
2020-01-04 13:52:22 +00:00

39 lines
800 B
C

/*
* Implementation of do_select() for winnet.c to use, that uses
* WSAAsyncSelect to convert network activity into window messages,
* for integration into a GUI event loop.
*/
#include "putty.h"
static HWND winsel_hwnd = NULL;
void winselgui_set_hwnd(HWND hwnd)
{
winsel_hwnd = hwnd;
}
void winselgui_clear_hwnd(void)
{
winsel_hwnd = NULL;
}
const char *do_select(SOCKET skt, bool enable)
{
int msg, events;
if (enable) {
msg = WM_NETEVENT;
events = (FD_CONNECT | FD_READ | FD_WRITE |
FD_OOB | FD_CLOSE | FD_ACCEPT);
} else {
msg = events = 0;
}
assert(winsel_hwnd);
if (p_WSAAsyncSelect(skt, winsel_hwnd, msg, events) == SOCKET_ERROR)
return winsock_error_string(p_WSAGetLastError());
return NULL;
}