/******
nonport.h
GameSpy Developer SDK 
  
Copyright 1999 GameSpy Industries, Inc

Suite E-204
2900 Bristol Street
Costa Mesa, CA 92626
(714)549-7689
Fax(714)549-0757

******/
#if defined(applec) || defined(THINK_C) || defined(__MWERKS__)
	#define _MACOS
#endif

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
	#include <windows.h>
	#include <winsock.h>
#else
#ifdef _MACOS
	#include <events.h>
	#include "mwinsock.h"
#else
	#include <unistd.h>
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <stdio.h>
	#include <stdlib.h>
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <sys/ioctl.h>
	#include <netinet/in.h>
	#include <netdb.h>
	#include <arpa/inet.h>
	#include <ctype.h>
	#include <errno.h>
	#include <sys/time.h>
#endif
#endif


#ifdef __cplusplus
extern "C" {
#endif
	
unsigned long current_time();
void msleep(unsigned long msec);

void SocketStartUp();
void SocketShutDown();

#ifndef SOCKET_ERROR 
	#define SOCKET_ERROR (-1)
#endif

#ifndef INVALID_SOCKET 
	#define INVALID_SOCKET (-1)
#endif

#if defined(_WIN32) && !defined(UNDER_CE)
	#define strcasecmp _stricmp
	#define strncasecmp _strnicmp
#else
	char *_strdup(const char *src);
	char *_strlwr(char *string);
	char *_strupr(char *string);
#endif


#if defined(_MACOS) || defined(UNDER_CE)
	int strcasecmp(const char *string1, const char *string2);
	int strncasecmp(const char *string1, const char *string2, size_t count);
#endif

#if !defined(_MACOS) && !defined(_WIN32)
	#define WSAGetLastError() errno

	#define SOCKET int	
	#define closesocket close
	#define ioctlsocket ioctl
	#define WSAEWOULDBLOCK EWOULDBLOCK             
	#define WSAEINPROGRESS EINPROGRESS             
	#define WSAEALREADY EALREADY                
	#define WSAENOTSOCK ENOTSOCK                
	#define WSAEDESTADDRREQ EDESTADDRREQ            
	#define WSAEMSGSIZE EMSGSIZE                
	#define WSAEPROTOTYPE EPROTOTYPE              
	#define WSAENOPROTOOPT ENOPROTOOPT             
	#define WSAEPROTONOSUPPORT EPROTONOSUPPORT         
	#define WSAESOCKTNOSUPPORT ESOCKTNOSUPPORT         
	#define WSAEOPNOTSUPP EOPNOTSUPP              
	#define WSAEPFNOSUPPORT EPFNOSUPPORT            
	#define WSAEAFNOSUPPORT EAFNOSUPPORT            
	#define WSAEADDRINUSE EADDRINUSE              
	#define WSAEADDRNOTAVAIL EADDRNOTAVAIL           
	#define WSAENETDOWN ENETDOWN                
	#define WSAENETUNREACH ENETUNREACH             
	#define WSAENETRESET ENETRESET               
	#define WSAECONNABORTED ECONNABORTED            
	#define WSAECONNRESET ECONNRESET              
	#define WSAENOBUFS ENOBUFS                 
	#define WSAEISCONN EISCONN                 
	#define WSAENOTCONN ENOTCONN                
	#define WSAESHUTDOWN ESHUTDOWN               
	#define WSAETOOMANYREFS ETOOMANYREFS            
	#define WSAETIMEDOUT ETIMEDOUT               
	#define WSAECONNREFUSED ECONNREFUSED            
	#define WSAELOOP ELOOP                   
	#define WSAENAMETOOLONG ENAMETOOLONG            
	#define WSAEHOSTDOWN EHOSTDOWN               
	#define WSAEHOSTUNREACH EHOSTUNREACH            
	#define WSAENOTEMPTY ENOTEMPTY               
	#define WSAEPROCLIM EPROCLIM                
	#define WSAEUSERS EUSERS                  
	#define WSAEDQUOT EDQUOT                  
	#define WSAESTALE ESTALE                  
	#define WSAEREMOTE EREMOTE                 


	typedef struct sockaddr SOCKADDR;
	typedef struct sockaddr_in SOCKADDR_IN;
	typedef struct in_addr IN_ADDR;
	typedef struct hostent HOSTENT;
	typedef struct timeval TIMEVAL;
#endif
	
#ifndef max
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#endif

#ifdef _WIN32
	#define PATHCHAR '\\'
#else
#ifdef MACOS
	#define PATHCHAR ':'
#else
	#define PATHCHAR '/'

#endif
#endif



#ifdef UNDER_CE
//CE does not have the stdlib time() call
	time_t time(time_t *timer);
#else
	#include <time.h>
#endif


#ifdef __cplusplus
}
#endif
