1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/sourcemm/oslink.h Tue Sep 18 20:03:47 2007 +0000
1.3 @@ -0,0 +1,91 @@
1.4 +/* ======== SourceMM ========
1.5 + * Copyright (C) 2004-2007 Metamod:Source Development Team
1.6 + * No warranties of any kind
1.7 + *
1.8 + * License: zlib/libpng
1.9 + *
1.10 + * Author(s): David "BAILOPAN" Anderson
1.11 + * ============================
1.12 + */
1.13 +
1.14 +#ifndef _INCLUDE_OSLINK_H
1.15 +#define _INCLUDE_OSLINK_H
1.16 +
1.17 +/**
1.18 + * @brief Defines OS-independent information
1.19 + * @file oslink.h
1.20 + */
1.21 +
1.22 +#if defined __WIN32__ || defined _WIN32 || defined WIN32
1.23 + #define WIN32_LEAN_AND_MEAN
1.24 + #define OS_WIN32
1.25 + #if defined _MSC_VER && _MSC_VER >= 1400
1.26 + #undef ARRAYSIZE
1.27 + #else
1.28 + #define mkdir(a) _mkdir(a)
1.29 + #endif
1.30 + #include <windows.h>
1.31 + #include <io.h>
1.32 + #include <direct.h>
1.33 + #define dlmount(x) LoadLibrary(x)
1.34 + #define dlsym(x, s) GetProcAddress(x, s)
1.35 + #define dlclose(x) FreeLibrary(x)
1.36 + const char* dlerror();
1.37 + #define abspath(x, s) _fullpath(x, s, sizeof(x))
1.38 + #define PATH_SEP_STR "\\"
1.39 + #define PATH_SEP_CHAR '\\'
1.40 + #define ALT_SEP_CHAR '/'
1.41 + #define PATH_SIZE MAX_PATH
1.42 + #define SERVER_DLL "server.dll"
1.43 +#elif defined __linux__
1.44 + #define OS_LINUX
1.45 + #include <dlfcn.h>
1.46 + #include <unistd.h>
1.47 + #include <sys/types.h>
1.48 + #include <dirent.h>
1.49 + typedef void* HINSTANCE;
1.50 + #define dlmount(x) dlopen(x,RTLD_NOW)
1.51 + #define abspath(x, s) realpath(s, x)
1.52 + #define PATH_SEP_STR "/"
1.53 + #define PATH_SEP_CHAR '/'
1.54 + #define ALT_SEP_CHAR '\\'
1.55 + #define PATH_SIZE PATH_MAX
1.56 + #define stricmp strcasecmp
1.57 + #define strnicmp strncasecmp
1.58 + #define SERVER_DLL "server_i486.so"
1.59 +#endif
1.60 +
1.61 +#if defined __linux__
1.62 + extern int errno;
1.63 + int GetLastError();
1.64 +#endif
1.65 +
1.66 +bool GetFileOfAddress(void *pAddr, char *buffer, size_t maxlength);
1.67 +
1.68 +#if defined __WIN32__ || defined _WIN32 || defined WIN32
1.69 + #define SMM_API extern "C" __declspec(dllexport)
1.70 +#elif defined __GNUC__
1.71 + #if (__GNUC__ == 4)
1.72 + #define SMM_API extern "C" __attribute__ ((visibility("default")))
1.73 + #else
1.74 + #define SMM_API extern "C"
1.75 + #endif
1.76 +#endif
1.77 +
1.78 +#if defined __WIN32__ || defined _WIN32 || defined WIN32
1.79 + typedef __int64 int64_t;
1.80 + typedef unsigned __int64 uint64_t;
1.81 +#elif defined __GNUC__
1.82 +#include <stdint.h>
1.83 +#if !__GLIBC_HAVE_LONG_LONG
1.84 + typedef long long int64_t;
1.85 + typedef unsigned long long uint64_t;
1.86 +#endif
1.87 +#endif
1.88 +
1.89 +#ifndef __linux__
1.90 + #define snprintf _snprintf
1.91 + #define vsnprintf _vsnprintf
1.92 +#endif
1.93 +
1.94 +#endif //_INCLUDE_OSLINK_H