darope@0: // vi: set ts=4 sw=4 : darope@0: // vim: set tw=75 : darope@0: darope@0: // trace_api.h - (main) description of HL API tracing operations darope@0: darope@0: /* darope@0: * Copyright (c) 2001-2003 Will Day darope@0: * darope@0: * This file is part of Metamod. darope@0: * darope@0: * Metamod is free software; you can redistribute it and/or modify it darope@0: * under the terms of the GNU General Public License as published by the darope@0: * Free Software Foundation; either version 2 of the License, or (at darope@0: * your option) any later version. darope@0: * darope@0: * Metamod is distributed in the hope that it will be useful, but darope@0: * WITHOUT ANY WARRANTY; without even the implied warranty of darope@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU darope@0: * General Public License for more details. darope@0: * darope@0: * You should have received a copy of the GNU General Public License darope@0: * along with Metamod; if not, write to the Free Software Foundation, darope@0: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA darope@0: * darope@0: * In addition, as a special exception, the author gives permission to darope@0: * link the code of this program with the Half-Life Game Engine ("HL darope@0: * Engine") and Modified Game Libraries ("MODs") developed by Valve, darope@0: * L.L.C ("Valve"). You must obey the GNU General Public License in all darope@0: * respects for all of the code used other than the HL Engine and MODs darope@0: * from Valve. If you modify this file, you may extend this exception darope@0: * to your version of the file, but you are not obligated to do so. If darope@0: * you do not wish to do so, delete this exception statement from your darope@0: * version. darope@0: * darope@0: */ darope@0: darope@0: #ifndef TRACE_API_H darope@0: #define TRACE_API_H darope@0: darope@0: #include // time() darope@0: darope@0: #include // ALERT() darope@0: #include // UTIL_VarArgs() darope@0: darope@0: #include "api_info.h" darope@0: darope@0: #define API_TRACE(api_info_table, cvar_trace, api_str, pfnName, post, args) \ darope@0: do { if((cvar_trace->value >= api_info_table.pfnName.loglevel || api_info_table.pfnName.trace) && (unlimit_trace->value || (last_trace_log != time(NULL)))) { \ darope@0: ALERT(at_logged, "[%s] %s(%d): called: %s%s; %s\n", \ darope@0: Plugin_info.logtag, api_str, \ darope@0: api_info_table.pfnName.loglevel, \ darope@0: api_info_table.pfnName.name, \ darope@0: (post ? "_Post" : ""), \ darope@0: UTIL_VarArgs args ); \ darope@0: last_trace_log=time(NULL); \ darope@0: } \ darope@0: } while(0) darope@0: darope@0: #define DLL_TRACE(pfnName, post, args) \ darope@0: API_TRACE(dllapi_info, dllapi_trace, "dllapi", pfnName, post, args) darope@0: darope@0: #define NEWDLL_TRACE(pfnName, post, args) \ darope@0: API_TRACE(newapi_info, newapi_trace, "newapi", pfnName, post, args) darope@0: darope@0: #define ENGINE_TRACE(pfnName, post, args) \ darope@0: API_TRACE(engine_info, engine_trace, "engine", pfnName, post, args) darope@0: darope@0: typedef enum { darope@0: TR_FAILURE = 0, darope@0: TR_SUCCESS, darope@0: TR_ALREADY, darope@0: } TRACE_RESULT; darope@0: darope@0: #define MAX_REG_MESSAGES 256 darope@0: darope@0: extern time_t last_trace_log; darope@0: darope@0: extern const char *msg_dest_types[32]; darope@0: darope@0: extern cvar_t init_dllapi_trace; darope@0: extern cvar_t init_newapi_trace; darope@0: extern cvar_t init_engine_trace; darope@0: extern cvar_t init_unlimit_trace; darope@0: darope@0: extern cvar_t *dllapi_trace; darope@0: extern cvar_t *newapi_trace; darope@0: extern cvar_t *engine_trace; darope@0: extern cvar_t *unlimit_trace; darope@0: darope@0: void trace_init(void); darope@0: darope@0: void svr_trace(void); darope@0: void cmd_trace_usage(void); darope@0: void cmd_trace_version(void); darope@0: void cmd_trace_set(void); darope@0: void cmd_trace_unset(void); darope@0: void cmd_trace_show(void); darope@0: void cmd_trace_list(void); darope@0: darope@0: TRACE_RESULT trace_setflag(const char **pfn_string, mBOOL flagval, const char **api); darope@0: darope@0: #endif /* TRACE_API_H */