Sync with trunk r63793.
[reactos.git] / dll / win32 / ws2_32 / include / ws2_32.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 DLL
4 * FILE: include/ws2_32.h
5 * PURPOSE: WinSock 2 DLL header
6 */
7
8 #ifndef __WS2_32_H
9 #define __WS2_32_H
10
11 #include <stdarg.h>
12
13 #define WIN32_NO_STATUS
14 #define _INC_WINDOWS
15 #define COM_NO_WINDOWS_H
16
17 #include <windef.h>
18 #include <winbase.h>
19 #include <winuser.h>
20 #include <ws2spi.h>
21 #define NTOS_MODE_USER
22 #include <ndk/rtlfuncs.h>
23
24 #include <wsahelp.h>
25
26 #undef assert
27 #include <debug.h>
28 #include <windns.h> // DNS_A_DATA
29
30 #include "catalog.h"
31 #include "handle.h"
32
33 #define EXPORT WINAPI
34
35 extern HINSTANCE g_hInstDll;
36 extern HANDLE GlobalHeap;
37 extern BOOL WsaInitialized; /* TRUE if WSAStartup() has been successfully called */
38 extern WSPUPCALLTABLE UpcallTable;
39
40 #define WS2_INTERNAL_MAX_ALIAS 16
41
42 typedef struct _WINSOCK_GETSERVBYNAME_CACHE
43 {
44 UINT Size;
45 SERVENT ServerEntry;
46 PCHAR Aliases[WS2_INTERNAL_MAX_ALIAS];
47 CHAR Data[1];
48 } WINSOCK_GETSERVBYNAME_CACHE, *PWINSOCK_GETSERVBYNAME_CACHE;
49
50 typedef struct _WINSOCK_GETSERVBYPORT_CACHE
51 {
52 UINT Size;
53 SERVENT ServerEntry;
54 PCHAR Aliases[WS2_INTERNAL_MAX_ALIAS];
55 CHAR Data[1];
56 } WINSOCK_GETSERVBYPORT_CACHE, *PWINSOCK_GETSERVBYPORT_CACHE;
57
58 typedef struct _WINSOCK_THREAD_BLOCK
59 {
60 INT LastErrorValue; /* Error value from last function that failed */
61 CHAR Intoa[16]; /* Buffer for inet_ntoa() */
62 PWINSOCK_GETSERVBYNAME_CACHE
63 Getservbyname; /* Buffer used by getservbyname */
64 PWINSOCK_GETSERVBYPORT_CACHE
65 Getservbyport; /* Buffer used by getservbyname */
66 struct hostent* Hostent;
67 } WINSOCK_THREAD_BLOCK, *PWINSOCK_THREAD_BLOCK;
68
69
70 /* Macros */
71
72 #define WSAINITIALIZED (WsaInitialized)
73
74 #define WSASETINITIALIZED (WsaInitialized = TRUE)
75
76 /* ws2_32 internal Functions */
77 void check_hostent(struct hostent **he);
78 void populate_hostent(struct hostent *he, char* name, IP4_ADDRESS addr);
79 void free_hostent(struct hostent *he);
80 void free_servent(struct servent* s);
81
82 #ifdef LE
83
84 /* DWORD network to host byte order conversion for little endian machines */
85 #define DN2H(dw) \
86 ((((dw) & 0xFF000000L) >> 24) | \
87 (((dw) & 0x00FF0000L) >> 8) | \
88 (((dw) & 0x0000FF00L) << 8) | \
89 (((dw) & 0x000000FFL) << 24))
90
91 /* DWORD host to network byte order conversion for little endian machines */
92 #define DH2N(dw) \
93 ((((dw) & 0xFF000000L) >> 24) | \
94 (((dw) & 0x00FF0000L) >> 8) | \
95 (((dw) & 0x0000FF00L) << 8) | \
96 (((dw) & 0x000000FFL) << 24))
97
98 /* WORD network to host order conversion for little endian machines */
99 #define WN2H(w) \
100 ((((w) & 0xFF00) >> 8) | \
101 (((w) & 0x00FF) << 8))
102
103 /* WORD host to network byte order conversion for little endian machines */
104 #define WH2N(w) \
105 ((((w) & 0xFF00) >> 8) | \
106 (((w) & 0x00FF) << 8))
107
108 #else /* LE */
109
110 /* DWORD network to host byte order conversion for big endian machines */
111 #define DN2H(dw) \
112 (dw)
113
114 /* DWORD host to network byte order conversion big endian machines */
115 #define DH2N(dw) \
116 (dw)
117
118 /* WORD network to host order conversion for big endian machines */
119 #define WN2H(w) \
120 (w)
121
122 /* WORD host to network byte order conversion for big endian machines */
123 #define WH2N(w) \
124 (w)
125
126 #endif /* LE */
127
128 #endif /* __WS2_32_H */