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