VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/shaderlib/wine/include/winsock.h

最後變更 在這個檔案是 53206,由 vboxsync 提交於 10 年 前

Devices/vmsvga: header fixes

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 34.7 KB
 
1/* 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.
5 *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23/*
24 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
25 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
26 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
27 * a choice of LGPL license versions is made available with the language indicating
28 * that LGPLv2 or any later version may be used, or where a choice of which version
29 * of the LGPL is applied is otherwise unspecified.
30 */
31
32#ifdef __WINESRC__
33# ifndef __WINE_WINSOCK2__
34# error Please use Winsock2 in Wine
35# endif
36#endif
37
38#ifndef __WINE_WINSOCKAPI_STDLIB_H
39#define __WINE_WINSOCKAPI_STDLIB_H
40
41/*
42 * This section defines the items that conflict with the Unix headers.
43 */
44#ifndef USE_WS_PREFIX
45/* We are not using the WS_ prefix we risk getting conflicts for
46 * everything related to select.
47 */
48# ifdef FD_CLR
49/* Too late, the Unix version of stdlib.h was included before winsock.h.
50 * This means select and all the related stuff is already defined and we
51 * cannot override types and function prototypes.
52 * All we can do is disable all these symbols so that they are not used
53 * inadvertently.
54 */
55# include <sys/types.h>
56# undef FD_SETSIZE
57# undef FD_CLR
58# undef FD_SET
59# undef FD_ZERO
60# undef FD_ISSET
61
62# define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
63# define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
64# define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
65# define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
66# define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
67# define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
68# define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
69# elif defined(RLIM_INFINITY)
70/* On Darwin stdlib.h includes sys/resource.h which defines timeval but not the fd_set macros */
71# define fd_set unix_fd_set
72# include <sys/types.h>
73# include <time.h>
74# include <stdlib.h>
75# undef fd_set
76# undef FD_SETSIZE
77# undef FD_CLR
78# undef FD_SET
79# undef FD_ZERO
80# undef FD_ISSET
81# define select Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
82# define timeval Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
83# else /* FD_CLR */
84/* stdlib.h has not been included yet so it's not too late. Include it now
85 * making sure that none of the select symbols is affected. Then we can
86 * define them with our own values.
87 */
88# define fd_set unix_fd_set
89# define timeval unix_timeval
90# define select unix_select
91# define socklen_t unix_socklen_t
92# define u_long unix_u_long
93# include <sys/types.h>
94# include <time.h>
95# include <stdlib.h>
96# undef fd_set
97# undef timeval
98# undef select
99# undef socklen_t
100# undef u_long
101# undef FD_SETSIZE
102# undef FD_CLR
103# undef FD_SET
104# undef FD_ZERO
105# undef FD_ISSET
106# undef _TIMEVAL_DEFINED
107
108# define WS_DEFINE_SELECT
109# endif /* FD_CLR */
110
111#else
112# define WS_DEFINE_SELECT
113# include <sys/types.h>
114# include <stdlib.h>
115#endif /* !USE_WS_PREFIX */
116
117#endif /* __WINE_WINSOCKAPI_STDLIB_H */
118
119#include <windows.h>
120
121#ifndef _WINSOCKAPI_
122#define _WINSOCKAPI_
123
124#include <inaddr.h>
125
126#ifdef USE_WS_PREFIX
127typedef unsigned char WS_u_char;
128typedef unsigned short WS_u_short;
129typedef unsigned int WS_u_int;
130typedef ULONG WS_u_long;
131#elif (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED)
132/* MinGW doesn't define the u_xxx types */
133typedef unsigned char u_char;
134typedef unsigned short u_short;
135typedef unsigned int u_int;
136typedef ULONG u_long;
137#define _BSDTYPES_DEFINED
138#else
139#define u_long ULONG /* make sure we don't use the system u_long */
140#endif
141
142#ifdef USE_WS_PREFIX
143# define WS(x) WS_##x
144#else
145# define WS(x) x
146#endif
147
148#ifdef __cplusplus
149extern "C" {
150#endif /* defined(__cplusplus) */
151
152/*
153 * Address families
154 */
155#ifndef USE_WS_PREFIX
156#define AF_UNSPEC 0
157#define AF_UNIX 1
158#define AF_INET 2
159#define AF_IMPLINK 3
160#define AF_PUP 4
161#define AF_CHAOS 5
162#define AF_NS 6
163#define AF_IPX AF_NS
164#define AF_ISO 7
165#define AF_OSI AF_ISO
166#define AF_ECMA 8
167#define AF_DATAKIT 9
168#define AF_CCITT 10
169#define AF_SNA 11
170#define AF_DECnet 12
171#define AF_DLI 13
172#define AF_LAT 14
173#define AF_HYLINK 15
174#define AF_APPLETALK 16
175#define AF_NETBIOS 17
176#define AF_VOICEVIEW 18
177#define AF_FIREFOX 19
178#define AF_UNKNOWN1 20
179#define AF_BAN 21
180#define AF_ATM 22
181#define AF_INET6 23
182#define AF_CLUSTER 24
183#define AF_12844 25
184#define AF_IRDA 26
185#define AF_MAX 27
186#define PF_UNSPEC AF_UNSPEC
187#define PF_UNIX AF_UNIX
188#define PF_INET AF_INET
189#define PF_IMPLINK AF_IMPLINK
190#define PF_PUP AF_PUP
191#define PF_CHAOS AF_CHAOS
192#define PF_NS AF_NS
193#define PF_IPX AF_IPX
194#define PF_ISO AF_ISO
195#define PF_OSI AF_OSI
196#define PF_ECMA AF_ECMA
197#define PF_DATAKIT AF_DATAKIT
198#define PF_CCITT AF_CCITT
199#define PF_SNA AF_SNA
200#define PF_DECnet AF_DECnet
201#define PF_DLI AF_DLI
202#define PF_LAT AF_LAT
203#define PF_HYLINK AF_HYLINK
204#define PF_APPLETALK AF_APPLETALK
205#define PF_VOICEVIEW AF_VOICEVIEW
206#define PF_FIREFOX AF_FIREFOX
207#define PF_UNKNOWN1 AF_UNKNOWN1
208#define PF_BAN AF_BAN
209#define PF_MAX AF_MAX
210#else /* USE_WS_PREFIX */
211#define WS_AF_UNSPEC 0
212#define WS_AF_UNIX 1
213#define WS_AF_INET 2
214#define WS_AF_IMPLINK 3
215#define WS_AF_PUP 4
216#define WS_AF_CHAOS 5
217#define WS_AF_NS 6
218#define WS_AF_IPX WS_AF_NS
219#define WS_AF_ISO 7
220#define WS_AF_OSI AF_ISO
221#define WS_AF_ECMA 8
222#define WS_AF_DATAKIT 9
223#define WS_AF_CCITT 10
224#define WS_AF_SNA 11
225#define WS_AF_DECnet 12
226#define WS_AF_DLI 13
227#define WS_AF_LAT 14
228#define WS_AF_HYLINK 15
229#define WS_AF_APPLETALK 16
230#define WS_AF_NETBIOS 17
231#define WS_AF_VOICEVIEW 18
232#define WS_AF_FIREFOX 19
233#define WS_AF_UNKNOWN1 20
234#define WS_AF_BAN 21
235#define WS_AF_ATM 22
236#define WS_AF_INET6 23
237#define WS_AF_CLUSTER 24
238#define WS_AF_12844 25
239#define WS_AF_IRDA 26
240#define WS_AF_MAX 27
241#endif /* USE_WS_PREFIX */
242
243/*
244 * Types
245 */
246#ifndef USE_WS_PREFIX
247#define SOCK_STREAM 1
248#define SOCK_DGRAM 2
249#define SOCK_RAW 3
250#define SOCK_RDM 4
251#define SOCK_SEQPACKET 5
252#else /* USE_WS_PREFIX */
253#define WS_SOCK_STREAM 1
254#define WS_SOCK_DGRAM 2
255#define WS_SOCK_RAW 3
256#define WS_SOCK_RDM 4
257#define WS_SOCK_SEQPACKET 5
258#endif /* USE_WS_PREFIX */
259
260
261/*
262 * Protocols
263 */
264#ifndef USE_WS_PREFIX
265#define IPPROTO_IP 0
266#define IPPROTO_ICMP 1
267#define IPPROTO_IGMP 2
268#define IPPROTO_GGP 3
269#define IPPROTO_TCP 6
270#define IPPROTO_UDP 17
271#define IPPROTO_IDP 22
272#define IPPROTO_IPV6 41
273#define IPPROTO_ND 77
274#define IPPROTO_RAW 255
275#define IPPROTO_MAX 256
276#else /* USE_WS_PREFIX */
277#define WS_IPPROTO_IP 0
278#define WS_IPPROTO_ICMP 1
279#define WS_IPPROTO_IGMP 2
280#define WS_IPPROTO_GGP 3
281#define WS_IPPROTO_TCP 6
282#define WS_IPPROTO_UDP 17
283#define WS_IPPROTO_IDP 22
284#define WS_IPPROTO_IPV6 41
285#define WS_IPPROTO_ND 77
286#define WS_IPPROTO_RAW 255
287#define WS_IPPROTO_MAX 256
288#endif /* USE_WS_PREFIX */
289
290typedef struct WS(protoent)
291{
292 char* p_name;
293 char** p_aliases;
294 short p_proto;
295} PROTOENT, *PPROTOENT, *LPPROTOENT;
296
297
298
299/*
300 * Networks
301 */
302struct WS(netent)
303{
304 char* n_name; /* official name of net */
305 char** n_aliases; /* alias list */
306 short n_addrtype; /* net address type */
307 ULONG n_net; /* network # */
308};
309
310
311/*
312 * Services
313 */
314#ifndef USE_WS_PREFIX
315#define IPPORT_ECHO 7
316#define IPPORT_DISCARD 9
317#define IPPORT_SYSTAT 11
318#define IPPORT_DAYTIME 13
319#define IPPORT_NETSTAT 15
320#define IPPORT_FTP 21
321#define IPPORT_TELNET 23
322#define IPPORT_SMTP 25
323#define IPPORT_TIMESERVER 37
324#define IPPORT_NAMESERVER 42
325#define IPPORT_WHOIS 43
326#define IPPORT_MTP 57
327#define IPPORT_TFTP 69
328#define IPPORT_RJE 77
329#define IPPORT_FINGER 79
330#define IPPORT_TTYLINK 87
331#define IPPORT_SUPDUP 95
332#define IPPORT_EXECSERVER 512
333#define IPPORT_LOGINSERVER 513
334#define IPPORT_CMDSERVER 514
335#define IPPORT_EFSSERVER 520
336#define IPPORT_BIFFUDP 512
337#define IPPORT_WHOSERVER 513
338#define IPPORT_ROUTESERVER 520
339#define IPPORT_RESERVED 1024
340#else /* USE_WS_PREFIX */
341#define WS_IPPORT_ECHO 7
342#define WS_IPPORT_DISCARD 9
343#define WS_IPPORT_SYSTAT 11
344#define WS_IPPORT_DAYTIME 13
345#define WS_IPPORT_NETSTAT 15
346#define WS_IPPORT_FTP 21
347#define WS_IPPORT_TELNET 23
348#define WS_IPPORT_SMTP 25
349#define WS_IPPORT_TIMESERVER 37
350#define WS_IPPORT_NAMESERVER 42
351#define WS_IPPORT_WHOIS 43
352#define WS_IPPORT_MTP 57
353#define WS_IPPORT_TFTP 69
354#define WS_IPPORT_RJE 77
355#define WS_IPPORT_FINGER 79
356#define WS_IPPORT_TTYLINK 87
357#define WS_IPPORT_SUPDUP 95
358#define WS_IPPORT_EXECSERVER 512
359#define WS_IPPORT_LOGINSERVER 513
360#define WS_IPPORT_CMDSERVER 514
361#define WS_IPPORT_EFSSERVER 520
362#define WS_IPPORT_BIFFUDP 512
363#define WS_IPPORT_WHOSERVER 513
364#define WS_IPPORT_ROUTESERVER 520
365#define WS_IPPORT_RESERVED 1024
366#endif /* USE_WS_PREFIX */
367
368typedef struct WS(servent)
369{
370 char* s_name; /* official service name */
371 char** s_aliases; /* alias list */
372#ifdef _WIN64
373 char* s_proto; /* protocol to use */
374 short s_port; /* port # */
375#else
376 short s_port; /* port # */
377 char* s_proto; /* protocol to use */
378#endif
379} SERVENT, *PSERVENT, *LPSERVENT;
380
381
382
383/*
384 * Hosts
385 */
386
387typedef struct WS(hostent)
388{
389 char* h_name; /* official name of host */
390 char** h_aliases; /* alias list */
391 short h_addrtype; /* host address type */
392 short h_length; /* length of address */
393 char** h_addr_list; /* list of addresses from name server */
394#define h_addr h_addr_list[0] /* address, for backward compat */
395} HOSTENT, *PHOSTENT, *LPHOSTENT;
396
397
398/*
399 * Sockets
400 */
401
402typedef UINT_PTR SOCKET;
403
404/*
405 * This is used instead of -1, since the
406 * SOCKET type is unsigned.
407 */
408#define INVALID_SOCKET (SOCKET)(~0)
409#define SOCKET_ERROR (-1)
410
411typedef struct WS(sockaddr)
412{
413 WS(u_short) sa_family;
414 char sa_data[14];
415} SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
416
417typedef struct WS(linger)
418{
419 WS(u_short) l_onoff; /* option on/off */
420 WS(u_short) l_linger; /* linger time */
421} LINGER, *PLINGER, *LPLINGER;
422
423/*
424 * Select
425 */
426
427#ifdef WS_DEFINE_SELECT
428/* Define our own version of select and the associated types and macros */
429
430# ifndef USE_WS_PREFIX
431# ifndef FD_SETSIZE
432# define FD_SETSIZE 64
433# endif
434# else
435# ifndef WS_FD_SETSIZE
436# define WS_FD_SETSIZE 64
437# endif
438# endif
439
440typedef struct WS(fd_set)
441{
442 WS(u_int) fd_count; /* how many are SET? */
443# ifndef USE_WS_PREFIX
444 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
445# else
446 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
447# endif
448} WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
449
450#ifndef _TIMEVAL_DEFINED
451#define _TIMEVAL_DEFINED
452typedef struct WS(timeval)
453{
454 LONG tv_sec; /* seconds */
455 LONG tv_usec; /* and microseconds */
456} TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
457#endif
458
459#define __WS_FD_CLR(fd, set, cast) do { \
460 unsigned int __i; \
461 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
462 { \
463 if (((cast*)(set))->fd_array[__i] == fd) \
464 { \
465 while (__i < ((cast*)(set))->fd_count-1) \
466 { \
467 ((cast*)(set))->fd_array[__i] = \
468 ((cast*)(set))->fd_array[__i+1]; \
469 __i++; \
470 } \
471 ((cast*)(set))->fd_count--; \
472 break; \
473 } \
474 } \
475} while(0)
476#define __WS_FD_SET1(fd, set, cast) do { \
477 if (((cast*)(set))->fd_count < FD_SETSIZE) \
478 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
479} while(0)
480/* This version checks if the filedesc is already in the list, and appends it
481 * only if it's not the case
482 */
483#define __WS_FD_SET2(fd, set, cast) do { \
484 unsigned int __i; \
485 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
486 { \
487 if (((cast*)(set))->fd_array[__i]==(fd)) \
488 break; \
489 } \
490 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
491 { \
492 ((cast*)(set))->fd_count++; \
493 ((cast*)(set))->fd_array[__i]=(fd);\
494 } \
495} while(0)
496
497#ifndef __WINE_WINSOCK2__
498#define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
499#else
500#define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
501#endif
502
503#ifndef USE_WS_PREFIX
504#define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
505#define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
506#define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
507#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
508#else
509#define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
510#define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
511#define WS_FD_ZERO(set) (((WS_fd_set*)(set))->fd_count=0)
512#define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
513#endif
514
515int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
516
517#endif /* WS_DEFINE_SELECT */
518
519/* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
520#ifndef USE_WS_PREFIX
521
522#undef htonl
523#undef htons
524#undef ntohl
525#undef ntohs
526
527#ifdef WORDS_BIGENDIAN
528
529#define htonl(l) ((ULONG)(l))
530#define htons(s) ((u_short)(s))
531#define ntohl(l) ((ULONG)(l))
532#define ntohs(s) ((u_short)(s))
533
534#else /* WORDS_BIGENDIAN */
535
536static inline u_short __wine_ushort_swap(u_short s)
537{
538 return (s >> 8) | (s << 8);
539}
540static inline ULONG __wine_ulong_swap(ULONG l)
541{
542 return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
543}
544#define htonl(l) __wine_ulong_swap(l)
545#define htons(s) __wine_ushort_swap(s)
546#define ntohl(l) __wine_ulong_swap(l)
547#define ntohs(s) __wine_ushort_swap(s)
548
549#endif /* WORDS_BIGENDIAN */
550
551#endif /* USE_WS_PREFIX */
552
553/*
554 * Internet address (old style... should be updated)
555 */
556
557#ifndef USE_WS_PREFIX
558#define IN_CLASSA_NSHIFT 24
559#define IN_CLASSA_MAX 128
560#define IN_CLASSA_NET 0xff000000
561#define IN_CLASSA_HOST 0x00ffffff
562#define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
563#define IN_CLASSB_NSHIFT 16
564#define IN_CLASSB_MAX 65536
565#define IN_CLASSB_NET 0xffff0000
566#define IN_CLASSB_HOST 0x0000ffff
567#define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
568#define IN_CLASSC_NSHIFT 8
569#define IN_CLASSC_NET 0xffffff00
570#define IN_CLASSC_HOST 0x000000ff
571#define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
572#else
573#define WS_IN_CLASSA_NSHIFT 24
574#define WS_IN_CLASSA_MAX 128
575#define WS_IN_CLASSA_NET 0xff000000
576#define WS_IN_CLASSA_HOST 0x00ffffff
577#define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
578#define WS_IN_CLASSB_NSHIFT 16
579#define WS_IN_CLASSB_MAX 65536
580#define WS_IN_CLASSB_NET 0xffff0000
581#define WS_IN_CLASSB_HOST 0x0000ffff
582#define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
583#define WS_IN_CLASSC_NSHIFT 8
584#define WS_IN_CLASSC_NET 0xffffff00
585#define WS_IN_CLASSC_HOST 0x000000ff
586#define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
587#endif /* USE_WS_PREFIX */
588
589#ifndef USE_WS_PREFIX
590#define INADDR_ANY ((ULONG)0x00000000)
591#define INADDR_LOOPBACK 0x7f000001
592#define INADDR_BROADCAST ((ULONG)0xffffffff)
593#define INADDR_NONE 0xffffffff
594#else
595#define WS_INADDR_ANY ((ULONG)0x00000000)
596#define WS_INADDR_LOOPBACK 0x7f000001
597#define WS_INADDR_BROADCAST ((ULONG)0xffffffff)
598#define WS_INADDR_NONE 0xffffffff
599#endif /* USE_WS_PREFIX */
600
601typedef struct WS(sockaddr_in)
602{
603 short sin_family;
604 WS(u_short) sin_port;
605 struct WS(in_addr) sin_addr;
606 char sin_zero[8];
607} SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
608
609/*
610 * Multicast group information
611 */
612
613#if !defined(__WINE_WINSOCK2__)
614struct WS(ip_mreq)
615{
616 struct WS(in_addr) imr_multiaddr;
617 struct WS(in_addr) imr_interface;
618};
619#endif
620
621/*
622 * WSAStartup
623 */
624#define WSADESCRIPTION_LEN 256
625#define WSASYS_STATUS_LEN 128
626
627typedef struct WS(WSAData)
628{
629 WORD wVersion;
630 WORD wHighVersion;
631#ifdef _WIN64
632 WORD iMaxSockets;
633 WORD iMaxUdpDg;
634 char *lpVendorInfo;
635 char szDescription[WSADESCRIPTION_LEN+1];
636 char szSystemStatus[WSASYS_STATUS_LEN+1];
637#else
638 char szDescription[WSADESCRIPTION_LEN+1];
639 char szSystemStatus[WSASYS_STATUS_LEN+1];
640 WORD iMaxSockets;
641 WORD iMaxUdpDg;
642 char *lpVendorInfo;
643#endif
644} WSADATA, *LPWSADATA;
645
646
647
648/*
649 * {get,set}sockopt
650 */
651#ifndef USE_WS_PREFIX
652#define SOL_SOCKET 0xffff
653#define SO_DEBUG 0x0001
654#define SO_ACCEPTCONN 0x0002
655#define SO_REUSEADDR 0x0004
656#define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR))
657#define SO_KEEPALIVE 0x0008
658#define SO_DONTROUTE 0x0010
659#define SO_BROADCAST 0x0020
660#define SO_USELOOPBACK 0x0040
661#define SO_LINGER 0x0080
662#define SO_OOBINLINE 0x0100
663#define SO_DONTLINGER ((u_int)(~SO_LINGER))
664#define SO_SNDBUF 0x1001
665#define SO_RCVBUF 0x1002
666#define SO_SNDLOWAT 0x1003
667#define SO_RCVLOWAT 0x1004
668#define SO_SNDTIMEO 0x1005
669#define SO_RCVTIMEO 0x1006
670#define SO_ERROR 0x1007
671#define SO_TYPE 0x1008
672
673
674#define IOCPARM_MASK 0x7f
675#define IOC_VOID 0x20000000
676#define IOC_OUT 0x40000000
677#define IOC_IN 0x80000000
678#define IOC_INOUT (IOC_IN|IOC_OUT)
679
680#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
681#define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
682#define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
683
684#else
685
686#define WS_SOL_SOCKET 0xffff
687#define WS_SO_DEBUG 0x0001
688#define WS_SO_ACCEPTCONN 0x0002
689#define WS_SO_REUSEADDR 0x0004
690#define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR))
691#define WS_SO_KEEPALIVE 0x0008
692#define WS_SO_DONTROUTE 0x0010
693#define WS_SO_BROADCAST 0x0020
694#define WS_SO_USELOOPBACK 0x0040
695#define WS_SO_LINGER 0x0080
696#define WS_SO_OOBINLINE 0x0100
697#define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER))
698#define WS_SO_SNDBUF 0x1001
699#define WS_SO_RCVBUF 0x1002
700#define WS_SO_SNDLOWAT 0x1003
701#define WS_SO_RCVLOWAT 0x1004
702#define WS_SO_SNDTIMEO 0x1005
703#define WS_SO_RCVTIMEO 0x1006
704#define WS_SO_ERROR 0x1007
705#define WS_SO_TYPE 0x1008
706
707#define WS_IOCPARM_MASK 0x7f
708#define WS_IOC_VOID 0x20000000
709#define WS_IOC_OUT 0x40000000
710#define WS_IOC_IN 0x80000000
711#define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
712
713#define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
714#define WS__IOR(x,y,t) (WS_IOC_OUT|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
715#define WS__IOW(x,y,t) (WS_IOC_IN|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
716
717#endif
718
719/* IPPROTO_TCP options */
720#ifndef USE_WS_PREFIX
721#define TCP_NODELAY 1
722#else
723#define WS_TCP_NODELAY 1
724#endif
725
726/* IPPROTO_IP options */
727#ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
728# ifndef USE_WS_PREFIX
729# define IP_OPTIONS 1
730# define IP_MULTICAST_IF 2
731# define IP_MULTICAST_TTL 3
732# define IP_MULTICAST_LOOP 4
733# define IP_ADD_MEMBERSHIP 5
734# define IP_DROP_MEMBERSHIP 6
735# define IP_TTL 7
736# define IP_TOS 8
737# define IP_DONTFRAGMENT 9
738# else
739# define WS_IP_OPTIONS 1
740# define WS_IP_MULTICAST_IF 2
741# define WS_IP_MULTICAST_TTL 3
742# define WS_IP_MULTICAST_LOOP 4
743# define WS_IP_ADD_MEMBERSHIP 5
744# define WS_IP_DROP_MEMBERSHIP 6
745# define WS_IP_TTL 7
746# define WS_IP_TOS 8
747# define WS_IP_DONTFRAGMENT 9
748# endif
749#endif
750
751
752/*
753 * Socket I/O flags (supported by spec 1.1)
754 */
755#ifndef USE_WS_PREFIX
756#define FIONREAD _IOR('f', 127, ULONG)
757#define FIONBIO _IOW('f', 126, ULONG)
758#define FIOASYNC _IOW('f', 125, ULONG)
759#define SIOCSHIWAT _IOW('s', 0, ULONG)
760#define SIOCGHIWAT _IOR('s', 1, ULONG)
761#define SIOCSLOWAT _IOW('s', 2, ULONG)
762#define SIOCGLOWAT _IOR('s', 3, ULONG)
763#define SIOCATMARK _IOR('s', 7, ULONG)
764#else
765#define WS_FIONREAD WS__IOR('f', 127, ULONG)
766#define WS_FIONBIO WS__IOW('f', 126, ULONG)
767#define WS_FIOASYNC WS__IOW('f', 125, ULONG)
768#define WS_SIOCSHIWAT WS__IOW('s', 0, ULONG)
769#define WS_SIOCGHIWAT WS__IOR('s', 1, ULONG)
770#define WS_SIOCSLOWAT WS__IOW('s', 2, ULONG)
771#define WS_SIOCGLOWAT WS__IOR('s', 3, ULONG)
772#define WS_SIOCATMARK WS__IOR('s', 7, ULONG)
773#endif
774
775/*
776 * Maximum queue length specifiable by listen.
777 */
778#ifndef USE_WS_PREFIX
779#define SOMAXCONN 5
780
781#define MSG_OOB 0x0001
782#define MSG_PEEK 0x0002
783#define MSG_DONTROUTE 0x0004
784#define MSG_WAITALL 0x0008
785#define MSG_INTERRUPT 0x0010
786#define MSG_PARTIAL 0x8000
787#define MSG_MAXIOVLEN 16
788#else /* USE_WS_PREFIX */
789#define WS_SOMAXCONN 5
790
791#define WS_MSG_OOB 0x0001
792#define WS_MSG_PEEK 0x0002
793#define WS_MSG_DONTROUTE 0x0004
794#define WS_MSG_WAITALL 0x0008
795#define WS_MSG_INTERRUPT 0x0010
796#define WS_MSG_PARTIAL 0x8000
797#define WS_MSG_MAXIOVLEN 16
798#endif /* USE_WS_PREFIX */
799
800/*
801 * Define constant based on rfc883, used by gethostbyxxxx() calls.
802 */
803#ifndef USE_WS_PREFIX
804#define MAXGETHOSTSTRUCT 1024
805#else
806#define MAXGETHOSTSTRUCT 1024
807#endif
808
809
810/*
811 * Define flags to be used with the WSAAsyncSelect() call.
812 */
813#define FD_READ 0x00000001
814#define FD_WRITE 0x00000002
815#define FD_OOB 0x00000004
816#define FD_ACCEPT 0x00000008
817#define FD_CONNECT 0x00000010
818#define FD_CLOSE 0x00000020
819
820/* internal per-socket flags */
821#ifdef __WINESRC__
822#define FD_WINE_LISTENING 0x10000000
823#define FD_WINE_NONBLOCKING 0x20000000
824#define FD_WINE_CONNECTED 0x40000000
825#define FD_WINE_RAW 0x80000000
826#define FD_WINE_INTERNAL 0xFFFF0000
827#endif
828
829/*
830 * All Windows Sockets error constants are biased by WSABASEERR from
831 * the "normal". They are also defined in winerror.h.
832 */
833#define WSABASEERR 10000
834/*
835 * Windows Sockets definitions of regular Microsoft C error constants
836 */
837#define WSAEINTR (WSABASEERR+4)
838#define WSAEBADF (WSABASEERR+9)
839#define WSAEACCES (WSABASEERR+13)
840#define WSAEFAULT (WSABASEERR+14)
841#define WSAEINVAL (WSABASEERR+22)
842#define WSAEMFILE (WSABASEERR+24)
843
844/*
845 * Windows Sockets definitions of regular Berkeley error constants
846 */
847#define WSAEWOULDBLOCK (WSABASEERR+35)
848#define WSAEINPROGRESS (WSABASEERR+36)
849#define WSAEALREADY (WSABASEERR+37)
850#define WSAENOTSOCK (WSABASEERR+38)
851#define WSAEDESTADDRREQ (WSABASEERR+39)
852#define WSAEMSGSIZE (WSABASEERR+40)
853#define WSAEPROTOTYPE (WSABASEERR+41)
854#define WSAENOPROTOOPT (WSABASEERR+42)
855#define WSAEPROTONOSUPPORT (WSABASEERR+43)
856#define WSAESOCKTNOSUPPORT (WSABASEERR+44)
857#define WSAEOPNOTSUPP (WSABASEERR+45)
858#define WSAEPFNOSUPPORT (WSABASEERR+46)
859#define WSAEAFNOSUPPORT (WSABASEERR+47)
860#define WSAEADDRINUSE (WSABASEERR+48)
861#define WSAEADDRNOTAVAIL (WSABASEERR+49)
862#define WSAENETDOWN (WSABASEERR+50)
863#define WSAENETUNREACH (WSABASEERR+51)
864#define WSAENETRESET (WSABASEERR+52)
865#define WSAECONNABORTED (WSABASEERR+53)
866#define WSAECONNRESET (WSABASEERR+54)
867#define WSAENOBUFS (WSABASEERR+55)
868#define WSAEISCONN (WSABASEERR+56)
869#define WSAENOTCONN (WSABASEERR+57)
870#define WSAESHUTDOWN (WSABASEERR+58)
871#define WSAETOOMANYREFS (WSABASEERR+59)
872#define WSAETIMEDOUT (WSABASEERR+60)
873#define WSAECONNREFUSED (WSABASEERR+61)
874#define WSAELOOP (WSABASEERR+62)
875#define WSAENAMETOOLONG (WSABASEERR+63)
876#define WSAEHOSTDOWN (WSABASEERR+64)
877#define WSAEHOSTUNREACH (WSABASEERR+65)
878#define WSAENOTEMPTY (WSABASEERR+66)
879#define WSAEPROCLIM (WSABASEERR+67)
880#define WSAEUSERS (WSABASEERR+68)
881#define WSAEDQUOT (WSABASEERR+69)
882#define WSAESTALE (WSABASEERR+70)
883#define WSAEREMOTE (WSABASEERR+71)
884
885/*
886 * Extended Windows Sockets error constant definitions
887 */
888#define WSASYSNOTREADY (WSABASEERR+91)
889#define WSAVERNOTSUPPORTED (WSABASEERR+92)
890#define WSANOTINITIALISED (WSABASEERR+93)
891#define WSAEDISCON (WSABASEERR+101)
892#define WSAENOMORE (WSABASEERR+102)
893#define WSAECANCELLED (WSABASEERR+103)
894#define WSAEINVALIDPROCTABLE (WSABASEERR+104)
895#define WSAEINVALIDPROVIDER (WSABASEERR+105)
896#define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
897#define WSASYSCALLFAILURE (WSABASEERR+107)
898#define WSASERVICE_NOT_FOUND (WSABASEERR+108)
899#define WSATYPE_NOT_FOUND (WSABASEERR+109)
900#define WSA_E_NO_MORE (WSABASEERR+110)
901#define WSA_E_CANCELLED (WSABASEERR+111)
902#define WSAEREFUSED (WSABASEERR+112)
903
904/*
905 * Error return codes from gethostbyname() and gethostbyaddr()
906 * (when using the resolver). Note that these errors are
907 * retrieved via WSAGetLastError() and must therefore follow
908 * the rules for avoiding clashes with error numbers from
909 * specific implementations or language run-time systems.
910 * For this reason the codes are based at WSABASEERR+1001.
911 * Note also that [WSA]NO_ADDRESS is defined only for
912 * compatibility purposes.
913 */
914
915#ifndef USE_WS_PREFIX
916#define h_errno WSAGetLastError()
917#else
918#define WS_h_errno WSAGetLastError()
919#endif
920
921/* Authoritative Answer: Host not found */
922#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
923
924/* Non-Authoritative: Host not found, or SERVERFAIL */
925#define WSATRY_AGAIN (WSABASEERR+1002)
926
927/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
928#define WSANO_RECOVERY (WSABASEERR+1003)
929
930/* Valid name, no data record of requested type */
931#define WSANO_DATA (WSABASEERR+1004)
932
933/* no address, look for MX record */
934#define WSANO_ADDRESS WSANO_DATA
935
936#ifndef USE_WS_PREFIX
937#define HOST_NOT_FOUND WSAHOST_NOT_FOUND
938#define TRY_AGAIN WSATRY_AGAIN
939#define NO_RECOVERY WSANO_RECOVERY
940#define NO_DATA WSANO_DATA
941#define NO_ADDRESS WSANO_ADDRESS
942#endif /* USE_WS_PREFIX */
943
944
945
946/*
947 * Windows message parameter composition and decomposition
948 * macros.
949 */
950
951/*
952 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
953 * when constructing the response to a WSAAsyncGetXByY() routine.
954 */
955#define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
956/*
957 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
958 * when constructing the response to WSAAsyncSelect().
959 */
960#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
961/*
962 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
963 * to extract the buffer length from the lParam in the response
964 * to a WSAGetXByY().
965 */
966#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
967/*
968 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
969 * to extract the error code from the lParam in the response
970 * to a WSAGetXByY().
971 */
972#define WSAGETASYNCERROR(lParam) HIWORD(lParam)
973/*
974 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
975 * to extract the event code from the lParam in the response
976 * to a WSAAsyncSelect().
977 */
978#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
979/*
980 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
981 * to extract the error code from the lParam in the response
982 * to a WSAAsyncSelect().
983 */
984#define WSAGETSELECTERROR(lParam) HIWORD(lParam)
985
986
987
988/*
989 * Prototypes
990 *
991 * Remember to keep this section in sync with the
992 * "Winsock Function Typedefs" section in winsock2.h.
993 */
994#if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
995HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,WS(u_int),const char*,int,int,char*,int);
996HANDLE WINAPI WSAAsyncGetHostByName(HWND,WS(u_int),const char*,char*,int);
997HANDLE WINAPI WSAAsyncGetProtoByName(HWND,WS(u_int),const char*,char*,int);
998HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,WS(u_int),int,char*,int);
999HANDLE WINAPI WSAAsyncGetServByName(HWND,WS(u_int),const char*,const char*,char*,int);
1000HANDLE WINAPI WSAAsyncGetServByPort(HWND,WS(u_int),int,const char*,char*,int);
1001int WINAPI WSAAsyncSelect(SOCKET,HWND,WS(u_int),LONG);
1002int WINAPI WSACancelAsyncRequest(HANDLE);
1003int WINAPI WSACancelBlockingCall(void);
1004int WINAPI WSACleanup(void);
1005int WINAPI WSAGetLastError(void);
1006BOOL WINAPI WSAIsBlocking(void);
1007FARPROC WINAPI WSASetBlockingHook(FARPROC);
1008void WINAPI WSASetLastError(int);
1009int WINAPI WSAStartup(WORD,LPWSADATA);
1010int WINAPI WSAUnhookBlockingHook(void);
1011
1012SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
1013int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
1014int WINAPI WS(closesocket)(SOCKET);
1015int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
1016struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
1017struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
1018int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
1019struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
1020struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
1021#ifdef WS_DEFINE_SELECT
1022int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
1023#endif
1024struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
1025struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
1026int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
1027int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
1028ULONG WINAPI WS(inet_addr)(const char*);
1029char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
1030int WINAPI WS(ioctlsocket)(SOCKET,LONG,ULONG*);
1031int WINAPI WS(listen)(SOCKET,int);
1032int WINAPI WS(recv)(SOCKET,char*,int,int);
1033int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
1034int WINAPI WS(send)(SOCKET,const char*,int,int);
1035int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
1036int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
1037int WINAPI WS(shutdown)(SOCKET,int);
1038SOCKET WINAPI WS(socket)(int,int,int);
1039
1040#if defined(__MINGW32__) || defined (_MSC_VER)
1041/* gethostname is not defined on Unix because of conflicts with unistd.h */
1042int WINAPI WS(gethostname)(char*,int);
1043#endif
1044
1045#endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
1046
1047#ifdef __cplusplus
1048}
1049#endif
1050
1051#ifndef __WINE_WINSOCK2__
1052#undef WS
1053#undef WS_API_PROTOTYPES
1054#undef WS_API_TYPEDEFS
1055#endif
1056
1057#endif /* _WINSOCKAPI_ */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette