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