drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / printw.c
blobac67f919bb2dd3fdbb7bf915e11e58771abc2384
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: printw.c,v 1.40 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: printw
11 Synopsis:
12 int printw(const char *fmt, ...);
13 int wprintw(WINDOW *win, const char *fmt, ...);
14 int mvprintw(int y, int x, const char *fmt, ...);
15 int mvwprintw(WINDOW *win, int y, int x, const char *fmt,...);
16 int vwprintw(WINDOW *win, const char *fmt, va_list varglist);
17 int vw_printw(WINDOW *win, const char *fmt, va_list varglist);
19 Description:
20 The printw() functions add a formatted string to the window at
21 the current or specified cursor position. The format strings are
22 the same as used in the standard C library's printf(). (printw()
23 can be used as a drop-in replacement for printf().)
25 Return Value:
26 All functions return the number of characters printed, or
27 ERR on error.
29 Portability X/Open BSD SYS V
30 printw Y Y Y
31 wprintw Y Y Y
32 mvprintw Y Y Y
33 mvwprintw Y Y Y
34 vwprintw Y - 4.0
35 vw_printw Y
37 **man-end****************************************************************/
39 #include <string.h>
41 int vwprintw(WINDOW *win, const char *fmt, va_list varglist)
43 char printbuf[513];
44 int len;
46 PDC_LOG(("vwprintw() - called\n"));
48 #ifdef HAVE_VSNPRINTF
49 len = vsnprintf(printbuf, 512, fmt, varglist);
50 #else
51 len = vsprintf(printbuf, fmt, varglist);
52 #endif
53 return (waddstr(win, printbuf) == ERR) ? ERR : len;
56 int printw(const char *fmt, ...)
58 va_list args;
59 int retval;
61 PDC_LOG(("printw() - called\n"));
63 va_start(args, fmt);
64 retval = vwprintw(stdscr, fmt, args);
65 va_end(args);
67 return retval;
70 int wprintw(WINDOW *win, const char *fmt, ...)
72 va_list args;
73 int retval;
75 PDC_LOG(("wprintw() - called\n"));
77 va_start(args, fmt);
78 retval = vwprintw(win, fmt, args);
79 va_end(args);
81 return retval;
84 int mvprintw(int y, int x, const char *fmt, ...)
86 va_list args;
87 int retval;
89 PDC_LOG(("mvprintw() - called\n"));
91 if (move(y, x) == ERR)
92 return ERR;
94 va_start(args, fmt);
95 retval = vwprintw(stdscr, fmt, args);
96 va_end(args);
98 return retval;
101 int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
103 va_list args;
104 int retval;
106 PDC_LOG(("mvwprintw() - called\n"));
108 if (wmove(win, y, x) == ERR)
109 return ERR;
111 va_start(args, fmt);
112 retval = vwprintw(win, fmt, args);
113 va_end(args);
115 return retval;
118 int vw_printw(WINDOW *win, const char *fmt, va_list varglist)
120 PDC_LOG(("vw_printw() - called\n"));
122 return vwprintw(win, fmt, varglist);