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.6 by maya, Mon Aug 28 12:27:16 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  
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            HelpId = HlpFileLog;
307            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))          if (! OpenFTDlg(LogVar))
326      FileTransEnd(OpLog);                  FileTransEnd(OpLog);
327  }  }
328  }  }
329    
# Line 420  void LogToFile() Line 450  void LogToFile()
450          {          {
451                  if (((cv.FilePause & OpLog)==0) && (! cv.ProtoFlag))                  if (((cv.FilePause & OpLog)==0) && (! cv.ProtoFlag))
452                  {                  {
453                            // 時刻を書き出す(2006.7.23 maya)
454                            // 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka)
455                            if (ts.LogTimestamp &&
456                                    (Start == 1 || Buf[Start-2] == 0x0a)) {
457    #if 0
458                                    SYSTEMTIME      LocalTime;
459                                    GetLocalTime(&LocalTime);
460                                    char strtime[27];
461    
462                                    // format time
463                                    sprintf(strtime, "[%04d/%02d/%02d %02d:%02d:%02d.%03d] ",
464                                                    LocalTime.wYear, LocalTime.wMonth,LocalTime.wDay,
465                                                    LocalTime.wHour, LocalTime.wMinute, LocalTime.wSecond,
466                                                    LocalTime.wMilliseconds);
467    #else
468                                            time_t tick = time(NULL);
469                                            char *strtime = ctime(&tick);
470    #endif
471    
472                                    // write to file
473                                    if (Start == 1 && ts.Append) {
474                                            _lwrite(LogVar->FileHandle,"\r\n",strlen("\r\n"));
475                                    }
476                                    _lwrite(LogVar->FileHandle,"[",1);
477                                    // 変換した文字列の終端に \n が含まれているので取り除く。
478                                    _lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1);
479                                    _lwrite(LogVar->FileHandle,"] ",2);
480                            }
481    
482                          _lwrite(LogVar->FileHandle,(PCHAR)&b,1);                          _lwrite(LogVar->FileHandle,(PCHAR)&b,1);
483                          (LogVar->ByteCount)++;                          (LogVar->ByteCount)++;
484                  }                  }
# Line 520  void FileSendStart() Line 579  void FileSendStart()
579    if (strlen(&(SendVar->FullName[SendVar->DirLen]))==0)    if (strlen(&(SendVar->FullName[SendVar->DirLen]))==0)
580    {    {
581      Option = MAKELONG(ts.TransBin,0);      Option = MAKELONG(ts.TransBin,0);
582            SendVar->FullName[0] = 0;
583      if (! (*GetTransFname)(SendVar, ts.FileDir, GTF_SEND, &Option))      if (! (*GetTransFname)(SendVar, ts.FileDir, GTF_SEND, &Option))
584      {      {
585        FileTransEnd(OpSendFile);        FileTransEnd(OpSendFile);
# Line 1006  void BPStart(int mode) Line 1066  void BPStart(int mode)
1066      FileVar->OpId = OpBPSend;      FileVar->OpId = OpBPSend;
1067      if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0)      if (strlen(&(FileVar->FullName[FileVar->DirLen]))==0)
1068      {      {
1069              FileVar->FullName[0] = 0;
1070        if (! (*GetTransFname)(FileVar, ts.FileDir, GTF_BP, &Option))        if (! (*GetTransFname)(FileVar, ts.FileDir, GTF_BP, &Option))
1071        {        {
1072          ProtoEnd();          ProtoEnd();
# Line 1063  void QVStart(int mode) Line 1124  void QVStart(int mode)
1124      ProtoEnd();      ProtoEnd();
1125  }  }
1126  }  }
1127    
1128    /*
1129     * $Log$
1130     * Revision 1.6  2006/08/28 12:27:16  maya
1131     * デフォルトのログファイル名を指定できるようにした。
1132     *   エディットコントロールを "Additional settings" ダイアログに追加した。
1133     *   teraterm.ini ファイルに LogDefaultName エントリを追加した。
1134     *   ファイル名に strftime のフォーマットを使えるようにした。
1135     *
1136     * Revision 1.5  2006/07/23 14:12:26  yutakakn
1137     * ログに含める日付フォーマットを世界標準書式に変更した。
1138     *
1139     * Revision 1.4  2006/07/22 16:15:54  maya
1140     * ログ記録時に時刻も書き込む機能を追加した。
1141     *
1142     * Revision 1.3  2005/05/07 09:49:24  yutakakn
1143     * teraterm.iniに LogTypePlainText を追加した。
1144     *
1145     * Revision 1.2  2005/02/20 14:51:29  yutakakn
1146     * ログファイルの種別に"plain text"を追加。このオプションが有効の場合は、ログファイルに
1147     * ASCII非表示文字の採取をしない。
1148     *
1149     * 現在、無視するキャラクタは以下のとおり。
1150     *  ・BS
1151     *  ・ASCII(0x00-0x1f)のうち非表示なもの
1152     *
1153     * ただし、例外として以下のものはログ採取対象。
1154     *  ・HT
1155     *  ・CR
1156     *  ・LF
1157     *
1158     */

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

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