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