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.1.1.1 by yutakakn, Mon Nov 15 14:43:41 2004 UTC revision 1.5 by yutakakn, Sun Jul 23 14:12:26 2006 UTC
# Line 224  void FreeFileVar(PFileVar *fv) Line 224  void FreeFileVar(PFileVar *fv)
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                  if (! (*GetTransFname)(LogVar, ts.FileDir, GTF_LOG, &Option))
252      (*SetFileVar)(LogVar);                  {
253                            FreeFileVar(&LogVar);
254                            FreeTTFILE();
255                            return;
256                    }
257                    ts.TransBin = LOWORD(Option);
258                    ts.Append = HIWORD(Option);
259    
260    if (ts.TransBin > 0)                  if (ts.Append & 0x1000) {
261    {                          ts.LogTypePlainText = 1;
262      BinLog = TRUE;                  } else {
263      FileLog = FALSE;                          ts.LogTypePlainText = 0;
264      if (! CreateBinBuf())                  }
     {  
       FileTransEnd(OpLog);  
       return;  
     }  
   }  
   else {  
     BinLog = FALSE;  
     FileLog = TRUE;  
     if (! CreateLogBuf())  
     {  
       FileTransEnd(OpLog);  
       return;  
     }  
   }  
   cv.LStart = cv.LogPtr;  
   cv.LCount = 0;  
265    
266    HelpId = HlpFileLog;                  if (ts.Append & 0x2000) {
267    if (ts.Append > 0)                          ts.LogTimestamp = 1;
268    {                  }
269      LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE);                  else {
270      if (LogVar->FileHandle>0)                          ts.LogTimestamp = 0;
271        _llseek(LogVar->FileHandle,0,2);                  }
272      else  
273        LogVar->FileHandle = _lcreat(LogVar->FullName,0);                  ts.Append &= 0x1; // 1bitにマスクする
274    }  
275    else          }
276      LogVar->FileHandle = _lcreat(LogVar->FullName,0);          else
277    LogVar->FileOpen = (LogVar->FileHandle>0);                  (*SetFileVar)(LogVar);
278    if (! LogVar->FileOpen)  
279    {          if (ts.TransBin > 0)
280      FileTransEnd(OpLog);          {
281      return;                  BinLog = TRUE;
282    }                  FileLog = FALSE;
283    LogVar->ByteCount = 0;                  if (! CreateBinBuf())
284                    {
285                            FileTransEnd(OpLog);
286                            return;
287                    }
288            }
289            else {
290                    BinLog = FALSE;
291                    FileLog = TRUE;
292                    if (! CreateLogBuf())
293                    {
294                            FileTransEnd(OpLog);
295                            return;
296                    }
297            }
298            cv.LStart = cv.LogPtr;
299            cv.LCount = 0;
300    
301            HelpId = HlpFileLog;
302            if (ts.Append > 0)
303            {
304                    LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE);
305                    if (LogVar->FileHandle>0)
306                            _llseek(LogVar->FileHandle,0,2);
307                    else
308                            LogVar->FileHandle = _lcreat(LogVar->FullName,0);
309            }
310            else
311                    LogVar->FileHandle = _lcreat(LogVar->FullName,0);
312            LogVar->FileOpen = (LogVar->FileHandle>0);
313            if (! LogVar->FileOpen)
314            {
315                    FileTransEnd(OpLog);
316                    return;
317            }
318            LogVar->ByteCount = 0;
319    
320    if (! OpenFTDlg(LogVar))          if (! OpenFTDlg(LogVar))
321      FileTransEnd(OpLog);                  FileTransEnd(OpLog);
322  }  }
323  }  }
324    
# Line 420  void LogToFile() Line 445  void LogToFile()
445          {          {
446                  if (((cv.FilePause & OpLog)==0) && (! cv.ProtoFlag))                  if (((cv.FilePause & OpLog)==0) && (! cv.ProtoFlag))
447                  {                  {
448                            // 時刻を書き出す(2006.7.23 maya)
449                            // 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka)
450                            if (ts.LogTimestamp &&
451                                    (Start == 1 || Buf[Start-2] == 0x0a)) {
452    #if 0
453                                    SYSTEMTIME      LocalTime;
454                                    GetLocalTime(&LocalTime);
455                                    char strtime[27];
456    
457                                    // format time
458                                    sprintf(strtime, "[%04d/%02d/%02d %02d:%02d:%02d.%03d] ",
459                                                    LocalTime.wYear, LocalTime.wMonth,LocalTime.wDay,
460                                                    LocalTime.wHour, LocalTime.wMinute, LocalTime.wSecond,
461                                                    LocalTime.wMilliseconds);
462    #else
463                                            time_t tick = time(NULL);
464                                            char *strtime = ctime(&tick);
465    #endif
466    
467                                    // write to file
468                                    if (Start == 1 && ts.Append) {
469                                            _lwrite(LogVar->FileHandle,"\r\n",strlen("\r\n"));
470                                    }
471                                    _lwrite(LogVar->FileHandle,"[",1);
472                                    // 変換した文字列の終端に \n が含まれているので取り除く。
473                                    _lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1);
474                                    _lwrite(LogVar->FileHandle,"] ",2);
475                            }
476    
477                          _lwrite(LogVar->FileHandle,(PCHAR)&b,1);                          _lwrite(LogVar->FileHandle,(PCHAR)&b,1);
478                          (LogVar->ByteCount)++;                          (LogVar->ByteCount)++;
479                  }                  }
# Line 1063  void QVStart(int mode) Line 1117  void QVStart(int mode)
1117      ProtoEnd();      ProtoEnd();
1118  }  }
1119  }  }
1120    
1121    /*
1122     * $Log$
1123     * Revision 1.5  2006/07/23 14:12:26  yutakakn
1124     * ログに含める日付フォーマットを世界標準書式に変更した。
1125     *
1126     * Revision 1.4  2006/07/22 16:15:54  maya
1127     * ログ記録時に時刻も書き込む機能を追加した。
1128     *
1129     * Revision 1.3  2005/05/07 09:49:24  yutakakn
1130     * teraterm.iniに LogTypePlainText を追加した。
1131     *
1132     * Revision 1.2  2005/02/20 14:51:29  yutakakn
1133     * ログファイルの種別に"plain text"を追加。このオプションが有効の場合は、ログファイルに
1134     * ASCII非表示文字の採取をしない。
1135     *
1136     * 現在、無視するキャラクタは以下のとおり。
1137     *  ・BS
1138     *  ・ASCII(0x00-0x1f)のうち非表示なもの
1139     *
1140     * ただし、例外として以下のものはログ採取対象。
1141     *  ・HT
1142     *  ・CR
1143     *  ・LF
1144     *
1145     */

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.5

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