trace_plugin/trace_api.h
changeset 0 d15304fcb7a7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/trace_plugin/trace_api.h	Tue Apr 06 07:36:14 2004 +0000
     1.3 @@ -0,0 +1,102 @@
     1.4 +// vi: set ts=4 sw=4 :
     1.5 +// vim: set tw=75 :
     1.6 +
     1.7 +// trace_api.h - (main) description of HL API tracing operations
     1.8 +
     1.9 +/*
    1.10 + * Copyright (c) 2001-2003 Will Day <[email protected]>
    1.11 + *
    1.12 + *    This file is part of Metamod.
    1.13 + *
    1.14 + *    Metamod is free software; you can redistribute it and/or modify it
    1.15 + *    under the terms of the GNU General Public License as published by the
    1.16 + *    Free Software Foundation; either version 2 of the License, or (at
    1.17 + *    your option) any later version.
    1.18 + *
    1.19 + *    Metamod is distributed in the hope that it will be useful, but
    1.20 + *    WITHOUT ANY WARRANTY; without even the implied warranty of
    1.21 + *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.22 + *    General Public License for more details.
    1.23 + *
    1.24 + *    You should have received a copy of the GNU General Public License
    1.25 + *    along with Metamod; if not, write to the Free Software Foundation,
    1.26 + *    Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.27 + *
    1.28 + *    In addition, as a special exception, the author gives permission to
    1.29 + *    link the code of this program with the Half-Life Game Engine ("HL
    1.30 + *    Engine") and Modified Game Libraries ("MODs") developed by Valve,
    1.31 + *    L.L.C ("Valve").  You must obey the GNU General Public License in all
    1.32 + *    respects for all of the code used other than the HL Engine and MODs
    1.33 + *    from Valve.  If you modify this file, you may extend this exception
    1.34 + *    to your version of the file, but you are not obligated to do so.  If
    1.35 + *    you do not wish to do so, delete this exception statement from your
    1.36 + *    version.
    1.37 + *
    1.38 + */
    1.39 +
    1.40 +#ifndef TRACE_API_H
    1.41 +#define TRACE_API_H
    1.42 +
    1.43 +#include <time.h>				// time()
    1.44 +
    1.45 +#include <enginecallback.h>		// ALERT()
    1.46 +#include <sdk_util.h>			// UTIL_VarArgs()
    1.47 +
    1.48 +#include "api_info.h"
    1.49 +
    1.50 +#define API_TRACE(api_info_table, cvar_trace, api_str, pfnName, post, args) \
    1.51 +	do { if((cvar_trace->value >= api_info_table.pfnName.loglevel || api_info_table.pfnName.trace) && (unlimit_trace->value || (last_trace_log != time(NULL)))) { \
    1.52 +			ALERT(at_logged, "[%s] %s(%d): called: %s%s; %s\n", \
    1.53 +					Plugin_info.logtag, api_str, \
    1.54 +					api_info_table.pfnName.loglevel, \
    1.55 +					api_info_table.pfnName.name, \
    1.56 +					(post ? "_Post" : ""), \
    1.57 +					UTIL_VarArgs args ); \
    1.58 +			last_trace_log=time(NULL); \
    1.59 +		} \
    1.60 +	} while(0)
    1.61 +
    1.62 +#define DLL_TRACE(pfnName, post, args) \
    1.63 +	API_TRACE(dllapi_info, dllapi_trace, "dllapi", pfnName, post, args)
    1.64 +
    1.65 +#define NEWDLL_TRACE(pfnName, post, args) \
    1.66 +	API_TRACE(newapi_info, newapi_trace, "newapi", pfnName, post, args)
    1.67 +
    1.68 +#define ENGINE_TRACE(pfnName, post, args) \
    1.69 +	API_TRACE(engine_info, engine_trace, "engine", pfnName, post, args)
    1.70 +
    1.71 +typedef enum {
    1.72 +	TR_FAILURE = 0,
    1.73 +	TR_SUCCESS,
    1.74 +	TR_ALREADY,
    1.75 +} TRACE_RESULT;
    1.76 +
    1.77 +#define MAX_REG_MESSAGES	256
    1.78 +
    1.79 +extern time_t last_trace_log;
    1.80 +
    1.81 +extern const char *msg_dest_types[32];
    1.82 +
    1.83 +extern cvar_t init_dllapi_trace;
    1.84 +extern cvar_t init_newapi_trace;
    1.85 +extern cvar_t init_engine_trace;
    1.86 +extern cvar_t init_unlimit_trace;
    1.87 +
    1.88 +extern cvar_t *dllapi_trace;
    1.89 +extern cvar_t *newapi_trace;
    1.90 +extern cvar_t *engine_trace;
    1.91 +extern cvar_t *unlimit_trace;
    1.92 +
    1.93 +void trace_init(void);
    1.94 +
    1.95 +void svr_trace(void);
    1.96 +void cmd_trace_usage(void);
    1.97 +void cmd_trace_version(void);
    1.98 +void cmd_trace_set(void);
    1.99 +void cmd_trace_unset(void);
   1.100 +void cmd_trace_show(void);
   1.101 +void cmd_trace_list(void);
   1.102 +
   1.103 +TRACE_RESULT trace_setflag(const char **pfn_string, mBOOL flagval, const char **api);
   1.104 +
   1.105 +#endif /* TRACE_API_H */