8999 SMBIOS: cleanup 32-bit specific code
[unleashed.git] / usr / src / ucblib / libcurses / scanw.c
blob9cd61cf03c97f80893ef7517229b11255c1f60af
1 /*
2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /*LINTLIBRARY*/
19 #ifndef lint
20 static char
21 sccsid[] = "@(#)scanw.c 1.8 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
22 #endif /* not lint */
24 #include <stdarg.h>
25 #include <string.h>
28 * scanw and friends
31 #include "curses.ext"
34 * This routine implements a scanf on the standard screen.
37 int
38 scanw(char *fmt, ...)
39 { int j;
40 va_list ap;
42 va_start(ap, fmt);
43 j = _sscans(stdscr, fmt, ap);
44 va_end(ap);
45 return (j);
49 * This routine implements a scanf on the given window.
52 int
53 wscanw(WINDOW *win, char *fmt, ...)
55 va_list ap;
56 int j;
58 va_start(ap, fmt);
59 j = _sscans(win, fmt, ap);
60 va_end(ap);
61 return (j);
64 * This routine actually executes the scanf from the window.
66 * This is really a modified version of "sscanf". As such,
67 * it assumes that sscanf interfaces with the other scanf functions
68 * in a certain way. If this is not how your system works, you
69 * will have to modify this routine to use the interface that your
70 * "sscanf" uses.
73 int
74 _sscans(WINDOW *win, char *fmt, va_list ap)
76 char buf[100];
77 FILE junk;
79 junk._flag = _IOREAD|_IOWRT;
80 junk._base = junk._ptr = (unsigned char *)buf;
81 if (wgetstr(win, buf) == ERR)
82 return (ERR);
83 junk._cnt = (ssize_t)strlen(buf);
84 return (_doscan(&junk, fmt, ap));