1 /****************************************************************************
2 * Copyright (c) 1998-2006,2007 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.68 2007/06/30 17:53:09 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
312 #define attr_t chtype
317 #if !USE_WIDEC_SUPPORT
318 #define NCURSES_CH_T chtype
320 #define NCURSES_CH_T cchar_t
323 #ifndef NCURSES_OPAQUE
324 #define NCURSES_OPAQUE 0
332 #define CTRL(x) ((x) & 0x1f)
335 #define QUIT CTRL('Q')
336 #define ESCAPE CTRL('[')
339 #define KEY_MIN 256 /* not defined in Solaris 8 */
343 * Workaround for HPUX
345 #if defined(__hpux) && !defined(NCURSES_VERSION)
346 #define getbegx(w) __getbegx(w)
347 #define getbegy(w) __getbegy(w)
348 #define getcurx(w) __getcurx(w)
349 #define getcury(w) __getcury(w)
350 #define getmaxx(w) __getmaxx(w)
351 #define getmaxy(w) __getmaxy(w)
352 #define getparx(w) __getparx(w)
353 #define getpary(w) __getpary(w)
357 * These usually are implemented as macros, but may be functions.
359 #if !defined(getcurx) && !HAVE_GETCURX
360 #define getcurx(win) ((win)?(win)->_curx:ERR)
361 #define getcury(win) ((win)?(win)->_cury:ERR)
364 #if !defined(getbegx) && !HAVE_GETBEGX
365 #define getbegx(win) ((win)?(win)->_begx:ERR)
366 #define getbegy(win) ((win)?(win)->_begy:ERR)
369 #if !defined(getmaxx) && !HAVE_GETMAXX
370 #define getmaxx(win) ((win)?((win)->_maxx + 1):ERR)
371 #define getmaxy(win) ((win)?((win)->_maxy + 1):ERR)
374 #if !defined(mvwvline) && !HAVE_MVWVLINE
375 #define mvwvline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : wvline(w,ch,n))
376 #define mvwhline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : whline(w,ch,n))
379 #if !defined(mvvline) && !HAVE_MVVLINE
380 #define mvvline(y,x,ch,n) (move(y,x) == ERR ? ERR : vline(ch,n))
381 #define mvhline(y,x,ch,n) (move(y,x) == ERR ? ERR : hline(ch,n))
385 * Try to accommodate curses implementations that have no terminfo support.
388 #define TIGETNUM(ti,tc) tigetnum(ti)
390 #define TIGETNUM(ti,tc) tgetnum(tc)
394 #define TIGETSTR(ti,tc) tigetstr(ti)
396 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
399 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
400 * (which is incompatible with legacy usage, doesn't solve any problems).
402 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
403 #define tparm2(a,b) tparm(a,b,0,0,0,0,0,0,0,0)
405 #define UChar(c) ((unsigned char)(c))
407 #define SIZEOF(table) (sizeof(table)/sizeof(table[0]))
409 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
410 #include <nc_alloc.h>
411 #if HAVE_NC_FREEALL && defined(USE_TINFO)
413 #define ExitProgram(code) _nc_free_tinfo(code)
416 #define typeMalloc(type,n) (type *) malloc((n) * sizeof(type))
417 #define typeRealloc(type,n,p) (type *) realloc(p, (n) * sizeof(type))
421 #define ExitProgram(code) exit(code)
425 #define EXIT_SUCCESS 0
428 #define EXIT_FAILURE 1
431 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
432 * curses which doesn't have const parameters declared (so far) in the places
435 #ifndef NCURSES_CONST
436 #define NCURSES_CONST /* nothing */
439 /* out-of-band values for representing absent capabilities */
440 #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
441 #define ABSENT_NUMERIC (-1)
442 #define ABSENT_STRING (char *)0
444 /* out-of-band values for representing cancels */
445 #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
446 #define CANCELLED_NUMERIC (-2)
447 #define CANCELLED_STRING (char *)(-1)
449 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
450 #define VALID_NUMERIC(s) ((s) >= 0)
451 #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
453 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
455 #define CATCHALL(handler) { \
457 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
458 if (nsig != SIGKILL) \
459 signal(nsig, handler); \
462 #endif /* __TEST_PRIV_H */