X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/b8fdac9e6fedfda5e291e437766ed46e3caf7c32..53c7a7053d06af60388507c7d38252af1b96696a:/client/ui.c?ds=sidebyside diff --git a/client/ui.c b/client/ui.c index 05e29dc7..dc122d2f 100644 --- a/client/ui.c +++ b/client/ui.c @@ -9,12 +9,14 @@ // UI utilities //----------------------------------------------------------------------------- -#include +#include +#ifndef EXTERNAL_PRINTANDLOG #include #include -#include +#include #include #include +#endif #include "ui.h" @@ -26,10 +28,12 @@ int GridOffset = 0; bool GridLocked = false; bool showDemod = true; -extern pthread_mutex_t print_lock; - static char *logfilename = "proxmark3.log"; +#ifndef EXTERNAL_PRINTANDLOG +// Declared in proxmark3.c +extern pthread_mutex_t print_lock; + void PrintAndLog(char *fmt, ...) { char *saved_line; @@ -48,7 +52,12 @@ void PrintAndLog(char *fmt, ...) logging=0; } } - + + // If there is an incoming message from the hardware (eg: lf hid read) in + // the background (while the prompt is displayed and accepting user input), + // stash the prompt and bring it back later. +#ifdef RL_STATE_READCMD + // We are using GNU readline. libedit (OSX) doesn't support this flag. int need_hack = (rl_readline_state & RL_STATE_READCMD) > 0; if (need_hack) { @@ -58,6 +67,7 @@ void PrintAndLog(char *fmt, ...) rl_replace_line("", 0); rl_redisplay(); } +#endif va_start(argptr, fmt); va_copy(argptr2, argptr); @@ -66,6 +76,8 @@ void PrintAndLog(char *fmt, ...) va_end(argptr); printf("\n"); +#ifdef RL_STATE_READCMD + // We are using GNU readline. libedit (OSX) doesn't support this flag. if (need_hack) { rl_restore_prompt(); rl_replace_line(saved_line, 0); @@ -73,6 +85,7 @@ void PrintAndLog(char *fmt, ...) rl_redisplay(); free(saved_line); } +#endif if (logging && logfile) { vfprintf(logfile, fmt, argptr2); @@ -88,7 +101,7 @@ void PrintAndLog(char *fmt, ...) //release lock pthread_mutex_unlock(&print_lock); } - +#endif void SetLogFilename(char *fn) {