iPXE
print.c
Go to the documentation of this file.
1#include <curses.h>
2#include <stdio.h>
3#include <stddef.h>
4#include <ipxe/vsprintf.h>
5#include "mucurses.h"
6
7/** @file
8 *
9 * MuCurses printing functions
10 *
11 */
12
13FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
14FILE_SECBOOT ( PERMITTED );
15
16/**
17 * Add a single-byte character and rendition to a window and advance
18 * the cursor
19 *
20 * @v *win window to be rendered in
21 * @v ch character to be added at cursor
22 * @ret rc return status code
23 */
24int waddch ( WINDOW *win, const chtype ch ) {
25 _wputch( win, ch, WRAP );
26 return OK;
27}
28
29/**
30 * Add string of single-byte characters to a window
31 *
32 * @v *win window to be rendered in
33 * @v *str standard c-style string
34 * @v n max number of chars from string to render
35 * @ret rc return status code
36 */
37int waddnstr ( WINDOW *win, const char *str, int n ) {
38 _wputstr( win, str, WRAP, n );
39 return OK;
40}
41
46
47static void _printw_handler ( struct printf_context *ctx, unsigned int c ) {
48 struct printw_context *wctx =
50
51 _wputch( wctx->win, c | wctx->win->attrs, WRAP );
52}
53
54/**
55 * Print formatted output in a window
56 *
57 * @v *win subject window
58 * @v *fmt formatted string
59 * @v varglist argument list
60 * @ret rc return status code
61 */
62int vw_printw ( WINDOW *win, const char *fmt, va_list varglist ) {
63 struct printw_context wctx;
64
65 wctx.win = win;
67 vcprintf ( &(wctx.ctx), fmt, varglist );
68 return OK;
69}
70
71/**
72 * Print formatted output to a window
73 *
74 * @v *win subject window
75 * @v *fmt formatted string
76 * @v ... string arguments
77 * @ret rc return status code
78 */
79int wprintw ( WINDOW *win, const char *fmt, ... ) {
80 va_list args;
81 int i;
82
83 va_start ( args, fmt );
84 i = vw_printw ( win, fmt, args );
85 va_end ( args );
86 return i;
87}
struct golan_eq_context ctx
Definition CIB_PRM.h:0
MuCurses header file.
uint32_t chtype
Definition curses.h:30
#define OK
Definition curses.h:25
struct _curses_window WINDOW
Curses Window struct.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
void _wputstr(WINDOW *win, const char *str, int wrap, int n) __nonnull
Write a standard c-style string to a window.
Definition mucurses.c:122
void _wputch(WINDOW *win, chtype ch, int wrap) __nonnull
Write a single character rendition to a window.
Definition mucurses.c:51
MuCurses core implementation specific header file.
#define WRAP
Definition mucurses.h:13
int waddch(WINDOW *win, const chtype ch)
Add a single-byte character and rendition to a window and advance the cursor.
Definition print.c:24
static void _printw_handler(struct printf_context *ctx, unsigned int c)
Definition print.c:47
int vw_printw(WINDOW *win, const char *fmt, va_list varglist)
Print formatted output in a window.
Definition print.c:62
int wprintw(WINDOW *win, const char *fmt,...)
Print formatted output to a window.
Definition print.c:79
int waddnstr(WINDOW *win, const char *str, int n)
Add string of single-byte characters to a window.
Definition print.c:37
uint8_t ch
Definition registers.h:1
#define va_end(ap)
Definition stdarg.h:10
#define va_start(ap, last)
Definition stdarg.h:8
__builtin_va_list va_list
Definition stdarg.h:7
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
attr_t attrs
window attributes
Definition curses.h:94
A printf context.
Definition vsprintf.h:48
void(* handler)(struct printf_context *ctx, unsigned int c)
Character handler.
Definition vsprintf.h:58
WINDOW * win
Definition print.c:44
struct printf_context ctx
Definition print.c:43
size_t vcprintf(struct printf_context *ctx, const char *fmt, va_list args)
Write a formatted string to a printf context.
Definition vsprintf.c:188
printf() and friends
int ssize_t const char * fmt
Definition vsprintf.h:73