summaryrefslogtreecommitdiffstats
path: root/contrib/ncurses/include/MKterm.h.awk.in
blob: ee22f014d128bf1eef2aec4bed64ac85219120d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
BEGIN		{
		    print  "/****************************************************************************"
		    print  " * Copyright (c) 1998-2003,2006 Free Software Foundation, Inc.              *"
		    print  " *                                                                          *"
		    print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
		    print  " * copy of this software and associated documentation files (the            *"
		    print  " * \"Software\"), to deal in the Software without restriction, including      *"
		    print  " * without limitation the rights to use, copy, modify, merge, publish,      *"
		    print  " * distribute, distribute with modifications, sublicense, and/or sell       *"
		    print  " * copies of the Software, and to permit persons to whom the Software is    *"
		    print  " * furnished to do so, subject to the following conditions:                 *"
		    print  " *                                                                          *"
		    print  " * The above copyright notice and this permission notice shall be included  *"
		    print  " * in all copies or substantial portions of the Software.                   *"
		    print  " *                                                                          *"
		    print  " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *"
		    print  " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *"
		    print  " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *"
		    print  " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *"
		    print  " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *"
		    print  " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *"
		    print  " * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *"
		    print  " *                                                                          *"
		    print  " * Except as contained in this notice, the name(s) of the above copyright   *"
		    print  " * holders shall not be used in advertising or otherwise to promote the     *"
		    print  " * sale, use or other dealings in this Software without prior written       *"
		    print  " * authorization.                                                           *"
		    print  " ****************************************************************************/"
		    print  ""
		    print  "/****************************************************************************/"
		    print  "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995                */"
		    print  "/*    and: Eric S. Raymond <esr@snark.thyrsus.com>                          */"
		    print  "/*    and: Thomas E. Dickey                        1995-on                  */"
		    print  "/****************************************************************************/"
		    print  ""
		    print  "/* $Id: MKterm.h.awk.in,v 1.47 2006/11/26 01:18:23 tom Exp $ */"
		    print  ""
		    print  "/*"
		    print  "**	term.h -- Definition of struct term"
		    print  "*/"
		    print  ""
		    print  "#ifndef NCURSES_TERM_H_incl"
		    print  "#define NCURSES_TERM_H_incl 1"
		    print  ""
		    print  "#undef  NCURSES_VERSION"
		    print  "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
		    print  ""
		    print  "#include <ncurses_dll.h>"
		    print  ""
		    print  "#ifdef __cplusplus"
		    print  "extern \"C\" {"
		    print  "#endif"
		    print  ""
		    print  "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
		    print  " * definition (based on the system for which this was configured)."
		    print  " */"
		    print  ""
		    print  "#undef  NCURSES_CONST"
		    print  "#define NCURSES_CONST @NCURSES_CONST@"
		    print  ""
		    print  "#undef  NCURSES_SBOOL"
		    print  "#define NCURSES_SBOOL @NCURSES_SBOOL@"
		    print  ""
		    print  "#undef  NCURSES_XNAMES"
		    print  "#define NCURSES_XNAMES @NCURSES_XNAMES@"
		    print  ""
		    print  "/* We will use these symbols to hide differences between"
		    print  " * termios/termio/sgttyb interfaces."
		    print  " */"
		    print  "#undef  TTY"
		    print  "#undef  SET_TTY"
		    print  "#undef  GET_TTY"
		    print  ""
		    print  "/* Assume POSIX termio if we have the header and function */"
		    print  "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
		    print  "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
		    print  ""
		    print  "#undef  TERMIOS"
		    print  "#define TERMIOS 1"
		    print  ""
		    print  "#include <termios.h>"
		    print  "#define TTY struct termios"
		    print  ""
		    print  "#else /* !HAVE_TERMIOS_H */"
		    print  ""
		    print  "/* #if HAVE_TERMIO_H */"
		    print  "#if @HAVE_TERMIO_H@"
		    print  ""
		    print  "#undef  TERMIOS"
		    print  "#define TERMIOS 1"
		    print  ""
		    print  "#include <termio.h>"
		    print  "#define TTY struct termio"
		    print  ""
		    print  "/* Add definitions to make termio look like termios."
		    print  " * But ifdef it, since there are some implementations"
		    print  " * that try to do this for us in a fake <termio.h>."
		    print  " */"
		    print  "#ifndef TCSANOW"
		    print  "#define TCSANOW TCSETA"
		    print  "#endif"
		    print  "#ifndef TCSADRAIN"
		    print  "#define TCSADRAIN TCSETAW"
		    print  "#endif"
		    print  "#ifndef TCSAFLUSH"
		    print  "#define TCSAFLUSH TCSETAF"
		    print  "#endif"
		    print  "#ifndef tcsetattr"
		    print  "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
		    print  "#endif"
		    print  "#ifndef tcgetattr"
		    print  "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
		    print  "#endif"
		    print  "#ifndef cfgetospeed"
		    print  "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
		    print  "#endif"
		    print  "#ifndef TCIFLUSH "
		    print  "#define TCIFLUSH 0"
		    print  "#endif"
		    print  "#ifndef TCOFLUSH "
		    print  "#define TCOFLUSH 1"
		    print  "#endif"
		    print  "#ifndef TCIOFLUSH "
		    print  "#define TCIOFLUSH 2"
		    print  "#endif"
		    print  "#ifndef tcflush"
		    print  "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
		    print  "#endif"
		    print  ""
		    print  "#else /* !HAVE_TERMIO_H */"
		    print  ""
		    print  "#undef TERMIOS"
		    print  "#include <sgtty.h>"
		    print  "#include <sys/ioctl.h>"
		    print  "#define TTY struct sgttyb"
		    print  ""
		    print  "#endif /* HAVE_TERMIO_H */"
		    print  ""
		    print  "#endif /* HAVE_TERMIOS_H */"
		    print  ""
		    print  "#ifdef TERMIOS"
		    print  "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
		    print  "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
		    print  "#else"
		    print  "#define GET_TTY(fd, buf) gtty(fd, buf)"
		    print  "#define SET_TTY(fd, buf) stty(fd, buf)"
		    print  "#endif"
		    print  ""
		    print  "#define NAMESIZE 256"
		    print  ""
		    print  "#define CUR cur_term->type."
		    print  ""
		}

$2 == "%%-STOP-HERE-%%"	{
			print  ""
			printf "#define BOOLWRITE %d\n", BoolCount
			printf "#define NUMWRITE  %d\n", NumberCount
			printf "#define STRWRITE  %d\n", StringCount
			print  ""
			print  "/* older synonyms for some capabilities */"
			print  "#define beehive_glitch	no_esc_ctlc"
			print  "#define teleray_glitch	dest_tabs_magic_smso"
			print  "#define micro_char_size micro_col_size"
			print  ""
			print  "#ifdef __INTERNAL_CAPS_VISIBLE"
		}

/^#/		{next;}

$1 == "acs_chars"	{acsindex = StringCount}

$3 == "bool"	{
		    printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
		}

$3 == "num"	{
		    printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
		}

$3 == "str"	{
		    printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
		}

END		{
			print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
			print  ""
			print  ""
			print  "/*"
			print  " * Predefined terminfo array sizes"
			print  " */"
			printf "#define BOOLCOUNT %d\n", BoolCount
			printf "#define NUMCOUNT  %d\n", NumberCount
			printf "#define STRCOUNT  %d\n", StringCount
			print  ""
			print  "/* used by code for comparing entries */"
			print  "#define acs_chars_index	", acsindex
			print  ""
			print  "typedef struct termtype {	/* in-core form of terminfo data */"
			print  "    char  *term_names;		/* str_table offset of term names */"
			print  "    char  *str_table;		/* pointer to string table */"
			print  "    NCURSES_SBOOL  *Booleans;	/* array of boolean values */"
			print  "    short *Numbers;		/* array of integer values */"
			print  "    char  **Strings;		/* array of string offsets */"
			print  ""
			print  "#if NCURSES_XNAMES"
			print  "    char  *ext_str_table;	/* pointer to extended string table */"
			print  "    char  **ext_Names;		/* corresponding names */"
			print  ""
			print  "    unsigned short num_Booleans;/* count total Booleans */"
			print  "    unsigned short num_Numbers;	/* count total Numbers */"
			print  "    unsigned short num_Strings;	/* count total Strings */"
			print  ""
			print  "    unsigned short ext_Booleans;/* count extensions to Booleans */"
			print  "    unsigned short ext_Numbers;	/* count extensions to Numbers */"
			print  "    unsigned short ext_Strings;	/* count extensions to Strings */"
			print  "#endif /* NCURSES_XNAMES */"
			print  ""
			print  "} TERMTYPE;"
			print  ""
			print  "typedef struct term {		/* describe an actual terminal */"
			print  "    TERMTYPE	type;		/* terminal type description */"
			print  "    short	Filedes;	/* file description being written to */"
			print  "    TTY		Ottyb,		/* original state of the terminal */"
			print  "		Nttyb;		/* current state of the terminal */"
			print  "    int		_baudrate;	/* used to compute padding */"
			print  "    char *      _termname;      /* used for termname() */"
			print  "} TERMINAL;"
			print  ""
			print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
			print  ""
			print  "#if BROKEN_LINKER"
			print  "#define boolnames  _nc_boolnames()"
			print  "#define boolcodes  _nc_boolcodes()"
			print  "#define boolfnames _nc_boolfnames()"
			print  "#define numnames   _nc_numnames()"
			print  "#define numcodes   _nc_numcodes()"
			print  "#define numfnames  _nc_numfnames()"
			print  "#define strnames   _nc_strnames()"
			print  "#define strcodes   _nc_strcodes()"
			print  "#define strfnames  _nc_strfnames()"
			print  ""
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolnames (void);"
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolcodes (void);"
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolfnames (void);"
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numnames (void);"
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numcodes (void);"
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numfnames (void);"
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strnames (void);"
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strcodes (void);"
			print  "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strfnames (void);"
			print  ""
			print  "#else"
			print  ""
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
			print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
			print  ""
			print  "#endif"
			print  ""
			print  "/* internals */"
			print  "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
			print  "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);"
			print  "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
			print  "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
			print  "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);"
			print  "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
			print  "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
			print  "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
			print  ""
			print  "/* entry points */"
			print  "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
			print  "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
			print  ""
			print  "/* miscellaneous entry points */"
			print  "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
			print  "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
			print  ""
			print  "/* terminfo entry points, also declared in curses.h */"
			print  "#if !defined(__NCURSES_H)"
			print  "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
			print  "extern NCURSES_EXPORT_VAR(char) ttytype[];"
			print  "extern NCURSES_EXPORT(int) putp (const char *);"
			print  "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
			print  "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
			print  ""
			print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
			print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);	/* implemented */"
			print  "#else"
			print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);	/* implemented */"
			print  "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);	/* implemented */"
			print  "#endif"
			print  ""
			print  "#endif /* __NCURSES_H */"
			print  ""
			print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
			print  "#if !defined(NCURSES_TERMCAP_H_incl)"
			print  "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
			print  "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
			print  "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
			print  "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
			print  "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
			print  "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
			print  "#endif /* NCURSES_TERMCAP_H_incl */"
			print  ""
			print  "#ifdef __cplusplus"
			print  "}"
			print  "#endif"
			print  ""
			print  "#endif /* NCURSES_TERM_H_incl */"
		}
OpenPOWER on IntegriCloud