]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_scanw.3x
ncurses 6.2 - patch 20200308
[ncurses.git] / man / curs_scanw.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
3 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_scanw.3x,v 1.26 2020/02/02 23:34:34 tom Exp $
31 .TH curs_scanw 3X ""
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .SH NAME
41 \fBscanw\fR,
42 \fBwscanw\fR,
43 \fBmvscanw\fR,
44 \fBmvwscanw\fR,
45 \fBvwscanw\fR, \fBvw_scanw\fR \- convert formatted input from a \fBcurses\fR window
46 .SH SYNOPSIS
47 \fB#include <curses.h>\fR
48 .sp
49 \fBint scanw(const char *fmt, ...);\fR
50 .br
51 \fBint wscanw(WINDOW *win, const char *fmt, ...);\fR
52 .br
53 \fBint mvscanw(int y, int x, const char *fmt, ...);\fR
54 .br
55 \fBint mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...);\fR
56 .br
57 \fBint vw_scanw(WINDOW *win, const char *fmt, va_list varglist);\fR
58 .sp
59 /* obsolete */
60 .br
61 \fBint vwscanw(WINDOW *win, const char *fmt, va_list varglist);\fR
62 .SH DESCRIPTION
63 The \fBscanw\fR, \fBwscanw\fR and \fBmvscanw\fR routines are analogous to
64 \fBscanf\fR [see \fBscanf\fR(3)].
65 The effect of these routines is as though
66 \fBwgetstr\fR were called on the window, and the resulting line used as input
67 for \fBsscanf\fR(3).
68 Fields which do not map to a variable in the \fIfmt\fR
69 field are lost.
70 .PP
71 The \fBvwscanw\fR and \fBvw_scanw\fR routines are analogous to \fBvscanf\fR(3).
72 They perform a \fBwscanw\fR using a variable argument list.
73 The third argument is a \fIva_list\fR,
74 a pointer to a list of arguments, as defined in \fB<stdarg.h>\fR.
75 .SH RETURN VALUE
76 \fBvwscanw\fR returns \fBERR\fR on failure and an integer equal to the
77 number of fields scanned on success.
78 .PP
79 Applications may use the return value from the \fBscanw\fR, \fBwscanw\fR,
80 \fBmvscanw\fR and \fBmvwscanw\fR routines to determine the number of fields
81 which were mapped in the call.
82 .PP
83 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
84 \fBwmove\fP, and return an error if the position is outside the window,
85 or if the window pointer is null.
86 .SH PORTABILITY
87 In this implementation, \fBvw_scanw\fP and \fBvwscanw\fP are equivalent,
88 to support legacy applications.
89 However, the latter (\fBvwscanw\fP) is obsolete:
90 .bP
91 The XSI Curses standard, Issue 4 described these functions,
92 noting that the function
93 \fBvwscanw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
94 \fBvw_scanw\fR using the \fB<stdarg.h>\fR interface.
95 .bP
96 The Single Unix Specification, Version 2 states that
97 \fBvw_scanw\fR  is preferred to \fBvwscanw\fR since the latter requires
98 including \fB<varargs.h>\fR, which
99 cannot be used in the same file as \fB<stdarg.h>\fR.
100 This implementation uses \fB<stdarg.h>\fR for both, because that header
101 is included in \fB<curses.h\fR>.
102 .bP
103 X/Open Curses, Issue 5 (December 2007) marked \fBvwscanw\fP (along with
104 \fBvwprintw\fP and the termcap interface) as withdrawn.
105 .LP
106 Both XSI and The Single Unix Specification, Version 2 state that these
107 functions return \fBERR\fP or \fBOK\fP.
108 .bP
109 Since the underlying \fBscanf\fR(3) can return the number of items scanned,
110 and the SVr4 code was documented to use this feature,
111 this is probably an editing error which was introduced in XSI,
112 rather than being done intentionally.
113 .bP
114 This implementation returns the number of items scanned,
115 for compatibility with SVr4 curses.
116 As of 2018, NetBSD curses also returns the number of items scanned.
117 Both ncurses and NetBSD curses call \fBvsscanf\fP to scan the string,
118 which returns \fBEOF\fP on error.
119 .bP
120 Portable applications should only test if the return value is \fBERR\fP,
121 since the \fBOK\fP value (zero) is likely to be misleading.
122 .IP
123 One possible way to get useful results would be to use a "%n" conversion
124 at the end of the format string to ensure that something was processed.
125 .SH SEE ALSO
126 .na
127 \fBcurses\fR(3X),
128 \fBcurs_getstr\fR(3X),
129 \fBcurs_printw\fR(3X),
130 \fBcurs_termcap\fP(3X),
131 \fBscanf\fR(3).