| 64 |
#define IdProtoTimeOutProc 9 |
#define IdProtoTimeOutProc 9 |
| 65 |
#define IdProtoCancel 10 |
#define IdProtoCancel 10 |
| 66 |
|
|
| 67 |
|
/* |
| 68 |
|
Line Head flag for timestamping |
| 69 |
|
2007.05.24 Gentaro |
| 70 |
|
*/ |
| 71 |
|
enum enumLineEnd { |
| 72 |
|
Line_Other = 0, |
| 73 |
|
Line_LineHead = 1, |
| 74 |
|
Line_FileHead = 2, |
| 75 |
|
}; |
| 76 |
|
|
| 77 |
|
enum enumLineEnd eLineEnd = Line_LineHead; |
| 78 |
|
|
| 79 |
BOOL LoadTTFILE() |
BOOL LoadTTFILE() |
| 80 |
{ |
{ |
| 81 |
BOOL Err; |
BOOL Err; |
| 268 |
{ |
{ |
| 269 |
char buf[MAXPATHLEN], buf2[MAXPATHLEN], *p = c; |
char buf[MAXPATHLEN], buf2[MAXPATHLEN], *p = c; |
| 270 |
|
|
| 271 |
|
memset(buf, 0, sizeof(buf)); |
| 272 |
|
|
| 273 |
while(*p != '\0') { |
while(*p != '\0') { |
| 274 |
if (*p == '&' && *(p+1) != '\0') { |
if (*p == '&' && *(p+1) != '\0') { |
| 275 |
switch (*(p+1)) { |
switch (*(p+1)) { |
| 391 |
cv.LCount = 0; |
cv.LCount = 0; |
| 392 |
|
|
| 393 |
HelpId = HlpFileLog; |
HelpId = HlpFileLog; |
| 394 |
|
/* 2007.05.24 Gentaro */ |
| 395 |
|
eLineEnd = Line_LineHead; |
| 396 |
|
|
| 397 |
if (ts.Append > 0) |
if (ts.Append > 0) |
| 398 |
{ |
{ |
| 399 |
LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE); |
LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE); |
| 400 |
if (LogVar->FileHandle>0) |
if (LogVar->FileHandle>0){ |
| 401 |
_llseek(LogVar->FileHandle,0,2); |
_llseek(LogVar->FileHandle,0,2); |
| 402 |
|
/* 2007.05.24 Gentaro |
| 403 |
|
If log file already exists, |
| 404 |
|
a newline is inserted before the first timestamp. |
| 405 |
|
*/ |
| 406 |
|
eLineEnd = Line_FileHead; |
| 407 |
|
} |
| 408 |
else |
else |
| 409 |
LogVar->FileHandle = _lcreat(LogVar->FullName,0); |
LogVar->FileHandle = _lcreat(LogVar->FullName,0); |
| 410 |
} |
} |
| 527 |
logfile_lock(); |
logfile_lock(); |
| 528 |
WriteFile((HANDLE)LogVar->FileHandle, buf, size, &wrote, NULL); |
WriteFile((HANDLE)LogVar->FileHandle, buf, size, &wrote, NULL); |
| 529 |
WriteFile((HANDLE)LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // 改行 |
WriteFile((HANDLE)LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // 改行 |
| 530 |
|
/* Set Line End Flag |
| 531 |
|
2007.05.24 Gentaro |
| 532 |
|
*/ |
| 533 |
|
eLineEnd = Line_LineHead; |
| 534 |
logfile_unlock(); |
logfile_unlock(); |
| 535 |
} |
} |
| 536 |
|
|
| 568 |
{ |
{ |
| 569 |
// 時刻を書き出す(2006.7.23 maya) |
// 時刻を書き出す(2006.7.23 maya) |
| 570 |
// 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka) |
// 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka) |
| 571 |
if (ts.LogTimestamp && |
/* 2007.05.24 Gentaro */ |
| 572 |
(Start == 1 || Buf[Start-2] == 0x0a)) { |
if ( ts.LogTimestamp && eLineEnd ) { |
| 573 |
#if 0 |
#if 0 |
| 574 |
SYSTEMTIME LocalTime; |
SYSTEMTIME LocalTime; |
| 575 |
GetLocalTime(&LocalTime); |
GetLocalTime(&LocalTime); |
| 584 |
time_t tick = time(NULL); |
time_t tick = time(NULL); |
| 585 |
char *strtime = ctime(&tick); |
char *strtime = ctime(&tick); |
| 586 |
#endif |
#endif |
| 587 |
|
/* 2007.05.24 Gentaro */ |
| 588 |
// write to file |
if( eLineEnd == Line_FileHead ){ |
| 589 |
if (Start == 1 && ts.Append) { |
_lwrite(LogVar->FileHandle,"\r\n",2); |
|
_lwrite(LogVar->FileHandle,"\r\n",strlen("\r\n")); |
|
| 590 |
} |
} |
| 591 |
_lwrite(LogVar->FileHandle,"[",1); |
_lwrite(LogVar->FileHandle,"[",1); |
| 592 |
// 変換した文字列の終端に \n が含まれているので取り除く。 |
// 変換した文字列の終端に \n が含まれているので取り除く。 |
| 593 |
_lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1); |
_lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1); |
| 594 |
_lwrite(LogVar->FileHandle,"] ",2); |
_lwrite(LogVar->FileHandle,"] ",2); |
| 595 |
} |
} |
| 596 |
|
|
| 597 |
|
/* 2007.05.24 Gentaro */ |
| 598 |
|
if( b == 0x0a ){ |
| 599 |
|
eLineEnd = Line_LineHead; /* set endmark*/ |
| 600 |
|
} |
| 601 |
|
else { |
| 602 |
|
eLineEnd = Line_Other; /* clear endmark*/ |
| 603 |
|
} |
| 604 |
|
|
| 605 |
_lwrite(LogVar->FileHandle,(PCHAR)&b,1); |
_lwrite(LogVar->FileHandle,(PCHAR)&b,1); |
| 606 |
(LogVar->ByteCount)++; |
(LogVar->ByteCount)++; |
| 1276 |
|
|
| 1277 |
/* |
/* |
| 1278 |
* $Log$ |
* $Log$ |
| 1279 |
|
* Revision 1.12 2007/05/25 09:56:05 yutakapon |
| 1280 |
|
* タイムスタンプ付きログで1KBごとに不要な改行が入るバグを修正。 |
| 1281 |
|
* |
| 1282 |
|
* Revision 1.11 2007/05/14 14:07:14 maya |
| 1283 |
|
* バッファをクリアしていないので落ちる問題を修正した。 |
| 1284 |
|
* |
| 1285 |
* Revision 1.10 2007/05/14 13:29:58 maya |
* Revision 1.10 2007/05/14 13:29:58 maya |
| 1286 |
* ログファイル名中の &h を、接続中のホスト名に変換する機能を追加した。 |
* ログファイル名中の &h を、接続中のホスト名に変換する機能を追加した。 |
| 1287 |
* |
* |