aboutsummaryrefslogtreecommitdiffstats
path: root/src/hci/mucurses/print.c
diff options
context:
space:
mode:
authorDan Lynch <danjlynch@users.sourceforge.net>2006-06-08 17:23:37 +0000
committerDan Lynch <danjlynch@users.sourceforge.net>2006-06-08 17:23:37 +0000
commitad1aca0634cb3b00f0d6a83bba16a63d8bddf0f1 (patch)
treedb55e8d7f7034002c70f9fe5b453f438daf820b8 /src/hci/mucurses/print.c
parent1697c78848c4811aef8b394262c64d6eae335911 (diff)
downloadipxe-ad1aca0634cb3b00f0d6a83bba16a63d8bddf0f1.tar.gz
- separated curses.c out into separate source files to optimise
library use later on - some small mods to existing functions
Diffstat (limited to 'src/hci/mucurses/print.c')
-rw-r--r--src/hci/mucurses/print.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/hci/mucurses/print.c b/src/hci/mucurses/print.c
new file mode 100644
index 000000000..c5b70282b
--- /dev/null
+++ b/src/hci/mucurses/print.c
@@ -0,0 +1,52 @@
+#include <curses.h>
+#include <vsprintf.h>
+#include <stddef.h>
+#include "core.h"
+
+static printw_context {
+ struct printf_context ctx;
+ WINDOW *win;
+};
+
+static void _printw_handler ( struct printf_context *ctx, unsigned int c ) {
+ struct printw_context *wctx =
+ container_of ( ctx, struct printw_context, ctx );
+
+ _wputch( wctx->win, c | wctx->win->attrs, WRAP );
+}
+
+/**
+ * Print formatted output in a window
+ *
+ * @v *win subject window
+ * @v *fmt formatted string
+ * @v varglist argument list
+ * @ret rc return status code
+ */
+int vw_printw ( WINDOW *win, const char *fmt, va_list varglist ) {
+ struct printw_context wctx = {
+ .win = win,
+ .ctx = { .handler = _printw_handler, },
+ };
+
+ vcprintf ( &(wctx.ctx), fmt, varglist );
+ return OK;
+}
+
+/**
+ * Print formatted output to a window
+ *
+ * @v *win subject window
+ * @v *fmt formatted string
+ * @v ... string arguments
+ * @ret rc return status code
+ */
+int wprintw ( WINDOW *win, const char *fmt, ... ) {
+ va_list args;
+ int i;
+
+ va_start ( args, fmt );
+ i = vw_printw ( win, fmt, args );
+ va_end ( args );
+ return i;
+}