Develop and Download Open Source Software

Browse CVS Repository

Diff of /ttssh2/teraterm/source/teraterm/filesys.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.8 by maya, Thu Jan 4 15:11:44 2007 UTC revision 1.12 by yutakapon, Fri May 25 09:56:05 2007 UTC
# Line 64  PProtoCancel ProtoCancel; Line 64  PProtoCancel ProtoCancel;
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;
# Line 251  void FreeFileVar(PFileVar *fv) Line 263  void FreeFileVar(PFileVar *fv)
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  {  {
# Line 283  void LogStart() Line 334  void LogStart()
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();
# Line 312  void LogStart() Line 362  void LogStart()
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          {          {
# Line 342  void LogStart() Line 391  void LogStart()
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          }          }
# Line 469  void CommentLogToFile(char *buf, int siz Line 527  void CommentLogToFile(char *buf, int siz
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    
# Line 506  void LogToFile() Line 568  void LogToFile()
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);
# Line 522  void LogToFile() Line 584  void LogToFile()
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)++;
# Line 634  void FileSendStart() Line 703  void FileSendStart()
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;
# Line 646  void FileSendStart() Line 711  void FileSendStart()
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);
# Line 975  int ProtoDlgParse() Line 1036  int ProtoDlgParse()
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);
# Line 1018  void KermitStart(int mode) Line 1075  void KermitStart(int mode)
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();
# Line 1030  void KermitStart(int mode) Line 1083  void KermitStart(int mode)
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;
# Line 1051  void KermitStart(int mode) Line 1100  void KermitStart(int mode)
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;
# Line 1089  void XMODEMStart(int mode) Line 1134  void XMODEMStart(int mode)
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;
# Line 1104  void XMODEMStart(int mode) Line 1144  void XMODEMStart(int mode)
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);
# Line 1145  void ZMODEMStart(int mode) Line 1181  void ZMODEMStart(int mode)
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();
# Line 1158  void ZMODEMStart(int mode) Line 1190  void ZMODEMStart(int mode)
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;
# Line 1189  void BPStart(int mode) Line 1217  void BPStart(int mode)
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;
# Line 1231  void QVStart(int mode) Line 1251  void QVStart(int mode)
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();
# Line 1243  void QVStart(int mode) Line 1259  void QVStart(int mode)
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;
# Line 1264  void QVStart(int mode) Line 1276  void QVStart(int mode)
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   *   *

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.12

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26