lib_printw.c revision 1.2
1/* $OpenBSD: lib_printw.c,v 1.2 2001/01/22 18:01:42 millert Exp $ */ 2 3/**************************************************************************** 4 * Copyright (c) 1998,2000 Free Software Foundation, Inc. * 5 * * 6 * Permission is hereby granted, free of charge, to any person obtaining a * 7 * copy of this software and associated documentation files (the * 8 * "Software"), to deal in the Software without restriction, including * 9 * without limitation the rights to use, copy, modify, merge, publish, * 10 * distribute, distribute with modifications, sublicense, and/or sell * 11 * copies of the Software, and to permit persons to whom the Software is * 12 * furnished to do so, subject to the following conditions: * 13 * * 14 * The above copyright notice and this permission notice shall be included * 15 * in all copies or substantial portions of the Software. * 16 * * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 24 * * 25 * Except as contained in this notice, the name(s) of the above copyright * 26 * holders shall not be used in advertising or otherwise to promote the * 27 * sale, use or other dealings in this Software without prior written * 28 * authorization. * 29 ****************************************************************************/ 30 31/**************************************************************************** 32 * Author: Thomas E. Dickey <dickey@clark.net> 1997 * 33 ****************************************************************************/ 34 35/* 36** lib_printw.c 37** 38** The routines printw(), wprintw() and friends. 39** 40*/ 41 42#include <curses.priv.h> 43 44MODULE_ID("$From: lib_printw.c,v 1.9 2000/12/10 02:43:27 tom Exp $") 45 46NCURSES_EXPORT(int) 47printw(NCURSES_CONST char *fmt,...) 48{ 49 va_list argp; 50 int code; 51 52 T(("printw(%s,...) called", _nc_visbuf(fmt))); 53 54 va_start(argp, fmt); 55 code = vwprintw(stdscr, fmt, argp); 56 va_end(argp); 57 58 return code; 59} 60 61NCURSES_EXPORT(int) 62wprintw(WINDOW *win, NCURSES_CONST char *fmt,...) 63{ 64 va_list argp; 65 int code; 66 67 T(("wprintw(%p,%s,...) called", win, _nc_visbuf(fmt))); 68 69 va_start(argp, fmt); 70 code = vwprintw(win, fmt, argp); 71 va_end(argp); 72 73 return code; 74} 75 76NCURSES_EXPORT(int) 77mvprintw(int y, int x, NCURSES_CONST char *fmt,...) 78{ 79 va_list argp; 80 int code = move(y, x); 81 82 if (code != ERR) { 83 va_start(argp, fmt); 84 code = vwprintw(stdscr, fmt, argp); 85 va_end(argp); 86 } 87 return code; 88} 89 90NCURSES_EXPORT(int) 91mvwprintw 92(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...) 93{ 94 va_list argp; 95 int code = wmove(win, y, x); 96 97 if (code != ERR) { 98 va_start(argp, fmt); 99 code = vwprintw(win, fmt, argp); 100 va_end(argp); 101 } 102 return code; 103} 104 105NCURSES_EXPORT(int) 106vwprintw 107(WINDOW *win, NCURSES_CONST char *fmt, va_list argp) 108{ 109 char *buf = _nc_printf_string(fmt, argp); 110 int code = ERR; 111 112 if (buf != 0) { 113 code = waddstr(win, buf); 114#if USE_SAFE_SPRINTF 115 free(buf); 116#endif 117 } 118 return code; 119} 120