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