--- mstools/h/winsock.h 2018/08/09 18:20:28 1.1.1.1 +++ mstools/h/winsock.h 2018/08/09 18:21:05 1.1.1.2 @@ -1,3 +1,11 @@ +/* WINSOCK.H--definitions to be used with the WINSOCK.DLL + * + * This file includes parts which are Copyright (c) 1982-1986 Regents + * of the University of California. All rights reserved. The + * Berkeley Software License Agreement specifies the terms and + * conditions for redistribution. + */ + #ifndef _WINSOCKAPI_ #define _WINSOCKAPI_ @@ -5,29 +13,23 @@ * Pull in WINDOWS.H if necessary */ #ifndef _INC_WINDOWS -#include +#include #endif /* _INC_WINDOWS */ -#ifndef FAR -#define FAR far -#endif /* FAR */ - - /* * Basic system type definitions, taken from the BSD file sys/types.h. */ - -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short ushort; /* sys III compat */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned short ushort; +typedef unsigned int u_int; +typedef unsigned long u_long; /* * The new type to be used in all * instances which refer to sockets. */ -typedef unsigned int SOCKET; +typedef u_int SOCKET; /* * Select uses arrays of SOCKETs. These macros manipulate such @@ -37,36 +39,36 @@ typedef unsigned int SOCKET; * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE. */ - #ifndef FD_SETSIZE -#define FD_SETSIZE 64 +#define FD_SETSIZE 64 #endif /* FD_SETSIZE */ typedef struct fd_set { - short fd_count; /* how many are SET? */ - SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */ + u_short fd_count; /* how many are SET? */ + SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */ } fd_set; -extern int FAR __WSAFDIsSet(SOCKET, fd_set FAR *); +extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *); #define FD_CLR(fd, set) { \ - int __i; \ - for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \ - if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \ - while (__i < ((fd_set FAR *)(set))->fd_count-1) { \ - ((fd_set FAR *)(set))->fd_array[__i] = \ - ((fd_set FAR*)(set))->fd_array[__i+1]; \ - __i++; \ - } \ - ((fd_set FAR *)(set))->fd_count--; \ - break; \ - } \ + u_int __i; \ + for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \ + if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \ + while (__i < (u_int)(((fd_set FAR *)(set))->fd_count-1)) { \ + ((fd_set FAR *)(set))->fd_array[__i] = \ + ((fd_set FAR*)(set))->fd_array[__i+1]; \ + __i++; \ + } \ + ((fd_set FAR *)(set))->fd_count--; \ + break; \ } \ + } \ } #define FD_SET(fd, set) { \ - if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \ - ((fd_set FAR *)(set))->fd_array[((fd_set FAR *)(set))->fd_count++] = fd; } + if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \ + ((fd_set FAR *)(set))->fd_array[((fd_set FAR *)(set))->fd_count++]=fd;\ +} #define FD_ZERO(set) ((fd_set FAR *)(set))->fd_count=0 @@ -76,8 +78,8 @@ extern int FAR __WSAFDIsSet(SOCKET, fd_s * Structure used in select() call, taken from the BSD file sys/time.h. */ struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ + long tv_sec; /* seconds */ + long tv_usec; /* and microseconds */ }; /* @@ -85,13 +87,11 @@ struct timeval { * * NB: timercmp does not work for >= or <=. */ -#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) - +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) #define timercmp(tvp, uvp, cmp) \ ((tvp)->tv_sec cmp (uvp)->tv_sec || \ - (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) - -#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 + (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 /* * Commands for ioctlsocket(), taken from the BSD file fcntl.h. @@ -103,29 +103,29 @@ struct timeval { * to encode the in/out status of the parameter; for now * we restrict parameters to at most 128 bytes. */ -#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ -#define IOC_VOID 0x20000000 /* no parameters */ -#define IOC_OUT 0x40000000 /* copy out parameters */ -#define IOC_IN 0x80000000 /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) - /* 0x20000000 distinguishes new & - old ioctl's */ -#define _IO(x,y) (IOC_VOID|('x'<<8)|y) - -#define _IOR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y) - -#define _IOW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y) - -#define FIONREAD _IOR(f, 127, int) /* get # bytes to read */ -#define FIONBIO _IOW(f, 126, int) /* set/clear non-blocking i/o */ -#define FIOASYNC _IOW(f, 125, int) /* set/clear async i/o */ +#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ +#define IOC_VOID 0x20000000 /* no parameters */ +#define IOC_OUT 0x40000000 /* copy out parameters */ +#define IOC_IN 0x80000000 /* copy in parameters */ +#define IOC_INOUT (IOC_IN|IOC_OUT) + /* 0x20000000 distinguishes new & + old ioctl's */ +#define _IO(x,y) (IOC_VOID|('x'<<8)|y) + +#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) + +#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) + +#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ +#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ +#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ /* Socket I/O Controls */ -#define SIOCSHIWAT _IOW(s, 0, int) /* set high watermark */ -#define SIOCGHIWAT _IOR(s, 1, int) /* get high watermark */ -#define SIOCSLOWAT _IOW(s, 2, int) /* set low watermark */ -#define SIOCGLOWAT _IOR(s, 3, int) /* get low watermark */ -#define SIOCATMARK _IOR(s, 7, int) /* at oob mark? */ +#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ +#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ +#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ +#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ +#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ /* * Structures returned by network data base library, taken from the @@ -133,40 +133,39 @@ struct timeval { * returned in network order (suitable for use in system calls). */ -struct hostent { - char FAR * h_name; /* official name of host */ - char FAR * FAR * h_aliases; /* alias list */ - int h_addrtype; /* host address type */ - int h_length; /* length of address */ - char FAR * FAR * h_addr_list; /* list of addresses */ -#define h_addr h_addr_list[0] /* address, for backward compat */ +struct hostent { + char FAR * h_name; /* official name of host */ + char FAR * FAR * h_aliases; /* alias list */ + int h_addrtype; /* host address type */ + int h_length; /* length of address */ + char FAR * FAR * h_addr_list; /* list of addresses */ +#define h_addr h_addr_list[0] /* address, for backward compat */ }; /* - * Assumption here is that a network number - * fits in 32 bits -- probably a poor one. + * It is assumed here that a network number + * fits in 32 bits. */ struct netent { - char FAR * n_name; /* official name of net */ - char FAR * FAR * n_aliases; /* alias list */ - int n_addrtype; /* net address type */ - unsigned long n_net; /* network # */ + char FAR * n_name; /* official name of net */ + char FAR * FAR * n_aliases; /* alias list */ + int n_addrtype; /* net address type */ + u_long n_net; /* network # */ }; struct servent { - char FAR * s_name; /* official service name */ - char FAR * FAR * s_aliases; /* alias list */ - int s_port; /* port # */ - char FAR * s_proto; /* protocol to use */ + char FAR * s_name; /* official service name */ + char FAR * FAR * s_aliases; /* alias list */ + int s_port; /* port # */ + char FAR * s_proto; /* protocol to use */ }; struct protoent { - char FAR * p_name; /* official protocol name */ - char FAR * FAR * p_aliases; /* alias list */ - int p_proto; /* protocol # */ + char FAR * p_name; /* official protocol name */ + char FAR * FAR * p_aliases; /* alias list */ + int p_proto; /* protocol # */ }; - /* * Constants and structures defined by the internet system, * Per RFC 790, September 1981, taken from the BSD file netinet/in.h. @@ -175,71 +174,71 @@ struct protoent { /* * Protocols */ -#define IPPROTO_IP 0 /* dummy for IP */ -#define IPPROTO_ICMP 1 /* control message protocol */ -#define IPPROTO_GGP 2 /* gateway^2 (deprecated) */ -#define IPPROTO_TCP 6 /* tcp */ -#define IPPROTO_PUP 12 /* pup */ -#define IPPROTO_UDP 17 /* user datagram protocol */ -#define IPPROTO_IDP 22 /* xns idp */ -#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ +#define IPPROTO_IP 0 /* dummy for IP */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#define IPPROTO_GGP 2 /* gateway^2 (deprecated) */ +#define IPPROTO_TCP 6 /* tcp */ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_UDP 17 /* user datagram protocol */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ -#define IPPROTO_RAW 255 /* raw IP packet */ -#define IPPROTO_MAX 256 +#define IPPROTO_RAW 255 /* raw IP packet */ +#define IPPROTO_MAX 256 /* * Port/socket numbers: network standard functions */ -#define IPPORT_ECHO 7 -#define IPPORT_DISCARD 9 -#define IPPORT_SYSTAT 11 -#define IPPORT_DAYTIME 13 -#define IPPORT_NETSTAT 15 -#define IPPORT_FTP 21 -#define IPPORT_TELNET 23 -#define IPPORT_SMTP 25 -#define IPPORT_TIMESERVER 37 -#define IPPORT_NAMESERVER 42 -#define IPPORT_WHOIS 43 -#define IPPORT_MTP 57 +#define IPPORT_ECHO 7 +#define IPPORT_DISCARD 9 +#define IPPORT_SYSTAT 11 +#define IPPORT_DAYTIME 13 +#define IPPORT_NETSTAT 15 +#define IPPORT_FTP 21 +#define IPPORT_TELNET 23 +#define IPPORT_SMTP 25 +#define IPPORT_TIMESERVER 37 +#define IPPORT_NAMESERVER 42 +#define IPPORT_WHOIS 43 +#define IPPORT_MTP 57 /* * Port/socket numbers: host specific functions */ -#define IPPORT_TFTP 69 -#define IPPORT_RJE 77 -#define IPPORT_FINGER 79 -#define IPPORT_TTYLINK 87 -#define IPPORT_SUPDUP 95 +#define IPPORT_TFTP 69 +#define IPPORT_RJE 77 +#define IPPORT_FINGER 79 +#define IPPORT_TTYLINK 87 +#define IPPORT_SUPDUP 95 /* * UNIX TCP sockets */ -#define IPPORT_EXECSERVER 512 -#define IPPORT_LOGINSERVER 513 -#define IPPORT_CMDSERVER 514 -#define IPPORT_EFSSERVER 520 +#define IPPORT_EXECSERVER 512 +#define IPPORT_LOGINSERVER 513 +#define IPPORT_CMDSERVER 514 +#define IPPORT_EFSSERVER 520 /* * UNIX UDP sockets */ -#define IPPORT_BIFFUDP 512 -#define IPPORT_WHOSERVER 513 -#define IPPORT_ROUTESERVER 520 - /* 520+1 also used */ +#define IPPORT_BIFFUDP 512 +#define IPPORT_WHOSERVER 513 +#define IPPORT_ROUTESERVER 520 + /* 520+1 also used */ /* * Ports < IPPORT_RESERVED are reserved for * privileged processes (e.g. root). */ -#define IPPORT_RESERVED 1024 +#define IPPORT_RESERVED 1024 /* * Link numbers */ -#define IMPLINK_IP 155 -#define IMPLINK_LOWEXPER 156 -#define IMPLINK_HIGHEXPER 158 +#define IMPLINK_IP 155 +#define IMPLINK_LOWEXPER 156 +#define IMPLINK_HIGHEXPER 158 /* * Internet address (old style... should be updated) @@ -250,7 +249,18 @@ struct in_addr { struct { u_short s_w1,s_w2; } S_un_w; u_long S_addr; } S_un; -#define s_addr S_un.S_addr /* can be used for most tcp & ip code */ +#define s_addr S_un.S_addr + /* can be used for most tcp & ip code */ +#define s_host S_un.S_un_b.s_b2 + /* host on imp */ +#define s_net S_un.S_un_b.s_b1 + /* network */ +#define s_imp S_un.S_un_w.s_w2 + /* imp */ +#define s_impno S_un.S_un_b.s_b4 + /* imp # */ +#define s_lh S_un.S_un_b.s_b3 + /* logical host */ }; /* @@ -276,17 +286,18 @@ struct in_addr { #define IN_CLASSC_HOST 0x000000ff #define INADDR_ANY (u_long)0x00000000 -#define INADDR_LOOPBACK 0x7f000001 +#define INADDR_LOOPBACK 0x7f000001 #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ +#define INADDR_NONE 0xffffffff /* -1 return */ /* * Socket address, internet style. */ struct sockaddr_in { - short sin_family; - u_short sin_port; - struct in_addr sin_addr; - char sin_zero[8]; + short sin_family; + u_short sin_port; + struct in_addr sin_addr; + char sin_zero[8]; }; #define WSADESCRIPTION_LEN 256 @@ -299,6 +310,7 @@ typedef struct WSAData { char szSystemStatus[WSASYS_STATUS_LEN+1]; int iMaxSockets; int iMaxUdpDg; + char FAR * lpVendorInfo; } WSADATA; typedef WSADATA FAR *LPWSADATA; @@ -306,7 +318,7 @@ typedef WSADATA FAR *LPWSADATA; /* * Options for use with [gs]etsockopt at the IP level. */ -#define IP_OPTIONS 1 /* set/get IP per-packet options */ +#define IP_OPTIONS 1 /* set/get IP per-packet options */ /* * Definitions related to sockets: types, address families, options, @@ -317,75 +329,75 @@ typedef WSADATA FAR *LPWSADATA; * This is used instead of -1, since the * SOCKET type is unsigned. */ -#define INVALID_SOCKET (SOCKET)(~0) +#define INVALID_SOCKET (SOCKET)(~0) #define SOCKET_ERROR (-1) /* * Types */ -#define SOCK_STREAM 1 /* stream socket */ -#define SOCK_DGRAM 2 /* datagram socket */ -#define SOCK_RAW 3 /* raw-protocol interface */ -#define SOCK_RDM 4 /* reliably-delivered message */ -#define SOCK_SEQPACKET 5 /* sequenced packet stream */ +#define SOCK_STREAM 1 /* stream socket */ +#define SOCK_DGRAM 2 /* datagram socket */ +#define SOCK_RAW 3 /* raw-protocol interface */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequenced packet stream */ /* * Option flags per-socket. */ -#define SO_DEBUG 0x0001 /* turn on debugging info recording */ -#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ -#define SO_REUSEADDR 0x0004 /* allow local address reuse */ -#define SO_KEEPALIVE 0x0008 /* keep connections alive */ -#define SO_DONTROUTE 0x0010 /* just use interface addresses */ -#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ -#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ -#define SO_LINGER 0x0080 /* linger on close if data present */ -#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ +#define SO_DEBUG 0x0001 /* turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ +#define SO_LINGER 0x0080 /* linger on close if data present */ +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ -#define SO_DONTLINGER (unsigned int) (~SO_LINGER) +#define SO_DONTLINGER (u_int)(~SO_LINGER) /* * Additional options. */ -#define SO_SNDBUF 0x1001 /* send buffer size */ -#define SO_RCVBUF 0x1002 /* receive buffer size */ -#define SO_SNDLOWAT 0x1003 /* send low-water mark */ -#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ -#define SO_SNDTIMEO 0x1005 /* send timeout */ -#define SO_RCVTIMEO 0x1006 /* receive timeout */ -#define SO_ERROR 0x1007 /* get error status and clear */ -#define SO_TYPE 0x1008 /* get socket type */ +#define SO_SNDBUF 0x1001 /* send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ +#define SO_SNDTIMEO 0x1005 /* send timeout */ +#define SO_RCVTIMEO 0x1006 /* receive timeout */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ /* * Address families. */ -#define AF_UNSPEC 0 /* unspecified */ -#define AF_UNIX 1 /* local to host (pipes, portals) */ -#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ -#define AF_IMPLINK 3 /* arpanet imp addresses */ -#define AF_PUP 4 /* pup protocols: e.g. BSP */ -#define AF_CHAOS 5 /* mit CHAOS protocols */ -#define AF_NS 6 /* XEROX NS protocols */ -#define AF_NBS 7 /* nbs protocols */ -#define AF_ECMA 8 /* european computer manufacturers */ -#define AF_DATAKIT 9 /* datakit protocols */ -#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ -#define AF_SNA 11 /* IBM SNA */ -#define AF_DECnet 12 /* DECnet */ -#define AF_DLI 13 /* Direct data link interface */ -#define AF_LAT 14 /* LAT */ -#define AF_HYLINK 15 /* NSC Hyperchannel */ -#define AF_APPLETALK 16 /* AppleTalk */ +#define AF_UNSPEC 0 /* unspecified */ +#define AF_UNIX 1 /* local to host (pipes, portals) */ +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ +#define AF_IMPLINK 3 /* arpanet imp addresses */ +#define AF_PUP 4 /* pup protocols: e.g. BSP */ +#define AF_CHAOS 5 /* mit CHAOS protocols */ +#define AF_NS 6 /* XEROX NS protocols */ +#define AF_NBS 7 /* nbs protocols */ +#define AF_ECMA 8 /* european computer manufacturers */ +#define AF_DATAKIT 9 /* datakit protocols */ +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ +#define AF_SNA 11 /* IBM SNA */ +#define AF_DECnet 12 /* DECnet */ +#define AF_DLI 13 /* Direct data link interface */ +#define AF_LAT 14 /* LAT */ +#define AF_HYLINK 15 /* NSC Hyperchannel */ +#define AF_APPLETALK 16 /* AppleTalk */ -#define AF_MAX 17 +#define AF_MAX 17 /* * Structure used by kernel to store most * addresses. */ struct sockaddr { - u_short sa_family; /* address family */ - char sa_data[14]; /* up to 14 bytes of direct address */ + u_short sa_family; /* address family */ + char sa_data[14]; /* up to 14 bytes of direct address */ }; /* @@ -393,68 +405,79 @@ struct sockaddr { * information in raw sockets. */ struct sockproto { - u_short sp_family; /* address family */ - u_short sp_protocol; /* protocol */ + u_short sp_family; /* address family */ + u_short sp_protocol; /* protocol */ }; /* * Protocol families, same as address families for now. */ -#define PF_UNSPEC AF_UNSPEC -#define PF_UNIX AF_UNIX -#define PF_INET AF_INET -#define PF_IMPLINK AF_IMPLINK -#define PF_PUP AF_PUP -#define PF_CHAOS AF_CHAOS -#define PF_NS AF_NS -#define PF_NBS AF_NBS -#define PF_ECMA AF_ECMA -#define PF_DATAKIT AF_DATAKIT -#define PF_CCITT AF_CCITT -#define PF_SNA AF_SNA -#define PF_DECnet AF_DECnet -#define PF_DLI AF_DLI -#define PF_LAT AF_LAT -#define PF_HYLINK AF_HYLINK -#define PF_APPLETALK AF_APPLETALK +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NS AF_NS +#define PF_NBS AF_NBS +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK -#define PF_MAX AF_MAX +#define PF_MAX AF_MAX /* * Structure used for manipulating linger option. */ struct linger { - u_short l_onoff; /* option on/off */ - u_short l_linger; /* linger time */ + u_short l_onoff; /* option on/off */ + u_short l_linger; /* linger time */ }; /* * Level number for (get/set)sockopt() to apply to socket itself. */ -#define SOL_SOCKET 0xffff /* options for socket level */ +#define SOL_SOCKET 0xffff /* options for socket level */ /* * Maximum queue length specifiable by listen. */ -#define SOMAXCONN 5 +#define SOMAXCONN 5 -#define MSG_OOB 0x1 /* process out-of-band data */ -#define MSG_PEEK 0x2 /* peek at incoming message */ -#define MSG_DONTROUTE 0x4 /* send without using routing tables */ +#define MSG_OOB 0x1 /* process out-of-band data */ +#define MSG_PEEK 0x2 /* peek at incoming message */ +#define MSG_DONTROUTE 0x4 /* send without using routing tables */ -#define MSG_MAXIOVLEN 16 +#define MSG_MAXIOVLEN 16 /* * Define constant based on rfc883, used by gethostbyxxxx() calls. */ -#define MAXGETHOSTSTRUCT 1024 +#define MAXGETHOSTSTRUCT 1024 /* - * All WinSock error constants are biased by WSABASEERR from the "normal" + * Define flags to be used with the WSAAsyncSelect() call. + */ +#define FD_READ 0x01 +#define FD_WRITE 0x02 +#define FD_OOB 0x04 +#define FD_ACCEPT 0x08 +#define FD_CONNECT 0x10 +#define FD_CLOSE 0x20 + +/* + * All Windows Sockets error constants are biased by WSABASEERR from + * the "normal" */ #define WSABASEERR 10000 /* - * WinSockAPI definitions of regular Microsoft C error constants + * Windows Sockets definitions of regular Microsoft C error constants */ #define WSAEINTR (WSABASEERR+4) #define WSAEBADF (WSABASEERR+9) @@ -463,7 +486,7 @@ struct linger { #define WSAEMFILE (WSABASEERR+24) /* - * WinSockAPI definitions of regular Berkeley error constants + * Windows Sockets definitions of regular Berkeley error constants */ #define WSAEWOULDBLOCK (WSABASEERR+35) #define WSAEINPROGRESS (WSABASEERR+36) @@ -504,10 +527,11 @@ struct linger { #define WSAEREMOTE (WSABASEERR+71) /* - * Extended WinSockAPI error constant definitions + * Extended Windows Sockets error constant definitions */ #define WSASYSNOTREADY (WSABASEERR+91) #define WSAVERNOTSUPPORTED (WSABASEERR+92) +#define WSANOTINITIALISED (WSABASEERR+93) /* * Error return codes from gethostbyname() and gethostbyaddr() @@ -515,37 +539,36 @@ struct linger { * retrieved via WSAGetLastError() and must therefore follow * the rules for avoiding clashes with error numbers from * specific implementations or language run-time systems. - * For this reason the codes are based at WSABASEERR+1001 + * For this reason the codes are based at WSABASEERR+1001. + * Note also that [WSA]NO_ADDRESS is defined only for + * compatibility purposes. */ #define h_errno WSAGetLastError() +/* Authoritative Answer: Host not found */ #define WSAHOST_NOT_FOUND (WSABASEERR+1001) - /* Authoritative Answer: Host not found */ -#define WSATRY_AGAIN (WSABASEERR+1002) - /* Non-Authoritative: Host not found, or SERVERFAIL */ -#define WSANO_RECOVERY (WSABASEERR+1003) - /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ -#define WSANO_DATA (WSABASEERR+1004) - /* Valid name, no data record of requested type */ -#define WSANO_ADDRESS WSANO_DATA - /* no address, look for MX record */ - #define HOST_NOT_FOUND WSAHOST_NOT_FOUND - /* Authoritative Answer: Host not found */ + +/* Non-Authoritative: Host not found, or SERVERFAIL */ +#define WSATRY_AGAIN (WSABASEERR+1002) #define TRY_AGAIN WSATRY_AGAIN - /* Non-Authoritative: Host not found, or SERVERFAIL */ + +/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ +#define WSANO_RECOVERY (WSABASEERR+1003) #define NO_RECOVERY WSANO_RECOVERY - /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ + +/* Valid name, no data record of requested type */ +#define WSANO_DATA (WSABASEERR+1004) #define NO_DATA WSANO_DATA - /* Valid name, no data record of requested type */ + +/* no address, look for MX record */ +#define WSANO_ADDRESS WSANO_DATA #define NO_ADDRESS WSANO_ADDRESS - /* no address, look for MX record */ /* - * WinSockAPI errors redefined as regular Berkeley error constants + * Windows Sockets errors redefined as regular Berkeley error constants */ - #if 0 #define EWOULDBLOCK WSAEWOULDBLOCK #define EINPROGRESS WSAEINPROGRESS @@ -588,115 +611,126 @@ struct linger { /* Socket function prototypes */ -SOCKET PASCAL accept (SOCKET s, struct sockaddr FAR *addr, int FAR *addrlen); +SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr, + int FAR *addrlen); -int PASCAL bind (SOCKET s, struct sockaddr FAR *addr, int namelen); +int PASCAL FAR bind (SOCKET s, struct sockaddr FAR *addr, int namelen); -int PASCAL closesocket (SOCKET s); +int PASCAL FAR closesocket (SOCKET s); -int PASCAL connect (SOCKET s, struct sockaddr FAR *name, int namelen); +int PASCAL FAR connect (SOCKET s, struct sockaddr FAR *name, int namelen); -int PASCAL ioctlsocket (SOCKET s, int cmd, u_long FAR *arg); +int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp); -int PASCAL getpeername (SOCKET s, struct sockaddr FAR *name, int FAR * namelen); +int PASCAL FAR getpeername (SOCKET s, struct sockaddr FAR *name, + int FAR * namelen); -int PASCAL getsockname (SOCKET s, struct sockaddr FAR *name, int FAR * namelen); +int PASCAL FAR getsockname (SOCKET s, struct sockaddr FAR *name, + int FAR * namelen); -int PASCAL getsockopt (SOCKET s, int level, int optname, char FAR *optval, - int FAR *optlen); +int PASCAL FAR getsockopt (SOCKET s, int level, int optname, + char FAR * optval, int FAR *optlen); -u_long PASCAL htonl (u_long hostlong); +u_long PASCAL FAR htonl (u_long hostlong); -u_short PASCAL htons (u_short hostshort); +u_short PASCAL FAR htons (u_short hostshort); #if 0 -struct in_addr PASCALinet_addr (char FAR *cp); +struct in_addr PASCAL FAR inet_addr (char FAR * cp); #else unsigned long PASCAL inet_addr (char FAR *cp); #endif +char FAR * PASCAL FAR inet_ntoa (struct in_addr in); -char FAR * PASCAL inet_ntoa (struct in_addr in); - -int PASCAL listen (SOCKET s, int backlog); +int PASCAL FAR listen (SOCKET s, int backlog); -u_long PASCAL ntohl (u_long netlong); +u_long PASCAL FAR ntohl (u_long netlong); -u_short PASCAL ntohs (u_short netshort); +u_short PASCAL FAR ntohs (u_short netshort); -int PASCAL recv (SOCKET s, char FAR *buf, int len, int flags); +int PASCAL FAR recv (SOCKET s, char FAR * buf, int len, int flags); -int PASCAL recvfrom (SOCKET s, char FAR *buf, int len, int flags, struct - sockaddr FAR *from, int FAR * fromlen); +int PASCAL FAR recvfrom (SOCKET s, char FAR * buf, int len, int flags, + struct sockaddr FAR *from, int FAR * fromlen); -long PASCAL select (int nfds, fd_set FAR *readfds, fd_set far *writefds, +long PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set far *writefds, fd_set FAR *exceptfds, struct timeval far *timeout); -int PASCAL send (SOCKET s, char FAR *buf, int len, int flags); +int PASCAL FAR send (SOCKET s, char FAR * buf, int len, int flags); -int PASCAL sendto (SOCKET s, char FAR *buf, int len, int flags, struct - sockaddr FAR *to, int tolen); +int PASCAL FAR sendto (SOCKET s, char FAR * buf, int len, int flags, + struct sockaddr FAR *to, int tolen); -int PASCAL setsockopt (SOCKET s, int level, int optname, char far *optval, - int optlen); +int PASCAL FAR setsockopt (SOCKET s, int level, int optname, + char FAR * optval, int optlen); -int PASCAL shutdown (SOCKET s, int how); +int PASCAL FAR shutdown (SOCKET s, int how); -SOCKET PASCAL socket (int af, int type, int protocol); +SOCKET PASCAL FAR socket (int af, int type, int protocol); /* Database function prototypes */ -struct hostent FAR * PASCAL gethostbyaddr(char FAR * addr, int len,int type); +struct hostent FAR * PASCAL FAR gethostbyaddr(char FAR * addr, + int len, int type); -struct hostent FAR * PASCAL gethostbyname(char FAR * name); +struct hostent FAR * PASCAL FAR gethostbyname(char FAR * name); -struct servent FAR * PASCAL getservbyport(int port, char FAR * proto); +struct servent FAR * PASCAL FAR getservbyport(int port, char FAR * proto); -struct servent FAR * PASCAL getservbyname(char FAR * name, char FAR * proto); +struct servent FAR * PASCAL FAR getservbyname(char FAR * name, + char FAR * proto); -struct protoent FAR * PASCAL getprotobynumber(int proto); +struct protoent FAR * PASCAL FAR getprotobynumber(int proto); -struct protoent FAR * PASCAL getprotobyname(char FAR * name); +struct protoent FAR * PASCAL FAR getprotobyname(char FAR * name); /* Microsoft Windows Extension function prototypes */ -int PASCAL WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData); +int PASCAL FAR WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData); -int PASCAL WSACleanup(); +int PASCAL FAR WSACleanup(void); -void PASCAL WSASetLastError(int iError); +void PASCAL FAR WSASetLastError(int iError); -int PASCAL WSAGetLastError(); +int PASCAL FAR WSAGetLastError(void); -BOOL PASCAL WSAIsBlocking(); +BOOL PASCAL FAR WSAIsBlocking(void); -int PASCAL WSAUnhookBlockingHook(); +int PASCAL FAR WSAUnhookBlockingHook(void); -FARPROC PASCAL WSASetBlockingHook(FARPROC lpBlockFunc); +FARPROC PASCAL FAR WSASetBlockingHook(FARPROC lpBlockFunc); -int PASCAL WSACancelBlockingCall(); +int PASCAL FAR WSACancelBlockingCall(void); -HANDLE PASCAL WSAAsyncGetServByName(HWND hWnd, unsigned int wMsg, char FAR * name, - char FAR * proto, char FAR * buf, int buflen); +HANDLE PASCAL FAR WSAAsyncGetServByName(HWND hWnd, u_int wMsg, + char FAR * name, char FAR * proto, + char FAR * buf, int buflen); -HANDLE PASCAL WSAAsyncGetServByPort(HWND hWnd, unsigned int wMsg, int port, - char FAR * proto, char FAR * buf, int buflen); +HANDLE PASCAL FAR WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port, + char FAR * proto, char FAR * buf, + int buflen); -HANDLE PASCAL WSAAsyncGetProtoByName(HWND hWnd, unsigned int wMsg, char FAR * name, - char FAR * buf, int buflen); +HANDLE PASCAL FAR WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, + char FAR * name, char FAR * buf, + int buflen); -HANDLE PASCAL WSAAsyncGetProtoByNumber(HWND hWnd, unsigned int wMsg, int number, - char FAR * buf, int buflen); +HANDLE PASCAL FAR WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, + int number, char FAR * buf, + int buflen); -HANDLE PASCAL WSAAsyncGetHostByName(HWND hWnd, unsigned int wMsg, char FAR * name, - char FAR * buf, int buflen); +HANDLE PASCAL FAR WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, + char FAR * name, char FAR * buf, + int buflen); -HANDLE PASCAL WSAAsyncGetHostByAddr(HWND hWnd, unsigned int wMsg, char FAR *addr, int len, - int type, char FAR * buf, int buflen); +HANDLE PASCAL FAR WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, + char FAR * addr, int len, int type, + char FAR * buf, int buflen); -int PASCAL WSACancelAsyncRequest(HANDLE hAsyncTaskHandle); +int PASCAL FAR WSACancelAsyncRequest(HANDLE hAsyncTaskHandle); -int PASCAL WSASelectWindow(SOCKET s, HWND hWnd, unsigned int wMsg, long lEvent); +int PASCAL FAR WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, + long lEvent); /* Microsoft Windows Extended data types */ typedef struct sockaddr SOCKADDR; @@ -716,8 +750,8 @@ typedef struct in_addr *PIN_ADDR; typedef struct in_addr FAR *LPIN_ADDR; typedef struct fd_set FD_SET; -typedef struct fd_set PFD_SET; -typedef struct fd_set LPFD_SET; +typedef struct fd_set *PFD_SET; +typedef struct fd_set FAR *LPFD_SET; typedef struct hostent HOSTENT; typedef struct hostent *PHOSTENT; @@ -731,5 +765,42 @@ typedef struct protoent PROTOENT; typedef struct protoent *PPROTOENT; typedef struct protoent FAR *LPPROTOENT; -#endif /* _WINSOCKAPI_ */ +/* + * Windows message parameter composition and decomposition + * macros. + * + * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation + * when constructing the response to a WSAGetXByY() + */ +#define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error) +/* + * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation + * when constructing the response to WSAAsyncSelect() + */ +#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error) +/* + * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application + * to extract the buffer length from the lParam in the response + * to a WSAGetXByY(). + */ +#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam) +/* + * WSAGETASYNCERROR is intended for use by the Windows Sockets application + * to extract the error code from the lParam in the response + * to a WSAGetXByY(). + */ +#define WSAGETASYNCERROR(lParam) HIWORD(lParam) +/* + * WSAGETSELECTEVENT is intended for use by the Windows Sockets application + * to extract the event code from the lParam in the response + * to a WSAAsyncSelect(). + */ +#define WSAGETSELECTEVENT(lParam) LOWORD(lParam) +/* + * WSAGETSELECTERROR is intended for use by the Windows Sockets application + * to extract the error code from the lParam in the response + * to a WSAAsyncSelect(). + */ +#define WSAGETSELECTERROR(lParam) HIWORD(lParam) +#endif /* _WINSOCKAPI_ */