1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2009 Michael Gernoth <michael at gernoth.net>
3 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
5 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
6 // at your option, any later version. See the LICENSE.txt file for the text of
8 //-----------------------------------------------------------------------------
10 //-----------------------------------------------------------------------------
16 #include <readline/readline.h>
21 double CursorScaleFactor
;
22 int PlotGridX
, PlotGridY
, PlotGridXdefault
= 64, PlotGridYdefault
= 64, CursorCPos
= 0, CursorDPos
= 0;
24 int flushAfterWrite
= 0; //buzzy
28 extern pthread_mutex_t print_lock
;
30 static char *logfilename
= "proxmark3.log";
32 void PrintAndLog(char *fmt
, ...)
36 va_list argptr
, argptr2
;
37 static FILE *logfile
= NULL
;
40 // lock this section to avoid interlacing prints from different threads
41 pthread_mutex_lock(&print_lock
);
43 if (logging
&& !logfile
) {
44 logfile
=fopen(logfilename
, "a");
46 fprintf(stderr
, "Can't open logfile, logging disabled!\n");
51 int need_hack
= (rl_readline_state
& RL_STATE_READCMD
) > 0;
54 saved_point
= rl_point
;
55 saved_line
= rl_copy_text(0, rl_end
);
57 rl_replace_line("", 0);
61 va_start(argptr
, fmt
);
62 va_copy(argptr2
, argptr
);
64 printf(" "); // cleaning prompt
70 rl_replace_line(saved_line
, 0);
71 rl_point
= saved_point
;
76 if (logging
&& logfile
) {
77 vfprintf(logfile
, fmt
, argptr2
);
78 fprintf(logfile
,"\n");
83 if (flushAfterWrite
== 1) //buzzy
88 pthread_mutex_unlock(&print_lock
);
92 void SetLogFilename(char *fn
)