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