blob: 637aa46ece01ab0921bb18216e9428f9999a1eb9 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301/****************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01002 * Copyright (c) 1998-2009,2011 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05303 * *
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/****************************************************************************
30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
31 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
32 ****************************************************************************/
33
34/*
35** lib_scanw.c
36**
37** The routines scanw(), wscanw() and friends.
38**
39*/
40
41#include <curses.priv.h>
42
Steve Kondikae271bc2015-11-15 02:50:53 +010043MODULE_ID("$Id: lib_scanw.c,v 1.13 2011/10/22 16:31:35 tom Exp $")
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053044
45NCURSES_EXPORT(int)
46vwscanw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
47{
48 char buf[BUFSIZ];
49
Steve Kondikae271bc2015-11-15 02:50:53 +010050 if (wgetnstr(win, buf, (int) sizeof(buf) - 1) == ERR)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053051 return (ERR);
52
53 return (vsscanf(buf, fmt, argp));
54}
55
56NCURSES_EXPORT(int)
57scanw(NCURSES_CONST char *fmt,...)
58{
59 int code;
60 va_list ap;
61
62 T(("scanw(\"%s\",...) called", fmt));
63
64 va_start(ap, fmt);
65 code = vwscanw(stdscr, fmt, ap);
66 va_end(ap);
67 return (code);
68}
69
70NCURSES_EXPORT(int)
71wscanw(WINDOW *win, NCURSES_CONST char *fmt,...)
72{
73 int code;
74 va_list ap;
75
Steve Kondikae271bc2015-11-15 02:50:53 +010076 T(("wscanw(%p,\"%s\",...) called", (void *) win, fmt));
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053077
78 va_start(ap, fmt);
79 code = vwscanw(win, fmt, ap);
80 va_end(ap);
81 return (code);
82}
83
84NCURSES_EXPORT(int)
85mvscanw(int y, int x, NCURSES_CONST char *fmt,...)
86{
87 int code;
88 va_list ap;
89
90 va_start(ap, fmt);
91 code = (move(y, x) == OK) ? vwscanw(stdscr, fmt, ap) : ERR;
92 va_end(ap);
93 return (code);
94}
95
96NCURSES_EXPORT(int)
97mvwscanw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...)
98{
99 int code;
100 va_list ap;
101
102 va_start(ap, fmt);
103 code = (wmove(win, y, x) == OK) ? vwscanw(win, fmt, ap) : ERR;
104 va_end(ap);
105 return (code);
106}