| 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; |
| 263 |
} |
} |
| 264 |
} |
} |
| 265 |
|
|
| 266 |
|
// &h をホスト名に置換 (2007.5.14) |
| 267 |
|
void ConvertLogname(char *c) |
| 268 |
|
{ |
| 269 |
|
char buf[MAXPATHLEN], buf2[MAXPATHLEN], *p = c; |
| 270 |
|
|
| 271 |
|
memset(buf, 0, sizeof(buf)); |
| 272 |
|
|
| 273 |
|
while(*p != '\0') { |
| 274 |
|
if (*p == '&' && *(p+1) != '\0') { |
| 275 |
|
switch (*(p+1)) { |
| 276 |
|
case 'h': |
| 277 |
|
if (cv.Open) { |
| 278 |
|
if (cv.PortType == IdTCPIP) { |
| 279 |
|
_snprintf(buf2, sizeof(buf2), "%s%s", buf, ts.HostName); |
| 280 |
|
strncpy(buf, buf2, sizeof(buf)-strlen(buf)-1); |
| 281 |
|
} |
| 282 |
|
else if (cv.PortType == IdSerial) { |
| 283 |
|
_snprintf(buf2, sizeof(buf2), "%sCOM%d", buf, ts.ComPort); |
| 284 |
|
strncpy(buf, buf2, sizeof(buf)-strlen(buf)-1); |
| 285 |
|
} |
| 286 |
|
} |
| 287 |
|
break; |
| 288 |
|
default: |
| 289 |
|
if (strlen(buf) < sizeof(buf)-3) { |
| 290 |
|
strncat(buf, p, 2); |
| 291 |
|
} |
| 292 |
|
} |
| 293 |
|
p++; |
| 294 |
|
} |
| 295 |
|
else { |
| 296 |
|
if (strlen(buf) < sizeof(buf)-2) { |
| 297 |
|
strncat(buf, p, 1); |
| 298 |
|
} |
| 299 |
|
} |
| 300 |
|
p++; |
| 301 |
|
} |
| 302 |
|
strcpy(c, buf); |
| 303 |
|
} |
| 304 |
|
|
| 305 |
extern "C" { |
extern "C" { |
| 306 |
void LogStart() |
void LogStart() |
| 307 |
{ |
{ |
| 334 |
strncat(LogVar->FullName, ts.LogDefaultName, sizeof(LogVar->FullName)); |
strncat(LogVar->FullName, ts.LogDefaultName, sizeof(LogVar->FullName)); |
| 335 |
ParseStrftimeFileName(LogVar->FullName); |
ParseStrftimeFileName(LogVar->FullName); |
| 336 |
|
|
| 337 |
#ifdef I18N |
// &h をホスト名に置換 (2007.5.14) |
| 338 |
if (! (*GetTransFname)(LogVar, ts.FileDir, GTF_LOG, &Option, &ts)) |
ConvertLogname(LogVar->FullName); |
| 339 |
#else |
|
| 340 |
if (! (*GetTransFname)(LogVar, ts.FileDir, GTF_LOG, &Option)) |
if (! (*GetTransFname)(LogVar, ts.FileDir, GTF_LOG, &Option)) |
|
#endif |
|
| 341 |
{ |
{ |
| 342 |
FreeFileVar(&LogVar); |
FreeFileVar(&LogVar); |
| 343 |
FreeTTFILE(); |
FreeTTFILE(); |
| 362 |
ts.Append &= 0x1; // 1bitにマスクする |
ts.Append &= 0x1; // 1bitにマスクする |
| 363 |
|
|
| 364 |
} |
} |
| 365 |
else |
else { |
| 366 |
#ifdef I18N |
// &h をホスト名に置換 (2007.5.14) |
| 367 |
(*SetFileVar)(FileVar, &ts); |
ConvertLogname(LogVar->FullName); |
|
#else |
|
| 368 |
(*SetFileVar)(LogVar); |
(*SetFileVar)(LogVar); |
| 369 |
#endif |
} |
| 370 |
|
|
| 371 |
if (ts.TransBin > 0) |
if (ts.TransBin > 0) |
| 372 |
{ |
{ |
| 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)++; |
| 703 |
{ |
{ |
| 704 |
Option = MAKELONG(ts.TransBin,0); |
Option = MAKELONG(ts.TransBin,0); |
| 705 |
SendVar->FullName[0] = 0; |
SendVar->FullName[0] = 0; |
|
#ifdef I18N |
|
|
if (! (*GetTransFname)(SendVar, ts.FileDir, GTF_SEND, &Option, &ts)) |
|
|
#else |
|
| 706 |
if (! (*GetTransFname)(SendVar, ts.FileDir, GTF_SEND, &Option)) |
if (! (*GetTransFname)(SendVar, ts.FileDir, GTF_SEND, &Option)) |
|
#endif |
|
| 707 |
{ |
{ |
| 708 |
FileTransEnd(OpSendFile); |
FileTransEnd(OpSendFile); |
| 709 |
return; |
return; |
| 711 |
ts.TransBin = LOWORD(Option); |
ts.TransBin = LOWORD(Option); |
| 712 |
} |
} |
| 713 |
else |
else |
|
#ifdef I18N |
|
|
(*SetFileVar)(FileVar, &ts); |
|
|
#else |
|
| 714 |
(*SetFileVar)(SendVar); |
(*SetFileVar)(SendVar); |
|
#endif |
|
| 715 |
|
|
| 716 |
SendVar->FileHandle = _lopen(SendVar->FullName,OF_READ); |
SendVar->FileHandle = _lopen(SendVar->FullName,OF_READ); |
| 717 |
SendVar->FileOpen = (SendVar->FileHandle>0); |
SendVar->FileOpen = (SendVar->FileHandle>0); |
| 1036 |
P = ActiveWin; |
P = ActiveWin; |
| 1037 |
if (PtDlg==NULL) return P; |
if (PtDlg==NULL) return P; |
| 1038 |
|
|
|
#ifdef I18N |
|
|
if ((*ProtoParse)(ProtoId,FileVar,ProtoVar,&cv,&ts)) |
|
|
#else |
|
| 1039 |
if ((*ProtoParse)(ProtoId,FileVar,ProtoVar,&cv)) |
if ((*ProtoParse)(ProtoId,FileVar,ProtoVar,&cv)) |
|
#endif |
|
| 1040 |
P = 0; /* continue */ |
P = 0; /* continue */ |
| 1041 |
else { |
else { |
| 1042 |
CommSend(&cv); |
CommSend(&cv); |
| 1075 |
FileVar->OpId = OpKmtSend; |
FileVar->OpId = OpKmtSend; |
| 1076 |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
| 1077 |
{ |
{ |
|
#ifdef I18N |
|
|
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_KERMIT,&w,&ts) || |
|
|
#else |
|
| 1078 |
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_KERMIT,&w) || |
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_KERMIT,&w) || |
|
#endif |
|
| 1079 |
(FileVar->NumFname==0)) |
(FileVar->NumFname==0)) |
| 1080 |
{ |
{ |
| 1081 |
ProtoEnd(); |
ProtoEnd(); |
| 1083 |
} |
} |
| 1084 |
} |
} |
| 1085 |
else |
else |
|
#ifdef I18N |
|
|
(*SetFileVar)(FileVar, &ts); |
|
|
#else |
|
| 1086 |
(*SetFileVar)(FileVar); |
(*SetFileVar)(FileVar); |
|
#endif |
|
| 1087 |
break; |
break; |
| 1088 |
case IdKmtReceive: |
case IdKmtReceive: |
| 1089 |
FileVar->OpId = OpKmtRcv; |
FileVar->OpId = OpKmtRcv; |
| 1100 |
} |
} |
| 1101 |
} |
} |
| 1102 |
else |
else |
|
#ifdef I18N |
|
|
(*SetFileVar)(FileVar, &ts); |
|
|
#else |
|
| 1103 |
(*SetFileVar)(FileVar); |
(*SetFileVar)(FileVar); |
|
#endif |
|
| 1104 |
break; |
break; |
| 1105 |
case IdKmtFinish: |
case IdKmtFinish: |
| 1106 |
FileVar->OpId = OpKmtFin; |
FileVar->OpId = OpKmtFin; |
| 1134 |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
| 1135 |
{ |
{ |
| 1136 |
Option = MAKELONG(ts.XmodemBin,ts.XmodemOpt); |
Option = MAKELONG(ts.XmodemBin,ts.XmodemOpt); |
|
#ifdef I18N |
|
|
if (! (*GetXFname)(FileVar->HMainWin, |
|
|
mode==IdXReceive,&Option,FileVar,ts.FileDir,&ts)) |
|
|
#else |
|
| 1137 |
if (! (*GetXFname)(FileVar->HMainWin, |
if (! (*GetXFname)(FileVar->HMainWin, |
| 1138 |
mode==IdXReceive,&Option,FileVar,ts.FileDir)) |
mode==IdXReceive,&Option,FileVar,ts.FileDir)) |
|
#endif |
|
| 1139 |
{ |
{ |
| 1140 |
ProtoEnd(); |
ProtoEnd(); |
| 1141 |
return; |
return; |
| 1144 |
ts.XmodemBin = LOWORD(Option); |
ts.XmodemBin = LOWORD(Option); |
| 1145 |
} |
} |
| 1146 |
else |
else |
|
#ifdef I18N |
|
|
(*SetFileVar)(FileVar, &ts); |
|
|
#else |
|
| 1147 |
(*SetFileVar)(FileVar); |
(*SetFileVar)(FileVar); |
|
#endif |
|
| 1148 |
|
|
| 1149 |
if (mode==IdXReceive) |
if (mode==IdXReceive) |
| 1150 |
FileVar->FileHandle = _lcreat(FileVar->FullName,0); |
FileVar->FileHandle = _lcreat(FileVar->FullName,0); |
| 1181 |
FileVar->OpId = OpZSend; |
FileVar->OpId = OpZSend; |
| 1182 |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
| 1183 |
{ |
{ |
|
#ifdef I18N |
|
|
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_Z,&Opt,&ts) || |
|
|
#else |
|
| 1184 |
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_Z,&Opt) || |
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_Z,&Opt) || |
|
#endif |
|
| 1185 |
(FileVar->NumFname==0)) |
(FileVar->NumFname==0)) |
| 1186 |
{ |
{ |
| 1187 |
ProtoEnd(); |
ProtoEnd(); |
| 1190 |
ts.XmodemBin = Opt; |
ts.XmodemBin = Opt; |
| 1191 |
} |
} |
| 1192 |
else |
else |
|
#ifdef I18N |
|
|
(*SetFileVar)(FileVar, &ts); |
|
|
#else |
|
| 1193 |
(*SetFileVar)(FileVar); |
(*SetFileVar)(FileVar); |
|
#endif |
|
| 1194 |
} |
} |
| 1195 |
else /* IdZReceive or IdZAuto */ |
else /* IdZReceive or IdZAuto */ |
| 1196 |
FileVar->OpId = OpZRcv; |
FileVar->OpId = OpZRcv; |
| 1217 |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
| 1218 |
{ |
{ |
| 1219 |
FileVar->FullName[0] = 0; |
FileVar->FullName[0] = 0; |
|
#ifdef I18N |
|
|
if (! (*GetTransFname)(FileVar, ts.FileDir, GTF_BP, &Option, &ts)) |
|
|
#else |
|
| 1220 |
if (! (*GetTransFname)(FileVar, ts.FileDir, GTF_BP, &Option)) |
if (! (*GetTransFname)(FileVar, ts.FileDir, GTF_BP, &Option)) |
|
#endif |
|
| 1221 |
{ |
{ |
| 1222 |
ProtoEnd(); |
ProtoEnd(); |
| 1223 |
return; |
return; |
| 1224 |
} |
} |
| 1225 |
} |
} |
| 1226 |
else |
else |
|
#ifdef I18N |
|
|
(*SetFileVar)(FileVar, &ts); |
|
|
#else |
|
| 1227 |
(*SetFileVar)(FileVar); |
(*SetFileVar)(FileVar); |
|
#endif |
|
| 1228 |
} |
} |
| 1229 |
else /* IdBPReceive or IdBPAuto */ |
else /* IdBPReceive or IdBPAuto */ |
| 1230 |
FileVar->OpId = OpBPRcv; |
FileVar->OpId = OpBPRcv; |
| 1251 |
FileVar->OpId = OpQVSend; |
FileVar->OpId = OpQVSend; |
| 1252 |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0) |
| 1253 |
{ |
{ |
|
#ifdef I18N |
|
|
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_QV, &W, &ts) || |
|
|
#else |
|
| 1254 |
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_QV, &W) || |
if (! (*GetMultiFname)(FileVar,ts.FileDir,GMF_QV, &W) || |
|
#endif |
|
| 1255 |
(FileVar->NumFname==0)) |
(FileVar->NumFname==0)) |
| 1256 |
{ |
{ |
| 1257 |
ProtoEnd(); |
ProtoEnd(); |
| 1259 |
} |
} |
| 1260 |
} |
} |
| 1261 |
else |
else |
|
#ifdef I18N |
|
|
(*SetFileVar)(FileVar, &ts); |
|
|
#else |
|
| 1262 |
(*SetFileVar)(FileVar); |
(*SetFileVar)(FileVar); |
|
#endif |
|
| 1263 |
} |
} |
| 1264 |
else |
else |
| 1265 |
FileVar->OpId = OpQVRcv; |
FileVar->OpId = OpQVRcv; |
| 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 |
| 1286 |
|
* ログファイル名中の &h を、接続中のホスト名に変換する機能を追加した。 |
| 1287 |
|
* |
| 1288 |
|
* Revision 1.9 2007/01/21 16:18:35 maya |
| 1289 |
|
* 表示メッセージの読み込み対応 |
| 1290 |
|
* |
| 1291 |
* Revision 1.8 2007/01/04 15:11:44 maya |
* Revision 1.8 2007/01/04 15:11:44 maya |
| 1292 |
* 表示メッセージの読み込み対応 |
* 表示メッセージの読み込み対応 |
| 1293 |
* |
* |