]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/test.priv.h
ncurses 5.9 - patch 20121215
[ncurses.git] / test / test.priv.h
1 /****************************************************************************
2  * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc.              *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *  Author: Thomas E. Dickey                    1996-on                     *
31  ****************************************************************************/
32 /* $Id: test.priv.h,v 1.115 2012/12/02 00:46:34 tom Exp $ */
33
34 #ifndef __TEST_PRIV_H
35 #define __TEST_PRIV_H 1
36
37 #include <ncurses_cfg.h>
38
39 /*
40  * Fix ifdef's that look for the form/menu/panel libraries, if we are building
41  * with wide-character ncurses.
42  */
43 #ifdef  HAVE_LIBFORMW
44 #define HAVE_LIBFORMW 1
45 #define HAVE_LIBFORM 1
46 #endif
47
48 #ifdef  HAVE_LIBMENUW
49 #define HAVE_LIBMENUW 1
50 #define HAVE_LIBMENU 1
51 #endif
52
53 #ifdef  HAVE_LIBPANELW
54 #define HAVE_LIBPANELW 1
55 #define HAVE_LIBPANEL 1
56 #endif
57
58 /*
59  * Fallback definitions to accommodate broken compilers.
60  */
61 #ifndef HAVE_ASSUME_DEFAULT_COLORS
62 #define HAVE_ASSUME_DEFAULT_COLORS 0
63 #endif
64
65 #ifndef HAVE_CURSES_VERSION
66 #define HAVE_CURSES_VERSION 0
67 #endif
68
69 #ifndef HAVE_CHGAT
70 #define HAVE_CHGAT 0
71 #endif
72
73 #ifndef HAVE_COLOR_SET
74 #define HAVE_COLOR_SET 0
75 #endif
76
77 #ifndef HAVE_FILTER
78 #define HAVE_FILTER 0
79 #endif
80
81 #ifndef HAVE_FORM_H
82 #define HAVE_FORM_H 0
83 #endif
84
85 #ifndef HAVE_GETBEGX
86 #define HAVE_GETBEGX 0
87 #endif
88
89 #ifndef HAVE_GETCURX
90 #define HAVE_GETCURX 0
91 #endif
92
93 #ifndef HAVE_GETMAXX
94 #define HAVE_GETMAXX 0
95 #endif
96
97 #ifndef HAVE_GETOPT_H
98 #define HAVE_GETOPT_H 0
99 #endif
100
101 #ifndef HAVE_GETPARX
102 #define HAVE_GETPARX 0
103 #endif
104
105 #ifndef HAVE_GETWIN
106 #define HAVE_GETWIN 0
107 #endif
108
109 #ifndef HAVE_LIBFORM
110 #define HAVE_LIBFORM 0
111 #endif
112
113 #ifndef HAVE_LIBMENU
114 #define HAVE_LIBMENU 0
115 #endif
116
117 #ifndef HAVE_LIBPANEL
118 #define HAVE_LIBPANEL 0
119 #endif
120
121 #ifndef HAVE_LOCALE_H
122 #define HAVE_LOCALE_H 0
123 #endif
124
125 #ifndef HAVE_MATH_H
126 #define HAVE_MATH_H 0
127 #endif
128
129 #ifndef HAVE_MENU_H
130 #define HAVE_MENU_H 0
131 #endif
132
133 #ifndef HAVE_MVVLINE
134 #define HAVE_MVVLINE 0
135 #endif
136
137 #ifndef HAVE_MVWVLINE
138 #define HAVE_MVWVLINE 0
139 #endif
140
141 #ifndef HAVE_NAPMS
142 #define HAVE_NAPMS 1
143 #endif
144
145 #ifndef HAVE_NC_ALLOC_H
146 #define HAVE_NC_ALLOC_H 0
147 #endif
148
149 #ifndef HAVE_PANEL_H
150 #define HAVE_PANEL_H 0
151 #endif
152
153 #ifndef HAVE_PUTWIN
154 #define HAVE_PUTWIN 0
155 #endif
156
157 #ifndef HAVE_RESIZE_TERM
158 #define HAVE_RESIZE_TERM 0
159 #endif
160
161 #ifndef HAVE_RIPOFFLINE
162 #define HAVE_RIPOFFLINE 0
163 #endif
164
165 #ifndef HAVE_SETUPTERM
166 #define HAVE_SETUPTERM 0
167 #endif
168
169 #ifndef HAVE_SLK_COLOR
170 #define HAVE_SLK_COLOR 0
171 #endif
172
173 #ifndef HAVE_SLK_INIT
174 #define HAVE_SLK_INIT 0
175 #endif
176
177 #ifndef HAVE_TERMATTRS
178 #define HAVE_TERMATTRS 0
179 #endif
180
181 #ifndef HAVE_TERMNAME
182 #define HAVE_TERMNAME 0
183 #endif
184
185 #ifndef HAVE_TGETENT
186 #define HAVE_TGETENT 0
187 #endif
188
189 #ifndef HAVE_TIGETNUM
190 #define HAVE_TIGETNUM 0
191 #endif
192
193 #ifndef HAVE_TIGETSTR
194 #define HAVE_TIGETSTR 0
195 #endif
196
197 #ifndef HAVE_TYPEAHEAD
198 #define HAVE_TYPEAHEAD 0
199 #endif
200
201 #ifndef HAVE_WINSSTR
202 #define HAVE_WINSSTR 0
203 #endif
204
205 #ifndef HAVE_USE_DEFAULT_COLORS
206 #define HAVE_USE_DEFAULT_COLORS 0
207 #endif
208
209 #ifndef HAVE_USE_SCREEN
210 #define HAVE_USE_SCREEN 0
211 #endif
212
213 #ifndef HAVE_USE_WINDOW
214 #define HAVE_USE_WINDOW 0
215 #endif
216
217 #ifndef HAVE_WRESIZE
218 #define HAVE_WRESIZE 0
219 #endif
220
221 #ifndef NCURSES_EXT_FUNCS
222 #define NCURSES_EXT_FUNCS 0
223 #endif
224
225 #ifndef NEED_PTEM_H
226 #define NEED_PTEM_H 0
227 #endif
228
229 #ifndef NEED_WCHAR_H
230 #define NEED_WCHAR_H 0
231 #endif
232
233 #ifndef NO_LEAKS
234 #define NO_LEAKS 0
235 #endif
236
237 /*
238  * Workaround for HPUX
239  */
240 #if defined(__hpux) && !defined(NCURSES_VERSION)
241 #define _ACS_COMPAT_CODE        /* needed for acs_map vs __acs_map */
242 #endif
243
244 #include <stdlib.h>
245 #include <stdarg.h>
246 #include <string.h>
247 #include <sys/types.h>
248 #include <errno.h>
249
250 #if HAVE_UNISTD_H
251 #include <unistd.h>
252 #endif
253
254 #include <signal.h>             /* include before curses.h to work around glibc bug */
255
256 #if NEED_WCHAR_H
257 #include <wchar.h>
258 #ifdef HAVE_LIBUTF8_H
259 #include <libutf8.h>
260 #endif
261 #endif
262
263 #if defined(HAVE_XCURSES)
264 #include <xcurses.h>
265 #elif defined(HAVE_NCURSESW_NCURSES_H)
266 #include <ncursesw/curses.h>
267 #elif defined(HAVE_NCURSES_NCURSES_H)
268 #include <ncurses/curses.h>
269 #else
270 #include <curses.h>
271 #endif
272
273 #if defined(HAVE_XCURSES) || defined(PDCURSES)
274 /* no other headers */
275 #undef  HAVE_SETUPTERM          /* nonfunctional */
276 #define HAVE_SETUPTERM 0
277 #undef  HAVE_TGETENT            /* nonfunctional */
278 #define HAVE_TGETENT 0
279 #undef  HAVE_TIGETSTR           /* nonfunctional */
280 #define HAVE_TIGETSTR 0
281 #elif defined(HAVE_NCURSESW_TERM_H)
282 #include <ncursesw/term.h>
283 #elif defined(HAVE_NCURSES_TERM_H)
284 #include <ncurses/term.h>
285 #elif defined(HAVE_TERM_H)
286 #include <term.h>
287 #endif
288
289 /*
290  * Not all curses.h implementations include unctrl.h,
291  */
292 #if defined(HAVE_NCURSESW_UNCTRL_H)
293 #include <ncursesw/unctrl.h>
294 #elif defined(HAVE_NCURSES_UNCTRL_H)
295 #include <ncurses/unctrl.h>
296 #elif defined(HAVE_UNCTRL_H)
297 #include <unctrl.h>
298 #endif
299
300 #if HAVE_GETOPT_H
301 #include <getopt.h>
302 #elif !defined(HAVE_GETOPT_HEADER)
303 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its variables
304  * doesn't hurt.
305  */
306 extern char *optarg;
307 extern int optind;
308 #endif /* HAVE_GETOPT_H */
309
310 #if HAVE_LOCALE_H
311 #include <locale.h>
312 #else
313 #define setlocale(name,string)  /* nothing */
314 #endif
315
316 #include <assert.h>
317 #include <ctype.h>
318
319 #ifndef GCC_NORETURN
320 #define GCC_NORETURN            /* nothing */
321 #endif
322 #ifndef GCC_PRINTFLIKE
323 #define GCC_PRINTFLIKE(a,b)     /* nothing */
324 #endif
325 #ifndef GCC_UNUSED
326 #define GCC_UNUSED              /* nothing */
327 #endif
328
329 #ifndef HAVE_GETNSTR
330 #define getnstr(s,n) getstr(s)
331 #endif
332
333 #ifndef USE_SOFTKEYS
334 #if HAVE_SLK_INIT
335 #define USE_SOFTKEYS 1
336 #else
337 #define USE_SOFTKEYS 0
338 #endif
339 #endif
340
341 #if !USE_SOFTKEYS
342 #define slk_init()              /* nothing */
343 #define slk_restore()           /* nothing */
344 #define slk_clear()             /* nothing */
345 #endif
346
347 #ifndef HAVE_WSYNCDOWN
348 #define wsyncdown(win)          /* nothing */
349 #endif
350
351 #ifndef USE_WIDEC_SUPPORT
352 #if (defined(_XOPEN_SOURCE_EXTENDED) \
353   || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) \
354   || (defined(NCURSES_WIDECHAR) && (NCURSES_WIDECHAR - 0 < 1))) \
355   && defined(WACS_ULCORNER)
356 #define USE_WIDEC_SUPPORT 1
357 #else
358 #define USE_WIDEC_SUPPORT 0
359 #endif
360 #endif
361
362 #if HAVE_PANEL_H && HAVE_LIBPANEL
363 #define USE_LIBPANEL 1
364 #else
365 #define USE_LIBPANEL 0
366 #endif
367
368 #if HAVE_MENU_H && HAVE_LIBMENU
369 #define USE_LIBMENU 1
370 #else
371 #define USE_LIBMENU 0
372 #endif
373
374 #if HAVE_FORM_H && HAVE_LIBFORM
375 #define USE_LIBFORM 1
376 #else
377 #define USE_LIBFORM 0
378 #endif
379
380 /* workaround, to build against NetBSD's variant of the form library */
381 #ifdef HAVE_NETBSD_FORM_H
382 #define form_getyx(form, y, x) y = current_field(form)->cursor_ypos, x = current_field(form)->cursor_xpos
383 #else
384 #define form_getyx(form, y, x) y = (form)->currow, x = (form)->curcol
385 #endif
386
387 /* workaround, to build against NetBSD's variant of the form library */
388 #ifdef HAVE_NETBSD_MENU_H
389 #define menu_itemwidth(menu) (menu)->max_item_width
390 #else
391 #define menu_itemwidth(menu) (menu)->itemlen
392 #endif
393
394 #ifndef HAVE_TYPE_ATTR_T
395 #if !USE_WIDEC_SUPPORT && !defined(attr_t)
396 #define attr_t chtype
397 #endif
398 #endif
399
400 #undef NCURSES_CH_T
401 #if !USE_WIDEC_SUPPORT
402 #define NCURSES_CH_T chtype
403 #else
404 #define NCURSES_CH_T cchar_t
405 #endif
406
407 #ifndef NCURSES_OPAQUE
408 #define NCURSES_OPAQUE 0
409 #endif
410
411 #ifndef CCHARW_MAX
412 #define CCHARW_MAX 5
413 #endif
414
415 #if defined(NCURSES_VERSION) && defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
416 #define CURSES_WACS_SYMBOLS
417 #endif
418
419 #if defined(CURSES_WACS_ARRAY) && !defined(CURSES_WACS_SYMBOLS)
420 /* NetBSD 5.1 defines these incorrectly */
421 #undef  WACS_RARROW
422 #undef  WACS_LARROW
423 #undef  WACS_UARROW
424 #undef  WACS_DARROW
425 #undef  WACS_BLOCK
426 #undef  WACS_DIAMOND
427 #undef  WACS_CKBOARD
428 #undef  WACS_DEGREE
429 #undef  WACS_PLMINUS
430 #undef  WACS_BOARD
431 #undef  WACS_LANTERN
432 #undef  WACS_LRCORNER
433 #undef  WACS_URCORNER
434 #undef  WACS_ULCORNER
435 #undef  WACS_LLCORNER
436 #undef  WACS_PLUS
437 #undef  WACS_HLINE
438 #undef  WACS_S1
439 #undef  WACS_S9
440 #undef  WACS_LTEE
441 #undef  WACS_RTEE
442 #undef  WACS_BTEE
443 #undef  WACS_TTEE
444 #undef  WACS_VLINE
445 #undef  WACS_BULLET
446 #undef  WACS_S3
447 #undef  WACS_S7
448 #undef  WACS_LEQUAL
449 #undef  WACS_GEQUAL
450 #undef  WACS_PI
451 #undef  WACS_NEQUAL
452 #undef  WACS_STERLING
453
454 #define WACS_RARROW     &(CURSES_WACS_ARRAY['+'])
455 #define WACS_LARROW     &(CURSES_WACS_ARRAY[','])
456 #define WACS_UARROW     &(CURSES_WACS_ARRAY['-'])
457 #define WACS_DARROW     &(CURSES_WACS_ARRAY['.'])
458 #define WACS_BLOCK      &(CURSES_WACS_ARRAY['0'])
459 #define WACS_DIAMOND    &(CURSES_WACS_ARRAY['`'])
460 #define WACS_CKBOARD    &(CURSES_WACS_ARRAY['a'])
461 #define WACS_DEGREE     &(CURSES_WACS_ARRAY['f'])
462 #define WACS_PLMINUS    &(CURSES_WACS_ARRAY['g'])
463 #define WACS_BOARD      &(CURSES_WACS_ARRAY['h'])
464 #define WACS_LANTERN    &(CURSES_WACS_ARRAY['i'])
465 #define WACS_LRCORNER   &(CURSES_WACS_ARRAY['j'])
466 #define WACS_URCORNER   &(CURSES_WACS_ARRAY['k'])
467 #define WACS_ULCORNER   &(CURSES_WACS_ARRAY['l'])
468 #define WACS_LLCORNER   &(CURSES_WACS_ARRAY['m'])
469 #define WACS_PLUS       &(CURSES_WACS_ARRAY['n'])
470 #define WACS_HLINE      &(CURSES_WACS_ARRAY['q'])
471 #define WACS_S1         &(CURSES_WACS_ARRAY['o'])
472 #define WACS_S9         &(CURSES_WACS_ARRAY['s'])
473 #define WACS_LTEE       &(CURSES_WACS_ARRAY['t'])
474 #define WACS_RTEE       &(CURSES_WACS_ARRAY['u'])
475 #define WACS_BTEE       &(CURSES_WACS_ARRAY['v'])
476 #define WACS_TTEE       &(CURSES_WACS_ARRAY['w'])
477 #define WACS_VLINE      &(CURSES_WACS_ARRAY['x'])
478 #define WACS_BULLET     &(CURSES_WACS_ARRAY['~'])
479 #define WACS_S3         &(CURSES_WACS_ARRAY['p'])
480 #define WACS_S7         &(CURSES_WACS_ARRAY['r'])
481 #define WACS_LEQUAL     &(CURSES_WACS_ARRAY['y'])
482 #define WACS_GEQUAL     &(CURSES_WACS_ARRAY['z'])
483 #define WACS_PI         &(CURSES_WACS_ARRAY['{'])
484 #define WACS_NEQUAL     &(CURSES_WACS_ARRAY['|'])
485 #define WACS_STERLING   &(CURSES_WACS_ARRAY['}'])
486 #endif
487
488 #undef CTRL
489 #define CTRL(x) ((x) & 0x1f)
490
491 #define QUIT            CTRL('Q')
492 #define ESCAPE          CTRL('[')
493
494 #ifndef KEY_MIN
495 #define KEY_MIN 256             /* not defined in Solaris 8 */
496 #endif
497
498 #ifdef DECL_CURSES_DATA_BOOLNAMES
499 extern char *boolnames[], *boolcodes[], *boolfnames[];
500 extern char *numnames[], *numcodes[], *numfnames[];
501 extern char *strnames[], *strcodes[], *strfnames[];
502 #endif
503
504 #define colored_chtype(ch, attr, pair) \
505         ((chtype) (ch) | (chtype) (attr) | (chtype) COLOR_PAIR(pair))
506
507 /*
508  * Workaround for HPUX
509  */
510 #if defined(__hpux) && !defined(NCURSES_VERSION)
511 #define getbegx(w) __getbegx(w)
512 #define getbegy(w) __getbegy(w)
513 #define getcurx(w) __getcurx(w)
514 #define getcury(w) __getcury(w)
515 #define getmaxx(w) __getmaxx(w)
516 #define getmaxy(w) __getmaxy(w)
517 #define getparx(w) __getparx(w)
518 #define getpary(w) __getpary(w)
519 #endif
520
521 /*
522  * Workaround in case getcchar() returns a positive value when the source
523  * string produces only a L'\0'.
524  */
525 #define TEST_CCHAR(s, count, then_stmt, else_stmt) \
526         if ((count = getcchar(s, NULL, NULL, NULL, NULL)) > 0) { \
527             wchar_t test_wch[CCHARW_MAX + 2]; \
528             attr_t test_attrs; \
529             short test_pair; \
530             \
531             if (getcchar( s, test_wch, &test_attrs, &test_pair, NULL) == OK \
532                 && test_wch[0] != L'\0') { \
533                 then_stmt \
534             } else { \
535                 else_stmt \
536             } \
537         } else { \
538             else_stmt \
539         }
540 /*
541  * These usually are implemented as macros, but may be functions.
542  */
543 #if !defined(getcurx) && !HAVE_GETCURX
544 #define getcurx(win)            ((win)?(win)->_curx:ERR)
545 #define getcury(win)            ((win)?(win)->_cury:ERR)
546 #endif
547
548 #if !defined(getbegx) && !HAVE_GETBEGX
549 #define getbegx(win)            ((win)?(win)->_begx:ERR)
550 #define getbegy(win)            ((win)?(win)->_begy:ERR)
551 #endif
552
553 #if !defined(getmaxx) && !HAVE_GETMAXX
554 #define getmaxx(win)            ((win)?((win)->_maxx + 1):ERR)
555 #define getmaxy(win)            ((win)?((win)->_maxy + 1):ERR)
556 #endif
557
558 /*
559  * Solaris 10 xpg4:
560 #define __m_getparx(w)          ((w)->_parent == (WINDOW *) 0 ? -1 \
561                                 : (w)->_begx - (w)->_parent->_begx)
562  */
563 #if !defined(getparx) && !HAVE_GETPARX
564 #ifdef __m_getparx
565 #define getparx(win)            __m_getparx(win)
566 #define getpary(win)            __m_getpary(win)
567 #else
568 #define getparx(win)            ((win)?((win)->_parx + 1):ERR)
569 #define getpary(win)            ((win)?((win)->_pary + 1):ERR)
570 #endif
571 #endif
572
573 #if !defined(mvwvline) && !HAVE_MVWVLINE
574 #define mvwvline(w,y,x,ch,n)    (move(y,x) == ERR ? ERR : wvline(w,ch,n))
575 #define mvwhline(w,y,x,ch,n)    (move(y,x) == ERR ? ERR : whline(w,ch,n))
576 #endif
577
578 #if !defined(mvvline) && !HAVE_MVVLINE
579 #define mvvline(y,x,ch,n)       (move(y,x) == ERR ? ERR : vline(ch,n))
580 #define mvhline(y,x,ch,n)       (move(y,x) == ERR ? ERR : hline(ch,n))
581 #endif
582
583 /*
584  * Try to accommodate curses implementations that have no terminfo support.
585  */
586 #if HAVE_TIGETNUM
587 #define TIGETNUM(ti,tc) tigetnum(ti)
588 #else
589 #define TIGETNUM(ti,tc) tgetnum(tc)
590 #endif
591
592 #if HAVE_TIGETSTR
593 #define TIGETSTR(ti,tc) tigetstr(ti)
594 #else
595 #define TIGETSTR(ti,tc) tgetstr(tc,&area_pointer)
596 #endif
597
598 /* ncurses implements tparm() with varargs, X/Open with a fixed-parameter list
599  * (which is incompatible with legacy usage, doesn't solve any problems).
600  */
601 #define tparm3(a,b,c) tparm(a,b,c,0,0,0,0,0,0,0)
602 #define tparm2(a,b)   tparm(a,b,0,0,0,0,0,0,0,0)
603
604 #define UChar(c)    ((unsigned char)(c))
605
606 #define SIZEOF(table)   (sizeof(table)/sizeof(table[0]))
607
608 #if defined(NCURSES_VERSION) && HAVE_NC_ALLOC_H
609 #include <nc_alloc.h>
610 #if HAVE_NC_FREEALL && defined(USE_TINFO)
611 #undef ExitProgram
612 #define ExitProgram(code) _nc_free_tinfo(code)
613 #endif
614 #else
615 #define typeMalloc(type,n) (type *) malloc((n) * sizeof(type))
616 #define typeCalloc(type,elts) (type *) calloc((elts), sizeof(type))
617 #define typeRealloc(type,n,p) (type *) realloc(p, (n) * sizeof(type))
618 #endif
619
620 #ifndef ExitProgram
621 #define ExitProgram(code) exit(code)
622 #endif
623
624 #ifndef EXIT_SUCCESS
625 #define EXIT_SUCCESS 0
626 #endif
627 #ifndef EXIT_FAILURE
628 #define EXIT_FAILURE 1
629 #endif
630
631 #ifdef __MINGW32__
632 #include <nc_mingw.h>
633 /* conflicts in test/firstlast.c */
634 #undef large
635 #undef small
636
637 #endif
638
639 /* Use this to quiet gcc's -Wwrite-strings warnings, but accommodate SVr4
640  * curses which doesn't have const parameters declared (so far) in the places
641  * that XSI shows.
642  */
643 #ifndef NCURSES_CONST
644 #define NCURSES_CONST           /* nothing */
645 #endif
646
647 /* out-of-band values for representing absent capabilities */
648 #define ABSENT_BOOLEAN          ((signed char)-1)       /* 255 */
649 #define ABSENT_NUMERIC          (-1)
650 #define ABSENT_STRING           (char *)0
651
652 /* out-of-band values for representing cancels */
653 #define CANCELLED_BOOLEAN       ((signed char)-2)       /* 254 */
654 #define CANCELLED_NUMERIC       (-2)
655 #define CANCELLED_STRING        (char *)(-1)
656
657 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1)      /* reject "-1" */
658 #define VALID_NUMERIC(s) ((s) >= 0)
659 #define VALID_STRING(s)  ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
660
661 #define VT_ACSC "``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~"
662
663 #define CATCHALL(handler) { \
664                 int nsig; \
665                 for (nsig = SIGHUP; nsig < SIGTERM; ++nsig) \
666                     if (nsig != SIGKILL) \
667                         signal(nsig, handler); \
668             }
669
670 /*
671  * Workaround for clean(er) compile with Solaris's legacy curses.
672  * The same would be needed for HPUX 10.20
673  */
674 #ifndef TPUTS_ARG
675 #define TPUTS_ARG int
676 #endif
677
678 #if defined(sun) && !defined(_XOPEN_CURSES) && !defined(NCURSES_VERSION_PATCH)
679 #undef TPUTS_ARG
680 #define TPUTS_ARG char
681 extern char *tgoto(char *, int, int);   /* available, but not prototyped */
682 #endif
683
684 #ifndef TPUTS_PROTO
685 #define TPUTS_PROTO(func,value) int func(TPUTS_ARG value)
686 #endif
687
688 #ifndef TPUTS_RETURN
689 #define TPUTS_RETURN(value) return value
690 #endif
691
692 /*
693  * Workarounds for Solaris's X/Open curses
694  */
695 #if !defined(KEY_MIN) && defined(__KEY_MIN)
696 #define KEY_MIN __KEY_MIN
697 #endif
698 #if !defined(KEY_MAX) && defined(__KEY_MIN)
699 #define KEY_MAX __KEY_MAX
700 #endif
701
702 /*
703  * Workaround to build with Sun's default SVr4 curses.
704  */
705 #ifdef NCURSES_VERSION
706 #ifndef HAVE_VW_PRINTW
707 #define HAVE_VW_PRINTW 1
708 #endif
709 #endif
710
711 /*
712  * ncurses provides arrays of capability names; X/Open discarded these SVr4
713  * features.  Some implementations continue to provide them (see the test
714  * configure script).
715  */
716 #ifdef NCURSES_VERSION
717 #ifndef HAVE_CURSES_DATA_BOOLNAMES
718 #define HAVE_CURSES_DATA_BOOLNAMES 1
719 #endif
720 #endif
721
722 /*
723  * ncurses uses const in some places where X/Open does (or did) not allow.
724  */
725 #ifdef NCURSES_VERSION
726 #define CONST_MENUS const
727 #else
728 #define CONST_MENUS             /* nothing */
729 #endif
730
731 /*
732  * Simplify setting up demo of threading with these macros.
733  */
734
735 #if HAVE_USE_WINDOW
736 #define USING_WINDOW(w,func) use_window(w, (NCURSES_WINDOW_CB) func, w)
737 #define USING_WINDOW2(w,func,data) use_window(w, (NCURSES_WINDOW_CB) func, data)
738 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
739 #else
740 #define USING_WINDOW(w,func) func(w)
741 #define USING_WINDOW2(w,func,data) func(w,data)
742 #define WANT_USE_WINDOW() extern void _nc_want_use_window(void)
743 #endif
744
745 #if HAVE_USE_WINDOW
746 #define USING_SCREEN(s,func,data) use_screen(s, (NCURSES_SCREEN_CB) func, data)
747 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
748 #else
749 #define USING_SCREEN(s,func,data) func(data)
750 #define WANT_USE_SCREEN() extern void _nc_want_use_screen(void)
751 #endif
752
753 #ifdef TRACE
754 #define Trace(p) _tracef p
755 #define USE_TRACE 1
756 #else
757 #define Trace(p)                /* nothing */
758 #define USE_TRACE 0
759 #endif
760
761 #define Trace2(p)               /* nothing */
762
763 #define MvAddCh         (void) mvaddch
764 #define MvWAddCh        (void) mvwaddch
765 #define MvAddStr        (void) mvaddstr
766 #define MvWAddStr       (void) mvwaddstr
767 #define MvWAddChStr     (void) mvwaddchstr
768 #define MvPrintw        (void) mvprintw
769 #define MvWPrintw       (void) mvwprintw
770 #define MvHLine         (void) mvhline
771 #define MvWHLine        (void) mvwhline
772 #define MvVLine         (void) mvvline
773 #define MvWVLine        (void) mvwvline
774
775 /*
776  * Workaround for defective implementation of gcc attribute warn_unused_result
777  */
778 #if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
779 #define IGNORE_RC(func) errno = func
780 #else
781 #define IGNORE_RC(func) (void) func
782 #endif /* gcc workarounds */
783
784 #define init_mb(state)  memset(&state, 0, sizeof(state))
785
786 #endif /* __TEST_PRIV_H */