📄 erawin.cpp
字号:
erlMsg = new char[ERM_BUF_SIZ];
erlWarn = new char[ERM_BUF_SIZ];
va_start (erlArgs, pasFormatStr);
vsprintf(erlMsg,pasFormatStr,erlArgs);
va_end (erlArgs);
erlFptr = eraGetFptr();
pasLocationPtr = eraGetLocStr(pasLocationPtr);
if (erlFptr)
{
strcpy(erlWarn,erlMsg);
erlWptr = erlWarn;
while (*erlWptr)
{
if ((*erlWptr == '\r') ||
(*erlWptr == '\n') ||
(*erlWptr == '\t'))
{
*erlWptr = ' ';
}
erlWptr++;
}
fprintf(erlFptr, "LOG %s:%s\n",pasLocationPtr,erlWarn);
FIUfclose(&erlFptr);
}
if (ermShowAllErrors)
{
MessageBox ( ermHparent,
erlMsg,
pasLocationPtr,
MB_OK | MB_ICONINFORMATION | MB_TASKMODAL );
}
LIMDELA(erlMsg);
}
VOID_RTN ERAparameterError
( CHAR *pasLocationPtr ) // Function where error occurred
{
ERAerrorLog( pasLocationPtr, "Invalid Parameter" );
}
/*\p*******************************************************************/
/* */
/* NAME: ERAerrorTerm */
/* */
/* PURPOSE: to terminate use of the error handler. */
/* */
/* */
/* */
/* INTERFACE DEFINITION: */
/* variable def. expected/description */
/* ------------ ----- ------------------------------------- */
/* erlErr FNC (SUCCEEDED_ / FAILED_) error return */
/*\p*******************************************************************/
STAT_TYPE ERAerrorTerm()
{ /* ERAerrorTerm procedure */
/**********************************************************************/
/* Local Constant Declarations */
/**********************************************************************/
/**********************************************************************/
/* Local Variable Declarations */
/**********************************************************************/
STAT_TYPE erlErr=SUCCEEDED_;
/**********************************************************************/
/* Procedure Body */
/**********************************************************************/
LIMDELA(ermFileName);
///////////////////////////////////////
// Parent window
// no longer available.
// Dialogs may remain enabled,
// however, because a value of NULL
// for the parent window is valid.
ermHparent = NULL;
return(erlErr);
} /* end ERAerrorTerm */
/*\p*******************************************************************/
/* */
/* NAME: ERAerrorReport */
/* */
/* PURPOSE: Allow routines to log or display and error message. */
/* This procedure transmits an IPC to the error handler process. */
/* Several commands are aavailable. See errorC.inc for constants */
/* used to specify the command paimeter. See "Mini-QUIC Error */
/* Reporter and Logger" document for a description of the various */
/* commands */
/* */
/* INPUTS: */
/* variable type expected description */
/* -------- ---- -------- ----------- */
/* pasCommand ERP_CMD_TY constant from errorC.inc */
/* pasLocationPtr ERP_LOC_TY * string where error occurred*/
/* pasErrorTextPtr ERP_TEXT_TY * string error Text */
/* */
/* OUTPUTS: */
/* variable type expected description */
/* -------- ---- -------- ----------- */
/* None */
/* GLOBALS: */
/* variable type expected description */
/* -------- ---- -------- ----------- */
/* None */
/*\p*******************************************************************/
VOID_RTN ERAerrorReport
( ERP_CMD_TY pasCommand,
CHAR *pasLocationPtr,
CHAR *pasFormatStr,
... ) /* macro that defines va_alist */
{ /* ERAerrorReport procedure */
/**********************************************************************/
/* LOCAL CONSTANT DECLARATIONS */
/**********************************************************************/
/**********************************************************************/
/* LOCAL VARIABLE DECLARATIONS */
/**********************************************************************/
int erlCmd;
va_list erlArgs;
CHAR *erlMsg;
CHAR *erlWarn;
CHAR *erlWptr;
FILE *erlFptr;
BOOLEAN erlReported;
int erlIcon;
/**********************************************************************/
/* Procedure Body */
/**********************************************************************/
erlMsg = new CHAR[ERM_BUF_SIZ];
erlWarn = new CHAR[ERM_BUF_SIZ];
va_start (erlArgs, pasFormatStr);
vsprintf(erlMsg,pasFormatStr,erlArgs);
va_end (erlArgs);
pasLocationPtr = eraGetLocStr(pasLocationPtr);
erlFptr = eraGetFptr();
if (erlFptr)
{
/****************************************
* In a file a report resides entirely
* on one LINE.
*/
strcpy(erlWarn,erlMsg);
erlWptr = erlWarn;
while (*erlWptr)
{
if ((*erlWptr == '\r') ||
(*erlWptr == '\n') ||
(*erlWptr == '\t'))
{
*erlWptr = ' ';
}
erlWptr++;
}
fprintf(erlFptr, "REPORT %s:%s\n",pasLocationPtr,erlWarn);
FIUfclose(&erlFptr);
}
erlReported = FALSE_;
erlIcon = MB_ICONASTERISK;
switch( pasCommand )
{
case ER_WARNING:
sprintf(erlWarn, "WARNING:%s", pasLocationPtr);
break;
case ER_REPORT:
case ER_INFO:
sprintf(erlWarn, "INFORMATION:%s", pasLocationPtr);
break;
case ER_ABORT:
sprintf(erlWarn, "ABORT ASAP!:%s", pasLocationPtr);
erlIcon = MB_ICONSTOP;
break;
case ER_FATAL:
sprintf(erlWarn, "FATAL ERROR!!:%s", pasLocationPtr);
strcat(erlMsg,"\r\nEXIT NOW?");
erlCmd = MessageBox( ermHparent,
erlMsg,
erlWarn,
MB_OKCANCEL | MB_ICONHAND | MB_TASKMODAL );
erlReported = TRUE_;
if (erlCmd == IDOK)
{
PostQuitMessage(-1);
}
break;
default:
sprintf(erlWarn, "UNDEFINED ID:%s", pasLocationPtr);
break;
}
if (!erlReported)
{
MessageBox( ermHparent,
erlMsg,
erlWarn,
MB_OK | erlIcon | MB_TASKMODAL );
}
LIMDELA(erlMsg);
LIMDELA(erlWarn);
} /* ERAerrorReport end */
/*\p********************************************************************
** **
** **
NAME: ERAsetWindowParent
PURPOSE: to set the parent window for this error handling
package based on Microsoft Windows.
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** erlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
void ERAsetWindowParent( UINT pasHparent )
{ /* ERAsetWindowParent procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
/************************* Procedure Body *****************************/
ermHparent = (HWND)pasHparent;
} /* ERAsetWindowParent end */
/*\p********************************************************************
** **
** **
NAME: ERAdisplayLogErrors
PURPOSE: to enable or disable the display of all errors
logged. Helpful to enable this when first bringing
up software. Once "stable", disable (default), and
just log errors to a file.
** **
** **
**\p*******************************************************************/
VOID_RTN ERAdisplayLogErrors( int pasDisplayAll )
{ /* ERAdisplayLogErrors procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
/************************* Procedure Body *****************************/
ermShowAllErrors = pasDisplayAll;
} /* ERAdisplayLogErrors end */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -