Commit | Line | Data |
---|---|---|
87c6fcf8 | 1 | /* |
2f14f200 KB |
2 | * Copyright (c) 1981 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
7e3eac84 | 5 | * %sccs.include.redist.c% |
87c6fcf8 DF |
6 | */ |
7 | ||
8 | #ifndef lint | |
7e3eac84 | 9 | static char sccsid[] = "@(#)scanw.c 5.4 (Berkeley) %G%"; |
2f14f200 | 10 | #endif /* not lint */ |
87c6fcf8 | 11 | |
4af7346f KA |
12 | /* |
13 | * scanw and friends | |
14 | * | |
4af7346f KA |
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 | } |