lib_printw.c revision 76726
1/****************************************************************************
2 * Copyright (c) 1998,2000 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 <dickey@clark.net> 1997                        *
31 ****************************************************************************/
32
33/*
34**	lib_printw.c
35**
36**	The routines printw(), wprintw() and friends.
37**
38*/
39
40#include <curses.priv.h>
41
42MODULE_ID("$Id: lib_printw.c,v 1.9 2000/12/10 02:43:27 tom Exp $")
43
44NCURSES_EXPORT(int)
45printw(NCURSES_CONST char *fmt,...)
46{
47    va_list argp;
48    int code;
49
50    T(("printw(%s,...) called", _nc_visbuf(fmt)));
51
52    va_start(argp, fmt);
53    code = vwprintw(stdscr, fmt, argp);
54    va_end(argp);
55
56    return code;
57}
58
59NCURSES_EXPORT(int)
60wprintw(WINDOW *win, NCURSES_CONST char *fmt,...)
61{
62    va_list argp;
63    int code;
64
65    T(("wprintw(%p,%s,...) called", win, _nc_visbuf(fmt)));
66
67    va_start(argp, fmt);
68    code = vwprintw(win, fmt, argp);
69    va_end(argp);
70
71    return code;
72}
73
74NCURSES_EXPORT(int)
75mvprintw(int y, int x, NCURSES_CONST char *fmt,...)
76{
77    va_list argp;
78    int code = move(y, x);
79
80    if (code != ERR) {
81	va_start(argp, fmt);
82	code = vwprintw(stdscr, fmt, argp);
83	va_end(argp);
84    }
85    return code;
86}
87
88NCURSES_EXPORT(int)
89mvwprintw
90(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...)
91{
92    va_list argp;
93    int code = wmove(win, y, x);
94
95    if (code != ERR) {
96	va_start(argp, fmt);
97	code = vwprintw(win, fmt, argp);
98	va_end(argp);
99    }
100    return code;
101}
102
103NCURSES_EXPORT(int)
104vwprintw
105(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
106{
107    char *buf = _nc_printf_string(fmt, argp);
108    int code = ERR;
109
110    if (buf != 0) {
111	code = waddstr(win, buf);
112#if USE_SAFE_SPRINTF
113	free(buf);
114#endif
115    }
116    return code;
117}
118