1 /**************************************************************************** 2 * Copyright (c) 1998-2009,2012 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: Thomas E. Dickey 1997-on * 31 ****************************************************************************/ 32 33 /* 34 ** lib_printw.c 35 ** 36 ** The routines printw(), wprintw() and friends. 37 ** 38 */ 39 40 #include <curses.priv.h> 41 42 MODULE_ID("$Id: lib_printw.c,v 1.23 2012/09/03 17:55:28 tom Exp $") 43 44 NCURSES_EXPORT(int) 45 printw(const char *fmt,...) 46 { 47 va_list argp; 48 int code; 49 50 #ifdef TRACE 51 va_list argq; 52 va_start(argq, fmt); 53 T((T_CALLED("printw(%s%s)"), 54 _nc_visbuf(fmt), _nc_varargs(fmt, argq))); 55 va_end(argq); 56 #endif 57 58 va_start(argp, fmt); 59 code = vwprintw(stdscr, fmt, argp); 60 va_end(argp); 61 62 returnCode(code); 63 } 64 65 NCURSES_EXPORT(int) 66 wprintw(WINDOW *win, const char *fmt,...) 67 { 68 va_list argp; 69 int code; 70 71 #ifdef TRACE 72 va_list argq; 73 va_start(argq, fmt); 74 T((T_CALLED("wprintw(%p,%s%s)"), 75 (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); 76 va_end(argq); 77 #endif 78 79 va_start(argp, fmt); 80 code = vwprintw(win, fmt, argp); 81 va_end(argp); 82 83 returnCode(code); 84 } 85 86 NCURSES_EXPORT(int) 87 mvprintw(int y, int x, const char *fmt,...) 88 { 89 va_list argp; 90 int code; 91 92 #ifdef TRACE 93 va_list argq; 94 va_start(argq, fmt); 95 T((T_CALLED("mvprintw(%d,%d,%s%s)"), 96 y, x, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); 97 va_end(argq); 98 #endif 99 100 if ((code = move(y, x)) != ERR) { 101 va_start(argp, fmt); 102 code = vwprintw(stdscr, fmt, argp); 103 va_end(argp); 104 } 105 returnCode(code); 106 } 107 108 NCURSES_EXPORT(int) 109 mvwprintw(WINDOW *win, int y, int x, const char *fmt,...) 110 { 111 va_list argp; 112 int code; 113 114 #ifdef TRACE 115 va_list argq; 116 va_start(argq, fmt); 117 T((T_CALLED("mvwprintw(%d,%d,%p,%s%s)"), 118 y, x, (void *) win, _nc_visbuf(fmt), _nc_varargs(fmt, argq))); 119 va_end(argq); 120 #endif 121 122 if ((code = wmove(win, y, x)) != ERR) { 123 va_start(argp, fmt); 124 code = vwprintw(win, fmt, argp); 125 va_end(argp); 126 } 127 returnCode(code); 128 } 129 130 NCURSES_EXPORT(int) 131 vwprintw(WINDOW *win, const char *fmt, va_list argp) 132 { 133 char *buf; 134 int code = ERR; 135 #if NCURSES_SP_FUNCS 136 SCREEN *sp = _nc_screen_of(win); 137 #endif 138 139 T((T_CALLED("vwprintw(%p,%s,va_list)"), (void *) win, _nc_visbuf(fmt))); 140 141 buf = NCURSES_SP_NAME(_nc_printf_string) (NCURSES_SP_ARGx fmt, argp); 142 if (buf != 0) { 143 code = waddstr(win, buf); 144 } 145 returnCode(code); 146 } 147