📄 gatedbg.h
字号:
/**********************************************************************************************
*
* $ProjectName: X:\SIPROJ\VOIP\HOST\WIN_NT\DEMOS\VOIPGATE\PROJECT.PJ $
* $ProjectRevision: 1.5 $
* $Label$
* $Revision: 1.7 $ - $Date: 1997/08/17 11:00:34 $
*
**********************************************************************************************/
#ifndef _GATEDBG_h
#define _GATEDBG_h
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
/* MNT driver libraries */
#include "qhostlib.h"
/* Mercury TSC and NetTSC H files */
#include "tscdefs.h"
#include "ntscdefs.h"
#include "dxxxlib.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Exit code */
typedef enum {
OPEN_ERROR = 1,
IOCP_ERROR,
CFG_ERROR,
CHAN_OUT_OF_SERVICE,
//new error code ,add by xuzq
OPEN_VOXFILE_ERROR,
PLAY_VOXFILE_ERROR,
GET_DIGITALS_ERROR
} errorCode;
#define GATE_MAX_ERROR_SIZE 256
#define GATE_ERROR_MASK 0xE0000000
#define GATE_LOGLEVEL_ENV "GATE_LOGLEVEL" /* This environment variable is
used to control dynamic logging. */
/* Predefined loglevels */
#define LOGLEVEL_FATAL 1
#define LOGLEVEL_ERROR 2
#define LOGLEVEL_ALERT 3
#define LOGLEVEL_WARNING 4
#define LOGLEVEL_INFO 5
#define LOGLEVEL_TRACE 6
#define GATE_PATH_SEPARATOR '\\'
//////////////////////
/// ///
/// Macros ///
/// ///
//////////////////////
/* Extract the filename from a given path. */
#define GATE_PATH_TO_FILE(path) \
(strrchr(path, GATE_PATH_SEPARATOR) ? strrchr(path,GATE_PATH_SEPARATOR)+1:path)
#ifdef GATE_LOG
/* Use the following macros, just like regular printf().
The behaviour of these macros is controlled by compile
time options and environment variables.
If compiled with GATE_LOG=n, where n is the initial loglevel desired
logging is enabled, else these macros are compiled out with a dummy
function. Almost all compilers optmise by removing dummy functions
from the object produced. Hence no overhead if compiled out.
If dynamic behaviour is desired for various levels of logging without
recompiling just set the environment variable "GATE_LOGLEVEL" to the
level desired. */
#define gateFATAL(ch,m) if(gateLog(__FILE__, __LINE__, LOGLEVEL_FATAL,ch)) PRINT (ch,m)
#define gateERROR(ch,m) if(gateLog(__FILE__, __LINE__, LOGLEVEL_ERROR,ch)) PRINT (ch,m)
#define gateALERT(ch,m) if(gateLog(__FILE__, __LINE__, LOGLEVEL_ALERT,ch)) PRINT (ch,m)
#define gateWARNING(ch,m) if(gateLog(__FILE__, __LINE__, LOGLEVEL_WARNING,ch)) PRINT (ch,m)
#define gateINFO(ch,m) if(gateLog(__FILE__, __LINE__, LOGLEVEL_INFO,ch)) PRINT (ch,m)
#define gateTRACE(ch,m) if(gateLog(__FILE__, __LINE__, LOGLEVEL_TRACE,ch)) PRINT (ch,m)
#define PRINT(ch,m) { \
fprintf m;\
fflush(Session[ch].LogFile);\
}
///////////////////////////////////////////////////////
/// ///
/// DECLERATION OF LOCAL FUNCTIONS ///
/// ///
///////////////////////////////////////////////////////
/*****FUNCTION***************************************************
* NAME : gateEventStr
* DESCRIPTION : Converts event number to string
* INPUT : UInt32 eventNumber
* OUTPUT : None
* RETURNS : char * - The string representing the event.
* CAUTIONS : None
****************************************************************/
char * gateEventStr(UInt32 eventNumber);
/*****FUNCTION***************************************************
* NAME : gateLog
* DESCRIPTION : This function logs the filename, line number,
* and loglevel into the terminal
* if the loglevel is <= the current loglevel desired
* by user.
*
* INPUT : char *file - Current file
* int line - Line number
* int level - Loglevel
* OUTPUT : None
* RETURNS : TRUE - logging enable, FALSE - logging disable
* CAUTIONS : None
****************************************************************/
BOOL gateLog(char *file,
int line,
int level,
USHORT channel);
/*****FUNCTION***************************************************
* NAME : gateErrorString
* DESCRIPTION : Return a string representation of LastError
* INPUT : None
* OUTPUT : None
* RETURNS : CONST LPSTR - The string representation of LastError
* CAUTIONS : None
****************************************************************/
CONST LPSTR gateErrorString();
#else GATE_LOG
#define gateFATAL gateDummyLog
#define gateERROR gateDummyLog
#define gateALERT gateDummyLog
#define gateWARNING gateDummyLog
#define gateINFO gateDummyLog
#define gateTRACE gateDummyLog
#define gateLOG(level) gateDummyLog
///////////////////////////////////////////////////////
/// ///
/// DECLARATION OF LOCAL FUNCTIONS ///
/// ///
///////////////////////////////////////////////////////
/*****FUNCTION***************************************************
* NAME : gateDummyLog
* DESCRIPTION : An empty function is effectively compiled out by the compiler
* during optimization phase.
* INPUT : const char *fmt, ...
* OUTPUT : None
* RETURNS : None
* CAUTIONS : None
****************************************************************/
void gateDummyLog(const char *fmt, ...);
#endif GATE_LOG
#ifdef __cplusplus
}
#endif __cplusplus
#endif _GATEDBG_h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -