-
Notifications
You must be signed in to change notification settings - Fork 10
/
RKLog.cpp
63 lines (57 loc) · 1.19 KB
/
RKLog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "RKLog.h"
bool CRKLog::GetEnableLog()
{
return m_enable;
}
void CRKLog::SetEnableLog(bool bEnable)
{
m_enable = bEnable;
}
CRKLog::CRKLog(bool enable)
{
EnableLog.setContainer(this);
EnableLog.getter(&CRKLog::GetEnableLog);
EnableLog.setter(&CRKLog::SetEnableLog);
m_enable = enable;
}
CRKLog::~CRKLog()
{
}
void CRKLog::Record(const tchar* lpFmt,...)
{
/************************* Êä³öµ½ÈÕÖ¾ ***********************/
va_list ap;
va_start(ap, lpFmt);
printf("librkupdate_");
vfprintf(stdout, lpFmt, ap);
printf("\r\n");
va_end(ap);
}
bool CRKLog::SaveBuffer(tstring fileName,PBYTE lpBuffer,DWORD dwSize)
{
FILE *file;
file = fopen(fileName.c_str(),_T("wb+"));
if (!file)
{
return false;
}
fwrite(lpBuffer,1,dwSize,file);
fclose(file);
return true;
}
void CRKLog::PrintBuffer(tstring &strOutput,PBYTE lpBuffer,DWORD dwSize,UINT uiLineCount)
{
UINT i,count;
tchar strHex[32];
strOutput = _T("");
for (i=0,count=0;i<dwSize;i++,count++)
{
if (count>=uiLineCount)
{
strOutput += _T("\r\n");
count = 0;
}
sprintf(strHex,_T("%02X"),lpBuffer[i]);
strOutput = strOutput + _T(" ") + strHex;
}
}