1 /****************************************************************************
2 * Copyright (c) 1998-2016,2017 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.146 2017/08/07 23:29:48 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
45 #define HAVE_LIBFORM 1
49 #define HAVE_LIBMENUW 1
50 #define HAVE_LIBMENU 1
54 #define HAVE_LIBPANELW 1
55 #define HAVE_LIBPANEL 1
59 * Fallback definitions to accommodate broken compilers.
61 #ifndef HAVE_ALLOC_PAIR
62 #define HAVE_ALLOC_PAIR 0
65 #ifndef HAVE_ASSUME_DEFAULT_COLORS
66 #define HAVE_ASSUME_DEFAULT_COLORS 0
69 #ifndef HAVE_BSD_STRING_H
70 #define HAVE_BSD_STRING_H 0
72 #ifndef HAVE_CURSES_VERSION
73 #define HAVE_CURSES_VERSION 0
80 #ifndef HAVE_COLOR_SET
81 #define HAVE_COLOR_SET 0
93 #define HAVE_GETBEGX 0
97 #define HAVE_GETCURX 0
101 #define HAVE_GETMAXX 0
104 #ifndef HAVE_GETOPT_H
105 #define HAVE_GETOPT_H 0
109 #define HAVE_GETPARX 0
113 #define HAVE_GETWIN 0
116 #ifndef HAVE_INIT_EXTENDED_COLOR
117 #define HAVE_INIT_EXTENDED_COLOR 0
121 #define HAVE_LIBFORM 0
125 #define HAVE_LIBMENU 0
128 #ifndef HAVE_LIBPANEL
129 #define HAVE_LIBPANEL 0
132 #ifndef HAVE_LANGINFO_CODESET
133 #define HAVE_LANGINFO_CODESET 0
136 #ifndef HAVE_LOCALE_H
137 #define HAVE_LOCALE_H 0
141 #define HAVE_MATH_H 0
145 #define HAVE_MENU_H 0
149 #define HAVE_MVVLINE 0
152 #ifndef HAVE_MVWVLINE
153 #define HAVE_MVWVLINE 0
160 #ifndef HAVE_NC_ALLOC_H
161 #define HAVE_NC_ALLOC_H 0
165 #define HAVE_PANEL_H 0
169 #define HAVE_PUTWIN 0
172 #ifndef HAVE_RESIZE_TERM
173 #define HAVE_RESIZE_TERM 0
176 #ifndef HAVE_RESTARTTERM
177 #define HAVE_RESTARTTERM 0
180 #ifndef HAVE_RIPOFFLINE
181 #define HAVE_RIPOFFLINE 0
184 #ifndef HAVE_SCR_DUMP
185 #define HAVE_SCR_DUMP 0
188 #ifndef HAVE_SETUPTERM
189 #define HAVE_SETUPTERM 0
192 #ifndef HAVE_SLK_COLOR
193 #define HAVE_SLK_COLOR 0
196 #ifndef HAVE_SLK_INIT
197 #define HAVE_SLK_INIT 0
200 #ifndef HAVE_SYS_IOCTL_H
201 #define HAVE_SYS_IOCTL_H 0
204 #ifndef HAVE_SYS_SELECT_H
205 #define HAVE_SYS_SELECT_H 0
208 #ifndef HAVE_TDESTROY
209 #define HAVE_TDESTROY 0
212 #ifndef HAVE_TERMATTRS
213 #define HAVE_TERMATTRS 0
216 #ifndef HAVE_TERMIOS_H
217 #define HAVE_TERMIOS_H 0
220 #ifndef HAVE_TERMNAME
221 #define HAVE_TERMNAME 0
224 #ifndef HAVE_TERM_ENTRY_H
225 #define HAVE_TERM_ENTRY_H 0
229 #define HAVE_TGETENT 0
232 #ifndef HAVE_TIGETNUM
233 #define HAVE_TIGETNUM 0
236 #ifndef HAVE_TIGETSTR
237 #define HAVE_TIGETSTR 0
240 #ifndef HAVE_TPUTS_SP
241 #define HAVE_TPUTS_SP 0
245 #define HAVE_TSEARCH 0
248 #ifndef HAVE_TYPEAHEAD
249 #define HAVE_TYPEAHEAD 0
253 #define HAVE_WINSSTR 0
256 #ifndef HAVE_USE_DEFAULT_COLORS
257 #define HAVE_USE_DEFAULT_COLORS 0
261 #define HAVE_USE_ENV 0
264 #ifndef HAVE_USE_EXTENDED_NAMES
265 #define HAVE_USE_EXTENDED_NAMES 0
268 #ifndef HAVE_USE_SCREEN
269 #define HAVE_USE_SCREEN 0
272 #ifndef HAVE_USE_WINDOW
273 #define HAVE_USE_WINDOW 0
277 #define HAVE_VIDPUTS 0
280 #ifndef HAVE_VID_PUTS
281 #define HAVE_VID_PUTS 0
285 #define HAVE_WRESIZE 0
289 #define HAVE__TRACEF 0
292 #ifndef NCURSES_EXT_FUNCS
293 #define NCURSES_EXT_FUNCS 0
297 #define NEED_PTEM_H 0
301 #define NEED_WCHAR_H 0
309 * Workaround for HPUX
311 #if defined(__hpux) && !defined(NCURSES_VERSION)
312 #define _ACS_COMPAT_CODE /* needed for acs_map vs __acs_map */
318 #include <sys/types.h>
325 #include <signal.h> /* include before curses.h to work around glibc bug */
329 #ifdef HAVE_LIBUTF8_H
334 #if defined(HAVE_XCURSES)
336 #elif defined(HAVE_NCURSESW_NCURSES_H)
337 #include <ncursesw/curses.h>
338 #elif defined(HAVE_NCURSES_NCURSES_H)
339 #include <ncurses/curses.h>
344 #if defined(HAVE_XCURSES) || defined(PDCURSES)
345 /* no other headers */
346 #undef HAVE_SETUPTERM /* nonfunctional */
347 #define HAVE_SETUPTERM 0
348 #undef HAVE_TGETENT /* nonfunctional */
349 #define HAVE_TGETENT 0
350 #undef HAVE_TIGETSTR /* nonfunctional */
351 #define HAVE_TIGETSTR 0
352 #elif defined(HAVE_NCURSESW_TERM_H)
353 #include <ncursesw/term.h>
354 #elif defined(HAVE_NCURSES_TERM_H)
355 #include <ncurses/term.h>
356 #elif defined(HAVE_TERM_H)
361 * Not all curses.h implementations include unctrl.h,
363 #if defined(HAVE_NCURSESW_UNCTRL_H)
364 #include <ncursesw/unctrl.h>
365 #elif defined(HAVE_NCURSES_UNCTRL_H)
366 #include <ncurses/unctrl.h>
367 #elif defined(HAVE_UNCTRL_H)
373 #elif !defined(HAVE_GETOPT_HEADER)
374 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
379 #endif /* HAVE_GETOPT_H */
384 #define setlocale(name,string) /* nothing */
391 #define GCC_NORETURN /* nothing */
393 #ifndef GCC_PRINTFLIKE
394 #define GCC_PRINTFLIKE(a,b) /* nothing */
397 #define GCC_UNUSED /* nothing */
401 #define getnstr(s,n) getstr(s)
406 #define USE_SOFTKEYS 1
408 #define USE_SOFTKEYS 0
413 #define slk_init() /* nothing */
414 #define slk_restore() /* nothing */
415 #define slk_clear() /* nothing */
418 #ifndef HAVE_WSYNCDOWN
419 #define wsyncdown(win) /* nothing */
422 #ifndef USE_WIDEC_SUPPORT
423 #if (defined(_XOPEN_SOURCE_EXTENDED) \
424 || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) \
425 || (defined(NCURSES_WIDECHAR) && (NCURSES_WIDECHAR - 0 < 1))) \
426 && defined(WACS_ULCORNER)
427 #define USE_WIDEC_SUPPORT 1
429 #define USE_WIDEC_SUPPORT 0
433 #if HAVE_PANEL_H && HAVE_LIBPANEL
434 #define USE_LIBPANEL 1
436 #define USE_LIBPANEL 0
439 #if HAVE_MENU_H && HAVE_LIBMENU
440 #define USE_LIBMENU 1
442 #define USE_LIBMENU 0
445 #if HAVE_FORM_H && HAVE_LIBFORM
446 #define USE_LIBFORM 1
448 #define USE_LIBFORM 0
451 /* workaround, to build against NetBSD's variant of the form library */
452 #ifdef HAVE_NETBSD_FORM_H
453 #define form_getyx(form, y, x) y = current_field(form)->cursor_ypos, x = current_field(form)->cursor_xpos
455 #define form_getyx(form, y, x) y = (form)->currow, x = (form)->curcol
458 /* workaround, to build against NetBSD's variant of the form library */
459 #ifdef HAVE_NETBSD_MENU_H
460 #define menu_itemwidth(menu) (menu)->max_item_width
462 #define menu_itemwidth(menu) (menu)->itemlen
465 #ifndef HAVE_TYPE_ATTR_T
466 #if !USE_WIDEC_SUPPORT && !defined(attr_t)
467 #define attr_t chtype
472 #if !USE_WIDEC_SUPPORT
473 #define NCURSES_CH_T chtype
475 #define NCURSES_CH_T cchar_t
478 #ifndef NCURSES_COLOR_T
479 #define NCURSES_COLOR_T short
482 #ifndef NCURSES_PAIRS_T
483 #define NCURSES_PAIRS_T short
490 #if defined(NCURSES_VERSION) && defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
491 #define CURSES_WACS_SYMBOLS
494 #if defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
495 /* NetBSD 5.1 defines these incorrectly */
529 #define WACS_RARROW &(CURSES_WACS_ARRAY['+'])
530 #define WACS_LARROW &(CURSES_WACS_ARRAY[','])
531 #define WACS_UARROW &(CURSES_WACS_ARRAY['-'])
532 #define WACS_DARROW &(CURSES_WACS_ARRAY['.'])
533 #define WACS_BLOCK &(CURSES_WACS_ARRAY['0'])
534 #define WACS_DIAMOND &(CURSES_WACS_ARRAY['`'])
535 #define WACS_CKBOARD &(CURSES_WACS_ARRAY['a'])
536 #define WACS_DEGREE &(CURSES_WACS_ARRAY['f'])
537 #define WACS_PLMINUS &(CURSES_WACS_ARRAY['g'])
538 #define WACS_BOARD &(CURSES_WACS_ARRAY['h'])
539 #define WACS_LANTERN &(CURSES_WACS_ARRAY['i'])
540 #define WACS_LRCORNER &(CURSES_WACS_ARRAY['j'])
541 #define WACS_URCORNER &(CURSES_WACS_ARRAY['k'])
542 #define WACS_ULCORNER &(CURSES_WACS_ARRAY['l'])
543 #define WACS_LLCORNER &(CURSES_WACS_ARRAY['m'])
544 #define WACS_PLUS &(CURSES_WACS_ARRAY['n'])
545 #define WACS_HLINE &(CURSES_WACS_ARRAY['q'])
546 #define WACS_S1 &(CURSES_WACS_ARRAY['o'])
547 #define WACS_S9 &(CURSES_WACS_ARRAY['s'])
548 #define WACS_LTEE &(CURSES_WACS_ARRAY['t'])
549 #define WACS_RTEE &(CURSES_WACS_ARRAY['u'])
550 #define WACS_BTEE &(CURSES_WACS_ARRAY['v'])
551 #define WACS_TTEE &(CURSES_WACS_ARRAY['w'])
552 #define WACS_VLINE &(CURSES_WACS_ARRAY['x'])
553 #define WACS_BULLET &(CURSES_WACS_ARRAY['~'])
554 #define WACS_S3 &(CURSES_WACS_ARRAY['p'])
555 #define WACS_S7 &(CURSES_WACS_ARRAY['r'])
556 #define WACS_LEQUAL &(CURSES_WACS_ARRAY['y'])
557 #define WACS_GEQUAL &(CURSES_WACS_ARRAY['z'])
558 #define WACS_PI &(CURSES_WACS_ARRAY['{'])
559 #define WACS_NEQUAL &(CURSES_WACS_ARRAY['|'])
560 #define WACS_STERLING &(CURSES_WACS_ARRAY['}'])
564 #define CTRL(x) ((x) & 0x1f)
566 #define QUIT CTRL('Q')
567 #define ESCAPE CTRL('[')
570 #define KEY_MIN 256 /* not defined in Solaris 8 */
573 #define HELP_KEY_1 '?'
574 #define HELP_KEY_2 KEY_F(1)
576 /* from nc_string.h, to make this stand alone */
577 #if HAVE_BSD_STRING_H
578 #include <bsd/string.h>
582 #define NCURSES_VOID /* nothing */
584 #define NCURSES_VOID (void)
588 #define HAVE_STRLCAT 0
592 #define HAVE_STRLCPY 0
595 #ifndef HAVE_SNPRINTF
596 #define HAVE_SNPRINTF 0
599 #ifndef USE_STRING_HACKS
600 #define USE_STRING_HACKS 0
603 #if USE_STRING_HACKS && HAVE_STRLCAT
604 #define _nc_STRCAT(d,s,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n))
605 #define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m))
607 #define _nc_STRCAT(d,s,n) NCURSES_VOID strcat((d),(s))
608 #define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strncat((d),(s),(n))
611 #if USE_STRING_HACKS && HAVE_STRLCPY
612 #define _nc_STRCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
613 #define _nc_STRNCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
615 #define _nc_STRCPY(d,s,n) NCURSES_VOID strcpy((d),(s))
616 #define _nc_STRNCPY(d,s,n) NCURSES_VOID strncpy((d),(s),(n))
619 #if USE_STRING_HACKS && HAVE_SNPRINTF
620 #define _nc_SPRINTF NCURSES_VOID snprintf
621 #define _nc_SLIMIT(n) NCURSES_CAST(size_t,n),
623 #define _nc_SPRINTF NCURSES_VOID sprintf
624 #define _nc_SLIMIT(n) /* nothing */
627 #ifdef DECL_CURSES_DATA_BOOLNAMES
628 extern char *boolnames[], *boolcodes[], *boolfnames[];
629 extern char *numnames[], *numcodes[], *numfnames[];
630 extern char *strnames[], *strcodes[], *strfnames[];
633 #ifdef DECL_CURSES_DATA_TTYTYPE
634 #define ttytype termname()
637 #define colored_chtype(ch, attr, pair) \
638 ((chtype) (ch) | (chtype) (attr) | (chtype) COLOR_PAIR(pair))
641 * Workaround for HPUX
643 #if defined(__hpux) && !defined(NCURSES_VERSION)
644 #define getbegx(w) __getbegx(w)
645 #define getbegy(w) __getbegy(w)
646 #define getcurx(w) __getcurx(w)
647 #define getcury(w) __getcury(w)
648 #define getmaxx(w) __getmaxx(w)
649 #define getmaxy(w) __getmaxy(w)
650 #define getparx(w) __getparx(w)
651 #define getpary(w) __getpary(w)
655 * Workaround in case getcchar() returns a positive value when the source
656 * string produces only a L'\0'.
658 #define TEST_CCHAR(s, count, then_stmt, else_stmt) \
659 if ((count = getcchar(s, NULL, NULL, NULL, NULL)) > 0) { \
660 wchar_t test_wch[CCHARW_MAX + 2]; \
662 NCURSES_PAIRS_T test_pair; \
664 if (getcchar( s, test_wch, &test_attrs, &test_pair, NULL) == OK \
665 && test_wch[0] != L'\0') { \
674 * These usually are implemented as macros, but may be functions.
676 #if !defined(getcurx) && !HAVE_GETCURX
677 #define getcurx(win) ((win)?(win)->_curx:ERR)
678 #define getcury(win) ((win)?(win)->_cury:ERR)
681 #if !defined(getbegx) && !HAVE_GETBEGX
682 #define getbegx(win) ((win)?(win)->_begx:ERR)
683 #define getbegy(win) ((win)?(win)->_begy:ERR)
686 #if !defined(getmaxx) && !HAVE_GETMAXX
687 #define getmaxx(win) ((win)?((win)->_maxx + 1):ERR)
688 #define getmaxy(win) ((win)?((win)->_maxy + 1):ERR)
693 #define __m_getparx(w) ((w)->_parent == (WINDOW *) 0 ? -1 \
694 : (w)->_begx - (w)->_parent->_begx)
696 #if !defined(getparx) && !HAVE_GETPARX
698 #define getparx(win) __m_getparx(win)
699 #define getpary(win) __m_getpary(win)
701 #define getparx(win) ((win)?((win)->_parx + 1):ERR)
702 #define getpary(win) ((win)?((win)->_pary + 1):ERR)
706 #if !defined(mvwvline) && !HAVE_MVWVLINE
707 #define mvwvline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : wvline(w,ch,n))
708 #define mvwhline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : whline(w,ch,n))
711 #if !defined(mvvline) && !HAVE_MVVLINE
712 #define mvvline(y,x,ch,n) (move(y,x) == ERR ? ERR : vline(ch,n))
713 #define mvhline(y,x,ch,n) (move(y,x) == ERR ? ERR : hline(ch,n))
717 * Try to accommodate curses implementations that have no terminfo support.
720 #define TIGETNUM(ti,tc) tigetnum(ti)
722 #define TIGETNUM(ti,tc) tgetnum(tc)
726 #define TIGETSTR(ti,tc) tigetstr(ti)
728 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
732 * So far (2013 - more than ten years), only ncurses implements
733 * use_extended_names().
735 #if defined(NCURSES_XNAMES)
736 #elif defined(NCURSES_VERSION) && defined(HAVE_TERM_ENTRY_H) && HAVE_TERM_ENTRY_H
737 #define NCURSES_XNAMES 1
739 #define NCURSES_XNAMES 0
742 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
743 * (which is incompatible with legacy usage, doesn't solve any problems).
745 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
746 #define tparm2(a,b) tparm(a,b,0,0,0,0,0,0,0,0)
748 #define UChar(c) ((unsigned char)(c))
750 #define SIZEOF(table) (sizeof(table)/sizeof(table[0]))
752 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
753 #include <nc_alloc.h>
754 #if HAVE_NC_FREEALL && defined(USE_TINFO)
756 #define ExitProgram(code) _nc_free_tinfo(code)
759 #define typeMalloc(type,n) (type *) malloc((size_t)(n) * sizeof(type))
760 #define typeCalloc(type,elts) (type *) calloc((size_t)(elts), sizeof(type))
761 #define typeRealloc(type,n,p) (type *) realloc(p, (size_t)(n) * sizeof(type))
765 #define ExitProgram(code) exit(code)
769 #define EXIT_SUCCESS 0
772 #define EXIT_FAILURE 1
775 #if defined(__MINGW32__) || defined(USE_WIN32CON_DRIVER)
777 #if defined(PDCURSES)
780 # error WINVER must at least be 0x0501
783 # define WINVER 0x0501
786 #include <sys/time.h> /* for struct timeval */
788 #define sleep(n) Sleep((n) * 1000)
791 #define getlogin() "username"
793 #elif defined(HAVE_NCURSESW_NCURSES_H)
794 #include <ncursesw/nc_mingw.h>
795 #elif defined(HAVE_NCURSES_NCURSES_H)
796 #include <ncurses/nc_mingw.h>
798 #include <nc_mingw.h>
801 /* conflicts in test/firstlast.c */
807 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
808 * curses which doesn't have const parameters declared (so far) in the places
811 #ifndef NCURSES_CONST
812 #define NCURSES_CONST /* nothing */
815 /* out-of-band values for representing absent capabilities */
816 #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
817 #define ABSENT_NUMERIC (-1)
818 #define ABSENT_STRING (char *)0
820 /* out-of-band values for representing cancels */
821 #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
822 #define CANCELLED_NUMERIC (-2)
823 #define CANCELLED_STRING (char *)(-1)
825 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
826 #define VALID_NUMERIC(s) ((s) >= 0)
827 #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
829 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
831 #define CATCHALL(handler) { \
833 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
834 if (nsig != SIGKILL) \
835 signal(nsig, handler); \
839 * Workaround for clean(er) compile with Solaris's legacy curses.
840 * The same would be needed for HPUX 10.20
843 #define TPUTS_ARG int
846 #if defined(sun) && !defined(_XOPEN_CURSES) && !defined(NCURSES_VERSION_PATCH)
848 #define TPUTS_ARG char
849 extern char *tgoto(char *, int, int); /* available, but not prototyped */
853 #define TPUTS_PROTO(func,value) int func(TPUTS_ARG value)
857 #define TPUTS_RETURN(value) return value
861 * Workarounds for Solaris's X/Open curses
863 #if !defined(KEY_MIN) && defined(__KEY_MIN)
864 #define KEY_MIN __KEY_MIN
866 #if !defined(KEY_MAX) && defined(__KEY_MIN)
867 #define KEY_MAX __KEY_MAX
871 * Workaround to build with Sun's default SVr4 curses.
873 #ifdef NCURSES_VERSION
874 #ifndef HAVE_VW_PRINTW
875 #define HAVE_VW_PRINTW 1
880 * ncurses provides arrays of capability names; X/Open discarded these SVr4
881 * features. Some implementations continue to provide them (see the test
884 #ifdef NCURSES_VERSION
885 #ifndef HAVE_CURSES_DATA_BOOLNAMES
886 #define HAVE_CURSES_DATA_BOOLNAMES 1
891 * ncurses uses const in some places where X/Open does (or did) not allow.
893 #ifdef NCURSES_VERSION
894 #define CONST_MENUS const
896 #define CONST_MENUS /* nothing */
900 * Simplify setting up demo of threading with these macros.
904 #define USING_WINDOW(w,func) use_window(w, (NCURSES_WINDOW_CB) func, w)
905 #define USING_WINDOW2(w,func,data) use_window(w, (NCURSES_WINDOW_CB) func, data)
906 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
908 #define USING_WINDOW(w,func) func(w)
909 #define USING_WINDOW2(w,func,data) func(w,data)
910 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
914 #define USING_SCREEN(s,func,data) use_screen(s, (NCURSES_SCREEN_CB) func, data)
915 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
917 #define USING_SCREEN(s,func,data) func(data)
918 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
921 #if defined(TRACE) && HAVE__TRACEF
922 #define Trace(p) _tracef p
924 #define START_TRACE() \
925 if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
926 int t = _nc_getenv_num("NCURSES_TRACE"); \
928 trace((unsigned) t); \
930 extern unsigned _nc_tracing;
931 extern int _nc_getenv_num(const char *);
934 #define Trace(p) /* nothing */
936 #define START_TRACE() /* nothing */
939 #define Trace2(p) /* nothing */
941 #define AddCh(c) (void) addch((chtype)(c))
942 #define WAddCh(w,c) (void) waddch((w),(chtype)(c))
943 #define MvAddCh(y,x,c) (void) mvaddch((y),(x),(chtype)(c))
944 #define MvWAddCh(w,y,x,c) (void) mvwaddch((w),(y),(x),(chtype)(c))
945 #define MvAddStr(y,x,s) (void) mvaddstr((y),(x),(s))
946 #define MvWAddStr(w,y,x,s) (void) mvwaddstr((w),(y),(x),(s))
947 #define MvWAddChStr(w,y,x,s) (void) mvwaddchstr((w),(y),(x),(s))
948 #define MvPrintw (void) mvprintw
949 #define MvWPrintw (void) mvwprintw
950 #define MvHLine (void) mvhline
951 #define MvWHLine (void) mvwhline
952 #define MvVLine (void) mvvline
953 #define MvWVLine (void) mvwvline
956 * The macro likely uses unsigned values, while X/Open prototype uses int.
958 #if defined(wattrset) || defined(PDCURSES)
959 #define AttrArg(p,a) (attr_t) ((attr_t)(p) | (attr_t)(a))
961 #define AttrArg(p,a) (int) ((attr_t)(p) | (attr_t)(a))
965 * Workaround for defective implementation of gcc attribute warn_unused_result
967 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
968 #define IGNORE_RC(func) errno = func
970 #define IGNORE_RC(func) (void) func
971 #endif /* gcc workarounds */
973 #define init_mb(state) memset(&state, 0, sizeof(state))
975 #endif /* __TEST_PRIV_H */