1 /****************************************************************************
2 * Copyright (c) 1998-2018,2019 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.180 2019/03/30 20:19:38 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
73 #ifndef HAVE_CURSES_VERSION
74 #define HAVE_CURSES_VERSION 0
85 #ifndef HAVE_COLOR_CONTENT
86 #define HAVE_COLOR_CONTENT 0
90 #define HAVE_COPYWIN 0
93 #ifndef HAVE_COLOR_SET
94 #define HAVE_COLOR_SET 0
97 #ifndef HAVE_DELSCREEN
98 #define HAVE_DELSCREEN 0
102 #define HAVE_DUPWIN 0
106 #define HAVE_FILTER 0
110 #define HAVE_FORM_H 0
114 #define HAVE_GETBEGX 0
118 #define HAVE_GETCURX 0
122 #define HAVE_GETMAXX 0
125 #ifndef HAVE_GETOPT_H
126 #define HAVE_GETOPT_H 0
130 #define HAVE_GETPARX 0
134 #define HAVE_GETWIN 0
137 #ifndef HAVE_HALFDELAY
138 #define HAVE_HALFDELAY 0
141 #ifndef HAVE_INIT_EXTENDED_COLOR
142 #define HAVE_INIT_EXTENDED_COLOR 0
146 #define HAVE_LIBFORM 0
150 #define HAVE_LIBMENU 0
153 #ifndef HAVE_LIBPANEL
154 #define HAVE_LIBPANEL 0
157 #ifndef HAVE_LANGINFO_CODESET
158 #define HAVE_LANGINFO_CODESET 0
161 #ifndef HAVE_LOCALE_H
162 #define HAVE_LOCALE_H 0
166 #define HAVE_MATH_H 0
170 #define HAVE_MENU_H 0
173 #ifndef HAVE_MVDERWIN
174 #define HAVE_MVDERWIN 0
178 #define HAVE_MVVLINE 0
185 #ifndef HAVE_MVWVLINE
186 #define HAVE_MVWVLINE 0
193 #ifndef HAVE_NC_ALLOC_H
194 #define HAVE_NC_ALLOC_H 0
198 #define HAVE_NEWPAD 0
202 #define HAVE_PANEL_H 0
206 #define HAVE_PUTWIN 0
209 #ifndef HAVE_RESET_COLOR_PAIRS
210 #define HAVE_RESET_COLOR_PAIRS 0
213 #ifndef HAVE_RESIZE_TERM
214 #define HAVE_RESIZE_TERM 0
217 #ifndef HAVE_RESTARTTERM
218 #define HAVE_RESTARTTERM 0
221 #ifndef HAVE_RIPOFFLINE
222 #define HAVE_RIPOFFLINE 0
225 #ifndef HAVE_SCR_DUMP
226 #define HAVE_SCR_DUMP 0
229 #ifndef HAVE_SETUPTERM
230 #define HAVE_SETUPTERM 0
233 #ifndef HAVE_SLK_COLOR
234 #define HAVE_SLK_COLOR 0
237 #ifndef HAVE_SLK_INIT
238 #define HAVE_SLK_INIT 0
241 #ifndef HAVE_STDINT_H
242 #define HAVE_STDINT_H 0
246 #define HAVE_STRSTR 0
249 #ifndef HAVE_SYS_IOCTL_H
250 #define HAVE_SYS_IOCTL_H 0
253 #ifndef HAVE_SYS_SELECT_H
254 #define HAVE_SYS_SELECT_H 0
257 #ifndef HAVE_TERMATTRS
258 #define HAVE_TERMATTRS 0
261 #ifndef HAVE_TERMIOS_H
262 #define HAVE_TERMIOS_H 0
265 #ifndef HAVE_TERMNAME
266 #define HAVE_TERMNAME 0
269 #ifndef HAVE_TERM_ENTRY_H
270 #define HAVE_TERM_ENTRY_H 0
274 #define HAVE_TGETENT 0
277 #ifndef HAVE_TIGETNUM
278 #define HAVE_TIGETNUM 0
281 #ifndef HAVE_TIGETSTR
282 #define HAVE_TIGETSTR 0
285 #ifndef HAVE_TPUTS_SP
286 #define HAVE_TPUTS_SP 0
290 #define HAVE_TSEARCH 0
293 #ifndef HAVE_TYPEAHEAD
294 #define HAVE_TYPEAHEAD 0
298 #define HAVE_WINSSTR 0
301 #ifndef HAVE_USE_DEFAULT_COLORS
302 #define HAVE_USE_DEFAULT_COLORS 0
306 #define HAVE_USE_ENV 0
309 #ifndef HAVE_USE_EXTENDED_NAMES
310 #define HAVE_USE_EXTENDED_NAMES 0
313 #ifndef HAVE_USE_SCREEN
314 #define HAVE_USE_SCREEN 0
317 #ifndef HAVE_USE_WINDOW
318 #define HAVE_USE_WINDOW 0
322 #define HAVE_VIDPUTS 0
325 #ifndef HAVE_VID_PUTS
326 #define HAVE_VID_PUTS 0
329 #ifndef HAVE_WINSDELLN
330 #define HAVE_WINSDELLN 0
334 #define HAVE_WRESIZE 0
338 #define HAVE__TRACEF 0
341 #ifndef NCURSES_EXT_FUNCS
342 #define NCURSES_EXT_FUNCS 0
346 #define NEED_PTEM_H 0
350 #define NEED_WCHAR_H 0
358 * Workaround for HPUX
360 #if defined(__hpux) && !defined(NCURSES_VERSION)
361 #define _ACS_COMPAT_CODE /* needed for acs_map vs __acs_map */
367 #include <sys/types.h>
374 #include <signal.h> /* include before curses.h to work around glibc bug */
378 #ifdef HAVE_LIBUTF8_H
383 #if defined(HAVE_XCURSES)
385 #elif defined(HAVE_NCURSESW_NCURSES_H)
386 #include <ncursesw/curses.h>
387 #elif defined(HAVE_NCURSES_NCURSES_H)
388 #include <ncurses/curses.h>
393 #if defined(HAVE_XCURSES) || defined(PDCURSES)
394 /* no other headers */
395 #undef HAVE_SETUPTERM /* nonfunctional */
396 #define HAVE_SETUPTERM 0
397 #undef HAVE_TGETENT /* nonfunctional */
398 #define HAVE_TGETENT 0
399 #undef HAVE_TIGETSTR /* nonfunctional */
400 #define HAVE_TIGETSTR 0
401 #elif defined(HAVE_NCURSESW_TERM_H)
402 #include <ncursesw/term.h>
403 #elif defined(HAVE_NCURSES_TERM_H)
404 #include <ncurses/term.h>
405 #elif defined(HAVE_TERM_H)
410 * Not all curses.h implementations include unctrl.h,
412 #if defined(HAVE_NCURSESW_UNCTRL_H)
413 #include <ncursesw/unctrl.h>
414 #elif defined(HAVE_NCURSES_UNCTRL_H)
415 #include <ncurses/unctrl.h>
416 #elif defined(HAVE_UNCTRL_H)
422 #elif !defined(HAVE_GETOPT_HEADER)
423 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
428 #endif /* HAVE_GETOPT_H */
433 #define setlocale(name,string) /* nothing */
440 #define GCC_NORETURN /* nothing */
442 #ifndef GCC_PRINTFLIKE
443 #define GCC_PRINTFLIKE(a,b) /* nothing */
445 #ifndef GCC_SCANFLIKE
446 #define GCC_SCANFLIKE(a,b) /* nothing */
449 #define GCC_UNUSED /* nothing */
453 #define getnstr(s,n) getstr(s)
456 #if HAVE_INIT_EXTENDED_COLOR
457 #define USE_EXTENDED_COLOR 1
459 #define USE_EXTENDED_COLOR 0
464 #define USE_SOFTKEYS 1
466 #define USE_SOFTKEYS 0
471 #define slk_init() /* nothing */
472 #define slk_restore() /* nothing */
473 #define slk_clear() /* nothing */
476 #if !NCURSES_EXT_FUNCS
477 #define set_tabsize(n) TABSIZE = (n)
481 #define USE_SP_FUNCS 1
483 #define USE_SP_FUNCS 0
486 #ifndef HAVE_WSYNCDOWN
487 #define wsyncdown(win) /* nothing */
490 #ifndef USE_WIDEC_SUPPORT
491 #if (defined(_XOPEN_SOURCE_EXTENDED) \
492 || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) \
493 || (defined(NCURSES_WIDECHAR) && (NCURSES_WIDECHAR - 0 < 1))) \
494 && defined(WACS_ULCORNER)
495 #define USE_WIDEC_SUPPORT 1
497 #define USE_WIDEC_SUPPORT 0
501 #if HAVE_PANEL_H && HAVE_LIBPANEL
502 #define USE_LIBPANEL 1
504 #define USE_LIBPANEL 0
507 #if HAVE_MENU_H && HAVE_LIBMENU
508 #define USE_LIBMENU 1
510 #define USE_LIBMENU 0
513 #if HAVE_FORM_H && HAVE_LIBFORM
514 #define USE_LIBFORM 1
516 #define USE_LIBFORM 0
519 /* workaround, to build against NetBSD's variant of the form library */
520 #ifdef HAVE_NETBSD_FORM_H
521 #define form_getyx(form, y, x) y = (int)current_field(form)->cursor_ypos, x = (int)current_field(form)->cursor_xpos
523 #define form_getyx(form, y, x) y = (int)(form)->currow, x = (int)(form)->curcol
526 /* workaround, to build against NetBSD's variant of the form library */
527 #ifdef HAVE_NETBSD_MENU_H
528 #define menu_itemwidth(menu) (menu)->max_item_width
530 #define menu_itemwidth(menu) (menu)->itemlen
533 #ifndef HAVE_TYPE_ATTR_T
534 #if !USE_WIDEC_SUPPORT && !defined(attr_t)
535 #define attr_t chtype
540 #if !USE_WIDEC_SUPPORT
541 #define NCURSES_CH_T chtype
543 #define NCURSES_CH_T cchar_t
546 #ifndef NCURSES_COLOR_T
547 #define NCURSES_COLOR_T short
550 #ifndef NCURSES_PAIRS_T
551 #define NCURSES_PAIRS_T short
558 #if defined(NCURSES_VERSION) && defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
559 #define CURSES_WACS_SYMBOLS
562 #if defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
563 /* NetBSD 5.1 defines these incorrectly */
597 #define WACS_RARROW &(CURSES_WACS_ARRAY['+'])
598 #define WACS_LARROW &(CURSES_WACS_ARRAY[','])
599 #define WACS_UARROW &(CURSES_WACS_ARRAY['-'])
600 #define WACS_DARROW &(CURSES_WACS_ARRAY['.'])
601 #define WACS_BLOCK &(CURSES_WACS_ARRAY['0'])
602 #define WACS_DIAMOND &(CURSES_WACS_ARRAY['`'])
603 #define WACS_CKBOARD &(CURSES_WACS_ARRAY['a'])
604 #define WACS_DEGREE &(CURSES_WACS_ARRAY['f'])
605 #define WACS_PLMINUS &(CURSES_WACS_ARRAY['g'])
606 #define WACS_BOARD &(CURSES_WACS_ARRAY['h'])
607 #define WACS_LANTERN &(CURSES_WACS_ARRAY['i'])
608 #define WACS_LRCORNER &(CURSES_WACS_ARRAY['j'])
609 #define WACS_URCORNER &(CURSES_WACS_ARRAY['k'])
610 #define WACS_ULCORNER &(CURSES_WACS_ARRAY['l'])
611 #define WACS_LLCORNER &(CURSES_WACS_ARRAY['m'])
612 #define WACS_PLUS &(CURSES_WACS_ARRAY['n'])
613 #define WACS_HLINE &(CURSES_WACS_ARRAY['q'])
614 #define WACS_S1 &(CURSES_WACS_ARRAY['o'])
615 #define WACS_S9 &(CURSES_WACS_ARRAY['s'])
616 #define WACS_LTEE &(CURSES_WACS_ARRAY['t'])
617 #define WACS_RTEE &(CURSES_WACS_ARRAY['u'])
618 #define WACS_BTEE &(CURSES_WACS_ARRAY['v'])
619 #define WACS_TTEE &(CURSES_WACS_ARRAY['w'])
620 #define WACS_VLINE &(CURSES_WACS_ARRAY['x'])
621 #define WACS_BULLET &(CURSES_WACS_ARRAY['~'])
622 #define WACS_S3 &(CURSES_WACS_ARRAY['p'])
623 #define WACS_S7 &(CURSES_WACS_ARRAY['r'])
624 #define WACS_LEQUAL &(CURSES_WACS_ARRAY['y'])
625 #define WACS_GEQUAL &(CURSES_WACS_ARRAY['z'])
626 #define WACS_PI &(CURSES_WACS_ARRAY['{'])
627 #define WACS_NEQUAL &(CURSES_WACS_ARRAY['|'])
628 #define WACS_STERLING &(CURSES_WACS_ARRAY['}'])
632 #define WA_NORMAL A_NORMAL
635 #define WA_BOLD A_BOLD
638 #define WA_REVERSE A_REVERSE
641 #define WA_UNDERLINE A_UNDERLINE
644 #define WA_BLINK A_BLINK
656 #define CTRL(x) ((x) & 0x1f)
658 #define QUIT CTRL('Q')
659 #define ESCAPE CTRL('[')
662 #define KEY_MIN 256 /* not defined in Solaris 8 */
665 #define HELP_KEY_1 '?'
666 #define HELP_KEY_2 KEY_F(1)
668 /* from nc_string.h, to make this stand alone */
669 #if HAVE_BSD_STRING_H
670 #include <bsd/string.h>
674 #define NCURSES_VOID /* nothing */
676 #define NCURSES_VOID (void)
680 #define HAVE_STRLCAT 0
684 #define HAVE_STRLCPY 0
687 #ifndef HAVE_SNPRINTF
688 #define HAVE_SNPRINTF 0
691 #ifndef USE_STRING_HACKS
692 #define USE_STRING_HACKS 0
698 #define NCURSES_CAST(type,value) static_cast<type>(value)
700 #define NCURSES_CAST(type,value) (type)(value)
704 #if USE_STRING_HACKS && HAVE_STRLCAT
705 #define _nc_STRCAT(d,s,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n))
706 #define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m))
708 #define _nc_STRCAT(d,s,n) NCURSES_VOID strcat((d),(s))
709 #define _nc_STRNCAT(d,s,m,n) NCURSES_VOID strncat((d),(s),(n))
712 #if USE_STRING_HACKS && HAVE_STRLCPY
713 #define _nc_STRCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
714 #define _nc_STRNCPY(d,s,n) NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
716 #define _nc_STRCPY(d,s,n) NCURSES_VOID strcpy((d),(s))
717 #define _nc_STRNCPY(d,s,n) NCURSES_VOID strncpy((d),(s),(n))
720 #if USE_STRING_HACKS && HAVE_SNPRINTF
721 #define _nc_SPRINTF NCURSES_VOID snprintf
722 #define _nc_SLIMIT(n) NCURSES_CAST(size_t,n),
724 #define _nc_SPRINTF NCURSES_VOID sprintf
725 #define _nc_SLIMIT(n) /* nothing */
728 #ifdef DECL_CURSES_DATA_BOOLNAMES
729 extern char *boolnames[], *boolcodes[], *boolfnames[];
730 extern char *numnames[], *numcodes[], *numfnames[];
731 extern char *strnames[], *strcodes[], *strfnames[];
734 #ifndef HAVE_CURSES_DATA_TTYTYPE
735 #define HAVE_CURSES_DATA_TTYTYPE 0
738 #ifndef DECL_CURSES_DATA_TTYTYPE
739 #define DECL_CURSES_DATA_TTYTYPE 0
742 #if !defined(ttytype) && (!HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE)
743 #define ttytype termname()
746 #define colored_chtype(ch, attr, pair) \
747 ((chtype) (ch) | (chtype) (attr) | (chtype) COLOR_PAIR(pair))
750 * Workaround for HPUX
752 #if defined(__hpux) && !defined(NCURSES_VERSION)
753 #define getbegx(w) __getbegx(w)
754 #define getbegy(w) __getbegy(w)
755 #define getcurx(w) __getcurx(w)
756 #define getcury(w) __getcury(w)
757 #define getmaxx(w) __getmaxx(w)
758 #define getmaxy(w) __getmaxy(w)
759 #define getparx(w) __getparx(w)
760 #define getpary(w) __getpary(w)
764 * Workaround in case getcchar() returns a positive value when the source
765 * string produces only a L'\0'.
767 #define TEST_CCHAR(s, count, then_stmt, else_stmt) \
768 if ((count = getcchar(s, NULL, NULL, NULL, NULL)) > 0) { \
769 wchar_t test_wch[CCHARW_MAX + 2]; \
771 NCURSES_PAIRS_T test_pair; \
773 if (getcchar( s, test_wch, &test_attrs, &test_pair, NULL) == OK \
774 && test_wch[0] != L'\0') { \
783 * These usually are implemented as macros, but may be functions.
785 #if !defined(getcurx) && !HAVE_GETCURX
786 #define getcurx(win) ((win) ? ((int)(win)->_curx) : ERR)
787 #define getcury(win) ((win) ? ((int)(win)->_cury) : ERR)
790 #if !defined(getbegx) && !HAVE_GETBEGX
791 #define getbegx(win) ((win) ? ((int)(win)->_begx) : ERR)
792 #define getbegy(win) ((win) ? ((int)(win)->_begy) : ERR)
795 #if !defined(getmaxx) && !HAVE_GETMAXX
796 #define getmaxx(win) ((win) ? ((int)(win)->_maxx + 1) : ERR)
797 #define getmaxy(win) ((win) ? ((int)(win)->_maxy + 1) : ERR)
802 #define __m_getparx(w) ((w)->_parent == (WINDOW *) 0 ? -1 \
803 : (w)->_begx - (w)->_parent->_begx)
805 #if !defined(getparx) && !HAVE_GETPARX
807 #define getparx(win) __m_getparx(win)
808 #define getpary(win) __m_getpary(win)
810 #define getparx(win) ((win)?((win)->_parx + 1):ERR)
811 #define getpary(win) ((win)?((win)->_pary + 1):ERR)
815 #if !defined(mvwvline) && !HAVE_MVWVLINE
816 #define mvwvline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : wvline(w,ch,n))
817 #define mvwhline(w,y,x,ch,n) (move(y,x) == ERR ? ERR : whline(w,ch,n))
820 #if !defined(mvvline) && !HAVE_MVVLINE
821 #define mvvline(y,x,ch,n) (move(y,x) == ERR ? ERR : vline(ch,n))
822 #define mvhline(y,x,ch,n) (move(y,x) == ERR ? ERR : hline(ch,n))
826 * Try to accommodate curses implementations that have no terminfo support.
829 #define TIGETNUM(ti,tc) tigetnum(ti)
831 #define TIGETNUM(ti,tc) tgetnum(tc)
835 #define TIGETSTR(ti,tc) tigetstr(ti)
837 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
841 * So far (2013 - more than ten years), only ncurses implements
842 * use_extended_names().
844 #if defined(NCURSES_XNAMES)
845 #elif defined(NCURSES_VERSION) && defined(HAVE_TERM_ENTRY_H) && HAVE_TERM_ENTRY_H
846 #define NCURSES_XNAMES 1
848 #define NCURSES_XNAMES 0
852 * ncurses restores the cursor in endwin(). Other libraries may not.
854 #ifdef NCURSES_VERSION
855 #define exit_curses() endwin()
857 #define exit_curses() do { endwin(); curs_set(1); } while (0)
860 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
861 * (which is incompatible with legacy usage, doesn't solve any problems).
863 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
864 #define tparm2(a,b) tparm(a,b,0,0,0,0,0,0,0,0)
866 #define UChar(c) ((unsigned char)(c))
868 #define SIZEOF(table) (sizeof(table)/sizeof(table[0]))
870 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
871 #include <nc_alloc.h>
872 #if HAVE_NC_FREEALL && defined(USE_TINFO)
874 #define ExitProgram(code) _nc_free_tinfo(code)
877 #define typeMalloc(type,n) (type *) malloc((size_t)(n) * sizeof(type))
878 #define typeCalloc(type,elts) (type *) calloc((size_t)(elts), sizeof(type))
879 #define typeRealloc(type,n,p) (type *) realloc(p, (size_t)(n) * sizeof(type))
883 #define ExitProgram(code) exit(code)
887 #define EXIT_SUCCESS 0
890 #define EXIT_FAILURE 1
893 #if defined(_WIN32) || defined(USE_WIN32CON_DRIVER)
895 #if defined(PDCURSES)
898 # error WINVER must at least be 0x0501
901 # define WINVER 0x0501
904 #include <sys/time.h> /* for struct timeval */
906 #define sleep(n) Sleep((n) * 1000)
909 #define getlogin() "username"
911 #elif defined(HAVE_NCURSESW_NCURSES_H)
912 #include <ncursesw/nc_mingw.h>
913 #elif defined(HAVE_NCURSES_NCURSES_H)
914 #include <ncurses/nc_mingw.h>
916 #include <nc_mingw.h>
919 /* conflicts in test/firstlast.c */
926 #if TIME_WITH_SYS_TIME
927 # include <sys/time.h>
931 # include <sys/time.h>
941 #ifndef STDOUT_FILENO
942 #define STDOUT_FILENO 1
946 extern char * _nc_strstr (const char *, const char *);
947 #define strstr(a,b) _nc_strstr((a),(b))
948 #endif /* !HAVE_STRSTR */
950 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
951 * curses which doesn't have const parameters declared (so far) in the places
954 #ifndef NCURSES_CONST
956 #define NCURSES_CONST const /* close enough */
958 #define NCURSES_CONST /* nothing */
962 /* out-of-band values for representing absent capabilities */
963 #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
964 #define ABSENT_NUMERIC (-1)
965 #define ABSENT_STRING (char *)0
967 /* out-of-band values for representing cancels */
968 #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
969 #define CANCELLED_NUMERIC (-2)
970 #define CANCELLED_STRING (char *)(-1)
972 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
973 #define VALID_NUMERIC(s) ((s) >= 0)
974 #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
976 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
978 #define CATCHALL(handler) do { \
980 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
981 if (nsig != SIGKILL) \
982 signal(nsig, handler); \
985 #ifdef NCURSES_VERSION
986 #define InitAndCatch(init,handler) do { CATCHALL(handler); init; } while (0)
988 #define InitAndCatch(init,handler) do { init; CATCHALL(handler); } while (0)
992 * Workaround for clean(er) compile with Solaris's legacy curses.
993 * The same would be needed for HPUX 10.20
996 #define TPUTS_ARG int
999 #if defined(sun) && !defined(_XOPEN_CURSES) && !defined(NCURSES_VERSION_PATCH)
1001 #define TPUTS_ARG char
1002 extern char *tgoto(char *, int, int); /* available, but not prototyped */
1006 #define TPUTS_PROTO(func,value) int func(TPUTS_ARG value)
1009 #ifndef TPUTS_RETURN
1010 #define TPUTS_RETURN(value) return value
1014 * Workarounds for Solaris's X/Open curses
1016 #if !defined(KEY_MIN) && defined(__KEY_MIN)
1017 #define KEY_MIN __KEY_MIN
1019 #if !defined(KEY_MAX) && defined(__KEY_MIN)
1020 #define KEY_MAX __KEY_MAX
1024 * Workaround to build with Sun's default SVr4 curses.
1026 #ifdef NCURSES_VERSION
1027 #ifndef HAVE_VW_PRINTW
1028 #define HAVE_VW_PRINTW 1
1033 * ncurses provides arrays of capability names; X/Open discarded these SVr4
1034 * features. Some implementations continue to provide them (see the test
1035 * configure script).
1037 #ifdef NCURSES_VERSION
1038 #ifndef HAVE_CURSES_DATA_BOOLNAMES
1039 #define HAVE_CURSES_DATA_BOOLNAMES 1
1044 * ncurses provides a termcap interface; a few packagers replace or displace
1045 * its header file with an incompatible one. The demo_termcap program uses
1046 * the ncurses file, if available.
1048 #ifdef NCURSES_VERSION
1049 #ifndef HAVE_NCURSES_TERMCAP_H
1050 #define HAVE_NCURSES_TERMCAP_H 0
1052 #ifndef HAVE_TERMCAP_H
1053 #define HAVE_TERMCAP_H 0
1058 * ncurses uses const in some places where X/Open does (or did) not allow.
1060 #if defined(NCURSES_CONST)
1061 #define CONST_MENUS NCURSES_CONST
1062 #elif defined(PDCURSES)
1063 #define CONST_MENUS const
1065 #define CONST_MENUS /* nothing */
1069 * Simplify setting up demo of threading with these macros.
1073 #define USING_WINDOW(w,func) use_window(w, (NCURSES_WINDOW_CB) func, w)
1074 #define USING_WINDOW1(w,func,safe) use_window(w, (NCURSES_WINDOW_CB) safe, NULL)
1075 #define USING_WINDOW2(w,func,data) use_window(w, (NCURSES_WINDOW_CB) func, data)
1076 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
1078 #define USING_WINDOW(w,func) func(w, NULL)
1079 #define USING_WINDOW1(w,func,safe) func(w)
1080 #define USING_WINDOW2(w,func,data) func(w,data)
1081 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
1085 #define USING_SCREEN(s,func,data) use_screen(s, (NCURSES_SCREEN_CB) func, data)
1086 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
1088 #define USING_SCREEN(s,func,data) func(data)
1089 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
1092 #if defined(TRACE) && HAVE__TRACEF
1093 #define Trace(p) _tracef p
1095 #define START_TRACE() \
1096 if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
1097 int t = _nc_getenv_num("NCURSES_TRACE"); \
1099 trace((unsigned) t); \
1101 extern unsigned _nc_tracing;
1102 extern int _nc_getenv_num(const char *);
1105 #define Trace(p) /* nothing */
1107 #define START_TRACE() /* nothing */
1110 #define Trace2(p) /* nothing */
1112 #define AddCh(c) (void) addch((chtype)(c))
1113 #define WAddCh(w,c) (void) waddch((w),(chtype)(c))
1114 #define MvAddCh(y,x,c) (void) mvaddch((y),(x),(chtype)(c))
1115 #define MvWAddCh(w,y,x,c) (void) mvwaddch((w),(y),(x),(chtype)(c))
1116 #define MvAddStr(y,x,s) (void) mvaddstr((y),(x),(s))
1117 #define MvWAddStr(w,y,x,s) (void) mvwaddstr((w),(y),(x),(s))
1118 #define MvWAddChStr(w,y,x,s) (void) mvwaddchstr((w),(y),(x),(s))
1119 #define MvPrintw (void) mvprintw
1120 #define MvWPrintw (void) mvwprintw
1121 #define MvHLine (void) mvhline
1122 #define MvWHLine (void) mvwhline
1123 #define MvVLine (void) mvvline
1124 #define MvWVLine (void) mvwvline
1127 * The macro likely uses unsigned values, while X/Open prototype uses int.
1129 #if defined(wattrset) || defined(PDCURSES)
1130 #define AttrArg(p,a) (chtype) ((chtype)(p) | (chtype)(a))
1132 #define AttrArg(p,a) (int) ((chtype)(p) | (chtype)(a))
1136 * Workaround for defective implementation of gcc attribute warn_unused_result
1138 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
1139 #define IGNORE_RC(func) errno = func
1141 #define IGNORE_RC(func) (void) func
1142 #endif /* gcc workarounds */
1144 #define init_mb(state) memset(&state, 0, sizeof(state))
1146 #endif /* __TEST_PRIV_H */