1 /****************************************************************************
2 * Copyright (c) 1998-2007,2008 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.76 2008/03/29 20:29:10 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
66 #ifndef HAVE_COLOR_SET
67 #define HAVE_COLOR_SET 0
79 #define HAVE_GETBEGX 0
83 #define HAVE_GETCURX 0
87 #define HAVE_GETMAXX 0
91 #define HAVE_GETOPT_H 0
95 #define HAVE_GETPARX 0
103 #define HAVE_LIBFORM 0
107 #define HAVE_LIBMENU 0
110 #ifndef HAVE_LIBPANEL
111 #define HAVE_LIBPANEL 0
114 #ifndef HAVE_LOCALE_H
115 #define HAVE_LOCALE_H 0
119 #define HAVE_MENU_H 0
123 #define HAVE_MVVLINE 0
126 #ifndef HAVE_MVWVLINE
127 #define HAVE_MVWVLINE 0
134 #ifndef HAVE_NC_ALLOC_H
135 #define HAVE_NC_ALLOC_H 0
139 #define HAVE_PANEL_H 0
143 #define HAVE_PUTWIN 0
146 #ifndef HAVE_RESIZE_TERM
147 #define HAVE_RESIZE_TERM 0
150 #ifndef HAVE_RIPOFFLINE
151 #define HAVE_RIPOFFLINE 0
154 #ifndef HAVE_SETUPTERM
155 #define HAVE_SETUPTERM 0
158 #ifndef HAVE_SLK_COLOR
159 #define HAVE_SLK_COLOR 0
162 #ifndef HAVE_SLK_INIT
163 #define HAVE_SLK_INIT 0
166 #ifndef HAVE_TERMATTRS
167 #define HAVE_TERMATTRS 0
170 #ifndef HAVE_TERMNAME
171 #define HAVE_TERMNAME 0
175 #define HAVE_TGETENT 0
178 #ifndef HAVE_TIGETNUM
179 #define HAVE_TIGETNUM 0
182 #ifndef HAVE_TYPEAHEAD
183 #define HAVE_TYPEAHEAD 0
186 #ifndef HAVE_TIGETSTR
187 #define HAVE_TIGETSTR 0
191 #define HAVE_WINSSTR 0
194 #ifndef HAVE_USE_DEFAULT_COLORS
195 #define HAVE_USE_DEFAULT_COLORS 0
199 #define HAVE_WRESIZE 0
202 #ifndef NCURSES_EXT_FUNCS
203 #define NCURSES_EXT_FUNCS 0
207 #define NEED_PTEM_H 0
216 #include <sys/types.h>
222 #include <signal.h> /* include before curses.h to work around glibc bug */
224 #if defined(HAVE_XCURSES)
226 #elif defined(HAVE_NCURSESW_NCURSES_H)
227 #include <ncursesw/curses.h>
228 #elif defined(HAVE_NCURSES_NCURSES_H)
229 #include <ncurses/curses.h>
234 #if defined(HAVE_XCURSES)
235 /* no other headers */
236 #undef HAVE_SETUPTERM /* nonfunctional */
237 #define HAVE_SETUPTERM 0
238 #undef HAVE_TGETENT /* nonfunctional */
239 #define HAVE_TGETENT 0
240 #undef HAVE_TIGETSTR /* nonfunctional */
241 #define HAVE_TIGETSTR 0
242 #elif defined(HAVE_NCURSESW_TERM_H)
243 #include <ncursesw/term.h>
244 #elif defined(HAVE_NCURSES_TERM_H)
245 #include <ncurses/term.h>
246 #elif defined(HAVE_TERM_H)
251 * Not all curses.h implementations include unctrl.h,
252 * Solaris 10 xpg4 for example.
254 #if defined(NCURSES_VERSION) || defined(_XOPEN_CURSES)
255 #if defined(HAVE_NCURSESW_NCURSES_H)
256 #include <ncursesw/unctrl.h>
257 #elif defined(HAVE_NCURSES_NCURSES_H)
258 #include <ncurses/unctrl.h>
267 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
272 #endif /* HAVE_GETOPT_H */
277 #define setlocale(name,string) /* nothing */
284 #define GCC_NORETURN /* nothing */
286 #ifndef GCC_PRINTFLIKE
287 #define GCC_PRINTFLIKE(a,b) /* nothing */
290 #define GCC_UNUSED /* nothing */
294 #define getnstr(s,n) getstr(s)
299 #define USE_SOFTKEYS 1
301 #define USE_SOFTKEYS 0
305 #ifndef USE_WIDEC_SUPPORT
306 #if defined(_XOPEN_SOURCE_EXTENDED) && defined(WACS_ULCORNER)
307 #define USE_WIDEC_SUPPORT 1
309 #define USE_WIDEC_SUPPORT 0
313 #if HAVE_PANEL_H && HAVE_LIBPANEL
314 #define USE_LIBPANEL 1
316 #define USE_LIBPANEL 0
319 #if HAVE_MENU_H && HAVE_LIBMENU
320 #define USE_LIBMENU 1
322 #define USE_LIBMENU 0
325 #if HAVE_FORM_H && HAVE_LIBFORM
326 #define USE_LIBFORM 1
328 #define USE_LIBFORM 0
331 #ifndef HAVE_TYPE_ATTR_T
332 #if !USE_WIDEC_SUPPORT && !defined(attr_t)
333 #define attr_t chtype
338 #if !USE_WIDEC_SUPPORT
339 #define NCURSES_CH_T chtype
341 #define NCURSES_CH_T cchar_t
344 #ifndef NCURSES_OPAQUE
345 #define NCURSES_OPAQUE 0
353 #define CTRL(x) ((x) & 0x1f)
355 #define QUIT CTRL('Q')
356 #define ESCAPE CTRL('[')
359 #define KEY_MIN 256 /* not defined in Solaris 8 */
363 * Workaround for HPUX
365 #if defined(__hpux) && !defined(NCURSES_VERSION)
366 #define getbegx(w) __getbegx(w)
367 #define getbegy(w) __getbegy(w)
368 #define getcurx(w) __getcurx(w)
369 #define getcury(w) __getcury(w)
370 #define getmaxx(w) __getmaxx(w)
371 #define getmaxy(w) __getmaxy(w)
372 #define getparx(w) __getparx(w)
373 #define getpary(w) __getpary(w)
377 * These usually are implemented as macros, but may be functions.
379 #if !defined(getcurx) && !HAVE_GETCURX
380 #define getcurx(win) ((win)?(win)->_curx:ERR)
381 #define getcury(win) ((win)?(win)->_cury:ERR)
384 #if !defined(getbegx) && !HAVE_GETBEGX
385 #define getbegx(win) ((win)?(win)->_begx:ERR)
386 #define getbegy(win) ((win)?(win)->_begy:ERR)
389 #if !defined(getmaxx) && !HAVE_GETMAXX
390 #define getmaxx(win) ((win)?((win)->_maxx + 1):ERR)
391 #define getmaxy(win) ((win)?((win)->_maxy + 1):ERR)
396 #define __m_getparx(w) ((w)->_parent == (WINDOW *) 0 ? -1 \
397 : (w)->_begx - (w)->_parent->_begx)
399 #if !defined(getparx) && !HAVE_GETPARX
401 #define getparx(win) __m_getparx(win)
402 #define getpary(win) __m_getpary(win)
404 #define getparx(win) ((win)?((win)->_parx + 1):ERR)
405 #define getpary(win) ((win)?((win)->_pary + 1):ERR)
409 #if !defined(mvwvline) && !HAVE_MVWVLINE
410 #define mvwvline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : wvline(w,ch,n))
411 #define mvwhline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : whline(w,ch,n))
414 #if !defined(mvvline) && !HAVE_MVVLINE
415 #define mvvline(y,x,ch,n) (move(y,x) == ERR ? ERR : vline(ch,n))
416 #define mvhline(y,x,ch,n) (move(y,x) == ERR ? ERR : hline(ch,n))
420 * Try to accommodate curses implementations that have no terminfo support.
423 #define TIGETNUM(ti,tc) tigetnum(ti)
425 #define TIGETNUM(ti,tc) tgetnum(tc)
429 #define TIGETSTR(ti,tc) tigetstr(ti)
431 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
434 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
435 * (which is incompatible with legacy usage, doesn't solve any problems).
437 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
438 #define tparm2(a,b) tparm(a,b,0,0,0,0,0,0,0,0)
440 #define UChar(c) ((unsigned char)(c))
442 #define SIZEOF(table) (sizeof(table)/sizeof(table[0]))
444 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
445 #include <nc_alloc.h>
446 #if HAVE_NC_FREEALL && defined(USE_TINFO)
448 #define ExitProgram(code) _nc_free_tinfo(code)
451 #define typeMalloc(type,n) (type *) malloc((n) * sizeof(type))
452 #define typeRealloc(type,n,p) (type *) realloc(p, (n) * sizeof(type))
456 #define ExitProgram(code) exit(code)
460 #define EXIT_SUCCESS 0
463 #define EXIT_FAILURE 1
466 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
467 * curses which doesn't have const parameters declared (so far) in the places
470 #ifndef NCURSES_CONST
471 #define NCURSES_CONST /* nothing */
474 /* out-of-band values for representing absent capabilities */
475 #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
476 #define ABSENT_NUMERIC (-1)
477 #define ABSENT_STRING (char *)0
479 /* out-of-band values for representing cancels */
480 #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
481 #define CANCELLED_NUMERIC (-2)
482 #define CANCELLED_STRING (char *)(-1)
484 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
485 #define VALID_NUMERIC(s) ((s) >= 0)
486 #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
488 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
490 #define CATCHALL(handler) { \
492 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
493 if (nsig != SIGKILL) \
494 signal(nsig, handler); \
498 * Workaround for clean(er) compile with Solaris's legacy curses.
499 * The same would be needed for HPUX 10.20
502 #if defined(sun) && !defined(_XOPEN_CURSES) && !defined(NCURSES_VERSION_PATCH)
503 #define TPUTS_ARG char
504 extern char *tgoto(char *, int, int); /* available, but not prototyped */
506 #define TPUTS_ARG int
511 * Workarounds for Solaris's X/Open curses
513 #if defined(sun) && defined(_XOPEN_CURSES) && !defined(NCURSES_VERSION_PATCH)
514 #if !defined(KEY_MIN) && defined(__KEY_MIN)
515 #define KEY_MIN __KEY_MIN
517 #if !defined(KEY_MAX) && defined(__KEY_MIN)
518 #define KEY_MAX __KEY_MAX
523 * ncurses uses const in some places where X/Open does (or did) not allow.
525 #ifdef NCURSES_VERSION
526 #define CONST_MENUS const
528 #define CONST_MENUS /* nothing */
531 #ifndef HAVE_USE_WINDOW
532 #if !defined(NCURSES_VERSION_PATCH) || (NCURSES_VERSION_PATCH < 20070915) || !NCURSES_EXT_FUNCS
533 #define HAVE_USE_WINDOW 0
535 #define HAVE_USE_WINDOW 1
540 * Simplify setting up demo of threading with these macros.
544 typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *);
545 typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *);
549 #define USING_WINDOW(w,func) use_window(w, (NCURSES_WINDOW_CB) func, w)
550 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
552 #define USING_WINDOW(w,func) func(w)
553 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
557 #define USING_SCREEN(s,func,data) use_screen(s, (NCURSES_SCREEN_CB) func, data)
558 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
560 #define USING_SCREEN(s,func,data) func(data)
561 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
565 #define Trace(p) _tracef p
568 #define Trace(p) /* nothing */
572 #endif /* __TEST_PRIV_H */