]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/curs_scanw.3x.html
ncurses 6.4 - patch 20231217
[ncurses.git] / doc / html / man / curs_scanw.3x.html
1 <!--
2   ****************************************************************************
3   * Copyright 2018-2022,2023 Thomas E. Dickey                                *
4   * Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
5   *                                                                          *
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:                 *
13   *                                                                          *
14   * The above copyright notice and this permission notice shall be included  *
15   * in all copies or substantial portions of the Software.                   *
16   *                                                                          *
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.                               *
24   *                                                                          *
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       *
28   * authorization.                                                           *
29   ****************************************************************************
30   * @Id: curs_scanw.3x,v 1.44 2023/12/17 22:50:40 tom Exp @
31   * https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/\
32   *  libcurses/scanw.c
33   * https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/include/\
34   *  varargs.h
35   * either header declares "va_list", but only one can be used
36 -->
37 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
38 <HTML>
39 <HEAD>
40 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
41 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
42 <TITLE>curs_scanw 3x 2023-12-17 ncurses 6.4 Library calls</TITLE>
43 <link rel="author" href="mailto:bug-ncurses@gnu.org">
44
45 </HEAD>
46 <BODY>
47 <H1 class="no-header">curs_scanw 3x 2023-12-17 ncurses 6.4 Library calls</H1>
48 <PRE>
49 <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>
50
51
52
53
54 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
55        <STRONG>scanw</STRONG>,  <STRONG>wscanw</STRONG>,  <STRONG>mvscanw</STRONG>,  <STRONG>mvwscanw</STRONG>, <STRONG>vwscanw</STRONG>, <STRONG>vw_scanw</STRONG> - read formatted
56        input from a <EM>curses</EM> window
57
58
59 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
60        <STRONG>#include</STRONG> <STRONG>&lt;curses.h&gt;</STRONG>
61
62        <STRONG>int</STRONG> <STRONG>scanw(const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>fmt</EM><STRONG>,</STRONG> <STRONG>...);</STRONG>
63        <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>
64        <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>
65        <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>
66
67        <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>
68
69        <EM>/*</EM> <EM>obsolete</EM> <EM>*/</EM>
70        <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>
71
72
73 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
74        <STRONG>scanw</STRONG>, <STRONG>wscanw</STRONG>, <STRONG>mvscanw</STRONG>, and <STRONG>mvwscanw</STRONG> are  analogous  to  <STRONG>scanf(3)</STRONG>.   In
75        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
76        argument,  then  attempt  conversion  of  the  resulting  string   with
77        <STRONG>vsscanf(3)</STRONG>.   Fields in the string that do not map to a variable in the
78        <EM>fmt</EM> parameter are discarded.
79
80        <STRONG>vwscanw</STRONG> and <STRONG>vw_scanw</STRONG> are analogous to <STRONG>vscanf(3)</STRONG>, and perform  a  <STRONG>wscanw</STRONG>
81        using  a  variable  argument  list.  The third argument is a <EM>va</EM><STRONG>_</STRONG><EM>list</EM>, a
82        pointer to a list of arguments, as defined in <EM>stdarg.h</EM>.
83
84
85 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
86        These functions return <STRONG>ERR</STRONG>  upon  failure  and  otherwise  a  count  of
87        successful conversions; this quantity may be zero.
88
89        In  <EM>ncurses,</EM> failure occurs if <STRONG>vsscanf(3)</STRONG> returns <STRONG>EOF</STRONG>, or if the window
90        pointer <EM>win</EM> is null.
91
92        Functions with a "mv" prefix first  perform  a  cursor  movement  using
93        <STRONG>wmove</STRONG>, and fail if the position is outside the window.
94
95
96 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
97        No  wide  character  counterpart  functions  are  defined by the "wide"
98        <EM>ncurses</EM> configuration nor by any standard.  They  are  unnecessary:  to
99        retrieve  and  convert  a  wide-character string from a <EM>curses</EM> terminal
100        keyboard, use these functions with the <STRONG>scanf(3)</STRONG> conversions  "%lc"  and
101        "%ls" for wide characters and strings, respectively.
102
103        <EM>ncurses</EM>  implements <STRONG>vsscanf(3)</STRONG> internally if it is unavailable when the
104        library is configured.
105
106
107 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
108        X/Open Curses, Issue 4, describes these  functions.   It  specifies  no
109        error conditions for them.
110
111        <EM>ncurses</EM>  defines  <STRONG>vw_scanw</STRONG>  and  <STRONG>vwscanw</STRONG>  identically to support legacy
112        applications.  However, the latter is obsolete.
113
114        <STRONG>o</STRONG>   X/Open Curses,  Issue  4,  Version  2  (1996),  marked  <STRONG>vwscanw</STRONG>  as
115            requiring  <EM>varargs.h</EM>  and "TO BE WITHDRAWN", and specified <STRONG>vw_scanw</STRONG>
116            using the <EM>stdarg.h</EM> interface.
117
118        <STRONG>o</STRONG>   X/Open Curses, Issue 5, Draft  2  (December  2007)  marked  <STRONG>vwscanw</STRONG>
119            (along with <STRONG>vwscanw</STRONG> and the termcap interface) as withdrawn.  After
120            incorporating review comments, this became X/Open Curses,  Issue  7
121            (2009).
122
123        <STRONG>o</STRONG>   <EM>ncurses</EM> provides <STRONG>vwscanw</STRONG>, but marks it as deprecated.
124
125        X/Open Curses Issues 4 and 7 both state that these functions return <STRONG>ERR</STRONG>
126        or <STRONG>OK</STRONG>.  This is likely an erratum.
127
128        <STRONG>o</STRONG>   Since the underlying <STRONG>scanf(3)</STRONG>  returns  the  number  of  successful
129            conversions,  and  SVr4  <EM>curses</EM> was documented to use this feature,
130            this may have been an  editorial  solecism  introduced  by  X/Open,
131            rather than an intentional change.
132
133        <STRONG>o</STRONG>   This  implementation retains compatibility with SVr4 <EM>curses.</EM>  As of
134            2018,  NetBSD  <EM>curses</EM>  also  returns  the  number   of   successful
135            conversions.   Both  <EM>ncurses</EM>  and  NetBSD <EM>curses</EM> call <STRONG>vsscanf(3)</STRONG> to
136            scan the string, which returns <STRONG>EOF</STRONG> on error.
137
138        <STRONG>o</STRONG>   Portable applications should test only if the return value is  <STRONG>ERR</STRONG>,
139            and  not  compare  it  to  <STRONG>OK</STRONG>,  since  that  value  (zero) might be
140            misleading.
141
142            One portable way to get useful results  would  be  to  use  a  "%n"
143            conversion  at the end of the format string, and check the value of
144            the  corresponding  variable  to  determine  how  many  conversions
145            succeeded.
146
147
148 </PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE>
149        <STRONG>scanw</STRONG>  was  implemented  in 4BSD (November 1980); that early version of
150        <EM>curses</EM> preceded the ANSI C standard of 1989.  The function  was  unused
151        in  Berkeley  distributions  for  over  ten  years, until 4.4BSD, which
152        employed it in a game.  The 4BSD <STRONG>scanw</STRONG> did not  use  <EM>varargs.h</EM>,  though
153        that  had been available since Seventh Edition Unix (1979).  In 1991 (a
154        couple of years after SVr4 was generally available,  and  after  the  C
155        standard  was  published),  other developers updated the library, using
156        <EM>stdarg.h</EM> internally in 4.4BSD <EM>curses.</EM>  Even with this improvement,  BSD
157        <EM>curses</EM>  did not use function prototypes (nor even declare functions) in
158        <EM>curses.h</EM> until 1992.
159
160        SVr2 (1984) documented <STRONG>scanw</STRONG>  and  <STRONG>wscanw</STRONG>  tersely  as  "scanf  through
161        <STRONG>stdscr</STRONG>" and "scanf through <EM>win</EM>", respectively.
162
163        SVr3 (1987) added <STRONG>mvscanw</STRONG>, and <STRONG>mvwscanw</STRONG>, stating
164
165               These  routines  correspond  to <STRONG>scanf(3S)</STRONG>, as do their arguments
166               and return values.  <STRONG>wgetstr</STRONG>() is called on the window,  and  the
167               resulting line is used as input for the scan.
168
169        SVr3  also  implemented  <STRONG>vwscanw</STRONG>,  describing  its third parameter as a
170        <EM>va</EM><STRONG>_</STRONG><EM>list</EM>, defined in <EM>varargs.h</EM>, and referred the reader  to  the  manual
171        pages  for <EM>varargs</EM> and <EM>vprintf</EM> for detailed descriptions.  (Because the
172        SVr3 documentation does not mention <EM>vscanf</EM>, the  reference  to  <EM>vprintf</EM>
173        might not be an error).
174
175        SVr4  (1989)  introduced  no  new variations of <EM>scanw</EM>, but provided for
176        using either <EM>varargs.h</EM> or <EM>stdarg.h</EM> to define the <EM>va</EM><STRONG>_</STRONG><EM>list</EM> type.
177
178        X/Open Curses, Issue 4 (1995), defined  <EM>vw</EM><STRONG>_</STRONG><EM>scanw</EM>  to  replace  <EM>vwscanw</EM>,
179        stating that its <EM>va</EM><STRONG>_</STRONG><EM>list</EM> type is defined in <EM>stdarg.h</EM>.
180
181
182 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
183        <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>
184
185
186
187 ncurses 6.4                       2023-12-17                    <STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>
188 </PRE>
189 <div class="nav">
190 <ul>
191 <li><a href="#h2-NAME">NAME</a></li>
192 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
193 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a></li>
194 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
195 <li><a href="#h2-NOTES">NOTES</a></li>
196 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
197 <li><a href="#h2-HISTORY">HISTORY</a></li>
198 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
199 </ul>
200 </div>
201 </BODY>
202 </HTML>