Revision: 8876 https://osdn.net/projects/ttssh2/scm/svn/commits/8876 Author: zmatsuo Date: 2020-08-06 00:06:06 +0900 (Thu, 06 Aug 2020) Log Message: ----------- filesys_log.h を作成 - filesys.h から分離 - 使用していないので filesys_log から ttpfile.dll のロードを行わないようにした - ログのポーズに cv.FilePause を使用しないようにした Modified Paths: -------------- branches/filesys_log/teraterm/teraterm/filesys.cpp branches/filesys_log/teraterm/teraterm/filesys.h branches/filesys_log/teraterm/teraterm/filesys_log.cpp branches/filesys_log/teraterm/teraterm/ftdlg.cpp branches/filesys_log/teraterm/teraterm/vtwin.cpp Added Paths: ----------- branches/filesys_log/teraterm/teraterm/filesys_log.h -------------- next part -------------- Modified: branches/filesys_log/teraterm/teraterm/filesys.cpp =================================================================== --- branches/filesys_log/teraterm/teraterm/filesys.cpp 2020-08-05 15:05:57 UTC (rev 8875) +++ branches/filesys_log/teraterm/teraterm/filesys.cpp 2020-08-05 15:06:06 UTC (rev 8876) @@ -381,9 +381,10 @@ OpLog: close Log OpSendFile: close FileSend */ { - if (((OpId==0) || (OpId==OpLog)) && (FileLog || BinLog)) - { - FLogClose(); + if ((OpId==0) || (OpId==OpLog)) { + if (FLogIsOpend()) { + FLogClose(); + } } if (((OpId==0) || (OpId==OpSendFile)) && FSend) Modified: branches/filesys_log/teraterm/teraterm/filesys.h =================================================================== --- branches/filesys_log/teraterm/teraterm/filesys.h 2020-08-05 15:05:57 UTC (rev 8875) +++ branches/filesys_log/teraterm/teraterm/filesys.h 2020-08-05 15:06:06 UTC (rev 8876) @@ -27,6 +27,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#pragma once + /* TERATERM.EXE, file transfer routines */ #ifdef __cplusplus extern "C" { @@ -92,35 +94,8 @@ extern PFileVar SendVar, FileVar; -// log -typedef struct { - wchar_t *filename; // [in] \x83t\x83@\x83C\x83\x8B\x96\xBC\x8F\x89\x8A\xFA\x92l(NULL=default) [out] \x93\xFC\x97̓t\x83@\x83C\x83\x8B\x96\xBC\x81Afree()\x82\xB7\x82邱\x82\xC6 - BOOL append; // TRUE/FALSE = append/new(overwrite) - BOOL bom; // TRUE = BOM\x82\xA0\x82\xE8 - int code; // 0/1/2 = UTF-8/UTF-16LE/UTF-16BE -} FLogDlgInfo_t; -extern BOOL FileLog, BinLog; -void logfile_lock_initialize(void); -void LogPut1(BYTE b); -void FLogPause(BOOL Pause); -void FLogRotateSize(size_t size); -void FLogRotateRotate(int step); -void FLogRotateHalt(void); -void FLogAddCommentDlg(HINSTANCE hInst, HWND hWnd); -void FLogClose(void); -BOOL FLogOpen(const wchar_t *fname); -BOOL FLogIsOpend(void); -void FLogWriteStr(const char *str); -void FLogInfo(char *param_ptr, size_t param_len); -const wchar_t *FLogGetFilename(void); -BOOL FLogOpenDialog(HINSTANCE hInst, HWND hWnd, FLogDlgInfo_t *info); -wchar_t *FLogGetLogFilename(const wchar_t *log_filename); -BOOL FLogIsPause(void); -void FLogWindow(int nCmdShow); -void FLogShowDlg(void); -int FLogGetCount(void); -void FLogWriteFile(void); - #ifdef __cplusplus } #endif + +#include "filesys_log.h" Modified: branches/filesys_log/teraterm/teraterm/filesys_log.cpp =================================================================== --- branches/filesys_log/teraterm/teraterm/filesys_log.cpp 2020-08-05 15:05:57 UTC (rev 8875) +++ branches/filesys_log/teraterm/teraterm/filesys_log.cpp 2020-08-05 15:06:06 UTC (rev 8876) @@ -28,7 +28,11 @@ /* TERATERM.EXE, log routines */ #include <stdio.h> -#include <io.h> +#if !defined(_CRTDBG_MAP_ALLOC) +#define _CRTDBG_MAP_ALLOC +#endif +#include <stdlib.h> +#include <crtdbg.h> #include <process.h> #include <windows.h> #include <htmlhelp.h> @@ -53,7 +57,7 @@ #include "asprintf.h" #include "filesys_log_res.h" -#include "filesys.h" +#include "filesys_log.h" typedef struct { wchar_t *FullName; @@ -62,7 +66,6 @@ BOOL FileOpen; HANDLE FileHandle; LONG FileSize, ByteCount; - BOOL OverWrite; DWORD StartTime; @@ -74,6 +77,8 @@ HANDLE LogThread; DWORD LogThreadId; HANDLE LogThreadEvent; + + BOOL IsPause; } TFileVar_; typedef TFileVar_ *PFileVar_; @@ -82,8 +87,8 @@ static PFileVar LogVar = NULL; -BOOL FileLog = FALSE; -BOOL BinLog = FALSE; +static BOOL FileLog = FALSE; +static BOOL BinLog = FALSE; /* Line Head flag for timestamping @@ -644,8 +649,6 @@ LogVar->FullName = _wcsdup(fname); - if (! LoadTTFILE()) return FALSE; - PFileVar fv = LogVar; wchar_t *p = wcsrchr(fv->FullName, L'\\'); if (p == NULL) { @@ -736,7 +739,7 @@ return FALSE; } - cv.FilePause &= ~OpLog; + LogVar->IsPause = FALSE; LogVar->StartTime = GetTickCount(); // \x92x\x89\x84\x8F\x91\x82\xAB\x8D\x9E\x82ݗp\x83X\x83\x8C\x83b\x83h\x82\xF0\x8BN\x82\xB1\x82\xB7\x81B @@ -1183,6 +1186,9 @@ static void FileTransEnd_(void) { + if (LogVar == NULL) { + return; + } FileLog = FALSE; BinLog = FALSE; cv.Log1Byte = NULL; @@ -1193,23 +1199,15 @@ FLogDlg->DestroyWindow(); FLogDlg = NULL; } - if (LogVar != NULL) - { - CloseFileSync(LogVar); - free(LogVar->FullName); - free(LogVar->FileName); - free(LogVar); - LogVar = NULL; - } + CloseFileSync(LogVar); FreeLogBuf(); FreeBinBuf(); - FreeTTFILE(); + free(LogVar); + LogVar = NULL; } - /** * \x83\x8D\x83O\x82\xF0\x83|\x81[\x83Y\x82\xB7\x82\xE9 - * \x8C\xB3\x82\xCD FLogChangeButton() \x82\xBE\x82\xC1\x82\xBD */ void FLogPause(BOOL Pause) { @@ -1216,9 +1214,8 @@ if (LogVar == NULL) { return; } - if (FLogDlg!=NULL) - FLogDlg->ChangeButton(Pause); - FileTransPause(OpLog, Pause); + LogVar->IsPause = Pause; + FLogDlg->ChangeButton(Pause); } /** @@ -1344,7 +1341,6 @@ memset(fv, 0, sizeof(TFileVar)); fv->FileOpen = FALSE; - fv->OverWrite = ((ts.FTFlag & FT_RENAME) == 0); ret = LogStart(fname); return ret; @@ -1473,11 +1469,17 @@ BOOL FLogIsPause() { - return ((cv.FilePause & OpLog) !=0); + if (LogVar == NULL) { + return FALSE; + } + return LogVar->IsPause; } void FLogWindow(int nCmdShow) { + if (LogVar == NULL) { + return; + } if (FLogDlg == NULL) return; @@ -1491,6 +1493,9 @@ void FLogShowDlg(void) { + if (LogVar == NULL) { + return; + } if (FLogDlg != NULL) { FLogDlg->ShowWindow(SW_SHOWNORMAL); SetForegroundWindow(FLogDlg->GetSafeHwnd()); @@ -1504,7 +1509,7 @@ //void Log1Bin(PComVar cv, BYTE b) static void Log1Bin(BYTE b) { - if (((cv.FilePause & OpLog)!=0) || cv.ProtoFlag) { + if (LogVar->IsPause || cv.ProtoFlag) { return; } if (cv.BinSkip > 0) { Copied: branches/filesys_log/teraterm/teraterm/filesys_log.h (from rev 8875, branches/filesys_log/teraterm/teraterm/filesys.h) =================================================================== --- branches/filesys_log/teraterm/teraterm/filesys_log.h (rev 0) +++ branches/filesys_log/teraterm/teraterm/filesys_log.h 2020-08-05 15:06:06 UTC (rev 8876) @@ -0,0 +1,68 @@ +/* + * (C) 2020 TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +/* TERATERM.EXE, log routines */ +#ifdef __cplusplus +extern "C" { +#endif + +//extern BOOL FileLog, BinLog; + +// log +typedef struct { + wchar_t *filename; // [in] \x83t\x83@\x83C\x83\x8B\x96\xBC\x8F\x89\x8A\xFA\x92l(NULL=default) [out] \x93\xFC\x97̓t\x83@\x83C\x83\x8B\x96\xBC\x81Afree()\x82\xB7\x82邱\x82\xC6 + BOOL append; // TRUE/FALSE = append/new(overwrite) + BOOL bom; // TRUE = BOM\x82\xA0\x82\xE8 + int code; // 0/1/2 = UTF-8/UTF-16LE/UTF-16BE +} FLogDlgInfo_t; +void logfile_lock_initialize(void); +void LogPut1(BYTE b); +void FLogPause(BOOL Pause); +void FLogRotateSize(size_t size); +void FLogRotateRotate(int step); +void FLogRotateHalt(void); +void FLogAddCommentDlg(HINSTANCE hInst, HWND hWnd); +void FLogClose(void); +BOOL FLogOpen(const wchar_t *fname); +BOOL FLogIsOpend(void); +void FLogWriteStr(const char *str); +void FLogInfo(char *param_ptr, size_t param_len); +const wchar_t *FLogGetFilename(void); +BOOL FLogOpenDialog(HINSTANCE hInst, HWND hWnd, FLogDlgInfo_t *info); +wchar_t *FLogGetLogFilename(const wchar_t *log_filename); +BOOL FLogIsPause(void); +void FLogWindow(int nCmdShow); +void FLogShowDlg(void); +int FLogGetCount(void); +void FLogWriteFile(void); + +#ifdef __cplusplus +} +#endif Modified: branches/filesys_log/teraterm/teraterm/ftdlg.cpp =================================================================== --- branches/filesys_log/teraterm/teraterm/ftdlg.cpp 2020-08-05 15:05:57 UTC (rev 8875) +++ branches/filesys_log/teraterm/teraterm/ftdlg.cpp 2020-08-05 15:06:06 UTC (rev 8876) @@ -266,7 +266,12 @@ BOOL CFileTransDlg::OnCancel( ) { - FileTransEnd(OpId); + if (OpId == OpLog) { + FLogClose(); + } + else { + FileTransEnd(OpId); + } return TRUE; } @@ -275,7 +280,12 @@ switch (LOWORD(wParam)) { case IDC_TRANSPAUSESTART: ChangeButton(! Pause); - FileTransPause(OpId, Pause); + if (OpId == OpLog) { + FLogPause(Pause); + } + else { + FileTransPause(OpId, Pause); + } return TRUE; case IDC_TRANSHELP: if (OpId == OpLog) { Modified: branches/filesys_log/teraterm/teraterm/vtwin.cpp =================================================================== --- branches/filesys_log/teraterm/teraterm/vtwin.cpp 2020-08-05 15:05:57 UTC (rev 8875) +++ branches/filesys_log/teraterm/teraterm/vtwin.cpp 2020-08-05 15:06:06 UTC (rev 8876) @@ -1740,6 +1740,7 @@ } } + FLogClose(); FileTransEnd(0); ProtoEnd(); @@ -4212,7 +4213,7 @@ // \x83\x8D\x83O\x8E擾\x82\xF0\x8FI\x97\xB9\x82\xB7\x82\xE9 void CVTWindow::OnStopLog() { - FileTransEnd(OpLog); + FLogClose(); } // \x83\x8D\x83O\x82̍Đ\xB6 (2006.12.13 yutaka)