| 1 | /* |
| 2 | * scanw and friends |
| 3 | * |
| 4 | * %G% (Berkeley) @(#)scanw.c 1.1 |
| 5 | */ |
| 6 | |
| 7 | # include "curses.ext" |
| 8 | |
| 9 | /* |
| 10 | * This routine implements a scanf on the standard screen. |
| 11 | */ |
| 12 | scanw(fmt, args) |
| 13 | char *fmt; |
| 14 | int args; { |
| 15 | |
| 16 | return _sscans(stdscr, fmt, &args); |
| 17 | } |
| 18 | /* |
| 19 | * This routine implements a scanf on the given window. |
| 20 | */ |
| 21 | wscanw(win, fmt, args) |
| 22 | WINDOW *win; |
| 23 | char *fmt; |
| 24 | int args; { |
| 25 | |
| 26 | return _sscans(win, fmt, &args); |
| 27 | } |
| 28 | /* |
| 29 | * This routine actually executes the scanf from the window. |
| 30 | * |
| 31 | * This is really a modified version of "sscanf". As such, |
| 32 | * it assumes that sscanf interfaces with the other scanf functions |
| 33 | * in a certain way. If this is not how your system works, you |
| 34 | * will have to modify this routine to use the interface that your |
| 35 | * "sscanf" uses. |
| 36 | */ |
| 37 | _sscans(win, fmt, args) |
| 38 | WINDOW *win; |
| 39 | char *fmt; |
| 40 | int *args; { |
| 41 | |
| 42 | char buf[100]; |
| 43 | FILE junk; |
| 44 | |
| 45 | junk._flag = _IOREAD|_IOSTRG; |
| 46 | junk._base = junk._ptr = buf; |
| 47 | if (wgetstr(win, buf) == ERR) |
| 48 | return ERR; |
| 49 | junk._cnt = strlen(buf); |
| 50 | return _doscan(&junk, fmt, args); |
| 51 | } |