diff options
Diffstat (limited to '')
-rw-r--r-- | scripts/kconfig/libcurses/printw.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/scripts/kconfig/libcurses/printw.c b/scripts/kconfig/libcurses/printw.c new file mode 100644 index 000000000..a753638a5 --- /dev/null +++ b/scripts/kconfig/libcurses/printw.c | |||
@@ -0,0 +1,131 @@ | |||
1 | /* PDCurses */ | ||
2 | |||
3 | #include "curspriv.h" | ||
4 | |||
5 | /*man-start************************************************************** | ||
6 | |||
7 | printw | ||
8 | ------ | ||
9 | |||
10 | ### Synopsis | ||
11 | |||
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); | ||
18 | |||
19 | ### Description | ||
20 | |||
21 | The printw() functions add a formatted string to the window at the | ||
22 | current or specified cursor position. The format strings are the same | ||
23 | as used in the standard C library's printf(). (printw() can be used | ||
24 | as a drop-in replacement for printf().) | ||
25 | |||
26 | The duplication between vwprintw() and vw_printw() is for historic | ||
27 | reasons. In PDCurses, they're the same. | ||
28 | |||
29 | ### Return Value | ||
30 | |||
31 | All functions return the number of characters printed, or ERR on | ||
32 | error. | ||
33 | |||
34 | ### Portability | ||
35 | |||
36 | Function | X/Open | ncurses | NetBSD | ||
37 | :---------------------|:------:|:-------:|:------: | ||
38 | printw | Y | Y | Y | ||
39 | wprintw | Y | Y | Y | ||
40 | mvprintw | Y | Y | Y | ||
41 | mvwprintw | Y | Y | Y | ||
42 | vwprintw | Y | Y | Y | ||
43 | vw_printw | Y | Y | Y | ||
44 | |||
45 | **man-end****************************************************************/ | ||
46 | |||
47 | #include <string.h> | ||
48 | |||
49 | int vwprintw(WINDOW *win, const char *fmt, va_list varglist) | ||
50 | { | ||
51 | char printbuf[513]; | ||
52 | int len; | ||
53 | |||
54 | PDC_LOG(("vwprintw() - called\n")); | ||
55 | |||
56 | #ifdef HAVE_VSNPRINTF | ||
57 | len = vsnprintf(printbuf, 512, fmt, varglist); | ||
58 | #else | ||
59 | len = vsprintf(printbuf, fmt, varglist); | ||
60 | #endif | ||
61 | return (waddstr(win, printbuf) == ERR) ? ERR : len; | ||
62 | } | ||
63 | |||
64 | int printw(const char *fmt, ...) | ||
65 | { | ||
66 | va_list args; | ||
67 | int retval; | ||
68 | |||
69 | PDC_LOG(("printw() - called\n")); | ||
70 | |||
71 | va_start(args, fmt); | ||
72 | retval = vwprintw(stdscr, fmt, args); | ||
73 | va_end(args); | ||
74 | |||
75 | return retval; | ||
76 | } | ||
77 | |||
78 | int wprintw(WINDOW *win, const char *fmt, ...) | ||
79 | { | ||
80 | va_list args; | ||
81 | int retval; | ||
82 | |||
83 | PDC_LOG(("wprintw() - called\n")); | ||
84 | |||
85 | va_start(args, fmt); | ||
86 | retval = vwprintw(win, fmt, args); | ||
87 | va_end(args); | ||
88 | |||
89 | return retval; | ||
90 | } | ||
91 | |||
92 | int mvprintw(int y, int x, const char *fmt, ...) | ||
93 | { | ||
94 | va_list args; | ||
95 | int retval; | ||
96 | |||
97 | PDC_LOG(("mvprintw() - called\n")); | ||
98 | |||
99 | if (move(y, x) == ERR) | ||
100 | return ERR; | ||
101 | |||
102 | va_start(args, fmt); | ||
103 | retval = vwprintw(stdscr, fmt, args); | ||
104 | va_end(args); | ||
105 | |||
106 | return retval; | ||
107 | } | ||
108 | |||
109 | int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...) | ||
110 | { | ||
111 | va_list args; | ||
112 | int retval; | ||
113 | |||
114 | PDC_LOG(("mvwprintw() - called\n")); | ||
115 | |||
116 | if (wmove(win, y, x) == ERR) | ||
117 | return ERR; | ||
118 | |||
119 | va_start(args, fmt); | ||
120 | retval = vwprintw(win, fmt, args); | ||
121 | va_end(args); | ||
122 | |||
123 | return retval; | ||
124 | } | ||
125 | |||
126 | int vw_printw(WINDOW *win, const char *fmt, va_list varglist) | ||
127 | { | ||
128 | PDC_LOG(("vw_printw() - called\n")); | ||
129 | |||
130 | return vwprintw(win, fmt, varglist); | ||
131 | } | ||