⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gatedbg.c

📁 ipt网关源码
💻 C
字号:
/**********************************************************************************************
* 
* $ProjectName: X:\SIPROJ\VOIP\HOST\WIN_NT\DEMOS\VOIPGATE\PROJECT.PJ $
* $ProjectRevision: 1.5 $
* $Label$
* $Revision: 1.7 $ - $Date: 1997/08/17 11:00:46 $
* 
**********************************************************************************************/
#define _GATEDBG_C

#include <time.h>

/* The GateDbg H files - 
   Function Prototype and Definition */
#include "GateDbg.h"
#include "gatestrc.h"
#include "gatedefs.h"
#include "gatevars.h"

#ifdef GATE_LOG

CHAR  szGateBuffer[GATE_MAX_ERROR_SIZE];

/*****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)
{

   switch(eventNumber) 
   {

      case  TSC_EvtCallState_Type_Connected:
         return("TSC_EvtCallState_Type_Connected");
   
      case  TSC_EvtCallState_Type_Disconnected:
         return("TSC_EvtCallState_Type_Disconnected");
   
      case  TSC_EvtCallState_Type_Failed:
         return("TSC_EvtCallState_Type_Failed");
   
      case  TSC_EvtCallState_Type_Null:
         return("TSC_EvtCallState_Type_Null");
   
      case  TSC_EvtCallState_Type_Idle:
         return("TSC_EvtCallState_Type_Idle");
   
      case  NetTSC_EvtH245Data_Type_NonStdCmd:
         return("NetTSC_EvtH245Data_Type_NonStdCmd");

      case  NetTSC_EvtH245Data_Type_UsrInputIndication:
         return("NetTSC_EvtH245Data_Type_UsrInputIndication");

      case  TSC_EvtCallState_Type_Offered:
         return("TSC_EvtCallState_Type_Offered");
   
      case  TSC_EvtChanState_Type_OutOfService:
         return("TSC_EvtChanState_Type_OutOfService");
   
      case TSC_MsgGetCallInfoCmplt :
         return("TSC_MsgGetCallInfoCmplt");

      case TSC_MsgMakeCallCmplt :
         return("TSC_MsgMakeCallCmplt");

      case Std_MsgDetectxEvtsCmplt:
         return("Std_MsgDetectxEvtsCmplt");

      case  DE_RINGS:
         return("DE_RINGS");
   
      case  DE_LCOFF:
         return("DE_LCOFF");
   
      case  DE_TONEON:
        return("DE_TONEON");

      case  DIGITAL_OFFHOOK:
         return("DIGITAL_OFFHOOK");

      case  DIGITAL_ONHOOK:			
         return("DIGITAL_ONHOOK");

      default:
         return("Unknown Event");
   }

} /* Function gateEventStr */


/*****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)
{

   char  tmpbuf[128];
   char *levelText[] = { "FATAL",
                         "ERROR",
                         "ALERT",
                         "WARNING",
                         "INFO",
                         "TRACE",
                         "USER_DEFINED",
                         "" };



   if(level > _logLevel) {
      
      return FALSE;           /* Logging disabled for the given level. */
   }

   fprintf(Session[channel].LogFile,"\n\n");

  _strdate(tmpbuf);
   fprintf(Session[channel].LogFile,"DATE: %s ",tmpbuf);
   _strtime(tmpbuf);
  fprintf( Session[channel].LogFile,"TIME: %s\n", tmpbuf );

   /* Print the loglevel, filename and the current line number. */
   fprintf(Session[channel].LogFile,"%s: File: %s Line: %d \n", 
          level<=LOGLEVEL_TRACE ? levelText[level-1]:levelText[LOGLEVEL_TRACE],
          GATE_PATH_TO_FILE(file), 
          line);
   
   return TRUE;               /* Logging enabled */

} /* Function gateLog */

/*****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()
{
   DWORD    dwError;

   /* Save the last error */
   dwError = GetLastError();

   sprintf(szGateBuffer, "Error No: 0x%0lx", dwError);

   if( GATE_ERROR_MASK & dwError) {
      /* This is a GATE Error code	 */
      switch(dwError) {
         case ERROR_MNT_MMB_ALLOC_FAILED:
            strcpy(szGateBuffer, "MNT_MMB_ALLOC_FAILED");
            break;
   
         case ERROR_MNT_INVALID_VALUE_TYPE:
            strcpy(szGateBuffer, "MNT_INVALID_VALUE_TYPE");
            break;
   
         case ERROR_MNT_NO_MCD_VERSION_ID:
            strcpy(szGateBuffer, "MNT_NO_MCD_VERSION_ID");
            break;
   
         case ERROR_MNT_NO_TRACE_HANDLE:
            strcpy(szGateBuffer, "MNT_NO_TRACE_HANDLE");
            break;
   
         case ERROR_MNT_CANTCLOSE:
            strcpy(szGateBuffer, "MNT_CANTCLOSE");
            break;
   
         case ERROR_MNT_INVALID_ATTR_KEY:
            strcpy(szGateBuffer, "MNT_INVALID_ATTR_KEY");
            break;
   
         case ERROR_MNT_NO_BOARDS_BY_ATTR:
            strcpy(szGateBuffer, "MNT_NO_BOARDS_BY_ATTR");
            break;
   
         case ERROR_MNT_NO_MEM:
            strcpy(szGateBuffer, "MNT_NO_MEM");
            break;
   
         case ERROR_MNT_MERCURY_STD_MSG:  
            strcpy(szGateBuffer, "MNT_MERCURY_STD_MSG");
            break;
   
         case ERROR_MNT_MERCURY_KRNL:
            strcpy(szGateBuffer, "MNT_MERCURY_KRNL");
            break;
   
         default:
            sprintf(szGateBuffer, "MNT_UNKNOWN_ERR (0x%lx)", dwError);
            break;
      }

   } 
   else {
      /* This is may be a system error code */

      FormatMessage(
                   FORMAT_MESSAGE_FROM_SYSTEM,
                   NULL,
                   dwError,
                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
                   szGateBuffer,
                   GATE_MAX_ERROR_SIZE,
                   NULL );
   }

   return (szGateBuffer);
}


#else GATE_LOG

/*****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, ...)
{
   
} /* Function gateDummyLog */

#endif GATE_LOG		


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -