2020-07-16 06:12:03 -07:00
|
|
|
/**
|
|
|
|
|
* @file logclose.cpp
|
2022-01-18 22:38:56 +03:30
|
|
|
* @author Sina Karvandi (sina@hyperdbg.org)
|
2020-07-16 06:12:03 -07:00
|
|
|
* @brief .logclose command
|
|
|
|
|
* @details
|
|
|
|
|
* @version 0.1
|
|
|
|
|
* @date 2020-07-16
|
|
|
|
|
*
|
|
|
|
|
* @copyright This project is released under the GNU Public License v3.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2022-05-04 16:38:21 -07:00
|
|
|
#include "pch.h"
|
2020-07-16 06:12:03 -07:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Global Variables
|
|
|
|
|
//
|
2021-03-22 18:19:39 +04:30
|
|
|
extern BOOLEAN g_LogOpened;
|
2020-07-16 06:12:03 -07:00
|
|
|
extern ofstream g_LogOpenFile;
|
|
|
|
|
|
2020-08-28 04:03:12 -07:00
|
|
|
/**
|
|
|
|
|
* @brief help .logclose command
|
2021-02-10 15:19:01 -08:00
|
|
|
*
|
|
|
|
|
* @return VOID
|
2020-08-28 04:03:12 -07:00
|
|
|
*/
|
2021-03-22 18:19:39 +04:30
|
|
|
VOID
|
|
|
|
|
CommandLogcloseHelp()
|
|
|
|
|
{
|
2022-04-10 22:24:56 +04:30
|
|
|
ShowMessages(".logclose : closes the previously opened log.\n\n");
|
2022-04-17 23:05:24 +04:30
|
|
|
|
2021-12-28 01:14:56 +03:30
|
|
|
ShowMessages("syntax : \t.logclose\n");
|
2020-07-16 06:12:03 -07:00
|
|
|
}
|
|
|
|
|
|
2020-08-28 04:03:12 -07:00
|
|
|
/**
|
|
|
|
|
* @brief .logclose command handler
|
2021-02-10 15:19:01 -08:00
|
|
|
*
|
2024-07-30 15:07:17 +09:00
|
|
|
* @param CommandTokens
|
2024-07-31 14:08:14 +09:00
|
|
|
* @param Command
|
2024-07-30 15:07:17 +09:00
|
|
|
*
|
2021-02-10 15:19:01 -08:00
|
|
|
* @return VOID
|
2020-08-28 04:03:12 -07:00
|
|
|
*/
|
2021-03-22 18:19:39 +04:30
|
|
|
VOID
|
2024-07-31 14:08:14 +09:00
|
|
|
CommandLogclose(vector<CommandToken> CommandTokens, string Command)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2024-07-30 15:07:17 +09:00
|
|
|
if (CommandTokens.size() != 1)
|
2021-03-22 18:19:39 +04:30
|
|
|
{
|
2024-07-30 15:07:17 +09:00
|
|
|
ShowMessages("incorrect use of the '%s'\n\n",
|
|
|
|
|
GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
|
2021-03-22 18:19:39 +04:30
|
|
|
CommandLogcloseHelp();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!g_LogOpened)
|
|
|
|
|
{
|
|
|
|
|
ShowMessages("there is no opened log, did you use '.logopen'? \n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-07-16 06:12:03 -07:00
|
|
|
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
|
|
|
|
// Show the time and message before close
|
|
|
|
|
//
|
|
|
|
|
time_t t = time(NULL);
|
|
|
|
|
struct tm tm = *localtime(&t);
|
|
|
|
|
ShowMessages("log file closed (%d-%02d-%02d "
|
|
|
|
|
"%02d:%02d:%02d)\n",
|
|
|
|
|
tm.tm_year + 1900,
|
|
|
|
|
tm.tm_mon + 1,
|
|
|
|
|
tm.tm_mday,
|
|
|
|
|
tm.tm_hour,
|
|
|
|
|
tm.tm_min,
|
|
|
|
|
tm.tm_sec);
|
|
|
|
|
//
|
|
|
|
|
// close the file
|
|
|
|
|
//
|
|
|
|
|
g_LogOpenFile.close();
|
2020-07-16 06:12:03 -07:00
|
|
|
|
2021-03-22 18:19:39 +04:30
|
|
|
//
|
|
|
|
|
// Globally indicate that file is no longer available
|
|
|
|
|
//
|
|
|
|
|
g_LogOpened = FALSE;
|
2020-07-16 06:12:03 -07:00
|
|
|
}
|