]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/test.priv.h
ncurses 6.4 - patch 20230415
[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.213 2023/04/15 21:44:58 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 #ifndef HAVE__NC_TPARM_ANALYZE
383 #define HAVE__NC_TPARM_ANALYZE 0
384 #endif
385
386 /*
387  * Workaround for HPUX
388  */
389 #if defined(__hpux) && !defined(NCURSES_VERSION)
390 #define _ACS_COMPAT_CODE        /* needed for acs_map vs __acs_map */
391 #endif
392
393 #include <stdlib.h>
394 #include <stdarg.h>
395 #include <string.h>
396 #include <sys/types.h>
397 #include <errno.h>
398
399 #if HAVE_UNISTD_H
400 #include <unistd.h>
401 #endif
402
403 #include <signal.h>             /* include before curses.h to work around glibc bug */
404
405 #if NEED_WCHAR_H
406 #include <wchar.h>
407 #ifdef HAVE_LIBUTF8_H
408 #include <libutf8.h>
409 #endif
410 #endif
411
412 #if defined(HAVE_XCURSES)
413 #include <xcurses.h>
414 #elif defined(HAVE_NCURSESW_NCURSES_H)
415 #include <ncursesw/curses.h>
416 #elif defined(HAVE_NCURSES_NCURSES_H)
417 #include <ncurses/curses.h>
418 #else
419 #include <curses.h>
420 #endif
421
422 #if HAVE_STDNORETURN_H && !defined(NCURSES_VERSION)
423 #include <stdnoreturn.h>
424 #undef GCC_NORETURN
425 #define GCC_NORETURN _Noreturn
426 #endif
427
428 #if !(defined(NCURSES_WGETCH_EVENTS) && defined(NEED_KEY_EVENT))
429 #undef KEY_EVENT                /* reduce compiler-warnings with Visual C++ */
430 #endif
431
432 #if defined(HAVE_XCURSES) || defined(PDCURSES)
433 /* no other headers */
434 #undef  HAVE_SETUPTERM          /* nonfunctional */
435 #define HAVE_SETUPTERM 0
436 #undef  HAVE_TGETENT            /* nonfunctional */
437 #define HAVE_TGETENT 0
438 #undef  HAVE_TIGETSTR           /* nonfunctional */
439 #define HAVE_TIGETSTR 0
440 #elif defined(HAVE_NCURSESW_TERM_H)
441 #include <ncursesw/term.h>
442 #elif defined(HAVE_NCURSES_TERM_H)
443 #include <ncurses/term.h>
444 #elif defined(HAVE_TERM_H)
445 #include <term.h>
446 #endif
447
448 /*
449  * Not all curses.h implementations include unctrl.h,
450  */
451 #if defined(HAVE_NCURSESW_UNCTRL_H)
452 #include <ncursesw/unctrl.h>
453 #elif defined(HAVE_NCURSES_UNCTRL_H)
454 #include <ncurses/unctrl.h>
455 #elif defined(HAVE_UNCTRL_H)
456 #include <unctrl.h>
457 #endif
458
459 #if HAVE_GETOPT_H
460 #include <getopt.h>
461 #elif !defined(HAVE_GETOPT_HEADER)
462 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
463  * doesn't hurt.
464  */
465 extern char *optarg;
466 extern int optind;
467 #endif /* HAVE_GETOPT_H */
468
469 #if HAVE_LOCALE_H
470 #include <locale.h>
471 #else
472 #define setlocale(name,string)  /* nothing */
473 #endif
474
475 #include <assert.h>
476 #include <ctype.h>
477
478 #if defined(_MSC_VER)
479 #undef popen
480 #define popen(s,n) _popen(s,n)
481 #undef pclose
482 #define pclose(s) _pclose(s)
483 #endif
484
485 #ifndef GCC_NORETURN
486 #define GCC_NORETURN            /* nothing */
487 #endif
488 #ifndef GCC_PRINTFLIKE
489 #define GCC_PRINTFLIKE(a,b)     /* nothing */
490 #endif
491 #ifndef GCC_SCANFLIKE
492 #define GCC_SCANFLIKE(a,b)      /* nothing */
493 #endif
494 #ifndef GCC_UNUSED
495 #define GCC_UNUSED              /* nothing */
496 #endif
497
498 #ifndef HAVE_GETNSTR
499 #define getnstr(s,n) getstr(s)
500 #endif
501
502 #if HAVE_INIT_EXTENDED_COLOR
503 #define USE_EXTENDED_COLOR 1
504 #else
505 #define USE_EXTENDED_COLOR 0
506 #endif
507
508 #ifndef USE_SOFTKEYS
509 #if HAVE_SLK_INIT
510 #define USE_SOFTKEYS 1
511 #else
512 #define USE_SOFTKEYS 0
513 #endif
514 #endif
515
516 #if !USE_SOFTKEYS
517 #define slk_init()              /* nothing */
518 #define slk_restore()           /* nothing */
519 #define slk_clear()             /* nothing */
520 #endif
521
522 #ifndef HAVE_CURSES_DATA_TABSIZE
523 #define HAVE_CURSES_DATA_TABSIZE 0
524 #endif
525
526 #if !NCURSES_EXT_FUNCS
527 #if HAVE_CURSES_DATA_TABSIZE
528 #define set_tabsize(n)  TABSIZE = (n)
529 #else
530 #define set_tabsize(n)          /* nothing */
531 #endif
532 #endif
533
534 #if HAVE_TPUTS_SP
535 #define USE_SP_FUNCS 1
536 #else
537 #define USE_SP_FUNCS 0
538 #endif
539
540 #ifndef HAVE_WSYNCDOWN
541 #define wsyncdown(win)          /* nothing */
542 #endif
543
544 #ifndef USE_WIDEC_SUPPORT
545 #if (defined(_XOPEN_SOURCE_EXTENDED) \
546   || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) \
547   || (defined(NCURSES_WIDECHAR) && (NCURSES_WIDECHAR - 0 < 1))) \
548   && defined(WACS_ULCORNER)
549 #define USE_WIDEC_SUPPORT 1
550 #else
551 #define USE_WIDEC_SUPPORT 0
552 #endif
553 #endif
554
555 #if HAVE_PANEL_H && HAVE_LIBPANEL
556 #define USE_LIBPANEL 1
557 #else
558 #define USE_LIBPANEL 0
559 #endif
560
561 #if HAVE_MENU_H && HAVE_LIBMENU
562 #define USE_LIBMENU 1
563 #else
564 #define USE_LIBMENU 0
565 #endif
566
567 #if HAVE_FORM_H && HAVE_LIBFORM
568 #define USE_LIBFORM 1
569 #else
570 #define USE_LIBFORM 0
571 #endif
572
573 /* workaround, to build against NetBSD's variant of the form library */
574 #ifdef HAVE_NETBSD_FORM_H
575 #define form_getyx(form, y, x) y = (int)current_field(form)->cursor_ypos, x = (int)current_field(form)->cursor_xpos
576 #define form_field_row(field) (field)->form_row
577 #define form_field_col(field) (field)->form_col
578 #else /* e.g., SVr4, ncurses */
579 #define form_getyx(form, y, x) y = (int)(form)->currow, x = (int)(form)->curcol
580 #define form_field_row(field) (field)->frow
581 #define form_field_col(field) (field)->fcol
582 #endif
583
584 /* workaround, to build against NetBSD's variant of the form library */
585 #ifdef HAVE_NETBSD_MENU_H
586 #define menu_itemwidth(menu) (menu)->max_item_width
587 #else
588 #define menu_itemwidth(menu) (menu)->itemlen
589 #endif
590
591 #ifndef HAVE_TYPE_ATTR_T
592 #if !USE_WIDEC_SUPPORT && !defined(attr_t)
593 #define attr_t chtype
594 #endif
595 #endif
596
597 #undef NCURSES_CH_T
598 #if !USE_WIDEC_SUPPORT
599 #define NCURSES_CH_T chtype
600 #else
601 #define NCURSES_CH_T cchar_t
602 #endif
603
604 #ifndef NCURSES_COLOR_T
605 #define NCURSES_COLOR_T short
606 #endif
607
608 #ifndef NCURSES_PAIRS_T
609 #define NCURSES_PAIRS_T short
610 #endif
611
612 #ifndef CCHARW_MAX
613 #define CCHARW_MAX 5
614 #endif
615
616 #if defined(NCURSES_VERSION) && defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
617 #define CURSES_WACS_SYMBOLS
618 #endif
619
620 #if defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
621 /* NetBSD 5.1 defines these incorrectly */
622 #undef  WACS_RARROW
623 #undef  WACS_LARROW
624 #undef  WACS_UARROW
625 #undef  WACS_DARROW
626 #undef  WACS_BLOCK
627 #undef  WACS_DIAMOND
628 #undef  WACS_CKBOARD
629 #undef  WACS_DEGREE
630 #undef  WACS_PLMINUS
631 #undef  WACS_BOARD
632 #undef  WACS_LANTERN
633 #undef  WACS_LRCORNER
634 #undef  WACS_URCORNER
635 #undef  WACS_ULCORNER
636 #undef  WACS_LLCORNER
637 #undef  WACS_PLUS
638 #undef  WACS_HLINE
639 #undef  WACS_S1
640 #undef  WACS_S9
641 #undef  WACS_LTEE
642 #undef  WACS_RTEE
643 #undef  WACS_BTEE
644 #undef  WACS_TTEE
645 #undef  WACS_VLINE
646 #undef  WACS_BULLET
647 #undef  WACS_S3
648 #undef  WACS_S7
649 #undef  WACS_LEQUAL
650 #undef  WACS_GEQUAL
651 #undef  WACS_PI
652 #undef  WACS_NEQUAL
653 #undef  WACS_STERLING
654
655 #define WACS_RARROW     &(CURSES_WACS_ARRAY['+'])
656 #define WACS_LARROW     &(CURSES_WACS_ARRAY[','])
657 #define WACS_UARROW     &(CURSES_WACS_ARRAY['-'])
658 #define WACS_DARROW     &(CURSES_WACS_ARRAY['.'])
659 #define WACS_BLOCK      &(CURSES_WACS_ARRAY['0'])
660 #define WACS_DIAMOND    &(CURSES_WACS_ARRAY['`'])
661 #define WACS_CKBOARD    &(CURSES_WACS_ARRAY['a'])
662 #define WACS_DEGREE     &(CURSES_WACS_ARRAY['f'])
663 #define WACS_PLMINUS    &(CURSES_WACS_ARRAY['g'])
664 #define WACS_BOARD      &(CURSES_WACS_ARRAY['h'])
665 #define WACS_LANTERN    &(CURSES_WACS_ARRAY['i'])
666 #define WACS_LRCORNER   &(CURSES_WACS_ARRAY['j'])
667 #define WACS_URCORNER   &(CURSES_WACS_ARRAY['k'])
668 #define WACS_ULCORNER   &(CURSES_WACS_ARRAY['l'])
669 #define WACS_LLCORNER   &(CURSES_WACS_ARRAY['m'])
670 #define WACS_PLUS       &(CURSES_WACS_ARRAY['n'])
671 #define WACS_HLINE      &(CURSES_WACS_ARRAY['q'])
672 #define WACS_S1         &(CURSES_WACS_ARRAY['o'])
673 #define WACS_S9         &(CURSES_WACS_ARRAY['s'])
674 #define WACS_LTEE       &(CURSES_WACS_ARRAY['t'])
675 #define WACS_RTEE       &(CURSES_WACS_ARRAY['u'])
676 #define WACS_BTEE       &(CURSES_WACS_ARRAY['v'])
677 #define WACS_TTEE       &(CURSES_WACS_ARRAY['w'])
678 #define WACS_VLINE      &(CURSES_WACS_ARRAY['x'])
679 #define WACS_BULLET     &(CURSES_WACS_ARRAY['~'])
680 #define WACS_S3         &(CURSES_WACS_ARRAY['p'])
681 #define WACS_S7         &(CURSES_WACS_ARRAY['r'])
682 #define WACS_LEQUAL     &(CURSES_WACS_ARRAY['y'])
683 #define WACS_GEQUAL     &(CURSES_WACS_ARRAY['z'])
684 #define WACS_PI         &(CURSES_WACS_ARRAY['{'])
685 #define WACS_NEQUAL     &(CURSES_WACS_ARRAY['|'])
686 #define WACS_STERLING   &(CURSES_WACS_ARRAY['}'])
687 #endif
688
689 #ifndef WA_NORMAL
690 #define WA_NORMAL       A_NORMAL
691 #endif
692 #ifndef WA_BOLD
693 #define WA_BOLD         A_BOLD
694 #endif
695 #ifndef WA_REVERSE
696 #define WA_REVERSE      A_REVERSE
697 #endif
698 #ifndef WA_UNDERLINE
699 #define WA_UNDERLINE    A_UNDERLINE
700 #endif
701 #ifndef WA_BLINK
702 #define WA_BLINK        A_BLINK
703 #endif
704
705 #ifndef OK
706 #define OK (0)
707 #endif
708
709 #ifndef ERR
710 #define ERR (-1)
711 #endif
712
713 #undef CTRL
714 #define CTRL(x) ((x) & 0x1f)
715
716 #define QUIT            CTRL('Q')
717 #define ESCAPE          CTRL('[')
718
719 #ifndef KEY_MIN
720 #define KEY_MIN 256             /* not defined in Solaris 8 */
721 #endif
722
723 #define HELP_KEY_1      '?'
724 #define HELP_KEY_2      KEY_F(1)
725
726 /* our "standard" options for getopt, needed for help2man */
727 #define OPTS_USAGE      'h'
728 #define OPTS_VERSION    'V'
729 #define OPTS_COMMON     "hV"
730 #define USAGE_COMMON    \
731  "Common options:"\
732 ," -h       show this message"\
733 ," -V       show version of curses"
734
735 #if HAVE_CURSES_VERSION
736 #define format_version(buffer) strcpy(buffer, curses_version())
737 #elif defined(NCURSES_VERSION_MAJOR) && defined(NCURSES_VERSION_MINOR) && defined(NCURSES_VERSION_PATCH)
738 #define format_version(buffer) sprintf(buffer, "ncurses %d.%d.%d", \
739         NCURSES_VERSION_MAJOR, \
740         NCURSES_VERSION_MINOR, \
741         NCURSES_VERSION_PATCH)
742 #else
743 #define format_version(buffer) strcpy(buffer, "ncurses-examples")
744 #endif
745
746 #define VERSION_COMMON() \
747 static char *version_common(char **argv) { \
748         char *base = argv[0]; \
749         char *leaf = strrchr(base, '/'); \
750         char *result = malloc(strlen(base) + 80); \
751         if (result != NULL) { \
752             if (leaf++ == NULL) leaf = base; \
753             sprintf(result, "%.20s: ", leaf); \
754             format_version(result + strlen(result)); \
755         } \
756         return result; \
757 } \
758 static void show_version(char **argv) { \
759         char *value = version_common(argv); \
760         if (value != NULL) { \
761             puts(value); \
762             free(value); \
763         } \
764 }
765
766 /* from nc_string.h, to make this stand alone */
767 #if HAVE_BSD_STRING_H
768 #include <bsd/string.h>
769 #endif
770
771 #ifdef __cplusplus
772 #define NCURSES_VOID            /* nothing */
773 #else
774 #define NCURSES_VOID (void)
775 #endif
776
777 #ifndef HAVE_STRLCAT
778 #define HAVE_STRLCAT 0
779 #endif
780
781 #ifndef HAVE_STRLCPY
782 #define HAVE_STRLCPY 0
783 #endif
784
785 #ifndef HAVE_SNPRINTF
786 #define HAVE_SNPRINTF 0
787 #endif
788
789 #ifndef HAVE_STRDUP
790 #define HAVE_STRDUP 0
791 #endif
792
793 #ifndef USE_STRING_HACKS
794 #define USE_STRING_HACKS 0
795 #endif
796
797 #ifndef HAVE_STRSTR
798 #define HAVE_STRSTR 0
799 #endif
800
801 #ifndef NCURSES_CAST
802 #ifdef __cplusplus
803 extern "C" {
804 #define NCURSES_CAST(type,value) static_cast<type>(value)
805 #else
806 #define NCURSES_CAST(type,value) (type)(value)
807 #endif
808 #endif
809
810 #if USE_STRING_HACKS && HAVE_STRLCAT
811 #define _nc_STRCAT(d,s,n)       NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,n))
812 #define _nc_STRNCAT(d,s,m,n)    NCURSES_VOID strlcat((d),(s),NCURSES_CAST(size_t,m))
813 #else
814 #define _nc_STRCAT(d,s,n)       NCURSES_VOID strcat((d),(s))
815 #define _nc_STRNCAT(d,s,m,n)    NCURSES_VOID strncat((d),(s),(n))
816 #endif
817
818 #if USE_STRING_HACKS && HAVE_STRLCPY
819 #define _nc_STRCPY(d,s,n)       NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
820 #define _nc_STRNCPY(d,s,n)      NCURSES_VOID strlcpy((d),(s),NCURSES_CAST(size_t,n))
821 #else
822 #define _nc_STRCPY(d,s,n)       NCURSES_VOID strcpy((d),(s))
823 #define _nc_STRNCPY(d,s,n)      NCURSES_VOID strncpy((d),(s),(n))
824 #endif
825
826 #if USE_STRING_HACKS && HAVE_SNPRINTF
827 #define _nc_SPRINTF             NCURSES_VOID (snprintf)
828 #define _nc_SLIMIT(n)           NCURSES_CAST(size_t,n),
829 #else
830 #define _nc_SPRINTF             NCURSES_VOID (sprintf)
831 #define _nc_SLIMIT(n)           /* nothing */
832 #endif
833
834 /*
835  * X/Open Curses does not define the arrays of terminfo/termcap names as SVr4
836  * curses did, and some implementations provide them anyway, but undeclared.
837  */
838 #ifdef DECL_CURSES_DATA_BOOLNAMES
839 extern char *boolnames[], *boolcodes[], *boolfnames[];
840 extern char *numnames[], *numcodes[], *numfnames[];
841 extern char *strnames[], *strcodes[], *strfnames[];
842 #endif
843
844 /*
845  * Again, an SVr4 curses feature latent in the libraries but not in headers.
846  */
847 #ifndef DECL_CURSES_DATA_TABSIZE
848 #define DECL_CURSES_DATA_TABSIZE 0
849 #endif
850
851 #if DECL_CURSES_DATA_TABSIZE
852 extern int TABSIZE;
853 #undef  HAVE_CURSES_DATA_TABSIZE
854 #define HAVE_CURSES_DATA_TABSIZE 1
855 #endif
856
857 #ifndef HAVE_CURSES_DATA_TABSIZE
858 #define HAVE_CURSES_DATA_TABSIZE 0
859 #endif
860
861 /*
862  * X/Open Curses provides termname(), whose return value is analogous to the
863  * SVr4 curses variable ttytype[].
864  */
865 #ifndef HAVE_CURSES_DATA_TTYTYPE
866 #define HAVE_CURSES_DATA_TTYTYPE 0
867 #endif
868
869 #ifndef DECL_CURSES_DATA_TTYTYPE
870 #define DECL_CURSES_DATA_TTYTYPE 0
871 #endif
872
873 #if !defined(ttytype) && (!HAVE_CURSES_DATA_TTYTYPE || DECL_CURSES_DATA_TTYTYPE)
874 #define ttytype termname()
875 #endif
876
877 #define colored_chtype(ch, attr, pair) \
878         ((chtype) (ch) | (chtype) (attr) | (chtype) COLOR_PAIR(pair))
879
880 /*
881  * Workaround for HPUX
882  */
883 #if defined(__hpux) && !defined(NCURSES_VERSION)
884 #define getbegx(w) __getbegx(w)
885 #define getbegy(w) __getbegy(w)
886 #define getcurx(w) __getcurx(w)
887 #define getcury(w) __getcury(w)
888 #define getmaxx(w) __getmaxx(w)
889 #define getmaxy(w) __getmaxy(w)
890 #define getparx(w) __getparx(w)
891 #define getpary(w) __getpary(w)
892 #endif
893
894 /*
895  * Workaround in case getcchar() returns a positive value when the source
896  * string produces only a L'\0'.
897  */
898 #define TEST_CCHAR(s, count, then_stmt, else_stmt) \
899         if ((count = getcchar(s, NULL, NULL, NULL, NULL)) > 0) { \
900             wchar_t test_wch[CCHARW_MAX + 2]; \
901             attr_t test_attrs; \
902             NCURSES_PAIRS_T test_pair; \
903             \
904             if (getcchar( s, test_wch, &test_attrs, &test_pair, NULL) == OK \
905                 && test_wch[0] != L'\0') { \
906                 then_stmt \
907             } else { \
908                 else_stmt \
909             } \
910         } else { \
911             else_stmt \
912         }
913 /*
914  * These usually are implemented as macros, but may be functions.
915  */
916 #if !defined(getcurx) && !HAVE_GETCURX
917 #define getcurx(win)            ((win) ? ((int)(win)->_curx) : ERR)
918 #define getcury(win)            ((win) ? ((int)(win)->_cury) : ERR)
919 #endif
920
921 #if !defined(getbegx) && !HAVE_GETBEGX
922 #define getbegx(win)            ((win) ? ((int)(win)->_begx) : ERR)
923 #define getbegy(win)            ((win) ? ((int)(win)->_begy) : ERR)
924 #endif
925
926 #if !defined(getmaxx) && !HAVE_GETMAXX
927 #define getmaxx(win)            ((win) ? ((int)(win)->_maxx + 1) : ERR)
928 #define getmaxy(win)            ((win) ? ((int)(win)->_maxy + 1) : ERR)
929 #endif
930
931 /*
932  * Solaris 10 xpg4:
933 #define __m_getparx(w)          ((w)->_parent == (WINDOW *) 0 ? -1 \
934                                 : (w)->_begx - (w)->_parent->_begx)
935  */
936 #if !defined(getparx) && !HAVE_GETPARX
937 #ifdef __m_getparx
938 #define getparx(win)            __m_getparx(win)
939 #define getpary(win)            __m_getpary(win)
940 #else
941 #define getparx(win)            ((win)?((win)->_parx + 1):ERR)
942 #define getpary(win)            ((win)?((win)->_pary + 1):ERR)
943 #endif
944 #endif
945
946 #if !defined(mvwvline) && !HAVE_MVWVLINE
947 #define mvwvline(w,y,x,ch,n)    (move(y,x) == ERR ? ERR : wvline(w,ch,n))
948 #define mvwhline(w,y,x,ch,n)    (move(y,x) == ERR ? ERR : whline(w,ch,n))
949 #endif
950
951 #if !defined(mvvline) && !HAVE_MVVLINE
952 #define mvvline(y,x,ch,n)       (move(y,x) == ERR ? ERR : vline(ch,n))
953 #define mvhline(y,x,ch,n)       (move(y,x) == ERR ? ERR : hline(ch,n))
954 #endif
955
956 /*
957  * Try to accommodate curses implementations that have no terminfo support.
958  */
959 #if HAVE_TIGETNUM
960 #define TIGETNUM(ti,tc) tigetnum(ti)
961 #else
962 #define TIGETNUM(ti,tc) tgetnum(tc)
963 #endif
964
965 #if HAVE_TIGETSTR
966 #define TIGETSTR(ti,tc) tigetstr(ti)
967 #else
968 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
969 #endif
970
971 /*
972  * So far (2013 - more than ten years), only ncurses implements
973  * use_extended_names().
974  */
975 #if defined(NCURSES_XNAMES)
976 #elif defined(NCURSES_VERSION) && defined(HAVE_TERM_ENTRY_H) && HAVE_TERM_ENTRY_H
977 #define NCURSES_XNAMES 1
978 #else
979 #define NCURSES_XNAMES 0
980 #endif
981
982 /*
983  * ncurses restores the cursor in endwin().  Other libraries may not.
984  */
985 #ifdef NCURSES_VERSION
986 #define stop_curses() endwin()
987 #else
988 #define stop_curses() do { endwin(); curs_set(1); } while (0)
989 #endif
990
991 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
992  * (which is incompatible with legacy usage, doesn't solve any problems).
993  */
994 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
995 #define tparm2(a,b)   tparm(a,b,0,0,0,0,0,0,0,0)
996
997 #define UChar(c)    ((unsigned char)(c))
998
999 #ifndef SIZEOF
1000 #define SIZEOF(table)   (sizeof(table)/sizeof(table[0]))
1001 #endif
1002
1003 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
1004 #include <nc_alloc.h>
1005 #if HAVE_EXIT_TERMINFO && !defined(USE_CURSES) && (defined(USE_TERMINFO) || defined(USE_TINFO))
1006 #undef ExitProgram
1007 #define ExitProgram(code) exit_terminfo(code)
1008 #elif HAVE_EXIT_CURSES
1009 #undef ExitProgram
1010 #define ExitProgram(code) exit_curses(code)
1011 #endif
1012 #else /* not ncurses-tree */
1013 #define typeMalloc(type,n) (type *) malloc((size_t)(n) * sizeof(type))
1014 #define typeCalloc(type,elts) (type *) calloc((size_t)(elts), sizeof(type))
1015 #define typeRealloc(type,n,p) (type *) realloc(p, (size_t)(n) * sizeof(type))
1016 #endif
1017
1018 #ifndef ExitProgram
1019 #define ExitProgram(code) exit(code)
1020 #endif
1021
1022 #ifndef EXIT_SUCCESS
1023 #define EXIT_SUCCESS 0
1024 #endif
1025 #ifndef EXIT_FAILURE
1026 #define EXIT_FAILURE 1
1027 #endif
1028
1029 #undef _NC_WINDOWS
1030 #if (defined(_WIN32) || defined(_WIN64))
1031 #define _NC_WINDOWS 1
1032 #endif
1033
1034 #if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
1035
1036 #if defined(PDCURSES)
1037 #ifdef WINVER
1038 #  if WINVER < 0x0501
1039 #    error WINVER must at least be 0x0501
1040 #  endif
1041 #else
1042 #  define WINVER 0x0501
1043 #endif
1044 #include <windows.h>
1045 #include <sys/time.h>           /* for struct timeval */
1046 #undef sleep
1047 #define sleep(n) Sleep((n) * 1000)
1048 #define SIGHUP  1
1049 #define SIGKILL 9
1050 #define getlogin() "username"
1051
1052 #elif defined(EXP_WIN32_DRIVER)
1053
1054 #if defined(HAVE_NCURSESW_NCURSES_H)
1055 #include <ncursesw/nc_win32.h>
1056 #elif defined(HAVE_NCURSES_NCURSES_H)
1057 #include <ncurses/nc_win32.h>
1058 #else
1059 #include <nc_win32.h>
1060 #endif
1061
1062 #else
1063
1064 #if defined(HAVE_NCURSESW_NCURSES_H)
1065 #include <ncursesw/nc_mingw.h>
1066 #elif defined(HAVE_NCURSES_NCURSES_H)
1067 #include <ncurses/nc_mingw.h>
1068 #else
1069 #include <nc_mingw.h>
1070 #endif
1071
1072 #endif
1073
1074 /* conflicts in test/firstlast.c */
1075 #undef large
1076 #undef small
1077
1078 #endif
1079
1080 #ifdef NEED_TIME_H
1081 #if TIME_WITH_SYS_TIME
1082 # include <sys/time.h>
1083 # include <time.h>
1084 #else
1085 # if HAVE_SYS_TIME_H
1086 #  include <sys/time.h>
1087 # else
1088 #  include <time.h>
1089 # endif
1090 #endif
1091 #endif
1092
1093 #if HAVE_CLOCK_GETTIME
1094 # define GetClockTime(t) clock_gettime(CLOCK_REALTIME, t)
1095 # define TimeType struct timespec
1096 # define TimeScale 1000000000L          /* 1e9 */
1097 # define ElapsedSeconds(b,e) \
1098             (double) (((e)->tv_sec - (b)->tv_sec) \
1099                     + ((e)->tv_nsec - (b)->tv_nsec) / TimeScale)
1100 #elif HAVE_GETTIMEOFDAY
1101 # define GetClockTime(t) gettimeofday(t, 0)
1102 # define TimeType struct timeval
1103 # define TimeScale 1000000L             /* 1e6 */
1104 # define ElapsedSeconds(b,e) \
1105             (double) (((e)->tv_sec - (b)->tv_sec) \
1106                     + ((e)->tv_usec - (b)->tv_usec) / TimeScale)
1107 #else
1108 # define TimeType time_t
1109 # define GetClockTime(t) time((time_t*)0)
1110 # define ElapsedSeconds(b,e) (double)((e) - (b))
1111 #endif
1112
1113 /*
1114  * Ultrix 3.1
1115  */
1116 #ifndef STDOUT_FILENO
1117 #define STDOUT_FILENO 1
1118 #endif
1119
1120 #if !HAVE_STRSTR
1121 extern char *_nc_strstr(const char *, const char *);
1122 #define strstr(a,b) _nc_strstr((a),(b))
1123 #endif /* !HAVE_STRSTR */
1124
1125 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
1126  * curses which doesn't have const parameters declared (so far) in the places
1127  * that XSI shows.
1128  */
1129 #ifndef NCURSES_CONST
1130 #ifdef PDCURSES
1131 #define NCURSES_CONST           const   /* close enough */
1132 #else
1133 #define NCURSES_CONST           /* nothing */
1134 #endif
1135 #endif
1136
1137 /* out-of-band values for representing absent capabilities */
1138 #define ABSENT_BOOLEAN          ((signed char)-1)       /* 255 */
1139 #define ABSENT_NUMERIC          (-1)
1140 #define ABSENT_STRING           (char *)0
1141
1142 /* out-of-band values for representing cancels */
1143 #define CANCELLED_BOOLEAN       ((signed char)-2)       /* 254 */
1144 #define CANCELLED_NUMERIC       (-2)
1145 #define CANCELLED_STRING        (char *)(-1)
1146
1147 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1)      /* reject "-1" */
1148 #define VALID_NUMERIC(s) ((s) >= 0)
1149 #define VALID_STRING(s)  ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
1150
1151 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
1152
1153 #define CATCHALL(handler) do { \
1154                 int nsig; \
1155                 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
1156                     if (nsig != SIGKILL) \
1157                         signal(nsig, handler); \
1158             } while(0)
1159
1160 #ifdef NCURSES_VERSION
1161 #define InitAndCatch(init,handler) do { CATCHALL(handler); init; } while (0)
1162 #else
1163 #define InitAndCatch(init,handler) do { init; CATCHALL(handler); } while (0)
1164 #endif
1165
1166 #if defined(_NC_WINDOWS) || defined(USE_WIN32CON_DRIVER)
1167 #define SetupAlarm(opt) (void)opt
1168 #else
1169 #define SetupAlarm(opt) if (opt) alarm((unsigned)opt)
1170 #endif
1171
1172 /*
1173  * Workaround for clean(er) compile with Solaris's legacy curses.
1174  * The same would be needed for HPUX 10.20
1175  */
1176 #ifndef TPUTS_ARG
1177 #define TPUTS_ARG int
1178 #endif
1179
1180 #if defined(sun) && !defined(_XOPEN_CURSES) && !defined(NCURSES_VERSION_PATCH)
1181 #undef TPUTS_ARG
1182 #define TPUTS_ARG char
1183 extern char *tgoto(char *, int, int);   /* available, but not prototyped */
1184 #endif
1185
1186 #ifndef TPUTS_PROTO
1187 #define TPUTS_PROTO(func,value) int func(TPUTS_ARG value)
1188 #endif
1189
1190 #ifndef TPUTS_RETURN
1191 #define TPUTS_RETURN(value) return value
1192 #endif
1193
1194 /*
1195  * Workarounds for Solaris's X/Open curses
1196  */
1197 #if !defined(KEY_MIN) && defined(__KEY_MIN)
1198 #define KEY_MIN __KEY_MIN
1199 #endif
1200 #if !defined(KEY_MAX) && defined(__KEY_MIN)
1201 #define KEY_MAX __KEY_MAX
1202 #endif
1203
1204 /*
1205  * Workaround to build with Sun's default SVr4 curses.
1206  */
1207 #ifdef NCURSES_VERSION
1208 #ifndef HAVE_VW_PRINTW
1209 #define HAVE_VW_PRINTW 1
1210 #endif
1211 #endif
1212
1213 /*
1214  * ncurses provides arrays of capability names; X/Open discarded these SVr4
1215  * features.  Some implementations continue to provide them (see the test
1216  * configure script).
1217  */
1218 #ifdef NCURSES_VERSION
1219 #ifndef HAVE_CURSES_DATA_BOOLNAMES
1220 #define HAVE_CURSES_DATA_BOOLNAMES 1
1221 #endif
1222 #endif
1223
1224 /*
1225  * ncurses provides a termcap interface; a few packagers replace or displace
1226  * its header file with an incompatible one.  The demo_termcap program uses
1227  * the ncurses file, if available.
1228  */
1229 #ifdef NCURSES_VERSION
1230 #ifndef HAVE_NCURSES_TERMCAP_H
1231 #define HAVE_NCURSES_TERMCAP_H 0
1232 #endif
1233 #ifndef HAVE_TERMCAP_H
1234 #define HAVE_TERMCAP_H 0
1235 #endif
1236 #endif
1237
1238 /*
1239  * ncurses uses const in some places where X/Open does (or did) not allow.
1240  */
1241 #if defined(NCURSES_CONST)
1242 #define CONST_MENUS NCURSES_CONST
1243 #elif defined(PDCURSES)
1244 #define CONST_MENUS const
1245 #else
1246 #define CONST_MENUS             /* nothing */
1247 #endif
1248
1249 #if defined(NCURSES_CONST)
1250 #define CONST_FMT NCURSES_CONST
1251 #elif defined(PDCURSES)
1252 #define CONST_FMT const
1253 #else
1254 #define CONST_FMT               /* nothing */
1255 #endif
1256
1257 /*
1258  * Simplify setting up demo of threading with these macros.
1259  */
1260
1261 #if HAVE_USE_WINDOW
1262 #define USING_WINDOW(w,func) use_window(w, (NCURSES_WINDOW_CB) func, w)
1263 #define USING_WINDOW1(w,func,safe) use_window(w, (NCURSES_WINDOW_CB) safe, NULL)
1264 #define USING_WINDOW2(w,func,data) use_window(w, (NCURSES_WINDOW_CB) func, data)
1265 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
1266 #else
1267 #define USING_WINDOW(w,func) func(w, NULL)
1268 #define USING_WINDOW1(w,func,safe) func(w)
1269 #define USING_WINDOW2(w,func,data) func(w,data)
1270 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
1271 #endif
1272
1273 #if HAVE_USE_WINDOW
1274 #define USING_SCREEN(s,func,data) use_screen(s, (NCURSES_SCREEN_CB) func, data)
1275 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
1276 #else
1277 #define USING_SCREEN(s,func,data) func(data)
1278 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
1279 #endif
1280
1281 #if defined(TRACE) && HAVE__TRACEF && HAVE_CURSES_TRACE
1282 #define Trace(p) _tracef p
1283 #define USE_TRACE 1
1284 #define START_TRACE() \
1285         if ((_nc_tracing & TRACE_MAXIMUM) == 0) { \
1286             int t = _nc_getenv_num("NCURSES_TRACE"); \
1287             if (t >= 0) \
1288                 curses_trace((unsigned) t); \
1289         }
1290 extern unsigned _nc_tracing;
1291 extern int _nc_getenv_num(const char *);
1292 #else
1293 #undef TRACE
1294 #define Trace(p)                /* nothing */
1295 #define USE_TRACE 0
1296 #define START_TRACE()           /* nothing */
1297 #endif
1298
1299 #define Trace2(p)               /* nothing */
1300
1301 #define AddCh(c)                (void) addch((chtype)(c))
1302 #define WAddCh(w,c)             (void) waddch((w),(chtype)(c))
1303 #define MvAddCh(y,x,c)          (void) mvaddch((y),(x),(chtype)(c))
1304 #define MvWAddCh(w,y,x,c)       (void) mvwaddch((w),(y),(x),(chtype)(c))
1305 #define MvAddStr(y,x,s)         (void) mvaddstr((y),(x),(s))
1306 #define MvWAddStr(w,y,x,s)      (void) mvwaddstr((w),(y),(x),(s))
1307 #define MvWAddChStr(w,y,x,s)    (void) mvwaddchstr((w),(y),(x),(s))
1308 #define MvPrintw                (void) mvprintw
1309 #define MvWPrintw               (void) mvwprintw
1310 #define MvHLine                 (void) mvhline
1311 #define MvWHLine                (void) mvwhline
1312 #define MvVLine                 (void) mvvline
1313 #define MvWVLine                (void) mvwvline
1314
1315 /*
1316  * The macro likely uses unsigned values, while X/Open prototype uses int.
1317  */
1318 #if defined(wattrset) || defined(PDCURSES)
1319 #define AttrArg(p,a)    (chtype) ((chtype)(p) | (chtype)(a))
1320 #else
1321 #define AttrArg(p,a)    (int) ((chtype)(p) | (chtype)(a))
1322 #endif
1323
1324 /*
1325  * Workaround for defective implementation of gcc attribute warn_unused_result
1326  */
1327 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
1328 #define IGNORE_RC(func) errno = func
1329 #else
1330 #define IGNORE_RC(func) (void) func
1331 #endif /* gcc workarounds */
1332
1333 #define init_mb(state)  memset(&state, 0, sizeof(state))
1334
1335 #endif /* __TEST_PRIV_H */