trace_plugin/trace_api.h
author Scott Ehlert <ds@alliedmods.net>
Thu Sep 26 22:57:05 2013 -0500 (2013-09-26)
changeset 286 202d9c3207a2
parent 0 d15304fcb7a7
permissions -rw-r--r--
Fixed warning when building stub_mm plugin.
     1 // vi: set ts=4 sw=4 :
     2 // vim: set tw=75 :
     3 
     4 // trace_api.h - (main) description of HL API tracing operations
     5 
     6 /*
     7  * Copyright (c) 2001-2003 Will Day <[email protected]>
     8  *
     9  *    This file is part of Metamod.
    10  *
    11  *    Metamod is free software; you can redistribute it and/or modify it
    12  *    under the terms of the GNU General Public License as published by the
    13  *    Free Software Foundation; either version 2 of the License, or (at
    14  *    your option) any later version.
    15  *
    16  *    Metamod is distributed in the hope that it will be useful, but
    17  *    WITHOUT ANY WARRANTY; without even the implied warranty of
    18  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    19  *    General Public License for more details.
    20  *
    21  *    You should have received a copy of the GNU General Public License
    22  *    along with Metamod; if not, write to the Free Software Foundation,
    23  *    Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24  *
    25  *    In addition, as a special exception, the author gives permission to
    26  *    link the code of this program with the Half-Life Game Engine ("HL
    27  *    Engine") and Modified Game Libraries ("MODs") developed by Valve,
    28  *    L.L.C ("Valve").  You must obey the GNU General Public License in all
    29  *    respects for all of the code used other than the HL Engine and MODs
    30  *    from Valve.  If you modify this file, you may extend this exception
    31  *    to your version of the file, but you are not obligated to do so.  If
    32  *    you do not wish to do so, delete this exception statement from your
    33  *    version.
    34  *
    35  */
    36 
    37 #ifndef TRACE_API_H
    38 #define TRACE_API_H
    39 
    40 #include <time.h>				// time()
    41 
    42 #include <enginecallback.h>		// ALERT()
    43 #include <sdk_util.h>			// UTIL_VarArgs()
    44 
    45 #include "api_info.h"
    46 
    47 #define API_TRACE(api_info_table, cvar_trace, api_str, pfnName, post, args) \
    48 	do { if((cvar_trace->value >= api_info_table.pfnName.loglevel || api_info_table.pfnName.trace) && (unlimit_trace->value || (last_trace_log != time(NULL)))) { \
    49 			ALERT(at_logged, "[%s] %s(%d): called: %s%s; %s\n", \
    50 					Plugin_info.logtag, api_str, \
    51 					api_info_table.pfnName.loglevel, \
    52 					api_info_table.pfnName.name, \
    53 					(post ? "_Post" : ""), \
    54 					UTIL_VarArgs args ); \
    55 			last_trace_log=time(NULL); \
    56 		} \
    57 	} while(0)
    58 
    59 #define DLL_TRACE(pfnName, post, args) \
    60 	API_TRACE(dllapi_info, dllapi_trace, "dllapi", pfnName, post, args)
    61 
    62 #define NEWDLL_TRACE(pfnName, post, args) \
    63 	API_TRACE(newapi_info, newapi_trace, "newapi", pfnName, post, args)
    64 
    65 #define ENGINE_TRACE(pfnName, post, args) \
    66 	API_TRACE(engine_info, engine_trace, "engine", pfnName, post, args)
    67 
    68 typedef enum {
    69 	TR_FAILURE = 0,
    70 	TR_SUCCESS,
    71 	TR_ALREADY,
    72 } TRACE_RESULT;
    73 
    74 #define MAX_REG_MESSAGES	256
    75 
    76 extern time_t last_trace_log;
    77 
    78 extern const char *msg_dest_types[32];
    79 
    80 extern cvar_t init_dllapi_trace;
    81 extern cvar_t init_newapi_trace;
    82 extern cvar_t init_engine_trace;
    83 extern cvar_t init_unlimit_trace;
    84 
    85 extern cvar_t *dllapi_trace;
    86 extern cvar_t *newapi_trace;
    87 extern cvar_t *engine_trace;
    88 extern cvar_t *unlimit_trace;
    89 
    90 void trace_init(void);
    91 
    92 void svr_trace(void);
    93 void cmd_trace_usage(void);
    94 void cmd_trace_version(void);
    95 void cmd_trace_set(void);
    96 void cmd_trace_unset(void);
    97 void cmd_trace_show(void);
    98 void cmd_trace_list(void);
    99 
   100 TRACE_RESULT trace_setflag(const char **pfn_string, mBOOL flagval, const char **api);
   101 
   102 #endif /* TRACE_API_H */