| 1 |
/* |
/* |
| 2 |
* Copyright (C) 1994-1998 T. Teranishi |
* Copyright (C) 1994-1998 T. Teranishi |
| 3 |
* (C) 2005-2018 TeraTerm Project |
* (C) 2005-2019 TeraTerm Project |
| 4 |
* All rights reserved. |
* All rights reserved. |
| 5 |
* |
* |
| 6 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
| 428 |
if (!ptr->FileOpen) |
if (!ptr->FileOpen) |
| 429 |
return; |
return; |
| 430 |
|
|
| 431 |
if (ptr->LogThread != (HANDLE)-1) { |
if (ptr->LogThread != INVALID_HANDLE_VALUE) { |
| 432 |
// スレッドの終了待ち |
// スレッドの終了待ち |
| 433 |
ret = PostThreadMessage(ptr->LogThreadId, WM_QUIT, 0, 0); |
ret = PostThreadMessage(ptr->LogThreadId, WM_QUIT, 0, 0); |
| 434 |
if (ret != 0) { |
if (ret != 0) { |
| 439 |
code = GetLastError(); |
code = GetLastError(); |
| 440 |
} |
} |
| 441 |
CloseHandle(ptr->LogThread); |
CloseHandle(ptr->LogThread); |
| 442 |
ptr->LogThread = (HANDLE)-1; |
ptr->LogThread = INVALID_HANDLE_VALUE; |
| 443 |
} |
} |
| 444 |
CloseHandle((HANDLE)ptr->FileHandle); |
CloseHandle(ptr->FileHandle); |
| 445 |
} |
} |
| 446 |
|
|
| 447 |
// 遅延書き込み用スレッド |
// 遅延書き込み用スレッド |
| 465 |
case WM_DPC_LOGTHREAD_SEND: |
case WM_DPC_LOGTHREAD_SEND: |
| 466 |
buf = (PCHAR)msg.wParam; |
buf = (PCHAR)msg.wParam; |
| 467 |
buflen = (DWORD)msg.lParam; |
buflen = (DWORD)msg.lParam; |
| 468 |
WriteFile((HANDLE)LogVar->FileHandle, buf, buflen, &wrote, NULL); |
WriteFile(LogVar->FileHandle, buf, buflen, &wrote, NULL); |
| 469 |
free(buf); // ここでメモリ解放 |
free(buf); // ここでメモリ解放 |
| 470 |
break; |
break; |
| 471 |
|
|
| 689 |
// 最初のファイルが設定したサイズでローテートしない問題の修正。 |
// 最初のファイルが設定したサイズでローテートしない問題の修正。 |
| 690 |
// (2016.4.9 yutaka) |
// (2016.4.9 yutaka) |
| 691 |
if (LogVar->RotateMode != ROTATE_NONE) { |
if (LogVar->RotateMode != ROTATE_NONE) { |
| 692 |
size = GetFileSize((HANDLE)LogVar->FileHandle, NULL); |
size = GetFileSize(LogVar->FileHandle, NULL); |
| 693 |
if (size != -1) |
if (size != -1) |
| 694 |
LogVar->ByteCount = size; |
LogVar->ByteCount = size; |
| 695 |
} |
} |
| 736 |
PostThreadMessage(LogVar->LogThreadId, WM_DPC_LOGTHREAD_SEND, (WPARAM)pbuf, size + 2); |
PostThreadMessage(LogVar->LogThreadId, WM_DPC_LOGTHREAD_SEND, (WPARAM)pbuf, size + 2); |
| 737 |
} else { // 直書き。ネットワーク経由だと遅い。 |
} else { // 直書き。ネットワーク経由だと遅い。 |
| 738 |
#endif |
#endif |
| 739 |
WriteFile((HANDLE)LogVar->FileHandle, buf, size, &written_size, NULL); |
WriteFile(LogVar->FileHandle, buf, size, &written_size, NULL); |
| 740 |
WriteFile((HANDLE)LogVar->FileHandle, crlf, crlf_len, &written_size, NULL); |
WriteFile(LogVar->FileHandle, crlf, crlf_len, &written_size, NULL); |
| 741 |
#if 0 |
#if 0 |
| 742 |
} |
} |
| 743 |
#endif |
#endif |
| 846 |
} |
} |
| 847 |
|
|
| 848 |
logfile_lock(); |
logfile_lock(); |
| 849 |
WriteFile((HANDLE)LogVar->FileHandle, buf, size, &wrote, NULL); |
WriteFile(LogVar->FileHandle, buf, size, &wrote, NULL); |
| 850 |
WriteFile((HANDLE)LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // 改行 |
WriteFile(LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // 改行 |
| 851 |
/* Set Line End Flag |
/* Set Line End Flag |
| 852 |
2007.05.24 Gentaro |
2007.05.24 Gentaro |
| 853 |
*/ |
*/ |
| 1054 |
strtime = strelapsed(cv.ConnectedTime); |
strtime = strelapsed(cv.ConnectedTime); |
| 1055 |
break; |
break; |
| 1056 |
} |
} |
| 1057 |
WriteFile((HANDLE)LogVar->FileHandle, "[", 1, &wrote, NULL); |
WriteFile(LogVar->FileHandle, "[", 1, &wrote, NULL); |
| 1058 |
WriteFile((HANDLE)LogVar->FileHandle, strtime, strlen(strtime), &wrote, NULL); |
WriteFile(LogVar->FileHandle, strtime, strlen(strtime), &wrote, NULL); |
| 1059 |
WriteFile((HANDLE)LogVar->FileHandle, "] ", 2, &wrote, NULL); |
WriteFile(LogVar->FileHandle, "] ", 2, &wrote, NULL); |
| 1060 |
} |
} |
| 1061 |
|
|
| 1062 |
/* 2007.05.24 Gentaro */ |
/* 2007.05.24 Gentaro */ |
| 1067 |
eLineEnd = Line_Other; /* clear endmark*/ |
eLineEnd = Line_Other; /* clear endmark*/ |
| 1068 |
} |
} |
| 1069 |
|
|
| 1070 |
WriteFile((HANDLE)LogVar->FileHandle, (PCHAR)&b, 1, &wrote, NULL); |
WriteFile(LogVar->FileHandle, (PCHAR)&b, 1, &wrote, NULL); |
| 1071 |
(LogVar->ByteCount)++; |
(LogVar->ByteCount)++; |
| 1072 |
} |
} |
| 1073 |
} |
} |
| 1305 |
|
|
| 1306 |
do { |
do { |
| 1307 |
if (FileSendHandler.pos == FileSendHandler.end) { |
if (FileSendHandler.pos == FileSendHandler.end) { |
| 1308 |
ReadFile((HANDLE)SendVar->FileHandle, &(FileSendHandler.buf[0]), sizeof(FileSendHandler.buf), &read_bytes, NULL); |
ReadFile(SendVar->FileHandle, &(FileSendHandler.buf[0]), sizeof(FileSendHandler.buf), &read_bytes, NULL); |
| 1309 |
fc = LOWORD(read_bytes); |
fc = LOWORD(read_bytes); |
| 1310 |
FileSendHandler.pos = 0; |
FileSendHandler.pos = 0; |
| 1311 |
FileSendHandler.end = fc; |
FileSendHandler.end = fc; |
| 1384 |
} |
} |
| 1385 |
} |
} |
| 1386 |
else if (! FileReadEOF) { |
else if (! FileReadEOF) { |
| 1387 |
ReadFile((HANDLE)SendVar->FileHandle, &FileByte, 1, &read_bytes, NULL); |
ReadFile(SendVar->FileHandle, &FileByte, 1, &read_bytes, NULL); |
| 1388 |
fc = LOWORD(read_bytes); |
fc = LOWORD(read_bytes); |
| 1389 |
SendVar->ByteCount = SendVar->ByteCount + fc; |
SendVar->ByteCount = SendVar->ByteCount + fc; |
| 1390 |
|
|
| 1391 |
if (FileCRSend && (fc==1) && (FileByte==0x0A)) { |
if (FileCRSend && (fc==1) && (FileByte==0x0A)) { |
| 1392 |
ReadFile((HANDLE)SendVar->FileHandle, &FileByte, 1, &read_bytes, NULL); |
ReadFile(SendVar->FileHandle, &FileByte, 1, &read_bytes, NULL); |
| 1393 |
fc = LOWORD(read_bytes); |
fc = LOWORD(read_bytes); |
| 1394 |
SendVar->ByteCount = SendVar->ByteCount + fc; |
SendVar->ByteCount = SendVar->ByteCount + fc; |
| 1395 |
} |
} |