:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / 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 <ddk/ntddk.h>
11 #include <winsock2.h>
12 #include <ws2spi.h>
13 #include <windows.h>
14 #include <debug.h>
15
16 /* Exported by ntdll.dll, but where is the prototype? */
17 unsigned long strtoul(const char *nptr, char **endptr, int base);
18
19
20 #define EXPORT STDCALL
21
22 extern HANDLE GlobalHeap;
23 extern WSPUPCALLTABLE UpcallTable;
24
25
26 typedef struct _WINSOCK_THREAD_BLOCK {
27     INT LastErrorValue;     /* Error value from last function that failed */
28     BOOL Initialized;       /* TRUE if WSAStartup() has been successfully called */
29     CHAR Intoa[16];         /* Buffer for inet_ntoa() */
30 } WINSOCK_THREAD_BLOCK, *PWINSOCK_THREAD_BLOCK;
31
32
33 /* Macros */
34
35 #define WSAINITIALIZED (((PWINSOCK_THREAD_BLOCK)NtCurrentTeb()->WinSockData)->Initialized)
36
37 #define WSASETINITIALIZED (((PWINSOCK_THREAD_BLOCK)NtCurrentTeb()->WinSockData)->Initialized = TRUE)
38
39
40 #ifdef LE
41
42 /* DWORD network to host byte order conversion for little endian machines */
43 #define DN2H(dw) \
44   ((((dw) & 0xFF000000L) >> 24) | \
45    (((dw) & 0x00FF0000L) >> 8) | \
46          (((dw) & 0x0000FF00L) << 8) | \
47          (((dw) & 0x000000FFL) << 24))
48
49 /* DWORD host to network byte order conversion for little endian machines */
50 #define DH2N(dw) \
51         ((((dw) & 0xFF000000L) >> 24) | \
52          (((dw) & 0x00FF0000L) >> 8) | \
53          (((dw) & 0x0000FF00L) << 8) | \
54          (((dw) & 0x000000FFL) << 24))
55
56 /* WORD network to host order conversion for little endian machines */
57 #define WN2H(w) \
58         ((((w) & 0xFF00) >> 8) | \
59          (((w) & 0x00FF) << 8))
60
61 /* WORD host to network byte order conversion for little endian machines */
62 #define WH2N(w) \
63         ((((w) & 0xFF00) >> 8) | \
64          (((w) & 0x00FF) << 8))
65
66 #else /* LE */
67
68 /* DWORD network to host byte order conversion for big endian machines */
69 #define DN2H(dw) \
70     (dw)
71
72 /* DWORD host to network byte order conversion big endian machines */
73 #define DH2N(dw) \
74     (dw)
75
76 /* WORD network to host order conversion for big endian machines */
77 #define WN2H(w) \
78     (w)
79
80 /* WORD host to network byte order conversion for big endian machines */
81 #define WH2N(w) \
82     (w)
83
84 #endif /* LE */
85
86 #endif /* __WS2_32_H */
87
88 /* EOF */