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.11 by maya, Mon May 14 14:07:14 2007 UTC revision 1.13 by maya, Wed May 30 16:04:27 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 294  extern "C" { Line 306  extern "C" {
306  void LogStart()  void LogStart()
307  {  {
308          LONG Option;          LONG Option;
309            char *logdir;
310    
311          if ((FileLog) || (BinLog)) return;          if ((FileLog) || (BinLog)) return;
312    
# Line 305  void LogStart() Line 318  void LogStart()
318          }          }
319          LogVar->OpId = OpLog;          LogVar->OpId = OpLog;
320    
321            if (strlen(ts.LogDefaultPath) > 0) {
322                    logdir = ts.LogDefaultPath;
323            }
324            else if (strlen(ts.FileDir) > 0) {
325                    logdir = ts.FileDir;
326            }
327            else {
328                    logdir = ts.HomeDir;
329            }
330    
331          if (strlen(&(LogVar->FullName[LogVar->DirLen]))==0)          if (strlen(&(LogVar->FullName[LogVar->DirLen]))==0)
332          {          {
333                  // LOWORD                  // LOWORD
# Line 320  void LogStart() Line 343  void LogStart()
343    
344                  // ログのデフォルトファイル名を設定 (2006.8.28 maya)                  // ログのデフォルトファイル名を設定 (2006.8.28 maya)
345                  strncat(LogVar->FullName, ts.LogDefaultName, sizeof(LogVar->FullName));                  strncat(LogVar->FullName, ts.LogDefaultName, sizeof(LogVar->FullName));
346    
347                  ParseStrftimeFileName(LogVar->FullName);                  ParseStrftimeFileName(LogVar->FullName);
348    
349                  // &h をホスト名に置換 (2007.5.14)                  // &h をホスト名に置換 (2007.5.14)
350                  ConvertLogname(LogVar->FullName);                  ConvertLogname(LogVar->FullName);
351    
352                  if (! (*GetTransFname)(LogVar, ts.FileDir, GTF_LOG, &Option))                  if (! (*GetTransFname)(LogVar, logdir, GTF_LOG, &Option))
353                  {                  {
354                          FreeFileVar(&LogVar);                          FreeFileVar(&LogVar);
355                          FreeTTFILE();                          FreeTTFILE();
# Line 351  void LogStart() Line 375  void LogStart()
375    
376          }          }
377          else {          else {
378                    // LogVar->DirLen = 0 だとここに来る
379                    // フルパス・相対パスともに LogVar->FullName に入れておく必要がある
380                    char FileName[MAX_PATH];
381    
382                    // フルパス化
383                    strncpy(FileName, LogVar->FullName, sizeof(FileName)-1);
384                    ConvFName(logdir,FileName,"",LogVar->FullName);
385    
386                    ParseStrftimeFileName(LogVar->FullName);
387    
388                  // &h をホスト名に置換 (2007.5.14)                  // &h をホスト名に置換 (2007.5.14)
389                  ConvertLogname(LogVar->FullName);                  ConvertLogname(LogVar->FullName);
390                  (*SetFileVar)(LogVar);                  (*SetFileVar)(LogVar);
# Line 379  void LogStart() Line 413  void LogStart()
413          cv.LCount = 0;          cv.LCount = 0;
414    
415          HelpId = HlpFileLog;          HelpId = HlpFileLog;
416            /* 2007.05.24 Gentaro */
417            eLineEnd = Line_LineHead;
418    
419          if (ts.Append > 0)          if (ts.Append > 0)
420          {          {
421                  LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE);                  LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE);
422                  if (LogVar->FileHandle>0)                  if (LogVar->FileHandle>0){
423                          _llseek(LogVar->FileHandle,0,2);                          _llseek(LogVar->FileHandle,0,2);
424                            /* 2007.05.24 Gentaro
425                                    If log file already exists,
426                                    a newline is inserted before the first timestamp.
427                            */
428                            eLineEnd = Line_FileHead;
429                    }
430                  else                  else
431                          LogVar->FileHandle = _lcreat(LogVar->FullName,0);                          LogVar->FileHandle = _lcreat(LogVar->FullName,0);
432          }          }
# Line 506  void CommentLogToFile(char *buf, int siz Line 549  void CommentLogToFile(char *buf, int siz
549          logfile_lock();          logfile_lock();
550          WriteFile((HANDLE)LogVar->FileHandle, buf, size, &wrote, NULL);          WriteFile((HANDLE)LogVar->FileHandle, buf, size, &wrote, NULL);
551          WriteFile((HANDLE)LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // 改行          WriteFile((HANDLE)LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // 改行
552            /* Set Line End Flag
553                    2007.05.24 Gentaro
554            */
555            eLineEnd = Line_LineHead;
556          logfile_unlock();          logfile_unlock();
557  }  }
558    
# Line 543  void LogToFile() Line 590  void LogToFile()
590                  {                  {
591                          // 時刻を書き出す(2006.7.23 maya)                          // 時刻を書き出す(2006.7.23 maya)
592                          // 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka)                          // 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka)
593                          if (ts.LogTimestamp &&                          /* 2007.05.24 Gentaro */
594                                  (Start == 1 || Buf[Start-2] == 0x0a)) {                          if ( ts.LogTimestamp && eLineEnd ) {
595  #if 0  #if 0
596                                  SYSTEMTIME      LocalTime;                                  SYSTEMTIME      LocalTime;
597                                  GetLocalTime(&LocalTime);                                  GetLocalTime(&LocalTime);
# Line 559  void LogToFile() Line 606  void LogToFile()
606                                          time_t tick = time(NULL);                                          time_t tick = time(NULL);
607                                          char *strtime = ctime(&tick);                                          char *strtime = ctime(&tick);
608  #endif  #endif
609                                    /* 2007.05.24 Gentaro */
610                                  // write to file                                  if( eLineEnd == Line_FileHead ){
611                                  if (Start == 1 && ts.Append) {                                          _lwrite(LogVar->FileHandle,"\r\n",2);
                                         _lwrite(LogVar->FileHandle,"\r\n",strlen("\r\n"));  
612                                  }                                  }
613                                  _lwrite(LogVar->FileHandle,"[",1);                                  _lwrite(LogVar->FileHandle,"[",1);
614                                  // 変換した文字列の終端に \n が含まれているので取り除く。                                  // 変換した文字列の終端に \n が含まれているので取り除く。
615                                  _lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1);                                  _lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1);
616                                  _lwrite(LogVar->FileHandle,"] ",2);                                  _lwrite(LogVar->FileHandle,"] ",2);
617                          }                          }
618                            
619                            /* 2007.05.24 Gentaro */
620                            if( b == 0x0a ){
621                                    eLineEnd = Line_LineHead; /* set endmark*/
622                            }
623                            else {
624                                    eLineEnd = Line_Other; /* clear endmark*/
625                            }
626    
627                          _lwrite(LogVar->FileHandle,(PCHAR)&b,1);                          _lwrite(LogVar->FileHandle,(PCHAR)&b,1);
628                          (LogVar->ByteCount)++;                          (LogVar->ByteCount)++;
# Line 1244  void QVStart(int mode) Line 1298  void QVStart(int mode)
1298    
1299  /*  /*
1300   * $Log$   * $Log$
1301     * Revision 1.13  2007/05/30 16:04:27  maya
1302     * 標準のログ保存先を指定できるようにした。
1303     *
1304     * Revision 1.12  2007/05/25 09:56:05  yutakapon
1305     * タイムスタンプ付きログで1KBごとに不要な改行が入るバグを修正。
1306     *
1307   * Revision 1.11  2007/05/14 14:07:14  maya   * Revision 1.11  2007/05/14 14:07:14  maya
1308   * バッファをクリアしていないので落ちる問題を修正した。   * バッファをクリアしていないので落ちる問題を修正した。
1309   *   *

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.13

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