📄 erapprtf.cpp
字号:
/*\t*******************************************************************/
/* Creation Date ....... Thu 05-06-1993 12:52:42 */
/* Filename ........... erapprtf.cpp */
/* Project ............. Parts Database */
/* Author ............. Matthew J. W. Ratcliff */
/* Language ........... C++ */
/* Operating System ... DOS */
/* Processor .......... ERA - Error Logging Application */
/* Function: DOS Error logging utility. */
/* Pass in procedure name or NULL. Pass in "printf" style */
/* argument list and associated arguments. If error logging */
/* enabled, errors are sent to associated log file too. */
/* */
/*\t*******************************************************************/
/*\r********************************************************************
** Revision History
***********************************************************************/
/*
Date By Change Description
dd-mmm-yy nnn text
--------- ---- -----------------------------------------------
**\r*/
/*\i********************************************************************
** Module Include Files
***********************************************************************/
/*********************** System Include Files *************************/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
/********************** Constant Include Files ************************/
#include "liidSys.h"
#include "erapdefs.h" // era public definitions
/***************** External Variable Include Files ********************/
/***************** External Procedure Include Files *******************/
#define NOVAR_DEF // Include prototypes, except for varargs
// prototypes. Can't prototype vararg functions
// for the source file they're defined in.
#include "eraprpt.h"
/*\m********************************************************************
** Module Declarations
***********************************************************************/
/************************* Module Constants ***************************/
#define ERM_ERR_FILE "error.log"
/************************* Module Variables ***************************/
/**************************************************
* Errors are logged to stdout by default,
* unless a call to ERAsetErrorFile() is
* made to change it.
*/
FILE *ermUserFile = stdout;
int ermCloseFlag= FALSE_;
LOCAL int ermShowAllErrors = FALSE_;
/************************* Module Procedures **************************/
/*\m*/
/*\p********************************************************************
** **
** **
NAME: ERAsetErrorFile
PURPOSE: to set an error file for output of
"fprintf()" error messages. If fail, use
'stderr' for error output. The string pasFopenMode
is "w" to overwrite any existing error log file and
"a" is to append to an error file, if it exists.
Output to pasFileName==
--------- -----------------
stdout "stdout"
stderr "stderr"
FILE.TXT "FILE.TXT"
If MSDOS
stdprn "stdprn" - system line printer
** **
** **
** INTERFACE DEFINITION: **
** variable def. expected/description **
** ------------ ----- ------------------------------------- **
** erlErr FNC (SUCCEEDED_ / FAILED_) error return **
**\p*******************************************************************/
STAT_TYPE ERAsetErrorFile
( CHAR *pasFileName, /* file name or NULL for default "error.log" */
CHAR *pasFopenMode ) /* "w" or "a" usually */
{ /* ERAsetErrorFile procedure */
/******************* Local Constant Declarations **********************/
/******************* Local Variable Declarations **********************/
STAT_TYPE erlErr=SUCCEEDED_; /* Iniz error return value */
/************************* Procedure Body *****************************/
ermCloseFlag = FALSE_; /* NO need to close on terminate */
if (strcmp(pasFileName,"stderr") == 0)
{
ermUserFile = stderr;
}
else if (strcmp(pasFileName,"stdout") == 0)
{
ermUserFile = stdout;
}
else if (strcmp(pasFileName, "stdprn") == 0)
{
ermUserFile = stdprn;
}
else
{
ermUserFile = fopen( pasFileName, pasFopenMode);
if (ermUserFile == NULL)
{
ermUserFile = stderr;
fprintf(stderr,
"Failed to open error log file %s, using 'stderr' instead\n",
pasFileName );
erlErr = FAILED_;
}
else
{
ermCloseFlag= TRUE_;
}
}
return(erlErr);
} /* ERAsetErrorFile end */
/*\p*******************************************************************/
/* */
/* NAME: ERAerrorInit */
/* */
/* PURPOSE: Initialize the error Handler. */
/* */
/* */
/* INPUTS: */
/* variable type expected description */
/* -------- ---- -------- ----------- */
/* None */
/* */
/* OUTPUTS: */
/* variable type expected description */
/* -------- ---- -------- ----------- */
/* None */
/* GLOBALS: */
/* variable type expected description */
/* -------- ---- -------- ----------- */
/* None */
/*\p*******************************************************************/
STAT_TY ERAerrorInit( CHAR *pasLocationStr )
{ /* ERAerrorInit procedure */
/**********************************************************************/
/* LOCAL CONSTANT DECLARATIONS */
/**********************************************************************/
/**********************************************************************/
/* LOCAL VARIABLE DECLARATIONS */
/**********************************************************************/
STAT_TYPE erlErr;
/**********************************************************************/
/* Procedure Body */
/**********************************************************************/
erlErr = SUCCEEDED_;
erlErr = ERAsetErrorFile( pasLocationStr, "w" );
return(erlErr);
}
/*\p*******************************************************************/
/* */
/* NAME: ERAerrorLog */
/* */
/* PURPOSE: Allow routines to log an error message in the log file. */
/* This procedure transmits an IPC to the error handler process. */
/* */
/* */
/* INPUTS: */
/* variable type expected description */
/* -------- ---- -------- ----------- */
/* pasLocationPtr ERP_LOC_TY * string where err occured */
/* pasErrorTextPtr ERP_TEXT_TY * string error Text */
/* */
/* OUTPUTS: */
/* variable type expected description */
/* -------- ---- -------- ----------- */
/* None */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -