1 | /*
|
---|
2 | * Copyright (c) 1981 Regents of the University of California.
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | * 1. Redistributions of source code must retain the above copyright
|
---|
9 | * notice, this list of conditions and the following disclaimer.
|
---|
10 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer in the
|
---|
12 | * documentation and/or other materials provided with the distribution.
|
---|
13 | * 3. All advertising materials mentioning features or use of this software
|
---|
14 | * must display the following acknowledgement:
|
---|
15 | * This product includes software developed by the University of
|
---|
16 | * California, Berkeley and its contributors.
|
---|
17 | * 4. Neither the name of the University nor the names of its contributors
|
---|
18 | * may be used to endorse or promote products derived from this software
|
---|
19 | * without specific prior written permission.
|
---|
20 | *
|
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
31 | * SUCH DAMAGE.
|
---|
32 | */
|
---|
33 |
|
---|
34 | #ifndef lint
|
---|
35 | static char sccsid[] = "@(#)printw.c 5.8 (Berkeley) 4/15/91";
|
---|
36 | #endif /* not lint */
|
---|
37 |
|
---|
38 | /*
|
---|
39 | * printw and friends.
|
---|
40 | *
|
---|
41 | * These routines make nonportable assumptions about varargs if __STDC__
|
---|
42 | * is not in effect.
|
---|
43 | */
|
---|
44 |
|
---|
45 | #if __STDC__
|
---|
46 | #include <stdarg.h>
|
---|
47 | #else
|
---|
48 | #include <varargs.h>
|
---|
49 | #endif
|
---|
50 | #include "curses.ext"
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * This routine implements a printf on the standard screen.
|
---|
54 | */
|
---|
55 | #if __STDC__
|
---|
56 | printw(const char *fmt, ...)
|
---|
57 | #else
|
---|
58 | printw(fmt, va_alist)
|
---|
59 | char *fmt;
|
---|
60 | va_dcl
|
---|
61 | #endif
|
---|
62 | {
|
---|
63 | va_list ap;
|
---|
64 | int ret;
|
---|
65 |
|
---|
66 | #if __STDC__
|
---|
67 | va_start(ap, fmt);
|
---|
68 | #else
|
---|
69 | va_start(ap);
|
---|
70 | #endif
|
---|
71 | ret = _sprintw(stdscr, fmt, ap);
|
---|
72 | va_end(ap);
|
---|
73 | return (ret);
|
---|
74 | }
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * This routine implements a printf on the given window.
|
---|
78 | */
|
---|
79 | #if __STDC__
|
---|
80 | wprintw(WINDOW *win, const char *fmt, ...)
|
---|
81 | #else
|
---|
82 | wprintw(win, fmt, va_alist)
|
---|
83 | WINDOW *win;
|
---|
84 | char *fmt;
|
---|
85 | va_dcl
|
---|
86 | #endif
|
---|
87 | {
|
---|
88 | va_list ap;
|
---|
89 | int ret;
|
---|
90 |
|
---|
91 | #ifdef __STDC__
|
---|
92 | va_start(ap, fmt);
|
---|
93 | #else
|
---|
94 | va_start(ap);
|
---|
95 | #endif
|
---|
96 | ret = _sprintw(win, fmt, ap);
|
---|
97 | va_end(ap);
|
---|
98 | return (ret);
|
---|
99 | }
|
---|
100 |
|
---|
101 | /*
|
---|
102 | * This routine actually executes the printf and adds it to the window.
|
---|
103 | * It must not be declared static as it is used in mvprintw.c.
|
---|
104 | * THIS SHOULD BE RENAMED vwprintw AND EXPORTED
|
---|
105 | */
|
---|
106 | _sprintw(win, fmt, ap)
|
---|
107 | WINDOW *win;
|
---|
108 | #if __STDC__
|
---|
109 | const char *fmt;
|
---|
110 | #else
|
---|
111 | char *fmt;
|
---|
112 | #endif
|
---|
113 | va_list ap;
|
---|
114 | {
|
---|
115 | char buffer[BUFSIZ];
|
---|
116 | register int l, c;
|
---|
117 |
|
---|
118 | (void) vsprintf(buffer, fmt, ap);
|
---|
119 | l = strlen(buffer);
|
---|
120 |
|
---|
121 | for ( c = 0; c < l; c++ ) {
|
---|
122 | if (waddch(win, buffer[c]) == ERR)
|
---|
123 | return (-1);
|
---|
124 | }
|
---|
125 |
|
---|
126 | return OK;
|
---|
127 | }
|
---|