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