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