| 224 |
extern "C" { |
extern "C" { |
| 225 |
void LogStart() |
void LogStart() |
| 226 |
{ |
{ |
| 227 |
LONG Option; |
LONG Option; |
| 228 |
|
|
| 229 |
if ((FileLog) || (BinLog)) return; |
if ((FileLog) || (BinLog)) return; |
| 230 |
|
|
| 231 |
if (! LoadTTFILE()) return; |
if (! LoadTTFILE()) return; |
| 232 |
if (! NewFileVar(&LogVar)) |
if (! NewFileVar(&LogVar)) |
| 233 |
{ |
{ |
| 234 |
FreeTTFILE(); |
FreeTTFILE(); |
| 235 |
return; |
return; |
| 236 |
} |
} |
| 237 |
LogVar->OpId = OpLog; |
LogVar->OpId = OpLog; |
| 238 |
|
|
| 239 |
if (strlen(&(LogVar->FullName[LogVar->DirLen]))==0) |
if (strlen(&(LogVar->FullName[LogVar->DirLen]))==0) |
| 240 |
{ |
{ |
| 241 |
Option = MAKELONG(ts.TransBin,ts.Append); |
// LOWORD |
| 242 |
if (! (*GetTransFname)(LogVar, ts.FileDir, GTF_LOG, &Option)) |
// 0x0001 = Binary |
| 243 |
{ |
// HIWORD |
| 244 |
FreeFileVar(&LogVar); |
// 0x0001 = Append |
| 245 |
FreeTTFILE(); |
// 0x1000 = plain text (2005.2.20 yutaka) |
| 246 |
return; |
// 0x2000 = timestamp (2006.7.23 maya) |
| 247 |
} |
// teraterm.iniの設定を見てからデフォルトオプションを決める。(2005.5.7 yutaka) |
| 248 |
ts.TransBin = LOWORD(Option); |
Option = MAKELONG(ts.TransBin,ts.Append | |
| 249 |
ts.Append = HIWORD(Option); |
(0x1000 * ts.LogTypePlainText) | |
| 250 |
} |
(0x2000 * ts.LogTimestamp)); |
| 251 |
else |
|
| 252 |
(*SetFileVar)(LogVar); |
// ログのデフォルトファイル名を設定 (2006.8.28 maya) |
| 253 |
|
strncat(LogVar->FullName, ts.LogDefaultName, sizeof(LogVar->FullName)); |
| 254 |
|
ParseStrftimeFileName(LogVar->FullName); |
| 255 |
|
|
| 256 |
if (ts.TransBin > 0) |
if (! (*GetTransFname)(LogVar, ts.FileDir, GTF_LOG, &Option)) |
| 257 |
{ |
{ |
| 258 |
BinLog = TRUE; |
FreeFileVar(&LogVar); |
| 259 |
FileLog = FALSE; |
FreeTTFILE(); |
| 260 |
if (! CreateBinBuf()) |
return; |
| 261 |
{ |
} |
| 262 |
FileTransEnd(OpLog); |
ts.TransBin = LOWORD(Option); |
| 263 |
return; |
ts.Append = HIWORD(Option); |
|
} |
|
|
} |
|
|
else { |
|
|
BinLog = FALSE; |
|
|
FileLog = TRUE; |
|
|
if (! CreateLogBuf()) |
|
|
{ |
|
|
FileTransEnd(OpLog); |
|
|
return; |
|
|
} |
|
|
} |
|
|
cv.LStart = cv.LogPtr; |
|
|
cv.LCount = 0; |
|
| 264 |
|
|
| 265 |
HelpId = HlpFileLog; |
if (ts.Append & 0x1000) { |
| 266 |
if (ts.Append > 0) |
ts.LogTypePlainText = 1; |
| 267 |
{ |
} else { |
| 268 |
LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE); |
ts.LogTypePlainText = 0; |
| 269 |
if (LogVar->FileHandle>0) |
} |
| 270 |
_llseek(LogVar->FileHandle,0,2); |
|
| 271 |
else |
if (ts.Append & 0x2000) { |
| 272 |
LogVar->FileHandle = _lcreat(LogVar->FullName,0); |
ts.LogTimestamp = 1; |
| 273 |
} |
} |
| 274 |
else |
else { |
| 275 |
LogVar->FileHandle = _lcreat(LogVar->FullName,0); |
ts.LogTimestamp = 0; |
| 276 |
LogVar->FileOpen = (LogVar->FileHandle>0); |
} |
| 277 |
if (! LogVar->FileOpen) |
|
| 278 |
{ |
ts.Append &= 0x1; // 1bitにマスクする |
| 279 |
FileTransEnd(OpLog); |
|
| 280 |
return; |
} |
| 281 |
} |
else |
| 282 |
LogVar->ByteCount = 0; |
(*SetFileVar)(LogVar); |
| 283 |
|
|
| 284 |
|
if (ts.TransBin > 0) |
| 285 |
|
{ |
| 286 |
|
BinLog = TRUE; |
| 287 |
|
FileLog = FALSE; |
| 288 |
|
if (! CreateBinBuf()) |
| 289 |
|
{ |
| 290 |
|
FileTransEnd(OpLog); |
| 291 |
|
return; |
| 292 |
|
} |
| 293 |
|
} |
| 294 |
|
else { |
| 295 |
|
BinLog = FALSE; |
| 296 |
|
FileLog = TRUE; |
| 297 |
|
if (! CreateLogBuf()) |
| 298 |
|
{ |
| 299 |
|
FileTransEnd(OpLog); |
| 300 |
|
return; |
| 301 |
|
} |
| 302 |
|
} |
| 303 |
|
cv.LStart = cv.LogPtr; |
| 304 |
|
cv.LCount = 0; |
| 305 |
|
|
| 306 |
if (! OpenFTDlg(LogVar)) |
HelpId = HlpFileLog; |
| 307 |
FileTransEnd(OpLog); |
if (ts.Append > 0) |
| 308 |
|
{ |
| 309 |
|
LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE); |
| 310 |
|
if (LogVar->FileHandle>0) |
| 311 |
|
_llseek(LogVar->FileHandle,0,2); |
| 312 |
|
else |
| 313 |
|
LogVar->FileHandle = _lcreat(LogVar->FullName,0); |
| 314 |
|
} |
| 315 |
|
else |
| 316 |
|
LogVar->FileHandle = _lcreat(LogVar->FullName,0); |
| 317 |
|
LogVar->FileOpen = (LogVar->FileHandle>0); |
| 318 |
|
if (! LogVar->FileOpen) |
| 319 |
|
{ |
| 320 |
|
FileTransEnd(OpLog); |
| 321 |
|
return; |
| 322 |
|
} |
| 323 |
|
LogVar->ByteCount = 0; |
| 324 |
|
|
| 325 |
|
if (! OpenFTDlg(LogVar)) |
| 326 |
|
FileTransEnd(OpLog); |
| 327 |
} |
} |
| 328 |
} |
} |
| 329 |
|
|
| 356 |
} |
} |
| 357 |
else cv.DCount++; |
else cv.DCount++; |
| 358 |
} |
} |
| 359 |
else |
else { |
| 360 |
cv.DCount = 0; |
cv.DCount = 0; |
| 361 |
|
// ログ採取中にマクロがストールする問題への修正。 |
| 362 |
|
// ログ採取中に一度マクロを止めると、バッファのインデックスが同期取れなくなり、 |
| 363 |
|
// 再度マクロを流しても正しいデータが送れないのが原因。 |
| 364 |
|
// マクロを停止させた状態でもインデックスの同期を取るようにした。 |
| 365 |
|
// (2006.12.26 yutaka) |
| 366 |
|
cv.DStart = cv.LogPtr; |
| 367 |
|
} |
| 368 |
} |
} |
| 369 |
|
|
| 370 |
void Log1Byte(BYTE b) |
void Log1Byte(BYTE b) |
| 457 |
{ |
{ |
| 458 |
if (((cv.FilePause & OpLog)==0) && (! cv.ProtoFlag)) |
if (((cv.FilePause & OpLog)==0) && (! cv.ProtoFlag)) |
| 459 |
{ |
{ |
| 460 |
|
// 時刻を書き出す(2006.7.23 maya) |
| 461 |
|
// 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka) |
| 462 |
|
if (ts.LogTimestamp && |
| 463 |
|
(Start == 1 || Buf[Start-2] == 0x0a)) { |
| 464 |
|
#if 0 |
| 465 |
|
SYSTEMTIME LocalTime; |
| 466 |
|
GetLocalTime(&LocalTime); |
| 467 |
|
char strtime[27]; |
| 468 |
|
|
| 469 |
|
// format time |
| 470 |
|
sprintf(strtime, "[%04d/%02d/%02d %02d:%02d:%02d.%03d] ", |
| 471 |
|
LocalTime.wYear, LocalTime.wMonth,LocalTime.wDay, |
| 472 |
|
LocalTime.wHour, LocalTime.wMinute, LocalTime.wSecond, |
| 473 |
|
LocalTime.wMilliseconds); |
| 474 |
|
#else |
| 475 |
|
time_t tick = time(NULL); |
| 476 |
|
char *strtime = ctime(&tick); |
| 477 |
|
#endif |
| 478 |
|
|
| 479 |
|
// write to file |
| 480 |
|
if (Start == 1 && ts.Append) { |
| 481 |
|
_lwrite(LogVar->FileHandle,"\r\n",strlen("\r\n")); |
| 482 |
|
} |
| 483 |
|
_lwrite(LogVar->FileHandle,"[",1); |
| 484 |
|
// 変換した文字列の終端に \n が含まれているので取り除く。 |
| 485 |
|
_lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1); |
| 486 |
|
_lwrite(LogVar->FileHandle,"] ",2); |
| 487 |
|
} |
| 488 |
|
|
| 489 |
_lwrite(LogVar->FileHandle,(PCHAR)&b,1); |
_lwrite(LogVar->FileHandle,(PCHAR)&b,1); |
| 490 |
(LogVar->ByteCount)++; |
(LogVar->ByteCount)++; |
| 491 |
} |
} |
| 586 |
if (strlen(&(SendVar->FullName[SendVar->DirLen]))==0) |
if (strlen(&(SendVar->FullName[SendVar->DirLen]))==0) |
| 587 |
{ |
{ |
| 588 |
Option = MAKELONG(ts.TransBin,0); |
Option = MAKELONG(ts.TransBin,0); |
| 589 |
|
SendVar->FullName[0] = 0; |
| 590 |
if (! (*GetTransFname)(SendVar, ts.FileDir, GTF_SEND, &Option)) |
if (! (*GetTransFname)(SendVar, ts.FileDir, GTF_SEND, &Option)) |
| 591 |
{ |
{ |
| 592 |
FileTransEnd(OpSendFile); |
FileTransEnd(OpSendFile); |
| 1073 |
FileVar->OpId = OpBPSend; |
FileVar->OpId = OpBPSend; |
| 1074 |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
| 1075 |
{ |
{ |
| 1076 |
|
FileVar->FullName[0] = 0; |
| 1077 |
if (! (*GetTransFname)(FileVar, ts.FileDir, GTF_BP, &Option)) |
if (! (*GetTransFname)(FileVar, ts.FileDir, GTF_BP, &Option)) |
| 1078 |
{ |
{ |
| 1079 |
ProtoEnd(); |
ProtoEnd(); |
| 1131 |
ProtoEnd(); |
ProtoEnd(); |
| 1132 |
} |
} |
| 1133 |
} |
} |
| 1134 |
|
|
| 1135 |
|
/* |
| 1136 |
|
* $Log$ |
| 1137 |
|
* Revision 1.7 2006/12/25 16:13:54 yutakapon |
| 1138 |
|
* ログ採取中にマクロがストールする問題への修正。 |
| 1139 |
|
* ログ採取中に一度マクロを止めると、バッファのインデックスが同期取れなくなり、 |
| 1140 |
|
* 再度マクロを流しても正しいデータが送れないのが原因。 |
| 1141 |
|
* マクロを停止させた状態でもインデックスの同期を取るようにした。 |
| 1142 |
|
* |
| 1143 |
|
* Revision 1.6 2006/08/28 12:27:16 maya |
| 1144 |
|
* デフォルトのログファイル名を指定できるようにした。 |
| 1145 |
|
* エディットコントロールを "Additional settings" ダイアログに追加した。 |
| 1146 |
|
* teraterm.ini ファイルに LogDefaultName エントリを追加した。 |
| 1147 |
|
* ファイル名に strftime のフォーマットを使えるようにした。 |
| 1148 |
|
* |
| 1149 |
|
* Revision 1.5 2006/07/23 14:12:26 yutakakn |
| 1150 |
|
* ログに含める日付フォーマットを世界標準書式に変更した。 |
| 1151 |
|
* |
| 1152 |
|
* Revision 1.4 2006/07/22 16:15:54 maya |
| 1153 |
|
* ログ記録時に時刻も書き込む機能を追加した。 |
| 1154 |
|
* |
| 1155 |
|
* Revision 1.3 2005/05/07 09:49:24 yutakakn |
| 1156 |
|
* teraterm.iniに LogTypePlainText を追加した。 |
| 1157 |
|
* |
| 1158 |
|
* Revision 1.2 2005/02/20 14:51:29 yutakakn |
| 1159 |
|
* ログファイルの種別に"plain text"を追加。このオプションが有効の場合は、ログファイルに |
| 1160 |
|
* ASCII非表示文字の採取をしない。 |
| 1161 |
|
* |
| 1162 |
|
* 現在、無視するキャラクタは以下のとおり。 |
| 1163 |
|
* ・BS |
| 1164 |
|
* ・ASCII(0x00-0x1f)のうち非表示なもの |
| 1165 |
|
* |
| 1166 |
|
* ただし、例外として以下のものはログ採取対象。 |
| 1167 |
|
* ・HT |
| 1168 |
|
* ・CR |
| 1169 |
|
* ・LF |
| 1170 |
|
* |
| 1171 |
|
*/ |