]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/test.priv.h
ncurses 6.4 - patch 20230225
[ncurses.git] / test / test.priv.h
1 /****************************************************************************
2  * Copyright 2018-2022,2023 Thomas E. Dickey                                *
3  * Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
4  *                                                                          *
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:                 *
12  *                                                                          *
13  * The above copyright notice and this permission notice shall be included  *
14  * in all copies or substantial portions of the Software.                   *
15  *                                                                          *
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.                               *
23  *                                                                          *
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       *
27  * authorization.                                                           *
28  ****************************************************************************/
29
30 /****************************************************************************
31  *  Author: Thomas E. Dickey                    1996-on                     *
32  ****************************************************************************/
33 /* $Id: test.priv.h,v 1.210 2023/02/25 21:26:04 tom Exp $ */
34
35 #ifndef __TEST_PRIV_H
36 #define __TEST_PRIV_H 1
37
38 #include <ncurses_cfg.h>
39
40 /*
41  * Fix ifdef's that look for the form/menu/panel libraries, if we are building
42  * with wide-character ncurses.
43  */
44 #ifdef  HAVE_LIBFORMW
45 #define HAVE_LIBFORMW 1
46 #define HAVE_LIBFORM 1
47 #endif
48
49 #ifdef  HAVE_LIBMENUW
50 #define HAVE_LIBMENUW 1
51 #define HAVE_LIBMENU 1
52 #endif
53
54 #ifdef  HAVE_LIBPANELW
55 #define HAVE_LIBPANELW 1
56 #define HAVE_LIBPANEL 1
57 #endif
58
59 /*
60  * Fallback definitions to accommodate broken compilers.
61  */
62 #ifndef HAVE_ALLOC_PAIR
63 #define HAVE_ALLOC_PAIR 0
64 #endif
65
66 #ifndef HAVE_ASSUME_DEFAULT_COLORS
67 #define HAVE_ASSUME_DEFAULT_COLORS 0
68 #endif
69
70 #ifndef HAVE_CFMAKERAW
71 #define HAVE_CFMAKERAW 0
72 #endif
73
74 #ifndef HAVE_CHGAT
75 #define HAVE_CHGAT 0
76 #endif
77
78 #ifndef HAVE_CLOCK_GETTIME
79 #define HAVE_CLOCK_GETTIME 0
80 #endif
81
82 #ifndef HAVE_COLOR_CONTENT
83 #define HAVE_COLOR_CONTENT 0
84 #endif
85
86 #ifndef HAVE_COPYWIN
87 #define HAVE_COPYWIN 0
88 #endif
89
90 #ifndef HAVE_COLOR_SET
91 #define HAVE_COLOR_SET 0
92 #endif
93
94 #ifndef HAVE_BSD_STRING_H
95 #define HAVE_BSD_STRING_H 0
96 #endif
97
98 #ifndef HAVE_CURSES_VERSION
99 #define HAVE_CURSES_VERSION 0
100 #endif
101
102 #ifndef HAVE_CURSCR
103 #define HAVE_CURSCR 0
104 #endif
105
106 #ifndef HAVE_DELSCREEN
107 #define HAVE_DELSCREEN 0
108 #endif
109
110 #ifndef HAVE_DUPWIN
111 #define HAVE_DUPWIN 0
112 #endif
113
114 #ifndef HAVE_FILTER
115 #define HAVE_FILTER 0
116 #endif
117
118 #ifndef HAVE_FORM_H
119 #define HAVE_FORM_H 0
120 #endif
121
122 #ifndef HAVE_GETBEGX
123 #define HAVE_GETBEGX 0
124 #endif
125
126 #ifndef HAVE_GETCURX
127 #define HAVE_GETCURX 0
128 #endif
129
130 #ifndef HAVE_GETMAXX
131 #define HAVE_GETMAXX 0
132 #endif
133
134 #ifndef HAVE_GETTIMEOFDAY
135 #define HAVE_GETTIMEOFDAY 0
136 #endif
137
138 #ifndef HAVE_GETOPT_H
139 #define HAVE_GETOPT_H 0
140 #endif
141
142 #ifndef HAVE_GETPARX
143 #define HAVE_GETPARX 0
144 #endif
145
146 #ifndef HAVE_GETWIN
147 #define HAVE_GETWIN 0
148 #endif
149
150 #ifndef HAVE_HALFDELAY
151 #define HAVE_HALFDELAY 0
152 #endif
153
154 #ifndef HAVE_INIT_EXTENDED_COLOR
155 #define HAVE_INIT_EXTENDED_COLOR 0
156 #endif
157
158 #ifndef HAVE_LIBFORM
159 #define HAVE_LIBFORM 0
160 #endif
161
162 #ifndef HAVE_LIBMENU
163 #define HAVE_LIBMENU 0
164 #endif
165
166 #ifndef HAVE_LIBPANEL
167 #define HAVE_LIBPANEL 0
168 #endif
169
170 #ifndef HAVE_LANGINFO_CODESET
171 #define HAVE_LANGINFO_CODESET 0
172 #endif
173
174 #ifndef HAVE_LOCALE_H
175 #define HAVE_LOCALE_H 0
176 #endif
177
178 #ifndef HAVE_MATH_FUNCS
179 #define HAVE_MATH_FUNCS 0
180 #endif
181
182 #ifndef HAVE_MATH_H
183 #define HAVE_MATH_H 0
184 #endif
185
186 #ifndef HAVE_MENU_H
187 #define HAVE_MENU_H 0
188 #endif
189
190 #ifndef HAVE_MVDERWIN
191 #define HAVE_MVDERWIN 0
192 #endif
193
194 #ifndef HAVE_MVVLINE
195 #define HAVE_MVVLINE 0
196 #endif
197
198 #ifndef HAVE_MVWIN
199 #define HAVE_MVWIN 0
200 #endif
201
202 #ifndef HAVE_MVWVLINE
203 #define HAVE_MVWVLINE 0
204 #endif
205
206 #ifndef HAVE_NAPMS
207 #define HAVE_NAPMS 1
208 #endif
209
210 #ifndef HAVE_NC_ALLOC_H
211 #define HAVE_NC_ALLOC_H 0
212 #endif
213
214 #ifndef HAVE_NEWPAD
215 #define HAVE_NEWPAD 0
216 #endif
217
218 #ifndef HAVE_PANEL_H
219 #define HAVE_PANEL_H 0
220 #endif
221
222 #ifndef HAVE_PUTWIN
223 #define HAVE_PUTWIN 0
224 #endif
225
226 #ifndef HAVE_RESET_COLOR_PAIRS
227 #define HAVE_RESET_COLOR_PAIRS 0
228 #endif
229
230 #ifndef HAVE_RESIZE_TERM
231 #define HAVE_RESIZE_TERM 0
232 #endif
233
234 #ifndef HAVE_RESTARTTERM
235 #define HAVE_RESTARTTERM 0
236 #endif
237
238 #ifndef HAVE_RIPOFFLINE
239 #define HAVE_RIPOFFLINE 0
240 #endif
241
242 #ifndef HAVE_SCR_DUMP
243 #define HAVE_SCR_DUMP 0
244 #endif
245
246 #ifndef HAVE_SETUPTERM
247 #define HAVE_SETUPTERM 0
248 #endif
249
250 #ifndef HAVE_SLK_COLOR
251 #define HAVE_SLK_COLOR 0
252 #endif
253
254 #ifndef HAVE_SLK_INIT
255 #define HAVE_SLK_INIT 0
256 #endif
257
258 #ifndef HAVE_STDINT_H
259 #define HAVE_STDINT_H 0
260 #endif
261
262 #ifndef HAVE_STDNORETURN_H
263 #define HAVE_STDNORETURN_H 0
264 #endif
265
266 #ifndef HAVE_STRSTR
267 #define HAVE_STRSTR 0
268 #endif
269
270 #ifndef HAVE_SYS_IOCTL_H
271 #define HAVE_SYS_IOCTL_H 0
272 #endif
273
274 #ifndef HAVE_SYS_SELECT_H
275 #define HAVE_SYS_SELECT_H 0
276 #endif
277
278 #ifndef HAVE_TERMATTRS
279 #define HAVE_TERMATTRS 0
280 #endif
281
282 #ifndef HAVE_TERMIOS_H
283 #define HAVE_TERMIOS_H 0
284 #endif
285
286 #ifndef HAVE_TERMNAME
287 #define HAVE_TERMNAME 0
288 #endif
289
290 #ifndef HAVE_TERM_ENTRY_H
291 #define HAVE_TERM_ENTRY_H 0
292 #endif
293
294 #ifndef HAVE_TGETENT
295 #define HAVE_TGETENT 0
296 #endif
297
298 #ifndef HAVE_TIGETNUM
299 #define HAVE_TIGETNUM 0
300 #endif
301
302 #ifndef HAVE_TIGETSTR
303 #define HAVE_TIGETSTR 0
304 #endif
305
306 #ifndef HAVE_TPUTS_SP
307 #define HAVE_TPUTS_SP 0
308 #endif
309
310 #ifndef HAVE_TSEARCH
311 #define HAVE_TSEARCH 0
312 #endif
313
314 #ifndef HAVE_TYPEAHEAD
315 #define HAVE_TYPEAHEAD 0
316 #endif
317
318 #ifndef HAVE_WINSSTR
319 #define HAVE_WINSSTR 0
320 #endif
321
322 #ifndef HAVE_UNGET_WCH
323 #define HAVE_UNGET_WCH 0
324 #endif
325
326 #ifndef HAVE_USE_DEFAULT_COLORS
327 #define HAVE_USE_DEFAULT_COLORS 0
328 #endif
329
330 #ifndef HAVE_USE_ENV
331 #define HAVE_USE_ENV 0
332 #endif
333
334 #ifndef HAVE_USE_EXTENDED_NAMES
335 #define HAVE_USE_EXTENDED_NAMES 0
336 #endif
337
338 #ifndef HAVE_USE_SCREEN
339 #define HAVE_USE_SCREEN 0
340 #endif
341
342 #ifndef HAVE_USE_WINDOW
343 #define HAVE_USE_WINDOW 0
344 #endif
345
346 #ifndef HAVE_VIDPUTS
347 #define HAVE_VIDPUTS 0
348 #endif
349
350 #ifndef HAVE_VID_PUTS
351 #define HAVE_VID_PUTS 0
352 #endif
353
354 #ifndef HAVE_WINSDELLN
355 #define HAVE_WINSDELLN 0
356 #endif
357
358 #ifndef HAVE_WRESIZE
359 #define HAVE_WRESIZE 0
360 #endif
361
362 #ifndef HAVE__TRACEF
363 #define HAVE__TRACEF 0
364 #endif
365
366 #ifndef NCURSES_EXT_FUNCS
367 #define NCURSES_EXT_FUNCS 0
368 #endif
369
370 #ifndef NEED_PTEM_H
371 #define NEED_PTEM_H 0
372 #endif
373
374 #ifndef NEED_WCHAR_H
375 #define NEED_WCHAR_H 0
376 #endif
377
378 #ifndef NO_LEAKS
379 #define NO_LEAKS 0
380 #endif
381
382 /*
383  * Workaround for HPUX
384  */
385 #if defined(__hpux) && !defined(NCURSES_VERSION)
386 #define _ACS_COMPAT_CODE        /* needed for acs_map vs __acs_map */
387 #endif
388
389 #include <stdlib.h>
390 #include <stdarg.h>
391 #include <string.h>
392 #include <sys/types.h>
393 #include <errno.h>
394
395 #if HAVE_UNISTD_H
396 #include <unistd.h>
397 #endif
398
399 #include <signal.h>             /* include before curses.h to work around glibc bug */
400
401 #if NEED_WCHAR_H
402 #include <wchar.h>
403 #ifdef HAVE_LIBUTF8_H
404 #include <libutf8.h>
405 #endif
406 #endif
407
408 #if defined(HAVE_XCURSES)
409 #include <xcurses.h>
410 #elif defined(HAVE_NCURSESW_NCURSES_H)
411 #include <ncursesw/curses.h>
412 #elif defined(HAVE_NCURSES_NCURSES_H)
413 #include <ncurses/curses.h>
414 #else
415 #include <curses.h>
416 #endif
417
418 #if HAVE_STDNORETURN_H && !defined(NCURSES_VERSION)
419 #include <stdnoreturn.h>
420 #undef GCC_NORETURN
421 #define GCC_NORETURN _Noreturn
422 #endif
423
424 #if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT))
425 #undef KEY_EVENT                /* reduce compiler-warnings with Visual C++ */
426 #endif
427
428 #if defined(HAVE_XCURSES) || defined(PDCURSES)
429 /* no other headers */
430 #undef  HAVE_SETUPTERM          /* nonfunctional */
431 #define HAVE_SETUPTERM 0
432 #undef  HAVE_TGETENT            /* nonfunctional */
433 #define HAVE_TGETENT 0
434 #undef  HAVE_TIGETSTR           /* nonfunctional */
435 #define HAVE_TIGETSTR 0
436 #elif defined(HAVE_NCURSESW_TERM_H)
437 #include <ncursesw/term.h>
438 #elif defined(HAVE_NCURSES_TERM_H)
439 #include <ncurses/term.h>
440 #elif defined(HAVE_TERM_H)
441 #include <term.h>
442 #endif
443
444 /*
445  * Not all curses.h implementations include unctrl.h,
446  */
447 #if defined(HAVE_NCURSESW_UNCTRL_H)
448 #include <ncursesw/unctrl.h>
449 #elif defined(HAVE_NCURSES_UNCTRL_H)
450 #include <ncurses/unctrl.h>
451 #elif defined(HAVE_UNCTRL_H)
452 #include <unctrl.h>
453 #endif
454
455 #if HAVE_GETOPT_H
456 #include <getopt.h>
457 #elif !defined(HAVE_GETOPT_HEADER)
458 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
459  * doesn't hurt.
460  */
461 extern char *optarg;
462 extern int optind;
463 #endif /* HAVE_GETOPT_H */
464
465 #if HAVE_LOCALE_H
466 #include <locale.h>
467 #else
468 #define setlocale(name,string)  /* nothing */
469 #endif
470
471 #include <assert.h>
472 #include <ctype.h>
473
474 #if defined(_MSC_VER)
475 #undef popen
476 #define popen(s,n) _popen(s,n)
477 #undef pclose
478 #define pclose(s) _pclose(s)
479 #endif
480
481 #ifndef GCC_NORETURN
482 #define GCC_NORETURN            /* nothing */
483 #endif
484 #ifndef GCC_PRINTFLIKE
485 #define GCC_PRINTFLIKE(a,b)     /* nothing */
486 #endif
487 #ifndef GCC_SCANFLIKE
488 #define GCC_SCANFLIKE(a,b)      /* nothing */
489 #endif
490 #ifndef GCC_UNUSED
491 #define GCC_UNUSED              /* nothing */
492 #endif
493
494 #ifndef HAVE_GETNSTR
495 #define getnstr(s,n) getstr(s)
496 #endif
497
498 #if HAVE_INIT_EXTENDED_COLOR
499 #define USE_EXTENDED_COLOR 1
500 #else
501 #define USE_EXTENDED_COLOR 0
502 #endif
503
504 #ifndef USE_SOFTKEYS
505 #if HAVE_SLK_INIT
506 #define USE_SOFTKEYS 1
507 #else
508 #define USE_SOFTKEYS 0
509 #endif
510 #endif
511
512 #if !USE_SOFTKEYS
513 #define slk_init()              /* nothing */
514 #define slk_restore()           /* nothing */
515 #define slk_clear()             /* nothing */
516 #endif
517
518 #ifndef HAVE_CURSES_DATA_TABSIZE
519 #define HAVE_CURSES_DATA_TABSIZE 0
520 #endif
521
522 #if !NCURSES_EXT_FUNCS
523 #if HAVE_CURSES_DATA_TABSIZE
524 #define set_tabsize(n)  TABSIZE = (n)
525 #else
526 #define set_tabsize(n)          /* nothing */
527 #endif
528 #endif
529
530 #if HAVE_TPUTS_SP
531 #define USE_SP_FUNCS 1
532 #else
533 #define USE_SP_FUNCS 0
534 #endif
535
536 #ifndef HAVE_WSYNCDOWN
537 #define wsyncdown(win)          /* nothing */
538 #endif
539
540 #ifndef USE_WIDEC_SUPPORT
541 #if (defined(_XOPEN_SOURCE_EXTENDED) \
542   || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) \
543   || (defined(NCURSES_WIDECHAR) && (NCURSES_WIDECHAR - 0 < 1))) \
544   && defined(WACS_ULCORNER)
545 #define USE_WIDEC_SUPPORT 1
546 #else
547 #define USE_WIDEC_SUPPORT 0
548 #endif
549 #endif
550
551 #if HAVE_PANEL_H && HAVE_LIBPANEL
552 #define USE_LIBPANEL 1
553 #else
554 #define USE_LIBPANEL 0
555 #endif
556
557 #if HAVE_MENU_H && HAVE_LIBMENU
558 #define USE_LIBMENU 1
559 #else
560 #define USE_LIBMENU 0
561 #endif
562
563 #if HAVE_FORM_H && HAVE_LIBFORM
564 #define USE_LIBFORM 1
565 #else
566 #define USE_LIBFORM 0
567 #endif
568
569 /* workaround, to build against NetBSD's variant of the form library */
570 #ifdef HAVE_NETBSD_FORM_H
571 #define form_getyx(form, y, x) y = (int)current_field(form)->cursor_ypos, x = (int)current_field(form)->cursor_xpos
572 #define form_field_row(field) (field)->form_row
573 #define form_field_col(field) (field)->form_col
574 #else /* e.g., SVr4, ncurses */
575 #define form_getyx(form, y, x) y = (int)(form)->currow, x = (int)(form)->curcol
576 #define form_field_row(field) (field)->frow
577 #define form_field_col(field) (field)->fcol
578 #endif
579
580 /* workaround, to build against NetBSD's variant of the form library */
581 #ifdef HAVE_NETBSD_MENU_H
582 #define menu_itemwidth(menu) (menu)->max_item_width
583 #else
584 #define menu_itemwidth(menu) (menu)->itemlen
585 #endif
586
587 #ifndef HAVE_TYPE_ATTR_T
588 #if !USE_WIDEC_SUPPORT && !defined(attr_t)
589 #define attr_t chtype
590 #endif
591 #endif
592
593 #undef NCURSES_CH_T
594 #if !USE_WIDEC_SUPPORT
595 #define NCURSES_CH_T chtype
596 #else
597 #define NCURSES_CH_T cchar_t
598 #endif
599
600 #ifndef NCURSES_COLOR_T
601 #define NCURSES_COLOR_T short
602 #endif
603
604 #ifndef NCURSES_PAIRS_T
605 #define NCURSES_PAIRS_T short
606 #endif
607
608 #ifndef CCHARW_MAX
609 #define CCHARW_MAX 5
610 #endif
611
612 #if defined(NCURSES_VERSION) && defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
613 #define CURSES_WACS_SYMBOLS
614 #endif
615
616 #if defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
617 /* NetBSD 5.1 defines these incorrectly */
618 #undef  WACS_RARROW
619 #undef  WACS_LARROW
620 #undef  WACS_UARROW
621 #undef  WACS_DARROW
622 #undef  WACS_BLOCK
623 #undef  WACS_DIAMOND
624 #undef  WACS_CKBOARD
625 #undef  WACS_DEGREE
626 #undef  WACS_PLMINUS
627 #undef  WACS_BOARD
628 #undef  WACS_LANTERN
629 #undef  WACS_LRCORNER
630 #undef  WACS_URCORNER
631 #undef  WACS_ULCORNER
632 #undef  WACS_LLCORNER
633 #undef  WACS_PLUS
634 #undef  WACS_HLINE
635 #undef  WACS_S1
636 #undef  WACS_S9
637 #undef  WACS_LTEE
638 #undef  WACS_RTEE
639 #undef  WACS_BTEE
640 #undef  WACS_TTEE
641 #undef  WACS_VLINE
642 #undef  WACS_BULLET
643 #undef  WACS_S3
644 #undef  WACS_S7
645 #undef  WACS_LEQUAL
646 #undef  WACS_GEQUAL
647 #undef  WACS_PI
648 #undef  WACS_NEQUAL
649 #undef  WACS_STERLING
650
651 #define WACS_RARROW     &(CURSES_WACS_ARRAY['+'])
652 #define WACS_LARROW     &(CURSES_WACS_ARRAY[','])
653 #define WACS_UARROW     &(CURSES_WACS_ARRAY['-'])
654 #define WACS_DARROW     &(CURSES_WACS_ARRAY['.'])
655 #define WACS_BLOCK      &(CURSES_WACS_ARRAY['0'])
656 #define WACS_DIAMOND    &(CURSES_WACS_ARRAY['`'])
657 #define WACS_CKBOARD    &(CURSES_WACS_ARRAY['a'])
658 #define WACS_DEGREE     &(CURSES_WACS_ARRAY['f'])
659 #define WACS_PLMINUS    &(CURSES_WACS_ARRAY['g'])
660 #define WACS_BOARD      &(CURSES_WACS_ARRAY['h'])
661 #define WACS_LANTERN    &(CURSES_WACS_ARRAY['i'])
662 #define WACS_LRCORNER   &(CURSES_WACS_ARRAY['j'])
663 #define WACS_URCORNER   &(CURSES_WACS_ARRAY['k'])
664 #define WACS_ULCORNER   &(CURSES_WACS_ARRAY['l'])
665 #define WACS_LLCORNER   &(CURSES_WACS_ARRAY['m'])
666 #define WACS_PLUS       &(CURSES_WACS_ARRAY['n'])
667 #define WACS_HLINE      &(CURSES_WACS_ARRAY['q'])
668 #define WACS_S1         &(CURSES_WACS_ARRAY['o'])
669 #define WACS_S9         &(CURSES_WACS_ARRAY['s'])
670 #define WACS_LTEE       &(CURSES_WACS_ARRAY['t'])
671 #define WACS_RTEE       &(CURSES_WACS_ARRAY['u'])
672 #define WACS_BTEE       &(CURSES_WACS_ARRAY['v'])
673 #define WACS_TTEE       &(CURSES_WACS_ARRAY['w'])
674 #define WACS_VLINE      &(CURSES_WACS_ARRAY['x'])
675 #define WACS_BULLET     &(CURSES_WACS_ARRAY['~'])
676 #define WACS_S3         &(CURSES_WACS_ARRAY['p'])
677 #define WACS_S7         &(CURSES_WACS_ARRAY['r'])
678 #define WACS_LEQUAL     &(CURSES_WACS_ARRAY['y'])
679 #define WACS_GEQUAL     &(CURSES_WACS_ARRAY['z'])
680 #define WACS_PI         &(CURSES_WACS_ARRAY['{'])
681 #define WACS_NEQUAL     &(CURSES_WACS_ARRAY['|'])
682 #define WACS_STERLING   &(CURSES_WACS_ARRAY['}'])
683 #endif
684
685 #ifndef WA_NORMAL
686 #define WA_NORMAL       A_NORMAL
687 #endif
688 #ifndef WA_BOLD
689 #define WA_BOLD         A_BOLD
690 #endif
691 #ifndef WA_REVERSE
692 #define WA_REVERSE      A_REVERSE
693 #endif
694 #ifndef WA_UNDERLINE
695 #define WA_UNDERLINE    A_UNDERLINE
696 #endif
697 #ifndef WA_BLINK
698 #define WA_BLINK        A_BLINK
699 #endif
700
701 #ifndef OK
702 #define OK (0)
703 #endif
704
705 #ifndef ERR
706 #define ERR (-1)
707 #endif
708
709 #undef CTRL
710 #define CTRL(x) ((x) & 0x1f)
711
712 #define QUIT            CTRL('Q')
713 #define ESCAPE          CTRL('[')
714
715 #ifndef KEY_MIN
716 #define KEY_MIN 256             /* not defined in Solaris 8 */
717 #endif
718
719 #define HELP_KEY_1      '?'
720 #define HELP_KEY_2      KEY_F(1)
721
722 /* our "standard" options for getopt, needed for help2man */
723 #define OPTS_USAGE      'h'
724 #define OPTS_VERSION    'V'
725 #define OPTS_COMMON     "hV"
726 #define USAGE_COMMON    \
727  "Common options:"\
728 ," -h       show this message"\
729 ," -V       show version of curses"
730
731 #if HAVE_CURSES_VERSION
732 #define format_version(buffer) strcpy(buffer, curses_version())
733 #elif defined(NCURSES_VERSION_MAJOR) && defined(NCURSES_VERSION_MINOR) && defined(NCURSES_VERSION_PATCH)
734 #define format_version(buffer) sprintf(buffer, "ncurses %d.%d.%d", \
735         NCURSES_VERSION_MAJOR, \
736         NCURSES_VERSION_MINOR, \
737         NCURSES_VERSION_PATCH)
738 #else
739 #define format_version(buffer) strcpy(buffer, "ncurses-examples")
740 #endif
741
742 #define VERSION_COMMON() \
743 static char *version_common(char **argv) { \
744         char *base = argv[0]; \
745         char *leaf = strrchr(base, '/'); \
746         char *result = malloc(strlen(base) + 80); \
747         if (result == NULL) { \
748             static char unknown[] = "?"; \
749             result = unknown; \
750         } else { \
751             if (leaf++ == NULL) leaf = base; \
752             sprintf(result, "%.20s: ", leaf); \
753             format_version(result + strlen(result)); \
754         } \
755         return result; \
756 } \
757 static void show_version(char **argv) { \
758         char *value = version_common(argv); \
759         if (value != NULL) { \
760             puts(value); \
761             free(value); \
762         } \
763 }
764
765 /* from nc_string.h, to make this stand alone */
766 #if HAVE_BSD_STRING_H
767 #include <bsd/string.h>
768 #endif
769
770 #ifdef __cplusplus
771 #define NCURSES_VOID            /* nothing */
772 #else
773 #define NCURSES_VOID (void)
774 #endif
775
776 #ifndef HAVE_STRLCAT
777 #define HAVE_STRLCAT 0
778 #endif
779
780 #ifndef HAVE_STRLCPY
781 #define HAVE_STRLCPY 0
782 #endif
783
784 #ifndef HAVE_SNPRINTF
785 #define HAVE_SNPRINTF 0
786 #endif
787
788 #ifndef HAVE_STRDUP
789 #define HAVE_STRDUP 0
790 #endif
791
792 #ifndef USE_STRING_HACKS
793 #define USE_STRING_HACKS 0
794 #endif
795
796 #ifndef HAVE_STRSTR
797 #define HAVE_STRSTR 0
798 #endif
799
800 #ifndef NCURSES_CAST
801 #ifdef __cplusplus
802 extern "C" {
803 #define NCURSES_CAST(type,value) static_cast<type>(value)
804 #else
805 #define NCURSES_CAST(type,value) (type)(value)
806 #endif
807 #endif
808
809 #if USE_STRING_HACKS && HAVE_STRLCAT
810 #define _nc_STRCAT(d,s,n)       NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n))
811 #define _nc_STRNCAT(d,s,m,n)    NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m))
812 #else
813 #define _nc_STRCAT(d,s,n)       NCURSES_VOID strcat((d),(s))
814 #define _nc_STRNCAT(d,s,m,n)    NCURSES_VOID strncat((d),(s),(n))
815 #endif
816
817 #if USE_STRING_HACKS && HAVE_STRLCPY
818 #define _nc_STRCPY(d,s,n)       NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
819 #define _nc_STRNCPY(d,s,n)      NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
820 #else
821 #define _nc_STRCPY(d,s,n)       NCURSES_VOID strcpy((d),(s))
822 #define _nc_STRNCPY(d,s,n)      NCURSES_VOID strncpy((d),(s),(n))
823 #endif
824
825 #if USE_STRING_HACKS && HAVE_SNPRINTF
826 #define _nc_SPRINTF             NCURSES_VOID (snprintf)
827 #define _nc_SLIMIT(n)           NCURSES_CAST(size_t,n),
828 #else
829 #define _nc_SPRINTF             NCURSES_VOID (sprintf)
830 #define _nc_SLIMIT(n)           /* nothing */
831 #endif
832
833 /*
834  * X/Open Curses does not define the arrays of terminfo/termcap names as SVr4
835  * curses did, and some implementations provide them anyway, but undeclared.
836  */
837 #ifdef DECL_CURSES_DATA_BOOLNAMES
838 extern char *boolnames[], *boolcodes[], *boolfnames[];
839 extern char *numnames[], *numcodes[], *numfnames[];
840 extern char *strnames[], *strcodes[], *strfnames[];
841 #endif
842
843 /*
844  * Again, an SVr4 curses feature latent in the libraries but not in headers.
845  */
846 #ifndef DECL_CURSES_DATA_TABSIZE
847 #define DECL_CURSES_DATA_TABSIZE 0
848 #endif
849
850 #if DECL_CURSES_DATA_TABSIZE
851 extern int TABSIZE;
852 #undef  HAVE_CURSES_DATA_TABSIZE
853 #define HAVE_CURSES_DATA_TABSIZE 1
854 #endif
855
856 #ifndef HAVE_CURSES_DATA_TABSIZE
857 #define HAVE_CURSES_DATA_TABSIZE 0
858 #endif
859
860 /*
861  * X/Open Curses provides termname(), whose return value is analogous to the
862  * SVr4 curses variable ttytype[].
863  */
864 #ifndef HAVE_CURSES_DATA_TTYTYPE
865 #define HAVE_CURSES_DATA_TTYTYPE 0
866 #endif
867
868 #ifndef DECL_CURSES_DATA_TTYTYPE
869 #define DECL_CURSES_DATA_TTYTYPE 0
870 #endif
871
872 #if !defined(ttytype) && (!HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE)
873 #define ttytype termname()
874 #endif
875
876 #define colored_chtype(ch, attr, pair) \
877         ((chtype) (ch) | (chtype) (attr) | (chtype) COLOR_PAIR(pair))
878
879 /*
880  * Workaround for HPUX
881  */
882 #if defined(__hpux) && !defined(NCURSES_VERSION)
883 #define getbegx(w) __getbegx(w)
884 #define getbegy(w) __getbegy(w)
885 #define getcurx(w) __getcurx(w)
886 #define getcury(w) __getcury(w)
887 #define getmaxx(w) __getmaxx(w)
888 #define getmaxy(w) __getmaxy(w)
889 #define getparx(w) __getparx(w)
890 #define getpary(w) __getpary(w)
891 #endif
892
893 /*
894  * Workaround in case getcchar() returns a positive value when the source
895  * string produces only a L'\0'.
896  */
897 #define TEST_CCHAR(s, count, then_stmt, else_stmt) \
898         if ((count = getcchar(s, NULL, NULL, NULL, NULL)) > 0) { \
899             wchar_t test_wch[CCHARW_MAX + 2]; \
900             attr_t test_attrs; \
901             NCURSES_PAIRS_T test_pair; \
902             \
903             if (getcchar( s, test_wch, &test_attrs, &test_pair, NULL) == OK \
904                 && test_wch[0] != L'\0') { \
905                 then_stmt \
906             } else { \
907                 else_stmt \
908             } \
909         } else { \
910             else_stmt \
911         }
912 /*
913  * These usually are implemented as macros, but may be functions.
914  */
915 #if !defined(getcurx) && !HAVE_GETCURX
916 #define getcurx(win)            ((win) ? ((int)(win)->_curx) : ERR)
917 #define getcury(win)            ((win) ? ((int)(win)->_cury) : ERR)
918 #endif
919
920 #if !defined(getbegx) && !HAVE_GETBEGX
921 #define getbegx(win)            ((win) ? ((int)(win)->_begx) : ERR)
922 #define getbegy(win)            ((win) ? ((int)(win)->_begy) : ERR)
923 #endif
924
925 #if !defined(getmaxx) && !HAVE_GETMAXX
926 #define getmaxx(win)            ((win) ? ((int)(win)->_maxx + 1) : ERR)
927 #define getmaxy(win)            ((win) ? ((int)(win)->_maxy + 1) : ERR)
928 #endif
929
930 /*
931  * Solaris 10 xpg4:
932 #define __m_getparx(w)          ((w)->_parent == (WINDOW *) 0 ? -1 \
933                                 : (w)->_begx - (w)->_parent->_begx)
934  */
935 #if !defined(getparx) && !HAVE_GETPARX
936 #ifdef __m_getparx
937 #define getparx(win)            __m_getparx(win)
938 #define getpary(win)            __m_getpary(win)
939 #else
940 #define getparx(win)            ((win)?((win)->_parx + 1):ERR)
941 #define getpary(win)            ((win)?((win)->_pary + 1):ERR)
942 #endif
943 #endif
944
945 #if !defined(mvwvline) && !HAVE_MVWVLINE
946 #define mvwvline(w,y,x,ch,n)    (move(y,x) == ERR ? ERR : wvline(w,ch,n))
947 #define mvwhline(w,y,x,ch,n)    (move(y,x) == ERR ? ERR : whline(w,ch,n))
948 #endif
949
950 #if !defined(mvvline) && !HAVE_MVVLINE
951 #define mvvline(y,x,ch,n)       (move(y,x) == ERR ? ERR : vline(ch,n))
952 #define mvhline(y,x,ch,n)       (move(y,x) == ERR ? ERR : hline(ch,n))
953 #endif
954
955 /*
956  * Try to accommodate curses implementations that have no terminfo support.
957  */
958 #if HAVE_TIGETNUM
959 #define TIGETNUM(ti,tc) tigetnum(ti)
960 #else
961 #define TIGETNUM(ti,tc) tgetnum(tc)
962 #endif
963
964 #if HAVE_TIGETSTR
965 #define TIGETSTR(ti,tc) tigetstr(ti)
966 #else
967 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
968 #endif
969
970 /*
971  * So far (2013 - more than ten years), only ncurses implements
972  * use_extended_names().
973  */
974 #if defined(NCURSES_XNAMES)
975 #elif defined(NCURSES_VERSION) && defined(HAVE_TERM_ENTRY_H) && HAVE_TERM_ENTRY_H
976 #define NCURSES_XNAMES 1
977 #else
978 #define NCURSES_XNAMES 0
979 #endif
980
981 /*
982  * ncurses restores the cursor in endwin().  Other libraries may not.
983  */
984 #ifdef NCURSES_VERSION
985 #define stop_curses() endwin()
986 #else
987 #define stop_curses() do { endwin(); curs_set(1); } while (0)
988 #endif
989
990 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
991  * (which is incompatible with legacy usage, doesn't solve any problems).
992  */
993 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
994 #define tparm2(a,b)   tparm(a,b,0,0,0,0,0,0,0,0)
995
996 #define UChar(c)    ((unsigned char)(c))
997
998 #define SIZEOF(table)   (sizeof(table)/sizeof(table[0]))
999
1000 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
1001 #include <nc_alloc.h>
1002 #if HAVE_EXIT_TERMINFO && !defined(USE_CURSES) && (defined(USE_TERMINFO) || defined(USE_TINFO))
1003 #undef ExitProgram
1004 #define ExitProgram(code) exit_terminfo(code)
1005 #elif HAVE_EXIT_CURSES
1006 #undef ExitProgram
1007 #define ExitProgram(code) exit_curses(code)
1008 #endif
1009 #else /* not ncurses-tree */
1010 #define typeMalloc(type,n) (type *) malloc((size_t)(n) * sizeof(type))
1011 #define typeCalloc(type,elts) (type *) calloc((size_t)(elts), sizeof(type))
1012 #define typeRealloc(type,n,p) (type *) realloc(p, (size_t)(n) * sizeof(type))
1013 #endif
1014
1015 #ifndef ExitProgram
1016 #define ExitProgram(code) exit(code)
1017 #endif
1018
1019 #ifndef EXIT_SUCCESS
1020 #define EXIT_SUCCESS 0
1021 #endif
1022 #ifndef EXIT_FAILURE
1023 #define EXIT_FAILURE 1
1024 #endif
1025
1026 #undef _NC_WINDOWS
1027 #if (defined(_WIN32) || defined(_WIN64))
1028 #define _NC_WINDOWS 1
1029 #endif
1030
1031 #if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
1032
1033 #if defined(PDCURSES)
1034 #ifdef WINVER
1035 #  if WINVER < 0x0501
1036 #    error WINVER must at least be 0x0501
1037 #  endif
1038 #else
1039 #  define WINVER 0x0501
1040 #endif
1041 #include <windows.h>
1042 #include <sys/time.h>           /* for struct timeval */
1043 #undef sleep
1044 #define sleep(n) Sleep((n) * 1000)
1045 #define SIGHUP  1
1046 #define SIGKILL 9
1047 #define getlogin() "username"
1048
1049 #elif defined(EXP_WIN32_DRIVER)
1050
1051 #if defined(HAVE_NCURSESW_NCURSES_H)
1052 #include <ncursesw/nc_win32.h>
1053 #elif defined(HAVE_NCURSES_NCURSES_H)
1054 #include <ncurses/nc_win32.h>
1055 #else
1056 #include <nc_win32.h>
1057 #endif
1058
1059 #else
1060
1061 #if defined(HAVE_NCURSESW_NCURSES_H)
1062 #include <ncursesw/nc_mingw.h>
1063 #elif defined(HAVE_NCURSES_NCURSES_H)
1064 #include <ncurses/nc_mingw.h>
1065 #else
1066 #include <nc_mingw.h>
1067 #endif
1068
1069 #endif
1070
1071 /* conflicts in test/firstlast.c */
1072 #undef large
1073 #undef small
1074
1075 #endif
1076
1077 #ifdef NEED_TIME_H
1078 #if TIME_WITH_SYS_TIME
1079 # include <sys/time.h>
1080 # include <time.h>
1081 #else
1082 # if HAVE_SYS_TIME_H
1083 #  include <sys/time.h>
1084 # else
1085 #  include <time.h>
1086 # endif
1087 #endif
1088 #endif
1089
1090 #if HAVE_CLOCK_GETTIME
1091 # define GetClockTime(t) clock_gettime(CLOCK_REALTIME, t)
1092 # define TimeType struct timespec
1093 # define TimeScale 1000000000L          /* 1e9 */
1094 # define ElapsedSeconds(b,e) \
1095             (double) (((e)->tv_sec - (b)->tv_sec) \
1096                     + ((e)->tv_nsec - (b)->tv_nsec) / TimeScale)
1097 #elif HAVE_GETTIMEOFDAY
1098 # define GetClockTime(t) gettimeofday(t, 0)
1099 # define TimeType struct timeval
1100 # define TimeScale 1000000L             /* 1e6 */
1101 # define ElapsedSeconds(b,e) \
1102             (double) (((e)->tv_sec - (b)->tv_sec) \
1103                     + ((e)->tv_usec - (b)->tv_usec) / TimeScale)
1104 #else
1105 # define TimeType time_t
1106 # define GetClockTime(t) time((time_t*)0)
1107 # define ElapsedSeconds(b,e) (double)((e) - (b))
1108 #endif
1109
1110 /*
1111  * Ultrix 3.1
1112  */
1113 #ifndef STDOUT_FILENO
1114 #define STDOUT_FILENO 1
1115 #endif
1116
1117 #if !HAVE_STRSTR
1118 extern char *_nc_strstr(const char *, const char *);
1119 #define strstr(a,b) _nc_strstr((a),(b))
1120 #endif /* !HAVE_STRSTR */
1121
1122 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
1123  * curses which doesn't have const parameters declared (so far) in the places
1124  * that XSI shows.
1125  */
1126 #ifndef NCURSES_CONST
1127 #ifdef PDCURSES
1128 #define NCURSES_CONST           const   /* close enough */
1129 #else
1130 #define NCURSES_CONST           /* nothing */
1131 #endif
1132 #endif
1133
1134 /* out-of-band values for representing absent capabilities */
1135 #define ABSENT_BOOLEAN          ((signed char)-1)       /* 255 */
1136 #define ABSENT_NUMERIC          (-1)
1137 #define ABSENT_STRING           (char *)0
1138
1139 /* out-of-band values for representing cancels */
1140 #define CANCELLED_BOOLEAN       ((signed char)-2)       /* 254 */
1141 #define CANCELLED_NUMERIC       (-2)
1142 #define CANCELLED_STRING        (char *)(-1)
1143
1144 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1)      /* reject "-1" */
1145 #define VALID_NUMERIC(s) ((s) >= 0)
1146 #define VALID_STRING(s)  ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
1147
1148 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
1149
1150 #define CATCHALL(handler) do { \
1151                 int nsig; \
1152                 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
1153                     if (nsig != SIGKILL) \
1154                         signal(nsig, handler); \
1155             } while(0)
1156
1157 #ifdef NCURSES_VERSION
1158 #define InitAndCatch(init,handler) do { CATCHALL(handler); init; } while (0)
1159 #else
1160 #define InitAndCatch(init,handler) do { init; CATCHALL(handler); } while (0)
1161 #endif
1162
1163 #if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
1164 #define SetupAlarm(opt) (void)opt
1165 #else
1166 #define SetupAlarm(opt) if (opt) alarm((unsigned)opt)
1167 #endif
1168
1169 /*
1170  * Workaround for clean(er) compile with Solaris's legacy curses.
1171  * The same would be needed for HPUX 10.20
1172  */
1173 #ifndef TPUTS_ARG
1174 #define TPUTS_ARG int
1175 #endif
1176
1177 #if defined(sun) && !defined(_XOPEN_CURSES) && !defined(NCURSES_VERSION_PATCH)
1178 #undef TPUTS_ARG
1179 #define TPUTS_ARG char
1180 extern char *tgoto(char *, int, int);   /* available, but not prototyped */
1181 #endif
1182
1183 #ifndef TPUTS_PROTO
1184 #define TPUTS_PROTO(func,value) int func(TPUTS_ARG value)
1185 #endif
1186
1187 #ifndef TPUTS_RETURN
1188 #define TPUTS_RETURN(value) return value
1189 #endif
1190
1191 /*
1192  * Workarounds for Solaris's X/Open curses
1193  */
1194 #if !defined(KEY_MIN) && defined(__KEY_MIN)
1195 #define KEY_MIN __KEY_MIN
1196 #endif
1197 #if !defined(KEY_MAX) && defined(__KEY_MIN)
1198 #define KEY_MAX __KEY_MAX
1199 #endif
1200
1201 /*
1202  * Workaround to build with Sun's default SVr4 curses.
1203  */
1204 #ifdef NCURSES_VERSION
1205 #ifndef HAVE_VW_PRINTW
1206 #define HAVE_VW_PRINTW 1
1207 #endif
1208 #endif
1209
1210 /*
1211  * ncurses provides arrays of capability names; X/Open discarded these SVr4
1212  * features.  Some implementations continue to provide them (see the test
1213  * configure script).
1214  */
1215 #ifdef NCURSES_VERSION
1216 #ifndef HAVE_CURSES_DATA_BOOLNAMES
1217 #define HAVE_CURSES_DATA_BOOLNAMES 1
1218 #endif
1219 #endif
1220
1221 /*
1222  * ncurses provides a termcap interface; a few packagers replace or displace
1223  * its header file with an incompatible one.  The demo_termcap program uses
1224  * the ncurses file, if available.
1225  */
1226 #ifdef NCURSES_VERSION
1227 #ifndef HAVE_NCURSES_TERMCAP_H
1228 #define HAVE_NCURSES_TERMCAP_H 0
1229 #endif
1230 #ifndef HAVE_TERMCAP_H
1231 #define HAVE_TERMCAP_H 0
1232 #endif
1233 #endif
1234
1235 /*
1236  * ncurses uses const in some places where X/Open does (or did) not allow.
1237  */
1238 #if defined(NCURSES_CONST)
1239 #define CONST_MENUS NCURSES_CONST
1240 #elif defined(PDCURSES)
1241 #define CONST_MENUS const
1242 #else
1243 #define CONST_MENUS             /* nothing */
1244 #endif
1245
1246 #if defined(NCURSES_CONST)
1247 #define CONST_FMT NCURSES_CONST
1248 #elif defined(PDCURSES)
1249 #define CONST_FMT const
1250 #else
1251 #define CONST_FMT               /* nothing */
1252 #endif
1253
1254 /*
1255  * Simplify setting up demo of threading with these macros.
1256  */
1257
1258 #if HAVE_USE_WINDOW
1259 #define USING_WINDOW(w,func) use_window(w, (NCURSES_WINDOW_CB) func, w)
1260 #define USING_WINDOW1(w,func,safe) use_window(w, (NCURSES_WINDOW_CB) safe, NULL)
1261 #define USING_WINDOW2(w,func,data) use_window(w, (NCURSES_WINDOW_CB) func, data)
1262 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
1263 #else
1264 #define USING_WINDOW(w,func) func(w, NULL)
1265 #define USING_WINDOW1(w,func,safe) func(w)
1266 #define USING_WINDOW2(w,func,data) func(w,data)
1267 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
1268 #endif
1269
1270 #if HAVE_USE_WINDOW
1271 #define USING_SCREEN(s,func,data) use_screen(s, (NCURSES_SCREEN_CB) func, data)
1272 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
1273 #else
1274 #define USING_SCREEN(s,func,data) func(data)
1275 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
1276 #endif
1277
1278 #if defined(TRACE) && HAVE__TRACEF && HAVE_CURSES_TRACE
1279 #define Trace(p) _tracef p
1280 #define USE_TRACE 1
1281 #define START_TRACE() \
1282         if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
1283             int t = _nc_getenv_num("NCURSES_TRACE"); \
1284             if (t >= 0) \
1285                 curses_trace((unsigned) t); \
1286         }
1287 extern unsigned _nc_tracing;
1288 extern int _nc_getenv_num(const char *);
1289 #else
1290 #undef TRACE
1291 #define Trace(p)                /* nothing */
1292 #define USE_TRACE 0
1293 #define START_TRACE()           /* nothing */
1294 #endif
1295
1296 #define Trace2(p)               /* nothing */
1297
1298 #define AddCh(c)                (void) addch((chtype)(c))
1299 #define WAddCh(w,c)             (void) waddch((w),(chtype)(c))
1300 #define MvAddCh(y,x,c)          (void) mvaddch((y),(x),(chtype)(c))
1301 #define MvWAddCh(w,y,x,c)       (void) mvwaddch((w),(y),(x),(chtype)(c))
1302 #define MvAddStr(y,x,s)         (void) mvaddstr((y),(x),(s))
1303 #define MvWAddStr(w,y,x,s)      (void) mvwaddstr((w),(y),(x),(s))
1304 #define MvWAddChStr(w,y,x,s)    (void) mvwaddchstr((w),(y),(x),(s))
1305 #define MvPrintw                (void) mvprintw
1306 #define MvWPrintw               (void) mvwprintw
1307 #define MvHLine                 (void) mvhline
1308 #define MvWHLine                (void) mvwhline
1309 #define MvVLine                 (void) mvvline
1310 #define MvWVLine                (void) mvwvline
1311
1312 /*
1313  * The macro likely uses unsigned values, while X/Open prototype uses int.
1314  */
1315 #if defined(wattrset) || defined(PDCURSES)
1316 #define AttrArg(p,a)    (chtype) ((chtype)(p) | (chtype)(a))
1317 #else
1318 #define AttrArg(p,a)    (int) ((chtype)(p) | (chtype)(a))
1319 #endif
1320
1321 /*
1322  * Workaround for defective implementation of gcc attribute warn_unused_result
1323  */
1324 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
1325 #define IGNORE_RC(func) errno = func
1326 #else
1327 #define IGNORE_RC(func) (void) func
1328 #endif /* gcc workarounds */
1329
1330 #define init_mb(state)  memset(&state, 0, sizeof(state))
1331
1332 #endif /* __TEST_PRIV_H */