1# vile:awkmode 2function declare_termtype(number,suffix) { 3 printf "typedef struct termtype%s { /* in-core form of terminfo data */\n", suffix; 4 print " char *term_names; /* str_table offset of term names */" 5 print " char *str_table; /* pointer to string table */" 6 print " NCURSES_SBOOL *Booleans; /* array of boolean values */" 7 printf " %-5s *Numbers; /* array of integer values */\n", number; 8 print " char **Strings; /* array of string offsets */" 9 print "" 10 print "#if NCURSES_XNAMES" 11 print " char *ext_str_table; /* pointer to extended string table */" 12 print " char **ext_Names; /* corresponding names */" 13 print "" 14 print " unsigned short num_Booleans;/* count total Booleans */"; 15 print " unsigned short num_Numbers; /* count total Numbers */"; 16 print " unsigned short num_Strings; /* count total Strings */"; 17 print "" 18 print " unsigned short ext_Booleans;/* count extensions to Booleans */"; 19 print " unsigned short ext_Numbers; /* count extensions to Numbers */"; 20 print " unsigned short ext_Strings; /* count extensions to Strings */"; 21 print "#endif /* NCURSES_XNAMES */" 22 print "" 23 printf "} TERMTYPE%s;\n", suffix; 24} 25BEGIN { 26 lcurl = "{"; 27 rcurl = "}"; 28 print "/****************************************************************************" 29 print " * Copyright 2018-2024,2025 Thomas E. Dickey *" 30 print " * Copyright 1998-2013,2017 Free Software Foundation, Inc. *" 31 print " * *" 32 print " * Permission is hereby granted, free of charge, to any person obtaining a *" 33 print " * copy of this software and associated documentation files (the *" 34 print " * \"Software\"), to deal in the Software without restriction, including *" 35 print " * without limitation the rights to use, copy, modify, merge, publish, *" 36 print " * distribute, distribute with modifications, sublicense, and/or sell *" 37 print " * copies of the Software, and to permit persons to whom the Software is *" 38 print " * furnished to do so, subject to the following conditions: *" 39 print " * *" 40 print " * The above copyright notice and this permission notice shall be included *" 41 print " * in all copies or substantial portions of the Software. *" 42 print " * *" 43 print " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS *" 44 print " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *" 45 print " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *" 46 print " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *" 47 print " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *" 48 print " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *" 49 print " * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *" 50 print " * *" 51 print " * Except as contained in this notice, the name(s) of the above copyright *" 52 print " * holders shall not be used in advertising or otherwise to promote the *" 53 print " * sale, use or other dealings in this Software without prior written *" 54 print " * authorization. *" 55 print " ****************************************************************************/" 56 print "" 57 print "/****************************************************************************/" 58 print "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */" 59 print "/* and: Eric S. Raymond <esr@snark.thyrsus.com> */" 60 print "/* and: Thomas E. Dickey 1995-on */" 61 print "/****************************************************************************/" 62 print "" 63 print "/* $Id: MKterm.h.awk.in,v 1.94 2025/12/26 23:33:14 tom Exp $ */" 64 print "" 65 print "/*" 66 print "** term.h -- Definition of struct term" 67 print "*/" 68 print "" 69 print "#ifndef NCURSES_TERM_H_incl" 70 print "#define NCURSES_TERM_H_incl 1" 71 print "" 72 print "#undef NCURSES_VERSION" 73 print "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\"" 74 print "" 75 print "#include <ncurses_dll.h>" 76 print "" 77 print "#ifdef __cplusplus" 78 printf "extern \"C\" %s\n", lcurl; 79 print "#endif" 80 print "" 81 print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H" 82 print " * definition (based on the system for which this was configured)." 83 print " */" 84 print "" 85 print "#ifndef __NCURSES_H" 86 print "" 87 print "typedef struct screen SCREEN;" 88 print "" 89 print "/* configured with --enable-sp-funcs? */" 90 print "#if @NCURSES_SP_FUNCS@" 91 print "#undef NCURSES_SP_FUNCS" 92 print "#define NCURSES_SP_FUNCS @NCURSES_PATCH@" 93 print "#undef NCURSES_SP_NAME" 94 print "#define NCURSES_SP_NAME(name) name##_sp" 95 print "" 96 print "/* Define the sp-funcs helper function */" 97 print "#undef NCURSES_SP_OUTC" 98 print "#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)" 99 print "typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);" 100 print "#endif" 101 print "" 102 print "#endif /* __NCURSES_H */" 103 print "" 104 print "#undef NCURSES_CONST" 105 print "#define NCURSES_CONST @NCURSES_CONST@" 106 print "" 107 print "#undef NCURSES_SBOOL" 108 print "#define NCURSES_SBOOL @NCURSES_SBOOL@" 109 print "" 110 print "#undef NCURSES_USE_DATABASE" 111 print "#define NCURSES_USE_DATABASE @NCURSES_USE_DATABASE@" 112 print "" 113 print "#undef NCURSES_USE_TERMCAP" 114 print "#define NCURSES_USE_TERMCAP @NCURSES_USE_TERMCAP@" 115 print "" 116 print "#undef NCURSES_XNAMES" 117 print "#define NCURSES_XNAMES @NCURSES_XNAMES@" 118 print "" 119 print "/* TTY, SET_TTY and GET_TTY are used internally */" 120 print "#ifdef NCURSES_INTERNALS" 121 print "" 122 print "/* We use these symbols to hide differences between" 123 print " * termios/termio/sgttyb interfaces." 124 print " */" 125 print "#undef TTY" 126 print "#undef SET_TTY" 127 print "#undef GET_TTY" 128 print "" 129 print "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@ /* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */" 130 print "" 131 print "#undef TERMIOS" 132 print "#define TERMIOS 1" 133 print "#include <termios.h>" 134 print "#define TTY struct termios" 135 print "" 136 print "#elif @HAVE_TERMIO_H@ /* HAVE_TERMIO_H */" 137 print "" 138 print "#undef TERMIOS" 139 print "#define TERMIOS 1" 140 print "#include <termio.h>" 141 print "#define TTY struct termio" 142 print "" 143 print "#elif (defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) || defined(__MINGW64__))" 144 print "" 145 print "#include <nc_win32.h>" 146 print "#define TTY ConsoleMode" 147 print "" 148 print "#elif @HAVE_SGTTY_H@ /* HAVE_SGTTY_H */" 149 print "" 150 print "#undef TERMIOS" 151 print "#include <sgtty.h>" 152 print "#include <sys/ioctl.h>" 153 print "#define TTY struct sgttyb" 154 print "" 155 print "#else" 156 print "" 157 print "#error no termio/termios/sgtty found" 158 print "" 159 print "#endif /* HAVE_TERMIOS_H */" 160 print "" 161 print "#ifdef TERMIOS" 162 print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)" 163 print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)" 164 print "/* configured with --enable-exp-win32? */" 165 print "#elif defined(_WIN32) || defined(_WIN64)" 166 print "#define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf)" 167 print "#define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf)" 168 print "#elif @HAVE_SGTTY_H@ /* HAVE_SGTTY_H */" 169 print "#define GET_TTY(fd, buf) gtty(fd, buf)" 170 print "#define SET_TTY(fd, buf) stty(fd, buf)" 171 print "#endif" 172 print "" 173 print "#endif /* NCURSES_INTERNALS */" 174 print "" 175 print "#ifndef GCC_NORETURN" 176 print "#define GCC_NORETURN /* nothing */" 177 print "#endif" 178 print "" 179 print "#define NAMESIZE 256" 180 print "" 181 print "/* The cast works because TERMTYPE is the first data in TERMINAL */" 182 print "#define CUR ((TERMTYPE *)(cur_term))->" 183 print "" 184} 185 186$2 == "%%-STOP-HERE-%%" { 187 print "" 188 printf "#define BOOLWRITE %d\n", BoolCount 189 printf "#define NUMWRITE %d\n", NumberCount 190 printf "#define STRWRITE %d\n", StringCount 191 print "" 192 print "/* older synonyms for some capabilities */" 193 print "#define beehive_glitch no_esc_ctlc" 194 print "#define teleray_glitch dest_tabs_magic_smso" 195 print "" 196 print "/* HPUX-11 uses this name rather than the standard one */" 197 print "#ifndef micro_char_size" 198 print "#define micro_char_size micro_col_size" 199 print "#endif" 200 print "" 201 print "#ifdef __INTERNAL_CAPS_VISIBLE" 202} 203 204/^#/ { next; } 205 206/^used_by/ { next ; } 207/^userdef/ { next ; } 208 209$1 == "acs_chars" { 210 acsindex = StringCount; 211} 212 213$3 == "bool" { 214 printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++ 215} 216 217$3 == "num" { 218 printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++ 219} 220 221$3 == "str" { 222 printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++ 223} 224 225END { 226 print "#endif /* __INTERNAL_CAPS_VISIBLE */" 227 print "" 228 print "" 229 print "/*" 230 print " * Predefined terminfo array sizes" 231 print " */" 232 printf "#define BOOLCOUNT %d\n", BoolCount 233 printf "#define NUMCOUNT %d\n", NumberCount 234 printf "#define STRCOUNT %d\n", StringCount 235 print "" 236 print "/* used by code for comparing entries */" 237 print "#define acs_chars_index ", acsindex 238 print "" 239 declare_termtype("short",""); 240 print "" 241 print "/*" 242 print " * The only reason these structures are visible is for read-only use." 243 print " * Programs which modify the data are not, never were, portable across" 244 print " * curses implementations." 245 print " *" 246 print " * The first field in TERMINAL is used in macros." 247 print " * The remaining fields are private." 248 print " */" 249 print "#ifdef NCURSES_INTERNALS" 250 print "" 251 print "#undef TERMINAL" 252 print "#define TERMINAL struct term" 253 print "TERMINAL;" 254 print "" 255 if (@NCURSES_EXT_COLORS@) { 256 print "/* configured with --enable-ext-colors */" 257 declare_termtype("int","2"); 258 } else { 259 print "#undef TERMTYPE2" 260 print "#define TERMTYPE2 TERMTYPE" 261 } 262 print "#else" 263 print "" 264 print "typedef struct term { /* describe an actual terminal */" 265 print " TERMTYPE type; /* terminal type description */" 266 print "} TERMINAL;" 267 print "" 268 print "#endif /* NCURSES_INTERNALS */" 269 print "" 270 print "/* configured with --enable-broken_linker and reentrancy disabled */" 271 print "#if @BROKEN_LINKER@ && !@cf_cv_enable_reentrant@" 272 print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" 273 print "/* reentrancy enabled */" 274 print "#elif @cf_cv_enable_reentrant@" 275 print "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);" 276 print "#define cur_term NCURSES_PUBLIC_VAR(cur_term())" 277 print "#else" 278 print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" 279 print "#endif" 280 print "" 281 print "/* configured with --enable-broken_linker or reentrancy enabled */" 282 print "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@" 283 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);" 284 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);" 285 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);" 286 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);" 287 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);" 288 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);" 289 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);" 290 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);" 291 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);" 292 print "" 293 print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())" 294 print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())" 295 print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())" 296 print "#define numnames NCURSES_PUBLIC_VAR(numnames())" 297 print "#define numcodes NCURSES_PUBLIC_VAR(numcodes())" 298 print "#define numfnames NCURSES_PUBLIC_VAR(numfnames())" 299 print "#define strnames NCURSES_PUBLIC_VAR(strnames())" 300 print "#define strcodes NCURSES_PUBLIC_VAR(strcodes())" 301 print "#define strfnames NCURSES_PUBLIC_VAR(strfnames())" 302 print "" 303 print "#else" 304 print "" 305 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];" 306 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];" 307 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];" 308 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];" 309 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];" 310 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];" 311 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];" 312 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];" 313 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];" 314 print "" 315 print "#endif" 316 print "" 317 print "/*" 318 print " * These entrypoints are used only by the ncurses utilities such as tic." 319 print " */" 320 print "#ifdef NCURSES_INTERNALS" 321 print "" 322 print "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);" 323 print "extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const);" 324 print "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *);" 325 print "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int);" 326 print "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);" 327 print "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);" 328 print "extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...);" 329 print "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);" 330 print "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);" 331 print "" 332 print "#endif /* NCURSES_INTERNALS */" 333 print "" 334 print "/*" 335 print " * Normal entry points" 336 print " */" 337 print "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);" 338 print "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);" 339 print "" 340 print "/* miscellaneous entry points */" 341 print "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);" 342 print "extern NCURSES_EXPORT(int) setupterm (const char *,int,int *);" 343 print "" 344 print "/* terminfo entry points, also declared in curses.h */" 345 print "#if !defined(__NCURSES_H)" 346 print "extern NCURSES_EXPORT(char *) tigetstr (const char *);" 347 print "extern NCURSES_EXPORT_VAR(char) ttytype[];" 348 print "extern NCURSES_EXPORT(int) putp (const char *);" 349 print "extern NCURSES_EXPORT(int) tigetflag (const char *);" 350 print "extern NCURSES_EXPORT(int) tigetnum (const char *);" 351 print "" 352 print "/* configured without --disable-tparm-varargs? */" 353 print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */" 354 print "extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */" 355 print "#else" 356 print "extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long); /* special */" 357 print "#endif" 358 print "" 359 print "extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */" 360 print "extern NCURSES_EXPORT(char *) tiparm_s (int, int, const char *, ...); /* special */" 361 print "extern NCURSES_EXPORT(int) tiscan_s (int *, int *, const char *); /* special */" 362 print "" 363 print "#endif /* __NCURSES_H */" 364 print "" 365 print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */" 366 print "#if !defined(NCURSES_TERMCAP_H_incl)" 367 print "extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);" 368 print "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);" 369 print "extern NCURSES_EXPORT(int) tgetent (char *, const char *);" 370 print "extern NCURSES_EXPORT(int) tgetflag (const char *);" 371 print "extern NCURSES_EXPORT(int) tgetnum (const char *);" 372 print "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));" 373 print "#endif /* NCURSES_TERMCAP_H_incl */" 374 print "" 375 print "/*" 376 print " * Include curses.h before term.h to enable these extensions." 377 print " */" 378 print "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)" 379 print "" 380 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *);" 381 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *);" 382 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *);" 383 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *);" 384 print "" 385 print "/* configured without --disable-tparm-varargs? */" 386 print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */" 387 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...); /* special */" 388 print "#else" 389 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long); /* special */" 390 print "#endif" 391 print "" 392 print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */" 393 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **);" 394 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);" 395 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);" 396 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *);" 397 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *);" 398 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);" 399 print "" 400 print "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);" 401 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);" 402 print "" 403 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);" 404 print "#endif /* NCURSES_SP_FUNCS */" 405 print "" 406 print "/*" 407 print " * Debugging features." 408 print " */" 409 print "extern GCC_NORETURN NCURSES_EXPORT(void) exit_terminfo(int);" 410 print "" 411 print "#ifdef __cplusplus" 412 printf "%s\n", rcurl; 413 print "#endif" 414 print "" 415 print "#endif /* NCURSES_TERM_H_incl */" 416} 417