OSDN Git Service

Apply LICENSE to all files as appropriate.
[mingw/mingw-org-wsl.git] / include / winsock.h
1 /**
2  * @file winsock.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 /*
25
26   Definitions for winsock 1.1
27   
28   Portions Copyright (c) 1980, 1983, 1988, 1993
29   The Regents of the University of California.  All rights reserved.
30
31   Portions Copyright (c) 1993 by Digital Equipment Corporation.
32  */
33
34 #ifndef _WINSOCK_H
35 #define _WINSOCK_H
36 #pragma GCC system_header
37
38 #define _GNU_H_WINDOWS32_SOCKETS
39
40 #include <windows.h>
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #if !defined ( _BSDTYPES_DEFINED )
47 /* also defined in gmon.h and in cygwin's sys/types */
48 typedef unsigned char   u_char;
49 typedef unsigned short  u_short;
50 typedef unsigned int    u_int;
51 typedef unsigned long   u_long;
52 #define _BSDTYPES_DEFINED
53 #endif /* !defined  _BSDTYPES_DEFINED */
54 typedef u_int   SOCKET;
55 #ifndef FD_SETSIZE
56 #define FD_SETSIZE      64
57 #endif
58
59 /* shutdown() how types */
60 #define SD_RECEIVE      0x00
61 #define SD_SEND         0x01
62 #define SD_BOTH         0x02
63
64 #ifndef _SYS_TYPES_FD_SET
65 /* fd_set may have be defined by the newlib <sys/types.h>
66  * if  __USE_W32_SOCKETS not defined.
67  */
68 #ifdef fd_set
69 #undef fd_set
70 #endif
71 typedef struct fd_set {
72         u_int   fd_count;
73         SOCKET  fd_array[FD_SETSIZE];
74 } fd_set;
75 int PASCAL __WSAFDIsSet(SOCKET,fd_set*);
76 #ifndef FD_CLR
77 #define FD_CLR(fd,set) do { u_int __i;\
78 for (__i = 0; __i < ((fd_set *)(set))->fd_count ; __i++) {\
79         if (((fd_set *)(set))->fd_array[__i] == (fd)) {\
80         while (__i < ((fd_set *)(set))->fd_count-1) {\
81                 ((fd_set*)(set))->fd_array[__i] = ((fd_set*)(set))->fd_array[__i+1];\
82                 __i++;\
83         }\
84         ((fd_set*)(set))->fd_count--;\
85         break;\
86         }\
87 }\
88 } while (0)
89 #endif
90 #ifndef FD_SET
91 #define FD_SET(fd, set) do { \
92     if (((fd_set *)(set))->fd_count < FD_SETSIZE) \
93         ((fd_set *)(set))->fd_array[((fd_set *)(set))->fd_count++]=(fd);\
94 }while (0)
95 #endif
96 #ifndef FD_ZERO
97 #define FD_ZERO(set) (((fd_set *)(set))->fd_count=0)
98 #endif
99 #ifndef FD_ISSET
100 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set *)(set))
101 #endif
102 #elif !defined(USE_SYS_TYPES_FD_SET)
103 #warning "fd_set and associated macros have been defined in sys/types.  \
104     This can cause runtime problems with W32 sockets" 
105 #endif /* ndef _SYS_TYPES_FD_SET */
106
107 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
108 #ifndef _TIMEVAL_DEFINED /* also in sys/time.h */
109 #define _TIMEVAL_DEFINED
110 struct timeval {
111         long    tv_sec;
112         long    tv_usec;
113 };
114 #define timerisset(tvp)  ((tvp)->tv_sec || (tvp)->tv_usec)
115 #define timercmp(tvp, uvp, cmp) \
116         (((tvp)->tv_sec != (uvp)->tv_sec) ? \
117         ((tvp)->tv_sec cmp (uvp)->tv_sec) : \
118         ((tvp)->tv_usec cmp (uvp)->tv_usec))
119 #define timerclear(tvp)  (tvp)->tv_sec = (tvp)->tv_usec = 0
120 #endif /* _TIMEVAL_DEFINED */
121 struct  hostent {
122         char    *h_name;
123         char    **h_aliases;
124         short   h_addrtype;
125         short   h_length;
126         char    **h_addr_list;
127 #define h_addr h_addr_list[0]
128 };
129 struct linger {
130         u_short l_onoff;
131         u_short l_linger;
132 };
133 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
134 #define IOCPARM_MASK    0x7f
135 #define IOC_VOID        0x20000000
136 #define IOC_OUT 0x40000000
137 #define IOC_IN  0x80000000
138 #define IOC_INOUT       (IOC_IN|IOC_OUT)
139
140 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
141 #define _IO(x,y)        (IOC_VOID|((x)<<8)|(y))
142 #define _IOR(x,y,t)     (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
143 #define _IOW(x,y,t)     (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
144 #define FIONBIO _IOW('f', 126, u_long)
145 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
146
147 #define FIONREAD        _IOR('f', 127, u_long)
148 #define FIOASYNC        _IOW('f', 125, u_long)
149 #define SIOCSHIWAT      _IOW('s',  0, u_long)
150 #define SIOCGHIWAT      _IOR('s',  1, u_long)
151 #define SIOCSLOWAT      _IOW('s',  2, u_long)
152 #define SIOCGLOWAT      _IOR('s',  3, u_long)
153 #define SIOCATMARK      _IOR('s',  7, u_long)
154
155 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
156 struct netent {
157         char    * n_name;
158         char    **n_aliases;
159         short   n_addrtype;
160         u_long n_net;
161 };
162 struct  servent {
163         char    *s_name;
164         char    **s_aliases;
165         short   s_port;
166         char    *s_proto;
167 };
168 struct  protoent {
169         char    *p_name;
170         char    **p_aliases;
171         short   p_proto;
172 };
173 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
174
175 #define IPPROTO_IP      0
176 #define IPPROTO_ICMP    1
177 #define IPPROTO_IGMP 2
178 #define IPPROTO_GGP 3
179 #define IPPROTO_TCP     6
180 #define IPPROTO_PUP     12
181 #define IPPROTO_UDP     17
182 #define IPPROTO_IDP     22
183 #define IPPROTO_ND      77
184 #define IPPROTO_RAW     255
185 #define IPPROTO_MAX     256
186 #define IPPORT_ECHO     7
187 #define IPPORT_DISCARD  9
188 #define IPPORT_SYSTAT   11
189 #define IPPORT_DAYTIME  13
190 #define IPPORT_NETSTAT  15
191 #define IPPORT_FTP      21
192 #define IPPORT_TELNET   23
193 #define IPPORT_SMTP     25
194 #define IPPORT_TIMESERVER 37
195 #define IPPORT_NAMESERVER 42
196 #define IPPORT_WHOIS    43
197 #define IPPORT_MTP      57
198 #define IPPORT_TFTP     69
199 #define IPPORT_RJE      77
200 #define IPPORT_FINGER   79
201 #define IPPORT_TTYLINK  87
202 #define IPPORT_SUPDUP   95
203 #define IPPORT_EXECSERVER       512
204 #define IPPORT_LOGINSERVER      513
205 #define IPPORT_CMDSERVER        514
206 #define IPPORT_EFSSERVER        520
207 #define IPPORT_BIFFUDP  512
208 #define IPPORT_WHOSERVER        513
209 #define IPPORT_ROUTESERVER      520
210 #define IPPORT_RESERVED 1024
211 #define IMPLINK_IP      155
212 #define IMPLINK_LOWEXPER        156
213 #define IMPLINK_HIGHEXPER       158
214 struct in_addr {
215         union {
216                 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
217                 struct { u_short s_w1,s_w2; } S_un_w;
218                 u_long S_addr;
219         } S_un;
220 #define s_addr  S_un.S_addr
221 #define s_host  S_un.S_un_b.s_b2
222 #define s_net   S_un.S_un_b.s_b1
223 #define s_imp   S_un.S_un_w.s_w2
224 #define s_impno S_un.S_un_b.s_b4
225 #define s_lh    S_un.S_un_b.s_b3
226 };
227 #define IN_CLASSA(i)    (((long)(i)&0x80000000) == 0)
228 #define IN_CLASSA_NET   0xff000000
229 #define IN_CLASSA_NSHIFT        24
230 #define IN_CLASSA_HOST  0x00ffffff
231 #define IN_CLASSA_MAX   128
232 #define IN_CLASSB(i)    (((long)(i)&0xc0000000)==0x80000000)
233 #define IN_CLASSB_NET      0xffff0000
234 #define IN_CLASSB_NSHIFT        16
235 #define IN_CLASSB_HOST    0x0000ffff
236 #define IN_CLASSB_MAX      65536
237 #define IN_CLASSC(i)    (((long)(i)&0xe0000000)==0xc0000000)
238 #define IN_CLASSC_NET      0xffffff00
239 #define IN_CLASSC_NSHIFT        8
240 #define IN_CLASSC_HOST    0xff
241 #define INADDR_ANY            (u_long)0
242 #define INADDR_LOOPBACK  0x7f000001
243 #define INADDR_BROADCAST        (u_long)0xffffffff
244 #define INADDR_NONE     0xffffffff
245 struct sockaddr_in {
246         short   sin_family;
247         u_short sin_port;
248         struct  in_addr sin_addr;
249         char    sin_zero[8];
250 };
251 #define WSADESCRIPTION_LEN      256
252 #define WSASYS_STATUS_LEN       128
253 typedef struct WSAData {
254         WORD    wVersion;
255         WORD    wHighVersion;
256         char    szDescription[WSADESCRIPTION_LEN+1];
257         char    szSystemStatus[WSASYS_STATUS_LEN+1];
258         unsigned short  iMaxSockets;
259         unsigned short  iMaxUdpDg;
260         char *  lpVendorInfo;
261 } WSADATA;
262 typedef WSADATA *LPWSADATA;
263
264 #ifndef __INSIDE_MSYS__
265 #define IP_OPTIONS      1
266 #define SO_DEBUG        1
267 #define SO_ACCEPTCONN   2
268 #define SO_REUSEADDR    4
269 #define SO_KEEPALIVE    8
270 #define SO_DONTROUTE    16
271 #define SO_BROADCAST    32
272 #define SO_USELOOPBACK  64
273 #define SO_LINGER       128
274 #define SO_OOBINLINE    256
275 #define SO_DONTLINGER   (u_int)(~SO_LINGER)
276 #define SO_SNDBUF       0x1001
277 #define SO_RCVBUF       0x1002
278 #define SO_SNDLOWAT     0x1003
279 #define SO_RCVLOWAT     0x1004
280 #define SO_SNDTIMEO     0x1005
281 #define SO_RCVTIMEO     0x1006
282 #define SO_ERROR        0x1007
283 #define SO_TYPE 0x1008
284 #endif /* !__INSIDE_MSYS__ */
285 /*
286  * Note that the next 5 IP defines are specific to WinSock 1.1 (wsock32.dll).
287  * They will cause errors or unexpected results if used with the
288  * (gs)etsockopts exported from the WinSock 2 lib, ws2_32.dll. Refer ws2tcpip.h.
289  */         
290 #define IP_MULTICAST_IF 2
291 #define IP_MULTICAST_TTL        3
292 #define IP_MULTICAST_LOOP       4
293 #define IP_ADD_MEMBERSHIP       5
294 #define IP_DROP_MEMBERSHIP  6
295
296 #define IP_DEFAULT_MULTICAST_TTL   1
297 #define IP_DEFAULT_MULTICAST_LOOP  1
298 #define IP_MAX_MEMBERSHIPS       20
299 struct ip_mreq {
300         struct in_addr imr_multiaddr;
301         struct in_addr imr_interface;
302 };
303 #define INVALID_SOCKET (SOCKET)(~0)
304 #define SOCKET_ERROR    (-1)
305 #define SOCK_STREAM     1
306 #define SOCK_DGRAM      2
307 #define SOCK_RAW        3
308 #define SOCK_RDM        4
309 #define SOCK_SEQPACKET  5
310 #define TCP_NODELAY     0x0001
311 #define AF_UNSPEC       0
312 #define AF_UNIX 1
313 #define AF_INET 2
314 #define AF_IMPLINK      3
315 #define AF_PUP  4
316 #define AF_CHAOS        5
317 #define AF_IPX  6
318 #define AF_NS   6
319 #define AF_ISO  7
320 #define AF_OSI  AF_ISO
321 #define AF_ECMA 8
322 #define AF_DATAKIT      9
323 #define AF_CCITT        10
324 #define AF_SNA  11
325 #define AF_DECnet       12
326 #define AF_DLI  13
327 #define AF_LAT  14
328 #define AF_HYLINK       15
329 #define AF_APPLETALK    16
330 #define AF_NETBIOS      17
331 #define AF_VOICEVIEW    18
332 #define AF_FIREFOX      19
333 #define AF_UNKNOWN1     20
334 #define AF_BAN  21
335 #define AF_ATM  22
336 #define AF_INET6        23
337 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
338 #define AF_MAX  24
339 struct sockaddr {
340         u_short sa_family;
341         char    sa_data[14];
342 };
343 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
344
345 struct sockproto {
346         u_short sp_family;
347         u_short sp_protocol;
348 };
349 #define PF_UNSPEC       AF_UNSPEC
350 #define PF_UNIX AF_UNIX
351 #define PF_INET AF_INET
352 #define PF_IMPLINK      AF_IMPLINK
353 #define PF_PUP  AF_PUP
354 #define PF_CHAOS        AF_CHAOS
355 #define PF_NS   AF_NS
356 #define PF_IPX  AF_IPX
357 #define PF_ISO  AF_ISO
358 #define PF_OSI  AF_OSI
359 #define PF_ECMA AF_ECMA
360 #define PF_DATAKIT      AF_DATAKIT
361 #define PF_CCITT        AF_CCITT
362 #define PF_SNA  AF_SNA
363 #define PF_DECnet       AF_DECnet
364 #define PF_DLI  AF_DLI
365 #define PF_LAT  AF_LAT
366 #define PF_HYLINK       AF_HYLINK
367 #define PF_APPLETALK    AF_APPLETALK
368 #define PF_VOICEVIEW    AF_VOICEVIEW
369 #define PF_FIREFOX      AF_FIREFOX
370 #define PF_UNKNOWN1     AF_UNKNOWN1
371 #define PF_BAN  AF_BAN
372 #define PF_ATM  AF_ATM
373 #define PF_INET6        AF_INET6
374 #define PF_MAX  AF_MAX
375 #define SOL_SOCKET      0xffff
376 #define SOMAXCONN       5
377 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
378 #define MSG_OOB 1
379 #define MSG_PEEK        2
380 #define MSG_DONTROUTE   4
381 #endif  /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
382 #define MSG_MAXIOVLEN   16
383 #define MSG_PARTIAL     0x8000
384 #define MAXGETHOSTSTRUCT        1024
385 #define FD_READ 1
386 #define FD_WRITE        2
387 #define FD_OOB  4
388 #define FD_ACCEPT       8
389 #define FD_CONNECT      16
390 #define FD_CLOSE        32
391 #ifndef WSABASEERR
392 #define WSABASEERR      10000
393 #define WSAEINTR        (WSABASEERR+4)
394 #define WSAEBADF        (WSABASEERR+9)
395 #define WSAEACCES       (WSABASEERR+13)
396 #define WSAEFAULT       (WSABASEERR+14)
397 #define WSAEINVAL       (WSABASEERR+22)
398 #define WSAEMFILE       (WSABASEERR+24)
399 #define WSAEWOULDBLOCK  (WSABASEERR+35)
400 #define WSAEINPROGRESS  (WSABASEERR+36)
401 #define WSAEALREADY     (WSABASEERR+37)
402 #define WSAENOTSOCK     (WSABASEERR+38)
403 #define WSAEDESTADDRREQ (WSABASEERR+39)
404 #define WSAEMSGSIZE     (WSABASEERR+40)
405 #define WSAEPROTOTYPE   (WSABASEERR+41)
406 #define WSAENOPROTOOPT  (WSABASEERR+42)
407 #define WSAEPROTONOSUPPORT      (WSABASEERR+43)
408 #define WSAESOCKTNOSUPPORT      (WSABASEERR+44)
409 #define WSAEOPNOTSUPP   (WSABASEERR+45)
410 #define WSAEPFNOSUPPORT (WSABASEERR+46)
411 #define WSAEAFNOSUPPORT (WSABASEERR+47)
412 #define WSAEADDRINUSE   (WSABASEERR+48)
413 #define WSAEADDRNOTAVAIL        (WSABASEERR+49)
414 #define WSAENETDOWN     (WSABASEERR+50)
415 #define WSAENETUNREACH  (WSABASEERR+51)
416 #define WSAENETRESET    (WSABASEERR+52)
417 #define WSAECONNABORTED (WSABASEERR+53)
418 #define WSAECONNRESET   (WSABASEERR+54)
419 #define WSAENOBUFS      (WSABASEERR+55)
420 #define WSAEISCONN      (WSABASEERR+56)
421 #define WSAENOTCONN     (WSABASEERR+57)
422 #define WSAESHUTDOWN    (WSABASEERR+58)
423 #define WSAETOOMANYREFS (WSABASEERR+59)
424 #define WSAETIMEDOUT    (WSABASEERR+60)
425 #define WSAECONNREFUSED (WSABASEERR+61)
426 #define WSAELOOP        (WSABASEERR+62)
427 #define WSAENAMETOOLONG (WSABASEERR+63)
428 #define WSAEHOSTDOWN    (WSABASEERR+64)
429 #define WSAEHOSTUNREACH (WSABASEERR+65)
430 #define WSAENOTEMPTY    (WSABASEERR+66)
431 #define WSAEPROCLIM     (WSABASEERR+67)
432 #define WSAEUSERS       (WSABASEERR+68)
433 #define WSAEDQUOT       (WSABASEERR+69)
434 #define WSAESTALE       (WSABASEERR+70)
435 #define WSAEREMOTE      (WSABASEERR+71)
436 #define WSAEDISCON      (WSABASEERR+101)
437 #define WSASYSNOTREADY  (WSABASEERR+91)
438 #define WSAVERNOTSUPPORTED      (WSABASEERR+92)
439 #define WSANOTINITIALISED       (WSABASEERR+93)
440 #define WSAHOST_NOT_FOUND       (WSABASEERR+1001)
441 #define WSATRY_AGAIN    (WSABASEERR+1002)
442 #define WSANO_RECOVERY  (WSABASEERR+1003)
443 #define WSANO_DATA      (WSABASEERR+1004)
444 #endif /* !WSABASEERR */
445
446 #define WSANO_ADDRESS   WSANO_DATA
447 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
448 #define h_errno WSAGetLastError()
449 #define HOST_NOT_FOUND  WSAHOST_NOT_FOUND
450 #define TRY_AGAIN       WSATRY_AGAIN
451 #define NO_RECOVERY     WSANO_RECOVERY
452 #define NO_DATA WSANO_DATA
453 #define NO_ADDRESS      WSANO_ADDRESS
454 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
455 SOCKET PASCAL accept(SOCKET,struct sockaddr*,int*);
456 int PASCAL bind(SOCKET,const struct sockaddr*,int);
457 int PASCAL closesocket(SOCKET);
458 int PASCAL connect(SOCKET,const struct sockaddr*,int);
459 int PASCAL ioctlsocket(SOCKET,long,u_long *);
460 int PASCAL getpeername(SOCKET,struct sockaddr*,int*);
461 int PASCAL getsockname(SOCKET,struct sockaddr*,int*);
462 int PASCAL getsockopt(SOCKET,int,int,char*,int*);
463 unsigned long PASCAL inet_addr(const char*);
464 DECLARE_STDCALL_P(char *) inet_ntoa(struct in_addr);
465 int PASCAL listen(SOCKET,int);
466 int PASCAL recv(SOCKET,char*,int,int);
467 int PASCAL recvfrom(SOCKET,char*,int,int,struct sockaddr*,int*);
468 int PASCAL send(SOCKET,const char*,int,int);
469 int PASCAL sendto(SOCKET,const char*,int,int,const struct sockaddr*,int);
470 int PASCAL setsockopt(SOCKET,int,int,const char*,int);
471 int PASCAL shutdown(SOCKET,int);
472 SOCKET PASCAL socket(int,int,int);
473 DECLARE_STDCALL_P(struct hostent *) gethostbyaddr(const char*,int,int);
474 DECLARE_STDCALL_P(struct hostent *) gethostbyname(const char*);
475 DECLARE_STDCALL_P(struct servent *) getservbyport(int,const char*);
476 DECLARE_STDCALL_P(struct servent *) getservbyname(const char*,const char*);
477 DECLARE_STDCALL_P(struct protoent *) getprotobynumber(int);
478 DECLARE_STDCALL_P(struct protoent *) getprotobyname(const char*);
479 int PASCAL WSAStartup(WORD,LPWSADATA);
480 int PASCAL WSACleanup(void);
481 void PASCAL WSASetLastError(int);
482 int PASCAL WSAGetLastError(void);
483 BOOL PASCAL WSAIsBlocking(void);
484 int PASCAL WSAUnhookBlockingHook(void);
485 FARPROC PASCAL WSASetBlockingHook(FARPROC);
486 int PASCAL WSACancelBlockingCall(void);
487 HANDLE PASCAL WSAAsyncGetServByName(HWND,u_int,const char*,const char*,char*,int);
488 HANDLE PASCAL WSAAsyncGetServByPort(HWND,u_int,int,const char*,char*,int);
489 HANDLE PASCAL WSAAsyncGetProtoByName(HWND,u_int,const char*,char*,int);
490 HANDLE PASCAL WSAAsyncGetProtoByNumber(HWND,u_int,int,char*,int);
491 HANDLE PASCAL WSAAsyncGetHostByName(HWND,u_int,const char*,char*,int);
492 HANDLE PASCAL WSAAsyncGetHostByAddr(HWND,u_int,const char*,int,int,char*,int);
493 int PASCAL WSACancelAsyncRequest(HANDLE);
494 int PASCAL WSAAsyncSelect(SOCKET,HWND,u_int,long);
495 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
496 u_long PASCAL htonl(u_long);
497 u_long PASCAL ntohl(u_long);
498 u_short PASCAL htons(u_short);
499 u_short PASCAL ntohs(u_short);
500 int PASCAL select(int nfds,fd_set*,fd_set*,fd_set*,const struct timeval*);
501 int PASCAL gethostname(char*,int);
502 #endif /* ! (__INSIDE_CYGWIN__ || __INSIDE_MSYS__) */
503
504 #define WSAMAKEASYNCREPLY(b,e)  MAKELONG(b,e)
505 #define WSAMAKESELECTREPLY(e,error)     MAKELONG(e,error)
506 #define WSAGETASYNCBUFLEN(l)    LOWORD(l)
507 #define WSAGETASYNCERROR(l)     HIWORD(l)
508 #define WSAGETSELECTEVENT(l)    LOWORD(l)
509 #define WSAGETSELECTERROR(l)    HIWORD(l)
510
511 typedef struct sockaddr SOCKADDR;
512 typedef struct sockaddr *PSOCKADDR;
513 typedef struct sockaddr *LPSOCKADDR;
514 typedef struct sockaddr_in SOCKADDR_IN;
515 typedef struct sockaddr_in *PSOCKADDR_IN;
516 typedef struct sockaddr_in *LPSOCKADDR_IN;
517 typedef struct linger LINGER;
518 typedef struct linger *PLINGER;
519 typedef struct linger *LPLINGER;
520 typedef struct in_addr IN_ADDR;
521 typedef struct in_addr *PIN_ADDR;
522 typedef struct in_addr *LPIN_ADDR;
523 typedef struct fd_set FD_SET;
524 typedef struct fd_set *PFD_SET;
525 typedef struct fd_set *LPFD_SET;
526 typedef struct hostent HOSTENT;
527 typedef struct hostent *PHOSTENT;
528 typedef struct hostent *LPHOSTENT;
529 typedef struct servent SERVENT;
530 typedef struct servent *PSERVENT;
531 typedef struct servent *LPSERVENT;
532 typedef struct protoent PROTOENT;
533 typedef struct protoent *PPROTOENT;
534 typedef struct protoent *LPPROTOENT;
535 typedef struct timeval TIMEVAL;
536 typedef struct timeval *PTIMEVAL;
537 typedef struct timeval *LPTIMEVAL;
538
539 #ifdef __cplusplus
540 }
541 #endif
542 /*
543  * Recent MSDN docs indicate that the MS-specific extensions exported from
544  * mswsock.dll (AcceptEx, TransmitFile. WSARecEx and GetAcceptExSockaddrs) are
545  * declared in mswsock.h. These extensions are not supported on W9x or WinCE.
546  * However, code using WinSock 1.1 API may expect the declarations and
547  * associated defines to be in this header. Thus we include mswsock.h here.
548  *
549  * When linking against the WinSock 1.1 lib, wsock32.dll, the mswsock functions
550  * are automatically routed to mswsock.dll (on platforms with support).
551  * The WinSock 2 lib, ws2_32.dll, does not contain any references to
552  * the mswsock extensions. 
553  */
554
555 #include <mswsock.h>
556
557 #endif