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 8911 by zmatsuo, Tue Aug 18 15:32:15 2020 UTC revision 8912 by zmatsuo, Tue Aug 18 15:32:23 2020 UTC
# Line 92  typedef struct { Line 92  typedef struct {
92    
93          PFileTransDlg FLogDlg;          PFileTransDlg FLogDlg;
94    
95          int log_code;          LogCode_t log_code;
96            BOOL bom;
97    
98  } TFileVar_;  } TFileVar_;
99  typedef TFileVar_ *PFileVar_;  typedef TFileVar_ *PFileVar_;
# Line 122  static BOOL CreateBinBuf(void); Line 123  static BOOL CreateBinBuf(void);
123  void LogPut1(BYTE b);  void LogPut1(BYTE b);
124  static void OutputStr(const wchar_t *str);  static void OutputStr(const wchar_t *str);
125  static void LogToFile(void);  static void LogToFile(void);
126    static void FLogOutputBOM(void);
127    
128  static BOOL OpenFTDlg_(PFileVar fv)  static BOOL OpenFTDlg_(PFileVar fv)
129  {  {
# Line 340  static void SetLogFlags(HWND Dialog) Line 342  static void SetLogFlags(HWND Dialog)
342          GetRB(Dialog, &val, IDC_ALLBUFF_INFIRST, IDC_ALLBUFF_INFIRST);          GetRB(Dialog, &val, IDC_ALLBUFF_INFIRST, IDC_ALLBUFF_INFIRST);
343          ts.LogAllBuffIncludedInFirst = val;          ts.LogAllBuffIncludedInFirst = val;
344    
345          ts.LogTimestampType = (GetCurSel(Dialog, IDC_TIMESTAMPTYPE) - 1);          ts.LogTimestampType = (WORD)(GetCurSel(Dialog, IDC_TIMESTAMPTYPE) - 1);
346  }  }
347    
348  /**  /**
# Line 563  static INT_PTR CALLBACK LogFnHook(HWND D Line 565  static INT_PTR CALLBACK LogFnHook(HWND D
565                          work->info->filename = _wcsdup(filename);                          work->info->filename = _wcsdup(filename);
566                          work->info->append = IsDlgButtonChecked(Dialog, IDC_APPEND) == BST_CHECKED;                          work->info->append = IsDlgButtonChecked(Dialog, IDC_APPEND) == BST_CHECKED;
567                          work->info->bom = IsDlgButtonChecked(Dialog, IDC_BOM) == BST_CHECKED;                          work->info->bom = IsDlgButtonChecked(Dialog, IDC_BOM) == BST_CHECKED;
568                          work->info->code = (int)SendDlgItemMessageA(Dialog, IDC_TEXTCODING_DROPDOWN, CB_GETCURSEL, 0, 0);                          work->info->code = (LogCode_t)SendDlgItemMessageA(Dialog, IDC_TEXTCODING_DROPDOWN, CB_GETCURSEL, 0, 0);
569                          SetLogFlags(Dialog);                          SetLogFlags(Dialog);
570                          EndDialog(Dialog, IDOK);                          EndDialog(Dialog, IDOK);
571                          break;                          break;
# Line 728  static BOOL LogStart(const wchar_t *fnam Line 730  static BOOL LogStart(const wchar_t *fnam
730                  */                  */
731                  fv->eLineEnd = Line_FileHead;                  fv->eLineEnd = Line_FileHead;
732          }          }
733            else {
734                    // 追記ではない(新規)場合は BOM を出力する
735                    if (fv->bom) {
736                            FLogOutputBOM();
737                    }
738            }
739    
740          // Log rotate configuration          // Log rotate configuration
741          LogVar->RotateMode = ts.LogRotate;          LogVar->RotateMode = ts.LogRotate;
# Line 911  static void LogRotate(void) Line 919  static void LogRotate(void)
919    
920          // 再オープン          // 再オープン
921          OpenLogFile(LogVar);          OpenLogFile(LogVar);
922            if (LogVar->bom) {
923                    FLogOutputBOM();
924            }
925          if (ts.DeferredLogWriteMode) {          if (ts.DeferredLogWriteMode) {
926                  StartThread(LogVar);                  StartThread(LogVar);
927          }          }
# Line 1112  void FLogRotateSize(size_t size) Line 1123  void FLogRotateSize(size_t size)
1123                  return;                  return;
1124          }          }
1125          LogVar->RotateMode = ROTATE_SIZE;          LogVar->RotateMode = ROTATE_SIZE;
1126          LogVar->RotateSize = size;          LogVar->RotateSize = (LONG)size;
1127  }  }
1128    
1129  /**  /**
# Line 1212  void FLogClose(void) Line 1223  void FLogClose(void)
1223   *      FLogGetLogFilename() や FLogOpenDialog() で   *      FLogGetLogFilename() や FLogOpenDialog() で
1224   *      ファイル名を取得できる。   *      ファイル名を取得できる。
1225   */   */
1226  BOOL FLogOpen(const wchar_t *fname)  BOOL FLogOpen(const wchar_t *fname, LogCode_t code, BOOL bom)
1227  {  {
1228          BOOL ret;          BOOL ret;
1229    
# Line 1231  BOOL FLogOpen(const wchar_t *fname) Line 1242  BOOL FLogOpen(const wchar_t *fname)
1242          fv->FileHandle = INVALID_HANDLE_VALUE;          fv->FileHandle = INVALID_HANDLE_VALUE;
1243          fv->LogThread = INVALID_HANDLE_VALUE;          fv->LogThread = INVALID_HANDLE_VALUE;
1244          fv->eLineEnd = Line_LineHead;          fv->eLineEnd = Line_LineHead;
         fv->log_code = 0;       // UTF-8  
1245    
1246            fv->log_code = code;
1247            fv->bom = bom;
1248          ret = LogStart(fname);          ret = LogStart(fname);
1249          if (ret == FALSE) {          if (ret == FALSE) {
1250                  FileTransEnd_();                  FileTransEnd_();
# Line 1490  void FLogPutUTF32(unsigned int u32) Line 1502  void FLogPutUTF32(unsigned int u32)
1502                  return;                  return;
1503          }          }
1504    
1505            // 行頭か?(改行を出力した直後)
1506          if (ts.LogTimestamp && fv->eLineEnd) {          if (ts.LogTimestamp && fv->eLineEnd) {
1507                    // タイムスタンプを出力
1508                  fv->eLineEnd = Line_Other; /* clear endmark*/                  fv->eLineEnd = Line_Other; /* clear endmark*/
1509                  wchar_t* strtime = TimeStampStr();                  wchar_t* strtime = TimeStampStr();
1510                  FLogWriteStr(strtime);                  FLogWriteStr(strtime);
# Line 1498  void FLogPutUTF32(unsigned int u32) Line 1512  void FLogPutUTF32(unsigned int u32)
1512          }          }
1513    
1514          switch(fv->log_code) {          switch(fv->log_code) {
1515          case 0: {          case LOG_UTF8: {
1516                  // UTF-8                  // UTF-8
1517                  char u8_buf[4];                  char u8_buf[4];
1518                  size_t u8_len = UTF32ToUTF8(u32, u8_buf, _countof(u8_buf));                  size_t u8_len = UTF32ToUTF8(u32, u8_buf, _countof(u8_buf));
# Line 1508  void FLogPutUTF32(unsigned int u32) Line 1522  void FLogPutUTF32(unsigned int u32)
1522                  }                  }
1523                  break;                  break;
1524          }          }
1525          case 1:          case LOG_UTF16LE:
1526          case 2: {          case LOG_UTF16BE: {
1527                  // UTF-16                  // UTF-16
1528                  wchar_t u16[2];                  wchar_t u16[2];
1529                  size_t u16_len = UTF32ToUTF16(u32, u16, _countof(u16));                  size_t u16_len = UTF32ToUTF16(u32, u16, _countof(u16));
1530                  size_t i;                  size_t i;
1531                  for (i = 0; i < u16_len; i++) {                  for (i = 0; i < u16_len; i++) {
1532                          if (fv->log_code == 1) {                          if (fv->log_code == LOG_UTF16LE) {
1533                                  // UTF-16LE                                  // UTF-16LE
1534                                  LogPut1(u16[i] & 0xff);                                  LogPut1(u16[i] & 0xff);
1535                                  LogPut1((u16[i] >> 8) & 0xff);                                  LogPut1((u16[i] >> 8) & 0xff);
# Line 1534  void FLogPutUTF32(unsigned int u32) Line 1548  void FLogPutUTF32(unsigned int u32)
1548          }          }
1549  }  }
1550    
1551  void FLogOutputBOM(void)  static void FLogOutputBOM(void)
1552  {  {
1553          PFileVar fv = LogVar;          PFileVar fv = LogVar;
1554          DWORD wrote;          DWORD wrote;
# Line 1566  void FLogOutputBOM(void) Line 1580  void FLogOutputBOM(void)
1580          }          }
1581  }  }
1582    
 void FLogSetCode(int code)  
 {  
         PFileVar fv = LogVar;  
         fv->log_code = code;  
 }  
   
1583  static void OutputStr(const wchar_t *str)  static void OutputStr(const wchar_t *str)
1584  {  {
1585          size_t len;          size_t len;

Legend:
Removed from v.8911  
changed lines
  Added in v.8912

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