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