]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_scanw.3x
905b93ba2f2f24321eca546393d0dd6fe53a056e
[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.24 2018/07/28 21:14:06 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)].
60 The effect of these routines is as though
61 \fBwgetstr\fR were called on the window, and the resulting line used as input
62 for \fBsscanf\fR(3).
63 Fields which do not map to a variable in the \fIfmt\fR
64 field are lost.
65 .PP
66 The \fBvwscanw\fR and \fBvw_scanw\fR routines are analogous to \fBvscanf\fR(3).
67 They perform a \fBwscanw\fR using a variable argument list.
68 The third argument is a \fIva_list\fR,
69 a pointer to a list of arguments, as defined in \fB<stdarg.h>\fR.
70 .SH RETURN VALUE
71 \fBvwscanw\fR returns \fBERR\fR on failure and an integer equal to the
72 number of fields scanned on success.
73 .PP
74 Applications may use the return value from the \fBscanw\fR, \fBwscanw\fR,
75 \fBmvscanw\fR and \fBmvwscanw\fR routines to determine the number of fields
76 which were mapped in the call.
77 .PP
78 Functions with a "mv" prefix first perform a cursor movement using
79 \fBwmove\fP, and return an error if the position is outside the window,
80 or if the window pointer is null.
81 .SH PORTABILITY
82 In this implementation, \fBvw_scanw\fP and \fBvwscanw\fP are equivalent,
83 to support legacy applications.
84 However, the latter (\fBvwscanw\fP) is obsolete:
85 .bP
86 The XSI Curses standard, Issue 4 described these functions,
87 noting that the function
88 \fBvwscanw\fR is marked TO BE WITHDRAWN, and is to be replaced by a function
89 \fBvw_scanw\fR using the \fB<stdarg.h>\fR interface.
90 .bP
91 The Single Unix Specification, Version 2 states that
92 \fBvw_scanw\fR  is preferred to \fBvwscanw\fR since the latter requires
93 including \fB<varargs.h>\fR, which
94 cannot be used in the same file as \fB<stdarg.h>\fR.
95 This implementation uses \fB<stdarg.h>\fR for both, because that header
96 is included in \fB<curses.h\fR>.
97 .bP
98 X/Open Curses, Issue 5 (December 2007) marked \fBvwscanw\fP (along with
99 \fBvwprintw\fP and the termcap interface) as withdrawn.
100 .LP
101 Both XSI and The Single Unix Specification, Version 2 state that these
102 functions return \fBERR\fP or \fBOK\fP.
103 .bP
104 Since the underlying \fBscanf\fR(3) can return the number of items scanned,
105 and the SVr4 code was documented to use this feature,
106 this is probably an editing error which was introduced in XSI,
107 rather than being done intentionally.
108 .bP
109 This implementation returns the number of items scanned,
110 for compatibility with SVr4 curses.
111 As of 2018, NetBSD curses also returns the number of items scanned.
112 Both ncurses and NetBSD curses call \fBvsscanf\fP to scan the string,
113 which returns \fBEOF\fP on error.
114 .bP
115 Portable applications should only test if the return value is \fBERR\fP,
116 since the \fBOK\fP value (zero) is likely to be misleading.
117 .IP
118 One possible way to get useful results would be to use a "%n" conversion
119 at the end of the format string to ensure that something was processed.
120 .SH SEE ALSO
121 .na
122 \fBcurses\fR(3X),
123 \fBcurs_getstr\fR(3X),
124 \fBcurs_printw\fR(3X),
125 \fBcurs_termcap\fP(3X),
126 \fBscanf\fR(3).