From 82077b2f1ce159cf225d58721086a2d724562a8c Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 16 Mar 2020 18:42:34 +0100 Subject: [PATCH] hint now uses session struct, in preperation for a preference file. --- client/cmdmain.c | 17 ++++++----------- client/proxgui.h | 1 - client/ui.c | 2 +- client/ui.h | 1 + 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/client/cmdmain.c b/client/cmdmain.c index 57cd4d10a..8d4b1c8b7 100644 --- a/client/cmdmain.c +++ b/client/cmdmain.c @@ -196,30 +196,25 @@ static int CmdHints(const char *Cmd) { char ctmp = tolower(param_getchar(Cmd, 0)); if (ctmp == 'h') return usage_hints(); - if (strlen(Cmd) < 1) { - PrintAndLogEx(INFO, "Hints are %s", (g_showhints) ? "ON" : "OFF"); - return PM3_SUCCESS; - } - if (strlen(Cmd) > 1){ str_lower((char *)Cmd); if (str_startswith(Cmd, "of")) { - g_showhints = false; + session.show_hints = false; } else { - g_showhints = true; + session.show_hints = true; } - } else { + } else if (strlen(Cmd) == 1) { if (param_getchar(Cmd, 0) != 0x00) { ms = param_get32ex(Cmd, 0, 0, 10); if (ms == 0) { - g_showhints = false; + session.show_hints = false; } else { - g_showhints = true; + session.show_hints = true; } } } - PrintAndLogEx(INFO, "Hints are %s", (g_showhints) ? "ON" : "OFF"); + PrintAndLogEx(INFO, "Hints are %s", (session.show_hints) ? "ON" : "OFF"); return PM3_SUCCESS; } diff --git a/client/proxgui.h b/client/proxgui.h index fea28d62b..c9cd0096d 100644 --- a/client/proxgui.h +++ b/client/proxgui.h @@ -55,7 +55,6 @@ extern size_t DemodBufferLen; extern size_t g_DemodStartIdx; extern bool showDemod; extern uint8_t g_debugMode; -extern uint8_t g_showhints; #ifndef FILE_PATH_SIZE #define FILE_PATH_SIZE 1000 diff --git a/client/ui.c b/client/ui.c index e4343fec3..d470647b7 100644 --- a/client/ui.c +++ b/client/ui.c @@ -131,7 +131,7 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) { return; // skip HINT messages if client has hints turned off i.e. 'HINT 0' - if (g_showhints == 0 && level == HINT) + if (session.show_hints == false && level == HINT) return; char prefix[40] = {0}; diff --git a/client/ui.h b/client/ui.h index 3b07caf46..5bb814b81 100644 --- a/client/ui.h +++ b/client/ui.h @@ -27,6 +27,7 @@ typedef struct { emojiMode_t emoji_mode; bool pm3_present; bool help_dump_mode; + bool show_hints; } session_arg_t; extern session_arg_t session;