1 /****************************************************************************
2 * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
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: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
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. *
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 *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Thomas E. Dickey 1996-on *
31 ****************************************************************************/
32 /* $Id: test.priv.h,v 1.63 2006/07/15 18:27:24 tom Exp $ */
35 #define __TEST_PRIV_H 1
37 #include <ncurses_cfg.h>
40 * Fix ifdef's that look for the form/menu/panel libraries, if we are building
41 * with wide-character ncurses.
44 #define HAVE_LIBFORMW 1
48 #define HAVE_LIBMENUW 1
52 #define HAVE_LIBPANELW 1
56 * Fallback definitions to accommodate broken compilers.
58 #ifndef HAVE_CURSES_VERSION
59 #define HAVE_CURSES_VERSION 0
71 #define HAVE_GETBEGX 0
75 #define HAVE_GETCURX 0
79 #define HAVE_GETMAXX 0
83 #define HAVE_GETOPT_H 0
91 #define HAVE_LIBFORM 0
95 #define HAVE_LIBMENU 0
99 #define HAVE_LIBPANEL 0
102 #ifndef HAVE_LOCALE_H
103 #define HAVE_LOCALE_H 0
107 #define HAVE_MENU_H 0
111 #define HAVE_MVVLINE 0
114 #ifndef HAVE_MVWVLINE
115 #define HAVE_MVWVLINE 0
122 #ifndef HAVE_NC_ALLOC_H
123 #define HAVE_NC_ALLOC_H 0
127 #define HAVE_PANEL_H 0
131 #define HAVE_PUTWIN 0
134 #ifndef HAVE_RESIZE_TERM
135 #define HAVE_RESIZE_TERM 0
138 #ifndef HAVE_RIPOFFLINE
139 #define HAVE_RIPOFFLINE 0
142 #ifndef HAVE_SETUPTERM
143 #define HAVE_SETUPTERM 0
146 #ifndef HAVE_SLK_COLOR
147 #define HAVE_SLK_COLOR 0
150 #ifndef HAVE_SLK_INIT
151 #define HAVE_SLK_INIT 0
154 #ifndef HAVE_TERMATTRS
155 #define HAVE_TERMATTRS 0
158 #ifndef HAVE_TERMNAME
159 #define HAVE_TERMNAME 0
163 #define HAVE_TGETENT 0
166 #ifndef HAVE_TIGETNUM
167 #define HAVE_TIGETNUM 0
170 #ifndef HAVE_TYPEAHEAD
171 #define HAVE_TYPEAHEAD 0
174 #ifndef HAVE_TIGETSTR
175 #define HAVE_TIGETSTR 0
179 #define HAVE_WINSSTR 0
182 #ifndef HAVE_USE_DEFAULT_COLORS
183 #define HAVE_USE_DEFAULT_COLORS 0
187 #define HAVE_WRESIZE 0
190 #ifndef NCURSES_EXT_FUNCS
191 #define NCURSES_EXT_FUNCS 0
195 #define NEED_PTEM_H 0
204 #include <sys/types.h>
210 #include <signal.h> /* include before curses.h to work around glibc bug */
212 #if defined(HAVE_XCURSES)
214 #elif defined(HAVE_NCURSESW_NCURSES_H)
215 #include <ncursesw/curses.h>
216 #elif defined(HAVE_NCURSES_NCURSES_H)
217 #include <ncurses/curses.h>
222 #if defined(HAVE_XCURSES)
223 /* no other headers */
224 #undef HAVE_SETUPTERM /* nonfunctional */
225 #define HAVE_SETUPTERM 0
226 #undef HAVE_TGETENT /* nonfunctional */
227 #define HAVE_TGETENT 0
228 #undef HAVE_TIGETSTR /* nonfunctional */
229 #define HAVE_TIGETSTR 0
230 #elif defined(HAVE_NCURSESW_TERM_H)
231 #include <ncursesw/term.h>
232 #elif defined(HAVE_NCURSES_TERM_H)
233 #include <ncurses/term.h>
234 #elif defined(HAVE_TERM_H)
238 #ifdef NCURSES_VERSION
239 #define HAVE_COLOR_SET 1
246 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
251 #endif /* HAVE_GETOPT_H */
256 #define setlocale(name,string) /* nothing */
263 #define GCC_NORETURN /* nothing */
265 #ifndef GCC_PRINTFLIKE
266 #define GCC_PRINTFLIKE(a,b) /* nothing */
269 #define GCC_UNUSED /* nothing */
273 #define getnstr(s,n) getstr(s)
278 #define USE_SOFTKEYS 1
280 #define USE_SOFTKEYS 0
284 #ifndef USE_WIDEC_SUPPORT
285 #if defined(_XOPEN_SOURCE_EXTENDED) && defined(WACS_ULCORNER)
286 #define USE_WIDEC_SUPPORT 1
288 #define USE_WIDEC_SUPPORT 0
292 #if HAVE_PANEL_H && HAVE_LIBPANEL
293 #define USE_LIBPANEL 1
295 #define USE_LIBPANEL 0
298 #if HAVE_MENU_H && HAVE_LIBMENU
299 #define USE_LIBMENU 1
301 #define USE_LIBMENU 0
304 #if HAVE_FORM_H && HAVE_LIBFORM
305 #define USE_LIBFORM 1
307 #define USE_LIBFORM 0
310 #ifndef HAVE_TYPE_ATTR_T
311 #if !USE_WIDEC_SUPPORT
317 #if !USE_WIDEC_SUPPORT
318 #define NCURSES_CH_T chtype
320 #define NCURSES_CH_T cchar_t
328 #define CTRL(x) ((x) & 0x1f)
331 #define QUIT CTRL('Q')
332 #define ESCAPE CTRL('[')
335 #define KEY_MIN 256 /* not defined in Solaris 8 */
339 * Workaround for HPUX
341 #if defined(__hpux) && !defined(NCURSES_VERSION)
342 #define getbegx(w) __getbegx(w)
343 #define getbegy(w) __getbegy(w)
344 #define getcurx(w) __getcurx(w)
345 #define getcury(w) __getcury(w)
346 #define getmaxx(w) __getmaxx(w)
347 #define getmaxy(w) __getmaxy(w)
348 #define getparx(w) __getparx(w)
349 #define getpary(w) __getpary(w)
353 * These usually are implemented as macros, but may be functions.
355 #if !defined(getcurx) && !HAVE_GETCURX
356 #define getcurx(win) ((win)?(win)->_curx:ERR)
357 #define getcury(win) ((win)?(win)->_cury:ERR)
360 #if !defined(getbegx) && !HAVE_GETBEGX
361 #define getbegx(win) ((win)?(win)->_begx:ERR)
362 #define getbegy(win) ((win)?(win)->_begy:ERR)
365 #if !defined(getmaxx) && !HAVE_GETMAXX
366 #define getmaxx(win) ((win)?((win)->_maxx + 1):ERR)
367 #define getmaxy(win) ((win)?((win)->_maxy + 1):ERR)
370 #if !defined(mvwvline) && !HAVE_MVWVLINE
371 #define mvwvline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : wvline(w,ch,n))
372 #define mvwhline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : whline(w,ch,n))
375 #if !defined(mvvline) && !HAVE_MVVLINE
376 #define mvvline(y,x,ch,n) (move(y,x) == ERR ? ERR : vline(ch,n))
377 #define mvhline(y,x,ch,n) (move(y,x) == ERR ? ERR : hline(ch,n))
381 * Try to accommodate curses implementations that have no terminfo support.
384 #define TIGETNUM(ti,tc) tigetnum(ti)
386 #define TIGETNUM(ti,tc) tgetnum(tc)
390 #define TIGETSTR(ti,tc) tigetstr(ti)
392 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
395 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
396 * (which is incompatible with legacy usage, doesn't solve any problems).
398 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
399 #define tparm2(a,b) tparm(a,b,0,0,0,0,0,0,0,0)
401 #define UChar(c) ((unsigned char)(c))
403 #define SIZEOF(table) (sizeof(table)/sizeof(table[0]))
405 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
406 #include <nc_alloc.h>
408 #define typeMalloc(type,n) (type *) malloc((n) * sizeof(type))
409 #define typeRealloc(type,n,p) (type *) realloc(p, (n) * sizeof(type))
413 #define ExitProgram(code) exit(code)
417 #define EXIT_SUCCESS 0
420 #define EXIT_FAILURE 1
423 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
424 * curses which doesn't have const parameters declared (so far) in the places
427 #ifndef NCURSES_CONST
428 #define NCURSES_CONST /* nothing */
431 /* out-of-band values for representing absent capabilities */
432 #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
433 #define ABSENT_NUMERIC (-1)
434 #define ABSENT_STRING (char *)0
436 /* out-of-band values for representing cancels */
437 #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
438 #define CANCELLED_NUMERIC (-2)
439 #define CANCELLED_STRING (char *)(-1)
441 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
442 #define VALID_NUMERIC(s) ((s) >= 0)
443 #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
445 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
447 #define CATCHALL(handler) { \
449 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
450 if (nsig != SIGKILL) \
451 signal(nsig, handler); \
454 #endif /* __TEST_PRIV_H */