lib_printw.c revision 50276
150276Speter/****************************************************************************
250276Speter * Copyright (c) 1998 Free Software Foundation, Inc.                        *
350276Speter *                                                                          *
450276Speter * Permission is hereby granted, free of charge, to any person obtaining a  *
550276Speter * copy of this software and associated documentation files (the            *
650276Speter * "Software"), to deal in the Software without restriction, including      *
750276Speter * without limitation the rights to use, copy, modify, merge, publish,      *
850276Speter * distribute, distribute with modifications, sublicense, and/or sell       *
950276Speter * copies of the Software, and to permit persons to whom the Software is    *
1050276Speter * furnished to do so, subject to the following conditions:                 *
1150276Speter *                                                                          *
1250276Speter * The above copyright notice and this permission notice shall be included  *
1350276Speter * in all copies or substantial portions of the Software.                   *
1450276Speter *                                                                          *
1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
2250276Speter *                                                                          *
2350276Speter * Except as contained in this notice, the name(s) of the above copyright   *
2450276Speter * holders shall not be used in advertising or otherwise to promote the     *
2550276Speter * sale, use or other dealings in this Software without prior written       *
2650276Speter * authorization.                                                           *
2750276Speter ****************************************************************************/
2850276Speter
2950276Speter/****************************************************************************
3050276Speter *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
3150276Speter ****************************************************************************/
3250276Speter
3350276Speter/*
3450276Speter**	lib_printw.c
3550276Speter**
3650276Speter**	The routines printw(), wprintw() and friends.
3750276Speter**
3850276Speter*/
3950276Speter
4050276Speter#include <curses.priv.h>
4150276Speter
4250276SpeterMODULE_ID("$Id: lib_printw.c,v 1.7 1998/04/11 22:53:44 tom Exp $")
4350276Speter
4450276Speterint printw(NCURSES_CONST char *fmt, ...)
4550276Speter{
4650276Speter	va_list argp;
4750276Speter	int code;
4850276Speter
4950276Speter	T(("printw(%s,...) called", _nc_visbuf(fmt)));
5050276Speter
5150276Speter	va_start(argp, fmt);
5250276Speter	code = vwprintw(stdscr, fmt, argp);
5350276Speter	va_end(argp);
5450276Speter
5550276Speter	return code;
5650276Speter}
5750276Speter
5850276Speterint wprintw(WINDOW *win, NCURSES_CONST char *fmt, ...)
5950276Speter{
6050276Speter	va_list argp;
6150276Speter	int code;
6250276Speter
6350276Speter	T(("wprintw(%p,%s,...) called", win, _nc_visbuf(fmt)));
6450276Speter
6550276Speter	va_start(argp, fmt);
6650276Speter	code = vwprintw(win, fmt, argp);
6750276Speter	va_end(argp);
6850276Speter
6950276Speter	return code;
7050276Speter}
7150276Speter
7250276Speterint mvprintw(int y, int x, NCURSES_CONST char *fmt, ...)
7350276Speter{
7450276Speter	va_list argp;
7550276Speter	int code = move(y, x);
7650276Speter
7750276Speter	if (code != ERR) {
7850276Speter		va_start(argp, fmt);
7950276Speter		code = vwprintw(stdscr, fmt, argp);
8050276Speter		va_end(argp);
8150276Speter	}
8250276Speter	return code;
8350276Speter}
8450276Speter
8550276Speterint mvwprintw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt, ...)
8650276Speter{
8750276Speter	va_list argp;
8850276Speter	int code = wmove(win, y, x);
8950276Speter
9050276Speter	if (code != ERR) {
9150276Speter		va_start(argp, fmt);
9250276Speter		code = vwprintw(win, fmt, argp);
9350276Speter		va_end(argp);
9450276Speter	}
9550276Speter	return code;
9650276Speter}
9750276Speter
9850276Speterint vwprintw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
9950276Speter{
10050276Speter	char *buf = _nc_printf_string(fmt, argp);
10150276Speter	int code = ERR;
10250276Speter
10350276Speter	if (buf != 0) {
10450276Speter		code = waddstr(win, buf);
10550276Speter#if USE_SAFE_SPRINTF
10650276Speter		free(buf);
10750276Speter#endif
10850276Speter	}
10950276Speter	return code;
11050276Speter}
111