mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
log interactive commands as well
This commit is contained in:
parent
ba47ac36cb
commit
e10085bfe8
4 changed files with 23 additions and 16 deletions
|
@ -117,6 +117,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
||||||
// loops every time enter is pressed...
|
// loops every time enter is pressed...
|
||||||
while (1) {
|
while (1) {
|
||||||
bool printprompt = false;
|
bool printprompt = false;
|
||||||
|
char *prompt = PROXPROMPT;
|
||||||
|
|
||||||
// If there is a script file
|
// If there is a script file
|
||||||
if (sf) {
|
if (sf) {
|
||||||
|
@ -171,12 +172,12 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
||||||
rl_event_hook = check_comm;
|
rl_event_hook = check_comm;
|
||||||
if (session.pm3_present) {
|
if (session.pm3_present) {
|
||||||
if (conn.send_via_fpc_usart == false)
|
if (conn.send_via_fpc_usart == false)
|
||||||
cmd = readline(PROXPROMPT_USB);
|
prompt = PROXPROMPT_USB;
|
||||||
else
|
else
|
||||||
cmd = readline(PROXPROMPT_FPC);
|
prompt = PROXPROMPT_FPC;
|
||||||
} else
|
} else
|
||||||
cmd = readline(PROXPROMPT_OFFLINE);
|
prompt = PROXPROMPT_OFFLINE;
|
||||||
|
cmd = readline(prompt);
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,8 +200,10 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) {
|
||||||
cmd[strlen(cmd) - off] = '\0';
|
cmd[strlen(cmd) - off] = '\0';
|
||||||
|
|
||||||
if (cmd[0] != '\0') {
|
if (cmd[0] != '\0') {
|
||||||
if (printprompt)
|
if (!printprompt)
|
||||||
PrintAndLogEx(NORMAL, PROXPROMPT"%s", cmd);
|
g_printAndLog = PRINTANDLOG_LOG;
|
||||||
|
PrintAndLogEx(NORMAL, "%s%s", prompt, cmd);
|
||||||
|
g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG;
|
||||||
|
|
||||||
int ret = CommandReceived(cmd);
|
int ret = CommandReceived(cmd);
|
||||||
|
|
||||||
|
@ -481,14 +484,14 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// short help
|
// short help
|
||||||
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
||||||
g_disableLogging = true;
|
g_printAndLog = PRINTANDLOG_PRINT;
|
||||||
show_help(true, exec_name);
|
show_help(true, exec_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dump help
|
// dump help
|
||||||
if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--text") == 0) {
|
if (strcmp(argv[i], "-t") == 0 || strcmp(argv[i], "--text") == 0) {
|
||||||
g_disableLogging = true;
|
g_printAndLog = PRINTANDLOG_PRINT;
|
||||||
show_help(false, exec_name);
|
show_help(false, exec_name);
|
||||||
dumpAllHelp(0);
|
dumpAllHelp(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -496,7 +499,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// dump markup
|
// dump markup
|
||||||
if (strcmp(argv[i], "-m") == 0 || strcmp(argv[i], "--markdown") == 0) {
|
if (strcmp(argv[i], "-m") == 0 || strcmp(argv[i], "--markdown") == 0) {
|
||||||
g_disableLogging = true;
|
g_printAndLog = PRINTANDLOG_PRINT;
|
||||||
dumpAllHelp(1);
|
dumpAllHelp(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
12
client/ui.c
12
client/ui.c
|
@ -223,7 +223,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
// lock this section to avoid interlacing prints from different threads
|
// lock this section to avoid interlacing prints from different threads
|
||||||
pthread_mutex_lock(&print_lock);
|
pthread_mutex_lock(&print_lock);
|
||||||
|
|
||||||
if (!g_disableLogging && logging && !logfile) {
|
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && !logfile) {
|
||||||
char *my_logfile_path = NULL;
|
char *my_logfile_path = NULL;
|
||||||
char filename[40];
|
char filename[40];
|
||||||
struct tm *timenow;
|
struct tm *timenow;
|
||||||
|
@ -269,9 +269,11 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
|
|
||||||
bool filter_ansi = !session.supports_colors;
|
bool filter_ansi = !session.supports_colors;
|
||||||
memcpy_filter_ansi(buffer2, buffer, sizeof(buffer), filter_ansi);
|
memcpy_filter_ansi(buffer2, buffer, sizeof(buffer), filter_ansi);
|
||||||
fprintf(stream, "%s", buffer2);
|
if (g_printAndLog & PRINTANDLOG_PRINT) {
|
||||||
fprintf(stream, " "); // cleaning prompt
|
fprintf(stream, "%s", buffer2);
|
||||||
fprintf(stream, "\n");
|
fprintf(stream, " "); // cleaning prompt
|
||||||
|
fprintf(stream, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RL_STATE_READCMD
|
#ifdef RL_STATE_READCMD
|
||||||
// We are using GNU readline. libedit (OSX) doesn't support this flag.
|
// We are using GNU readline. libedit (OSX) doesn't support this flag.
|
||||||
|
@ -284,7 +286,7 @@ static void fPrintAndLog(FILE *stream, const char *fmt, ...) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!g_disableLogging && logging && logfile) {
|
if ((g_printAndLog & PRINTANDLOG_LOG) && logging && logfile) {
|
||||||
if (filter_ansi) { // already done
|
if (filter_ansi) { // already done
|
||||||
fprintf(logfile, "%s\n", buffer2);
|
fprintf(logfile, "%s\n", buffer2);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
// global client debug variable
|
// global client debug variable
|
||||||
uint8_t g_debugMode = 0;
|
uint8_t g_debugMode = 0;
|
||||||
// global client disable logging variable
|
// global client disable logging variable
|
||||||
bool g_disableLogging = false;
|
uint8_t g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t g_debugMode;
|
uint8_t g_debugMode;
|
||||||
bool g_disableLogging;
|
uint8_t g_printAndLog;
|
||||||
|
#define PRINTANDLOG_PRINT 1
|
||||||
|
#define PRINTANDLOG_LOG 2
|
||||||
|
|
||||||
int kbd_enter_pressed(void);
|
int kbd_enter_pressed(void);
|
||||||
void AddLogLine(const char *fn, const char *data, const char *c);
|
void AddLogLine(const char *fn, const char *data, const char *c);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue