1 // ------------------------------------------------------------------------------------------------
2 
3 #include <stdarg.h>
4 #include <stdio.h>
5 
6 #include <windows.h>
7 
8 #include <IIEP_Def.H>
9 
10 // ------------------------------------------------------------------------------------------------
11 
12 static bool s_bLogFileOpened = false;
13 
14 // ------------------------------------------------------------------------------------------------
15 // name: DebugLog()
16 // desc:
17 // ------------------------------------------------------------------------------------------------
18 
DebugLog(const char * pcszFormat,...)19 void IIEP::DebugLog(const char *pcszFormat, ...)
20 {
21 #ifdef _DEBUG
22   char cBuffer[0x8000];
23 
24   va_list pcArg;
25 
26   va_start(pcArg, pcszFormat);
27   _vsnprintf(cBuffer, 0x8000, pcszFormat, pcArg);
28   va_end(pcArg);
29 
30   ::OutputDebugStringA(cBuffer);
31 #endif
32 }
33 
34 // ------------------------------------------------------------------------------------------------
35 
DebugLog(const WORD * pcwsFormat,...)36 void IIEP::DebugLog(const WORD *pcwsFormat, ...)
37 {
38 #ifdef _DEBUG
39   WCHAR wcBuffer[0x8000];
40 
41   va_list pcArg;
42 
43   va_start(pcArg, pcwsFormat);
44   _vsnwprintf(wcBuffer, 0x8000, pcwsFormat, pcArg);
45   va_end(pcArg);
46 
47   ::OutputDebugStringW(wcBuffer);
48 #endif
49 }
50 
51 // ------------------------------------------------------------------------------------------------
52 // name: WriteLog()
53 // desc:
54 // ------------------------------------------------------------------------------------------------
55 
WriteLog(const char * pcszFormat,...)56 void IIEP::WriteLog(const char *pcszFormat, ...)
57 {
58   char cBuffer[0x8000];
59 
60   va_list pcArg;
61 
62   va_start(pcArg, pcszFormat);
63   _vsnprintf(cBuffer, 0x8000, pcszFormat, pcArg);
64   va_end(pcArg);
65 
66   FILE *phFile;
67 
68   #define LOG_FILE "C:\\IIEP.LOG"
69 
70   if (s_bLogFileOpened)
71   {
72     phFile = fopen(LOG_FILE, "a+");
73   }
74   else
75   {
76     phFile = fopen(LOG_FILE, "w");
77 
78     s_bLogFileOpened = true;
79   }
80 
81   if (phFile)
82   {
83     fprintf(phFile, cBuffer);
84     fclose(phFile);
85   }
86 }
87 
88 // ------------------------------------------------------------------------------------------------
89 
WriteLog(const WORD * pcwsFormat,...)90 void IIEP::WriteLog(const WORD *pcwsFormat, ...)
91 {
92   WCHAR wcBuffer[0x8000];
93 
94   va_list pcArg;
95 
96   va_start(pcArg, pcwsFormat);
97   _vsnwprintf(wcBuffer, 0x8000, pcwsFormat, pcArg);
98   va_end(pcArg);
99 
100   FILE *phFile;
101 
102   #define LOG_FILE "C:\\IIEP.LOG"
103 
104   if (s_bLogFileOpened)
105   {
106     phFile = fopen(LOG_FILE, "a");
107   }
108   else
109   {
110     phFile = fopen(LOG_FILE, "w");
111 
112     s_bLogFileOpened = true;
113   }
114 
115   if (phFile)
116   {
117     fwprintf(phFile, wcBuffer);
118     fclose(phFile);
119   }
120 }
121 
122 // ------------------------------------------------------------------------------------------------