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 8902 by zmatsuo, Tue Aug 18 15:30:18 2020 UTC revision 8904 by zmatsuo, Tue Aug 18 15:31:14 2020 UTC
# Line 92  typedef struct { Line 92  typedef struct {
92          BOOL IsPause;          BOOL IsPause;
93    
94          PFileTransDlg FLogDlg;          PFileTransDlg FLogDlg;
95    
96            int log_code;
97    
98  } TFileVar_;  } TFileVar_;
99  typedef TFileVar_ *PFileVar_;  typedef TFileVar_ *PFileVar_;
100    
# Line 1308  BOOL FLogOpen(const wchar_t *fname) Line 1311  BOOL FLogOpen(const wchar_t *fname)
1311          fv->FileHandle = INVALID_HANDLE_VALUE;          fv->FileHandle = INVALID_HANDLE_VALUE;
1312          fv->LogThread = INVALID_HANDLE_VALUE;          fv->LogThread = INVALID_HANDLE_VALUE;
1313          fv->eLineEnd = Line_LineHead;          fv->eLineEnd = Line_LineHead;
1314            fv->log_code = 0;       // UTF-8
1315    
1316          ret = LogStart(fname);          ret = LogStart(fname);
1317          if (ret == FALSE) {          if (ret == FALSE) {
# Line 1322  BOOL FLogIsOpend(void) Line 1326  BOOL FLogIsOpend(void)
1326          return LogVar != NULL;          return LogVar != NULL;
1327  }  }
1328    
1329    BOOL FLogIsOpendText(void)
1330    {
1331            return LogVar != NULL && FileLog;
1332    }
1333    
1334    BOOL FLogIsOpendBin(void)
1335    {
1336            return LogVar != NULL && BinLog;
1337    }
1338    
1339  void FLogWriteStr(const char *str)  void FLogWriteStr(const char *str)
1340  {  {
1341          if (LogVar != NULL)          if (LogVar != NULL)
# Line 1540  void FLogWriteFile(void) Line 1554  void FLogWriteFile(void)
1554                  cv.BinBuf = NULL;                  cv.BinBuf = NULL;
1555          }          }
1556  }  }
1557    
1558    void FLogPutUTF32(unsigned int u32)
1559    {
1560            PFileVar fv = LogVar;
1561            size_t i;
1562            BOOL log_available = (cv.HLogBuf != 0);
1563    
1564            if (!log_available) {
1565                    // ログには出力しない(macro出力だけだった)
1566                    return;
1567            }
1568    
1569            switch(fv->log_code) {
1570            case 0: {
1571                    // UTF-8
1572                    char u8_buf[4];
1573                    size_t u8_len = UTF32ToUTF8(u32, u8_buf, _countof(u8_buf));
1574                    for (i = 0; i < u8_len; i++) {
1575                            BYTE b = u8_buf[i];
1576                            LogPut1(b);
1577                    }
1578                    break;
1579            }
1580            case 1:
1581            case 2: {
1582                    // UTF-16
1583                    wchar_t u16[2];
1584                    size_t u16_len = UTF32ToUTF16(u32, u16, _countof(u16));
1585                    size_t i;
1586                    for (i = 0; i < u16_len; i++) {
1587                            if (fv->log_code == 1) {
1588                                    // UTF-16LE
1589                                    LogPut1(u16[i] & 0xff);
1590                                    LogPut1((u16[i] >> 8) & 0xff);
1591                            }
1592                            else {
1593                                    // UTF-16BE
1594                                    LogPut1((u16[i] >> 8) & 0xff);
1595                                    LogPut1(u16[i] & 0xff);
1596                            }
1597                    }
1598            }
1599            }
1600    }
1601    
1602    void FLogOutputBOM(void)
1603    {
1604            PFileVar fv = LogVar;
1605            BOOL needs_unlock = FALSE;
1606    
1607            if ((cv.HLogBuf!=NULL) && (cv.LogBuf==NULL)) {
1608                    cv.LogBuf = (PCHAR)GlobalLock(cv.HLogBuf);
1609                    needs_unlock = TRUE;
1610            }
1611    
1612            switch(fv->log_code) {
1613            case 0:
1614                    // UTF-8
1615                    LogPut1(0xef);
1616                    LogPut1(0xbb);
1617                    LogPut1(0xbf);
1618                    break;
1619            case 1:
1620                    // UTF-16LE
1621                    LogPut1(0xfe);
1622                    LogPut1(0xff);
1623                    break;
1624            case 2:
1625                    // UTF-16BE
1626                    LogPut1(0xff);
1627                    LogPut1(0xfe);
1628                    break;
1629            default:
1630                    break;
1631            }
1632    
1633            if (needs_unlock) {
1634                    GlobalUnlock(cv.HLogBuf);
1635                    cv.LogBuf = NULL;
1636            }
1637    }
1638    
1639    void FLogSetCode(int code)
1640    {
1641            PFileVar fv = LogVar;
1642            fv->log_code = code;
1643    }

Legend:
Removed from v.8902  
changed lines
  Added in v.8904

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