Adding debian version 3.70~pre8+dfsg-1.
[syslinux-debian/hramrach.git] / gpxe / src / hci / mucurses / print.c
blob9fca308821a5371fc7577eace3d7b1ceeeb120ca
1 #include <curses.h>
2 #include <stdio.h>
3 #include <stddef.h>
4 #include <gpxe/vsprintf.h>
5 #include "mucurses.h"
7 /** @file
9 * MuCurses printing functions
13 /**
14 * Add a single-byte character and rendition to a window and advance
15 * the cursor
17 * @v *win window to be rendered in
18 * @v ch character to be added at cursor
19 * @ret rc return status code
21 int waddch ( WINDOW *win, const chtype ch ) {
22 _wputch( win, ch, WRAP );
23 return OK;
26 /**
27 * Add string of single-byte characters to a window
29 * @v *win window to be rendered in
30 * @v *str standard c-style string
31 * @v n max number of chars from string to render
32 * @ret rc return status code
34 int waddnstr ( WINDOW *win, const char *str, int n ) {
35 _wputstr( win, str, WRAP, n );
36 return OK;
39 struct printw_context {
40 struct printf_context ctx;
41 WINDOW *win;
44 static void _printw_handler ( struct printf_context *ctx, unsigned int c ) {
45 struct printw_context *wctx =
46 container_of ( ctx, struct printw_context, ctx );
48 _wputch( wctx->win, c | wctx->win->attrs, WRAP );
51 /**
52 * Print formatted output in a window
54 * @v *win subject window
55 * @v *fmt formatted string
56 * @v varglist argument list
57 * @ret rc return status code
59 int vw_printw ( WINDOW *win, const char *fmt, va_list varglist ) {
60 struct printw_context wctx;
62 wctx.win = win;
63 wctx.ctx.handler = _printw_handler;
64 vcprintf ( &(wctx.ctx), fmt, varglist );
65 return OK;
68 /**
69 * Print formatted output to a window
71 * @v *win subject window
72 * @v *fmt formatted string
73 * @v ... string arguments
74 * @ret rc return status code
76 int wprintw ( WINDOW *win, const char *fmt, ... ) {
77 va_list args;
78 int i;
80 va_start ( args, fmt );
81 i = vw_printw ( win, fmt, args );
82 va_end ( args );
83 return i;