1 /* 2 * Copyright (c) 1981, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)scanw.c 8.3 (Berkeley) 05/04/94"; 10 #endif /* not lint */ 11 12 /* 13 * scanw and friends. 14 */ 15 16 #ifdef __STDC__ 17 #include <stdarg.h> 18 #else 19 #include <varargs.h> 20 #endif 21 22 #include "curses.h" 23 24 /* 25 * scanw -- 26 * Implement a scanf on the standard screen. 27 */ 28 int 29 #ifdef __STDC__ 30 scanw(const char *fmt, ...) 31 #else 32 scanw(fmt, va_alist) 33 char *fmt; 34 va_dcl 35 #endif 36 { 37 va_list ap; 38 int ret; 39 40 #ifdef __STDC__ 41 va_start(ap, fmt); 42 #else 43 va_start(ap); 44 #endif 45 ret = vwscanw(stdscr, fmt, ap); 46 va_end(ap); 47 return (ret); 48 } 49 50 /* 51 * wscanw -- 52 * Implements a scanf on the given window. 53 */ 54 int 55 #ifdef __STDC__ 56 wscanw(WINDOW *win, const char *fmt, ...) 57 #else 58 wscanw(win, fmt, va_alist) 59 WINDOW *win; 60 char *fmt; 61 va_dcl 62 #endif 63 { 64 va_list ap; 65 int ret; 66 67 #ifdef __STDC__ 68 va_start(ap, fmt); 69 #else 70 va_start(ap); 71 #endif 72 ret = vwscanw(win, fmt, ap); 73 va_end(ap); 74 return (ret); 75 } 76 77 /* 78 * mvscanw, mvwscanw -- 79 * Implement the mvscanw commands. Due to the variable number of 80 * arguments, they cannot be macros. Another sigh.... 81 */ 82 int 83 #ifdef __STDC__ 84 mvscanw(register int y, register int x, const char *fmt,...) 85 #else 86 mvscanw(y, x, fmt, va_alist) 87 register int y, x; 88 char *fmt; 89 va_dcl 90 #endif 91 { 92 va_list ap; 93 int ret; 94 95 if (move(y, x) != OK) 96 return (ERR); 97 #ifdef __STDC__ 98 va_start(ap, fmt); 99 #else 100 va_start(ap); 101 #endif 102 ret = vwscanw(stdscr, fmt, ap); 103 va_end(ap); 104 return (ret); 105 } 106 107 int 108 #ifdef __STDC__ 109 mvwscanw(register WINDOW * win, register int y, register int x, 110 const char *fmt, ...) 111 #else 112 mvwscanw(win, y, x, fmt, va_alist) 113 register WINDOW *win; 114 register int y, x; 115 char *fmt; 116 va_dcl 117 #endif 118 { 119 va_list ap; 120 int ret; 121 122 if (move(y, x) != OK) 123 return (ERR); 124 #ifdef __STDC__ 125 va_start(ap, fmt); 126 #else 127 va_start(ap); 128 #endif 129 ret = vwscanw(win, fmt, ap); 130 va_end(ap); 131 return (ret); 132 } 133 134 /* 135 * vwscanw -- 136 * This routine actually executes the scanf from the window. 137 */ 138 int 139 vwscanw(win, fmt, ap) 140 WINDOW *win; 141 const char *fmt; 142 va_list ap; 143 { 144 145 char buf[1024]; 146 147 return (wgetstr(win, buf) == OK ? 148 vsscanf(buf, fmt, ap) : ERR); 149 } 150