loader/loader.h
author Scott Ehlert <ds@alliedmods.net>
Sun Nov 15 22:52:54 2009 -0500 (2009-11-15)
changeset 681 a9f34c9f06e7
parent 674 c4ed595f6248
child 683 b507295429f9
permissions -rw-r--r--
Fixed crash on Linux when loading via gameinfo.txt on Left 4 Dead 2 (bug 4111, r=dvander).
     1 /**
     2  * vim: set ts=4 sw=4 tw=99 noet :
     3  * ======================================================
     4  * Metamod:Source
     5  * Copyright (C) 2004-2009 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 
    26 #ifndef _INCLUDE_METAMOD_SOURCE_LOADER_H_
    27 #define _INCLUDE_METAMOD_SOURCE_LOADER_H_
    28 
    29 #define SH_COMP_GCC 	1
    30 #define SH_COMP_MSVC	2
    31 
    32 #if defined WIN32
    33 #define WINDOWS_LEAN_AND_MEAN
    34 #include <windows.h>
    35 #include <direct.h>
    36 #define PLATFORM_MAX_PATH	MAX_PATH
    37 #define SH_COMP				SH_COMP_MSVC
    38 #define	PATH_SEP_STR		"\\"
    39 #define PATH_SEP_CHAR		'\\'
    40 #define ALT_SEP_CHAR		'/'
    41 #elif defined __linux__
    42 #include <dlfcn.h>
    43 #include <dirent.h>
    44 #include <stdint.h>
    45 #include <unistd.h>
    46 typedef void *	HMODULE;
    47 #define PLATFORM_MAX_PATH	PATH_MAX
    48 #define SH_COMP				SH_COMP_GCC
    49 #define	PATH_SEP_STR		"/"
    50 #define PATH_SEP_CHAR		'/'
    51 #define ALT_SEP_CHAR		'\\'
    52 #else
    53 #error "OS detection failed"
    54 #endif
    55 
    56 #include "loader_bridge.h"
    57 
    58 #define SH_PTRSIZE sizeof(void*)
    59 
    60 enum MetamodBackend
    61 {
    62 	MMBackend_Episode1 = 0,
    63 	MMBackend_DarkMessiah,
    64 	MMBackend_Episode2,
    65 	MMBackend_Episode2Valve,
    66 	MMBackend_Left4Dead,
    67 	MMBackend_Left4Dead2,
    68 	MMBackend_UNKNOWN
    69 };
    70 
    71 extern bool
    72 mm_LoadMetamodLibrary(MetamodBackend backend, char *buffer, size_t maxlength);
    73 
    74 extern void *
    75 mm_GetProcAddress(const char *name);
    76 
    77 extern void
    78 mm_UnloadMetamodLibrary();
    79 
    80 extern void
    81 mm_LogFatal(const char *message, ...);
    82 
    83 extern const char *
    84 mm_GetGameName();
    85 
    86 extern MetamodBackend
    87 mm_DetermineBackend(QueryValveInterface qvi, const char *game_name);
    88 
    89 #endif /* _INCLUDE_METAMOD_SOURCE_LOADER_H_ */
    90