[ttssh2-commit] [9872] ファイル内グローバル変数を構造体へ移動した

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 4月 21日 (木) 22:36:07 JST


Revision: 9872
          https://osdn.net/projects/ttssh2/scm/svn/commits/9872
Author:   zmatsuo
Date:     2022-04-21 22:36:07 +0900 (Thu, 21 Apr 2022)
Log Message:
-----------
ファイル内グローバル変数を構造体へ移動した

- FileLog
- BinLog

Modified Paths:
--------------
    trunk/teraterm/teraterm/filesys_log.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/filesys_log.cpp
===================================================================
--- trunk/teraterm/teraterm/filesys_log.cpp	2022-04-20 13:02:00 UTC (rev 9871)
+++ trunk/teraterm/teraterm/filesys_log.cpp	2022-04-21 13:36:07 UTC (rev 9872)
@@ -96,6 +96,8 @@
 	LogCode_t log_code;
 	BOOL bom;
 
+	BOOL FileLog;
+	BOOL BinLog;
 } TFileVar_;
 typedef TFileVar_ *PFileVar_;
 
@@ -104,9 +106,6 @@
 
 static PFileVar LogVar = NULL;
 
-static BOOL FileLog = FALSE;
-static BOOL BinLog = FALSE;
-
 static PCHAR cv_LogBuf;
 static int cv_LogPtr, cv_LStart, cv_LCount;
 static PCHAR cv_BinBuf;
@@ -706,8 +705,8 @@
 
 	if (ts.LogBinary > 0)
 	{
-		BinLog = TRUE;
-		FileLog = FALSE;
+		fv->BinLog = TRUE;
+		fv->FileLog = FALSE;
 		if (! CreateBinBuf())
 		{
 			return FALSE;
@@ -714,8 +713,8 @@
 		}
 	}
 	else {
-		BinLog = FALSE;
-		FileLog = TRUE;
+		fv->BinLog = FALSE;
+		fv->FileLog = TRUE;
 		if (! CreateLogBuf())
 		{
 			return FALSE;
@@ -777,10 +776,10 @@
 		StartThread(fv);
 	}
 
-	if (FileLog) {
+	if (fv->FileLog) {
 		cv.Log1Byte = LogPut1;
 	}
-	if (BinLog) {
+	if (fv->BinLog) {
 		cv.Log1Bin = Log1Bin;
 		cv.LogBinSkip = LogBinSkip;
 	}
@@ -819,12 +818,14 @@
  */
 void LogPut1(BYTE b)
 {
+	PFileVar fv = LogVar;
+
 	cv_LogBuf[cv_LogPtr] = b;
 	cv_LogPtr++;
 	if (cv_LogPtr>=InBuffSize)
 		cv_LogPtr = cv_LogPtr-InBuffSize;
 
-	if (FileLog)
+	if (fv->FileLog)
 	{
 		if (cv_LCount>=InBuffSize)
 		{
@@ -972,17 +973,18 @@
  */
 static void LogToFile(void)
 {
+	PFileVar fv = LogVar;
 	PCHAR Buf;
 	int Start, Count;
 	BYTE b;
 
-	if (FileLog)
+	if (fv->FileLog)
 	{
 		Buf = cv_LogBuf;
 		Start = cv_LStart;
 		Count = cv_LCount;
 	}
-	else if (BinLog)
+	else if (fv->BinLog)
 	{
 		Buf = cv_BinBuf;
 		Start = cv_BStart;
@@ -1030,7 +1032,7 @@
 
 	logfile_unlock();
 
-	if (FileLog)
+	if (fv->FileLog)
 	{
 		cv_LStart = Start;
 		cv_LCount = Count;
@@ -1094,8 +1096,9 @@
 	if (LogVar == NULL) {
 		return;
 	}
-	FileLog = FALSE;
-	BinLog = FALSE;
+	PFileVar fv = LogVar;
+	fv->FileLog = FALSE;
+	fv->BinLog = FALSE;
 	cv.Log1Byte = NULL;
 	cv.Log1Bin = NULL;
 	cv.LogBinSkip = NULL;
@@ -1243,7 +1246,6 @@
 	if (LogVar != NULL) {
 		return FALSE;
 	}
-	if ((FileLog) || (BinLog)) return FALSE;
 
 	//
 	PFileVar fv = (PFileVar)malloc(sizeof(TFileVar));
@@ -1273,12 +1275,12 @@
 
 BOOL FLogIsOpendText(void)
 {
-	return LogVar != NULL && FileLog;
+	return LogVar != NULL && LogVar->FileLog;
 }
 
 BOOL FLogIsOpendBin(void)
 {
-	return LogVar != NULL && BinLog;
+	return LogVar != NULL && LogVar->BinLog;
 }
 
 void FLogWriteStr(const wchar_t *str)
@@ -1450,10 +1452,14 @@
  */
 int FLogGetCount(void)
 {
-	if (FileLog) {
+	PFileVar fv = LogVar;
+	if (fv == NULL) {
+		return 0;
+	}
+	if (fv->FileLog) {
 		return cv_LCount;
 	}
-	if (BinLog) {
+	if (fv->BinLog) {
 		return cv_BCount;
 	}
 	return 0;
@@ -1464,10 +1470,14 @@
  */
 int FLogGetFreeCount(void)
 {
-	if (FileLog) {
+	PFileVar fv = LogVar;
+	if (fv == NULL) {
+		return 0;
+	}
+	if (fv->FileLog) {
 		return InBuffSize - cv_LCount;
 	}
-	if (BinLog) {
+	if (fv->BinLog) {
 		return InBuffSize - cv_BCount;
 	}
 	return 0;
@@ -1478,9 +1488,13 @@
  */
 void FLogWriteFile(void)
 {
+	PFileVar fv = LogVar;
+	if (fv == NULL) {
+		return;
+	}
 	if (cv_LogBuf!=NULL)
 	{
-		if (FileLog) {
+		if (fv->FileLog) {
 			LogToFile();
 		}
 	}
@@ -1487,7 +1501,7 @@
 
 	if (cv_BinBuf!=NULL)
 	{
-		if (BinLog) {
+		if (fv->BinLog) {
 			LogToFile();
 		}
 	}


ttssh2-commit メーリングリストの案内
Back to archive index