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