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.10 by maya, Mon May 14 13:29:58 2007 UTC revision 1.15 by maya, Wed Jun 6 14:02:53 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 165  static PProtoDlg PtDlg = NULL; Line 177  static PProtoDlg PtDlg = NULL;
177  BOOL OpenFTDlg(PFileVar fv)  BOOL OpenFTDlg(PFileVar fv)
178  {  {
179    PFileTransDlg FTDlg;    PFileTransDlg FTDlg;
180  #ifdef I18N  #ifndef NO_I18N
181    HWND HFTDlg;    HWND HFTDlg;
182  #endif  #endif
183    
# Line 173  BOOL OpenFTDlg(PFileVar fv) Line 185  BOOL OpenFTDlg(PFileVar fv)
185        
186    if (FTDlg!=NULL)    if (FTDlg!=NULL)
187    {    {
188  #ifdef I18N  #ifndef NO_I18N
189      FTDlg->Create(fv, &cv, &ts);      FTDlg->Create(fv, &cv, &ts);
190  #else  #else
191      FTDlg->Create(fv, &cv);      FTDlg->Create(fv, &cv);
# Line 188  BOOL OpenFTDlg(PFileVar fv) Line 200  BOOL OpenFTDlg(PFileVar fv)
200    else    else
201      SendDlg = FTDlg; /* File send */      SendDlg = FTDlg; /* File send */
202    
203  #ifdef I18N  #ifndef NO_I18N
204    HFTDlg=FTDlg->GetSafeHwnd();    HFTDlg=FTDlg->GetSafeHwnd();
205    
206    GetDlgItemText(HFTDlg, IDC_TRANS_FILENAME, ts.UIMsg, sizeof(ts.UIMsg));    GetDlgItemText(HFTDlg, IDC_TRANS_FILENAME, ts.UIMsg, sizeof(ts.UIMsg));
# Line 256  void ConvertLogname(char *c) Line 268  void ConvertLogname(char *c)
268  {  {
269    char buf[MAXPATHLEN], buf2[MAXPATHLEN], *p = c;    char buf[MAXPATHLEN], buf2[MAXPATHLEN], *p = c;
270    
271      memset(buf, 0, sizeof(buf));
272    
273    while(*p != '\0') {    while(*p != '\0') {
274      if (*p == '&' && *(p+1) != '\0') {      if (*p == '&' && *(p+1) != '\0') {
275        switch (*(p+1)) {        switch (*(p+1)) {
# Line 292  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 303  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 317  void LogStart() Line 342  void LogStart()
342                                                    (0x2000 * ts.LogTimestamp));                                                    (0x2000 * ts.LogTimestamp));
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)-1);
346                    LogVar->FullName[sizeof(LogVar->FullName)-1] = '\0';
347    
348                  ParseStrftimeFileName(LogVar->FullName);                  ParseStrftimeFileName(LogVar->FullName);
349    
350                  // &h をホスト名に置換 (2007.5.14)                  // &h をホスト名に置換 (2007.5.14)
351                  ConvertLogname(LogVar->FullName);                  ConvertLogname(LogVar->FullName);
352    
353                  if (! (*GetTransFname)(LogVar, ts.FileDir, GTF_LOG, &Option))                  if (! (*GetTransFname)(LogVar, logdir, GTF_LOG, &Option))
354                  {                  {
355                          FreeFileVar(&LogVar);                          FreeFileVar(&LogVar);
356                          FreeTTFILE();                          FreeTTFILE();
# Line 349  void LogStart() Line 376  void LogStart()
376    
377          }          }
378          else {          else {
379                    // LogVar->DirLen = 0 だとここに来る
380                    // フルパス・相対パスともに LogVar->FullName に入れておく必要がある
381                    char FileName[MAX_PATH];
382    
383                    // フルパス化
384                    strncpy(FileName, LogVar->FullName, sizeof(FileName)-1);
385                    FileName[sizeof(FileName)-1] = '\0';
386                    ConvFName(logdir,FileName,"",LogVar->FullName);
387    
388                    ParseStrftimeFileName(LogVar->FullName);
389    
390                  // &h をホスト名に置換 (2007.5.14)                  // &h をホスト名に置換 (2007.5.14)
391                  ConvertLogname(LogVar->FullName);                  ConvertLogname(LogVar->FullName);
392                  (*SetFileVar)(LogVar);                  (*SetFileVar)(LogVar);
# Line 377  void LogStart() Line 415  void LogStart()
415          cv.LCount = 0;          cv.LCount = 0;
416    
417          HelpId = HlpFileLog;          HelpId = HlpFileLog;
418            /* 2007.05.24 Gentaro */
419            eLineEnd = Line_LineHead;
420    
421          if (ts.Append > 0)          if (ts.Append > 0)
422          {          {
423                  LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE);                  LogVar->FileHandle = _lopen(LogVar->FullName,OF_WRITE);
424                  if (LogVar->FileHandle>0)                  if (LogVar->FileHandle>0){
425                          _llseek(LogVar->FileHandle,0,2);                          _llseek(LogVar->FileHandle,0,2);
426                            /* 2007.05.24 Gentaro
427                                    If log file already exists,
428                                    a newline is inserted before the first timestamp.
429                            */
430                            eLineEnd = Line_FileHead;
431                    }
432                  else                  else
433                          LogVar->FileHandle = _lcreat(LogVar->FullName,0);                          LogVar->FileHandle = _lcreat(LogVar->FullName,0);
434          }          }
# Line 488  void CommentLogToFile(char *buf, int siz Line 535  void CommentLogToFile(char *buf, int siz
535          DWORD wrote;          DWORD wrote;
536    
537          if (LogVar == NULL || !LogVar->FileOpen) {          if (LogVar == NULL || !LogVar->FileOpen) {
538  #ifdef I18N  #ifndef NO_I18N
539                  char uimsg[MAX_UIMSG];                  char uimsg[MAX_UIMSG];
540                  strcpy(uimsg, "ERROR");                  strcpy(uimsg, "ERROR");
541                  get_lang_msg("MSG_ERROR", uimsg, ts.UILanguageFile);                  get_lang_msg("MSG_ERROR", uimsg, ts.UILanguageFile);
# Line 504  void CommentLogToFile(char *buf, int siz Line 551  void CommentLogToFile(char *buf, int siz
551          logfile_lock();          logfile_lock();
552          WriteFile((HANDLE)LogVar->FileHandle, buf, size, &wrote, NULL);          WriteFile((HANDLE)LogVar->FileHandle, buf, size, &wrote, NULL);
553          WriteFile((HANDLE)LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // 改行          WriteFile((HANDLE)LogVar->FileHandle, "\r\n", 2, &wrote, NULL); // 改行
554            /* Set Line End Flag
555                    2007.05.24 Gentaro
556            */
557            eLineEnd = Line_LineHead;
558          logfile_unlock();          logfile_unlock();
559  }  }
560    
# Line 541  void LogToFile() Line 592  void LogToFile()
592                  {                  {
593                          // 時刻を書き出す(2006.7.23 maya)                          // 時刻を書き出す(2006.7.23 maya)
594                          // 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka)                          // 日付フォーマットを日本ではなく世界標準に変更した (2006.7.23 yutaka)
595                          if (ts.LogTimestamp &&                          /* 2007.05.24 Gentaro */
596                                  (Start == 1 || Buf[Start-2] == 0x0a)) {                          if ( ts.LogTimestamp && eLineEnd ) {
597  #if 0  #if 0
598                                  SYSTEMTIME      LocalTime;                                  SYSTEMTIME      LocalTime;
599                                  GetLocalTime(&LocalTime);                                  GetLocalTime(&LocalTime);
# Line 557  void LogToFile() Line 608  void LogToFile()
608                                          time_t tick = time(NULL);                                          time_t tick = time(NULL);
609                                          char *strtime = ctime(&tick);                                          char *strtime = ctime(&tick);
610  #endif  #endif
611                                    /* 2007.05.24 Gentaro */
612                                  // write to file                                  if( eLineEnd == Line_FileHead ){
613                                  if (Start == 1 && ts.Append) {                                          _lwrite(LogVar->FileHandle,"\r\n",2);
                                         _lwrite(LogVar->FileHandle,"\r\n",strlen("\r\n"));  
614                                  }                                  }
615                                  _lwrite(LogVar->FileHandle,"[",1);                                  _lwrite(LogVar->FileHandle,"[",1);
616                                  // 変換した文字列の終端に \n が含まれているので取り除く。                                  // 変換した文字列の終端に \n が含まれているので取り除く。
617                                  _lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1);                                  _lwrite(LogVar->FileHandle, strtime, strlen(strtime) - 1);
618                                  _lwrite(LogVar->FileHandle,"] ",2);                                  _lwrite(LogVar->FileHandle,"] ",2);
619                          }                          }
620                            
621                            /* 2007.05.24 Gentaro */
622                            if( b == 0x0a ){
623                                    eLineEnd = Line_LineHead; /* set endmark*/
624                            }
625                            else {
626                                    eLineEnd = Line_Other; /* clear endmark*/
627                            }
628    
629                          _lwrite(LogVar->FileHandle,(PCHAR)&b,1);                          _lwrite(LogVar->FileHandle,(PCHAR)&b,1);
630                          (LogVar->ByteCount)++;                          (LogVar->ByteCount)++;
# Line 843  BOOL OpenProtoDlg(PFileVar fv, int IdPro Line 901  BOOL OpenProtoDlg(PFileVar fv, int IdPro
901  {  {
902    int vsize;    int vsize;
903    PProtoDlg pd;    PProtoDlg pd;
904  #ifdef I18N  #ifndef NO_I18N
905    HWND Hpd;    HWND Hpd;
906  #endif  #endif
907    
# Line 897  BOOL OpenProtoDlg(PFileVar fv, int IdPro Line 955  BOOL OpenProtoDlg(PFileVar fv, int IdPro
955      ProtoVar = NULL;      ProtoVar = NULL;
956      return FALSE;      return FALSE;
957    }    }
958  #ifdef I18N  #ifndef NO_I18N
959    pd->Create(fv,&ts);    pd->Create(fv,&ts);
960  #else  #else
961    pd->Create(fv);    pd->Create(fv);
962  #endif  #endif
963    
964  #ifdef I18N  #ifndef NO_I18N
965    Hpd=pd->GetSafeHwnd();    Hpd=pd->GetSafeHwnd();
966    
967    GetDlgItemText(Hpd, IDC_PROT_FILENAME, ts.UIMsg, sizeof(ts.UIMsg));    GetDlgItemText(Hpd, IDC_PROT_FILENAME, ts.UIMsg, sizeof(ts.UIMsg));
# Line 1242  void QVStart(int mode) Line 1300  void QVStart(int mode)
1300    
1301  /*  /*
1302   * $Log$   * $Log$
1303     * Revision 1.15  2007/06/06 14:02:53  maya
1304     * プリプロセッサにより構造体が変わってしまうので、INET6 と I18N の #define を逆転させた。
1305     *
1306     * Revision 1.14  2007/05/31 14:39:05  maya
1307     * 接続時に自動的にログ採取を開始できるようにした。
1308     *
1309     * Revision 1.13  2007/05/30 16:04:27  maya
1310     * 標準のログ保存先を指定できるようにした。
1311     *
1312     * Revision 1.12  2007/05/25 09:56:05  yutakapon
1313     * タイムスタンプ付きログで1KBごとに不要な改行が入るバグを修正。
1314     *
1315     * Revision 1.11  2007/05/14 14:07:14  maya
1316     * バッファをクリアしていないので落ちる問題を修正した。
1317     *
1318   * Revision 1.10  2007/05/14 13:29:58  maya   * Revision 1.10  2007/05/14 13:29:58  maya
1319   * ログファイル名中の &h を、接続中のホスト名に変換する機能を追加した。   * ログファイル名中の &h を、接続中のホスト名に変換する機能を追加した。
1320   *   *

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.15

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