3#ifndef __GSPLATFORM_H__
4#define __GSPLATFORM_H__
26#if defined (__linux__) || defined(_LINUX) || defined(_MACOSX) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
34 #if !defined(SN_SYSTEMS) && !defined(EENET) && !defined(INSOCK)
35 #error "PlayStation2 network stack was not defined!"
39#if defined(_XBOX) || defined (_X360)
66 #define WIN32_LEAN_AND_MEAN
71 #if defined(GSI_WINSOCK2)
78 #define itoa(v, s, r) _itoa(v, s, r)
87 #include <sys/socket.h>
88 #include <sys/errno.h>
89 #include <netinet/in.h>
90 #include <arpa/inet.h>
92 #include <sys/select.h>
106 #include <ilsocksf.h>
120 #include "snskdefs.h"
122 #include "snsocket.h"
123 #include "sneeutil.h"
124 #include "sntcutil.h"
128 #include "libinsck.h"
130 #include "sys/errno.h"
137 #include <sys/types.h>
138 #include <sys/socket.h>
140 #include <sys/types.h>
141 #include <sys/socket.h>
142 #include <sys/ioctl.h>
143 #include <netinet/in.h>
156 #include <arpa/inet.h>
158 #include <sys/time.h>
161 #include <netinet/tcp.h>
164 #define SB_NO_ICMP_SUPPORT
169 #define NINET_NWBASE_MD5_H_
170 #include <nitroWiFi.h>
175 #define SB_NO_ICMP_SUPPORT
181 #include <pspnet_error.h>
182 #include <pspnet_inet.h>
183 #include <pspnet/sys/select.h>
184 #include <pspnet_resolver.h>
185 #include <pspnet_apctl.h>
186 #include <pspnet_ap_dialog_dummy.h>
191 #include <pspnet/sys/socket.h>
192 #include <pspnet/netinet/in.h>
193 #include <utility\utility_common.h>
194 #include <utility\utility_netconf.h>
195 #include <utility\utility_module.h>
198#include <netex/errno.h>
199 #include <sys/process.h>
200 #include <sys/time.h>
201 #include <sys/types.h>
202 #include <sys/select.h>
203 #include <sys/socket.h>
204 #include <sys/sys_time.h>
205 #include <sys/timer.h>
208 #include <netinet/in.h>
209 #include <arpa/inet.h>
210 #include <netex/net.h>
211 #include <netex/ifctl.h>
217#elif defined(_REVOLUTION)
218 #include <revolution.h>
219 #include <revolution/soex.h>
220 #include <revolution/ncd.h>
224 #define SB_NO_ICMP_SUPPORT
228 #error "The GameSpy SDKs do not support this operating system"
236 #define GS_STATIC_CALLBACK __cdecl
238 #define GS_STATIC_CALLBACK
243#if defined(_PS3) || defined(_REVOLUTION) || defined(_X360)
244 #define GSI_BIG_ENDIAN
246#ifndef GSI_BIG_ENDIAN
247 #define GSI_LITTLE_ENDIAN
260#if defined(GS_NO_FILE) || defined(_PS2) || defined(_PS3) || defined(_NITRO) || defined(_PSP) || defined(_XBOX)
264#if defined(_PSP) || defined(_NITRO)
265 #define GS_WIRELESS_DEVICE
268#if !defined(GSI_DOMAIN_NAME)
269 #define GSI_DOMAIN_NAME "gamespy.com"
279typedef unsigned char gsi_u8;
280typedef short gsi_i16;
281typedef unsigned short gsi_u16;
283typedef unsigned int gsi_u32;
284typedef unsigned int gsi_time;
287typedef gsi_i32 goa_int32;
288typedef gsi_u32 goa_uint32;
291#define gsi_false ((gsi_bool)0)
292#define gsi_true ((gsi_bool)1)
293#define gsi_is_false(x) ((x) == gsi_false)
294#define gsi_is_true(x) ((x) != gsi_false)
297#if defined(_INTEGRAL_MAX_BITS) && !defined(GSI_MAX_INTEGRAL_BITS)
298 #define GSI_MAX_INTEGRAL_BITS _INTEGRAL_MAX_BITS
300 #define GSI_MAX_INTEGRAL_BITS 32
305 typedef signed long gsi_i64;
306 typedef unsigned long gsi_u64;
308 #if (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64))
309 typedef __int64 gsi_i64;
310 typedef unsigned __int64 gsi_u64;
316 typedef long long gsi_i64;
317 typedef unsigned long long gsi_u64;
319 typedef int64_t gsi_i64;
320 typedef uint64_t gsi_u64;
321#elif defined (_REVOLUTION)
322 typedef signed long long gsi_i64;
323 typedef unsigned long long gsi_u64;
325 typedef long long gsi_i64;
326 typedef unsigned long long gsi_u64;
330 #define gsi_char char
332 #define gsi_char unsigned short
337#define GSI_MIN_I8 CHAR_MIN
338#define GSI_MAX_I8 CHAR_MAX
339#define GSI_MAX_U8 UCHAR_MAX
341#define GSI_MIN_I16 SHRT_MIN
342#define GSI_MAX_I16 SHRT_MAX
343#define GSI_MAX_U16 USHRT_MAX
345#define GSI_MIN_I32 INT_MIN
346#define GSI_MAX_I32 INT_MAX
347#define GSI_MAX_U32 UINT_MAX
349#if (GSI_MAX_INTEGRAL_BITS >= 64)
350#define GSI_MIN_I64 (-9223372036854775807 - 1)
351#define GSI_MAX_I64 9223372036854775807
352#define GSI_MAX_U64 0xffffffffffffffffui64
377 #define _vftprintf vfwprintf
378 #define _ftprintf fwprintf
379 #define _stprintf swprintf
380 #define _tprintf wprintf
381 #define _tcscpy wcscpy
382 #define _tcsncpy(d, s, l) wcsncpy((wchar_t *)d, (wchar_t *)s, l)
383 #define _tcscat wcscat
384 #define _tcslen wcslen
385 #define _tcschr wcschr
386 #define _tcscmp(s1, s2) wcscmp((wchar_t *)s1, (wchar_t *)s2)
387 #define _tfopen _wfopen
390 #if defined(_WIN32) || defined(_PS2)
391 #define _tsnprintf _snwprintf
393 #define _tsnprintf swprintf
396 #define _vftprintf vfprintf
397 #define _ftprintf fprintf
398 #define _stprintf sprintf
399 #define _tprintf printf
400 #define _tcscpy strcpy
401 #define _tcsncpy strncpy
402 #define _tcscat strcat
403 #define _tcslen strlen
404#if defined (_MSC_VER)
406 #define _tcschr strchr
409 #define _tcschr strchr
411 #define _tcscmp strcmp
412 #define _tfopen fopen
418 #define _tsnprintf _snprintf
420 #define _tsnprintf snprintf
425 #define snprintf _snprintf
429 #define strcasecmp _stricmp
430 #define strncasecmp _strnicmp
434 char *_strlwr(
char *
string);
435 char *_strupr(
char *
string);
438char * goastrdup(
const char *src);
439unsigned short * goawstrdup(
const unsigned short *src);
455 #define PRE_ALIGN(x) __declspec(align(x))
456 #define POST_ALIGN(x)
457#elif defined (_PS2) || defined (_PSP) || defined (_PS3)
459 #define POST_ALIGN(x) __attribute__((aligned (x)))
460#elif defined (_REVOLUTION)
462 #define POST_ALIGN(x) __attribute__((aligned(32)))
466 #define POST_ALIGN(x)
469#define DIM( x ) ( sizeof( x ) / sizeof((x)[ 0 ]))
471unsigned char * gsiFloatSwap(
unsigned char buf[4],
float);
472float gsiFloatUnswap(
unsigned char buf[4]);
473extern gsi_u16 gsiByteOrderSwap16(gsi_u16);
474extern gsi_u32 gsiByteOrderSwap32(gsi_u32);
475extern gsi_u64 gsiByteOrderSwap64(gsi_u64);