My CLOG implementation

zhaozj2021-02-08  220

Corresponding to an out-name work.

############ log.h #################

/ / =========================================================================================================================================================================================== ==================================== //// homework from belgium not licensed Software // 1999 - 2000 No Rights Reserved //// = ============================================================================================================================================================================================================= ========================================== ============== //// description: Declaration of clog class //// classes: clog //// Information: // compiler (s): Visual C 6.0 // Target (s): windows 95/98 and windows nt (x86) // editor: Visual C 6.0 Internal Editor //// History // VERS. Date Aut. Type Description // -------------- ---- ------ - ----------------------------------------- // 1.00 22 05 1999 BG Create Original // 1.01 20 12 2000 Hewen Add // 1.03 24 10 2001 Hewen Add ////////// ========================== =======================================

=============== # iFNDef _Log_h_included __ # define _log_h_included__

/ / =========================================================================================================================================================================================== =========================== // macros and typedefs // ================ ============================================================================================================================================================================================================= =========

/ / =========================================================================================================================================================================================== ==================================== // // Class: Clog // Author (s): bart gysens //// Description: Declaration of the clog class //// Comments: none /////.com: 1.00: Create // 1.01: Hewen add // 1.03: Hewen add // =========== ============================================================================================================================================================================================================= ================ Class Clog {// Member functions public: clog ();

Public: static void Putlog (lpctstr pfmt, ...); //1.01 static void setfile (lpctstr filename); // 1.03 static void delete (void); // 1.04 static void Putlogbinary (Void * Pmem, DWord Length, Bool Btxt); Static Void MessageBox (lpctstr pfmt, ...);

}

#ENDIF / / _LOG_H_INCLUDED__

############ log.cpp ####################

/ / =========================================================================================================================================================================================== ==================================== //// homework from belgium not licensed Software // 1999 - 2000 No Rights Reserved //// = ============================================================================================================================================================================================================= ==================================================================================================================== //// description: Declaration of clog class //// classes: clog //// Information: // compiler (s): Visual C 6.0 // Target (s): windows 95/98 and windows nt (x86) // editor: Visual C 6.0 Internal Editor //// History // VERS. Date Aut. Type Description // -------------- ---- ------ - ----------------------------------------- // 1.00 22 05 1999 BG Create Original // 1.01 20 12 2000 Hewen Add // 1.03 24 10 2001 Hewen Add // 1.04 16 06 2003 Hewen Add my birthday // ===================== =====================================

================= # include "stdafx.h" #include "stdio.h" // 1.01 # include "stdlib.h" #include "log.h"

/ / =========================================================================================================================================================================================== =========================== // macros and typedefs // ================ ============================================================================================================================================================================================================= =========

/ / =========================================================================================================================================================================================== ==================================== // // Class: Clog // Author (s): bart gysens //// Description: Declaration of the clog class //// Comments: none /////.com: 1.00: Create // 1.01: Hewen add // 1.03: Hewen add // =========== ============================================================================================================================================================================================================= ================ // 1.01static char Glogfilename [_MAX_PATH] = "log.txt";

CLOG :: clog () {}

Void Clog :: Putlog (lpctstr pfmt, ...) {// 1.02 # ifdef _debug_log

File * pfile; // 1.01 pfile = fopen (glogfilename, "ab"); // 1.00 // pfile = fopen ("c: //log.txt", "a");

IF (pfile! = null) {va_list arg; va_start (arg, pfmt); vfprintf (pfile, pfmt, arg); va_end (arg); fclose (pfile);} #ENDIF}

//1.01void clog :: setfile (lpctstr filename) {// 1.02 # ifdef _debug_log strncpy (GlogfileName, FileName, _MAX_PATH); # ENDIF}

//1.03void clog :: delete (void) {# ifdef _debug_log deletefile (glogfilename); # endif}

//1.04void clog :: Putlogbinary (Void * PMEM, DWORD LENGTH, BOOL BTXT) {# IFDEF _Debug_log file * pfile; int ROW, R, I, J; IF (PMEM == Null || length <= 0) Return ;

Pfile = fopen (glogfilename, "ab");

Unsigned char * p = (unsigned char *) PMEM;

UNSIGNED Char txtbuff [16];

IF (pfile! = null) {if (! btxt) {FWRITE (P, Length, 1, pfile);} else {row = length / 16; r = length% 16;

For (i = 0; i

FPRINTF (Pfile, "|"); FWRITE (TXTBUF, 16, 1, PFILE); FPRINTF (Pfile, "/ R / N");}

FPRINTF (Pfile, "% 04x:", ROW); for (i = 0; i <16; i ) {if (i