Sync with HEAD.
[dragonfly.git] / lib / libncurses / include / MKterm.h.awk
blob2f47f7d3be582bb962f0c69524141d10ffac1e99
1 # $DragonFly: src/lib/libncurses/include/MKterm.h.awk,v 1.3 2005/07/29 14:20:11 joerg Exp $
2 BEGIN {
3 print "/****************************************************************************"
4 print " * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc. *"
5 print " * *"
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: *"
13 print " * *"
14 print " * The above copyright notice and this permission notice shall be included *"
15 print " * in all copies or substantial portions of the Software. *"
16 print " * *"
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. *"
24 print " * *"
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 " ****************************************************************************/"
30 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-2003 */"
35 print "/****************************************************************************/"
36 print ""
37 print "/* $Id: MKterm.h.awk.in,v 1.42 2003/12/27 19:09:16 tom Exp $ */"
38 print ""
39 print "/*"
40 print "** term.h -- Definition of struct term"
41 print "*/"
42 print ""
43 print "#ifndef NCURSES_TERM_H_incl"
44 print "#define NCURSES_TERM_H_incl 1"
45 print ""
46 print "#undef NCURSES_VERSION"
47 print "#define NCURSES_VERSION \"5.4\""
48 print ""
49 print "#if 0"
50 print "#include <ncurses_dll.h>"
51 print "#else"
52 print "/* From ncurses_dll.h */"
53 print "/* This is copied so we don't need to install "
54 print " ncurses_dll.h as well */"
55 print "/* Take care of non-cygwin platforms */"
56 print "#if !defined(NCURSES_IMPEXP)"
57 print "# define NCURSES_IMPEXP /* nothing */"
58 print "#endif"
59 print "#if !defined(NCURSES_API)"
60 print "# define NCURSES_API /* nothing */"
61 print "#endif"
62 print "#if !defined(NCURSES_EXPORT)"
63 print "# define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API"
64 print "#endif"
65 print "#if !defined(NCURSES_EXPORT_VAR)"
66 print "# define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type"
67 print "#endif"
68 print "#endif"
69 print "#"
70 print ""
71 print "#ifdef __cplusplus"
72 print "extern \"C\" {"
73 print "#endif"
74 print ""
75 print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
76 print " * definition (based on the system for which this was configured)."
77 print " */"
78 print ""
79 print "#undef HAVE_TERMIOS_H"
80 print "#define HAVE_TERMIOS_H 1/*default*/"
81 print ""
82 print "#undef HAVE_TCGETATTR"
83 print "#define HAVE_TCGETATTR 1/*default*/"
84 print ""
85 print "#undef NCURSES_CONST"
86 print "#define NCURSES_CONST const"
87 print ""
88 print "#undef NCURSES_XNAMES"
89 print "#define NCURSES_XNAMES 1"
90 print ""
91 print "/* We will use these symbols to hide differences between"
92 print " * termios/termio/sgttyb interfaces."
93 print " */"
94 print "#undef TTY"
95 print "#undef SET_TTY"
96 print "#undef GET_TTY"
97 print ""
98 print "/* Assume POSIX termio if we have the header and function */"
99 print "#if HAVE_TERMIOS_H && HAVE_TCGETATTR"
100 print ""
101 print "#undef TERMIOS"
102 print "#define TERMIOS 1"
103 print ""
104 print "#include <termios.h>"
105 print "#define TTY struct termios"
106 print ""
107 print "#else /* !HAVE_TERMIOS_H */"
108 print ""
109 print "#if HAVE_TERMIO_H"
110 print ""
111 print "#undef TERMIOS"
112 print "#define TERMIOS 1"
113 print ""
114 print "#include <termio.h>"
115 print "#define TTY struct termio"
116 print ""
117 print "/* Add definitions to make termio look like termios."
118 print " * But ifdef it, since there are some implementations"
119 print " * that try to do this for us in a fake <termio.h>."
120 print " */"
121 print "#ifndef TCSANOW"
122 print "#define TCSANOW TCSETA"
123 print "#endif"
124 print "#ifndef TCSADRAIN"
125 print "#define TCSADRAIN TCSETAW"
126 print "#endif"
127 print "#ifndef TCSAFLUSH"
128 print "#define TCSAFLUSH TCSETAF"
129 print "#endif"
130 print "#ifndef tcsetattr"
131 print "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
132 print "#endif"
133 print "#ifndef tcgetattr"
134 print "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
135 print "#endif"
136 print "#ifndef cfgetospeed"
137 print "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
138 print "#endif"
139 print "#ifndef TCIFLUSH "
140 print "#define TCIFLUSH 0"
141 print "#endif"
142 print "#ifndef TCOFLUSH "
143 print "#define TCOFLUSH 1"
144 print "#endif"
145 print "#ifndef TCIOFLUSH "
146 print "#define TCIOFLUSH 2"
147 print "#endif"
148 print "#ifndef tcflush"
149 print "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
150 print "#endif"
151 print ""
152 print "#else /* !HAVE_TERMIO_H */"
153 print ""
154 print "#undef TERMIOS"
155 print "#include <sgtty.h>"
156 print "#include <sys/ioctl.h>"
157 print "#define TTY struct sgttyb"
158 print ""
159 print "#endif /* HAVE_TERMIO_H */"
160 print ""
161 print "#endif /* HAVE_TERMIOS_H */"
162 print ""
163 print "#ifdef TERMIOS"
164 print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
165 print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
166 print "#else"
167 print "#define GET_TTY(fd, buf) gtty(fd, buf)"
168 print "#define SET_TTY(fd, buf) stty(fd, buf)"
169 print "#endif"
170 print ""
171 print "#define NAMESIZE 256"
172 print ""
173 print "#define CUR cur_term->type."
174 print ""
177 $2 == "%%-STOP-HERE-%%" {
178 print ""
179 printf "#define BOOLWRITE %d\n", BoolCount
180 printf "#define NUMWRITE %d\n", NumberCount
181 printf "#define STRWRITE %d\n", StringCount
182 print ""
183 print "/* older synonyms for some capabilities */"
184 print "#define beehive_glitch no_esc_ctlc"
185 print "#define teleray_glitch dest_tabs_magic_smso"
186 print "#define micro_char_size micro_col_size"
187 print ""
188 print "#ifdef __INTERNAL_CAPS_VISIBLE"
191 /^#/ {next;}
193 $1 == "acs_chars" {acsindex = StringCount}
195 $3 == "bool" {
196 printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
199 $3 == "num" {
200 printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
203 $3 == "str" {
204 printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
207 END {
208 print "#endif /* __INTERNAL_CAPS_VISIBLE */"
209 print ""
210 print ""
211 print "/*"
212 print " * Predefined terminfo array sizes"
213 print " */"
214 printf "#define BOOLCOUNT %d\n", BoolCount
215 printf "#define NUMCOUNT %d\n", NumberCount
216 printf "#define STRCOUNT %d\n", StringCount
217 print ""
218 print "/* used by code for comparing entries */"
219 print "#define acs_chars_index ", acsindex
220 print ""
221 print "typedef struct termtype { /* in-core form of terminfo data */"
222 print " char *term_names; /* str_table offset of term names */"
223 print " char *str_table; /* pointer to string table */"
224 print " char *Booleans; /* array of boolean values */"
225 print " short *Numbers; /* array of integer values */"
226 print " char **Strings; /* array of string offsets */"
227 print ""
228 print "#if NCURSES_XNAMES"
229 print " char *ext_str_table; /* pointer to extended string table */"
230 print " char **ext_Names; /* corresponding names */"
231 print ""
232 print " unsigned short num_Booleans;/* count total Booleans */"
233 print " unsigned short num_Numbers; /* count total Numbers */"
234 print " unsigned short num_Strings; /* count total Strings */"
235 print ""
236 print " unsigned short ext_Booleans;/* count extensions to Booleans */"
237 print " unsigned short ext_Numbers; /* count extensions to Numbers */"
238 print " unsigned short ext_Strings; /* count extensions to Strings */"
239 print "#endif /* NCURSES_XNAMES */"
240 print ""
241 print "} TERMTYPE;"
242 print ""
243 print "typedef struct term { /* describe an actual terminal */"
244 print " TERMTYPE type; /* terminal type description */"
245 print " short Filedes; /* file description being written to */"
246 print " TTY Ottyb, /* original state of the terminal */"
247 print " Nttyb; /* current state of the terminal */"
248 print " int _baudrate; /* used to compute padding */"
249 print " char * _termname; /* used for termname() */"
250 print "} TERMINAL;"
251 print ""
252 print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
253 print ""
254 print "#if BROKEN_LINKER"
255 print "#define boolnames _nc_boolnames()"
256 print "#define boolcodes _nc_boolcodes()"
257 print "#define boolfnames _nc_boolfnames()"
258 print "#define numnames _nc_numnames()"
259 print "#define numcodes _nc_numcodes()"
260 print "#define numfnames _nc_numfnames()"
261 print "#define strnames _nc_strnames()"
262 print "#define strcodes _nc_strcodes()"
263 print "#define strfnames _nc_strfnames()"
264 print ""
265 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolnames (void);"
266 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolcodes (void);"
267 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolfnames (void);"
268 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numnames (void);"
269 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numcodes (void);"
270 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numfnames (void);"
271 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strnames (void);"
272 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strcodes (void);"
273 print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strfnames (void);"
274 print ""
275 print "#else"
276 print ""
277 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
278 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
279 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
280 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
281 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
282 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
283 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
284 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
285 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
286 print ""
287 print "#endif"
288 print ""
289 print "/* internals */"
290 print "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
291 print "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);"
292 print "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
293 print "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
294 print "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
295 print "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
296 print "extern NCURSES_EXPORT(int) _nc_read_termcap_entry (const char *const, TERMTYPE *const);"
297 print "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
298 print ""
299 print "/* entry points */"
300 print "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
301 print "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
302 print ""
303 print "/* miscellaneous entry points */"
304 print "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
305 print "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
306 print ""
307 print "/* terminfo entry points, also declared in curses.h */"
308 print "#if !defined(__NCURSES_H)"
309 print "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
310 print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);"
311 print "extern NCURSES_EXPORT_VAR(char) ttytype[];"
312 print "extern NCURSES_EXPORT(int) putp (const char *);"
313 print "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
314 print "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
315 print "#endif /* __NCURSES_H */"
316 print ""
317 print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
318 print "#if !defined(NCURSES_TERMCAP_H_incl)"
319 print "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
320 print "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
321 print "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
322 print "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
323 print "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
324 print "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
325 print "#endif /* NCURSES_TERMCAP_H_incl */"
326 print ""
327 print "#ifdef __cplusplus"
328 print "}"
329 print "#endif"
330 print ""
331 print "#endif /* NCURSES_TERM_H_incl */"