All modules either build with msvcrt headers or define USE_WS_PREFIX now.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- include/msvcrt/sys/types.h | 8 -------- include/winsock.h | 21 +++++---------------- 2 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/include/msvcrt/sys/types.h b/include/msvcrt/sys/types.h index b44aa386d44..47af7752a5d 100644 --- a/include/msvcrt/sys/types.h +++ b/include/msvcrt/sys/types.h @@ -46,14 +46,6 @@ typedef int _off_t; #define _OFF_T_DEFINED #endif
-#ifndef _BSDTYPES_DEFINED -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef __msvcrt_ulong u_long; -#define _BSDTYPES_DEFINED -#endif - #define dev_t _dev_t #define ino_t _ino_t #define mode_t _mode_t diff --git a/include/winsock.h b/include/winsock.h index cafac1a1723..1d33d573329 100644 --- a/include/winsock.h +++ b/include/winsock.h @@ -114,28 +114,17 @@
#include <inaddr.h>
-#ifdef USE_WS_PREFIX -typedef unsigned char WS_u_char; -typedef unsigned short WS_u_short; -typedef unsigned int WS_u_int; -typedef ULONG WS_u_long; -#elif (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED) -/* MinGW doesn't define the u_xxx types */ -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef ULONG u_long; -#define _BSDTYPES_DEFINED -#else -#define u_long ULONG /* make sure we don't use the system u_long */ -#endif - #ifdef USE_WS_PREFIX # define WS(x) WS_##x #else # define WS(x) x #endif
+typedef unsigned char WS(u_char); +typedef unsigned short WS(u_short); +typedef unsigned int WS(u_int); +typedef ULONG WS(u_long); + #ifdef __cplusplus extern "C" { #endif /* defined(__cplusplus) */
All modules either build with msvcrt headers or define USE_WS_PREFIX now.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/http.sys/http.c | 1 + dlls/inetmib1/main.c | 1 + dlls/ntdll/rtl.c | 1 + dlls/ntoskrnl.exe/tests/ntoskrnl.c | 1 + dlls/rpcrt4/rpcrt4_main.c | 1 + dlls/ws2_32/tests/sock.c | 5 -- include/iphlpapi.h | 16 ++--- include/winsock.h | 103 +---------------------------- include/ws2tcpip.h | 6 +- programs/ipconfig/ipconfig.c | 1 + 10 files changed, 15 insertions(+), 121 deletions(-)
diff --git a/dlls/http.sys/http.c b/dlls/http.sys/http.c index e655edfeea2..ab021b9d8eb 100644 --- a/dlls/http.sys/http.c +++ b/dlls/http.sys/http.c @@ -19,6 +19,7 @@ */
#include <assert.h> +#include <stdlib.h> #include "ntstatus.h" #define WIN32_NO_STATUS #include "wine/http.h" diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c index 6345573350e..2aa8b43dc21 100644 --- a/dlls/inetmib1/main.c +++ b/dlls/inetmib1/main.c @@ -26,6 +26,7 @@ #include "windef.h" #include "winbase.h" #include "snmp.h" +#include "winsock2.h" #include "iphlpapi.h" #include "wine/debug.h"
diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index cf21c980a45..04690e8fb06 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -24,6 +24,7 @@ */
#include <stdarg.h> +#include <stdlib.h>
#include "ntstatus.h" #define NONAMELESSUNION diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c index 9fe4cd03175..efab9a01f22 100644 --- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c @@ -22,6 +22,7 @@ */
#include <stdio.h> +#include <time.h> #include "ntstatus.h" #define WIN32_NO_STATUS #include "windows.h" diff --git a/dlls/rpcrt4/rpcrt4_main.c b/dlls/rpcrt4/rpcrt4_main.c index 57e33673c7a..6889bf131a0 100644 --- a/dlls/rpcrt4/rpcrt4_main.c +++ b/dlls/rpcrt4/rpcrt4_main.c @@ -42,6 +42,7 @@ #include "winnt.h" #include "winternl.h" #include "ntsecapi.h" +#include "winsock2.h" #include "iptypes.h" #include "iphlpapi.h" #include "rpc.h" diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 61af5b0183a..717c6264fc0 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -4147,11 +4147,6 @@ static void test_dns(void) "hostent->h_addr_list[0] should be in %p, it is in %p\n", addr.mem, h->h_addr_list[0]); }
-/* Our winsock headers don't define gethostname because it conflicts with the - * definition in unistd.h. Define it here to get rid of the warning. */ - -int WINAPI gethostname(char *name, int namelen); - static void test_gethostbyname(void) { struct hostent *he; diff --git a/include/iphlpapi.h b/include/iphlpapi.h index da5819c8423..cd4bf50b39e 100644 --- a/include/iphlpapi.h +++ b/include/iphlpapi.h @@ -26,6 +26,12 @@ extern "C" { #include <ipexport.h> #include <iptypes.h>
+#ifdef USE_WS_PREFIX +# define WS(x) WS_##x +#else +# define WS(x) x +#endif + #define NET_STRING_IPV4_ADDRESS 0x00000001 #define NET_STRING_IPV4_SERVICE 0x00000002 #define NET_STRING_IPV4_NETWORK 0x00000004 @@ -124,15 +130,7 @@ DWORD WINAPI GetUniDirectionalAdapterInfo(
DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex);
-#ifdef __WINE_WINSOCKAPI_STDLIB_H -DWORD WINAPI GetBestInterfaceEx( -#ifdef USE_WS_PREFIX - struct WS_sockaddr *pDestAddr, -#else - struct sockaddr *pDestAddr, -#endif - PDWORD pdwBestIfIndex); -#endif +DWORD WINAPI GetBestInterfaceEx(struct WS(sockaddr) *addr, DWORD *index);
DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute); diff --git a/include/winsock.h b/include/winsock.h index 1d33d573329..4b65c38da68 100644 --- a/include/winsock.h +++ b/include/winsock.h @@ -26,87 +26,6 @@ # endif #endif
-#ifndef __WINE_WINSOCKAPI_STDLIB_H -#define __WINE_WINSOCKAPI_STDLIB_H - -/* - * This section defines the items that conflict with the Unix headers. - */ -#ifndef USE_WS_PREFIX -/* We are not using the WS_ prefix we risk getting conflicts for - * everything related to select. - */ -# ifdef FD_CLR -/* Too late, the Unix version of stdlib.h was included before winsock.h. - * This means select and all the related stuff is already defined and we - * cannot override types and function prototypes. - * All we can do is disable all these symbols so that they are not used - * inadvertently. - */ -# include <sys/types.h> -# undef FD_SETSIZE -# undef FD_CLR -# undef FD_SET -# undef FD_ZERO -# undef FD_ISSET - -# define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library -# define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library -# define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library -# define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library -# define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library -# define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library -# define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library -# elif defined(RLIM_INFINITY) -/* On Darwin stdlib.h includes sys/resource.h which defines timeval but not the fd_set macros */ -# define fd_set unix_fd_set -# include <sys/types.h> -# include <time.h> -# include <stdlib.h> -# undef fd_set -# undef FD_SETSIZE -# undef FD_CLR -# undef FD_SET -# undef FD_ZERO -# undef FD_ISSET -# define select Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library -# define timeval Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library -# else /* FD_CLR */ -/* stdlib.h has not been included yet so it's not too late. Include it now - * making sure that none of the select symbols is affected. Then we can - * define them with our own values. - */ -# define fd_set unix_fd_set -# define timeval unix_timeval -# define select unix_select -# define socklen_t unix_socklen_t -# define u_long unix_u_long -# include <sys/types.h> -# include <time.h> -# include <stdlib.h> -# undef fd_set -# undef timeval -# undef select -# undef socklen_t -# undef u_long -# undef FD_SETSIZE -# undef FD_CLR -# undef FD_SET -# undef FD_ZERO -# undef FD_ISSET -# undef _TIMEVAL_DEFINED - -# define WS_DEFINE_SELECT -# endif /* FD_CLR */ - -#else -# define WS_DEFINE_SELECT -# include <sys/types.h> -# include <stdlib.h> -#endif /* !USE_WS_PREFIX */ - -#endif /* __WINE_WINSOCKAPI_STDLIB_H */ - #include <windows.h>
#ifndef _WINSOCKAPI_ @@ -408,9 +327,6 @@ typedef struct WS(linger) * Select */
-#ifdef WS_DEFINE_SELECT -/* Define our own version of select and the associated types and macros */ - # ifndef USE_WS_PREFIX # ifndef FD_SETSIZE # define FD_SETSIZE 64 @@ -431,14 +347,11 @@ typedef struct WS(fd_set) # endif } WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
-#ifndef _TIMEVAL_DEFINED -#define _TIMEVAL_DEFINED typedef struct WS(timeval) { LONG tv_sec; /* seconds */ LONG tv_usec; /* and microseconds */ } TIMEVAL, *PTIMEVAL, *LPTIMEVAL; -#endif
#define __WS_FD_CLR(fd, set, cast) do { \ unsigned int __i; \ @@ -498,16 +411,8 @@ typedef struct WS(timeval)
int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
-#endif /* WS_DEFINE_SELECT */ - -/* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */ #ifndef USE_WS_PREFIX
-#undef htonl -#undef htons -#undef ntohl -#undef ntohs - #ifdef WORDS_BIGENDIAN
static inline u_short __wine_ushort_noop(u_short s) @@ -1020,12 +925,11 @@ int WINAPI WS(closesocket)(SOCKET); int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int); struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int); struct WS(hostent)* WINAPI WS(gethostbyname)(const char*); +int WINAPI WS(gethostname)(char*,int); int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*); struct WS(protoent)* WINAPI WS(getprotobyname)(const char*); struct WS(protoent)* WINAPI WS(getprotobynumber)(int); -#ifdef WS_DEFINE_SELECT int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*); -#endif struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*); struct WS(servent)* WINAPI WS(getservbyport)(int,const char*); int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*); @@ -1042,11 +946,6 @@ int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int); int WINAPI WS(shutdown)(SOCKET,int); SOCKET WINAPI WS(socket)(int,int,int);
-#if defined(__MINGW32__) || defined (_MSC_VER) || defined(__WINE_USE_MSVCRT) -/* gethostname is not defined on Unix because of conflicts with unistd.h */ -int WINAPI WS(gethostname)(char*,int); -#endif - #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
#ifdef __cplusplus diff --git a/include/ws2tcpip.h b/include/ws2tcpip.h index 5ba891185b5..19f4ec22941 100644 --- a/include/ws2tcpip.h +++ b/include/ws2tcpip.h @@ -58,11 +58,7 @@ typedef struct WS(addrinfoW) typedef WINELIB_NAME_AW(ADDRINFO) ADDRINFOT, *PADDRINFOT; #endif
-#ifdef USE_WS_PREFIX -typedef int WS_socklen_t; -#else -#define socklen_t int /* avoid conflicts with the system's socklen_t typedef */ -#endif +typedef int WS(socklen_t);
typedef ADDRINFOA ADDRINFO, *LPADDRINFO;
diff --git a/programs/ipconfig/ipconfig.c b/programs/ipconfig/ipconfig.c index a056771128c..cd9069cd59e 100644 --- a/programs/ipconfig/ipconfig.c +++ b/programs/ipconfig/ipconfig.c @@ -22,6 +22,7 @@ #define NONAMELESSUNION
#include <stdio.h> +#include <stdlib.h> #include <winsock2.h> #include <windows.h> #include <iphlpapi.h>
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89306
Your paranoid android.
=== w864 (64 bit report) ===
ntoskrnl.exe: 0a8c:ntoskrnl: unhandled exception c0000005 at 00007FF9FBF63DAA
=== debiant2 (32 bit report) ===
ws2_32: sock.c:1863: Test failed: bind(s1) failed error: 10048 sock.c:1893: Test failed: listen() failed with error: 10022
=== debiant2 (32 bit French report) ===
ws2_32: sock.c:1863: Test failed: bind(s1) failed error: 10048 sock.c:1893: Test failed: listen() failed with error: 10022
=== debiant2 (32 bit Japanese:Japan report) ===
ws2_32: sock.c:1863: Test failed: bind(s1) failed error: 10048 sock.c:1893: Test failed: listen() failed with error: 10022
=== debiant2 (32 bit Chinese:China report) ===
ntdll: om.c:2305: Test failed: got 87
ws2_32: sock.c:1863: Test failed: bind(s1) failed error: 10048 sock.c:1893: Test failed: listen() failed with error: 10022
=== debiant2 (64 bit WoW report) ===
ws2_32: sock.c:1863: Test failed: bind(s1) failed error: 10048 sock.c:1893: Test failed: listen() failed with error: 10022
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/socket.c | 2 +- include/winsock.h | 139 +++------------- include/winsock2.h | 370 ++++++++++++++++++++++++++++++++++++++++++- include/ws2def.h | 160 +++++++++++++++++++ server/sock.c | 28 +--- 5 files changed, 551 insertions(+), 148 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 262171ebab0..29464fb94c9 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -905,7 +905,7 @@ static const int ws_proto_map[][2] = MAP_OPTION( IPPROTO_ICMP ), MAP_OPTION( IPPROTO_IGMP ), MAP_OPTION( IPPROTO_RAW ), - MAP_OPTION( IPPROTO_IPIP ), + {WS_IPPROTO_IPV4, IPPROTO_IPIP}, {FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO}, };
diff --git a/include/winsock.h b/include/winsock.h index 4b65c38da68..d9f790f55ac 100644 --- a/include/winsock.h +++ b/include/winsock.h @@ -21,9 +21,7 @@ */
#ifdef __WINESRC__ -# ifndef __WINE_WINSOCK2__ -# error Please use Winsock2 in Wine -# endif +# error Please use winsock2 in Wine #endif
#include <windows.h> @@ -76,12 +74,7 @@ extern "C" { #define AF_FIREFOX 19 #define AF_UNKNOWN1 20 #define AF_BAN 21 -#define AF_ATM 22 -#define AF_INET6 23 -#define AF_CLUSTER 24 -#define AF_12844 25 -#define AF_IRDA 26 -#define AF_MAX 27 +#define AF_MAX 22 #define PF_UNSPEC AF_UNSPEC #define PF_UNIX AF_UNIX #define PF_INET AF_INET @@ -131,12 +124,7 @@ extern "C" { #define WS_AF_FIREFOX 19 #define WS_AF_UNKNOWN1 20 #define WS_AF_BAN 21 -#define WS_AF_ATM 22 -#define WS_AF_INET6 23 -#define WS_AF_CLUSTER 24 -#define WS_AF_12844 25 -#define WS_AF_IRDA 26 -#define WS_AF_MAX 27 +#define WS_AF_MAX 22 #endif /* USE_WS_PREFIX */
/* @@ -165,12 +153,9 @@ extern "C" { #define IPPROTO_ICMP 1 #define IPPROTO_IGMP 2 #define IPPROTO_GGP 3 -#define IPPROTO_IPIP 4 #define IPPROTO_TCP 6 #define IPPROTO_UDP 17 #define IPPROTO_IDP 22 -#define IPPROTO_IPV6 41 -#define IPPROTO_ICMPV6 58 #define IPPROTO_ND 77 #define IPPROTO_RAW 255 #define IPPROTO_MAX 256 @@ -179,12 +164,9 @@ extern "C" { #define WS_IPPROTO_ICMP 1 #define WS_IPPROTO_IGMP 2 #define WS_IPPROTO_GGP 3 -#define WS_IPPROTO_IPIP 4 #define WS_IPPROTO_TCP 6 #define WS_IPPROTO_UDP 17 #define WS_IPPROTO_IDP 22 -#define WS_IPPROTO_IPV6 41 -#define WS_IPPROTO_ICMPV6 58 #define WS_IPPROTO_ND 77 #define WS_IPPROTO_RAW 255 #define WS_IPPROTO_MAX 256 @@ -370,32 +352,11 @@ typedef struct WS(timeval) } \ } \ } while(0) -#define __WS_FD_SET1(fd, set, cast) do { \ + +#define __WS_FD_SET(fd, set, cast) do { \ if (((cast*)(set))->fd_count < FD_SETSIZE) \ ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \ } while(0) -/* This version checks if the filedesc is already in the list, and appends it - * only if it's not the case - */ -#define __WS_FD_SET2(fd, set, cast) do { \ - unsigned int __i; \ - for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \ - { \ - if (((cast*)(set))->fd_array[__i]==(fd)) \ - break; \ - } \ - if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \ - { \ - ((cast*)(set))->fd_count++; \ - ((cast*)(set))->fd_array[__i]=(fd);\ - } \ -} while(0) - -#ifndef __WINE_WINSOCK2__ -#define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast) -#else -#define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast) -#endif
#ifndef USE_WS_PREFIX #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set) @@ -507,13 +468,11 @@ typedef struct WS(sockaddr_in) * Multicast group information */
-#if !defined(__WINE_WINSOCK2__) struct WS(ip_mreq) { struct WS(in_addr) imr_multiaddr; struct WS(in_addr) imr_interface; }; -#endif
/* * WSAStartup @@ -566,12 +525,6 @@ typedef struct WS(WSAData) #define SO_RCVTIMEO 0x1006 #define SO_ERROR 0x1007 #define SO_TYPE 0x1008 -#define SO_BSP_STATE 0x1009 - -#define SO_RANDOMIZE_PORT 0x3005 -#define SO_PORT_SCALABILITY 0x3006 -#define SO_REUSE_UNICASTPORT 0x3007 -#define SO_REUSE_MULTICASTPORT 0x3008
#define IOCPARM_MASK 0x7f #define IOC_VOID 0x20000000 @@ -605,12 +558,6 @@ typedef struct WS(WSAData) #define WS_SO_RCVTIMEO 0x1006 #define WS_SO_ERROR 0x1007 #define WS_SO_TYPE 0x1008 -#define WS_SO_BSP_STATE 0x1009 - -#define WS_SO_RANDOMIZE_PORT 0x3005 -#define WS_SO_PORT_SCALABILITY 0x3006 -#define WS_SO_REUSE_UNICASTPORT 0x3007 -#define WS_SO_REUSE_MULTICASTPORT 0x3008
#define WS_IOCPARM_MASK 0x7f #define WS_IOC_VOID 0x20000000 @@ -631,31 +578,26 @@ typedef struct WS(WSAData) #define WS_TCP_NODELAY 1 #endif
-/* IPPROTO_IP options */ -#ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */ -# ifndef USE_WS_PREFIX -# define IP_OPTIONS 1 -# define IP_MULTICAST_IF 2 -# define IP_MULTICAST_TTL 3 -# define IP_MULTICAST_LOOP 4 -# define IP_ADD_MEMBERSHIP 5 -# define IP_DROP_MEMBERSHIP 6 -# define IP_TTL 7 -# define IP_TOS 8 -# define IP_DONTFRAGMENT 9 -# define IP_RECEIVE_BROADCAST 22 -# else -# define WS_IP_OPTIONS 1 -# define WS_IP_MULTICAST_IF 2 -# define WS_IP_MULTICAST_TTL 3 -# define WS_IP_MULTICAST_LOOP 4 -# define WS_IP_ADD_MEMBERSHIP 5 -# define WS_IP_DROP_MEMBERSHIP 6 -# define WS_IP_TTL 7 -# define WS_IP_TOS 8 -# define WS_IP_DONTFRAGMENT 9 -# define WS_IP_RECEIVE_BROADCAST 22 -# endif +#ifndef USE_WS_PREFIX +# define IP_OPTIONS 1 +# define IP_MULTICAST_IF 2 +# define IP_MULTICAST_TTL 3 +# define IP_MULTICAST_LOOP 4 +# define IP_ADD_MEMBERSHIP 5 +# define IP_DROP_MEMBERSHIP 6 +# define IP_TTL 7 +# define IP_TOS 8 +# define IP_DONTFRAGMENT 9 +#else +# define WS_IP_OPTIONS 1 +# define WS_IP_MULTICAST_IF 2 +# define WS_IP_MULTICAST_TTL 3 +# define WS_IP_MULTICAST_LOOP 4 +# define WS_IP_ADD_MEMBERSHIP 5 +# define WS_IP_DROP_MEMBERSHIP 6 +# define WS_IP_TTL 7 +# define WS_IP_TOS 8 +# define WS_IP_DONTFRAGMENT 9 #endif
@@ -691,8 +633,6 @@ typedef struct WS(WSAData) #define MSG_OOB 0x0001 #define MSG_PEEK 0x0002 #define MSG_DONTROUTE 0x0004 -#define MSG_WAITALL 0x0008 -#define MSG_INTERRUPT 0x0010 #define MSG_PARTIAL 0x8000 #define MSG_MAXIOVLEN 16 #else /* USE_WS_PREFIX */ @@ -701,8 +641,6 @@ typedef struct WS(WSAData) #define WS_MSG_OOB 0x0001 #define WS_MSG_PEEK 0x0002 #define WS_MSG_DONTROUTE 0x0004 -#define WS_MSG_WAITALL 0x0008 -#define WS_MSG_INTERRUPT 0x0010 #define WS_MSG_PARTIAL 0x8000 #define WS_MSG_MAXIOVLEN 16 #endif /* USE_WS_PREFIX */ @@ -727,15 +665,6 @@ typedef struct WS(WSAData) #define FD_CONNECT 0x00000010 #define FD_CLOSE 0x00000020
-/* internal per-socket flags */ -#ifdef __WINESRC__ -#define FD_WINE_LISTENING 0x10000000 -#define FD_WINE_NONBLOCKING 0x20000000 -#define FD_WINE_CONNECTED 0x40000000 -#define FD_WINE_RAW 0x80000000 -#define FD_WINE_INTERNAL 0xFFFF0000 -#endif - /* * All Windows Sockets error constants are biased by WSABASEERR from * the "normal". They are also defined in winerror.h. @@ -799,17 +728,6 @@ typedef struct WS(WSAData) #define WSAVERNOTSUPPORTED (WSABASEERR+92) #define WSANOTINITIALISED (WSABASEERR+93) #define WSAEDISCON (WSABASEERR+101) -#define WSAENOMORE (WSABASEERR+102) -#define WSAECANCELLED (WSABASEERR+103) -#define WSAEINVALIDPROCTABLE (WSABASEERR+104) -#define WSAEINVALIDPROVIDER (WSABASEERR+105) -#define WSAEPROVIDERFAILEDINIT (WSABASEERR+106) -#define WSASYSCALLFAILURE (WSABASEERR+107) -#define WSASERVICE_NOT_FOUND (WSABASEERR+108) -#define WSATYPE_NOT_FOUND (WSABASEERR+109) -#define WSA_E_NO_MORE (WSABASEERR+110) -#define WSA_E_CANCELLED (WSABASEERR+111) -#define WSAEREFUSED (WSABASEERR+112)
/* * Error return codes from gethostbyname() and gethostbyaddr() @@ -901,7 +819,6 @@ typedef struct WS(WSAData) * Remember to keep this section in sync with the * "Winsock Function Typedefs" section in winsock2.h. */ -#if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,WS(u_int),const char*,int,int,char*,int); HANDLE WINAPI WSAAsyncGetHostByName(HWND,WS(u_int),const char*,char*,int); HANDLE WINAPI WSAAsyncGetProtoByName(HWND,WS(u_int),const char*,char*,int); @@ -946,16 +863,10 @@ int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int); int WINAPI WS(shutdown)(SOCKET,int); SOCKET WINAPI WS(socket)(int,int,int);
-#endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */ - #ifdef __cplusplus } #endif
-#ifndef __WINE_WINSOCK2__ #undef WS -#undef WS_API_PROTOTYPES -#undef WS_API_TYPEDEFS -#endif
#endif /* _WINSOCKAPI_ */ diff --git a/include/winsock2.h b/include/winsock2.h index 1935c99ad40..30d29ce0b57 100644 --- a/include/winsock2.h +++ b/include/winsock2.h @@ -17,13 +17,26 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * FIXME: Still missing required Winsock 2 definitions. */
#ifndef _WINSOCK2API_ #define _WINSOCK2API_
+#include <windows.h> + +#ifdef USE_WS_PREFIX +# define WS(x) WS_##x +#else +# define WS(x) x +#endif + +typedef unsigned char WS(u_char); +typedef unsigned short WS(u_short); +typedef unsigned int WS(u_int); +typedef ULONG WS(u_long); + +typedef UINT_PTR SOCKET; + /* * Setup phase */ @@ -43,18 +56,36 @@ #define WS_API_TYPEDEFS INCL_WINSOCK_API_TYPEDEFS #endif
-#define __WINE_WINSOCK2__ -#include <winsock.h> -#undef __WINE_WINSOCK2__ - #include <ws2def.h>
#ifdef __cplusplus extern "C" { #endif /* defined(__cplusplus) */
+#define INVALID_SOCKET (SOCKET)(~0) +#define SOCKET_ERROR (-1)
#ifndef USE_WS_PREFIX +#define SOL_SOCKET 0xffff +#define SO_DEBUG 0x0001 +#define SO_ACCEPTCONN 0x0002 +#define SO_REUSEADDR 0x0004 +#define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR)) +#define SO_KEEPALIVE 0x0008 +#define SO_DONTROUTE 0x0010 +#define SO_BROADCAST 0x0020 +#define SO_USELOOPBACK 0x0040 +#define SO_LINGER 0x0080 +#define SO_OOBINLINE 0x0100 +#define SO_DONTLINGER ((u_int)(~SO_LINGER)) +#define SO_SNDBUF 0x1001 +#define SO_RCVBUF 0x1002 +#define SO_SNDLOWAT 0x1003 +#define SO_RCVLOWAT 0x1004 +#define SO_SNDTIMEO 0x1005 +#define SO_RCVTIMEO 0x1006 +#define SO_ERROR 0x1007 +#define SO_TYPE 0x1008 #define SO_GROUP_ID 0x2001 #define SO_GROUP_PRIORITY 0x2002 #define SO_MAX_MSG_SIZE 0x2003 @@ -64,6 +95,26 @@ extern "C" { #define PVD_CONFIG 0x3001 #define SO_CONDITIONAL_ACCEPT 0x3002 #else +#define WS_SOL_SOCKET 0xffff +#define WS_SO_DEBUG 0x0001 +#define WS_SO_ACCEPTCONN 0x0002 +#define WS_SO_REUSEADDR 0x0004 +#define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR)) +#define WS_SO_KEEPALIVE 0x0008 +#define WS_SO_DONTROUTE 0x0010 +#define WS_SO_BROADCAST 0x0020 +#define WS_SO_USELOOPBACK 0x0040 +#define WS_SO_LINGER 0x0080 +#define WS_SO_OOBINLINE 0x0100 +#define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER)) +#define WS_SO_SNDBUF 0x1001 +#define WS_SO_RCVBUF 0x1002 +#define WS_SO_SNDLOWAT 0x1003 +#define WS_SO_RCVLOWAT 0x1004 +#define WS_SO_SNDTIMEO 0x1005 +#define WS_SO_RCVTIMEO 0x1006 +#define WS_SO_ERROR 0x1007 +#define WS_SO_TYPE 0x1008 #define WS_SO_GROUP_ID 0x2001 #define WS_SO_GROUP_PRIORITY 0x2002 #define WS_SO_MAX_MSG_SIZE 0x2003 @@ -95,7 +146,31 @@ extern "C" { /* protocol families */
#ifndef USE_WS_PREFIX +#define PF_APPLETALK AF_APPLETALK +#define PF_BAN AF_BAN +#define PF_CCITT AF_CCITT +#define PF_CHAOS AF_CHAOS +#define PF_DATAKIT AF_DATAKIT +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_ECMA AF_ECMA +#define PF_FIREFOX AF_FIREFOX +#define PF_HYLINK AF_HYLINK +#define PF_IMPLINK AF_IMPLINK +#define PF_INET AF_INET #define PF_INET6 AF_INET6 +#define PF_IPX AF_IPX +#define PF_ISO AF_ISO +#define PF_LAT AF_LAT +#define PF_MAX AF_MAX +#define PF_NS AF_NS +#define PF_OSI AF_OSI +#define PF_PUP AF_PUP +#define PF_SNA AF_SNA +#define PF_UNIX AF_UNIX +#define PF_UNKNOWN1 AF_UNKNOWN1 +#define PF_UNSPEC AF_UNSPEC +#define PF_VOICEVIEW AF_VOICEVIEW #endif
/* option flags per socket */ @@ -112,11 +187,23 @@ extern "C" { #define FD_ROUTING_INTERFACE_CHANGE_BIT 8 #define FD_ADDRESS_LIST_CHANGE_BIT 9
+#define FD_READ 0x00000001 +#define FD_WRITE 0x00000002 +#define FD_OOB 0x00000004 +#define FD_ACCEPT 0x00000008 +#define FD_CONNECT 0x00000010 +#define FD_CLOSE 0x00000020 #define FD_QOS 0x00000040 #define FD_GROUP_QOS 0x00000080 #define FD_ROUTING_INTERFACE_CHANGE 0x00000100 #define FD_ADDRESS_LIST_CHANGE 0x00000200
+#ifdef __WINESRC__ +#define FD_WINE_LISTENING 0x10000000 +#define FD_WINE_NONBLOCKING 0x20000000 +#define FD_WINE_CONNECTED 0x40000000 +#endif + /* Constants for LPCONDITIONPROC */ #define CF_ACCEPT 0x0000 #define CF_REJECT 0x0001 @@ -164,10 +251,22 @@ extern "C" { #define WS_IOC_OUT 0x40000000 #define WS_IOC_IN 0x80000000 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT) +#define WS_IOCPARM_MASK 0x7f +#define WS__IO(x,y) (WS_IOC_VOID | ((x) << 8) | (y)) +#define WS__IOR(x,y,t) (WS_IOC_OUT | (((UINT)sizeof(t) & WS_IOCPARM_MASK) << 16) | ((x) << 8) | (y)) +#define WS__IOW(x,y,t) (WS_IOC_IN | (((UINT)sizeof(t) & WS_IOCPARM_MASK) << 16) | ((x) << 8) | (y)) #define _WSAIO(x,y) (WS_IOC_VOID|(x)|(y)) #define _WSAIOR(x,y) (WS_IOC_OUT|(x)|(y)) #define _WSAIOW(x,y) (WS_IOC_IN|(x)|(y)) #define _WSAIORW(x,y) (WS_IOC_INOUT|(x)|(y)) +#define WS_FIONREAD WS__IOR('f', 127, ULONG) +#define WS_FIONBIO WS__IOW('f', 126, ULONG) +#define WS_FIOASYNC WS__IOW('f', 125, ULONG) +#define WS_SIOCSHIWAT WS__IOW('s', 0, ULONG) +#define WS_SIOCGHIWAT WS__IOR('s', 1, ULONG) +#define WS_SIOCSLOWAT WS__IOW('s', 2, ULONG) +#define WS_SIOCGLOWAT WS__IOR('s', 3, ULONG) +#define WS_SIOCATMARK WS__IOR('s', 7, ULONG) #define WS_SIO_ASSOCIATE_HANDLE _WSAIOW(WS_IOC_WS2,1) #define WS_SIO_ENABLE_CIRCULAR_QUEUEING _WSAIO(WS_IOC_WS2,2) #define WS_SIO_FIND_ROUTE _WSAIOR(WS_IOC_WS2,3) @@ -200,10 +299,22 @@ extern "C" { #define IOC_OUT 0x40000000 #define IOC_IN 0x80000000 #define IOC_INOUT (IOC_IN|IOC_OUT) +#define IOCPARM_MASK 0x7f +#define _IO(x,y) (IOC_VOID | ((x) << 8) | (y)) +#define _IOR(x,y,t) (IOC_OUT | (((UINT)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y)) +#define _IOW(x,y,t) (IOC_IN | (((UINT)sizeof(t) & IOCPARM_MASK) << 16) | ((x) << 8) | (y)) #define _WSAIO(x,y) (IOC_VOID|(x)|(y)) #define _WSAIOR(x,y) (IOC_OUT|(x)|(y)) #define _WSAIOW(x,y) (IOC_IN|(x)|(y)) #define _WSAIORW(x,y) (IOC_INOUT|(x)|(y)) +#define FIONREAD _IOR('f', 127, ULONG) +#define FIONBIO _IOW('f', 126, ULONG) +#define FIOASYNC _IOW('f', 125, ULONG) +#define SIOCSHIWAT _IOW('s', 0, ULONG) +#define SIOCGHIWAT _IOR('s', 1, ULONG) +#define SIOCSLOWAT _IOW('s', 2, ULONG) +#define SIOCGLOWAT _IOR('s', 3, ULONG) +#define SIOCATMARK _IOR('s', 7, ULONG) #define SIO_ASSOCIATE_HANDLE _WSAIOW(IOC_WS2,1) #define SIO_ENABLE_CIRCULAR_QUEUEING _WSAIO(IOC_WS2,2) #define SIO_FIND_ROUTE _WSAIOR(IOC_WS2,3) @@ -225,6 +336,28 @@ extern "C" { #define SIO_GET_INTERFACE_LIST _IOR ('t', 127, ULONG) #endif /* USE_WS_PREFIX */
+#ifndef USE_WS_PREFIX +#define SOMAXCONN 0x7fffffff + +#define MSG_OOB 0x0001 +#define MSG_PEEK 0x0002 +#define MSG_DONTROUTE 0x0004 +#define MSG_WAITALL 0x0008 +#define MSG_INTERRUPT 0x0010 +#define MSG_PARTIAL 0x8000 +#define MSG_MAXIOVLEN 16 +#else /* USE_WS_PREFIX */ +#define WS_SOMAXCONN 0x7fffffff + +#define WS_MSG_OOB 0x0001 +#define WS_MSG_PEEK 0x0002 +#define WS_MSG_DONTROUTE 0x0004 +#define WS_MSG_WAITALL 0x0008 +#define WS_MSG_INTERRUPT 0x0010 +#define WS_MSG_PARTIAL 0x8000 +#define WS_MSG_MAXIOVLEN 16 +#endif /* USE_WS_PREFIX */ + /* Constants for WSAIoctl() */ #define WSA_FLAG_OVERLAPPED 0x0001 #define WSA_FLAG_MULTIPOINT_C_ROOT 0x0002 @@ -284,6 +417,8 @@ extern "C" { #include <guiddef.h> #endif
+#define MAXGETHOSTSTRUCT 1024 + #define MAX_PROTOCOL_CHAIN 7 #define BASE_PROTOCOL 1 #define LAYERED_PROTOCOL 0 @@ -328,6 +463,74 @@ typedef struct _WSAPROTOCOLCHAIN
#define SECURITY_PROTOCOL_NONE 0x0000
+typedef struct WS(timeval) +{ + LONG tv_sec; + LONG tv_usec; +} TIMEVAL, *PTIMEVAL, *LPTIMEVAL; + +#define __WS_FD_CLR(fd, set, cast) do { \ + unsigned int __i; \ + for (__i = 0; __i < ((cast*)(set))->fd_count; __i++) \ + { \ + if (((cast*)(set))->fd_array[__i] == fd) \ + { \ + while (__i < ((cast*)(set))->fd_count-1) \ + { \ + ((cast*)(set))->fd_array[__i] = \ + ((cast*)(set))->fd_array[__i+1]; \ + __i++; \ + } \ + ((cast*)(set))->fd_count--; \ + break; \ + } \ + } \ +} while (0) + +#define __WS_FD_SET(fd, set, cast) do { \ + unsigned int __i; \ + for (__i = 0; __i < ((cast*)(set))->fd_count; __i++) \ + { \ + if (((cast*)(set))->fd_array[__i] == (fd)) \ + break; \ + } \ + if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \ + { \ + ((cast*)(set))->fd_count++; \ + ((cast*)(set))->fd_array[__i]=(fd);\ + } \ +} while (0) + +#ifndef USE_WS_PREFIX + +# ifndef FD_SETSIZE +# define FD_SETSIZE 64 +# endif + +# define FD_CLR(fd, set) __WS_FD_CLR((fd), (set), fd_set) +# define FD_SET(fd, set) __WS_FD_SET((fd), (set), fd_set) +# define FD_ZERO(set) (((fd_set*)(set))->fd_count=0) +# define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set)) + +#else + +# ifndef WS_FD_SETSIZE +# define WS_FD_SETSIZE 64 +# endif + +# define WS_FD_CLR(fd, set) __WS_FD_CLR((fd), (set), WS_fd_set) +# define WS_FD_SET(fd, set) __WS_FD_SET((fd), (set), WS_fd_set) +# define WS_FD_ZERO(set) (((WS_fd_set*)(set))->fd_count=0) +# define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set)) + +#endif + +typedef struct WS(fd_set) +{ + WS(u_int) fd_count; + SOCKET fd_array[WS(FD_SETSIZE)]; +} WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET; + typedef struct /*WS(pollfd)*/ { SOCKET fd; @@ -335,6 +538,42 @@ typedef struct /*WS(pollfd)*/ SHORT revents; } WSAPOLLFD;
+typedef struct WS(hostent) +{ + char *h_name; + char **h_aliases; + short h_addrtype; + short h_length; + char **h_addr_list; +#define h_addr h_addr_list[0] +} HOSTENT, *PHOSTENT, *LPHOSTENT; + +typedef struct WS(servent) +{ + char *s_name; + char **s_aliases; +#ifdef _WIN64 + char *s_proto; + short s_port; +#else + short s_port; + char *s_proto; +#endif +} SERVENT, *PSERVENT, *LPSERVENT; + +typedef struct WS(protoent) +{ + char *p_name; + char **p_aliases; + short p_proto; +} PROTOENT, *PPROTOENT, *LPPROTOENT; + +typedef struct WS(linger) +{ + WS(u_short) l_onoff; + WS(u_short) l_linger; +} LINGER, *PLINGER, *LPLINGER; + #define WSAPROTOCOL_LEN 255 typedef struct _WSAPROTOCOL_INFOA { @@ -441,6 +680,17 @@ DECL_WINELIB_TYPE_AW(LPWSASERVICECLASSINFO) #define WSAOVERLAPPED OVERLAPPED typedef struct _OVERLAPPED* LPWSAOVERLAPPED;
+#ifndef USE_WS_PREFIX +#define h_errno WSAGetLastError() +#else +#define WS_h_errno WSAGetLastError() +#endif + +#define WSAHOST_NOT_FOUND (WSABASEERR + 1001) +#define WSATRY_AGAIN (WSABASEERR + 1002) +#define WSANO_RECOVERY (WSABASEERR + 1003) +#define WSANO_DATA (WSABASEERR + 1004) + #define WSA_IO_PENDING (ERROR_IO_PENDING) #define WSA_IO_INCOMPLETE (ERROR_IO_INCOMPLETE) #define WSA_INVALID_HANDLE (ERROR_INVALID_HANDLE) @@ -628,6 +878,69 @@ typedef struct _WSACOMPLETION { } Parameters; } WSACOMPLETION, *PWSACOMPLETION, *LPWSACOMPLETION;
+#define WSADESCRIPTION_LEN 256 +#define WSASYS_STATUS_LEN 128 + +typedef struct WSAData +{ + WORD wVersion; + WORD wHighVersion; +#ifdef _WIN64 + WORD iMaxSockets; + WORD iMaxUdpDg; + char *lpVendorInfo; + char szDescription[WSADESCRIPTION_LEN+1]; + char szSystemStatus[WSASYS_STATUS_LEN+1]; +#else + char szDescription[WSADESCRIPTION_LEN+1]; + char szSystemStatus[WSASYS_STATUS_LEN+1]; + WORD iMaxSockets; + WORD iMaxUdpDg; + char *lpVendorInfo; +#endif +} WSADATA, *LPWSADATA; + +#ifndef USE_WS_PREFIX +#ifdef WORDS_BIGENDIAN + +static inline u_short __wine_ushort_noop(u_short s) +{ + return s; +} +static inline ULONG __wine_ulong_noop(ULONG l) +{ + return l; +} +#define htonl __wine_ulong_noop +#define htons __wine_ushort_noop +#define ntohl __wine_ulong_noop +#define ntohs __wine_ushort_noop + +#else /* WORDS_BIGENDIAN */ + +static inline u_short __wine_ushort_swap(u_short s) +{ + return (s >> 8) | (s << 8); +} +static inline ULONG __wine_ulong_swap(ULONG l) +{ + return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16)); +} +#define htonl __wine_ulong_swap +#define htons __wine_ushort_swap +#define ntohl __wine_ulong_swap +#define ntohs __wine_ushort_swap + +#endif /* WORDS_BIGENDIAN */ +#endif /* USE_WS_PREFIX */ + +#define WSAMAKEASYNCREPLY(size, error) MAKELONG(size, error) +#define WSAMAKESELECTREPLY(flags, error) MAKELONG(flags, error) +#define WSAGETASYNCBUFLEN(x) LOWORD(x) +#define WSAGETASYNCERROR(x) HIWORD(x) +#define WSAGETSELECTEVENT(x) LOWORD(x) +#define WSAGETSELECTERROR(x) HIWORD(x) + /* * Winsock Function Typedefs * @@ -695,11 +1008,50 @@ typedef SOCKET (WINAPI *LPFN_SOCKET)(int,int,int); * "Winsock2 Function Typedefs" section below. */ #if WS_API_PROTOTYPES +int WINAPI __WSAFDIsSet(SOCKET, WS(fd_set) *); + +SOCKET WINAPI WS(accept)(SOCKET, struct WS(sockaddr) *, int *); +int WINAPI WS(bind)(SOCKET, const struct WS(sockaddr) *, int); +int WINAPI WS(closesocket)(SOCKET); +int WINAPI WS(connect)(SOCKET, const struct WS(sockaddr) *, int); +struct WS(hostent) * WINAPI WS(gethostbyaddr)(const char *, int, int); +struct WS(hostent) * WINAPI WS(gethostbyname)(const char *); +int WINAPI WS(gethostname)(char *, int); +int WINAPI WS(getpeername)(SOCKET, struct WS(sockaddr) *, int *); +struct WS(protoent) * WINAPI WS(getprotobyname)(const char *); +struct WS(protoent) * WINAPI WS(getprotobynumber)(int); +int WINAPI WS(select)(int, WS(fd_set) *, WS(fd_set) *, WS(fd_set) *, const struct WS(timeval) *); +struct WS(servent) * WINAPI WS(getservbyname)(const char *, const char *); +struct WS(servent) * WINAPI WS(getservbyport)(int, const char *); +int WINAPI WS(getsockname)(SOCKET, struct WS(sockaddr) *, int *); +int WINAPI WS(getsockopt)(SOCKET, int, int, char *, int *); +ULONG WINAPI WS(inet_addr)(const char *); +char * WINAPI WS(inet_ntoa)(struct WS(in_addr)); +int WINAPI WS(ioctlsocket)(SOCKET, LONG, WS(u_long) *); +int WINAPI WS(listen)(SOCKET, int); +int WINAPI WS(recv)(SOCKET, char *, int, int); +int WINAPI WS(recvfrom)(SOCKET, char *, int, int, struct WS(sockaddr) *, int *); +int WINAPI WS(send)(SOCKET, const char *, int, int); +int WINAPI WS(sendto)(SOCKET, const char *, int, int, const struct WS(sockaddr) *, int); +int WINAPI WS(setsockopt)(SOCKET, int, int, const char *, int); +int WINAPI WS(shutdown)(SOCKET, int); +SOCKET WINAPI WS(socket)(int, int, int); + int WINAPI GetHostNameW(WCHAR *, int); SOCKET WINAPI WSAAccept(SOCKET,struct WS(sockaddr)*,LPINT,LPCONDITIONPROC,DWORD_PTR); INT WINAPI WSAAddressToStringA(LPSOCKADDR,DWORD,LPWSAPROTOCOL_INFOA,LPSTR,LPDWORD); INT WINAPI WSAAddressToStringW(LPSOCKADDR,DWORD,LPWSAPROTOCOL_INFOW,LPWSTR,LPDWORD); #define WSAAddressToString WINELIB_NAME_AW(WSAAddressToString) +HANDLE WINAPI WSAAsyncGetHostByAddr(HWND, WS(u_int), const char *, int, int, char *, int); +HANDLE WINAPI WSAAsyncGetHostByName(HWND, WS(u_int), const char *, char *, int); +HANDLE WINAPI WSAAsyncGetProtoByName(HWND, WS(u_int), const char *, char *, int); +HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND, WS(u_int), int, char *, int); +HANDLE WINAPI WSAAsyncGetServByName(HWND, WS(u_int), const char *, const char *, char *, int); +HANDLE WINAPI WSAAsyncGetServByPort(HWND, WS(u_int), int, const char *, char *, int); +int WINAPI WSAAsyncSelect(SOCKET, HWND, WS(u_int), LONG); +int WINAPI WSACancelAsyncRequest(HANDLE); +int WINAPI WSACancelBlockingCall(void); +int WINAPI WSACleanup(void); BOOL WINAPI WSACloseEvent(WSAEVENT); int WINAPI WSAConnect(SOCKET,const struct WS(sockaddr)*,int,LPWSABUF,LPWSABUF,LPQOS,LPQOS); WSAEVENT WINAPI WSACreateEvent(void); @@ -714,6 +1066,7 @@ int WINAPI WSAEnumProtocolsA(LPINT,LPWSAPROTOCOL_INFOA,LPDWORD); int WINAPI WSAEnumProtocolsW(LPINT,LPWSAPROTOCOL_INFOW,LPDWORD); #define WSAEnumProtocols WINELIB_NAME_AW(WSAEnumProtocols) int WINAPI WSAEventSelect(SOCKET,WSAEVENT,LONG); +int WINAPI WSAGetLastError(void); BOOL WINAPI WSAGetOverlappedResult(SOCKET,LPWSAOVERLAPPED,LPDWORD,BOOL,LPDWORD); BOOL WINAPI WSAGetQOSByName(SOCKET,LPWSABUF,LPQOS); INT WINAPI WSAGetServiceClassInfoA(LPGUID,LPGUID,LPDWORD,LPWSASERVICECLASSINFOA); @@ -728,6 +1081,7 @@ int WINAPI WSAInstallServiceClassA(LPWSASERVICECLASSINFOA); int WINAPI WSAInstallServiceClassW(LPWSASERVICECLASSINFOW); #define WSAInstallServiceClass WINELIB_NAME_AW(WSAInstallServiceClass) int WINAPI WSAIoctl(SOCKET,DWORD,LPVOID,DWORD,LPVOID,DWORD,LPDWORD,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE); +BOOL WINAPI WSAIsBlocking(void); SOCKET WINAPI WSAJoinLeaf(SOCKET,const struct WS(sockaddr)*,int,LPWSABUF,LPWSABUF,LPQOS,LPQOS,DWORD); INT WINAPI WSALookupServiceBeginA(LPWSAQUERYSETA,DWORD,LPHANDLE); INT WINAPI WSALookupServiceBeginW(LPWSAQUERYSETW,DWORD,LPHANDLE); @@ -749,16 +1103,20 @@ BOOL WINAPI WSAResetEvent(WSAEVENT); int WINAPI WSASend(SOCKET,LPWSABUF,DWORD,LPDWORD,DWORD,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE); int WINAPI WSASendDisconnect(SOCKET,LPWSABUF); int WINAPI WSASendTo(SOCKET,LPWSABUF,DWORD,LPDWORD,DWORD,const struct WS(sockaddr)*,int,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE); +FARPROC WINAPI WSASetBlockingHook(FARPROC); BOOL WINAPI WSASetEvent(WSAEVENT); +void WINAPI WSASetLastError(int); INT WINAPI WSASetServiceA(LPWSAQUERYSETA,WSAESETSERVICEOP,DWORD); INT WINAPI WSASetServiceW(LPWSAQUERYSETW,WSAESETSERVICEOP,DWORD); #define WSASetService WINELIB_NAME_AW(WSASetService) SOCKET WINAPI WSASocketA(int,int,int,LPWSAPROTOCOL_INFOA,GROUP,DWORD); SOCKET WINAPI WSASocketW(int,int,int,LPWSAPROTOCOL_INFOW,GROUP,DWORD); #define WSASocket WINELIB_NAME_AW(WSASocket) +int WINAPI WSAStartup(WORD,WSADATA*); INT WINAPI WSAStringToAddressA(LPSTR,INT,LPWSAPROTOCOL_INFOA,LPSOCKADDR,LPINT); INT WINAPI WSAStringToAddressW(LPWSTR,INT,LPWSAPROTOCOL_INFOW,LPSOCKADDR,LPINT); #define WSAStringToAddress WINELIB_NAME_AW(WSAStringToAddress) +int WINAPI WSAUnhookBlockingHook(void); DWORD WINAPI WSAWaitForMultipleEvents(DWORD,const WSAEVENT*,BOOL,DWORD,BOOL); #endif /* WS_API_PROTOTYPES */
diff --git a/include/ws2def.h b/include/ws2def.h index b92bf68bae8..9ddfa031633 100644 --- a/include/ws2def.h +++ b/include/ws2def.h @@ -29,6 +29,166 @@
typedef USHORT ADDRESS_FAMILY;
+typedef struct WS(sockaddr) +{ + unsigned short sa_family; + char sa_data[14]; +} SOCKADDR, *PSOCKADDR, *LPSOCKADDR; + +#ifndef USE_WS_PREFIX +#define AF_UNSPEC 0 +#define AF_UNIX 1 +#define AF_INET 2 +#define AF_IMPLINK 3 +#define AF_PUP 4 +#define AF_CHAOS 5 +#define AF_NS 6 +#define AF_IPX AF_NS +#define AF_ISO 7 +#define AF_OSI AF_ISO +#define AF_ECMA 8 +#define AF_DATAKIT 9 +#define AF_CCITT 10 +#define AF_SNA 11 +#define AF_DECnet 12 +#define AF_DLI 13 +#define AF_LAT 14 +#define AF_HYLINK 15 +#define AF_APPLETALK 16 +#define AF_NETBIOS 17 +#define AF_VOICEVIEW 18 +#define AF_FIREFOX 19 +#define AF_UNKNOWN1 20 +#define AF_BAN 21 +#define AF_ATM 22 +#define AF_INET6 23 +#define AF_CLUSTER 24 +#define AF_12844 25 +#define AF_IRDA 26 +#define AF_MAX 27 +#else /* USE_WS_PREFIX */ +#define WS_AF_UNSPEC 0 +#define WS_AF_UNIX 1 +#define WS_AF_INET 2 +#define WS_AF_IMPLINK 3 +#define WS_AF_PUP 4 +#define WS_AF_CHAOS 5 +#define WS_AF_NS 6 +#define WS_AF_IPX WS_AF_NS +#define WS_AF_ISO 7 +#define WS_AF_OSI WS_AF_ISO +#define WS_AF_ECMA 8 +#define WS_AF_DATAKIT 9 +#define WS_AF_CCITT 10 +#define WS_AF_SNA 11 +#define WS_AF_DECnet 12 +#define WS_AF_DLI 13 +#define WS_AF_LAT 14 +#define WS_AF_HYLINK 15 +#define WS_AF_APPLETALK 16 +#define WS_AF_NETBIOS 17 +#define WS_AF_VOICEVIEW 18 +#define WS_AF_FIREFOX 19 +#define WS_AF_UNKNOWN1 20 +#define WS_AF_BAN 21 +#define WS_AF_ATM 22 +#define WS_AF_INET6 23 +#define WS_AF_CLUSTER 24 +#define WS_AF_12844 25 +#define WS_AF_IRDA 26 +#define WS_AF_MAX 27 +#endif /* USE_WS_PREFIX */ + +#ifndef USE_WS_PREFIX +#define IPPROTO_IP 0 +#else +#define WS_IPPROTO_IP 0 +#endif + +typedef enum +{ + WS(IPPROTO_ICMP) = 1, + WS(IPPROTO_IGMP) = 2, + WS(IPPROTO_GGP) = 3, + WS(IPPROTO_IPV4) = 4, + WS(IPPROTO_TCP) = 6, + WS(IPPROTO_UDP) = 17, + WS(IPPROTO_IDP) = 22, + WS(IPPROTO_IPV6) = 41, + WS(IPPROTO_ICMPV6) = 58, + WS(IPPROTO_ND) = 77, + WS(IPPROTO_RAW) = 255, + WS(IPPROTO_MAX) = 256, +} IPPROTO; + +#ifndef USE_WS_PREFIX +#define INADDR_ANY ((ULONG)0x00000000) +#define INADDR_LOOPBACK 0x7f000001 +#define INADDR_BROADCAST ((ULONG)0xffffffff) +#define INADDR_NONE 0xffffffff +#else +#define WS_INADDR_ANY ((ULONG)0x00000000) +#define WS_INADDR_LOOPBACK 0x7f000001 +#define WS_INADDR_BROADCAST ((ULONG)0xffffffff) +#define WS_INADDR_NONE 0xffffffff +#endif + +#ifndef USE_WS_PREFIX +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_MAX 128 +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_HOST 0x00ffffff +#define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0) +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_MAX 65536 +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_HOST 0x0000ffff +#define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000) +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_HOST 0x000000ff +#define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000) +#else +#define WS_IN_CLASSA_NSHIFT 24 +#define WS_IN_CLASSA_MAX 128 +#define WS_IN_CLASSA_NET 0xff000000 +#define WS_IN_CLASSA_HOST 0x00ffffff +#define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0) +#define WS_IN_CLASSB_NSHIFT 16 +#define WS_IN_CLASSB_MAX 65536 +#define WS_IN_CLASSB_NET 0xffff0000 +#define WS_IN_CLASSB_HOST 0x0000ffff +#define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000) +#define WS_IN_CLASSC_NSHIFT 8 +#define WS_IN_CLASSC_NET 0xffffff00 +#define WS_IN_CLASSC_HOST 0x000000ff +#define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000) +#endif /* USE_WS_PREFIX */ + +#ifndef USE_WS_PREFIX +#define SO_BSP_STATE 0x1009 +#define SO_RANDOMIZE_PORT 0x3005 +#define SO_PORT_SCALABILITY 0x3006 +#define SO_REUSE_UNICASTPORT 0x3007 +#define SO_REUSE_MULTICASTPORT 0x3008 +#define TCP_NODELAY 0x0001 +#else +#define WS_SO_BSP_STATE 0x1009 +#define WS_SO_RANDOMIZE_PORT 0x3005 +#define WS_SO_PORT_SCALABILITY 0x3006 +#define WS_SO_REUSE_UNICASTPORT 0x3007 +#define WS_SO_REUSE_MULTICASTPORT 0x3008 +#define WS_TCP_NODELAY 0x0001 +#endif + +typedef struct WS(sockaddr_in) +{ + short sin_family; + unsigned short sin_port; + struct WS(in_addr) sin_addr; + char sin_zero[8]; +} SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN; + #ifndef __CSADDR_DEFINED__ #define __CSADDR_DEFINED__
diff --git a/server/sock.c b/server/sock.c index 00d5b0b9044..39f02036da8 100644 --- a/server/sock.c +++ b/server/sock.c @@ -96,32 +96,6 @@ #include "request.h" #include "user.h"
-/* From winsock.h */ -#define FD_MAX_EVENTS 10 -#define FD_READ_BIT 0 -#define FD_WRITE_BIT 1 -#define FD_OOB_BIT 2 -#define FD_ACCEPT_BIT 3 -#define FD_CONNECT_BIT 4 -#define FD_CLOSE_BIT 5 - -/* - * Define flags to be used with the WSAAsyncSelect() call. - */ -#define FD_READ 0x00000001 -#define FD_WRITE 0x00000002 -#define FD_OOB 0x00000004 -#define FD_ACCEPT 0x00000008 -#define FD_CONNECT 0x00000010 -#define FD_CLOSE 0x00000020 - -/* internal per-socket flags */ -#define FD_WINE_LISTENING 0x10000000 -#define FD_WINE_NONBLOCKING 0x20000000 -#define FD_WINE_CONNECTED 0x40000000 -#define FD_WINE_RAW 0x80000000 -#define FD_WINE_INTERNAL 0xFFFF0000 - struct accept_req { struct list entry; @@ -988,7 +962,7 @@ static int get_unix_protocol( int protocol ) case WS_IPPROTO_ICMP: return IPPROTO_ICMP; case WS_IPPROTO_IGMP: return IPPROTO_IGMP; case WS_IPPROTO_IP: return IPPROTO_IP; - case WS_IPPROTO_IPIP: return IPPROTO_IPIP; + case WS_IPPROTO_IPV4: return IPPROTO_IPIP; case WS_IPPROTO_IPV6: return IPPROTO_IPV6; case WS_IPPROTO_RAW: return IPPROTO_RAW; case WS_IPPROTO_TCP: return IPPROTO_TCP;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/shell32/tests/shlfileop.c | 1 - dlls/shell32/tests/string.c | 1 - include/windows.h | 3 --- include/winsock2.h | 1 + tools/winapi/winapi_test | 2 -- 5 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c index 70d90a5c7ac..726585e39a2 100644 --- a/dlls/shell32/tests/shlfileop.c +++ b/dlls/shell32/tests/shlfileop.c @@ -22,7 +22,6 @@ #include <stdio.h>
#define COBJMACROS -#define WINE_NOWINSOCK #include <windows.h> #include "shellapi.h" #include "shlobj.h" diff --git a/dlls/shell32/tests/string.c b/dlls/shell32/tests/string.c index acd94448119..d1d621d9577 100644 --- a/dlls/shell32/tests/string.c +++ b/dlls/shell32/tests/string.c @@ -21,7 +21,6 @@ #include <stdarg.h> #include <stdio.h>
-#define WINE_NOWINSOCK #include "windef.h" #include "winbase.h" #include "wtypes.h" diff --git a/include/windows.h b/include/windows.h index ec5c6a20028..47f13e395d2 100644 --- a/include/windows.h +++ b/include/windows.h @@ -59,10 +59,7 @@ #include <rpc.h> #include <shellapi.h> #include <winperf.h> - -#ifndef WINE_NOWINSOCK #include <winsock.h> -#endif /* WINE_NOWINSOCK */
#ifndef NOCRYPT #include <wincrypt.h> diff --git a/include/winsock2.h b/include/winsock2.h index 30d29ce0b57..d6b5020a738 100644 --- a/include/winsock2.h +++ b/include/winsock2.h @@ -21,6 +21,7 @@
#ifndef _WINSOCK2API_ #define _WINSOCK2API_ +#define _WINSOCKAPI_
#include <windows.h>
diff --git a/tools/winapi/winapi_test b/tools/winapi/winapi_test index 716bb30ac08..b9628e85154 100755 --- a/tools/winapi/winapi_test +++ b/tools/winapi/winapi_test @@ -517,8 +517,6 @@ sub output_header($$$) { print OUT " */\n"; print OUT "\n";
- print OUT "#define WINE_NOWINSOCK\n"; - print OUT "\n"; foreach my $test (@tests) { my @includes = $tests->get_section($test_dir, $test, "include"); foreach my $include (@includes) {
Zebediah Figura z.figura12@gmail.com writes:
All modules either build with msvcrt headers or define USE_WS_PREFIX now.
I think we want to preserve the ability to use that header in Winelib.
On 4/26/21 5:24 AM, Alexandre Julliard wrote:
Zebediah Figura z.figura12@gmail.com writes:
All modules either build with msvcrt headers or define USE_WS_PREFIX now.
I think we want to preserve the ability to use that header in Winelib.
Sorry, can you please clarify which header you mean? Do you mean that winelib programs should be able to use winsock.h without building with msvcrt or defining USE_WS_PREFIX?
"Zebediah Figura (she/her)" zfigura@codeweavers.com writes:
On 4/26/21 5:24 AM, Alexandre Julliard wrote:
Zebediah Figura z.figura12@gmail.com writes:
All modules either build with msvcrt headers or define USE_WS_PREFIX now.
I think we want to preserve the ability to use that header in Winelib.
Sorry, can you please clarify which header you mean? Do you mean that winelib programs should be able to use winsock.h without building with msvcrt or defining USE_WS_PREFIX?
Yes, exactly.