sourcemm/metamod_oslink.h
author David Anderson <dvander@alliedmods.net>
Sat Jul 26 05:02:29 2008 +0000 (2008-07-26)
changeset 529 7f1c8e49df8f
parent 523 6f1630519b81
permissions -rw-r--r--
Bumped version for tagging
Removed unused update_tool from trunk
     1 /**
     2  * vim: set ts=4 :
     3  * ======================================================
     4  * Metamod:Source
     5  * Copyright (C) 2004-2008 AlliedModders LLC and authors.
     6  * All rights reserved.
     7  * ======================================================
     8  *
     9  * This software is provided 'as-is', without any express or implied warranty.
    10  * In no event will the authors be held liable for any damages arising from 
    11  * the use of this software.
    12  * 
    13  * Permission is granted to anyone to use this software for any purpose, 
    14  * including commercial applications, and to alter it and redistribute it 
    15  * freely, subject to the following restrictions:
    16  *
    17  * 1. The origin of this software must not be misrepresented; you must not 
    18  * claim that you wrote the original software. If you use this software in a 
    19  * product, an acknowledgment in the product documentation would be 
    20  * appreciated but is not required.
    21  * 2. Altered source versions must be plainly marked as such, and must not be
    22  * misrepresented as being the original software.
    23  * 3. This notice may not be removed or altered from any source distribution.
    24  *
    25  * Version: $Id$
    26  */
    27 
    28 #ifndef _INCLUDE_OSLINK_H
    29 #define _INCLUDE_OSLINK_H
    30 
    31 /**
    32  * @brief Defines OS-independent information
    33  * @file oslink.h
    34  */
    35 
    36 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    37 	#define WIN32_LEAN_AND_MEAN
    38 	#define OS_WIN32
    39 	#if defined _MSC_VER && _MSC_VER >= 1400
    40 		#undef ARRAYSIZE
    41 	#else
    42 		#define mkdir(a) _mkdir(a)
    43 	#endif
    44 	#include <windows.h>
    45 	#include <io.h>
    46 	#include <direct.h>
    47 	#define		dlmount(x)		LoadLibrary(x)
    48 	#define		dlsym(x, s)		GetProcAddress(x, s)
    49 	#define		dlclose(x)		FreeLibrary(x)
    50 	const char*	dlerror();
    51 	#define		abspath(x, s)	_fullpath(x, s, sizeof(x))
    52 	#define	PATH_SEP_STR		"\\"
    53 	#define PATH_SEP_CHAR		'\\'
    54 	#define ALT_SEP_CHAR		'/'
    55 	#define PATH_SIZE			MAX_PATH
    56 	#define SERVER_DLL			"server.dll"
    57 	#define strcasecmp			stricmp
    58 	inline bool _IsPathSepChar(char c) { return (c == '/' || c == '\\'); }
    59 #elif defined __linux__
    60 	#define OS_LINUX
    61 	#include <dlfcn.h>
    62 	#include <unistd.h>
    63 	#include <sys/types.h>
    64 	#include <dirent.h>
    65 	typedef		void*			HINSTANCE;
    66 	#define		dlmount(x)		dlopen(x,RTLD_NOW)
    67 	#define		abspath(x, s)	realpath(s, x)
    68 	#define	PATH_SEP_STR		"/"
    69 	#define PATH_SEP_CHAR		'/'
    70 	#define ALT_SEP_CHAR		'\\'
    71 	#define PATH_SIZE			PATH_MAX
    72 	#define	stricmp				strcasecmp
    73 	#define strnicmp			strncasecmp
    74 	#define SERVER_DLL			"server_i486.so"
    75 	inline bool _IsPathSepChar(char c) { return (c == '/'); }
    76 #endif
    77 
    78 #if defined __linux__
    79 	#include <errno.h>
    80 	int GetLastError();
    81 #endif
    82 
    83 bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength);
    84 
    85 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    86 	#define SMM_API extern "C" __declspec(dllexport)
    87 #elif defined __GNUC__
    88 	#if (__GNUC__ == 4)
    89 		#define SMM_API extern "C" __attribute__ ((visibility("default")))	
    90 	#else
    91 		#define SMM_API	extern "C" 
    92 	#endif	
    93 #endif
    94 
    95 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    96 	typedef __int64				int64_t;
    97 	typedef unsigned __int64	uint64_t;
    98 #elif defined __GNUC__
    99 #include <stdint.h>
   100 #if !__GLIBC_HAVE_LONG_LONG
   101 	typedef long long			int64_t;
   102 	typedef unsigned long long	uint64_t;
   103 #endif
   104 #endif
   105 
   106 #ifndef __linux__
   107 	#define snprintf	_snprintf
   108 	#define vsnprintf	_vsnprintf
   109 #endif
   110 
   111 #endif //_INCLUDE_OSLINK_H