sourcemm/metamod_oslink.h
author David Anderson <dvander@alliedmods.net>
Thu Oct 04 19:18:19 2007 +0000 (2007-10-04)
branchsourcemm-1.6.0
changeset 369 2b8c2ea08b6d
parent 367 fc76472b980f
permissions -rw-r--r--
fixed usermessages not printing
removed old ConMsg extraction code
     1 /**
     2  * vim: set ts=4 :
     3  * ======================================================
     4  * Metamod:Source
     5  * Copyright (C) 2004-2007 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 #elif defined __linux__
    59 	#define OS_LINUX
    60 	#include <dlfcn.h>
    61 	#include <unistd.h>
    62 	#include <sys/types.h>
    63 	#include <dirent.h>
    64 	typedef		void*			HINSTANCE;
    65 	#define		dlmount(x)		dlopen(x,RTLD_NOW)
    66 	#define		abspath(x, s)	realpath(s, x)
    67 	#define	PATH_SEP_STR		"/"
    68 	#define PATH_SEP_CHAR		'/'
    69 	#define ALT_SEP_CHAR		'\\'
    70 	#define PATH_SIZE			PATH_MAX
    71 	#define	stricmp				strcasecmp
    72 	#define strnicmp			strncasecmp
    73 	#define SERVER_DLL			"server_i486.so"
    74 #endif
    75 
    76 #if defined __linux__
    77 	extern int errno;
    78 	int GetLastError();
    79 #endif
    80 
    81 bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength);
    82 
    83 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    84 	#define SMM_API extern "C" __declspec(dllexport)
    85 #elif defined __GNUC__
    86 	#if (__GNUC__ == 4)
    87 		#define SMM_API extern "C" __attribute__ ((visibility("default")))	
    88 	#else
    89 		#define SMM_API	extern "C" 
    90 	#endif	
    91 #endif
    92 
    93 #if defined __WIN32__ || defined _WIN32 || defined WIN32
    94 	typedef __int64				int64_t;
    95 	typedef unsigned __int64	uint64_t;
    96 #elif defined __GNUC__
    97 #include <stdint.h>
    98 #if !__GLIBC_HAVE_LONG_LONG
    99 	typedef long long			int64_t;
   100 	typedef unsigned long long	uint64_t;
   101 #endif
   102 #endif
   103 
   104 #ifndef __linux__
   105 	#define snprintf	_snprintf
   106 	#define vsnprintf	_vsnprintf
   107 #endif
   108 
   109 #endif //_INCLUDE_OSLINK_H