* arch_def.h, net_sys.h, wsaerror.h: New headers, adapted from uhexen2.

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@214 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2010-06-21 10:55:21 +00:00
parent 7239a9a679
commit 291a531b44
3 changed files with 370 additions and 0 deletions

117
quakespasm/Quake/arch_def.h Normal file
View File

@ -0,0 +1,117 @@
/*
arch_def.h
platform specific definitions
Copyright (C) 2007 O.Sezer <sezero@users.sourceforge.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#ifndef __ARCH_DEFS__
#define __ARCH_DEFS__
#if defined(__APPLE__) && defined(__MACH__)
# if !defined(__MACOSX__)
# define __MACOSX__ 1
# endif
#elif defined(macintosh) /* MacOS Classic */
# if !defined(__MACOS__)
# define __MACOS__ 1
# endif
#elif (defined(__sun) || defined(sun)) && \
(defined(__svr4__) || defined(__SVR4))
# if !defined(__SOLARIS__)
# define __SOLARIS__ 1
# endif
#elif defined(__sun) || defined(sun)
# if !defined(__SUNOS__)
# define __SUNOS__ 1
# endif
#elif defined(__sgi) || defined(sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
# if !defined(__IRIX__)
# define __IRIX__ 1
# endif
#elif defined(__QNXNTO__)
# if !defined(__QNX__)
# define __QNX__ 1
# endif
#elif defined(__amigados__) || defined(__amigaos4__) || \
defined(__AMIGA) || defined(__amigaos__)
# if !defined(__AMIGA__)
# define __AMIGA__ 1
# endif
#endif /* end of custom definitions */
#if defined(__DJGPP__) || defined(MSDOS) || defined(__MSDOS__) || defined(__DOS__)
# if !defined(PLATFORM_DOS)
# define PLATFORM_DOS 1
# endif
#elif defined(_WIN32) || defined(_WIN64)
# if !defined(PLATFORM_WINDOWS)
# define PLATFORM_WINDOWS 1
# endif
#elif defined(__MACOS__) || defined(__MACOSX__)
# if !defined(PLATFORM_MAC)
# define PLATFORM_MAC 1
# endif
#elif defined(__MORPHOS__) || defined(__AMIGA__)
# if !defined(PLATFORM_AMIGA)
# define PLATFORM_AMIGA 1
# endif
#else /* here goes the unix platforms */
#if defined(__unix) || defined(__unix__) || defined(unix) || \
defined(__linux__) || defined(__linux) || \
defined(__FreeBSD__) || defined(__DragonFly__) || \
defined(__OpenBSD__) || defined(__NetBSD__) || \
defined(__hpux) || defined(__hpux__) || defined(_hpux) || \
defined(__sun) || defined(sun) || defined(__IRIX__) || \
defined(__QNX__)
# if !defined(PLATFORM_UNIX)
# define PLATFORM_UNIX 1
# endif
#endif
#endif /* end of PLATFORM_ definitions */
/* Hack section: Platforms that are mostly fine when
* classified under PLATFORM_UNIX :
*/
#if defined(__MACOSX__)
# if !defined(PLATFORM_UNIX)
# define PLATFORM_UNIX 2
# endif
#endif /* end of PLATFORM_UNIX hacks */
#endif /* __ARCH_DEFS__ */

162
quakespasm/Quake/net_sys.h Normal file
View File

@ -0,0 +1,162 @@
/*
net_sys.h
common network system header
Copyright (C) 2007-2010 O.Sezer <sezero@users.sourceforge.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#if defined(_USE_SDLNET)
/* can not use the IP banning mechanism in net_dgrm.c with
limited SDL_net functionality. */
#undef BAN_TEST
#define sys_socket_t int
#define INVALID_SOCKET (-1)
#define SOCKET_ERROR (-1)
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif
#ifndef AF_INET
#define AF_INET 2 /* internet */
#endif
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */
#endif
#ifndef __NET_SYS_H__
#define __NET_SYS_H__ /* the rest below are not needed. */
#endif
#endif /* _USE_SDLNET */
#ifndef __NET_SYS_H__
#define __NET_SYS_H__
#include <sys/types.h>
#include <errno.h>
#include <stddef.h>
#include <limits.h>
/* unix includes and compatibility macros */
#if defined(PLATFORM_UNIX) || defined(PLATFORM_AMIGA)
#include <sys/param.h>
#include <sys/ioctl.h>
#include <unistd.h>
#if defined(__sun) || defined(sun)
#include <sys/filio.h>
#endif /* __sunos__ */
#if defined(PLATFORM_AMIGA)
#include <proto/socket.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
typedef int sys_socket_t;
#define INVALID_SOCKET (-1)
#define SOCKET_ERROR (-1)
#if defined(PLATFORM_AMIGA)
typedef int socklen_t;
#define SOCKETERRNO Errno()
#define ioctlsocket IoctlSocket
#define closesocket CloseSocket
#else
#define SOCKETERRNO errno
#define ioctlsocket ioctl
#define closesocket close
#endif
#define socketerror(x) strerror((x))
#endif /* end of unix stuff */
/* windows includes and compatibility macros */
#if defined(PLATFORM_WINDOWS)
/* NOTE: winsock[2].h already includes windows.h */
#if !defined(_USE_WINSOCK2)
#include <winsock.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
/* there is no in_addr_t on windows: define it as
the type of the S_addr of in_addr structure */
typedef u_long in_addr_t; /* uint32_t */
/* on windows, socklen_t is to be a winsock2 thing */
#if !defined(IP_MSFILTER_SIZE)
typedef int socklen_t;
#endif /* socklen_t type */
typedef SOCKET sys_socket_t;
#define SOCKETERRNO WSAGetLastError()
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ECONNREFUSED WSAECONNREFUSED
/* must #include "wsaerror.h" for this : */
#define socketerror(x) __WSAE_StrError((x))
#endif /* end of windows stuff */
/* dos includes and compatibility macros */
#if defined(PLATFORM_DOS)
/* our local headers : */
#include "dos/dos_inet.h"
#include "dos/dos_sock.h"
#endif /* end of dos stuff. */
/* macros which may still be missing */
#if !defined(INADDR_NONE)
#define INADDR_NONE ((in_addr_t) 0xffffffff)
#endif /* INADDR_NONE */
#if !defined(INADDR_LOOPBACK)
#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* 127.0.0.1 */
#endif /* INADDR_LOOPBACK */
#if !defined(MAXHOSTNAMELEN)
/* SUSv2 guarantees that `Host names are limited to 255 bytes'.
POSIX 1003.1-2001 guarantees that `Host names (not including
the terminating NUL) are limited to HOST_NAME_MAX bytes'. */
#define MAXHOSTNAMELEN 256
#endif /* MAXHOSTNAMELEN */
#endif /* __NET_SYS_H__ */

View File

@ -0,0 +1,91 @@
/* strings for winsock error codes.
* from online references, such as
* http://aluigi.org/mytoolz/winerr.h
* http://www.winsock-error.com or
* http://www.sockets.com/err_lst1.htm
*/
#ifndef __wsaerr_static
#define __wsaerr_static static
#endif /* static */
__wsaerr_static const char *__WSAE_StrError (int err)
{
switch (err)
{
case 0: return "No error";
case WSAEINTR: return "Interrupted system call"; /* 10004 */
case WSAEBADF: return "Bad file number"; /* 10009 */
case WSAEACCES: return "Permission denied"; /* 10013 */
case WSAEFAULT: return "Bad address"; /* 10014 */
case WSAEINVAL: return "Invalid argument (not bind)"; /* 10022 */
case WSAEMFILE: return "Too many open files"; /* 10024 */
case WSAEWOULDBLOCK: return "Operation would block"; /* 10035 */
case WSAEINPROGRESS: return "Operation now in progress"; /* 10036 */
case WSAEALREADY: return "Operation already in progress"; /* 10037 */
case WSAENOTSOCK: return "Socket operation on non-socket"; /* 10038 */
case WSAEDESTADDRREQ: return "Destination address required"; /* 10039 */
case WSAEMSGSIZE: return "Message too long"; /* 10040 */
case WSAEPROTOTYPE: return "Protocol wrong type for socket"; /* 10041 */
case WSAENOPROTOOPT: return "Bad protocol option"; /* 10042 */
case WSAEPROTONOSUPPORT: return "Protocol not supported"; /* 10043 */
case WSAESOCKTNOSUPPORT: return "Socket type not supported"; /* 10044 */
case WSAEOPNOTSUPP: return "Operation not supported on socket"; /* 10045 */
case WSAEPFNOSUPPORT: return "Protocol family not supported"; /* 10046 */
case WSAEAFNOSUPPORT: return "Address family not supported by protocol family"; /* 10047 */
case WSAEADDRINUSE: return "Address already in use"; /* 10048 */
case WSAEADDRNOTAVAIL: return "Can't assign requested address"; /* 10049 */
case WSAENETDOWN: return "Network is down"; /* 10050 */
case WSAENETUNREACH: return "Network is unreachable"; /* 10051 */
case WSAENETRESET: return "Net dropped connection or reset"; /* 10052 */
case WSAECONNABORTED: return "Software caused connection abort"; /* 10053 */
case WSAECONNRESET: return "Connection reset by peer"; /* 10054 */
case WSAENOBUFS: return "No buffer space available"; /* 10055 */
case WSAEISCONN: return "Socket is already connected"; /* 10056 */
case WSAENOTCONN: return "Socket is not connected"; /* 10057 */
case WSAESHUTDOWN: return "Can't send after socket shutdown"; /* 10058 */
case WSAETOOMANYREFS: return "Too many references, can't splice"; /* 10059 */
case WSAETIMEDOUT: return "Connection timed out"; /* 10060 */
case WSAECONNREFUSED: return "Connection refused"; /* 10061 */
case WSAELOOP: return "Too many levels of symbolic links"; /* 10062 */
case WSAENAMETOOLONG: return "File name too long"; /* 10063 */
case WSAEHOSTDOWN: return "Host is down"; /* 10064 */
case WSAEHOSTUNREACH: return "No Route to Host"; /* 10065 */
case WSAENOTEMPTY: return "Directory not empty"; /* 10066 */
case WSAEPROCLIM: return "Too many processes"; /* 10067 */
case WSAEUSERS: return "Too many users"; /* 10068 */
case WSAEDQUOT: return "Disc Quota Exceeded"; /* 10069 */
case WSAESTALE: return "Stale NFS file handle"; /* 10070 */
case WSAEREMOTE: return "Too many levels of remote in path"; /* 10071 */
case WSAEDISCON: return "Graceful shutdown in progress"; /* 10101 */
case WSASYSNOTREADY: return "Network SubSystem is unavailable"; /* 10091 */
case WSAVERNOTSUPPORTED: return "WINSOCK DLL Version out of range"; /* 10092 */
case WSANOTINITIALISED: return "Successful WSASTARTUP not yet performed"; /* 10093 */
case WSAHOST_NOT_FOUND: return "Authoritative answer: Host not found"; /* 11001 */
case WSATRY_AGAIN: return "Non-Authoritative: Host not found or SERVERFAIL"; /* 11002 */
case WSANO_RECOVERY: return "Non-Recoverable errors, FORMERR, REFUSED, NOTIMP"; /* 11003 */
case WSANO_DATA: return "Valid name, no data record of requested type"; /* 11004 */
case WSAENOMORE: return "10102: No more results"; /* 10102 */
case WSAECANCELLED: return "10103: Call has been canceled"; /* 10103 */
case WSAEINVALIDPROCTABLE: return "Procedure call table is invalid"; /* 10104 */
case WSAEINVALIDPROVIDER: return "Service provider is invalid"; /* 10105 */
case WSAEPROVIDERFAILEDINIT: return "Service provider failed to initialize"; /* 10106 */
case WSASYSCALLFAILURE: return "System call failure"; /* 10107 */
case WSASERVICE_NOT_FOUND: return "Service not found"; /* 10108 */
case WSATYPE_NOT_FOUND: return "Class type not found"; /* 10109 */
case WSA_E_NO_MORE: return "10110: No more results"; /* 10110 */
case WSA_E_CANCELLED: return "10111: Call was canceled"; /* 10111 */
case WSAEREFUSED: return "Database query was refused"; /* 10112 */
default:
{
static char _err_unknown[64];
sprintf(_err_unknown, "Unknown WSAE error (%d)", err);
return _err_unknown;
}
}
}