sourcemm/util.h
author David Anderson <dvander@alliedmods.net>
Thu Oct 06 00:59:01 2005 +0000 (2005-10-06)
changeset 122 7c36121e2dfe
parent 84 3f77bc9e64d8
child 138 dfa3b31cc042
permissions -rw-r--r--
Initial import of new GameDLL loading code
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2005 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_UTIL_H
    12 #define _INCLUDE_UTIL_H
    13 
    14 /**
    15  * @brief Utility functons
    16  * @file util.h
    17  */
    18 
    19 const char *UTIL_GetExtension(const char *file);
    20 void UTIL_TrimComments(char *buffer);
    21 void UTIL_TrimLeft(char *buffer);
    22 void UTIL_TrimRight(char *buffer);
    23 void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t len2);
    24 void UTIL_PathFmt(char *buffer, size_t len, const char *fmt, ...);
    25 bool UTIL_PathCmp(const char *path1, const char *path2);
    26 
    27 #define META_INTERFACE_MACRO(type, final) \
    28 	PluginIter i; \
    29 	void *mret=NULL, *d; \
    30 	META_RES mres, high=MRES_IGNORED; \
    31 	g_SmmAPI.SetLastMetaReturn(MRES_IGNORED); \
    32 	for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++) \
    33 	{ \
    34 		if ( (*i) && (*i)->fac_list. type ) \
    35 		{ \
    36 			d = ((*i)->fac_list. type)(name, ret); \
    37 			mres = g_SmmAPI.GetLastMetaReturn(); \
    38 			if (mres > high) \
    39 				high = mres; \
    40 			if (mres >= MRES_OVERRIDE) \
    41 				mret = d; \
    42 		} \
    43 	} \
    44 	if (high == MRES_OVERRIDE) \
    45 	{ \
    46 		if (final) \
    47 			(final)(name, ret); \
    48 		return mret; \
    49 	} else if (high == MRES_SUPERCEDE) { \
    50 		return mret; \
    51 	} else { \
    52 		if (final) \
    53 			return (final)(name, ret); \
    54 		return NULL; \
    55 	} 
    56 
    57 #endif //_INCLUDE_UTIL_H