Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/teraterm/teraterm/filesys_log.cpp

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

revision 8909 by zmatsuo, Tue Aug 18 15:31:59 2020 UTC revision 8910 by zmatsuo, Tue Aug 18 15:32:07 2020 UTC
# Line 920  static void LogRotate(void) Line 920  static void LogRotate(void)
920          logfile_unlock();          logfile_unlock();
921  }  }
922    
923  static char *TimeStampStr()  static wchar_t *TimeStampStr()
924  {  {
925          char *strtime = NULL;          char *strtime = NULL;
926          switch (ts.LogTimestampType) {          switch (ts.LogTimestampType) {
# Line 945  static char *TimeStampStr() Line 945  static char *TimeStampStr()
945          strncat_s(tmp, sizeof(tmp), strtime, _TRUNCATE);          strncat_s(tmp, sizeof(tmp), strtime, _TRUNCATE);
946          strncat_s(tmp, sizeof(tmp), "] ", _TRUNCATE);          strncat_s(tmp, sizeof(tmp), "] ", _TRUNCATE);
947    
948          return strdup(tmp);          return ToWcharA(tmp);
 //      return ToWcharA(tmp);  
949  }  }
950    
951  /**  /**
# Line 957  static void LogToFile(void) Line 956  static void LogToFile(void)
956          PCHAR Buf;          PCHAR Buf;
957          int Start, Count;          int Start, Count;
958          BYTE b;          BYTE b;
         PFileVar fv = LogVar;  
959    
960          if (FileLog)          if (FileLog)
961          {          {
# Line 994  static void LogToFile(void) Line 992  static void LogToFile(void)
992                          WriteBuf = (PCHAR)realloc(WriteBuf, WriteBufMax);                          WriteBuf = (PCHAR)realloc(WriteBuf, WriteBufMax);
993                  }                  }
994    
                 // add time stamp string  
                 if ( ts.LogTimestamp && fv->eLineEnd ) {  
                         char *strtime = TimeStampStr();  
                         size_t len = strlen(strtime);  
                         memcpy(&WriteBuf[WriteBufLen], strtime, len);  
                         free(strtime);  
                         WriteBufLen += len;  
                 }  
   
                 /* 2007.05.24 Gentaro */  
                 if( b == 0x0a ){  
                         fv->eLineEnd = Line_LineHead; /* set endmark*/  
                 }  
                 else {  
                         fv->eLineEnd = Line_Other; /* clear endmark*/  
                 }  
   
995                  WriteBuf[WriteBufLen++] = b;                  WriteBuf[WriteBufLen++] = b;
996    
997                  (LogVar->ByteCount)++;                  (LogVar->ByteCount)++;
# Line 1280  BOOL FLogIsOpendBin(void) Line 1261  BOOL FLogIsOpendBin(void)
1261  void FLogWriteStr(const wchar_t *str)  void FLogWriteStr(const wchar_t *str)
1262  {  {
1263          if (LogVar != NULL) {          if (LogVar != NULL) {
 #if 0  
                 DWORD wrote;  
                 size_t len = wcslen(str)  * sizeof(wchar_t);  
                 logfile_lock();  
                 WriteFile(LogVar->FileHandle, str, len, &wrote, NULL);  
                 LogVar->eLineEnd = Line_LineHead;  
                 logfile_unlock();  
                 LogVar->ByteCount =  
                         LogVar->ByteCount + len;  
                 LogVar->FLogDlg->RefreshNum(LogVar->StartTime, LogVar->FileSize, LogVar->ByteCount);  
 #endif  
1264                  OutputStr(str);                  OutputStr(str);
1265          }          }
1266  }  }
# Line 1508  void FLogWriteFile(void) Line 1478  void FLogWriteFile(void)
1478                  if (BinLog) {                  if (BinLog) {
1479                          LogToFile();                          LogToFile();
1480                  }                  }
 //              GlobalUnlock(cv_HBinBuf);  
 //              cv_BinBuf = NULL;  
1481          }          }
1482  }  }
1483    
# Line 1524  void FLogPutUTF32(unsigned int u32) Line 1492  void FLogPutUTF32(unsigned int u32)
1492                  return;                  return;
1493          }          }
1494    
1495            if (ts.LogTimestamp && fv->eLineEnd) {
1496                    fv->eLineEnd = Line_Other; /* clear endmark*/
1497                    wchar_t* strtime = TimeStampStr();
1498                    FLogWriteStr(strtime);
1499                    free(strtime);
1500            }
1501    
1502          switch(fv->log_code) {          switch(fv->log_code) {
1503          case 0: {          case 0: {
1504                  // UTF-8                  // UTF-8
# Line 1555  void FLogPutUTF32(unsigned int u32) Line 1530  void FLogPutUTF32(unsigned int u32)
1530                  }                  }
1531          }          }
1532          }          }
1533    
1534            if (u32 == 0x0a) {
1535                    fv->eLineEnd = Line_LineHead; /* set endmark*/
1536            }
1537  }  }
1538    
1539  void FLogOutputBOM(void)  void FLogOutputBOM(void)
1540  {  {
1541          PFileVar fv = LogVar;          PFileVar fv = LogVar;
1542            DWORD wrote;
1543    
1544          switch(fv->log_code) {          switch(fv->log_code) {
1545          case 0:          case 0: {
1546                  // UTF-8                  // UTF-8
1547                  LogPut1(0xef);                  const char *bom = "\xef\xbb\xbf";
1548                  LogPut1(0xbb);                  WriteFile(LogVar->FileHandle, bom, 3, &wrote, NULL);
1549                  LogPut1(0xbf);                  LogVar->ByteCount += 3;
1550                  break;                  break;
1551          case 1:          }
1552            case 1: {
1553                  // UTF-16LE                  // UTF-16LE
1554                  LogPut1(0xff);                  const char *bom = "\xff\xfe";
1555                  LogPut1(0xfe);                  WriteFile(LogVar->FileHandle, bom, 2, &wrote, NULL);
1556                    LogVar->ByteCount += 2;
1557                  break;                  break;
1558          case 2:          }
1559            case 2: {
1560                  // UTF-16BE                  // UTF-16BE
1561                  LogPut1(0xfe);                  const char *bom = "\xfe\xff";
1562                  LogPut1(0xff);                  WriteFile(LogVar->FileHandle, bom, 2, &wrote, NULL);
1563                    LogVar->ByteCount += 2;
1564                  break;                  break;
1565            }
1566          default:          default:
1567                  break;                  break;
1568          }          }

Legend:
Removed from v.8909  
changed lines
  Added in v.8910

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