. use library function to parse memory string
[minix3.git] / lib / curses / prntscan.c
blob80257f1b87c5899b591fa0d1e7686b413144bb16
1 #include <string.h>
2 #include <curses.h>
3 #include "curspriv.h"
5 static char printscanbuf[513]; /* buffer used during I/O */
7 /****************************************************************/
8 /* Wprintw(win,fmt,args) does a printf() in window 'win'. */
9 /****************************************************************/
10 int wprintw(WINDOW *win, const char *fmt, ...)
12 va_list args;
14 va_start(args, fmt);
15 vsprintf(printscanbuf, fmt, args);
16 if (waddstr(win, printscanbuf) == ERR) return(ERR);
17 return(strlen(printscanbuf));
20 /****************************************************************/
21 /* Printw(fmt,args) does a printf() in stdscr. */
22 /****************************************************************/
23 int printw(const char *fmt, ...)
25 va_list args;
27 va_start(args, fmt);
28 vsprintf(printscanbuf, fmt, args);
29 if (waddstr(stdscr, printscanbuf) == ERR) return(ERR);
30 return(strlen(printscanbuf));
31 } /* printw */
33 /****************************************************************/
34 /* Mvprintw(fmt,args) moves the stdscr cursor to a new posi- */
35 /* tion, then does a printf() in stdscr. */
36 /****************************************************************/
37 int mvprintw(int y, int x, const char *fmt, ...)
39 va_list args;
41 va_start(args, fmt);
42 if (wmove(stdscr, y, x) == ERR) return(ERR);
43 vsprintf(printscanbuf, fmt, args);
44 if (waddstr(stdscr, printscanbuf) == ERR) return(ERR);
45 return(strlen(printscanbuf));
48 /****************************************************************/
49 /* Mvwprintw(win,fmt,args) moves the window 'win's cursor to */
50 /* A new position, then does a printf() in window 'win'. */
51 /****************************************************************/
52 int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
54 va_list args;
56 va_start(args, fmt);
57 if (wmove(win, y, x) == ERR) return(ERR);
58 vsprintf(printscanbuf, fmt, args);
59 if (waddstr(win, printscanbuf) == ERR) return(ERR);
60 return(strlen(printscanbuf));
61 } /* mvwprintw */
63 /****************************************************************/
64 /* Wscanw(win,fmt,args) gets a string via window 'win', then */
65 /* Scans the string using format 'fmt' to extract the values */
66 /* And put them in the variables pointed to the arguments. */
67 /****************************************************************/
68 int wscanw(WINDOW *win, const char *fmt, ...)
70 va_list args;
72 va_start(args, fmt);
73 wrefresh(win); /* set cursor */
74 if (wgetstr(win, printscanbuf) == ERR) /* get string */
75 return(ERR);
76 return(vsscanf(printscanbuf, fmt, args));
77 } /* wscanw */
79 /****************************************************************/
80 /* Scanw(fmt,args) gets a string via stdscr, then scans the */
81 /* String using format 'fmt' to extract the values and put them */
82 /* In the variables pointed to the arguments. */
83 /****************************************************************/
84 int scanw(const char *fmt, ...)
86 va_list args;
88 va_start(args, fmt);
89 wrefresh(stdscr); /* set cursor */
90 if (wgetstr(stdscr, printscanbuf) == ERR) /* get string */
91 return(ERR);
92 return(vsscanf(printscanbuf, fmt, args));
93 } /* scanw */
95 /****************************************************************/
96 /* Mvscanw(y,x,fmt,args) moves stdscr's cursor to a new posi- */
97 /* Tion, then gets a string via stdscr and scans the string */
98 /* Using format 'fmt' to extract the values and put them in the */
99 /* Variables pointed to the arguments. */
100 /****************************************************************/
101 int mvscanw(int y, int x, const char *fmt, ...)
103 va_list args;
105 va_start(args, fmt);
106 if (wmove(stdscr, y, x) == ERR) return(ERR);
107 wrefresh(stdscr); /* set cursor */
108 if (wgetstr(stdscr, printscanbuf) == ERR) /* get string */
109 return(ERR);
110 return(vsscanf(printscanbuf, fmt, args));
111 } /* mvscanw */
113 /****************************************************************/
114 /* Mvwscanw(win,y,x,fmt,args) moves window 'win's cursor to a */
115 /* New position, then gets a string via 'win' and scans the */
116 /* String using format 'fmt' to extract the values and put them */
117 /* In the variables pointed to the arguments. */
118 /****************************************************************/
119 int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...)
121 va_list args;
123 va_start(args, fmt);
124 if (wmove(win, y, x) == ERR) return(ERR);
125 wrefresh(win); /* set cursor */
126 if (wgetstr(win, printscanbuf) == ERR) /* get string */
127 return(ERR);
128 return(vsscanf(printscanbuf, fmt, args));
129 } /* mvwscanw */