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