Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 1998-2010,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 30 | .\" $Id: curs_scanw.3x,v 1.53 2024/04/20 19:18:18 tom Exp $ |
| 31 | .TH curs_scanw 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" |
| 32 | .ie \n(.g \{\ |
| 33 | .ds `` \(lq |
| 34 | .ds '' \(rq |
| 35 | .\} |
| 36 | .el \{\ |
| 37 | .ie t .ds `` `` |
| 38 | .el .ds `` "" |
| 39 | .ie t .ds '' '' |
| 40 | .el .ds '' "" |
| 41 | .\} |
| 42 | . |
| 43 | .de bP |
| 44 | .ie n .IP \(bu 4 |
| 45 | .el .IP \(bu 2 |
| 46 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 47 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 48 | \fB\%scanw\fP, |
| 49 | \fB\%wscanw\fP, |
| 50 | \fB\%mvscanw\fP, |
| 51 | \fB\%mvwscanw\fP, |
| 52 | \fB\%vwscanw\fP, |
| 53 | \fB\%vw_scanw\fP \- |
| 54 | read formatted input from a \fIcurses\fR window |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 56 | .nf |
| 57 | \fB#include <curses.h> |
| 58 | .PP |
| 59 | \fBint scanw(const char *\fIfmt\fP, ...); |
| 60 | \fBint wscanw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, ...); |
| 61 | \fBint mvscanw(int \fIy\fP, int \fIx\fP, const char *\fIfmt\fP, ...); |
| 62 | \fBint mvwscanw(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, const char *\fIfmt\fP, ...); |
| 63 | .PP |
| 64 | \fBint vw_scanw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, va_list \fIvarglist\fP); |
| 65 | .PP |
| 66 | \fI/* obsolete */\fP |
| 67 | \fBint vwscanw(WINDOW *\fIwin\fP, const char *\fIfmt\fP, va_list \fIvarglist\fP); |
| 68 | .fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 69 | .SH DESCRIPTION |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 70 | \fB\%scanw\fP, |
| 71 | \fB\%wscanw\fP, |
| 72 | \fB\%mvscanw\fP, |
| 73 | and |
| 74 | \fB\%mvwscanw\fP |
| 75 | are analogous to \fI\%scanf\fP(3). |
| 76 | In effect, |
| 77 | they call \fB\%wgetstr\fP(3X) with |
| 78 | .I win |
| 79 | (or |
| 80 | .BR \%stdscr ) |
| 81 | as its first argument, |
| 82 | then attempt conversion of the resulting string with \fI\%vsscanf\fP(3). |
| 83 | Fields in the string that do not map to a variable in the \fIfmt\fP |
| 84 | parameter are discarded. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 85 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 86 | \fB\%vwscanw\fP |
| 87 | and |
| 88 | \fB\%vw_scanw\fP are analogous to \fI\%vscanf\fP(3), |
| 89 | and perform a \fB\%wscanw\fP using a variable argument list. |
| 90 | The third argument is a \fI\%va_list\fP, |
| 91 | a pointer to a list of arguments, |
| 92 | as defined in \fI\%stdarg.h\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 93 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 94 | These functions return |
| 95 | .B ERR |
| 96 | upon failure and otherwise a count of successful conversions; |
| 97 | this quantity may be zero. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 98 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 99 | In |
| 100 | .IR \%ncurses , |
| 101 | failure occurs if \fI\%vsscanf\fP(3) returns |
| 102 | \fBEOF\fP, |
| 103 | or if the window pointer |
| 104 | .I win |
| 105 | is null. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 106 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 107 | Functions prefixed with \*(``mv\*('' first perform cursor movement and |
| 108 | fail if the position |
| 109 | .RI ( y , |
| 110 | .IR x ) |
| 111 | is outside the window boundaries. |
| 112 | .SH NOTES |
| 113 | No wide character counterpart functions are defined by the |
| 114 | \*(``wide\*('' |
| 115 | .I \%ncurses |
| 116 | configuration nor by any standard. |
| 117 | They are unnecessary: |
| 118 | to retrieve and convert a wide-character string from a |
| 119 | .I curses |
| 120 | terminal keyboard, |
| 121 | use these functions with the \fI\%scanf\fP(3) conversions \*(``%lc\*('' |
| 122 | and \*(``%ls\*('' for wide characters and strings, |
| 123 | respectively. |
| 124 | .PP |
| 125 | .I \%ncurses |
| 126 | implements \fI\%vsscanf\fP(3) internally if it is unavailable when the |
| 127 | library is configured. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 128 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 129 | X/Open Curses, |
| 130 | Issue 4 describes these functions. |
| 131 | It specifies no error conditions for them. |
| 132 | .PP |
| 133 | .I \%ncurses |
| 134 | defines \fB\%vw_scanw\fP and \fB\%vwscanw\fP identically to support |
| 135 | legacy applications. |
| 136 | However, |
| 137 | the latter is obsolete. |
| 138 | .bP |
| 139 | X/Open Curses, |
| 140 | Issue 4 Version 2 (1996), |
| 141 | marked \fB\%vwscanw\fP as requiring \fI\%varargs.h\fP and |
| 142 | \*(``TO BE WITHDRAWN\*('', |
| 143 | and specified \fB\%vw_scanw\fP using the \fI\%stdarg.h\fP interface. |
| 144 | .bP |
| 145 | X/Open Curses, |
| 146 | Issue 5, |
| 147 | Draft 2 (December 2007) marked \fB\%vwscanw\fP (along with |
| 148 | \fB\%vwscanw\fP and the \fItermcap\fP interface) as withdrawn. |
| 149 | After incorporating review comments, |
| 150 | this became |
| 151 | X/Open Curses, Issue 7 (2009). |
| 152 | .bP |
| 153 | .I \%ncurses |
| 154 | provides \fB\%vwscanw\fP, |
| 155 | but marks it as deprecated. |
| 156 | .PP |
| 157 | X/Open Curses Issues 4 and 7 both state that these functions return |
| 158 | \fBERR\fP or \fBOK\fP. |
| 159 | This is likely an erratum. |
| 160 | .bP |
| 161 | Since the underlying \fI\%scanf\fP(3) returns the number of successful |
| 162 | conversions, |
| 163 | and SVr4 |
| 164 | .I curses |
| 165 | was documented to use this feature, |
| 166 | this may have been an editorial solecism introduced by X/Open, |
| 167 | rather than an intentional change. |
| 168 | .bP |
| 169 | This implementation retains compatibility with SVr4 |
| 170 | .IR curses . |
| 171 | As of 2018, |
| 172 | NetBSD |
| 173 | .I curses |
| 174 | also returns the number of successful conversions. |
| 175 | Both |
| 176 | .I \%ncurses\fP |
| 177 | and NetBSD |
| 178 | .I curses |
| 179 | call \fI\%vsscanf\fP(3) to scan the string, |
| 180 | which returns \fBEOF\fP on error. |
| 181 | .bP |
| 182 | Portable applications should test only if the return value is \fBERR\fP, |
| 183 | and not compare it to \fBOK\fP, |
| 184 | since that value (zero) might be misleading. |
| 185 | .IP |
| 186 | One portable way to get useful results would be to use a \*(``%n\*('' |
| 187 | conversion at the end of the format string, |
| 188 | and check the value of the corresponding variable to determine how many |
| 189 | conversions succeeded. |
| 190 | .SH HISTORY |
| 191 | \fB\%scanw\fP was implemented in 4BSD |
| 192 | (November 1980); |
| 193 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/\ |
| 194 | .\" libcurses/scanw.c |
| 195 | that early version of |
| 196 | .I curses |
| 197 | preceded the ANSI C standard of 1989. |
| 198 | The function was unused in Berkeley distributions for over ten years, |
| 199 | until 4.4BSD, |
| 200 | which employed it in a game. |
| 201 | The 4BSD \fB\%scanw\fP did not use \fI\%varargs.h\fP, |
| 202 | though that had been available since Seventh Edition Unix (1979). |
| 203 | .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/include/\ |
| 204 | .\" varargs.h |
| 205 | In 1991 |
| 206 | (a couple of years after SVr4 was generally available, |
| 207 | and after the C standard was published), |
| 208 | other developers updated the library, |
| 209 | using \fI\%stdarg.h\fP internally in 4.4BSD |
| 210 | .IR curses . |
| 211 | Even with this improvement, |
| 212 | BSD |
| 213 | .I curses |
| 214 | did not use function prototypes |
| 215 | (nor even declare functions) |
| 216 | in \fI\%curses.h\fP until 1992. |
| 217 | .PP |
| 218 | SVr2 (1984) documented \fB\%scanw\fP and \fB\%wscanw\fP tersely as |
| 219 | \*(``scanf through \fB\%stdscr\fP\*('' and |
| 220 | \*(``scanf through \fIwin\fP\*('', |
| 221 | respectively. |
| 222 | .PP |
| 223 | SVr3 (1987) added |
| 224 | \fB\%mvscanw\fP, and |
| 225 | \fB\%mvwscanw\fP, stating |
| 226 | .RS |
| 227 | .PP |
| 228 | \*(``[t]hese routines correspond to \fIscanf\fP(3S), |
| 229 | as do their arguments and return values. |
| 230 | \fB\%wgetstr\fP() is called on the window, |
| 231 | and the resulting line is used as input for the scan.\*('' |
| 232 | .RE |
| 233 | .PP |
| 234 | SVr3 also implemented \fB\%vwscanw\fP, |
| 235 | describing its third parameter as a \fI\%va_list\fP, |
| 236 | defined in \fI\%varargs.h\fP, |
| 237 | and referred the reader to the manual pages for \fI\%varargs\fP and |
| 238 | \fI\%vprintf\fP for detailed descriptions. |
| 239 | (Because the SVr3 documentation does not mention \fI\%vscanf\fP, |
| 240 | the reference to \fI\%vprintf\fP might not be an error). |
| 241 | .PP |
| 242 | SVr4 (1989) introduced no new variations of \fI\%scanw\fP, |
| 243 | but provided for using either \fI\%varargs.h\fP or \fI\%stdarg.h\fP to |
| 244 | define the \fI\%va_list\fP type. |
| 245 | .\" either header declares "va_list", but only one can be used |
| 246 | .PP |
| 247 | X/Open Curses, Issue 4 (1995), |
| 248 | defined \fI\%vw_scanw\fP to replace \fI\%vwscanw\fP, |
| 249 | stating that its \fI\%va_list\fP type is defined in \fI\%stdarg.h\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 250 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 251 | \fB\%curses\fP(3X), |
| 252 | \fB\%curs_getstr\fP(3X), |
| 253 | \fB\%curs_printw\fP(3X), |
| 254 | \fB\%scanf\fP(3), |
| 255 | \fB\%vscanf\fP(3) |