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