blob: 02a6cc59c04df36169e04cb2dc1a376da0f1eea9 [file] [log] [blame]
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001/* WINSOCK.H--definitions to be used with the WINSOCK.DLL
2 *
3 * This header file corresponds to version 1.1 of the Windows Sockets
4 * specification.
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00005 *
6 * Copyright (C) the Wine project
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Alexandre Julliardfb9a9191994-03-01 19:48:04 +000021 */
22
Dimitrie O. Paun8b366812003-01-04 00:52:18 +000023#ifdef __WINESRC__
Francois Gouget27202312001-11-14 21:26:23 +000024# ifndef __WINE_WINSOCK2__
25# error Please use Winsock2 in Wine
26# endif
27#endif
28
Alexandre Julliard15f0ac32003-04-04 19:32:18 +000029#ifndef __WINE_WINSOCKAPI_STDLIB_H
30#define __WINE_WINSOCKAPI_STDLIB_H
Patrik Stridvall14da7b11999-06-12 10:53:06 +000031
Francois Gouget27202312001-11-14 21:26:23 +000032/*
33 * This section defines the items that conflict with the Unix headers.
34 */
Alexandre Julliard70c47b62003-03-31 23:56:35 +000035#ifndef USE_WS_PREFIX
36/* We are not using the WS_ prefix we risk getting conflicts for
37 * everything related to select.
Francois Gouget27202312001-11-14 21:26:23 +000038 */
Alexandre Julliard70c47b62003-03-31 23:56:35 +000039# ifdef FD_CLR
40/* Too late, the Unix version of stdlib.h was included before winsock.h.
41 * This means select and all the related stuff is already defined and we
42 * cannot override types and function prototypes.
43 * All we can do is disable all these symbols so that they are not used
44 * inadvertantly.
45 */
46# undef FD_SETSIZE
47# undef FD_CLR
48# undef FD_SET
49# undef FD_ZERO
50# undef FD_ISSET
Francois Gouget27202312001-11-14 21:26:23 +000051
Alexandre Julliard70c47b62003-03-31 23:56:35 +000052# define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
53# define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
54# define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
55# define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
56# define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
57# define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
58# define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
59# else /* FD_CLR */
60/* stdlib.h has not been included yet so it's not too late. Include it now
61 * making sure that none of the select symbols is affected. Then we can
62 * define them with our own values.
63 */
64# define fd_set unix_fd_set
65# define timeval unix_timeval
66# define select unix_select
67# include <sys/types.h>
Yorick Hardy1b3755e2003-06-13 18:07:25 +000068# include <time.h>
Alexandre Julliard70c47b62003-03-31 23:56:35 +000069# include <stdlib.h>
70# undef fd_set
71# undef timeval
72# undef select
73# undef FD_SETSIZE
74# undef FD_CLR
75# undef FD_SET
76# undef FD_ZERO
77# undef FD_ISSET
78
79# define WS_DEFINE_SELECT
80# endif /* FD_CLR */
81
82#else
83# define WS_DEFINE_SELECT
84# include <sys/types.h>
85# include <stdlib.h>
86#endif /* !USE_WS_PREFIX */
87
Alexandre Julliard15f0ac32003-04-04 19:32:18 +000088#endif /* __WINE_WINSOCKAPI_STDLIB_H */
89
Alexandre Julliard9ee24132003-04-02 01:38:42 +000090#ifndef __WINESRC__
Dimitrie O. Paun53f9c212003-08-28 21:43:34 +000091# include <windows.h>
Alexandre Julliard9ee24132003-04-02 01:38:42 +000092#else
Dimitrie O. Paun53f9c212003-08-28 21:43:34 +000093# include <windef.h>
Alexandre Julliard9ee24132003-04-02 01:38:42 +000094#endif
95
Alexandre Julliard15f0ac32003-04-04 19:32:18 +000096#ifndef _WINSOCKAPI_
97#define _WINSOCKAPI_
98
Jon Griffithscf2f57f2003-07-19 03:07:16 +000099#if (defined(_MSC_VER) || defined(__MINGW_H)) && !defined(MSVCRT_BSD_TYPES_DEFINED)
Alexandre Julliard70c47b62003-03-31 23:56:35 +0000100/* MinGW doesn't define the u_xxx types */
101typedef unsigned char u_char;
102typedef unsigned short u_short;
103typedef unsigned int u_int;
104typedef unsigned long u_long;
105#endif
Francois Gouget27202312001-11-14 21:26:23 +0000106
Alexandre Julliard15f0ac32003-04-04 19:32:18 +0000107#ifdef USE_WS_PREFIX
108# define WS(x) WS_##x
109#else
110# define WS(x) x
111#endif
112
113#ifdef __cplusplus
114extern "C" {
115#endif /* defined(__cplusplus) */
116
Alexandre Julliard9ee24132003-04-02 01:38:42 +0000117/* proper 4-byte packing */
Dimitrie O. Paun53f9c212003-08-28 21:43:34 +0000118#include <pshpack4.h>
Francois Gouget27202312001-11-14 21:26:23 +0000119
120/*
121 * Address families
122 */
123#ifndef USE_WS_PREFIX
124#define AF_UNSPEC 0
125#define AF_UNIX 1
126#define AF_INET 2
127#define AF_IMPLINK 3
128#define AF_PUP 4
129#define AF_CHAOS 5
130#define AF_NS 6
131#define AF_IPX AF_NS
132#define AF_ISO 7
133#define AF_OSI AF_ISO
134#define AF_ECMA 8
135#define AF_DATAKIT 9
136#define AF_CCITT 10
137#define AF_SNA 11
138#define AF_DECnet 12
139#define AF_DLI 13
140#define AF_LAT 14
141#define AF_HYLINK 15
142#define AF_APPLETALK 16
143#define AF_NETBIOS 17
144#define AF_VOICEVIEW 18
145#define AF_FIREFOX 19
146#define AF_UNKNOWN1 20
147#define AF_BAN 21
148#define AF_ATM 22
149#define AF_INET6 23
150#define AF_CLUSTER 24
151#define AF_12844 25
152#define AF_IRDA 26
153#define AF_MAX 27
154#define PF_UNSPEC AF_UNSPEC
155#define PF_UNIX AF_UNIX
156#define PF_INET AF_INET
157#define PF_IMPLINK AF_IMPLINK
158#define PF_PUP AF_PUP
159#define PF_CHAOS AF_CHAOS
160#define PF_NS AF_NS
161#define PF_IPX AF_IPX
162#define PF_ISO AF_ISO
163#define PF_OSI AF_OSI
164#define PF_ECMA AF_ECMA
165#define PF_DATAKIT AF_DATAKIT
166#define PF_CCITT AF_CCITT
167#define PF_SNA AF_SNA
168#define PF_DECnet AF_DECnet
169#define PF_DLI AF_DLI
170#define PF_LAT AF_LAT
171#define PF_HYLINK AF_HYLINK
172#define PF_APPLETALK AF_APPLETALK
173#define PF_VOICEVIEW AF_VOICEVIEW
174#define PF_FIREFOX AF_FIREFOX
175#define PF_UNKNOWN1 AF_UNKNOWN1
176#define PF_BAN AF_BAN
177#define PF_MAX AF_MAX
178#else /* USE_WS_PREFIX */
179#define WS_AF_UNSPEC 0
180#define WS_AF_UNIX 1
181#define WS_AF_INET 2
182#define WS_AF_IMPLINK 3
183#define WS_AF_PUP 4
184#define WS_AF_CHAOS 5
185#define WS_AF_NS 6
186#define WS_AF_IPX WS_AF_NS
187#define WS_AF_ISO 7
188#define WS_AF_OSI AF_ISO
189#define WS_AF_ECMA 8
190#define WS_AF_DATAKIT 9
191#define WS_AF_CCITT 10
192#define WS_AF_SNA 11
193#define WS_AF_DECnet 12
194#define WS_AF_DLI 13
195#define WS_AF_LAT 14
196#define WS_AF_HYLINK 15
197#define WS_AF_APPLETALK 16
198#define WS_AF_NETBIOS 17
199#define WS_AF_VOICEVIEW 18
200#define WS_AF_FIREFOX 19
201#define WS_AF_UNKNOWN1 20
202#define WS_AF_BAN 21
203#define WS_AF_ATM 22
204#define WS_AF_INET6 23
205#define WS_AF_CLUSTER 24
206#define WS_AF_12844 25
207#define WS_AF_IRDA 26
208#define WS_AF_MAX 27
209#endif /* USE_WS_PREFIX */
210
211/*
212 * Types
213 */
214#ifndef USE_WS_PREFIX
215#define SOCK_STREAM 1
216#define SOCK_DGRAM 2
217#define SOCK_RAW 3
218#define SOCK_RDM 4
219#define SOCK_SEQPACKET 5
220#else /* USE_WS_PREFIX */
221#define WS_SOCK_STREAM 1
222#define WS_SOCK_DGRAM 2
223#define WS_SOCK_RAW 3
224#define WS_SOCK_RDM 4
225#define WS_SOCK_SEQPACKET 5
226#endif /* USE_WS_PREFIX */
227
228
229/*
230 * Protocols
231 */
232#ifndef USE_WS_PREFIX
233#define IPPROTO_IP 0
234#define IPPROTO_ICMP 1
235#define IPPROTO_IGMP 2
236#define IPPROTO_GGP 3
237#define IPPROTO_TCP 6
238#define IPPROTO_UDP 17
239#define IPPROTO_IDP 22
240#define IPPROTO_ND 77
241#define IPPROTO_RAW 255
242#define IPPROTO_MAX 256
243#else /* USE_WS_PREFIX */
244#define WS_IPPROTO_IP 0
245#define WS_IPPROTO_ICMP 1
246#define WS_IPPROTO_IGMP 2
247#define WS_IPPROTO_GGP 3
248#define WS_IPPROTO_TCP 6
249#define WS_IPPROTO_UDP 17
250#define WS_IPPROTO_IDP 22
251#define WS_IPPROTO_ND 77
252#define WS_IPPROTO_RAW 255
253#define WS_IPPROTO_MAX 256
254#endif /* USE_WS_PREFIX */
255
256typedef struct WS(protoent)
Andreas Mohrae509412000-08-03 22:19:09 +0000257{
Francois Gouget27202312001-11-14 21:26:23 +0000258 char* p_name;
259 char** p_aliases;
260 short p_proto;
261} PROTOENT, *PPROTOENT, *LPPROTOENT;
Andreas Mohrae509412000-08-03 22:19:09 +0000262
Francois Gouget27202312001-11-14 21:26:23 +0000263
264
265/*
266 * Networks
267 */
268struct WS(netent)
Andreas Mohrae509412000-08-03 22:19:09 +0000269{
Francois Gouget27202312001-11-14 21:26:23 +0000270 char* n_name; /* official name of net */
271 char** n_aliases; /* alias list */
272 short n_addrtype; /* net address type */
273 u_long n_net; /* network # */
274};
Andreas Mohrae509412000-08-03 22:19:09 +0000275
Francois Gouget27202312001-11-14 21:26:23 +0000276
277/*
278 * Services
279 */
280#ifndef USE_WS_PREFIX
281#define IPPORT_ECHO 7
282#define IPPORT_DISCARD 9
283#define IPPORT_SYSTAT 11
284#define IPPORT_DAYTIME 13
285#define IPPORT_NETSTAT 15
286#define IPPORT_FTP 21
287#define IPPORT_TELNET 23
288#define IPPORT_SMTP 25
289#define IPPORT_TIMESERVER 37
290#define IPPORT_NAMESERVER 42
291#define IPPORT_WHOIS 43
292#define IPPORT_MTP 57
293#define IPPORT_TFTP 69
294#define IPPORT_RJE 77
295#define IPPORT_FINGER 79
296#define IPPORT_TTYLINK 87
297#define IPPORT_SUPDUP 95
298#define IPPORT_EXECSERVER 512
299#define IPPORT_LOGINSERVER 513
300#define IPPORT_CMDSERVER 514
301#define IPPORT_EFSSERVER 520
302#define IPPORT_BIFFUDP 512
303#define IPPORT_WHOSERVER 513
304#define IPPORT_ROUTESERVER 520
305#define IPPORT_RESERVED 1024
306#else /* USE_WS_PREFIX */
307#define WS_IPPORT_ECHO 7
308#define WS_IPPORT_DISCARD 9
309#define WS_IPPORT_SYSTAT 11
310#define WS_IPPORT_DAYTIME 13
311#define WS_IPPORT_NETSTAT 15
312#define WS_IPPORT_FTP 21
313#define WS_IPPORT_TELNET 23
314#define WS_IPPORT_SMTP 25
315#define WS_IPPORT_TIMESERVER 37
316#define WS_IPPORT_NAMESERVER 42
317#define WS_IPPORT_WHOIS 43
318#define WS_IPPORT_MTP 57
319#define WS_IPPORT_TFTP 69
320#define WS_IPPORT_RJE 77
321#define WS_IPPORT_FINGER 79
322#define WS_IPPORT_TTYLINK 87
323#define WS_IPPORT_SUPDUP 95
324#define WS_IPPORT_EXECSERVER 512
325#define WS_IPPORT_LOGINSERVER 513
326#define WS_IPPORT_CMDSERVER 514
327#define WS_IPPORT_EFSSERVER 520
328#define WS_IPPORT_BIFFUDP 512
329#define WS_IPPORT_WHOSERVER 513
330#define WS_IPPORT_ROUTESERVER 520
331#define WS_IPPORT_RESERVED 1024
332#endif /* USE_WS_PREFIX */
333
334typedef struct WS(servent)
Andreas Mohrae509412000-08-03 22:19:09 +0000335{
Francois Gouget27202312001-11-14 21:26:23 +0000336 char* s_name; /* official service name */
337 char** s_aliases; /* alias list */
338 short s_port; /* port # */
339 char* s_proto; /* protocol to use */
340} SERVENT, *PSERVENT, *LPSERVENT;
Andreas Mohrae509412000-08-03 22:19:09 +0000341
Francois Gouget27202312001-11-14 21:26:23 +0000342
343
344/*
345 * Hosts
346 */
347
348typedef struct WS(hostent)
Andreas Mohrae509412000-08-03 22:19:09 +0000349{
Francois Gouget27202312001-11-14 21:26:23 +0000350 char* h_name; /* official name of host */
351 char** h_aliases; /* alias list */
352 short h_addrtype; /* host address type */
353 short h_length; /* length of address */
354 char** h_addr_list; /* list of addresses from name server */
355#define h_addr h_addr_list[0] /* address, for backward compat */
356} HOSTENT, *PHOSTENT, *LPHOSTENT;
Andreas Mohrae509412000-08-03 22:19:09 +0000357
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000358
Francois Gouget27202312001-11-14 21:26:23 +0000359/*
360 * Sockets
361 */
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000362
Martin Wilck9fc8b112002-10-30 20:26:32 +0000363typedef UINT_PTR SOCKET;
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000364
Francois Gouget27202312001-11-14 21:26:23 +0000365/*
366 * This is used instead of -1, since the
367 * SOCKET type is unsigned.
368 */
369#define INVALID_SOCKET (~0)
370#define SOCKET_ERROR (-1)
371
372typedef struct WS(sockaddr)
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000373{
Francois Gouget27202312001-11-14 21:26:23 +0000374 u_short sa_family;
375 char sa_data[14];
376} SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000377
Francois Gouget27202312001-11-14 21:26:23 +0000378typedef struct WS(linger)
379{
380 u_short l_onoff; /* option on/off */
381 u_short l_linger; /* linger time */
382} LINGER, *PLINGER, *LPLINGER;
Jeremy White65cab522000-09-16 20:46:16 +0000383
Francois Gouget27202312001-11-14 21:26:23 +0000384/*
385 * Select
386 */
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000387
Francois Gouget27202312001-11-14 21:26:23 +0000388#ifdef WS_DEFINE_SELECT
Francois Gouget27202312001-11-14 21:26:23 +0000389/* Define our own version of select and the associated types and macros */
390
391# ifndef USE_WS_PREFIX
392# ifndef FD_SETSIZE
393# define FD_SETSIZE 64
394# endif
395# else
396# ifndef WS_FD_SETSIZE
397# define WS_FD_SETSIZE 64
398# endif
399# endif
400
401typedef struct WS(fd_set)
402{
403 u_int fd_count; /* how many are SET? */
404# ifndef USE_WS_PREFIX
405 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
406# else
407 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
408# endif
409} WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
410
411typedef struct WS(timeval)
412{
413 long tv_sec; /* seconds */
414 long tv_usec; /* and microseconds */
415} TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
416
417#define WINE_FD_CLR(fd, set, cast) do { \
418 u_int __i; \
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000419 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000420 { \
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000421 if (((cast*)(set))->fd_array[__i] == fd) \
Francois Gouget27202312001-11-14 21:26:23 +0000422 { \
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000423 while (__i < ((cast*)(set))->fd_count-1) \
Francois Gouget27202312001-11-14 21:26:23 +0000424 { \
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000425 ((cast*)(set))->fd_array[__i] = \
426 ((cast*)(set))->fd_array[__i+1]; \
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000427 __i++; \
428 } \
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000429 ((cast*)(set))->fd_count--; \
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000430 break; \
431 } \
432 } \
433} while(0)
Francois Gouget27202312001-11-14 21:26:23 +0000434#define __WS_FD_SET1(fd, set, cast) do { \
Alexandre Julliard44ed71f1997-12-21 19:17:50 +0000435 if (((cast*)(set))->fd_count < FD_SETSIZE) \
Francois Gouget27202312001-11-14 21:26:23 +0000436 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000437} while(0)
Vincent BĂ©ron9a624912002-05-31 23:06:46 +0000438/* This version checks if the filedesc is already in the list, and appends it
Francois Gouget27202312001-11-14 21:26:23 +0000439 * only if it's not the case
440 */
441#define __WS_FD_SET2(fd, set, cast) do { \
442 u_int __i; \
443 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
444 { \
Patrick J. McNerthney3e2217c2002-09-24 03:05:59 +0000445 if (((cast*)(set))->fd_array[__i]==(fd)) \
Francois Gouget27202312001-11-14 21:26:23 +0000446 break; \
447 } \
448 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
449 { \
450 ((cast*)(set))->fd_count++; \
451 ((cast*)(set))->fd_array[__i]=(fd);\
452 } \
453} while(0)
454
455#ifndef __WINE_WINSOCK2__
Patrick J. McNerthney3e2217c2002-09-24 03:05:59 +0000456#define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
Francois Gouget27202312001-11-14 21:26:23 +0000457#else
Patrick J. McNerthney3e2217c2002-09-24 03:05:59 +0000458#define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
Francois Gouget27202312001-11-14 21:26:23 +0000459#endif
460
461#ifndef USE_WS_PREFIX
Patrick J. McNerthney3e2217c2002-09-24 03:05:59 +0000462#define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
463#define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
464#define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
465#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
Francois Gouget27202312001-11-14 21:26:23 +0000466#else
Patrick J. McNerthney3e2217c2002-09-24 03:05:59 +0000467#define WS_FD_CLR(fd, set) WINE_FD_CLR((fd),(set), WS_fd_set)
468#define WS_FD_SET(fd, set) WINE_FD_SET((fd),(set), WS_fd_set)
469#define WS_FD_ZERO(set) ((WS_fd_set*)(set))->fd_count=0)
470#define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
Francois Gouget27202312001-11-14 21:26:23 +0000471#endif
Alexandre Julliard9ee24132003-04-02 01:38:42 +0000472
Dimitrie O. Paund93f0812003-05-13 00:37:36 +0000473int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
474
Francois Gouget27202312001-11-14 21:26:23 +0000475#endif /* WS_DEFINE_SELECT */
476
Alexandre Julliard9aee7c62003-04-17 02:47:17 +0000477/* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
478#ifndef USE_WS_PREFIX
479
480#undef htonl
481#undef htons
482#undef ntohl
483#undef ntohs
484
485#ifdef WORDS_BIGENDIAN
486
487#define htonl(l) ((u_long)(l))
488#define htons(s) ((u_short)(s))
489#define ntohl(l) ((u_long)(l))
490#define ntohs(s) ((u_short)(s))
491
492#else /* WORDS_BIGENDIAN */
493
494inline static u_short __wine_ushort_swap(u_short s)
495{
496 return (s >> 8) | (s << 8);
497}
498inline static u_long __wine_ulong_swap(u_long l)
499{
Jon Griffithscf2f57f2003-07-19 03:07:16 +0000500 return ((u_long)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
Alexandre Julliard9aee7c62003-04-17 02:47:17 +0000501}
502#define htonl(l) __wine_ulong_swap(l)
503#define htons(s) __wine_ushort_swap(s)
504#define ntohl(l) __wine_ulong_swap(l)
505#define ntohs(s) __wine_ushort_swap(s)
506
507#endif /* WORDS_BIGENDIAN */
508
509#endif /* USE_WS_PREFIX */
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000510
Vincent BĂ©ron9a624912002-05-31 23:06:46 +0000511/*
512 * Internet address (old style... should be updated)
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000513 */
514
Francois Gouget27202312001-11-14 21:26:23 +0000515#ifndef USE_WS_PREFIX
516#define IN_CLASSA_NSHIFT 24
517#define IN_CLASSA_MAX 128
518#define IN_CLASSA_NET 0xff000000
519#define IN_CLASSA_HOST 0x00ffffff
520#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
521#define IN_CLASSB_NSHIFT 16
522#define IN_CLASSB_MAX 65536
523#define IN_CLASSB_NET 0xffff0000
524#define IN_CLASSB_HOST 0x0000ffff
525#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
526#define IN_CLASSC_NSHIFT 8
527#define IN_CLASSC_NET 0xffffff00
528#define IN_CLASSC_HOST 0x000000ff
529#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
530#else
531#define WS_IN_CLASSA_NSHIFT 24
532#define WS_IN_CLASSA_MAX 128
533#define WS_IN_CLASSA_NET 0xff000000
534#define WS_IN_CLASSA_HOST 0x00ffffff
535#define WS_IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
536#define WS_IN_CLASSB_NSHIFT 16
537#define WS_IN_CLASSB_MAX 65536
538#define WS_IN_CLASSB_NET 0xffff0000
539#define WS_IN_CLASSB_HOST 0x0000ffff
540#define WS_IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
541#define WS_IN_CLASSC_NSHIFT 8
542#define WS_IN_CLASSC_NET 0xffffff00
543#define WS_IN_CLASSC_HOST 0x000000ff
544#define WS_IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
545#endif /* USE_WS_PREFIX */
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000546
Francois Gouget27202312001-11-14 21:26:23 +0000547#ifndef USE_WS_PREFIX
548#define INADDR_ANY (u_long)0x00000000
549#define INADDR_LOOPBACK 0x7f000001
550#define INADDR_BROADCAST (u_long)0xffffffff
551#define INADDR_NONE 0xffffffff
552#else
553#define WS_INADDR_ANY (u_long)0x00000000
554#define WS_INADDR_LOOPBACK 0x7f000001
555#define WS_INADDR_BROADCAST (u_long)0xffffffff
556#define WS_INADDR_NONE 0xffffffff
557#endif /* USE_WS_PREFIX */
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000558
Francois Gouget27202312001-11-14 21:26:23 +0000559typedef struct WS(in_addr)
560{
561 union {
562 struct {
563 u_char s_b1,s_b2,s_b3,s_b4;
564 } S_un_b;
565 struct {
566 u_short s_w1,s_w2;
567 } S_un_w;
568 u_long S_addr;
569 } S_un;
570#ifndef USE_WS_PREFIX
571#define s_addr S_un.S_addr
572#define s_host S_un.S_un_b.s_b2
573#define s_net S_un.S_un_b.s_b1
574#define s_imp S_un.S_un_w.s_w2
575#define s_impno S_un.S_un_b.s_b4
576#define s_lh S_un.S_un_b.s_b3
577#else
578#define WS_s_addr S_un.S_addr
579#define WS_s_host S_un.S_un_b.s_b2
580#define WS_s_net S_un.S_un_b.s_b1
581#define WS_s_imp S_un.S_un_w.s_w2
582#define WS_s_impno S_un.S_un_b.s_b4
583#define WS_s_lh S_un.S_un_b.s_b3
584#endif /* USE_WS_PREFIX */
585} IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
586
587typedef struct WS(sockaddr_in)
588{
589 short sin_family;
590 u_short sin_port;
591 struct WS(in_addr) sin_addr;
592 char sin_zero[8];
593} SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
594
Felix Nawothnig18a00452004-03-25 23:36:26 +0000595/*
596 * Multicast group information
597 */
598
Francois Gougetff915d42004-03-31 19:58:46 +0000599#if !defined(__WINE_WINSOCK2__)
Felix Nawothnig18a00452004-03-25 23:36:26 +0000600struct WS(ip_mreq)
601{
602 struct WS(in_addr) imr_multiaddr;
603 struct WS(in_addr) imr_interface;
604};
Francois Gougetff915d42004-03-31 19:58:46 +0000605#endif
Francois Gouget27202312001-11-14 21:26:23 +0000606
607/*
608 * WSAStartup
609 */
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000610#define WSADESCRIPTION_LEN 256
611#define WSASYS_STATUS_LEN 128
612
Francois Gouget27202312001-11-14 21:26:23 +0000613typedef struct WS(WSAData)
614{
615 WORD wVersion;
616 WORD wHighVersion;
617 char szDescription[WSADESCRIPTION_LEN+1];
618 char szSystemStatus[WSASYS_STATUS_LEN+1];
619 WORD iMaxSockets;
620 WORD iMaxUdpDg;
621 char *lpVendorInfo;
Alexandre Julliard1285c2f1996-05-06 16:06:24 +0000622} WSADATA, *LPWSADATA;
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000623
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000624
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000625
626/*
Francois Gouget27202312001-11-14 21:26:23 +0000627 * {get,set}sockopt
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000628 */
Francois Gouget27202312001-11-14 21:26:23 +0000629#ifndef USE_WS_PREFIX
630#define SOL_SOCKET 0xffff
631#define SO_DEBUG 0x0001
632#define SO_ACCEPTCONN 0x0002
633#define SO_REUSEADDR 0x0004
634#define SO_KEEPALIVE 0x0008
635#define SO_DONTROUTE 0x0010
636#define SO_BROADCAST 0x0020
637#define SO_USELOOPBACK 0x0040
638#define SO_LINGER 0x0080
639#define SO_OOBINLINE 0x0100
640#define SO_DONTLINGER (u_int)(~SO_LINGER)
641#define SO_SNDBUF 0x1001
642#define SO_RCVBUF 0x1002
643#define SO_SNDLOWAT 0x1003
644#define SO_RCVLOWAT 0x1004
645#define SO_SNDTIMEO 0x1005
646#define SO_RCVTIMEO 0x1006
647#define SO_ERROR 0x1007
648#define SO_TYPE 0x1008
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000649
Paul Rupe99ed3422001-12-14 22:48:38 +0000650
Francois Gouget27202312001-11-14 21:26:23 +0000651#define IOCPARM_MASK 0x7f
652#define IOC_VOID 0x20000000
653#define IOC_OUT 0x40000000
654#define IOC_IN 0x80000000
655#define IOC_INOUT (IOC_IN|IOC_OUT)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000656
Francois Gouget27202312001-11-14 21:26:23 +0000657#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
658#define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
659#define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000660
Francois Gouget27202312001-11-14 21:26:23 +0000661#else
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000662
Francois Gouget27202312001-11-14 21:26:23 +0000663#define WS_SOL_SOCKET 0xffff
664#define WS_SO_DEBUG 0x0001
665#define WS_SO_ACCEPTCONN 0x0002
666#define WS_SO_REUSEADDR 0x0004
667#define WS_SO_KEEPALIVE 0x0008
668#define WS_SO_DONTROUTE 0x0010
669#define WS_SO_BROADCAST 0x0020
670#define WS_SO_USELOOPBACK 0x0040
671#define WS_SO_LINGER 0x0080
672#define WS_SO_OOBINLINE 0x0100
673#define WS_SO_DONTLINGER (u_int)(~WS_SO_LINGER)
674#define WS_SO_SNDBUF 0x1001
675#define WS_SO_RCVBUF 0x1002
676#define WS_SO_SNDLOWAT 0x1003
677#define WS_SO_RCVLOWAT 0x1004
678#define WS_SO_SNDTIMEO 0x1005
679#define WS_SO_RCVTIMEO 0x1006
680#define WS_SO_ERROR 0x1007
681#define WS_SO_TYPE 0x1008
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000682
Francois Gouget27202312001-11-14 21:26:23 +0000683#define WS_IOCPARM_MASK 0x7f
684#define WS_IOC_VOID 0x20000000
685#define WS_IOC_OUT 0x40000000
686#define WS_IOC_IN 0x80000000
687#define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
688
689#define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
690#define WS__IOR(x,y,t) (WS_IOC_OUT|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
691#define WS__IOW(x,y,t) (WS_IOC_IN|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
692
693#endif
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000694
Marcus Meissner5eaf7751999-03-09 17:31:42 +0000695/* IPPROTO_TCP options */
Francois Gouget27202312001-11-14 21:26:23 +0000696#ifndef USE_WS_PREFIX
697#define TCP_NODELAY 1
698#else
699#define WS_TCP_NODELAY 1
700#endif
Marcus Meissner5eaf7751999-03-09 17:31:42 +0000701
Mike Hearnceb86a92003-04-04 22:04:47 +0000702/* IPPROTO_IP options */
703#ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
704# ifndef USE_WS_PREFIX
705# define IP_OPTIONS 1
706# define IP_MULTICAST_IF 2
707# define IP_MULTICAST_TTL 3
708# define IP_MULTICAST_LOOP 4
709# define IP_ADD_MEMBERSHIP 5
710# define IP_DROP_MEMBERSHIP 6
711# define IP_TTL 7
712# define IP_TOS 8
713# define IP_DONTFRAGMENT 9
714# else
715# define WS_IP_OPTIONS 1
716# define WS_IP_MULTICAST_IF 2
717# define WS_IP_MULTICAST_TTL 3
718# define WS_IP_MULTICAST_LOOP 4
719# define WS_IP_ADD_MEMBERSHIP 5
720# define WS_IP_DROP_MEMBERSHIP 6
721# define WS_IP_TTL 7
722# define WS_IP_TOS 8
723# define WS_IP_DONTFRAGMENT 9
724# endif
725#endif
726
727
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000728/*
729 * Socket I/O flags (supported by spec 1.1)
730 */
Francois Gouget27202312001-11-14 21:26:23 +0000731#ifndef USE_WS_PREFIX
732#define FIONREAD _IOR('f', 127, u_long)
733#define FIONBIO _IOW('f', 126, u_long)
734#define SIOCATMARK _IOR('s', 7, u_long)
735#else
736#define WS_FIONREAD WS__IOR('f', 127, u_long)
737#define WS_FIONBIO WS__IOW('f', 126, u_long)
738#define WS_SIOCATMARK WS__IOR('s', 7, u_long)
739#endif
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000740
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000741/*
742 * Maximum queue length specifiable by listen.
743 */
Francois Gouget27202312001-11-14 21:26:23 +0000744#ifndef USE_WS_PREFIX
745#define SOMAXCONN 5
Alexandre Julliard58199531994-04-21 01:20:00 +0000746
Francois Gouget27202312001-11-14 21:26:23 +0000747#define MSG_OOB 0x0001
748#define MSG_PEEK 0x0002
749#define MSG_DONTROUTE 0x0004
750#define MSG_MAXIOVLEN 0x000a
751#define MSG_PARTIAL 0x8000
752#else /* USE_WS_PREFIX */
753#define WS_SOMAXCONN 5
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000754
Francois Gouget27202312001-11-14 21:26:23 +0000755#define WS_MSG_OOB 0x0001
756#define WS_MSG_PEEK 0x0002
757#define WS_MSG_DONTROUTE 0x0004
758#define WS_MSG_MAXIOVLEN 0x000a
759#define WS_MSG_PARTIAL 0x8000
760#endif /* USE_WS_PREFIX */
Moses DeJonge0a3ba51999-11-23 22:29:00 +0000761
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000762/*
763 * Define constant based on rfc883, used by gethostbyxxxx() calls.
764 */
Francois Gouget27202312001-11-14 21:26:23 +0000765#ifndef USE_WS_PREFIX
766#define MAXGETHOSTSTRUCT 1024
767#else
768#define MAXGETHOSTSTRUCT 1024
769#endif
770
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000771
772/*
773 * Define flags to be used with the WSAAsyncSelect() call.
774 */
Francois Gouget126e6b82001-08-24 19:14:56 +0000775#define FD_READ 0x00000001
776#define FD_WRITE 0x00000002
777#define FD_OOB 0x00000004
778#define FD_ACCEPT 0x00000008
779#define FD_CONNECT 0x00000010
780#define FD_CLOSE 0x00000020
Alexandre Julliardda0cfb31996-12-01 17:17:47 +0000781
Francois Gouget126e6b82001-08-24 19:14:56 +0000782/* internal per-socket flags */
Dimitrie O. Paun8b366812003-01-04 00:52:18 +0000783#ifdef __WINESRC__
Francois Gouget126e6b82001-08-24 19:14:56 +0000784#define FD_WINE_LISTENING 0x10000000
785#define FD_WINE_NONBLOCKING 0x20000000
786#define FD_WINE_CONNECTED 0x40000000
787#define FD_WINE_RAW 0x80000000
Francois Gouget126e6b82001-08-24 19:14:56 +0000788#define FD_WINE_INTERNAL 0xFFFF0000
789#endif
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000790
791/*
792 * All Windows Sockets error constants are biased by WSABASEERR from
793 * the "normal"
794 */
Francois Gouget27202312001-11-14 21:26:23 +0000795#define WSABASEERR 10000
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000796/*
797 * Windows Sockets definitions of regular Microsoft C error constants
798 */
Francois Gouget27202312001-11-14 21:26:23 +0000799#define WSAEINTR (WSABASEERR+4)
800#define WSAEBADF (WSABASEERR+9)
801#define WSAEACCES (WSABASEERR+13)
802#define WSAEFAULT (WSABASEERR+14)
803#define WSAEINVAL (WSABASEERR+22)
804#define WSAEMFILE (WSABASEERR+24)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000805
806/*
807 * Windows Sockets definitions of regular Berkeley error constants
808 */
Francois Gouget27202312001-11-14 21:26:23 +0000809#define WSAEWOULDBLOCK (WSABASEERR+35)
810#define WSAEINPROGRESS (WSABASEERR+36)
811#define WSAEALREADY (WSABASEERR+37)
812#define WSAENOTSOCK (WSABASEERR+38)
813#define WSAEDESTADDRREQ (WSABASEERR+39)
814#define WSAEMSGSIZE (WSABASEERR+40)
815#define WSAEPROTOTYPE (WSABASEERR+41)
816#define WSAENOPROTOOPT (WSABASEERR+42)
817#define WSAEPROTONOSUPPORT (WSABASEERR+43)
818#define WSAESOCKTNOSUPPORT (WSABASEERR+44)
819#define WSAEOPNOTSUPP (WSABASEERR+45)
820#define WSAEPFNOSUPPORT (WSABASEERR+46)
821#define WSAEAFNOSUPPORT (WSABASEERR+47)
822#define WSAEADDRINUSE (WSABASEERR+48)
823#define WSAEADDRNOTAVAIL (WSABASEERR+49)
824#define WSAENETDOWN (WSABASEERR+50)
825#define WSAENETUNREACH (WSABASEERR+51)
826#define WSAENETRESET (WSABASEERR+52)
827#define WSAECONNABORTED (WSABASEERR+53)
828#define WSAECONNRESET (WSABASEERR+54)
829#define WSAENOBUFS (WSABASEERR+55)
830#define WSAEISCONN (WSABASEERR+56)
831#define WSAENOTCONN (WSABASEERR+57)
832#define WSAESHUTDOWN (WSABASEERR+58)
833#define WSAETOOMANYREFS (WSABASEERR+59)
834#define WSAETIMEDOUT (WSABASEERR+60)
835#define WSAECONNREFUSED (WSABASEERR+61)
836#define WSAELOOP (WSABASEERR+62)
837#define WSAENAMETOOLONG (WSABASEERR+63)
838#define WSAEHOSTDOWN (WSABASEERR+64)
839#define WSAEHOSTUNREACH (WSABASEERR+65)
840#define WSAENOTEMPTY (WSABASEERR+66)
841#define WSAEPROCLIM (WSABASEERR+67)
842#define WSAEUSERS (WSABASEERR+68)
843#define WSAEDQUOT (WSABASEERR+69)
844#define WSAESTALE (WSABASEERR+70)
845#define WSAEREMOTE (WSABASEERR+71)
Dimitrie O. Paunce1a4302002-11-21 23:44:19 +0000846#define WSAEDISCON (WSABASEERR+101)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000847
848/*
849 * Extended Windows Sockets error constant definitions
850 */
Francois Gouget27202312001-11-14 21:26:23 +0000851#define WSASYSNOTREADY (WSABASEERR+91)
852#define WSAVERNOTSUPPORTED (WSABASEERR+92)
853#define WSANOTINITIALISED (WSABASEERR+93)
Vitaliy Margolenda7d5ac2003-04-09 23:33:50 +0000854#define WSAEDISCON (WSABASEERR+101)
855#define WSAENOMORE (WSABASEERR+102)
856#define WSAECANCELLED (WSABASEERR+103)
857#define WSAEINVALIDPROCTABLE (WSABASEERR+104)
858#define WSAEINVALIDPROVIDER (WSABASEERR+105)
859#define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
860#define WSASYSCALLFAILURE (WSABASEERR+107)
861#define WSASERVICE_NOT_FOUND (WSABASEERR+108)
862#define WSATYPE_NOT_FOUND (WSABASEERR+109)
863#define WSA_E_NO_MORE (WSABASEERR+110)
864#define WSA_E_CANCELLED (WSABASEERR+111)
865#define WSAEREFUSED (WSABASEERR+112)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000866
867/*
868 * Error return codes from gethostbyname() and gethostbyaddr()
869 * (when using the resolver). Note that these errors are
870 * retrieved via WSAGetLastError() and must therefore follow
871 * the rules for avoiding clashes with error numbers from
872 * specific implementations or language run-time systems.
873 * For this reason the codes are based at WSABASEERR+1001.
874 * Note also that [WSA]NO_ADDRESS is defined only for
875 * compatibility purposes.
876 */
877
Francois Gouget27202312001-11-14 21:26:23 +0000878#ifndef USE_WS_PREFIX
879#define h_errno WSAGetLastError()
880#else
881#define WS_h_errno WSAGetLastError()
882#endif
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000883
884/* Authoritative Answer: Host not found */
Francois Gouget27202312001-11-14 21:26:23 +0000885#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000886
887/* Non-Authoritative: Host not found, or SERVERFAIL */
Francois Gouget27202312001-11-14 21:26:23 +0000888#define WSATRY_AGAIN (WSABASEERR+1002)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000889
890/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
Francois Gouget27202312001-11-14 21:26:23 +0000891#define WSANO_RECOVERY (WSABASEERR+1003)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000892
893/* Valid name, no data record of requested type */
Francois Gouget27202312001-11-14 21:26:23 +0000894#define WSANO_DATA (WSABASEERR+1004)
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000895
896/* no address, look for MX record */
Francois Gouget27202312001-11-14 21:26:23 +0000897#define WSANO_ADDRESS WSANO_DATA
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000898
Francois Gouget27202312001-11-14 21:26:23 +0000899#ifndef USE_WS_PREFIX
900#define HOST_NOT_FOUND WSAHOST_NOT_FOUND
901#define TRY_AGAIN WSATRY_AGAIN
902#define NO_RECOVERY WSANO_RECOVERY
903#define NO_DATA WSANO_DATA
904#define NO_ADDRESS WSANO_ADDRESS
905#endif /* USE_WS_PREFIX */
Stephen Langasek12392cd1998-11-14 16:47:09 +0000906
Patrik Stridvall896889f1999-05-08 12:50:36 +0000907
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000908
909/*
910 * Windows message parameter composition and decomposition
911 * macros.
Francois Gouget27202312001-11-14 21:26:23 +0000912 */
913
914/*
Alexandre Julliardfb9a9191994-03-01 19:48:04 +0000915 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
916 * when constructing the response to a WSAAsyncGetXByY() routine.
917 */
918#define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
919/*
920 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
921 * when constructing the response to WSAAsyncSelect().
922 */
923#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
924/*
925 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
926 * to extract the buffer length from the lParam in the response
927 * to a WSAGetXByY().
928 */
929#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
930/*
931 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
932 * to extract the error code from the lParam in the response
933 * to a WSAGetXByY().
934 */
935#define WSAGETASYNCERROR(lParam) HIWORD(lParam)
936/*
937 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
938 * to extract the event code from the lParam in the response
939 * to a WSAAsyncSelect().
940 */
941#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
942/*
943 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
944 * to extract the error code from the lParam in the response
945 * to a WSAAsyncSelect().
946 */
947#define WSAGETSELECTERROR(lParam) HIWORD(lParam)
948
Francois Gouget27202312001-11-14 21:26:23 +0000949
950
951/*
952 * Prototypes
953 *
Vincent BĂ©ron9a624912002-05-31 23:06:46 +0000954 * Remember to keep this section in sync with the
Francois Gouget27202312001-11-14 21:26:23 +0000955 * "Winsock Function Typedefs" section in winsock2.h.
956 */
957#if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
958HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,u_int,const char*,int,int,char*,int);
959HANDLE WINAPI WSAAsyncGetHostByName(HWND,u_int,const char*,char*,int);
960HANDLE WINAPI WSAAsyncGetProtoByName(HWND,u_int,const char*,char*,int);
961HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,u_int,int,char*,int);
962HANDLE WINAPI WSAAsyncGetServByName(HWND,u_int,const char*,const char*,char*,int);
963HANDLE WINAPI WSAAsyncGetServByPort(HWND,u_int,int,const char*,char*,int);
964int WINAPI WSAAsyncSelect(SOCKET,HWND,u_int,long);
965int WINAPI WSACancelAsyncRequest(HANDLE);
966int WINAPI WSACancelBlockingCall(void);
967int WINAPI WSACleanup(void);
968int WINAPI WSAGetLastError(void);
969BOOL WINAPI WSAIsBlocking(void);
970FARPROC WINAPI WSASetBlockingHook(FARPROC);
971void WINAPI WSASetLastError(int);
972int WINAPI WSAStartup(WORD,LPWSADATA);
973int WINAPI WSAUnhookBlockingHook(void);
974
975SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
976int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
977int WINAPI WS(closesocket)(SOCKET);
978int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
979struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
980struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
Francois Gouget9e881be2002-04-01 21:01:13 +0000981/* gethostname not defined because of conflicts with unistd.h */
Francois Gouget27202312001-11-14 21:26:23 +0000982int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
983struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
984struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
985#ifdef WS_DEFINE_SELECT
Patrick J. McNerthney3e2217c2002-09-24 03:05:59 +0000986int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
Francois Gouget27202312001-11-14 21:26:23 +0000987#endif
988struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
989struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
990int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
991int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
Francois Gouget27202312001-11-14 21:26:23 +0000992unsigned long WINAPI WS(inet_addr)(const char*);
993char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
994int WINAPI WS(ioctlsocket)(SOCKET,long,u_long*);
995int WINAPI WS(listen)(SOCKET,int);
Francois Gouget27202312001-11-14 21:26:23 +0000996int WINAPI WS(recv)(SOCKET,char*,int,int);
997int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
998int WINAPI WS(send)(SOCKET,const char*,int,int);
999int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
1000int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
1001int WINAPI WS(shutdown)(SOCKET,int);
1002SOCKET WINAPI WS(socket)(int,int,int);
1003
Francois Gouget27202312001-11-14 21:26:23 +00001004#endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
1005
1006
Dimitrie O. Paun53f9c212003-08-28 21:43:34 +00001007#include <poppack.h>
Francois Gouget27202312001-11-14 21:26:23 +00001008
Patrik Stridvall14da7b11999-06-12 10:53:06 +00001009#ifdef __cplusplus
Francois Gouget27202312001-11-14 21:26:23 +00001010}
1011#endif
1012
1013#ifndef __WINE_WINSOCK2__
1014#undef WS
1015#undef WS_API_PROTOTYPES
1016#undef WS_API_TYPEDEFS
1017#endif
Patrik Stridvall14da7b11999-06-12 10:53:06 +00001018
Alexandre Julliardfb9a9191994-03-01 19:48:04 +00001019#endif /* _WINSOCKAPI_ */