1 /****************************************************************************
2 * Copyright 2018-2019,2020 Thomas E. Dickey *
3 * Copyright 1998-2017,2018 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Thomas E. Dickey 1996-on *
32 ****************************************************************************/
33 /* $Id: test.priv.h,v 1.189 2020/08/01 16:55:28 tom Exp $ */
36 #define __TEST_PRIV_H 1
38 #include <ncurses_cfg.h>
41 * Fix ifdef's that look for the form/menu/panel libraries, if we are building
42 * with wide-character ncurses.
45 #define HAVE_LIBFORMW 1
46 #define HAVE_LIBFORM 1
50 #define HAVE_LIBMENUW 1
51 #define HAVE_LIBMENU 1
55 #define HAVE_LIBPANELW 1
56 #define HAVE_LIBPANEL 1
60 * Fallback definitions to accommodate broken compilers.
62 #ifndef HAVE_ALLOC_PAIR
63 #define HAVE_ALLOC_PAIR 0
66 #ifndef HAVE_ASSUME_DEFAULT_COLORS
67 #define HAVE_ASSUME_DEFAULT_COLORS 0
70 #ifndef HAVE_BSD_STRING_H
71 #define HAVE_BSD_STRING_H 0
74 #ifndef HAVE_CURSES_VERSION
75 #define HAVE_CURSES_VERSION 0
86 #ifndef HAVE_COLOR_CONTENT
87 #define HAVE_COLOR_CONTENT 0
91 #define HAVE_COPYWIN 0
94 #ifndef HAVE_COLOR_SET
95 #define HAVE_COLOR_SET 0
98 #ifndef HAVE_DELSCREEN
99 #define HAVE_DELSCREEN 0
103 #define HAVE_DUPWIN 0
107 #define HAVE_FILTER 0
111 #define HAVE_FORM_H 0
115 #define HAVE_GETBEGX 0
119 #define HAVE_GETCURX 0
123 #define HAVE_GETMAXX 0
126 #ifndef HAVE_GETOPT_H
127 #define HAVE_GETOPT_H 0
131 #define HAVE_GETPARX 0
135 #define HAVE_GETWIN 0
138 #ifndef HAVE_HALFDELAY
139 #define HAVE_HALFDELAY 0
142 #ifndef HAVE_INIT_EXTENDED_COLOR
143 #define HAVE_INIT_EXTENDED_COLOR 0
147 #define HAVE_LIBFORM 0
151 #define HAVE_LIBMENU 0
154 #ifndef HAVE_LIBPANEL
155 #define HAVE_LIBPANEL 0
158 #ifndef HAVE_LANGINFO_CODESET
159 #define HAVE_LANGINFO_CODESET 0
162 #ifndef HAVE_LOCALE_H
163 #define HAVE_LOCALE_H 0
167 #define HAVE_MATH_H 0
171 #define HAVE_MENU_H 0
174 #ifndef HAVE_MVDERWIN
175 #define HAVE_MVDERWIN 0
179 #define HAVE_MVVLINE 0
186 #ifndef HAVE_MVWVLINE
187 #define HAVE_MVWVLINE 0
194 #ifndef HAVE_NC_ALLOC_H
195 #define HAVE_NC_ALLOC_H 0
199 #define HAVE_NEWPAD 0
203 #define HAVE_PANEL_H 0
207 #define HAVE_PUTWIN 0
210 #ifndef HAVE_RESET_COLOR_PAIRS
211 #define HAVE_RESET_COLOR_PAIRS 0
214 #ifndef HAVE_RESIZE_TERM
215 #define HAVE_RESIZE_TERM 0
218 #ifndef HAVE_RESTARTTERM
219 #define HAVE_RESTARTTERM 0
222 #ifndef HAVE_RIPOFFLINE
223 #define HAVE_RIPOFFLINE 0
226 #ifndef HAVE_SCR_DUMP
227 #define HAVE_SCR_DUMP 0
230 #ifndef HAVE_SETUPTERM
231 #define HAVE_SETUPTERM 0
234 #ifndef HAVE_SLK_COLOR
235 #define HAVE_SLK_COLOR 0
238 #ifndef HAVE_SLK_INIT
239 #define HAVE_SLK_INIT 0
242 #ifndef HAVE_STDINT_H
243 #define HAVE_STDINT_H 0
247 #define HAVE_STRSTR 0
250 #ifndef HAVE_SYS_IOCTL_H
251 #define HAVE_SYS_IOCTL_H 0
254 #ifndef HAVE_SYS_SELECT_H
255 #define HAVE_SYS_SELECT_H 0
258 #ifndef HAVE_TERMATTRS
259 #define HAVE_TERMATTRS 0
262 #ifndef HAVE_TERMIOS_H
263 #define HAVE_TERMIOS_H 0
266 #ifndef HAVE_TERMNAME
267 #define HAVE_TERMNAME 0
270 #ifndef HAVE_TERM_ENTRY_H
271 #define HAVE_TERM_ENTRY_H 0
275 #define HAVE_TGETENT 0
278 #ifndef HAVE_TIGETNUM
279 #define HAVE_TIGETNUM 0
282 #ifndef HAVE_TIGETSTR
283 #define HAVE_TIGETSTR 0
286 #ifndef HAVE_TPUTS_SP
287 #define HAVE_TPUTS_SP 0
291 #define HAVE_TSEARCH 0
294 #ifndef HAVE_TYPEAHEAD
295 #define HAVE_TYPEAHEAD 0
299 #define HAVE_WINSSTR 0
302 #ifndef HAVE_USE_DEFAULT_COLORS
303 #define HAVE_USE_DEFAULT_COLORS 0
307 #define HAVE_USE_ENV 0
310 #ifndef HAVE_USE_EXTENDED_NAMES
311 #define HAVE_USE_EXTENDED_NAMES 0
314 #ifndef HAVE_USE_SCREEN
315 #define HAVE_USE_SCREEN 0
318 #ifndef HAVE_USE_WINDOW
319 #define HAVE_USE_WINDOW 0
323 #define HAVE_VIDPUTS 0
326 #ifndef HAVE_VID_PUTS
327 #define HAVE_VID_PUTS 0
330 #ifndef HAVE_WINSDELLN
331 #define HAVE_WINSDELLN 0
335 #define HAVE_WRESIZE 0
339 #define HAVE__TRACEF 0
342 #ifndef NCURSES_EXT_FUNCS
343 #define NCURSES_EXT_FUNCS 0
347 #define NEED_PTEM_H 0
351 #define NEED_WCHAR_H 0
359 * Workaround for HPUX
361 #if defined(__hpux) && !defined(NCURSES_VERSION)
362 #define _ACS_COMPAT_CODE /* needed for acs_map vs __acs_map */
368 #include <sys/types.h>
375 #include <signal.h> /* include before curses.h to work around glibc bug */
379 #ifdef HAVE_LIBUTF8_H
384 #if defined(HAVE_XCURSES)
386 #elif defined(HAVE_NCURSESW_NCURSES_H)
387 #include <ncursesw/curses.h>
388 #elif defined(HAVE_NCURSES_NCURSES_H)
389 #include <ncurses/curses.h>
394 #if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT))
395 #undef KEY_EVENT /* reduce compiler-warnings with Visual C++ */
398 #if defined(HAVE_XCURSES) || defined(PDCURSES)
399 /* no other headers */
400 #undef HAVE_SETUPTERM /* nonfunctional */
401 #define HAVE_SETUPTERM 0
402 #undef HAVE_TGETENT /* nonfunctional */
403 #define HAVE_TGETENT 0
404 #undef HAVE_TIGETSTR /* nonfunctional */
405 #define HAVE_TIGETSTR 0
406 #elif defined(HAVE_NCURSESW_TERM_H)
407 #include <ncursesw/term.h>
408 #elif defined(HAVE_NCURSES_TERM_H)
409 #include <ncurses/term.h>
410 #elif defined(HAVE_TERM_H)
415 * Not all curses.h implementations include unctrl.h,
417 #if defined(HAVE_NCURSESW_UNCTRL_H)
418 #include <ncursesw/unctrl.h>
419 #elif defined(HAVE_NCURSES_UNCTRL_H)
420 #include <ncurses/unctrl.h>
421 #elif defined(HAVE_UNCTRL_H)
427 #elif !defined(HAVE_GETOPT_HEADER)
428 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
433 #endif /* HAVE_GETOPT_H */
438 #define setlocale(name,string) /* nothing */
444 #if defined(_MSC_VER)
446 #define popen(s,n) _popen(s,n)
448 #define pclose(s) _pclose(s)
452 #define GCC_NORETURN /* nothing */
454 #ifndef GCC_PRINTFLIKE
455 #define GCC_PRINTFLIKE(a,b) /* nothing */
457 #ifndef GCC_SCANFLIKE
458 #define GCC_SCANFLIKE(a,b) /* nothing */
461 #define GCC_UNUSED /* nothing */
465 #define getnstr(s,n) getstr(s)
468 #if HAVE_INIT_EXTENDED_COLOR
469 #define USE_EXTENDED_COLOR 1
471 #define USE_EXTENDED_COLOR 0
476 #define USE_SOFTKEYS 1
478 #define USE_SOFTKEYS 0
483 #define slk_init() /* nothing */
484 #define slk_restore() /* nothing */
485 #define slk_clear() /* nothing */
488 #ifndef HAVE_CURSES_DATA_TABSIZE
489 #define HAVE_CURSES_DATA_TABSIZE 0
492 #if !NCURSES_EXT_FUNCS
493 #if HAVE_CURSES_DATA_TABSIZE
494 #define set_tabsize(n) TABSIZE = (n)
496 #define set_tabsize(n) /* nothing */
501 #define USE_SP_FUNCS 1
503 #define USE_SP_FUNCS 0
506 #ifndef HAVE_WSYNCDOWN
507 #define wsyncdown(win) /* nothing */
510 #ifndef USE_WIDEC_SUPPORT
511 #if (defined(_XOPEN_SOURCE_EXTENDED) \
512 || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) \
513 || (defined(NCURSES_WIDECHAR) && (NCURSES_WIDECHAR - 0 < 1))) \
514 && defined(WACS_ULCORNER)
515 #define USE_WIDEC_SUPPORT 1
517 #define USE_WIDEC_SUPPORT 0
521 #if HAVE_PANEL_H && HAVE_LIBPANEL
522 #define USE_LIBPANEL 1
524 #define USE_LIBPANEL 0
527 #if HAVE_MENU_H && HAVE_LIBMENU
528 #define USE_LIBMENU 1
530 #define USE_LIBMENU 0
533 #if HAVE_FORM_H && HAVE_LIBFORM
534 #define USE_LIBFORM 1
536 #define USE_LIBFORM 0
539 /* workaround, to build against NetBSD's variant of the form library */
540 #ifdef HAVE_NETBSD_FORM_H
541 #define form_getyx(form, y, x) y = (int)current_field(form)->cursor_ypos, x = (int)current_field(form)->cursor_xpos
543 #define form_getyx(form, y, x) y = (int)(form)->currow, x = (int)(form)->curcol
546 /* workaround, to build against NetBSD's variant of the form library */
547 #ifdef HAVE_NETBSD_MENU_H
548 #define menu_itemwidth(menu) (menu)->max_item_width
550 #define menu_itemwidth(menu) (menu)->itemlen
553 #ifndef HAVE_TYPE_ATTR_T
554 #if !USE_WIDEC_SUPPORT && !defined(attr_t)
555 #define attr_t chtype
560 #if !USE_WIDEC_SUPPORT
561 #define NCURSES_CH_T chtype
563 #define NCURSES_CH_T cchar_t
566 #ifndef NCURSES_COLOR_T
567 #define NCURSES_COLOR_T short
570 #ifndef NCURSES_PAIRS_T
571 #define NCURSES_PAIRS_T short
578 #if defined(NCURSES_VERSION) && defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
579 #define CURSES_WACS_SYMBOLS
582 #if defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
583 /* NetBSD 5.1 defines these incorrectly */
617 #define WACS_RARROW &(CURSES_WACS_ARRAY['+'])
618 #define WACS_LARROW &(CURSES_WACS_ARRAY[','])
619 #define WACS_UARROW &(CURSES_WACS_ARRAY['-'])
620 #define WACS_DARROW &(CURSES_WACS_ARRAY['.'])
621 #define WACS_BLOCK &(CURSES_WACS_ARRAY['0'])
622 #define WACS_DIAMOND &(CURSES_WACS_ARRAY['`'])
623 #define WACS_CKBOARD &(CURSES_WACS_ARRAY['a'])
624 #define WACS_DEGREE &(CURSES_WACS_ARRAY['f'])
625 #define WACS_PLMINUS &(CURSES_WACS_ARRAY['g'])
626 #define WACS_BOARD &(CURSES_WACS_ARRAY['h'])
627 #define WACS_LANTERN &(CURSES_WACS_ARRAY['i'])
628 #define WACS_LRCORNER &(CURSES_WACS_ARRAY['j'])
629 #define WACS_URCORNER &(CURSES_WACS_ARRAY['k'])
630 #define WACS_ULCORNER &(CURSES_WACS_ARRAY['l'])
631 #define WACS_LLCORNER &(CURSES_WACS_ARRAY['m'])
632 #define WACS_PLUS &(CURSES_WACS_ARRAY['n'])
633 #define WACS_HLINE &(CURSES_WACS_ARRAY['q'])
634 #define WACS_S1 &(CURSES_WACS_ARRAY['o'])
635 #define WACS_S9 &(CURSES_WACS_ARRAY['s'])
636 #define WACS_LTEE &(CURSES_WACS_ARRAY['t'])
637 #define WACS_RTEE &(CURSES_WACS_ARRAY['u'])
638 #define WACS_BTEE &(CURSES_WACS_ARRAY['v'])
639 #define WACS_TTEE &(CURSES_WACS_ARRAY['w'])
640 #define WACS_VLINE &(CURSES_WACS_ARRAY['x'])
641 #define WACS_BULLET &(CURSES_WACS_ARRAY['~'])
642 #define WACS_S3 &(CURSES_WACS_ARRAY['p'])
643 #define WACS_S7 &(CURSES_WACS_ARRAY['r'])
644 #define WACS_LEQUAL &(CURSES_WACS_ARRAY['y'])
645 #define WACS_GEQUAL &(CURSES_WACS_ARRAY['z'])
646 #define WACS_PI &(CURSES_WACS_ARRAY['{'])
647 #define WACS_NEQUAL &(CURSES_WACS_ARRAY['|'])
648 #define WACS_STERLING &(CURSES_WACS_ARRAY['}'])
652 #define WA_NORMAL A_NORMAL
655 #define WA_BOLD A_BOLD
658 #define WA_REVERSE A_REVERSE
661 #define WA_UNDERLINE A_UNDERLINE
664 #define WA_BLINK A_BLINK
676 #define CTRL(x) ((x) & 0x1f)
678 #define QUIT CTRL('Q')
679 #define ESCAPE CTRL('[')
682 #define KEY_MIN 256 /* not defined in Solaris 8 */
685 #define HELP_KEY_1 '?'
686 #define HELP_KEY_2 KEY_F(1)
688 /* from nc_string.h, to make this stand alone */
689 #if HAVE_BSD_STRING_H
690 #include <bsd/string.h>
694 #define NCURSES_VOID /* nothing */
696 #define NCURSES_VOID (void)
700 #define HAVE_STRLCAT 0
704 #define HAVE_STRLCPY 0
707 #ifndef HAVE_SNPRINTF
708 #define HAVE_SNPRINTF 0
711 #ifndef USE_STRING_HACKS
712 #define USE_STRING_HACKS 0
718 #define NCURSES_CAST(type,value) static_cast<type>(value)
720 #define NCURSES_CAST(type,value) (type)(value)
724 #if USE_STRING_HACKS && HAVE_STRLCAT
725 #define _nc_STRCAT(d,s,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n))
726 #define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m))
728 #define _nc_STRCAT(d,s,n) NCURSES_VOID strcat((d),(s))
729 #define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strncat((d),(s),(n))
732 #if USE_STRING_HACKS && HAVE_STRLCPY
733 #define _nc_STRCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
734 #define _nc_STRNCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
736 #define _nc_STRCPY(d,s,n) NCURSES_VOID strcpy((d),(s))
737 #define _nc_STRNCPY(d,s,n) NCURSES_VOID strncpy((d),(s),(n))
740 #if USE_STRING_HACKS && HAVE_SNPRINTF
741 #define _nc_SPRINTF NCURSES_VOID snprintf
742 #define _nc_SLIMIT(n) NCURSES_CAST(size_t,n),
744 #define _nc_SPRINTF NCURSES_VOID sprintf
745 #define _nc_SLIMIT(n) /* nothing */
749 * X/Open Curses does not define the arrays of terminfo/termcap names as SVr4
750 * curses did, and some implementations provide them anyway, but undeclared.
752 #ifdef DECL_CURSES_DATA_BOOLNAMES
753 extern char *boolnames[], *boolcodes[], *boolfnames[];
754 extern char *numnames[], *numcodes[], *numfnames[];
755 extern char *strnames[], *strcodes[], *strfnames[];
759 * Again, an SVr4 curses feature latent in the libraries but not in headers.
761 #ifndef DECL_CURSES_DATA_TABSIZE
762 #define DECL_CURSES_DATA_TABSIZE 0
765 #if DECL_CURSES_DATA_TABSIZE
767 #undef HAVE_CURSES_DATA_TABSIZE
768 #define HAVE_CURSES_DATA_TABSIZE 1
771 #ifndef HAVE_CURSES_DATA_TABSIZE
772 #define HAVE_CURSES_DATA_TABSIZE 0
776 * X/Open Curses provides termname(), whose return value is analogous to the
777 * SVr4 curses variable ttytype[].
779 #ifndef HAVE_CURSES_DATA_TTYTYPE
780 #define HAVE_CURSES_DATA_TTYTYPE 0
783 #ifndef DECL_CURSES_DATA_TTYTYPE
784 #define DECL_CURSES_DATA_TTYTYPE 0
787 #if !defined(ttytype) && (!HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE)
788 #define ttytype termname()
791 #define colored_chtype(ch, attr, pair) \
792 ((chtype) (ch) | (chtype) (attr) | (chtype) COLOR_PAIR(pair))
795 * Workaround for HPUX
797 #if defined(__hpux) && !defined(NCURSES_VERSION)
798 #define getbegx(w) __getbegx(w)
799 #define getbegy(w) __getbegy(w)
800 #define getcurx(w) __getcurx(w)
801 #define getcury(w) __getcury(w)
802 #define getmaxx(w) __getmaxx(w)
803 #define getmaxy(w) __getmaxy(w)
804 #define getparx(w) __getparx(w)
805 #define getpary(w) __getpary(w)
809 * Workaround in case getcchar() returns a positive value when the source
810 * string produces only a L'\0'.
812 #define TEST_CCHAR(s, count, then_stmt, else_stmt) \
813 if ((count = getcchar(s, NULL, NULL, NULL, NULL)) > 0) { \
814 wchar_t test_wch[CCHARW_MAX + 2]; \
816 NCURSES_PAIRS_T test_pair; \
818 if (getcchar( s, test_wch, &test_attrs, &test_pair, NULL) == OK \
819 && test_wch[0] != L'\0') { \
828 * These usually are implemented as macros, but may be functions.
830 #if !defined(getcurx) && !HAVE_GETCURX
831 #define getcurx(win) ((win) ? ((int)(win)->_curx) : ERR)
832 #define getcury(win) ((win) ? ((int)(win)->_cury) : ERR)
835 #if !defined(getbegx) && !HAVE_GETBEGX
836 #define getbegx(win) ((win) ? ((int)(win)->_begx) : ERR)
837 #define getbegy(win) ((win) ? ((int)(win)->_begy) : ERR)
840 #if !defined(getmaxx) && !HAVE_GETMAXX
841 #define getmaxx(win) ((win) ? ((int)(win)->_maxx + 1) : ERR)
842 #define getmaxy(win) ((win) ? ((int)(win)->_maxy + 1) : ERR)
847 #define __m_getparx(w) ((w)->_parent == (WINDOW *) 0 ? -1 \
848 : (w)->_begx - (w)->_parent->_begx)
850 #if !defined(getparx) && !HAVE_GETPARX
852 #define getparx(win) __m_getparx(win)
853 #define getpary(win) __m_getpary(win)
855 #define getparx(win) ((win)?((win)->_parx + 1):ERR)
856 #define getpary(win) ((win)?((win)->_pary + 1):ERR)
860 #if !defined(mvwvline) && !HAVE_MVWVLINE
861 #define mvwvline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : wvline(w,ch,n))
862 #define mvwhline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : whline(w,ch,n))
865 #if !defined(mvvline) && !HAVE_MVVLINE
866 #define mvvline(y,x,ch,n) (move(y,x) == ERR ? ERR : vline(ch,n))
867 #define mvhline(y,x,ch,n) (move(y,x) == ERR ? ERR : hline(ch,n))
871 * Try to accommodate curses implementations that have no terminfo support.
874 #define TIGETNUM(ti,tc) tigetnum(ti)
876 #define TIGETNUM(ti,tc) tgetnum(tc)
880 #define TIGETSTR(ti,tc) tigetstr(ti)
882 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
886 * So far (2013 - more than ten years), only ncurses implements
887 * use_extended_names().
889 #if defined(NCURSES_XNAMES)
890 #elif defined(NCURSES_VERSION) && defined(HAVE_TERM_ENTRY_H) && HAVE_TERM_ENTRY_H
891 #define NCURSES_XNAMES 1
893 #define NCURSES_XNAMES 0
897 * ncurses restores the cursor in endwin(). Other libraries may not.
899 #ifdef NCURSES_VERSION
900 #define stop_curses() endwin()
902 #define stop_curses() do { endwin(); curs_set(1); } while (0)
905 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
906 * (which is incompatible with legacy usage, doesn't solve any problems).
908 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
909 #define tparm2(a,b) tparm(a,b,0,0,0,0,0,0,0,0)
911 #define UChar(c) ((unsigned char)(c))
913 #define SIZEOF(table) (sizeof(table)/sizeof(table[0]))
915 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
916 #include <nc_alloc.h>
917 #if HAVE_EXIT_TERMINFO && defined(USE_TINFO)
919 #define ExitProgram(code) exit_terminfo(code)
922 #define typeMalloc(type,n) (type *) malloc((size_t)(n) * sizeof(type))
923 #define typeCalloc(type,elts) (type *) calloc((size_t)(elts), sizeof(type))
924 #define typeRealloc(type,n,p) (type *) realloc(p, (size_t)(n) * sizeof(type))
928 #define ExitProgram(code) exit(code)
932 #define EXIT_SUCCESS 0
935 #define EXIT_FAILURE 1
938 #if defined(_WIN32) || defined(USE_WIN32CON_DRIVER)
940 #if defined(PDCURSES)
943 # error WINVER must at least be 0x0501
946 # define WINVER 0x0501
949 #include <sys/time.h> /* for struct timeval */
951 #define sleep(n) Sleep((n) * 1000)
954 #define getlogin() "username"
956 #elif defined(HAVE_NCURSESW_NCURSES_H)
957 #include <ncursesw/nc_mingw.h>
958 #elif defined(HAVE_NCURSES_NCURSES_H)
959 #include <ncurses/nc_mingw.h>
961 #include <nc_mingw.h>
964 /* conflicts in test/firstlast.c */
971 #if TIME_WITH_SYS_TIME
972 # include <sys/time.h>
976 # include <sys/time.h>
986 #ifndef STDOUT_FILENO
987 #define STDOUT_FILENO 1
991 extern char *_nc_strstr(const char *, const char *);
992 #define strstr(a,b) _nc_strstr((a),(b))
993 #endif /* !HAVE_STRSTR */
995 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
996 * curses which doesn't have const parameters declared (so far) in the places
999 #ifndef NCURSES_CONST
1001 #define NCURSES_CONST const /* close enough */
1003 #define NCURSES_CONST /* nothing */
1007 /* out-of-band values for representing absent capabilities */
1008 #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
1009 #define ABSENT_NUMERIC (-1)
1010 #define ABSENT_STRING (char *)0
1012 /* out-of-band values for representing cancels */
1013 #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
1014 #define CANCELLED_NUMERIC (-2)
1015 #define CANCELLED_STRING (char *)(-1)
1017 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
1018 #define VALID_NUMERIC(s) ((s) >= 0)
1019 #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
1021 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
1023 #define CATCHALL(handler) do { \
1025 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
1026 if (nsig != SIGKILL) \
1027 signal(nsig, handler); \
1030 #ifdef NCURSES_VERSION
1031 #define InitAndCatch(init,handler) do { CATCHALL(handler); init; } while (0)
1033 #define InitAndCatch(init,handler) do { init; CATCHALL(handler); } while (0)
1036 #if defined(_WIN32) || defined(USE_WIN32CON_DRIVER)
1037 #define SetupAlarm(opt) (void)opt
1039 #define SetupAlarm(opt) if (opt) alarm((unsigned)opt)
1043 * Workaround for clean(er) compile with Solaris's legacy curses.
1044 * The same would be needed for HPUX 10.20
1047 #define TPUTS_ARG int
1050 #if defined(sun) && !defined(_XOPEN_CURSES) && !defined(NCURSES_VERSION_PATCH)
1052 #define TPUTS_ARG char
1053 extern char *tgoto(char *, int, int); /* available, but not prototyped */
1057 #define TPUTS_PROTO(func,value) int func(TPUTS_ARG value)
1060 #ifndef TPUTS_RETURN
1061 #define TPUTS_RETURN(value) return value
1065 * Workarounds for Solaris's X/Open curses
1067 #if !defined(KEY_MIN) && defined(__KEY_MIN)
1068 #define KEY_MIN __KEY_MIN
1070 #if !defined(KEY_MAX) && defined(__KEY_MIN)
1071 #define KEY_MAX __KEY_MAX
1075 * Workaround to build with Sun's default SVr4 curses.
1077 #ifdef NCURSES_VERSION
1078 #ifndef HAVE_VW_PRINTW
1079 #define HAVE_VW_PRINTW 1
1084 * ncurses provides arrays of capability names; X/Open discarded these SVr4
1085 * features. Some implementations continue to provide them (see the test
1086 * configure script).
1088 #ifdef NCURSES_VERSION
1089 #ifndef HAVE_CURSES_DATA_BOOLNAMES
1090 #define HAVE_CURSES_DATA_BOOLNAMES 1
1095 * ncurses provides a termcap interface; a few packagers replace or displace
1096 * its header file with an incompatible one. The demo_termcap program uses
1097 * the ncurses file, if available.
1099 #ifdef NCURSES_VERSION
1100 #ifndef HAVE_NCURSES_TERMCAP_H
1101 #define HAVE_NCURSES_TERMCAP_H 0
1103 #ifndef HAVE_TERMCAP_H
1104 #define HAVE_TERMCAP_H 0
1109 * ncurses uses const in some places where X/Open does (or did) not allow.
1111 #if defined(NCURSES_CONST)
1112 #define CONST_MENUS NCURSES_CONST
1113 #elif defined(PDCURSES)
1114 #define CONST_MENUS const
1116 #define CONST_MENUS /* nothing */
1120 * Simplify setting up demo of threading with these macros.
1124 #define USING_WINDOW(w,func) use_window(w, (NCURSES_WINDOW_CB) func, w)
1125 #define USING_WINDOW1(w,func,safe) use_window(w, (NCURSES_WINDOW_CB) safe, NULL)
1126 #define USING_WINDOW2(w,func,data) use_window(w, (NCURSES_WINDOW_CB) func, data)
1127 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
1129 #define USING_WINDOW(w,func) func(w, NULL)
1130 #define USING_WINDOW1(w,func,safe) func(w)
1131 #define USING_WINDOW2(w,func,data) func(w,data)
1132 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
1136 #define USING_SCREEN(s,func,data) use_screen(s, (NCURSES_SCREEN_CB) func, data)
1137 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
1139 #define USING_SCREEN(s,func,data) func(data)
1140 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
1143 #if defined(TRACE) && HAVE__TRACEF
1144 #define Trace(p) _tracef p
1146 #define START_TRACE() \
1147 if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
1148 int t = _nc_getenv_num("NCURSES_TRACE"); \
1150 curses_trace((unsigned) t); \
1152 extern unsigned _nc_tracing;
1153 extern int _nc_getenv_num(const char *);
1156 #define Trace(p) /* nothing */
1158 #define START_TRACE() /* nothing */
1161 #define Trace2(p) /* nothing */
1163 #define AddCh(c) (void) addch((chtype)(c))
1164 #define WAddCh(w,c) (void) waddch((w),(chtype)(c))
1165 #define MvAddCh(y,x,c) (void) mvaddch((y),(x),(chtype)(c))
1166 #define MvWAddCh(w,y,x,c) (void) mvwaddch((w),(y),(x),(chtype)(c))
1167 #define MvAddStr(y,x,s) (void) mvaddstr((y),(x),(s))
1168 #define MvWAddStr(w,y,x,s) (void) mvwaddstr((w),(y),(x),(s))
1169 #define MvWAddChStr(w,y,x,s) (void) mvwaddchstr((w),(y),(x),(s))
1170 #define MvPrintw (void) mvprintw
1171 #define MvWPrintw (void) mvwprintw
1172 #define MvHLine (void) mvhline
1173 #define MvWHLine (void) mvwhline
1174 #define MvVLine (void) mvvline
1175 #define MvWVLine (void) mvwvline
1178 * The macro likely uses unsigned values, while X/Open prototype uses int.
1180 #if defined(wattrset) || defined(PDCURSES)
1181 #define AttrArg(p,a) (chtype) ((chtype)(p) | (chtype)(a))
1183 #define AttrArg(p,a) (int) ((chtype)(p) | (chtype)(a))
1187 * Workaround for defective implementation of gcc attribute warn_unused_result
1189 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
1190 #define IGNORE_RC(func) errno = func
1192 #define IGNORE_RC(func) (void) func
1193 #endif /* gcc workarounds */
1195 #define init_mb(state) memset(&state, 0, sizeof(state))
1197 #endif /* __TEST_PRIV_H */