forked from deplinenoise/webby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webby_win32.h
52 lines (40 loc) · 907 Bytes
/
webby_win32.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <winsock2.h>
#include <windows.h>
typedef SOCKET webby_socket_t;
#define WB_ALIGN(x) __declspec(align(x))
#define WB_INVALID_SOCKET INVALID_SOCKET
#define snprintf _snprintf
typedef int webby_socklen_t;
static int wb_socket_error(void)
{
return WSAGetLastError();
}
static int strcasecmp(const char *a, const char *b)
{
return _stricmp(a, b);
}
static int strncasecmp(const char *a, const char *b, size_t len)
{
return _strnicmp(a, b, len);
}
static int wb_set_blocking(webby_socket_t socket, int blocking)
{
u_long val = !blocking;
return ioctlsocket(socket, FIONBIO, &val);
}
static int wb_valid_socket(webby_socket_t socket)
{
return INVALID_SOCKET != socket;
}
static void wb_close_socket(webby_socket_t socket)
{
closesocket(socket);
}
static int wb_is_blocking_error(int error)
{
return WSAEWOULDBLOCK == error;
}
static int wb_sleep(int time)
{
Sleep(time);
}