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

📄 erawin.cpp

📁 用c++变得一个测量财富的+游戏
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*\t*******************************************************************/
/*    Creation Date .......  Thu  05-06-1993  12:52:42                */
/*    Filename  ...........  erawin.cpp                               */
/*    Project .............  Parts Database                           */
/*    Author  .............  Matthew J. W. Ratcliff                   */
/*    Language  ...........  C++                                      */
/*    Operating System  ...  DOS/Windows                              */
/*    Processor  ..........  ERA - Error Logging Application          */
/*    Function:         Windows 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 <windows.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>


/********************** Constant Include Files ************************/
#include "liidSys.h"
#include "liustrg.h"
#include "erapdefs.h" // era public definitions
#include "fipfile.h"

/***************** 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 "fiufile.h"
#include "eraprpt.h"



/*\i*/

/*\m********************************************************************
**                       Module Declarations
***********************************************************************/

/************************* Module Constants ***************************/

#define  ERM_STRLEN 240
#define  ERM_BUF_SIZ 4096

#define  ERM_ERR_FILE "error.log"

#define  ERM_DEBUG 1 // 1=debug 0=normal

/**************************************************
* Errors are logged to stdout by default,
* unless a call to ERAsetErrorFile() is
* made to change it.
*/

LOCAL char    *ermFileName = NULL;


/****************************************
* Parent window of application, for
* creating message boxes.
*/

LOCAL HWND            ermHparent              = NULL;
LOCAL int             ermShowAllErrors        = FALSE_;

/************************* Module Variables ***************************/

/************************* Module Procedures **************************/

/*\m*/

char *eraGetLocStr( char *pasLocationStr )
{
if (!pasLocationStr) return("FYI");
else                 return(pasLocationStr);
}
/****************************************
* NAME: eraGetFptr
*
* If file name specified previously,
* then open the error file for append
* and return a file pointer to it,
* else return NULL, indicating no
* file logging of error(s).
*/

FILE *eraGetFptr()
{
FILE *erlFptr;

if (ermFileName)
  {
  erlFptr = FIUfopen(ermFileName,"a");
  }
else
  {
  erlFptr = NULL;
  }
return(erlFptr);
}



/*\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 */
FILE                   *erlFptr;

/************************* Procedure Body *****************************/

if (ermFileName) LIMDELA(ermFileName);
if (pasFileName != NULL)
  {
  if (*pasFileName)
    {
    ermFileName = new char[strlen(pasFileName)+1];
    strcpy(ermFileName,pasFileName);
    erlFptr = FIUfopen(ermFileName,pasFopenMode);
    if (erlFptr == NULL)
      {
      MessageBox( ermHparent,
                  "Can't Open Error File",
                  pasFileName, MB_OK );
      LIMDELA(ermFileName);
      erlErr = FAILED_;
      }
    else
      {
      FIUfclose(&erlFptr);
      }
    }
  }

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 = SUCCEEDED_;


/**********************************************************************/
/*                            Procedure Body                          */
/**********************************************************************/

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                                                       */
/*  GLOBALS:                                                          */
/*         variable       type        expected         description    */
/*         --------       ----        --------         -----------    */
/*         None                                                       */
/*\p*******************************************************************/

VOID_RTN ERAerrorLog
(    CHAR *pasLocationPtr,       // Function where error occurred
     CHAR *pasFormatStr,         // 'printf' format string
     ...   )                     //  macro that defines va_alist

{ /* ERAerrorLog  procedure */

/**********************************************************************/
/*                        LOCAL CONSTANT DECLARATIONS                 */
/**********************************************************************/


/**********************************************************************/
/*                        LOCAL VARIABLE DECLARATIONS                 */
/**********************************************************************/

va_list  erlArgs;
CHAR     *erlMsg;
CHAR     *erlWarn;
CHAR     *erlWptr;
FILE     *erlFptr;
/**********************************************************************/
/*                            Procedure Body                          */
/**********************************************************************/

⌨️ 快捷键说明

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