1 | /** |
---|
2 | @file win32.h |
---|
3 | @brief ENet Win32 header |
---|
4 | */ |
---|
5 | #ifndef __ENET_WIN32_H__ |
---|
6 | #define __ENET_WIN32_H__ |
---|
7 | |
---|
8 | #ifdef ENET_BUILDING_LIB |
---|
9 | #pragma warning (disable: 4996) // 'strncpy' was declared deprecated |
---|
10 | #pragma warning (disable: 4267) // size_t to int conversion |
---|
11 | #pragma warning (disable: 4244) // 64bit to 32bit int |
---|
12 | #pragma warning (disable: 4018) // signed/unsigned mismatch |
---|
13 | #endif |
---|
14 | |
---|
15 | #include <stdlib.h> |
---|
16 | #include <winsock2.h> |
---|
17 | #include <ws2tcpip.h> |
---|
18 | |
---|
19 | typedef SOCKET ENetSocket; |
---|
20 | |
---|
21 | enum |
---|
22 | { |
---|
23 | ENET_SOCKET_NULL = INVALID_SOCKET |
---|
24 | }; |
---|
25 | |
---|
26 | #define ENET_HOST_TO_NET_16(value) (htons (value)) |
---|
27 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) |
---|
28 | |
---|
29 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) |
---|
30 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) |
---|
31 | |
---|
32 | typedef struct |
---|
33 | { |
---|
34 | size_t dataLength; |
---|
35 | void * data; |
---|
36 | } ENetBuffer; |
---|
37 | |
---|
38 | #define ENET_CALLBACK __cdecl |
---|
39 | |
---|
40 | #if defined ENET_DLL |
---|
41 | #if defined ENET_BUILDING_LIB |
---|
42 | #define ENET_API __declspec( dllexport ) |
---|
43 | #else |
---|
44 | #define ENET_API __declspec( dllimport ) |
---|
45 | #endif /* ENET_BUILDING_LIB */ |
---|
46 | #else /* !ENET_DLL */ |
---|
47 | #define ENET_API extern |
---|
48 | #endif /* ENET_DLL */ |
---|
49 | |
---|
50 | typedef fd_set ENetSocketSet; |
---|
51 | |
---|
52 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) |
---|
53 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) |
---|
54 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLEAR (socket, & (sockset)) |
---|
55 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) |
---|
56 | |
---|
57 | #ifndef AI_ADDRCONFIG |
---|
58 | #define AI_ADDRCONFIG 0x0400 /* AI_ADDRCONFIG is not defined everywhere */ |
---|
59 | #endif |
---|
60 | |
---|
61 | #endif /* __ENET_WIN32_H__ */ |
---|
62 | |
---|
63 | |
---|