fm/ipmitopo: fix 64-bit compilation
[unleashed.git] / contrib / ncurses / include / MKterm.h.awk
blobccea39f0be8a47b66c0665c62f8b0ec55b6d02a5
1 # vile:awkmode
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 */"
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;
25 BEGIN {
26 lcurl = "{";
27 rcurl = "}";
28 print "/****************************************************************************"
29 print " * Copyright (c) 1998-2013,2017 Free Software Foundation, Inc. *"
30 print " * *"
31 print " * Permission is hereby granted, free of charge, to any person obtaining a *"
32 print " * copy of this software and associated documentation files (the *"
33 print " * \"Software\"), to deal in the Software without restriction, including *"
34 print " * without limitation the rights to use, copy, modify, merge, publish, *"
35 print " * distribute, distribute with modifications, sublicense, and/or sell *"
36 print " * copies of the Software, and to permit persons to whom the Software is *"
37 print " * furnished to do so, subject to the following conditions: *"
38 print " * *"
39 print " * The above copyright notice and this permission notice shall be included *"
40 print " * in all copies or substantial portions of the Software. *"
41 print " * *"
42 print " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS *"
43 print " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *"
44 print " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *"
45 print " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *"
46 print " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *"
47 print " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *"
48 print " * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *"
49 print " * *"
50 print " * Except as contained in this notice, the name(s) of the above copyright *"
51 print " * holders shall not be used in advertising or otherwise to promote the *"
52 print " * sale, use or other dealings in this Software without prior written *"
53 print " * authorization. *"
54 print " ****************************************************************************/"
55 print ""
56 print "/****************************************************************************/"
57 print "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */"
58 print "/* and: Eric S. Raymond <esr@snark.thyrsus.com> */"
59 print "/* and: Thomas E. Dickey 1995-on */"
60 print "/****************************************************************************/"
61 print ""
62 print "/* $Id: MKterm.h.awk.in,v 1.67 2017/04/06 00:19:26 tom Exp $ */"
63 print ""
64 print "/*"
65 print "** term.h -- Definition of struct term"
66 print "*/"
67 print ""
68 print "#ifndef NCURSES_TERM_H_incl"
69 print "#define NCURSES_TERM_H_incl 1"
70 print ""
71 print "#undef NCURSES_VERSION"
72 print "#define NCURSES_VERSION \"6.0\""
73 print ""
74 print "#include <ncurses_dll.h>"
75 print ""
76 print "#ifdef __cplusplus"
77 printf "extern \"C\" %s\n", lcurl;
78 print "#endif"
79 print ""
80 print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
81 print " * definition (based on the system for which this was configured)."
82 print " */"
83 print ""
84 print "#undef NCURSES_CONST"
85 print "#define NCURSES_CONST const"
86 print ""
87 print "#undef NCURSES_SBOOL"
88 print "#define NCURSES_SBOOL char"
89 print ""
90 print "#undef NCURSES_USE_DATABASE"
91 print "#define NCURSES_USE_DATABASE 1"
92 print ""
93 print "#undef NCURSES_USE_TERMCAP"
94 print "#define NCURSES_USE_TERMCAP 0"
95 print ""
96 print "#undef NCURSES_XNAMES"
97 print "#define NCURSES_XNAMES 1"
98 print ""
99 print "/* We will use these symbols to hide differences between"
100 print " * termios/termio/sgttyb interfaces."
101 print " */"
102 print "#undef TTY"
103 print "#undef SET_TTY"
104 print "#undef GET_TTY"
105 print ""
106 print "/* Assume POSIX termio if we have the header and function */"
107 print "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
108 print "#if 1 && 1"
109 print ""
110 print "#undef TERMIOS"
111 print "#define TERMIOS 1"
112 print ""
113 print "#include <termios.h>"
114 print "#define TTY struct termios"
115 print ""
116 print "#else /* !HAVE_TERMIOS_H */"
117 print ""
118 print "/* #if HAVE_TERMIO_H */"
119 print "#if 1"
120 print ""
121 print "#undef TERMIOS"
122 print "#define TERMIOS 1"
123 print ""
124 print "#include <termio.h>"
125 print "#define TTY struct termio"
126 print ""
127 print "#else /* !HAVE_TERMIO_H */"
128 print ""
129 print "#if __MINGW32__"
130 print "# include <ncurses_mingw.h>"
131 print "# define TTY struct termios"
132 print "#else"
133 print "#undef TERMIOS"
134 print "#include <sgtty.h>"
135 print "#include <sys/ioctl.h>"
136 print "#define TTY struct sgttyb"
137 print "#endif /* MINGW32 */"
138 print "#endif /* HAVE_TERMIO_H */"
139 print ""
140 print "#endif /* HAVE_TERMIOS_H */"
141 print ""
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)"
145 print "#else"
146 print "#define GET_TTY(fd, buf) gtty(fd, buf)"
147 print "#define SET_TTY(fd, buf) stty(fd, buf)"
148 print "#endif"
149 print ""
150 print "#define NAMESIZE 256"
151 print ""
152 print "/* The cast works because TERMTYPE is the first data in TERMINAL */"
153 print "#define CUR ((TERMTYPE *)(cur_term))->"
154 print ""
157 $2 == "%%-STOP-HERE-%%" {
158 print ""
159 printf "#define BOOLWRITE %d\n", BoolCount
160 printf "#define NUMWRITE %d\n", NumberCount
161 printf "#define STRWRITE %d\n", StringCount
162 print ""
163 print "/* older synonyms for some capabilities */"
164 print "#define beehive_glitch no_esc_ctlc"
165 print "#define teleray_glitch dest_tabs_magic_smso"
166 print "#define micro_char_size micro_col_size"
167 print ""
168 print "#ifdef __INTERNAL_CAPS_VISIBLE"
171 /^#/ {
172 next;
175 $1 == "acs_chars" {
176 acsindex = StringCount;
179 $3 == "bool" {
180 printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
183 $3 == "num" {
184 printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
187 $3 == "str" {
188 printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
191 END {
192 print "#endif /* __INTERNAL_CAPS_VISIBLE */"
193 print ""
194 print ""
195 print "/*"
196 print " * Predefined terminfo array sizes"
197 print " */"
198 printf "#define BOOLCOUNT %d\n", BoolCount
199 printf "#define NUMCOUNT %d\n", NumberCount
200 printf "#define STRCOUNT %d\n", StringCount
201 print ""
202 print "/* used by code for comparing entries */"
203 print "#define acs_chars_index ", acsindex
204 print ""
205 declare_termtype("short","");
206 print ""
207 print "/*"
208 print " * The only reason these structures are visible is for read-only use."
209 print " * Programs which modify the data are not, never were, portable across"
210 print " * curses implementations."
211 print " */"
212 print "#ifdef NCURSES_INTERNALS"
213 print ""
214 if (1) {
215 declare_termtype("int","2");
216 } else {
217 print "typedef TERMTYPE TERMTYPE2;"
219 print ""
220 print "typedef struct term { /* describe an actual terminal */"
221 print " TERMTYPE type; /* terminal type description */"
222 print " short Filedes; /* file description being written to */"
223 print " TTY Ottyb; /* original state of the terminal */"
224 print " TTY Nttyb; /* current state of the terminal */"
225 print " int _baudrate; /* used to compute padding */"
226 print " char * _termname; /* used for termname() */"
227 if (1) {
228 print " TERMTYPE2 type2; /* extended terminal type description */"
230 print "} TERMINAL;"
231 print "#else"
232 print "typedef struct term TERMINAL;"
233 print "#endif /* NCURSES_INTERNALS */"
234 print ""
235 print ""
236 print "#if 0 && !0"
237 print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
238 print "#elif 0"
239 print "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
240 print "#define cur_term NCURSES_PUBLIC_VAR(cur_term())"
241 print "#else"
242 print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
243 print "#endif"
244 print ""
245 print "#if 0 || 0"
246 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
247 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
248 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
249 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
250 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
251 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
252 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
253 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
254 print "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
255 print ""
256 print "#define boolnames NCURSES_PUBLIC_VAR(boolnames())"
257 print "#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())"
258 print "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
259 print "#define numnames NCURSES_PUBLIC_VAR(numnames())"
260 print "#define numcodes NCURSES_PUBLIC_VAR(numcodes())"
261 print "#define numfnames NCURSES_PUBLIC_VAR(numfnames())"
262 print "#define strnames NCURSES_PUBLIC_VAR(strnames())"
263 print "#define strcodes NCURSES_PUBLIC_VAR(strcodes())"
264 print "#define strfnames NCURSES_PUBLIC_VAR(strfnames())"
265 print ""
266 print "#else"
267 print ""
268 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
269 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
270 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
271 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
272 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
273 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
274 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
275 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
276 print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
277 print ""
278 print "#endif"
279 print ""
280 print "/*"
281 print " * These entrypoints are used only by the ncurses utilities such as tic."
282 print " */"
283 print "#ifdef NCURSES_INTERNALS"
284 print ""
285 print "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
286 print "extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const);"
287 print "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *);"
288 print "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int);"
289 print "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
290 print "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
291 print ""
292 print "#endif /* NCURSES_INTERNALS */"
293 print ""
294 print ""
295 print "/*"
296 print " * These entrypoints are used by tack."
297 print " */"
298 print "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
299 print "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
300 print ""
301 print "/* Normal entry points */"
302 print "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
303 print "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
304 print ""
305 print "/* miscellaneous entry points */"
306 print "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
307 print "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
308 print ""
309 print "/* terminfo entry points, also declared in curses.h */"
310 print "#if !defined(__NCURSES_H)"
311 print "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
312 print "extern NCURSES_EXPORT_VAR(char) ttytype[];"
313 print "extern NCURSES_EXPORT(int) putp (const char *);"
314 print "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
315 print "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
316 print ""
317 print "#if 1 /* NCURSES_TPARM_VARARGS */"
318 print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* special */"
319 print "#else"
320 print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* special */"
321 print "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...); /* special */"
322 print "#endif"
323 print ""
324 print "extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */"
325 print ""
326 print "#endif /* __NCURSES_H */"
327 print ""
328 print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
329 print "#if !defined(NCURSES_TERMCAP_H_incl)"
330 print "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
331 print "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
332 print "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
333 print "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
334 print "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
335 print "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
336 print "#endif /* NCURSES_TERMCAP_H_incl */"
337 print ""
338 print "/*"
339 print " * Include curses.h before term.h to enable these extensions."
340 print " */"
341 print "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)"
342 print ""
343 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, NCURSES_CONST char *);"
344 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *);"
345 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, NCURSES_CONST char *);"
346 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, NCURSES_CONST char *);"
347 print ""
348 print "#if 1 /* NCURSES_TPARM_VARARGS */"
349 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, ...); /* special */"
350 print "#else"
351 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* special */"
352 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm_varargs) (SCREEN*, NCURSES_CONST char *, ...); /* special */"
353 print "#endif"
354 print ""
355 print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
356 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, NCURSES_CONST char *, char **);"
357 print "extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);"
358 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);"
359 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);"
360 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);"
361 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);"
362 print ""
363 print "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);"
364 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);"
365 print ""
366 print "extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);"
367 print "#endif /* NCURSES_SP_FUNCS */"
368 print ""
369 print "#ifdef __cplusplus"
370 printf "%s\n", rcurl;
371 print "#endif"
372 print ""
373 print "#endif /* NCURSES_TERM_H_incl */"