3 print "/****************************************************************************"
4 print " * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *"
6 print " * Permission is hereby granted, free of charge, to any person obtaining a *"
7 print " * copy of this software and associated documentation files (the *"
8 print " * \"Software\"), to deal in the Software without restriction, including *"
9 print " * without limitation the rights to use, copy, modify, merge, publish, *"
10 print " * distribute, distribute with modifications, sublicense, and/or sell *"
11 print " * copies of the Software, and to permit persons to whom the Software is *"
12 print " * furnished to do so, subject to the following conditions: *"
14 print " * The above copyright notice and this permission notice shall be included *"
15 print " * in all copies or substantial portions of the Software. *"
17 print " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS *"
18 print " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *"
19 print " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *"
20 print " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *"
21 print " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *"
22 print " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *"
23 print " * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *"
25 print " * Except as contained in this notice, the name(s) of the above copyright *"
26 print " * holders shall not be used in advertising or otherwise to promote the *"
27 print " * sale, use or other dealings in this Software without prior written *"
28 print " * authorization. *"
29 print " ****************************************************************************/"
31 print "/****************************************************************************/"
32 print "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */"
33 print "/* and: Eric S. Raymond <esr@snark.thyrsus.com> */"
34 print "/* and: Thomas E. Dickey 1995-on */"
35 print "/****************************************************************************/"
37 print "/* $Id: MKterm.h.awk.in,v 1.49 2007/08/18 11:44:26 tom Exp $ */"
40 print "** term.h -- Definition of struct term"
43 print "#ifndef NCURSES_TERM_H_incl"
44 print "#define NCURSES_TERM_H_incl 1"
46 print "#undef NCURSES_VERSION"
47 print "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
49 print "#include <ncurses_dll.h>"
51 print "#ifdef __cplusplus"
52 print "extern \"C\" {"
55 print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
56 print " * definition (based on the system for which this was configured)."
59 print "#undef NCURSES_CONST"
60 print "#define NCURSES_CONST @NCURSES_CONST@"
62 print "#undef NCURSES_SBOOL"
63 print "#define NCURSES_SBOOL @NCURSES_SBOOL@"
65 print "#undef NCURSES_XNAMES"
66 print "#define NCURSES_XNAMES @NCURSES_XNAMES@"
68 print "/* We will use these symbols to hide differences between"
69 print " * termios/termio/sgttyb interfaces."
72 print "#undef SET_TTY"
73 print "#undef GET_TTY"
75 print "/* Assume POSIX termio if we have the header and function */"
76 print "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
77 print "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
79 print "#undef TERMIOS"
80 print "#define TERMIOS 1"
82 print "#include <termios.h>"
83 print "#define TTY struct termios"
85 print "#else /* !HAVE_TERMIOS_H */"
87 print "/* #if HAVE_TERMIO_H */"
88 print "#if @HAVE_TERMIO_H@"
90 print "#undef TERMIOS"
91 print "#define TERMIOS 1"
93 print "#include <termio.h>"
94 print "#define TTY struct termio"
96 print "/* Add definitions to make termio look like termios."
97 print " * But ifdef it, since there are some implementations"
98 print " * that try to do this for us in a fake <termio.h>."
100 print "#ifndef TCSANOW"
101 print "#define TCSANOW TCSETA"
103 print "#ifndef TCSADRAIN"
104 print "#define TCSADRAIN TCSETAW"
106 print "#ifndef TCSAFLUSH"
107 print "#define TCSAFLUSH TCSETAF"
109 print "#ifndef tcsetattr"
110 print "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
112 print "#ifndef tcgetattr"
113 print "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
115 print "#ifndef cfgetospeed"
116 print "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
118 print "#ifndef TCIFLUSH "
119 print "#define TCIFLUSH 0"
121 print "#ifndef TCOFLUSH "
122 print "#define TCOFLUSH 1"
124 print "#ifndef TCIOFLUSH "
125 print "#define TCIOFLUSH 2"
127 print "#ifndef tcflush"
128 print "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
131 print "#else /* !HAVE_TERMIO_H */"
133 print "#undef TERMIOS"
134 print "#include <sgtty.h>"
135 print "#include <sys/ioctl.h>"
136 print "#define TTY struct sgttyb"
138 print "#endif /* HAVE_TERMIO_H */"
140 print "#endif /* HAVE_TERMIOS_H */"
142 print "#ifdef TERMIOS"
143 print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
144 print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
146 print "#define GET_TTY(fd, buf) gtty(fd, buf)"
147 print "#define SET_TTY(fd, buf) stty(fd, buf)"
150 print "#define NAMESIZE 256"
152 print "#define CUR cur_term->type."
156 $2 == "%%-STOP-HERE-%%" {
158 printf "#define BOOLWRITE %d\n", BoolCount
159 printf "#define NUMWRITE %d\n", NumberCount
160 printf "#define STRWRITE %d\n", StringCount
162 print "/* older synonyms for some capabilities */"
163 print "#define beehive_glitch no_esc_ctlc"
164 print "#define teleray_glitch dest_tabs_magic_smso"
165 print "#define micro_char_size micro_col_size"
167 print "#ifdef __INTERNAL_CAPS_VISIBLE"
172 $1 == "acs_chars" {acsindex = StringCount}
175 printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
179 printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
183 printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
187 print "#endif /* __INTERNAL_CAPS_VISIBLE */"
191 print " * Predefined terminfo array sizes"
193 printf "#define BOOLCOUNT %d\n", BoolCount
194 printf "#define NUMCOUNT %d\n", NumberCount
195 printf "#define STRCOUNT %d\n", StringCount
197 print "/* used by code for comparing entries */"
198 print "#define acs_chars_index ", acsindex
200 print "typedef struct termtype { /* in-core form of terminfo data */"
201 print " char *term_names; /* str_table offset of term names */"
202 print " char *str_table; /* pointer to string table */"
203 print " NCURSES_SBOOL *Booleans; /* array of boolean values */"
204 print " short *Numbers; /* array of integer values */"
205 print " char **Strings; /* array of string offsets */"
207 print "#if NCURSES_XNAMES"
208 print " char *ext_str_table; /* pointer to extended string table */"
209 print " char **ext_Names; /* corresponding names */"
211 print " unsigned short num_Booleans;/* count total Booleans */"
212 print " unsigned short num_Numbers; /* count total Numbers */"
213 print " unsigned short num_Strings; /* count total Strings */"
215 print " unsigned short ext_Booleans;/* count extensions to Booleans */"
216 print " unsigned short ext_Numbers; /* count extensions to Numbers */"
217 print " unsigned short ext_Strings; /* count extensions to Strings */"
218 print "#endif /* NCURSES_XNAMES */"
222 print "typedef struct term { /* describe an actual terminal */"
223 print " TERMTYPE type; /* terminal type description */"
224 print " short Filedes; /* file description being written to */"
225 print " TTY Ottyb, /* original state of the terminal */"
226 print " Nttyb; /* current state of the terminal */"
227 print " int _baudrate; /* used to compute padding */"
228 print " char * _termname; /* used for termname() */"
231 print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
233 print "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@"
234 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
235 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
236 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
237 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
238 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
239 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
240 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
241 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
242 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
244 print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())"
245 print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())"
246 print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
247 print "#define numnames NCURSES_PUBLIC_VAR(numnames())"
248 print "#define numcodes NCURSES_PUBLIC_VAR(numcodes())"
249 print "#define numfnames NCURSES_PUBLIC_VAR(numfnames())"
250 print "#define strnames NCURSES_PUBLIC_VAR(strnames())"
251 print "#define strcodes NCURSES_PUBLIC_VAR(strcodes())"
252 print "#define strfnames NCURSES_PUBLIC_VAR(strfnames())"
256 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
257 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
258 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
259 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
260 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
261 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
262 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
263 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
264 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
268 print "/* internals */"
269 print "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
270 print "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);"
271 print "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
272 print "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
273 print "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);"
274 print "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
275 print "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
276 print "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
278 print "/* entry points */"
279 print "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
280 print "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
282 print "/* miscellaneous entry points */"
283 print "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
284 print "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
286 print "/* terminfo entry points, also declared in curses.h */"
287 print "#if !defined(__NCURSES_H)"
288 print "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
289 print "extern NCURSES_EXPORT_VAR(char) ttytype[];"
290 print "extern NCURSES_EXPORT(int) putp (const char *);"
291 print "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
292 print "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
294 print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
295 print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* special */"
297 print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* special */"
298 print "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...); /* special */"
301 print "#endif /* __NCURSES_H */"
303 print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
304 print "#if !defined(NCURSES_TERMCAP_H_incl)"
305 print "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
306 print "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
307 print "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
308 print "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
309 print "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
310 print "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
311 print "#endif /* NCURSES_TERMCAP_H_incl */"
313 print "#ifdef __cplusplus"
317 print "#endif /* NCURSES_TERM_H_incl */"