From 6de20d7f8a60ca52aa7c0ac5e0651e8dd6b03765 Mon Sep 17 00:00:00 2001 From: tma Date: Sat, 9 Aug 2008 19:12:30 +0000 Subject: * Use IPv6 header qcommon/wspiapi.h if it has been added by the end user * Update README to explain the Windows XP requirement git-svn-id: svn://svn.icculus.org/quake3/trunk@1444 edf5b092-35ff-0310-97b2-ce42778d08ea --- Makefile | 12 +++---- README | 8 +++++ code/qcommon/net_ip.c | 93 +++++++++++++++++++++++++++------------------------ 3 files changed, 62 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index 9a141a0..8dd2362 100644 --- a/Makefile +++ b/Makefile @@ -423,14 +423,10 @@ ifeq ($(PLATFORM),mingw32) BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ -DUSE_ICON - # Require Windows XP or later - # - # IPv6 support requires a header wspiapi.h to work on earlier versions of - # windows. There is no MinGW equivalent of this header so we're forced to - # require XP. In theory this restriction can be removed if this header is - # obtained separately from the platform SDK. The MSVC build does not have - # this limitation. - BASE_CFLAGS += -DWINVER=0x501 + # In the absence of wspiapi.h, require Windows XP or later + ifeq ($(shell test -e $(CMDIR)/wspiapi.h; echo $$?),1) + BASE_CFLAGS += -DWINVER=0x501 + endif ifeq ($(USE_OPENAL),1) BASE_CFLAGS += -DUSE_OPENAL diff --git a/README b/README index 6977470..d9bf915 100644 --- a/README +++ b/README @@ -433,6 +433,14 @@ PNG support Restart GtkRadiant and PNG textures are now available. +Building with MinGW for pre Windows XP + IPv6 support requires a header named "wspiapi.h" to abstract away from + differences in earlier versions of Windows' IPv6 stack. There is no MinGW + equivalent of this header and the Microsoft version is obviously not + redistributable, so in its absence we're forced to require Windows XP. + However if this header is acquired separately and placed in the qcommon/ + directory, this restriction is lifted. + ------------------------------------------------------------- Contributing ----- diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c index dd59320..e93ee23 100644 --- a/code/qcommon/net_ip.c +++ b/code/qcommon/net_ip.c @@ -24,61 +24,68 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/qcommon.h" #ifdef _WIN32 -#include -#include -#if WINVER < 0x501 -#include -#else -#include -#endif +# include +# include +# if WINVER < 0x501 +# ifdef __MINGW32__ + // wspiapi.h isn't available on MinGW, so if it's + // present it's because the end user has added it + // and we should look for it in our tree +# include "wspiapi.h" +# else +# include +# endif +# else +# include +# endif typedef int socklen_t; -#ifdef ADDRESS_FAMILY -#define sa_family_t ADDRESS_FAMILY -#else +# ifdef ADDRESS_FAMILY +# define sa_family_t ADDRESS_FAMILY +# else typedef unsigned short sa_family_t; -#endif +# endif -#define EAGAIN WSAEWOULDBLOCK -#define EADDRNOTAVAIL WSAEADDRNOTAVAIL -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#define ECONNRESET WSAECONNRESET -#define socketError WSAGetLastError( ) +# define EAGAIN WSAEWOULDBLOCK +# define EADDRNOTAVAIL WSAEADDRNOTAVAIL +# define EAFNOSUPPORT WSAEAFNOSUPPORT +# define ECONNRESET WSAECONNRESET +# define socketError WSAGetLastError( ) static WSADATA winsockdata; static qboolean winsockInitialized = qfalse; #else -#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020 - // needed for socklen_t on OSX 10.2 -# define _BSD_SOCKLEN_T_ -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if !defined(__sun) && !defined(__sgi) -#include -#endif - -#ifdef __sun -#include -#endif +# if MAC_OS_X_VERSION_MIN_REQUIRED == 1020 + // needed for socklen_t on OSX 10.2 +# define _BSD_SOCKLEN_T_ +# endif + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# if !defined(__sun) && !defined(__sgi) +# include +# endif + +# ifdef __sun +# include +# endif typedef int SOCKET; -#define INVALID_SOCKET -1 -#define SOCKET_ERROR -1 -#define closesocket close -#define ioctlsocket ioctl -#define socketError errno +# define INVALID_SOCKET -1 +# define SOCKET_ERROR -1 +# define closesocket close +# define ioctlsocket ioctl +# define socketError errno #endif -- cgit v1.2.3