MKterm.h.awk.in revision 50276
1219820Sjeff
2219820SjeffBEGIN		{
3219820Sjeff		    print  "/****************************************************************************"
4219820Sjeff		    print  " * Copyright (c) 1998 Free Software Foundation, Inc.                        *"
5219820Sjeff		    print  " *                                                                          *"
6219820Sjeff		    print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
7219820Sjeff		    print  " * copy of this software and associated documentation files (the            *"
8219820Sjeff		    print  " * "Software"), to deal in the Software without restriction, including      *"
9219820Sjeff		    print  " * without limitation the rights to use, copy, modify, merge, publish,      *"
10219820Sjeff		    print  " * distribute, distribute with modifications, sublicense, and/or sell       *"
11219820Sjeff		    print  " * copies of the Software, and to permit persons to whom the Software is    *"
12219820Sjeff		    print  " * furnished to do so, subject to the following conditions:                 *"
13219820Sjeff		    print  " *                                                                          *"
14219820Sjeff		    print  " * The above copyright notice and this permission notice shall be included  *"
15219820Sjeff		    print  " * in all copies or substantial portions of the Software.                   *"
16219820Sjeff		    print  " *                                                                          *"
17219820Sjeff		    print  " * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *"
18219820Sjeff		    print  " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *"
19219820Sjeff		    print  " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *"
20219820Sjeff		    print  " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *"
21219820Sjeff		    print  " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *"
22219820Sjeff		    print  " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *"
23219820Sjeff		    print  " * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *"
24219820Sjeff		    print  " *                                                                          *"
25219820Sjeff		    print  " * Except as contained in this notice, the name(s) of the above copyright   *"
26219820Sjeff		    print  " * holders shall not be used in advertising or otherwise to promote the     *"
27219820Sjeff		    print  " * sale, use or other dealings in this Software without prior written       *"
28219820Sjeff		    print  " * authorization.                                                           *"
29219820Sjeff		    print  " ****************************************************************************/"
30219820Sjeff		    print  ""
31219820Sjeff		    print  "/****************************************************************************/"
32219820Sjeff		    print  "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995                */"
33219820Sjeff		    print  "/*    and: Eric S. Raymond <esr@snark.thyrsus.com>                          */"
34219820Sjeff		    print  "/****************************************************************************/"
35219820Sjeff		    print  ""
36219820Sjeff		    print  "/* $Id: MKterm.h.awk.in,v 1.35 1999/02/24 01:04:55 tom Exp $ */"
37219820Sjeff		    print  ""
38219820Sjeff		    print  "/*"
39219820Sjeff		    print  "**	term.h -- Definition of struct term"
40219820Sjeff		    print  "*/"
41219820Sjeff		    print  ""
42219820Sjeff		    print  "#ifndef _NCU_TERM_H"
43219820Sjeff		    print  "#define _NCU_TERM_H 1"
44219820Sjeff		    print  ""
45219820Sjeff		    print  "#undef  NCURSES_VERSION"
46219820Sjeff		    print  "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
47219820Sjeff		    print  ""
48219820Sjeff		    print  "#ifdef __cplusplus"
49219820Sjeff		    print  "extern \"C\" {"
50219820Sjeff		    print  "#endif"
51219820Sjeff		    print  ""
52219820Sjeff		    print  "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
53219820Sjeff		    print  " * and BROKEN_LINKER definition (based on the system for which this was"
54219820Sjeff		    print  " * configured)."
55219820Sjeff		    print  " */"
56219820Sjeff		    print  ""
57219820Sjeff		    print  "#undef  HAVE_TERMIOS_H"
58219820Sjeff		    print  "#define HAVE_TERMIOS_H 1/*default*/"
59219820Sjeff		    print  ""
60219820Sjeff		    print  "#undef  HAVE_TERMIO_H"
61219820Sjeff		    print  "#define HAVE_TERMIO_H 0/*default*/"
62219820Sjeff		    print  ""
63219820Sjeff		    print  "#undef  HAVE_TCGETATTR"
64219820Sjeff		    print  "#define HAVE_TCGETATTR 1/*default*/"
65219820Sjeff		    print  ""
66219820Sjeff		    print  "#undef  BROKEN_LINKER"
67219820Sjeff		    print  "#define BROKEN_LINKER 0/*default*/"
68219820Sjeff		    print  ""
69219820Sjeff		    print  "#undef  NCURSES_CONST"
70219820Sjeff		    print  "#define NCURSES_CONST @NCURSES_CONST@"
71219820Sjeff		    print  ""
72219820Sjeff		    print  "#undef  NCURSES_XNAMES"
73219820Sjeff		    print  "#define NCURSES_XNAMES @NCURSES_XNAMES@"
74219820Sjeff		    print  ""
75219820Sjeff		    print  "/* We will use these symbols to hide differences between"
76219820Sjeff		    print  " * termios/termio/sgttyb interfaces."
77219820Sjeff		    print  " */"
78219820Sjeff		    print  "#undef  TTY"
79219820Sjeff		    print  "#undef  SET_TTY"
80219820Sjeff		    print  "#undef  GET_TTY"
81219820Sjeff		    print  ""
82219820Sjeff		    print  "/* Assume Posix termio if we have the header and function */"
83219820Sjeff		    print  "#if HAVE_TERMIOS_H && HAVE_TCGETATTR"
84219820Sjeff		    print  ""
85219820Sjeff		    print  "#undef  TERMIOS"
86219820Sjeff		    print  "#define TERMIOS 1"
87219820Sjeff		    print  ""
88219820Sjeff		    print  "#include <termios.h>"
89219820Sjeff		    print  "#define TTY struct termios"
90219820Sjeff		    print  ""
91219820Sjeff		    print  "#else /* !HAVE_TERMIOS_H */"
92219820Sjeff		    print  ""
93219820Sjeff		    print  "#if HAVE_TERMIO_H"
94219820Sjeff		    print  ""
95219820Sjeff		    print  "#undef  TERMIOS"
96219820Sjeff		    print  "#define TERMIOS 1"
97219820Sjeff		    print  ""
98219820Sjeff		    print  "#include <termio.h>"
99219820Sjeff		    print  "#define TTY struct termio"
100219820Sjeff		    print  ""
101219820Sjeff		    print  "/* Add definitions to make termio look like termios."
102219820Sjeff		    print  " * But ifdef it, since there are some implementations"
103219820Sjeff		    print  " * that try to do this for us in a fake <termio.h>."
104219820Sjeff		    print  " */"
105219820Sjeff		    print  "#ifndef TCSANOW"
106219820Sjeff		    print  "#define TCSANOW TCSETA"
107219820Sjeff		    print  "#endif"
108219820Sjeff		    print  "#ifndef TCSADRAIN"
109219820Sjeff		    print  "#define TCSADRAIN TCSETAW"
110219820Sjeff		    print  "#endif"
111219820Sjeff		    print  "#ifndef TCSAFLUSH"
112219820Sjeff		    print  "#define TCSAFLUSH TCSETAF"
113219820Sjeff		    print  "#endif"
114219820Sjeff		    print  "#ifndef tcsetattr"
115219820Sjeff		    print  "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
116219820Sjeff		    print  "#endif"
117219820Sjeff		    print  "#ifndef tcgetattr"
118219820Sjeff		    print  "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
119219820Sjeff		    print  "#endif"
120219820Sjeff		    print  "#ifndef cfgetospeed"
121219820Sjeff		    print  "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
122219820Sjeff		    print  "#endif"
123219820Sjeff		    print  "#ifndef TCIFLUSH "
124219820Sjeff		    print  "#define TCIFLUSH 0"
125219820Sjeff		    print  "#endif"
126219820Sjeff		    print  "#ifndef TCOFLUSH "
127219820Sjeff		    print  "#define TCOFLUSH 1"
128219820Sjeff		    print  "#endif"
129219820Sjeff		    print  "#ifndef TCIOFLUSH "
130219820Sjeff		    print  "#define TCIOFLUSH 2"
131219820Sjeff		    print  "#endif"
132219820Sjeff		    print  "#ifndef tcflush"
133219820Sjeff		    print  "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
134219820Sjeff		    print  "#endif"
135219820Sjeff		    print  ""
136219820Sjeff		    print  "#else /* !HAVE_TERMIO_H */"
137219820Sjeff		    print  ""
138219820Sjeff		    print  "#undef TERMIOS"
139219820Sjeff		    print  "#include <sgtty.h>"
140219820Sjeff		    print  "#include <sys/ioctl.h>"
141219820Sjeff		    print  "#define TTY struct sgttyb"
142219820Sjeff		    print  ""
143219820Sjeff		    print  "#endif /* HAVE_TERMIO_H */"
144219820Sjeff		    print  ""
145219820Sjeff		    print  "#endif /* HAVE_TERMIOS_H */"
146219820Sjeff		    print  ""
147219820Sjeff		    print  "#ifdef TERMIOS"
148219820Sjeff		    print  "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
149219820Sjeff		    print  "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
150219820Sjeff		    print  "#else"
151219820Sjeff		    print  "#define GET_TTY(fd, buf) gtty(fd, buf)"
152219820Sjeff		    print  "#define SET_TTY(fd, buf) stty(fd, buf)"
153219820Sjeff		    print  "#endif"
154219820Sjeff		    print  ""
155219820Sjeff		    print  "#define NAMESIZE 256"
156219820Sjeff		    print  ""
157219820Sjeff		    print  "#define CUR cur_term->type."
158219820Sjeff		    print  ""
159219820Sjeff		}
160219820Sjeff
161219820Sjeff$2 == "%%-STOP-HERE-%%"	{
162219820Sjeff			print  ""
163219820Sjeff			printf "#define BOOLWRITE %d\n", BoolCount
164219820Sjeff			printf "#define NUMWRITE  %d\n", NumberCount
165219820Sjeff			printf "#define STRWRITE  %d\n", StringCount
166219820Sjeff			print  ""
167219820Sjeff			print  "/* older synonyms for some capabilities */"
168219820Sjeff			print  "#define beehive_glitch	no_esc_ctlc"
169219820Sjeff			print  "#define teleray_glitch	dest_tabs_magic_smso"
170219820Sjeff			print  "#define micro_char_size micro_col_size"
171219820Sjeff			print  ""
172219820Sjeff			print  "#ifdef __INTERNAL_CAPS_VISIBLE"
173219820Sjeff		}
174219820Sjeff
175219820Sjeff/^#/		{next;}
176219820Sjeff
177219820Sjeff$3 == "bool"	{
178219820Sjeff		    printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
179219820Sjeff		}
180219820Sjeff
181219820Sjeff$3 == "num"	{
182219820Sjeff		    printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
183219820Sjeff		}
184219820Sjeff
185219820Sjeff$3 == "str"	{
186219820Sjeff		    printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
187219820Sjeff		}
188219820Sjeff
189219820SjeffEND		{
190219820Sjeff			print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
191219820Sjeff			print  ""
192219820Sjeff			print  ""
193219820Sjeff			print  "/*"
194219820Sjeff			print  " * Predefined terminfo array sizes"
195219820Sjeff			print  " */"
196219820Sjeff			printf "#define BOOLCOUNT %d\n", BoolCount
197219820Sjeff			printf "#define NUMCOUNT  %d\n", NumberCount
198219820Sjeff			printf "#define STRCOUNT  %d\n", StringCount
199219820Sjeff			print  ""
200219820Sjeff			print  "typedef struct termtype {	/* in-core form of terminfo data */"
201219820Sjeff			print  "    char  *term_names;		/* str_table offset of term names */"
202219820Sjeff			print  "    char  *str_table;		/* pointer to string table */"
203219820Sjeff			print  "    char  *Booleans;		/* array of boolean values */"
204219820Sjeff			print  "    short *Numbers;		/* array of integer values */"
205219820Sjeff			print  "    char  **Strings;		/* array of string offsets */"
206219820Sjeff			print  ""
207219820Sjeff			print  "#if NCURSES_XNAMES"
208219820Sjeff			print  "    char  *ext_str_table;	/* pointer to extended string table */"
209219820Sjeff			print  "    char  **ext_Names;		/* corresponding names */"
210219820Sjeff			print  ""
211219820Sjeff			print  "    unsigned short num_Booleans;/* count total Booleans */"
212219820Sjeff			print  "    unsigned short num_Numbers;	/* count total Numbers */"
213219820Sjeff			print  "    unsigned short num_Strings;	/* count total Strings */"
214219820Sjeff			print  ""
215219820Sjeff			print  "    unsigned short ext_Booleans;/* count extensions to Booleans */"
216219820Sjeff			print  "    unsigned short ext_Numbers;	/* count extensions to Numbers */"
217219820Sjeff			print  "    unsigned short ext_Strings;	/* count extensions to Strings */"
218219820Sjeff			print  "#endif /* NCURSES_XNAMES */"
219219820Sjeff			print  ""
220219820Sjeff			print  "} TERMTYPE;"
221219820Sjeff			print  ""
222219820Sjeff			print  "typedef struct term {		/* describe an actual terminal */"
223219820Sjeff			print  "    TERMTYPE	type;		/* terminal type description */"
224219820Sjeff			print  "    short 	Filedes;	/* file description being written to */"
225219820Sjeff			print  "    TTY		Ottyb,		/* original state of the terminal */"
226219820Sjeff			print  "		Nttyb;		/* current state of the terminal */"
227219820Sjeff			print  "    int		_baudrate;	/* used to compute padding */"
228219820Sjeff			print  "} TERMINAL;"
229219820Sjeff			print  ""
230219820Sjeff			print  "extern TERMINAL	*cur_term;"
231219820Sjeff			print  ""
232219820Sjeff			print  "#if BROKEN_LINKER"
233219820Sjeff			print  "#define boolnames  _nc_boolnames()"
234219820Sjeff			print  "#define boolcodes  _nc_boolcodes()"
235219820Sjeff			print  "#define boolfnames _nc_boolfnames()"
236219820Sjeff			print  "#define numnames   _nc_numnames()"
237219820Sjeff			print  "#define numcodes   _nc_numcodes()"
238219820Sjeff			print  "#define numfnames  _nc_numfnames()"
239219820Sjeff			print  "#define strnames   _nc_strnames()"
240219820Sjeff			print  "#define strcodes   _nc_strcodes()"
241219820Sjeff			print  "#define strfnames  _nc_strfnames()"
242219820Sjeff			print  ""
243219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_boolnames(void);"
244219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_boolcodes(void);"
245219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_boolfnames(void);"
246219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_numnames(void);"
247219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_numcodes(void);"
248219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_numfnames(void);"
249219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_strnames(void);"
250219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_strcodes(void);"
251219820Sjeff			print  "extern NCURSES_CONST char * const *_nc_strfnames(void);"
252219820Sjeff			print  ""
253219820Sjeff			print  "#else"
254219820Sjeff			print  ""
255219820Sjeff			print  "extern NCURSES_CONST char *const boolnames[];"
256219820Sjeff			print  "extern NCURSES_CONST char *const boolcodes[];"
257219820Sjeff			print  "extern NCURSES_CONST char *const boolfnames[];"
258219820Sjeff			print  "extern NCURSES_CONST char *const numnames[];"
259219820Sjeff			print  "extern NCURSES_CONST char *const numcodes[];"
260219820Sjeff			print  "extern NCURSES_CONST char *const numfnames[];"
261219820Sjeff			print  "extern NCURSES_CONST char *const strnames[];"
262219820Sjeff			print  "extern NCURSES_CONST char *const strcodes[];"
263219820Sjeff			print  "extern NCURSES_CONST char *const strfnames[];"
264219820Sjeff			print  ""
265219820Sjeff			print  "#endif"
266219820Sjeff			print  ""
267219820Sjeff			print  "/* internals */"
268219820Sjeff			print  "extern int _nc_set_tty_mode(TTY *buf);"
269219820Sjeff			print  "extern int _nc_get_tty_mode(TTY *buf);"
270219820Sjeff			print  "extern int _nc_read_entry(const char * const, char * const, TERMTYPE *const);"
271219820Sjeff			print  "extern int _nc_read_file_entry(const char *const, TERMTYPE *);"
272219820Sjeff			print  "extern char *_nc_first_name(const char *const);"
273219820Sjeff			print  "extern int _nc_name_match(const char *const, const char *const, const char *const);"
274219820Sjeff			print  "extern int _nc_read_termcap_entry(const char *const, TERMTYPE *const);"
275219820Sjeff			print  "extern const TERMTYPE *_nc_fallback(const char *);"
276219820Sjeff			print  ""
277219820Sjeff			print  "/* entry points */"
278219820Sjeff			print  "extern TERMINAL *set_curterm(TERMINAL *);"
279219820Sjeff			print  "extern int del_curterm(TERMINAL *);"
280219820Sjeff			print  ""
281219820Sjeff			print  "/* miscellaneous entry points */"
282219820Sjeff			print  "extern int restartterm(NCURSES_CONST char *, int, int *);"
283219820Sjeff			print  "extern int setupterm(NCURSES_CONST char *,int,int *);"
284219820Sjeff			print  ""
285219820Sjeff			print  "/* terminfo entry points, also declared in curses.h */"
286219820Sjeff			print  "#if !defined(__NCURSES_H)"
287219820Sjeff			print  "extern char *tigetstr(NCURSES_CONST char *);"
288219820Sjeff			print  "extern char *tparm(NCURSES_CONST char *, ...);"
289219820Sjeff			print  "extern char ttytype[];"
290219820Sjeff			print  "extern int putp(const char *);"
291219820Sjeff			print  "extern int tigetflag(NCURSES_CONST char *);"
292219820Sjeff			print  "extern int tigetnum(NCURSES_CONST char *);"
293219820Sjeff			print  "#endif /* __NCURSES_H */"
294219820Sjeff			print  ""
295219820Sjeff			print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
296219820Sjeff			print  "#if !defined(_NCU_TERMCAP_H)"
297219820Sjeff			print  "extern char *tgetstr(NCURSES_CONST char *, char **);"
298219820Sjeff			print  "extern char *tgoto(const char *, int, int);"
299219820Sjeff			print  "extern int tgetent(char *, const char *);"
300219820Sjeff			print  "extern int tgetflag(NCURSES_CONST char *);"
301219820Sjeff			print  "extern int tgetnum(NCURSES_CONST char *);"
302219820Sjeff			print  "extern int tputs(const char *, int, int (*)(int));"
303219820Sjeff			print  "#endif /* _NCU_TERMCAP_H */"
304219820Sjeff			print  ""
305219820Sjeff			print  "#ifdef __cplusplus"
306219820Sjeff			print  "}"
307219820Sjeff			print  "#endif"
308219820Sjeff			print  ""
309219820Sjeff			print  "#endif /* _NCU_TERM_H */"
310219820Sjeff		}
311219820Sjeff