]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/lib_scanw.c
ncurses 4.1
[ncurses.git] / ncurses / lib_scanw.c
1
2 /***************************************************************************
3 *                            COPYRIGHT NOTICE                              *
4 ****************************************************************************
5 *                ncurses is copyright (C) 1992-1995                        *
6 *                          Zeyd M. Ben-Halim                               *
7 *                          zmbenhal@netcom.com                             *
8 *                          Eric S. Raymond                                 *
9 *                          esr@snark.thyrsus.com                           *
10 *                                                                          *
11 *        Permission is hereby granted to reproduce and distribute ncurses  *
12 *        by any means and for any fee, whether alone or as part of a       *
13 *        larger distribution, in source or in binary form, PROVIDED        *
14 *        this notice is included with any such distribution, and is not    *
15 *        removed from any of its header files. Mention of ncurses in any   *
16 *        applications linked with it is highly appreciated.                *
17 *                                                                          *
18 *        ncurses comes AS IS with no warranty, implied or expressed.       *
19 *                                                                          *
20 ***************************************************************************/
21
22
23
24 /*
25 **      lib_scanw.c
26 **
27 **      The routines scanw(), wscanw() and friends.
28 **
29 */
30
31 #include <curses.priv.h>
32
33 MODULE_ID("$Id: lib_scanw.c,v 1.4 1997/02/08 14:45:51 tom Exp $")
34
35 #if !HAVE_VSSCANF
36 extern int vsscanf(const char *str, const char *format, ...);
37 #endif
38
39 int vwscanw(WINDOW *win, const char *fmt, va_list argp)
40 {
41 char buf[BUFSIZ];
42
43         if (wgetstr(win, buf) == ERR)
44             return(ERR);
45
46         return(vsscanf(buf, fmt, argp));
47 }
48
49 int scanw(const char *fmt, ...)
50 {
51 int code;
52 va_list ap;
53
54         T(("scanw(\"%s\",...) called", fmt));
55
56         va_start(ap, fmt);
57         code = vwscanw(stdscr, fmt, ap);
58         va_end(ap);
59         return (code);
60 }
61
62 int wscanw(WINDOW *win, const char *fmt, ...)
63 {
64 int code;
65 va_list ap;
66
67         T(("wscanw(%p,\"%s\",...) called", win, fmt));
68
69         va_start(ap, fmt);
70         code = vwscanw(win, fmt, ap);
71         va_end(ap);
72         return (code);
73 }
74
75 int mvscanw(int y, int x, const char *fmt, ...)
76 {
77 int code;
78 va_list ap;
79
80         va_start(ap, fmt);
81         code = (move(y, x) == OK) ? vwscanw(stdscr, fmt, ap) : ERR;
82         va_end(ap);
83         return (code);
84 }
85
86 int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...)
87 {
88 int code;
89 va_list ap;
90
91         va_start(ap, fmt);
92         code = (wmove(win, y, x) == OK) ? vwscanw(win, fmt, ap) : ERR;
93         va_end(ap);
94         return (code);
95 }