gdi32: Use the helper function in GetCharABCWidthsFloatA to support DBCS.
[wine.git] / include / ws2tcpip.h
blobb1c296ccdf4dd80ea6fec3589f7ba902e7fc7607
1 /*
2 * Copyright (C) 2001 Francois Gouget
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WS2TCPIP__
20 #define __WS2TCPIP__
22 #include <winsock2.h>
23 #include <ws2ipdef.h>
24 #include <limits.h>
26 #ifdef USE_WS_PREFIX
27 #define WS(x) WS_##x
28 #else
29 #define WS(x) x
30 #endif
32 /* for addrinfo calls */
33 typedef struct WS(addrinfo)
35 int ai_flags;
36 int ai_family;
37 int ai_socktype;
38 int ai_protocol;
39 size_t ai_addrlen;
40 char * ai_canonname;
41 struct WS(sockaddr)* ai_addr;
42 struct WS(addrinfo)* ai_next;
43 } ADDRINFOA, *PADDRINFOA;
45 typedef struct WS(addrinfoW)
47 int ai_flags;
48 int ai_family;
49 int ai_socktype;
50 int ai_protocol;
51 size_t ai_addrlen;
52 PWSTR ai_canonname;
53 struct WS(sockaddr)* ai_addr;
54 struct WS(addrinfoW)* ai_next;
55 } ADDRINFOW, *PADDRINFOW;
57 typedef int WS(socklen_t);
59 typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
61 /* Possible Windows flags for getaddrinfo() */
62 #ifndef USE_WS_PREFIX
63 # define AI_PASSIVE 0x00000001
64 # define AI_CANONNAME 0x00000002
65 # define AI_NUMERICHOST 0x00000004
66 # define AI_ADDRCONFIG 0x00000400
67 # define AI_NON_AUTHORITATIVE 0x00004000
68 # define AI_SECURE 0x00008000
69 # define AI_RETURN_PREFERRED_NAMES 0x00010000
70 /* getaddrinfo error codes */
71 # define EAI_AGAIN WSATRY_AGAIN
72 # define EAI_BADFLAGS WSAEINVAL
73 # define EAI_FAIL WSANO_RECOVERY
74 # define EAI_FAMILY WSAEAFNOSUPPORT
75 # define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
76 # define EAI_NODATA EAI_NONAME
77 # define EAI_NONAME WSAHOST_NOT_FOUND
78 # define EAI_SERVICE WSATYPE_NOT_FOUND
79 # define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
80 #else
81 # define WS_AI_PASSIVE 0x00000001
82 # define WS_AI_CANONNAME 0x00000002
83 # define WS_AI_NUMERICHOST 0x00000004
84 # define WS_AI_ADDRCONFIG 0x00000400
85 # define WS_AI_NON_AUTHORITATIVE 0x00004000
86 # define WS_AI_SECURE 0x00008000
87 # define WS_AI_RETURN_PREFERRED_NAMES 0x00010000
88 /* getaddrinfo error codes */
89 # define WS_EAI_AGAIN WSATRY_AGAIN
90 # define WS_EAI_BADFLAGS WSAEINVAL
91 # define WS_EAI_FAIL WSANO_RECOVERY
92 # define WS_EAI_FAMILY WSAEAFNOSUPPORT
93 # define WS_EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
94 # define WS_EAI_NODATA WS_EAI_NONAME
95 # define WS_EAI_NONAME WSAHOST_NOT_FOUND
96 # define WS_EAI_SERVICE WSATYPE_NOT_FOUND
97 # define WS_EAI_SOCKTYPE WSAESOCKTNOSUPPORT
98 #endif
100 #ifndef USE_WS_PREFIX
101 # define NI_MAXHOST 1025
102 # define NI_MAXSERV 32
103 #else
104 # define WS_NI_MAXHOST 1025
105 # define WS_NI_MAXSERV 32
106 #endif
108 /* Possible Windows flags for getnameinfo() */
109 #ifndef USE_WS_PREFIX
110 # define NI_NOFQDN 0x01
111 # define NI_NUMERICHOST 0x02
112 # define NI_NAMEREQD 0x04
113 # define NI_NUMERICSERV 0x08
114 # define NI_DGRAM 0x10
115 #else
116 # define WS_NI_NOFQDN 0x01
117 # define WS_NI_NUMERICHOST 0x02
118 # define WS_NI_NAMEREQD 0x04
119 # define WS_NI_NUMERICSERV 0x08
120 # define WS_NI_DGRAM 0x10
121 #endif
124 #ifdef __cplusplus
125 extern "C" {
126 #endif
128 #define GAI_STRERROR_BUFFER_SIZE 1024
130 static inline char *gai_strerrorA(int errcode)
132 static char buffer[GAI_STRERROR_BUFFER_SIZE + 1];
134 /* FIXME: should format message from system, ignoring inserts in neutral
135 * language */
136 buffer[0] = '\0';
138 return buffer;
141 static inline WCHAR *gai_strerrorW(int errcode)
143 static WCHAR buffer[GAI_STRERROR_BUFFER_SIZE + 1];
145 /* FIXME: should format message from system, ignoring inserts in neutral
146 * language */
147 buffer[0] = '\0';
149 return buffer;
152 #ifdef USE_WS_PREFIX
153 # define WS_gai_strerror WINELIB_NAME_AW(gai_strerror)
154 #elif defined(WINE_NO_UNICODE_MACROS)
155 # define gai_strerror gai_strerrorA
156 #else
157 # define gai_strerror WINELIB_NAME_AW(gai_strerror)
158 #endif
160 void WINAPI WS(freeaddrinfo)(LPADDRINFO);
161 #define FreeAddrInfoA WS(freeaddrinfo)
162 void WINAPI FreeAddrInfoW(PADDRINFOW);
163 #define FreeAddrInfo WINELIB_NAME_AW(FreeAddrInfo)
164 int WINAPI WS(getaddrinfo)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**);
165 #define GetAddrInfoA WS(getaddrinfo)
166 int WINAPI GetAddrInfoW(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*);
167 #define GetAddrInfo WINELIB_NAME_AW(GetAddrInfo)
168 int WINAPI WS(getnameinfo)(const SOCKADDR*,WS(socklen_t),PCHAR,DWORD,PCHAR,DWORD,INT);
169 #define GetNameInfoA WS(getnameinfo)
170 INT WINAPI GetNameInfoW(const SOCKADDR*,WS(socklen_t),PWCHAR,DWORD,PWCHAR,DWORD,INT);
171 #define GetNameInfo WINELIB_NAME_AW(GetNameInfo)
172 PCSTR WINAPI WS(inet_ntop)(INT,PVOID,PSTR,SIZE_T);
173 #define InetNtopA WS(inet_ntop)
174 PCWSTR WINAPI InetNtopW(INT,PVOID,PWSTR,SIZE_T);
175 #define InetNtop WINELIB_NAME_AW(InetNtop)
176 int WINAPI WS(inet_pton)(INT,PCSTR,PVOID);
177 #define InetPtonA WS(inet_pton)
178 int WINAPI InetPtonW(INT,PCWSTR,PVOID);
179 #define InetPton WINELIB_NAME_AW(InetPton)
182 * Ws2tcpip Function Typedefs
184 * Remember to keep this section in sync with the
185 * prototypes above.
187 #if INCL_WINSOCK_API_TYPEDEFS
189 typedef void (WINAPI *LPFN_FREEADDRINFO)(LPADDRINFO);
190 #define LPFN_FREEADDRINFOA LPFN_FREEADDRINFO
191 typedef void (WINAPI *LPFN_FREEADDRINFOW)(PADDRINFOW);
192 #define LPFN_FREEADDRINFOT WINELIB_NAME_AW(LPFN_FREEADDRINFO)
193 typedef int (WINAPI *LPFN_GETADDRINFO)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**);
194 #define LPFN_GETADDRINFOA LPFN_GETADDRINFO
195 typedef int (WINAPI *LPFN_GETADDRINFOW)(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*);
196 #define LPFN_GETADDRINFOT WINELIB_NAME_AW(LPFN_GETADDRINFO)
197 typedef int (WINAPI *LPFN_GETNAMEINFO)(const struct sockaddr*,socklen_t,char*,DWORD,char*,DWORD,int);
198 #define LPFN_GETNAMEINFOA LPFN_GETNAMEINFO
199 typedef int (WINAPI *LPFN_GETNAMEINFOW)(const SOCKADDR*,socklen_t,PWCHAR,DWORD,PWCHAR,DWORD,INT);
200 #define LPFN_GETNAMEINFOT WINELIB_NAME_AW(LPFN_GETNAMEINFO)
202 #endif
204 #ifdef __cplusplus
206 #endif
208 #endif /* __WS2TCPIP__ */