aboutsummaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@secunet.com>2011-07-07 15:41:53 +0200
committerStefan Reinauer <stefan.reinauer@coreboot.org>2011-08-04 08:10:41 +0200
commit3b77b723ca209199c8a224702812441e2196d452 (patch)
treecbf3be2c724139ec80a33dbf8e002b7871ef9307 /payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c
parent1ac19e28eed4f6c53a4f295eb55500c65fc80f8d (diff)
libpayload: Add PDCurses and ncurses' libform/libmenu
PDCurses provides an alternative implementation of the curses library standard in addition to tinycurses. Where tinycurses is really tiny, PDCurses is more complete and provides virtually unlimited windows and the full API. The PDCurses code is brought in "vanilla", with all local changes residing in curses/pdcurses-backend/ In addition to a curses library, this change also provides libpanel (as part of the PDCurses code), and libform and libmenu which were derived from ncurses-5.9. As they rely on ncurses internals (and PDCurses is not ncurses), more changes were required for these libraries to work. The build system is extended to install the right set of header files depending on the selected curses implementation. Change-Id: I9e5b920f94b6510da01da2f656196a993170d1c5 Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Reviewed-on: http://review.coreboot.org/106 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones <marcj303@gmail.com>
Diffstat (limited to 'payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c')
-rw-r--r--payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c
new file mode 100644
index 0000000000..95dc7d445f
--- /dev/null
+++ b/payloads/libpayload/curses/PDCurses-3.4/pdcurses/debug.c
@@ -0,0 +1,81 @@
+/* Public Domain Curses */
+
+#include <curspriv.h>
+
+RCSID("$Id: debug.c,v 1.7 2008/07/13 16:08:18 wmcbrine Exp $")
+
+/*man-start**************************************************************
+
+ Name: debug
+
+ Synopsis:
+ void traceon(void);
+ void traceoff(void);
+ void PDC_debug(const char *, ...);
+
+ Description:
+ traceon() and traceoff() toggle the recording of debugging
+ information to the file "trace". Although not standard, similar
+ functions are in some other curses implementations.
+
+ PDC_debug() is the function that writes to the file, based on
+ whether traceon() has been called. It's used from the PDC_LOG()
+ macro.
+
+ Portability X/Open BSD SYS V
+ traceon - - -
+ traceoff - - -
+ PDC_debug - - -
+
+**man-end****************************************************************/
+
+#include <string.h>
+#include <sys/types.h>
+#include <time.h>
+
+bool pdc_trace_on = FALSE;
+
+void PDC_debug(const char *fmt, ...)
+{
+ va_list args;
+ FILE *dbfp;
+ char hms[9];
+ time_t now;
+
+ if (!pdc_trace_on)
+ return;
+
+ /* open debug log file append */
+
+ dbfp = fopen("trace", "a");
+ if (!dbfp)
+ {
+ fprintf(stderr,
+ "PDC_debug(): Unable to open debug log file\n");
+ return;
+ }
+
+ time(&now);
+ strftime(hms, 9, "%H:%M:%S", localtime(&now));
+ fprintf(dbfp, "At: %8.8ld - %s ", (long) clock(), hms);
+
+ va_start(args, fmt);
+ vfprintf(dbfp, fmt, args);
+ va_end(args);
+
+ fclose(dbfp);
+}
+
+void traceon(void)
+{
+ PDC_LOG(("traceon() - called\n"));
+
+ pdc_trace_on = TRUE;
+}
+
+void traceoff(void)
+{
+ PDC_LOG(("traceoff() - called\n"));
+
+ pdc_trace_on = FALSE;
+}