| 96 |
LogCode_t log_code; |
LogCode_t log_code; |
| 97 |
BOOL bom; |
BOOL bom; |
| 98 |
|
|
| 99 |
|
BOOL FileLog; |
| 100 |
|
BOOL BinLog; |
| 101 |
} TFileVar_; |
} TFileVar_; |
| 102 |
typedef TFileVar_ *PFileVar_; |
typedef TFileVar_ *PFileVar_; |
| 103 |
|
|
| 106 |
|
|
| 107 |
static PFileVar LogVar = NULL; |
static PFileVar LogVar = NULL; |
| 108 |
|
|
|
static BOOL FileLog = FALSE; |
|
|
static BOOL BinLog = FALSE; |
|
|
|
|
| 109 |
static PCHAR cv_LogBuf; |
static PCHAR cv_LogBuf; |
| 110 |
static int cv_LogPtr, cv_LStart, cv_LCount; |
static int cv_LogPtr, cv_LStart, cv_LCount; |
| 111 |
static PCHAR cv_BinBuf; |
static PCHAR cv_BinBuf; |
| 705 |
|
|
| 706 |
if (ts.LogBinary > 0) |
if (ts.LogBinary > 0) |
| 707 |
{ |
{ |
| 708 |
BinLog = TRUE; |
fv->BinLog = TRUE; |
| 709 |
FileLog = FALSE; |
fv->FileLog = FALSE; |
| 710 |
if (! CreateBinBuf()) |
if (! CreateBinBuf()) |
| 711 |
{ |
{ |
| 712 |
return FALSE; |
return FALSE; |
| 713 |
} |
} |
| 714 |
} |
} |
| 715 |
else { |
else { |
| 716 |
BinLog = FALSE; |
fv->BinLog = FALSE; |
| 717 |
FileLog = TRUE; |
fv->FileLog = TRUE; |
| 718 |
if (! CreateLogBuf()) |
if (! CreateLogBuf()) |
| 719 |
{ |
{ |
| 720 |
return FALSE; |
return FALSE; |
| 776 |
StartThread(fv); |
StartThread(fv); |
| 777 |
} |
} |
| 778 |
|
|
| 779 |
if (FileLog) { |
if (fv->FileLog) { |
| 780 |
cv.Log1Byte = LogPut1; |
cv.Log1Byte = LogPut1; |
| 781 |
} |
} |
| 782 |
if (BinLog) { |
if (fv->BinLog) { |
| 783 |
cv.Log1Bin = Log1Bin; |
cv.Log1Bin = Log1Bin; |
| 784 |
cv.LogBinSkip = LogBinSkip; |
cv.LogBinSkip = LogBinSkip; |
| 785 |
} |
} |
| 818 |
*/ |
*/ |
| 819 |
void LogPut1(BYTE b) |
void LogPut1(BYTE b) |
| 820 |
{ |
{ |
| 821 |
|
PFileVar fv = LogVar; |
| 822 |
|
|
| 823 |
cv_LogBuf[cv_LogPtr] = b; |
cv_LogBuf[cv_LogPtr] = b; |
| 824 |
cv_LogPtr++; |
cv_LogPtr++; |
| 825 |
if (cv_LogPtr>=InBuffSize) |
if (cv_LogPtr>=InBuffSize) |
| 826 |
cv_LogPtr = cv_LogPtr-InBuffSize; |
cv_LogPtr = cv_LogPtr-InBuffSize; |
| 827 |
|
|
| 828 |
if (FileLog) |
if (fv->FileLog) |
| 829 |
{ |
{ |
| 830 |
if (cv_LCount>=InBuffSize) |
if (cv_LCount>=InBuffSize) |
| 831 |
{ |
{ |
| 973 |
*/ |
*/ |
| 974 |
static void LogToFile(void) |
static void LogToFile(void) |
| 975 |
{ |
{ |
| 976 |
|
PFileVar fv = LogVar; |
| 977 |
PCHAR Buf; |
PCHAR Buf; |
| 978 |
int Start, Count; |
int Start, Count; |
| 979 |
BYTE b; |
BYTE b; |
| 980 |
|
|
| 981 |
if (FileLog) |
if (fv->FileLog) |
| 982 |
{ |
{ |
| 983 |
Buf = cv_LogBuf; |
Buf = cv_LogBuf; |
| 984 |
Start = cv_LStart; |
Start = cv_LStart; |
| 985 |
Count = cv_LCount; |
Count = cv_LCount; |
| 986 |
} |
} |
| 987 |
else if (BinLog) |
else if (fv->BinLog) |
| 988 |
{ |
{ |
| 989 |
Buf = cv_BinBuf; |
Buf = cv_BinBuf; |
| 990 |
Start = cv_BStart; |
Start = cv_BStart; |
| 1032 |
|
|
| 1033 |
logfile_unlock(); |
logfile_unlock(); |
| 1034 |
|
|
| 1035 |
if (FileLog) |
if (fv->FileLog) |
| 1036 |
{ |
{ |
| 1037 |
cv_LStart = Start; |
cv_LStart = Start; |
| 1038 |
cv_LCount = Count; |
cv_LCount = Count; |
| 1096 |
if (LogVar == NULL) { |
if (LogVar == NULL) { |
| 1097 |
return; |
return; |
| 1098 |
} |
} |
| 1099 |
FileLog = FALSE; |
PFileVar fv = LogVar; |
| 1100 |
BinLog = FALSE; |
fv->FileLog = FALSE; |
| 1101 |
|
fv->BinLog = FALSE; |
| 1102 |
cv.Log1Byte = NULL; |
cv.Log1Byte = NULL; |
| 1103 |
cv.Log1Bin = NULL; |
cv.Log1Bin = NULL; |
| 1104 |
cv.LogBinSkip = NULL; |
cv.LogBinSkip = NULL; |
| 1246 |
if (LogVar != NULL) { |
if (LogVar != NULL) { |
| 1247 |
return FALSE; |
return FALSE; |
| 1248 |
} |
} |
|
if ((FileLog) || (BinLog)) return FALSE; |
|
| 1249 |
|
|
| 1250 |
// |
// |
| 1251 |
PFileVar fv = (PFileVar)malloc(sizeof(TFileVar)); |
PFileVar fv = (PFileVar)malloc(sizeof(TFileVar)); |
| 1275 |
|
|
| 1276 |
BOOL FLogIsOpendText(void) |
BOOL FLogIsOpendText(void) |
| 1277 |
{ |
{ |
| 1278 |
return LogVar != NULL && FileLog; |
return LogVar != NULL && LogVar->FileLog; |
| 1279 |
} |
} |
| 1280 |
|
|
| 1281 |
BOOL FLogIsOpendBin(void) |
BOOL FLogIsOpendBin(void) |
| 1282 |
{ |
{ |
| 1283 |
return LogVar != NULL && BinLog; |
return LogVar != NULL && LogVar->BinLog; |
| 1284 |
} |
} |
| 1285 |
|
|
| 1286 |
void FLogWriteStr(const wchar_t *str) |
void FLogWriteStr(const wchar_t *str) |
| 1452 |
*/ |
*/ |
| 1453 |
int FLogGetCount(void) |
int FLogGetCount(void) |
| 1454 |
{ |
{ |
| 1455 |
if (FileLog) { |
PFileVar fv = LogVar; |
| 1456 |
|
if (fv == NULL) { |
| 1457 |
|
return 0; |
| 1458 |
|
} |
| 1459 |
|
if (fv->FileLog) { |
| 1460 |
return cv_LCount; |
return cv_LCount; |
| 1461 |
} |
} |
| 1462 |
if (BinLog) { |
if (fv->BinLog) { |
| 1463 |
return cv_BCount; |
return cv_BCount; |
| 1464 |
} |
} |
| 1465 |
return 0; |
return 0; |
| 1470 |
*/ |
*/ |
| 1471 |
int FLogGetFreeCount(void) |
int FLogGetFreeCount(void) |
| 1472 |
{ |
{ |
| 1473 |
if (FileLog) { |
PFileVar fv = LogVar; |
| 1474 |
|
if (fv == NULL) { |
| 1475 |
|
return 0; |
| 1476 |
|
} |
| 1477 |
|
if (fv->FileLog) { |
| 1478 |
return InBuffSize - cv_LCount; |
return InBuffSize - cv_LCount; |
| 1479 |
} |
} |
| 1480 |
if (BinLog) { |
if (fv->BinLog) { |
| 1481 |
return InBuffSize - cv_BCount; |
return InBuffSize - cv_BCount; |
| 1482 |
} |
} |
| 1483 |
return 0; |
return 0; |
| 1488 |
*/ |
*/ |
| 1489 |
void FLogWriteFile(void) |
void FLogWriteFile(void) |
| 1490 |
{ |
{ |
| 1491 |
|
PFileVar fv = LogVar; |
| 1492 |
|
if (fv == NULL) { |
| 1493 |
|
return; |
| 1494 |
|
} |
| 1495 |
if (cv_LogBuf!=NULL) |
if (cv_LogBuf!=NULL) |
| 1496 |
{ |
{ |
| 1497 |
if (FileLog) { |
if (fv->FileLog) { |
| 1498 |
LogToFile(); |
LogToFile(); |
| 1499 |
} |
} |
| 1500 |
} |
} |
| 1501 |
|
|
| 1502 |
if (cv_BinBuf!=NULL) |
if (cv_BinBuf!=NULL) |
| 1503 |
{ |
{ |
| 1504 |
if (BinLog) { |
if (fv->BinLog) { |
| 1505 |
LogToFile(); |
LogToFile(); |
| 1506 |
} |
} |
| 1507 |
} |
} |