Updated SDL_net
This commit is contained in:
@@ -1,53 +1,54 @@
|
||||
/*
|
||||
SDL_net: An example cross-platform network library for use with SDL
|
||||
Copyright (C) 1997-2004 Sam Lantinga
|
||||
SDL_net: An example cross-platform network library for use with SDL
|
||||
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* $Id: SDLnetsys.h 1720 2005-11-23 07:57:10Z icculus $ */
|
||||
/* $Id$ */
|
||||
|
||||
/* Include normal system headers */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef macintosh
|
||||
#ifndef USE_GUSI_SOCKETS
|
||||
#define MACOS_OPENTRANSPORT
|
||||
//#error Open Transport driver is broken
|
||||
#ifndef _WIN32_WCE
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#endif /* macintosh */
|
||||
|
||||
/* Include system network headers */
|
||||
#ifdef MACOS_OPENTRANSPORT
|
||||
#include <OpenTransport.h>
|
||||
#include <OpenTptInternet.h>
|
||||
#else
|
||||
#if defined(__WIN32__) || defined(WIN32)
|
||||
#define __USE_W32_SOCKETS
|
||||
#include <windows.h>
|
||||
#ifdef _WIN64
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <winsock.h>
|
||||
/* NOTE: windows socklen_t is signed
|
||||
* and is defined only for winsock2. */
|
||||
typedef int socklen_t;
|
||||
#endif /* W64 */
|
||||
#include <iphlpapi.h>
|
||||
#else /* UNIX */
|
||||
#ifdef __OS2__
|
||||
#include <types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@@ -58,18 +59,17 @@
|
||||
#ifdef linux /* FIXME: what other platforms have this? */
|
||||
#include <netinet/tcp.h>
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <netdb.h>
|
||||
#endif /* WIN32 */
|
||||
#endif /* Open Transport */
|
||||
|
||||
/* FIXME: What platforms need this? */
|
||||
#if 0
|
||||
typedef Uint32 socklen_t;
|
||||
#endif
|
||||
|
||||
/* System-dependent definitions */
|
||||
#ifdef MACOS_OPENTRANSPORT
|
||||
//#define closesocket OTCloseProvider
|
||||
#define closesocket OTSndOrderlyDisconnect
|
||||
#define SOCKET EndpointRef
|
||||
#define INVALID_SOCKET kOTInvalidEndpointRef
|
||||
#else
|
||||
#ifndef __USE_W32_SOCKETS
|
||||
#ifdef __OS2__
|
||||
#define closesocket soclose
|
||||
@@ -80,5 +80,15 @@
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
#endif /* __USE_W32_SOCKETS */
|
||||
#endif /* Open Transport */
|
||||
|
||||
#ifdef __USE_W32_SOCKETS
|
||||
#define SDLNet_GetLastError WSAGetLastError
|
||||
#define SDLNet_SetLastError WSASetLastError
|
||||
#ifndef EINTR
|
||||
#define EINTR WSAEINTR
|
||||
#endif
|
||||
#else
|
||||
int SDLNet_GetLastError(void);
|
||||
void SDLNet_SetLastError(int err);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user