mb/google/nissa/var/glassway: Modify touch screen ILIT2901 sequence
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / debug.c
blob812b0ee0408a42ded7e6b8db6293d2874dc210c6
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: debug.c,v 1.7 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: debug
11 Synopsis:
12 void traceon(void);
13 void traceoff(void);
14 void PDC_debug(const char *, ...);
16 Description:
17 traceon() and traceoff() toggle the recording of debugging
18 information to the file "trace". Although not standard, similar
19 functions are in some other curses implementations.
21 PDC_debug() is the function that writes to the file, based on
22 whether traceon() has been called. It's used from the PDC_LOG()
23 macro.
25 Portability X/Open BSD SYS V
26 traceon - - -
27 traceoff - - -
28 PDC_debug - - -
30 **man-end****************************************************************/
32 #include <string.h>
33 #include <sys/types.h>
34 #include <time.h>
36 bool pdc_trace_on = FALSE;
38 void PDC_debug(const char *fmt, ...)
40 va_list args;
41 FILE *dbfp;
42 char hms[9];
43 time_t now;
45 if (!pdc_trace_on)
46 return;
48 /* open debug log file append */
50 dbfp = fopen("trace", "a");
51 if (!dbfp)
53 fprintf(stderr,
54 "PDC_debug(): Unable to open debug log file\n");
55 return;
58 time(&now);
59 strftime(hms, 9, "%H:%M:%S", localtime(&now));
60 fprintf(dbfp, "At: %8.8ld - %s ", (long) clock(), hms);
62 va_start(args, fmt);
63 vfprintf(dbfp, fmt, args);
64 va_end(args);
66 fclose(dbfp);
69 void traceon(void)
71 PDC_LOG(("traceon() - called\n"));
73 pdc_trace_on = TRUE;
76 void traceoff(void)
78 PDC_LOG(("traceoff() - called\n"));
80 pdc_trace_on = FALSE;