]>
Commit | Line | Data |
---|---|---|
6658905f | 1 | #include <stdarg.h> |
2 | #include <stdio.h> | |
3 | #include <time.h> | |
4 | ||
5 | #include "proxgui.h" | |
6 | #include "translate.h" | |
cd00aa30 | 7 | #include "prox.h" |
6658905f | 8 | |
9 | int GraphBuffer[MAX_GRAPH_TRACE_LEN]; | |
10 | int GraphTraceLen; | |
11 | double CursorScaleFactor; | |
f4434ad2 | 12 | int PlotGridX, PlotGridY; |
6658905f | 13 | int CommandFinished; |
d722c4ce | 14 | int offline; |
6658905f | 15 | |
16 | static char *logfilename = "proxmark3.log"; | |
17 | ||
18 | void PrintToScrollback(char *fmt, ...) { | |
5aad6db0 | 19 | va_list argptr, argptr2; |
6658905f | 20 | static FILE *logfile = NULL; |
21 | static int logging=1; | |
22 | ||
23 | if (logging && !logfile) { | |
24 | logfile=fopen(logfilename, "a"); | |
25 | if (!logfile) { | |
26 | fprintf(stderr, "Can't open logfile, logging disabled!\n"); | |
27 | logging=0; | |
28 | } | |
29 | } | |
30 | ||
31 | va_start(argptr, fmt); | |
5aad6db0 | 32 | va_copy(argptr2, argptr); |
6658905f | 33 | vprintf(fmt, argptr); |
5aad6db0 | 34 | va_end(argptr); |
6658905f | 35 | printf("\n"); |
36 | if (logging && logfile) { | |
37 | #if 0 | |
38 | char zeit[25]; | |
39 | time_t jetzt_t; | |
40 | struct tm *jetzt; | |
41 | ||
42 | jetzt_t = time(NULL); | |
43 | jetzt = localtime(&jetzt_t); | |
44 | strftime(zeit, 25, "%b %e %T", jetzt); | |
45 | ||
46 | fprintf(logfile,"%s ", zeit); | |
47 | #endif | |
5aad6db0 | 48 | vfprintf(logfile, fmt, argptr2); |
6658905f | 49 | fprintf(logfile,"\n"); |
50 | fflush(logfile); | |
51 | } | |
5aad6db0 | 52 | va_end(argptr2); |
6658905f | 53 | } |
54 | ||
55 | void setlogfilename(char *fn) | |
56 | { | |
57 | logfilename = fn; | |
58 | } |