]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/test.priv.h
85e14a04af05d8c8c00a839a69295284bdfb7d69
[ncurses.git] / test / test.priv.h
1 /****************************************************************************
2  * Copyright (c) 1998-2002,2003 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> 1996                        *
31  ****************************************************************************/
32 /* $Id: test.priv.h,v 1.48 2004/04/10 20:11:37 tom Exp $ */
33
34 #ifndef __TEST_PRIV_H
35 #define __TEST_PRIV_H 1
36
37 #include <ncurses_cfg.h>
38
39 /*
40  * Fix ifdef's that look for the form/menu/panel libraries, if we are building
41  * with wide-character ncurses.
42  */
43 #ifdef  HAVE_LIBFORMW
44 #define HAVE_LIBFORM 1
45 #endif
46
47 #ifdef  HAVE_LIBMENUW
48 #define HAVE_LIBMENU 1
49 #endif
50
51 #ifdef  HAVE_LIBPANELW
52 #define HAVE_LIBPANEL 1
53 #endif
54
55 /*
56  * Fallback definitions to accommodate broken compilers
57  */
58 #ifndef HAVE_CURSES_VERSION
59 #define HAVE_CURSES_VERSION 0
60 #endif
61
62 #ifndef HAVE_FORM_H
63 #define HAVE_FORM_H 0
64 #endif
65
66 #ifndef HAVE_LIBFORM
67 #define HAVE_LIBFORM 0
68 #endif
69
70 #ifndef HAVE_LIBMENU
71 #define HAVE_LIBMENU 0
72 #endif
73
74 #ifndef HAVE_LIBPANEL
75 #define HAVE_LIBPANEL 0
76 #endif
77
78 #ifndef HAVE_LOCALE_H
79 #define HAVE_LOCALE_H 0
80 #endif
81
82 #ifndef HAVE_MENU_H
83 #define HAVE_MENU_H 0
84 #endif
85
86 #ifndef HAVE_NAPMS
87 #define HAVE_NAPMS 1
88 #endif
89
90 #ifndef HAVE_NC_ALLOC_H
91 #define HAVE_NC_ALLOC_H 0
92 #endif
93
94 #ifndef HAVE_PANEL_H
95 #define HAVE_PANEL_H 0
96 #endif
97
98 #ifndef HAVE_SLK_COLOR
99 #define HAVE_SLK_COLOR 0
100 #endif
101
102 #ifndef HAVE_WRESIZE
103 #define HAVE_WRESIZE 0
104 #endif
105
106 #ifndef NCURSES_EXT_FUNCS
107 #define NCURSES_EXT_FUNCS 0
108 #endif
109
110 #ifndef NCURSES_NOMACROS
111 #define NCURSES_NOMACROS 0
112 #endif
113
114 #ifndef NEED_PTEM_H
115 #define NEED_PTEM_H 0
116 #endif
117
118 #include <stdlib.h>
119 #include <string.h>
120 #include <sys/types.h>
121
122 #if HAVE_UNISTD_H
123 #include <unistd.h>
124 #endif
125
126 #include <signal.h>     /* include before curses.h to work around glibc bug */
127
128 #if defined(HAVE_NCURSESW_NCURSES_H)
129 #include <ncursesw/curses.h>
130 #include <ncursesw/term.h>
131 #elif defined(HAVE_NCURSES_NCURSES_H)
132 #include <ncurses/curses.h>
133 #include <ncurses/term.h>
134 #else
135 #include <curses.h>
136 #include <term.h>
137 #endif
138
139 #ifdef NCURSES_VERSION
140 #define HAVE_COLOR_SET 1
141 #endif
142
143 #if NCURSES_NOMACROS
144 #include <nomacros.h>
145 #endif
146
147 #if HAVE_GETOPT_H
148 #include <getopt.h>
149 #else
150 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
151  * doesn't hurt.
152  */
153 extern char *optarg;
154 extern int optind;
155 #endif /* HAVE_GETOPT_H */
156
157 #if HAVE_LOCALE_H
158 #include <locale.h>
159 #else
160 #define setlocale(name,string) /* nothing */
161 #endif
162
163 #include <assert.h>
164 #include <ctype.h>
165
166 #ifndef GCC_NORETURN
167 #define GCC_NORETURN /* nothing */
168 #endif
169 #ifndef GCC_UNUSED
170 #define GCC_UNUSED /* nothing */
171 #endif
172
173 #ifndef HAVE_GETNSTR
174 #define getnstr(s,n) getstr(s)
175 #endif
176
177 #ifndef USE_WIDEC_SUPPORT
178 #if defined(_XOPEN_SOURCE_EXTENDED) && defined(WACS_ULCORNER)
179 #define USE_WIDEC_SUPPORT 1
180 #else
181 #define USE_WIDEC_SUPPORT 0
182 #endif
183 #endif
184
185 #if HAVE_PANEL_H && HAVE_LIBPANEL
186 #define USE_LIBPANEL 1
187 #else
188 #define USE_LIBPANEL 0
189 #endif
190
191 #if HAVE_MENU_H && HAVE_LIBMENU
192 #define USE_LIBMENU 1
193 #else
194 #define USE_LIBMENU 0
195 #endif
196
197 #if HAVE_FORM_H && HAVE_LIBFORM
198 #define USE_LIBFORM 1
199 #else
200 #define USE_LIBFORM 0
201 #endif
202
203 #ifndef HAVE_TYPE_ATTR_T
204 #if !USE_WIDEC_SUPPORT
205 #define attr_t long
206 #endif
207 #endif
208
209 #undef NCURSES_CH_T
210 #if !USE_WIDEC_SUPPORT
211 #define NCURSES_CH_T chtype
212 #else
213 #define NCURSES_CH_T cchar_t
214 #endif
215
216 #ifndef CCHARW_MAX
217 #define CCHARW_MAX 5
218 #endif
219
220 #ifndef CTRL
221 #define CTRL(x)         ((x) & 0x1f)
222 #endif
223
224 #define QUIT            CTRL('Q')
225 #define ESCAPE          CTRL('[')
226
227 #ifndef KEY_MIN
228 #define KEY_MIN 256     /* not defined in Solaris 8 */
229 #endif
230
231 #ifndef getcurx
232 #define getcurx(win)            ((win)?(win)->_curx:ERR)
233 #define getcury(win)            ((win)?(win)->_cury:ERR)
234 #endif
235
236 #ifndef getbegx
237 #define getbegx(win)            ((win)?(win)->_begx:ERR)
238 #define getbegy(win)            ((win)?(win)->_begy:ERR)
239 #endif
240
241 #ifndef getmaxx
242 #define getmaxx(win)            ((win)?((win)->_maxx + 1):ERR)
243 #define getmaxy(win)            ((win)?((win)->_maxy + 1):ERR)
244 #endif
245
246 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
247  * (which is incompatible with legacy usage, doesn't solve any problems).
248  */
249 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
250 #define tparm2(a,b)   tparm(a,b,0,0,0,0,0,0,0,0)
251
252 #define UChar(c)    ((unsigned char)(c))
253
254 #define SIZEOF(table)   (sizeof(table)/sizeof(table[0]))
255
256 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
257 #include <nc_alloc.h>
258 #else
259 #define typeMalloc(type,n) (type *) malloc((n) * sizeof(type))
260 #define typeRealloc(type,n,p) (type *) realloc(p, (n) * sizeof(type))
261 #endif
262
263 #ifndef ExitProgram
264 #define ExitProgram(code) exit(code)
265 #endif
266
267 #ifndef EXIT_SUCCESS
268 #define EXIT_SUCCESS 0
269 #endif
270 #ifndef EXIT_FAILURE
271 #define EXIT_FAILURE 1
272 #endif
273
274 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
275  * curses which doesn't have const parameters declared (so far) in the places
276  * that XSI shows.
277  */
278 #ifndef NCURSES_CONST
279 #define NCURSES_CONST /* nothing */
280 #endif
281
282 /* out-of-band values for representing absent capabilities */
283 #define ABSENT_BOOLEAN          ((signed char)-1)       /* 255 */
284 #define ABSENT_NUMERIC          (-1)
285 #define ABSENT_STRING           (char *)0
286
287 /* out-of-band values for representing cancels */
288 #define CANCELLED_BOOLEAN       ((signed char)-2)       /* 254 */
289 #define CANCELLED_NUMERIC       (-2)
290 #define CANCELLED_STRING        (char *)(-1)
291
292 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
293 #define VALID_NUMERIC(s) ((s) >= 0)
294 #define VALID_STRING(s)  ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
295
296 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
297
298 #endif /* __TEST_PRIV_H */