MKterm.h.awk.in revision 166124
1BEGIN		{
2		    print  "/****************************************************************************"
3		    print  " * Copyright (c) 1998-2003,2006 Free Software Foundation, Inc.              *"
4		    print  " *                                                                          *"
5		    print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
6		    print  " * copy of this software and associated documentation files (the            *"
7		    print  " * \"Software\"), to deal in the Software without restriction, including      *"
8		    print  " * without limitation the rights to use, copy, modify, merge, publish,      *"
9		    print  " * distribute, distribute with modifications, sublicense, and/or sell       *"
10		    print  " * copies of the Software, and to permit persons to whom the Software is    *"
11		    print  " * furnished to do so, subject to the following conditions:                 *"
12		    print  " *                                                                          *"
13		    print  " * The above copyright notice and this permission notice shall be included  *"
14		    print  " * in all copies or substantial portions of the Software.                   *"
15		    print  " *                                                                          *"
16		    print  " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *"
17		    print  " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *"
18		    print  " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *"
19		    print  " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *"
20		    print  " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *"
21		    print  " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *"
22		    print  " * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *"
23		    print  " *                                                                          *"
24		    print  " * Except as contained in this notice, the name(s) of the above copyright   *"
25		    print  " * holders shall not be used in advertising or otherwise to promote the     *"
26		    print  " * sale, use or other dealings in this Software without prior written       *"
27		    print  " * authorization.                                                           *"
28		    print  " ****************************************************************************/"
29		    print  ""
30		    print  "/****************************************************************************/"
31		    print  "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995                */"
32		    print  "/*    and: Eric S. Raymond <esr@snark.thyrsus.com>                          */"
33		    print  "/*    and: Thomas E. Dickey                        1995-on                  */"
34		    print  "/****************************************************************************/"
35		    print  ""
36		    print  "/* $Id: MKterm.h.awk.in,v 1.47 2006/11/26 01:18:23 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  " * definition (based on the system for which this was configured)."
56		    print  " */"
57		    print  ""
58		    print  "#undef  NCURSES_CONST"
59		    print  "#define NCURSES_CONST @NCURSES_CONST@"
60		    print  ""
61		    print  "#undef  NCURSES_SBOOL"
62		    print  "#define NCURSES_SBOOL @NCURSES_SBOOL@"
63		    print  ""
64		    print  "#undef  NCURSES_XNAMES"
65		    print  "#define NCURSES_XNAMES @NCURSES_XNAMES@"
66		    print  ""
67		    print  "/* We will use these symbols to hide differences between"
68		    print  " * termios/termio/sgttyb interfaces."
69		    print  " */"
70		    print  "#undef  TTY"
71		    print  "#undef  SET_TTY"
72		    print  "#undef  GET_TTY"
73		    print  ""
74		    print  "/* Assume POSIX termio if we have the header and function */"
75		    print  "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
76		    print  "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
77		    print  ""
78		    print  "#undef  TERMIOS"
79		    print  "#define TERMIOS 1"
80		    print  ""
81		    print  "#include <termios.h>"
82		    print  "#define TTY struct termios"
83		    print  ""
84		    print  "#else /* !HAVE_TERMIOS_H */"
85		    print  ""
86		    print  "/* #if HAVE_TERMIO_H */"
87		    print  "#if @HAVE_TERMIO_H@"
88		    print  ""
89		    print  "#undef  TERMIOS"
90		    print  "#define TERMIOS 1"
91		    print  ""
92		    print  "#include <termio.h>"
93		    print  "#define TTY struct termio"
94		    print  ""
95		    print  "/* Add definitions to make termio look like termios."
96		    print  " * But ifdef it, since there are some implementations"
97		    print  " * that try to do this for us in a fake <termio.h>."
98		    print  " */"
99		    print  "#ifndef TCSANOW"
100		    print  "#define TCSANOW TCSETA"
101		    print  "#endif"
102		    print  "#ifndef TCSADRAIN"
103		    print  "#define TCSADRAIN TCSETAW"
104		    print  "#endif"
105		    print  "#ifndef TCSAFLUSH"
106		    print  "#define TCSAFLUSH TCSETAF"
107		    print  "#endif"
108		    print  "#ifndef tcsetattr"
109		    print  "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
110		    print  "#endif"
111		    print  "#ifndef tcgetattr"
112		    print  "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
113		    print  "#endif"
114		    print  "#ifndef cfgetospeed"
115		    print  "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
116		    print  "#endif"
117		    print  "#ifndef TCIFLUSH "
118		    print  "#define TCIFLUSH 0"
119		    print  "#endif"
120		    print  "#ifndef TCOFLUSH "
121		    print  "#define TCOFLUSH 1"
122		    print  "#endif"
123		    print  "#ifndef TCIOFLUSH "
124		    print  "#define TCIOFLUSH 2"
125		    print  "#endif"
126		    print  "#ifndef tcflush"
127		    print  "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
128		    print  "#endif"
129		    print  ""
130		    print  "#else /* !HAVE_TERMIO_H */"
131		    print  ""
132		    print  "#undef TERMIOS"
133		    print  "#include <sgtty.h>"
134		    print  "#include <sys/ioctl.h>"
135		    print  "#define TTY struct sgttyb"
136		    print  ""
137		    print  "#endif /* HAVE_TERMIO_H */"
138		    print  ""
139		    print  "#endif /* HAVE_TERMIOS_H */"
140		    print  ""
141		    print  "#ifdef TERMIOS"
142		    print  "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
143		    print  "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
144		    print  "#else"
145		    print  "#define GET_TTY(fd, buf) gtty(fd, buf)"
146		    print  "#define SET_TTY(fd, buf) stty(fd, buf)"
147		    print  "#endif"
148		    print  ""
149		    print  "#define NAMESIZE 256"
150		    print  ""
151		    print  "#define CUR cur_term->type."
152		    print  ""
153		}
154
155$2 == "%%-STOP-HERE-%%"	{
156			print  ""
157			printf "#define BOOLWRITE %d\n", BoolCount
158			printf "#define NUMWRITE  %d\n", NumberCount
159			printf "#define STRWRITE  %d\n", StringCount
160			print  ""
161			print  "/* older synonyms for some capabilities */"
162			print  "#define beehive_glitch	no_esc_ctlc"
163			print  "#define teleray_glitch	dest_tabs_magic_smso"
164			print  "#define micro_char_size micro_col_size"
165			print  ""
166			print  "#ifdef __INTERNAL_CAPS_VISIBLE"
167		}
168
169/^#/		{next;}
170
171$1 == "acs_chars"	{acsindex = StringCount}
172
173$3 == "bool"	{
174		    printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
175		}
176
177$3 == "num"	{
178		    printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
179		}
180
181$3 == "str"	{
182		    printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
183		}
184
185END		{
186			print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
187			print  ""
188			print  ""
189			print  "/*"
190			print  " * Predefined terminfo array sizes"
191			print  " */"
192			printf "#define BOOLCOUNT %d\n", BoolCount
193			printf "#define NUMCOUNT  %d\n", NumberCount
194			printf "#define STRCOUNT  %d\n", StringCount
195			print  ""
196			print  "/* used by code for comparing entries */"
197			print  "#define acs_chars_index	", acsindex
198			print  ""
199			print  "typedef struct termtype {	/* in-core form of terminfo data */"
200			print  "    char  *term_names;		/* str_table offset of term names */"
201			print  "    char  *str_table;		/* pointer to string table */"
202			print  "    NCURSES_SBOOL  *Booleans;	/* array of boolean values */"
203			print  "    short *Numbers;		/* array of integer values */"
204			print  "    char  **Strings;		/* array of string offsets */"
205			print  ""
206			print  "#if NCURSES_XNAMES"
207			print  "    char  *ext_str_table;	/* pointer to extended string table */"
208			print  "    char  **ext_Names;		/* corresponding names */"
209			print  ""
210			print  "    unsigned short num_Booleans;/* count total Booleans */"
211			print  "    unsigned short num_Numbers;	/* count total Numbers */"
212			print  "    unsigned short num_Strings;	/* count total Strings */"
213			print  ""
214			print  "    unsigned short ext_Booleans;/* count extensions to Booleans */"
215			print  "    unsigned short ext_Numbers;	/* count extensions to Numbers */"
216			print  "    unsigned short ext_Strings;	/* count extensions to Strings */"
217			print  "#endif /* NCURSES_XNAMES */"
218			print  ""
219			print  "} TERMTYPE;"
220			print  ""
221			print  "typedef struct term {		/* describe an actual terminal */"
222			print  "    TERMTYPE	type;		/* terminal type description */"
223			print  "    short	Filedes;	/* file description being written to */"
224			print  "    TTY		Ottyb,		/* original state of the terminal */"
225			print  "		Nttyb;		/* current state of the terminal */"
226			print  "    int		_baudrate;	/* used to compute padding */"
227			print  "    char *      _termname;      /* used for termname() */"
228			print  "} TERMINAL;"
229			print  ""
230			print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
231			print  ""
232			print  "#if BROKEN_LINKER"
233			print  "#define boolnames  _nc_boolnames()"
234			print  "#define boolcodes  _nc_boolcodes()"
235			print  "#define boolfnames _nc_boolfnames()"
236			print  "#define numnames   _nc_numnames()"
237			print  "#define numcodes   _nc_numcodes()"
238			print  "#define numfnames  _nc_numfnames()"
239			print  "#define strnames   _nc_strnames()"
240			print  "#define strcodes   _nc_strcodes()"
241			print  "#define strfnames  _nc_strfnames()"
242			print  ""
243			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolnames (void);"
244			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolcodes (void);"
245			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolfnames (void);"
246			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numnames (void);"
247			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numcodes (void);"
248			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numfnames (void);"
249			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strnames (void);"
250			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strcodes (void);"
251			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strfnames (void);"
252			print  ""
253			print  "#else"
254			print  ""
255			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
256			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
257			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
258			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
259			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
260			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
261			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
262			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
263			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
264			print  ""
265			print  "#endif"
266			print  ""
267			print  "/* internals */"
268			print  "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
269			print  "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);"
270			print  "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
271			print  "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
272			print  "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);"
273			print  "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
274			print  "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
275			print  "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
276			print  ""
277			print  "/* entry points */"
278			print  "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
279			print  "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
280			print  ""
281			print  "/* miscellaneous entry points */"
282			print  "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
283			print  "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
284			print  ""
285			print  "/* terminfo entry points, also declared in curses.h */"
286			print  "#if !defined(__NCURSES_H)"
287			print  "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
288			print  "extern NCURSES_EXPORT_VAR(char) ttytype[];"
289			print  "extern NCURSES_EXPORT(int) putp (const char *);"
290			print  "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
291			print  "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
292			print  ""
293			print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
294			print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* implemented */"
295			print  "#else"
296			print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);	/* implemented */"
297			print  "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);	/* implemented */"
298			print  "#endif"
299			print  ""
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