xref: /csrg-svn/lib/libcurses/scanw.c (revision 42657)
1 /*
2  * Copyright (c) 1981 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)scanw.c	5.4 (Berkeley) 06/01/90";
10 #endif /* not lint */
11 
12 /*
13  * scanw and friends
14  *
15  */
16 
17 # include	"curses.ext"
18 
19 /*
20  *	This routine implements a scanf on the standard screen.
21  */
22 scanw(fmt, args)
23 char	*fmt;
24 int	args; {
25 
26 	return _sscans(stdscr, fmt, &args);
27 }
28 /*
29  *	This routine implements a scanf on the given window.
30  */
31 wscanw(win, fmt, args)
32 WINDOW	*win;
33 char	*fmt;
34 int	args; {
35 
36 	return _sscans(win, fmt, &args);
37 }
38 /*
39  *	This routine actually executes the scanf from the window.
40  *
41  *	This is really a modified version of "sscanf".  As such,
42  * it assumes that sscanf interfaces with the other scanf functions
43  * in a certain way.  If this is not how your system works, you
44  * will have to modify this routine to use the interface that your
45  * "sscanf" uses.
46  */
47 _sscans(win, fmt, args)
48 WINDOW	*win;
49 char	*fmt;
50 int	*args; {
51 
52 	char	buf[100];
53 	FILE	junk;
54 
55 	junk._flag = _IOREAD|_IOSTRG;
56 	junk._base = junk._ptr = buf;
57 	if (wgetstr(win, buf) == ERR)
58 		return ERR;
59 	junk._cnt = strlen(buf);
60 	return _doscan(&junk, fmt, args);
61 }
62