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