2 ****************************************************************************
3 * Copyright 2018-2023,2024 Thomas E. Dickey *
4 * Copyright 1998-2010,2017 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************
30 * @Id: curs_scanw.3x,v 1.53 2024/04/20 19:18:18 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>curs_scanw 3x 2024-04-20 ncurses 6.5 Library calls</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <H1 class="no-header">curs_scanw 3x 2024-04-20 ncurses 6.5 Library calls</H1>
44 <STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG> Library calls <STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>scanw</STRONG>, <STRONG>wscanw</STRONG>, <STRONG>mvscanw</STRONG>, <STRONG>mvwscanw</STRONG>, <STRONG>vwscanw</STRONG>, <STRONG>vw_scanw</STRONG> - read formatted
51 input from a <EM>curses</EM> window
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
57 <STRONG>int</STRONG> <STRONG>scanw(const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>fmt</EM><STRONG>,</STRONG> <STRONG>...);</STRONG>
58 <STRONG>int</STRONG> <STRONG>wscanw(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>fmt</EM><STRONG>,</STRONG> <STRONG>...);</STRONG>
59 <STRONG>int</STRONG> <STRONG>mvscanw(int</STRONG> <EM>y</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>x</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>fmt</EM><STRONG>,</STRONG> <STRONG>...);</STRONG>
60 <STRONG>int</STRONG> <STRONG>mvwscanw(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>y</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>x</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>fmt</EM><STRONG>,</STRONG> <STRONG>...);</STRONG>
62 <STRONG>int</STRONG> <STRONG>vw_scanw(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>fmt</EM><STRONG>,</STRONG> <STRONG>va_list</STRONG> <EM>varglist</EM><STRONG>);</STRONG>
64 <EM>/*</EM> <EM>obsolete</EM> <EM>*/</EM>
65 <STRONG>int</STRONG> <STRONG>vwscanw(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>fmt</EM><STRONG>,</STRONG> <STRONG>va_list</STRONG> <EM>varglist</EM><STRONG>);</STRONG>
68 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
69 <STRONG>scanw</STRONG>, <STRONG>wscanw</STRONG>, <STRONG>mvscanw</STRONG>, and <STRONG>mvwscanw</STRONG> are analogous to <STRONG>scanf(3)</STRONG>. In
70 effect, they call <STRONG><A HREF="curs_getstr.3x.html">wgetstr(3x)</A></STRONG> with <EM>win</EM> (or <STRONG>stdscr</STRONG>) as its first
71 argument, then attempt conversion of the resulting string with
72 <STRONG>vsscanf(3)</STRONG>. Fields in the string that do not map to a variable in the
73 <EM>fmt</EM> parameter are discarded.
75 <STRONG>vwscanw</STRONG> and <STRONG>vw_scanw</STRONG> are analogous to <STRONG>vscanf(3)</STRONG>, and perform a <STRONG>wscanw</STRONG>
76 using a variable argument list. The third argument is a <EM>va</EM><STRONG>_</STRONG><EM>list</EM>, a
77 pointer to a list of arguments, as defined in <EM>stdarg.h</EM>.
80 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
81 These functions return <STRONG>ERR</STRONG> upon failure and otherwise a count of
82 successful conversions; this quantity may be zero.
84 In <EM>ncurses</EM>, failure occurs if <STRONG>vsscanf(3)</STRONG> returns <STRONG>EOF</STRONG>, or if the window
85 pointer <EM>win</EM> is null.
87 Functions prefixed with "mv" first perform cursor movement and fail if
88 the position (<EM>y</EM>, <EM>x</EM>) is outside the window boundaries.
91 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
92 No wide character counterpart functions are defined by the "wide"
93 <EM>ncurses</EM> configuration nor by any standard. They are unnecessary: to
94 retrieve and convert a wide-character string from a <EM>curses</EM> terminal
95 keyboard, use these functions with the <STRONG>scanf(3)</STRONG> conversions "%lc" and
96 "%ls" for wide characters and strings, respectively.
98 <EM>ncurses</EM> implements <STRONG>vsscanf(3)</STRONG> internally if it is unavailable when the
99 library is configured.
102 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
103 X/Open Curses, Issue 4 describes these functions. It specifies no
104 error conditions for them.
106 <EM>ncurses</EM> defines <STRONG>vw_scanw</STRONG> and <STRONG>vwscanw</STRONG> identically to support legacy
107 applications. However, the latter is obsolete.
109 <STRONG>o</STRONG> X/Open Curses, Issue 4 Version 2 (1996), marked <STRONG>vwscanw</STRONG> as
110 requiring <EM>varargs.h</EM> and "TO BE WITHDRAWN", and specified <STRONG>vw_scanw</STRONG>
111 using the <EM>stdarg.h</EM> interface.
113 <STRONG>o</STRONG> X/Open Curses, Issue 5, Draft 2 (December 2007) marked <STRONG>vwscanw</STRONG>
114 (along with <STRONG>vwscanw</STRONG> and the <EM>termcap</EM> interface) as withdrawn. After
115 incorporating review comments, this became X/Open Curses, Issue 7
118 <STRONG>o</STRONG> <EM>ncurses</EM> provides <STRONG>vwscanw</STRONG>, but marks it as deprecated.
120 X/Open Curses Issues 4 and 7 both state that these functions return <STRONG>ERR</STRONG>
121 or <STRONG>OK</STRONG>. This is likely an erratum.
123 <STRONG>o</STRONG> Since the underlying <STRONG>scanf(3)</STRONG> returns the number of successful
124 conversions, and SVr4 <EM>curses</EM> was documented to use this feature,
125 this may have been an editorial solecism introduced by X/Open,
126 rather than an intentional change.
128 <STRONG>o</STRONG> This implementation retains compatibility with SVr4 <EM>curses</EM>. As of
129 2018, NetBSD <EM>curses</EM> also returns the number of successful
130 conversions. Both <EM>ncurses</EM> and NetBSD <EM>curses</EM> call <STRONG>vsscanf(3)</STRONG> to
131 scan the string, which returns <STRONG>EOF</STRONG> on error.
133 <STRONG>o</STRONG> Portable applications should test only if the return value is <STRONG>ERR</STRONG>,
134 and not compare it to <STRONG>OK</STRONG>, since that value (zero) might be
137 One portable way to get useful results would be to use a "%n"
138 conversion at the end of the format string, and check the value of
139 the corresponding variable to determine how many conversions
143 </PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE>
144 <STRONG>scanw</STRONG> was implemented in 4BSD (November 1980); that early version of
145 <EM>curses</EM> preceded the ANSI C standard of 1989. The function was unused
146 in Berkeley distributions for over ten years, until 4.4BSD, which
147 employed it in a game. The 4BSD <STRONG>scanw</STRONG> did not use <EM>varargs.h</EM>, though
148 that had been available since Seventh Edition Unix (1979). In 1991 (a
149 couple of years after SVr4 was generally available, and after the C
150 standard was published), other developers updated the library, using
151 <EM>stdarg.h</EM> internally in 4.4BSD <EM>curses</EM>. Even with this improvement, BSD
152 <EM>curses</EM> did not use function prototypes (nor even declare functions) in
153 <EM>curses.h</EM> until 1992.
155 SVr2 (1984) documented <STRONG>scanw</STRONG> and <STRONG>wscanw</STRONG> tersely as "scanf through
156 <STRONG>stdscr</STRONG>" and "scanf through <EM>win</EM>", respectively.
158 SVr3 (1987) added <STRONG>mvscanw</STRONG>, and <STRONG>mvwscanw</STRONG>, stating
160 "[t]hese routines correspond to <STRONG>scanf(3S)</STRONG>, as do their arguments
161 and return values. <STRONG>wgetstr</STRONG>() is called on the window, and the
162 resulting line is used as input for the scan."
164 SVr3 also implemented <STRONG>vwscanw</STRONG>, describing its third parameter as a
165 <EM>va</EM><STRONG>_</STRONG><EM>list</EM>, defined in <EM>varargs.h</EM>, and referred the reader to the manual
166 pages for <EM>varargs</EM> and <EM>vprintf</EM> for detailed descriptions. (Because the
167 SVr3 documentation does not mention <EM>vscanf</EM>, the reference to <EM>vprintf</EM>
168 might not be an error).
170 SVr4 (1989) introduced no new variations of <EM>scanw</EM>, but provided for
171 using either <EM>varargs.h</EM> or <EM>stdarg.h</EM> to define the <EM>va</EM><STRONG>_</STRONG><EM>list</EM> type.
173 X/Open Curses, Issue 4 (1995), defined <EM>vw</EM><STRONG>_</STRONG><EM>scanw</EM> to replace <EM>vwscanw</EM>,
174 stating that its <EM>va</EM><STRONG>_</STRONG><EM>list</EM> type is defined in <EM>stdarg.h</EM>.
177 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
178 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>, <STRONG><A HREF="curs_printw.3x.html">curs_printw(3x)</A></STRONG>, <STRONG>scanf(3)</STRONG>, <STRONG>vscanf(3)</STRONG>
182 ncurses 6.5 2024-04-20 <STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>
186 <li><a href="#h2-NAME">NAME</a></li>
187 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
188 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a></li>
189 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
190 <li><a href="#h2-NOTES">NOTES</a></li>
191 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
192 <li><a href="#h2-HISTORY">HISTORY</a></li>
193 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>