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