sourcemm/oslink.h
author David Anderson <dvander@alliedmods.net>
Thu Sep 27 19:28:05 2007 +0000 (2007-09-27)
branchsourcemm-1.6.0
changeset 356 bbcf8dcb2aa7
parent 347 e82968c21606
permissions -rw-r--r--
removed unnecessary api call
     1 /* ======== SourceMM ======== 
     2  * Copyright (C) 2004-2007 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		abspath(x, s)	_fullpath(x, s, sizeof(x))
    35 	#define	PATH_SEP_STR		"\\"
    36 	#define PATH_SEP_CHAR		'\\'
    37 	#define ALT_SEP_CHAR		'/'
    38 	#define PATH_SIZE			MAX_PATH
    39 	#define SERVER_DLL			"server.dll"
    40 #elif defined __linux__
    41 	#define OS_LINUX
    42 	#include <dlfcn.h>
    43 	#include <unistd.h>
    44 	#include <sys/types.h>
    45 	#include <dirent.h>
    46 	typedef		void*			HINSTANCE;
    47 	#define		dlmount(x)		dlopen(x,RTLD_NOW)
    48 	#define		abspath(x, s)	realpath(s, x)
    49 	#define	PATH_SEP_STR		"/"
    50 	#define PATH_SEP_CHAR		'/'
    51 	#define ALT_SEP_CHAR		'\\'
    52 	#define PATH_SIZE			PATH_MAX
    53 	#define	stricmp				strcasecmp
    54 	#define strnicmp			strncasecmp
    55 	#define SERVER_DLL			"server_i486.so"
    56 #endif
    57 
    58 #if defined __linux__
    59 	extern int errno;
    60 	int GetLastError();
    61 #endif
    62 
    63 bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength);
    64 
    65 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    66 	#define SMM_API extern "C" __declspec(dllexport)
    67 #elif defined __GNUC__
    68 	#if (__GNUC__ == 4)
    69 		#define SMM_API extern "C" __attribute__ ((visibility("default")))	
    70 	#else
    71 		#define SMM_API	extern "C" 
    72 	#endif	
    73 #endif
    74 
    75 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    76 	typedef __int64				int64_t;
    77 	typedef unsigned __int64	uint64_t;
    78 #elif defined __GNUC__
    79 #include <stdint.h>
    80 #if !__GLIBC_HAVE_LONG_LONG
    81 	typedef long long			int64_t;
    82 	typedef unsigned long long	uint64_t;
    83 #endif
    84 #endif
    85 
    86 #ifndef __linux__
    87 	#define snprintf	_snprintf
    88 	#define vsnprintf	_vsnprintf
    89 #endif
    90 
    91 #endif //_INCLUDE_OSLINK_H