1 /**************************************************************************** 2 * Copyright (c) 1998-2001,2009 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 /**************************************************************************** 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 43 MODULE_ID("$Id: lib_scanw.c,v 1.12 2009/10/24 22:35:14 tom Exp $") 44 45 NCURSES_EXPORT(int) 46 vwscanw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp) 47 { 48 char buf[BUFSIZ]; 49 50 if (wgetnstr(win, buf, sizeof(buf) - 1) == ERR) 51 return (ERR); 52 53 return (vsscanf(buf, fmt, argp)); 54 } 55 56 NCURSES_EXPORT(int) 57 scanw(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 70 NCURSES_EXPORT(int) 71 wscanw(WINDOW *win, NCURSES_CONST char *fmt,...) 72 { 73 int code; 74 va_list ap; 75 76 T(("wscanw(%p,\"%s\",...) called", (void *) win, fmt)); 77 78 va_start(ap, fmt); 79 code = vwscanw(win, fmt, ap); 80 va_end(ap); 81 return (code); 82 } 83 84 NCURSES_EXPORT(int) 85 mvscanw(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 96 NCURSES_EXPORT(int) 97 mvwscanw(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 } 107