sourcemm/oslink.h
author Scott Ehlert <ds@alliedmods.net>
Thu Feb 08 11:44:11 2007 +0000 (2007-02-08)
changeset 281 588bc5e6a607
parent 251 3bd7e7008ac3
child 282 7a237e9ea5a1
permissions -rw-r--r--
Added 1.3d to changelog...
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2006 Metamod:Source Development Team
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): David "BAILOPAN" Anderson
     8 * ============================
     9 */
    10 
    11 #ifndef _INCLUDE_OSLINK_H
    12 #define _INCLUDE_OSLINK_H
    13 
    14 /**
    15  * @brief Defines OS-independent information
    16  * @file oslink.h
    17  */
    18 
    19 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    20 	#define WIN32_LEAN_AND_MEAN
    21 	#define OS_WIN32
    22 	#if defined _MSC_VER && _MSC_VER >= 1400
    23 		#undef ARRAYSIZE
    24 	#else
    25 		#define mkdir(a) _mkdir(a)
    26 	#endif
    27 	#include <windows.h>
    28 	#include <io.h>
    29 	#include <direct.h>
    30 	#define		dlmount(x)		LoadLibrary(x)
    31 	#define		dlsym(x, s)		GetProcAddress(x, s)
    32 	#define		dlclose(x)		FreeLibrary(x)
    33 	const char*	dlerror();
    34 	#define	PATH_SEP_STR	"\\"
    35 	#define PATH_SEP_CHAR	'\\'
    36 	#define ALT_SEP_CHAR	'/'
    37 	#define SERVER_DLL		"server.dll"
    38 #elif defined __linux__
    39 	#define OS_LINUX
    40 	#include <dlfcn.h>
    41 	#include <unistd.h>
    42 	#include <sys/types.h>
    43 	#include <dirent.h>
    44 	#define		dlmount(x)		dlopen(x,RTLD_NOW)
    45 	typedef		void*			HINSTANCE;
    46 	#define	PATH_SEP_STR	"/"
    47 	#define PATH_SEP_CHAR	'/'
    48 	#define ALT_SEP_CHAR	'\\'
    49 	#define	stricmp				strcasecmp
    50 	#define strnicmp			strncasecmp
    51 	#define SERVER_DLL		"server_i486.so"
    52 #endif
    53 
    54 #if defined __linux__
    55 	extern int errno;
    56 	int GetLastError();
    57 #endif
    58 
    59 bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength);
    60 
    61 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    62 	#define SMM_API extern "C" __declspec(dllexport)
    63 #elif defined __GNUC__
    64 	#if (__GNUC__ == 4)
    65 		#define SMM_API extern "C" __attribute__ ((visibility("default")))	
    66 	#else
    67 		#define SMM_API	extern "C" 
    68 	#endif	
    69 #endif
    70 
    71 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    72 	typedef __int64				int64_t;
    73 	typedef unsigned __int64	uint64_t;
    74 #elif defined __GNUC__
    75 #include <stdint.h>
    76 #if !__GLIBC_HAVE_LONG_LONG
    77 	typedef long long			int64_t;
    78 	typedef unsigned long long	uint64_t;
    79 #endif
    80 #endif
    81 
    82 #ifndef __linux__
    83 	#define snprintf	_snprintf
    84 	#define vsnprintf	_vsnprintf
    85 #endif
    86 
    87 #endif //_INCLUDE_OSLINK_H