2 function 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 */"
10 print "#if NCURSES_XNAMES"
11 print " char *ext_str_table; /* pointer to extended string table */"
12 print " char **ext_Names; /* corresponding names */"
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 */";
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 */"
23 printf "} TERMTYPE%s;\n", suffix;
28 print "/****************************************************************************"
29 print " * Copyright 2018-2020,2021 Thomas E. Dickey *"
30 print " * Copyright 1998-2013,2017 Free Software Foundation, Inc. *"
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: *"
40 print " * The above copyright notice and this permission notice shall be included *"
41 print " * in all copies or substantial portions of the Software. *"
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. *"
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 " ****************************************************************************/"
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 "/****************************************************************************/"
63 print "/* $Id: MKterm.h.awk.in,v 1.81 2021/08/18 20:52:42 tom Exp $ */"
66 print "** term.h -- Definition of struct term"
69 print "#ifndef NCURSES_TERM_H_incl"
70 print "#define NCURSES_TERM_H_incl 1"
72 print "#undef NCURSES_VERSION"
73 print "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
75 print "#include <ncurses_dll.h>"
77 print "#ifdef __cplusplus"
78 printf "extern \"C\" %s\n", lcurl;
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)."
85 print "#ifndef __NCURSES_H"
87 print "typedef struct screen SCREEN;"
89 print "#if @NCURSES_SP_FUNCS@"
90 print "#undef NCURSES_SP_FUNCS"
91 print "#define NCURSES_SP_FUNCS @NCURSES_PATCH@"
92 print "#undef NCURSES_SP_NAME"
93 print "#define NCURSES_SP_NAME(name) name##_sp"
95 print "/* Define the sp-funcs helper function */"
96 print "#undef NCURSES_SP_OUTC"
97 print "#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)"
98 print "typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);"
101 print "#endif /* __NCURSES_H */"
103 print "#undef NCURSES_CONST"
104 print "#define NCURSES_CONST @NCURSES_CONST@"
106 print "#undef NCURSES_SBOOL"
107 print "#define NCURSES_SBOOL @NCURSES_SBOOL@"
109 print "#undef NCURSES_USE_DATABASE"
110 print "#define NCURSES_USE_DATABASE @NCURSES_USE_DATABASE@"
112 print "#undef NCURSES_USE_TERMCAP"
113 print "#define NCURSES_USE_TERMCAP @NCURSES_USE_TERMCAP@"
115 print "#undef NCURSES_XNAMES"
116 print "#define NCURSES_XNAMES @NCURSES_XNAMES@"
118 print "/* We will use these symbols to hide differences between"
119 print " * termios/termio/sgttyb interfaces."
122 print "#undef SET_TTY"
123 print "#undef GET_TTY"
125 print "/* Assume POSIX termio if we have the header and function */"
126 print "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
127 print "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
129 print "#undef TERMIOS"
130 print "#define TERMIOS 1"
132 print "#include <termios.h>"
133 print "#define TTY struct termios"
135 print "#else /* !HAVE_TERMIOS_H */"
137 print "/* #if HAVE_TERMIO_H */"
138 print "#if @HAVE_TERMIO_H@"
140 print "#undef TERMIOS"
141 print "#define TERMIOS 1"
143 print "#include <termio.h>"
144 print "#define TTY struct termio"
146 print "#else /* !HAVE_TERMIO_H */"
148 print "#if (defined(_WIN32) || defined(_WIN64))"
149 print "#if @EXP_WIN32_DRIVER@"
150 print "#include <win32_curses.h>"
151 print "#define TTY struct winconmode"
153 print "#include <ncurses_mingw.h>"
154 print "#define TTY struct termios"
157 print "#undef TERMIOS"
158 print "#include <sgtty.h>"
159 print "#include <sys/ioctl.h>"
160 print "#define TTY struct sgttyb"
161 print "#endif /* MINGW32 */"
162 print "#endif /* HAVE_TERMIO_H */"
164 print "#endif /* HAVE_TERMIOS_H */"
166 print "#ifdef TERMIOS"
167 print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
168 print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
169 print "#elif @EXP_WIN32_DRIVER@ && (defined(_WIN32) || defined(_WIN64))"
170 print "#define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf)"
171 print "#define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf)"
173 print "#define GET_TTY(fd, buf) gtty(fd, buf)"
174 print "#define SET_TTY(fd, buf) stty(fd, buf)"
177 print "#ifndef GCC_NORETURN"
178 print "#define GCC_NORETURN /* nothing */"
181 print "#define NAMESIZE 256"
183 print "/* The cast works because TERMTYPE is the first data in TERMINAL */"
184 print "#define CUR ((TERMTYPE *)(cur_term))->"
188 $2 == "%%-STOP-HERE-%%" {
190 printf "#define BOOLWRITE %d\n", BoolCount
191 printf "#define NUMWRITE %d\n", NumberCount
192 printf "#define STRWRITE %d\n", StringCount
194 print "/* older synonyms for some capabilities */"
195 print "#define beehive_glitch no_esc_ctlc"
196 print "#define teleray_glitch dest_tabs_magic_smso"
198 print "/* HPUX-11 uses this name rather than the standard one */"
199 print "#ifndef micro_char_size"
200 print "#define micro_char_size micro_col_size"
203 print "#ifdef __INTERNAL_CAPS_VISIBLE"
208 /^used_by/ { next ; }
209 /^userdef/ { next ; }
212 acsindex = StringCount;
216 printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
220 printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
224 printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
228 print "#endif /* __INTERNAL_CAPS_VISIBLE */"
232 print " * Predefined terminfo array sizes"
234 printf "#define BOOLCOUNT %d\n", BoolCount
235 printf "#define NUMCOUNT %d\n", NumberCount
236 printf "#define STRCOUNT %d\n", StringCount
238 print "/* used by code for comparing entries */"
239 print "#define acs_chars_index ", acsindex
241 declare_termtype("short","");
244 print " * The only reason these structures are visible is for read-only use."
245 print " * Programs which modify the data are not, never were, portable across"
246 print " * curses implementations."
248 print " * The first field in TERMINAL is used in macros."
249 print " * The remaining fields are private."
251 print "#ifdef NCURSES_INTERNALS"
253 if (@NCURSES_EXT_COLORS@) {
254 declare_termtype("int","2");
256 print "typedef TERMTYPE TERMTYPE2;"
259 print "typedef struct term TERMINAL;"
262 print "typedef struct term { /* describe an actual terminal */"
263 print " TERMTYPE type; /* terminal type description */"
266 print "#endif /* NCURSES_INTERNALS */"
269 print "#if @BROKEN_LINKER@ && !@cf_cv_enable_reentrant@"
270 print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
271 print "#elif @cf_cv_enable_reentrant@"
272 print "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
273 print "#define cur_term NCURSES_PUBLIC_VAR(cur_term())"
275 print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
278 print "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@"
279 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
280 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
281 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
282 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
283 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
284 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
285 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
286 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
287 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
289 print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())"
290 print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())"
291 print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
292 print "#define numnames NCURSES_PUBLIC_VAR(numnames())"
293 print "#define numcodes NCURSES_PUBLIC_VAR(numcodes())"
294 print "#define numfnames NCURSES_PUBLIC_VAR(numfnames())"
295 print "#define strnames NCURSES_PUBLIC_VAR(strnames())"
296 print "#define strcodes NCURSES_PUBLIC_VAR(strcodes())"
297 print "#define strfnames NCURSES_PUBLIC_VAR(strfnames())"
301 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
302 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
303 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
304 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
305 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
306 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
307 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
308 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
309 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
314 print " * These entrypoints are used only by the ncurses utilities such as tic."
316 print "#ifdef NCURSES_INTERNALS"
318 print "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
319 print "extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const);"
320 print "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *);"
321 print "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int);"
322 print "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
323 print "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
324 print "extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...);"
326 print "#endif /* NCURSES_INTERNALS */"
330 print " * These entrypoints are used by tack 1.07."
332 print "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
333 print "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
336 print " * Normal entry points"
338 print "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
339 print "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
341 print "/* miscellaneous entry points */"
342 print "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
343 print "extern NCURSES_EXPORT(int) setupterm (const char *,int,int *);"
345 print "/* terminfo entry points, also declared in curses.h */"
346 print "#if !defined(__NCURSES_H)"
347 print "extern NCURSES_EXPORT(char *) tigetstr (const char *);"
348 print "extern NCURSES_EXPORT_VAR(char) ttytype[];"
349 print "extern NCURSES_EXPORT(int) putp (const char *);"
350 print "extern NCURSES_EXPORT(int) tigetflag (const char *);"
351 print "extern NCURSES_EXPORT(int) tigetnum (const char *);"
353 print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
354 print "extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */"
356 print "extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long); /* special */"
359 print "extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */"
361 print "#endif /* __NCURSES_H */"
363 print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
364 print "#if !defined(NCURSES_TERMCAP_H_incl)"
365 print "extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);"
366 print "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
367 print "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
368 print "extern NCURSES_EXPORT(int) tgetflag (const char *);"
369 print "extern NCURSES_EXPORT(int) tgetnum (const char *);"
370 print "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
371 print "#endif /* NCURSES_TERMCAP_H_incl */"
374 print " * Include curses.h before term.h to enable these extensions."
376 print "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)"
378 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *);"
379 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *);"
380 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *);"
381 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *);"
383 print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
384 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...); /* special */"
386 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long); /* special */"
389 print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
390 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **);"
391 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);"
392 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);"
393 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *);"
394 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *);"
395 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);"
397 print "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);"
398 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);"
400 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);"
401 print "#endif /* NCURSES_SP_FUNCS */"
404 print " * Debugging features."
406 print "extern GCC_NORETURN NCURSES_EXPORT(void) exit_terminfo(int);"
408 print "#ifdef __cplusplus"
409 printf "%s\n", rcurl;
412 print "#endif /* NCURSES_TERM_H_incl */"