ncurses 4.2
[ncurses.git] / include / MKterm.h.awk.in
1
2 BEGIN           {
3                     print "/****************************************************************************"
4                     print " * Copyright (c) 1998 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.23 1998/02/11 12:13:46 tom Exp $ */"
37                     print ""
38                     print "/*"
39                     print "**   term.h -- Definition of struct term"
40                     print "*/"
41                     print ""
42                     print "#ifndef _TERM_H"
43                     print "#define _TERM_H"
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 configured)."
54                     print " */"
55                     print ""
56                     print "#ifndef HAVE_TERMIOS_H"
57                     print "#define HAVE_TERMIOS_H 1/*default*/"
58                     print "#endif"
59                     print ""
60                     print "#ifndef HAVE_TERMIO_H"
61                     print "#define HAVE_TERMIO_H 0/*default*/"
62                     print "#endif"
63                     print ""
64                     print "#ifndef HAVE_TCGETATTR"
65                     print "#define HAVE_TCGETATTR 1/*default*/"
66                     print "#endif"
67                     print ""
68                     print "#ifndef BROKEN_LINKER"
69                     print "#define BROKEN_LINKER 0/*default*/"
70                     print "#endif"
71                     print ""
72                     print "#ifndef NCURSES_CONST"
73                     print "#define NCURSES_CONST /* nothing */"
74                     print "#endif"
75                     print ""
76                     print "/* Assume Posix termio if we have the header and function */"
77                     print "#if HAVE_TERMIOS_H && HAVE_TCGETATTR"
78                     print "#ifndef TERMIOS"
79                     print "#define TERMIOS 1"
80                     print "#endif"
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 "#ifndef TERMIOS"
88                     print "#define TERMIOS 1"
89                     print "#endif"
90                     print "#include <termio.h>"
91                     print "#define TTY struct termio"
92                     print "#define TCSANOW TCSETA"
93                     print "#define TCSADRAIN TCSETAW"
94                     print "#define TCSAFLUSH TCSETAF"
95                     print "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
96                     print "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
97                     print "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
98                     print "#define TCIFLUSH 0"
99                     print "#define TCOFLUSH 1"
100                     print "#define TCIOFLUSH 2"
101                     print "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
102                     print ""
103                     print "#else /* !HAVE_TERMIO_H */"
104                     print ""
105                     print "#undef TERMIOS"
106                     print "#include <sgtty.h>"
107                     print "#include <sys/ioctl.h>"
108                     print "#define TTY struct sgttyb"
109                     print ""
110                     print "#endif /* HAVE_TERMIO_H */"
111                     print ""
112                     print "#endif /* HAVE_TERMIOS_H */"
113                     print ""
114                     print "#ifdef TERMIOS"
115                     print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
116                     print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
117                     print "#else"
118                     print "#define GET_TTY(fd, buf) gtty(fd, buf)"
119                     print "#define SET_TTY(fd, buf) stty(fd, buf)"
120                     print "#endif"
121                     print ""
122                     print "extern char ttytype[];"
123                     print "#define NAMESIZE 256"
124                     print ""
125                     print "#define CUR cur_term->type."
126                     print ""
127                 }
128
129 $2 == "%%-STOP-HERE-%%" {
130                         print  ""
131                         printf "#define BOOLWRITE %d\n", BoolCount
132                         printf "#define NUMWRITE  %d\n", NumberCount
133                         printf "#define STRWRITE  %d\n", StringCount
134                         print  ""
135                         print  "/* older synonyms for some capabilities */"
136                         print  "#define beehive_glitch  no_esc_ctlc"
137                         print  "#define teleray_glitch  dest_tabs_magic_smso"
138                         print  ""
139                         print  "/* XSI synonyms */"
140                         print  "#define micro_col_size  micro_char_size"
141                         print  ""
142                         print  "#ifdef __INTERNAL_CAPS_VISIBLE"
143                 }
144
145 /^#/            {next;}
146
147 $3 == "bool"    {
148                     printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
149                 }
150
151 $3 == "num"     {
152                     printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
153                 }
154
155 $3 == "str"     {
156                     printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
157                 }
158
159 END             {
160                         print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
161                         print  ""
162                         print  ""
163                         printf "#define BOOLCOUNT %d\n", BoolCount
164                         printf "#define NUMCOUNT  %d\n", NumberCount
165                         printf "#define STRCOUNT  %d\n", StringCount
166                         print  ""
167                         print "typedef struct termtype {        /* in-core form of terminfo data */"
168                         print "    char  *term_names;           /* str_table offset of term names */"
169                         print "    char  *str_table;            /* pointer to string table */"
170                         print "    char  Booleans[BOOLCOUNT];   /* array of values */"
171                         print "    short Numbers[NUMCOUNT];     /* array of values */"
172                         print "    char  *Strings[STRCOUNT];    /* array of string offsets */"
173                         print "} TERMTYPE;"
174                         print ""
175                         print "typedef struct term {            /* describe an actual terminal */"
176                         print "    TERMTYPE     type;           /* terminal type description */"
177                         print "    short        Filedes;        /* file description being written to */"
178                         print "    TTY          Ottyb,          /* original state of the terminal */"
179                         print "                 Nttyb;          /* current state of the terminal */"
180                         print "    int          _baudrate;      /* used to compute padding */"
181                         print "} TERMINAL;"
182                         print ""
183                         print "extern TERMINAL  *cur_term;"
184                         print ""
185                         print ""
186                         print "#if BROKEN_LINKER"
187                         print "#define boolnames  _nc_boolnames()"
188                         print "#define boolcodes  _nc_boolcodes()"
189                         print "#define boolfnames _nc_boolfnames()"
190                         print "#define numnames   _nc_numnames()"
191                         print "#define numcodes   _nc_numcodes()"
192                         print "#define numfnames  _nc_numfnames()"
193                         print "#define strnames   _nc_strnames()"
194                         print "#define strcodes   _nc_strcodes()"
195                         print "#define strfnames  _nc_strfnames()"
196                         print ""
197                         print "extern NCURSES_CONST char * const *_nc_boolnames(void);"
198                         print "extern NCURSES_CONST char * const *_nc_boolcodes(void);"
199                         print "extern NCURSES_CONST char * const *_nc_boolfnames(void);"
200                         print "extern NCURSES_CONST char * const *_nc_numnames(void);"
201                         print "extern NCURSES_CONST char * const *_nc_numcodes(void);"
202                         print "extern NCURSES_CONST char * const *_nc_numfnames(void);"
203                         print "extern NCURSES_CONST char * const *_nc_strnames(void);"
204                         print "extern NCURSES_CONST char * const *_nc_strcodes(void);"
205                         print "extern NCURSES_CONST char * const *_nc_strfnames(void);"
206                         print ""
207                         print "#else"
208                         print ""
209                         print "extern NCURSES_CONST char *const boolnames[];"
210                         print "extern NCURSES_CONST char *const boolcodes[];"
211                         print "extern NCURSES_CONST char *const boolfnames[];"
212                         print "extern NCURSES_CONST char *const numnames[];"
213                         print "extern NCURSES_CONST char *const numcodes[];"
214                         print "extern NCURSES_CONST char *const numfnames[];"
215                         print "extern NCURSES_CONST char *const strnames[];"
216                         print "extern NCURSES_CONST char *const strcodes[];"
217                         print "extern NCURSES_CONST char *const strfnames[];"
218                         print ""
219                         print "#endif"
220                         print ""
221                         print "/* internals */"
222                         print "extern int _nc_set_curterm(TTY *buf);"
223                         print "extern int _nc_get_curterm(TTY *buf);"
224                         print "extern int _nc_read_entry(const char * const, char * const, TERMTYPE *const);"
225                         print "extern int _nc_read_file_entry(const char *const, TERMTYPE *);"
226                         print "extern char *_nc_first_name(const char *const);"
227                         print "extern int _nc_name_match(const char *const, const char *const, const char *const);"
228                         print "extern int _nc_read_termcap_entry(const char *const, TERMTYPE *const);"
229                         print "extern const TERMTYPE *_nc_fallback(const char *);"
230                         print  ""
231                         print "/* entry points */"
232                         print "extern TERMINAL *set_curterm(TERMINAL *);"
233                         print "extern int del_curterm(TERMINAL *);"
234                         print  ""
235                         print "/* miscellaneous entry points */"
236                         print "extern int putp(const char *);"
237                         print "extern int restartterm(const char *, int, int *);"
238                         print "extern int setupterm(const char *,int,int *);"
239                         print "extern int tputs(const char *, int, int (*)(int));"
240                         print  ""
241                         print "/* terminfo entry points */"
242                         print "extern int tigetflag(const char *);"
243                         print "extern int tigetnum(const char *);"
244                         print "extern char *tigetstr(const char *);"
245                         print "extern char *tparm(const char *, ...);"
246                         print ""
247                         print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
248                         print "extern int tgetent(char *, const char *);"
249                         print "extern int tgetflag(const char *);"
250                         print "extern int tgetnum(const char *);"
251                         print "extern char *tgetstr(const char *, char **);"
252                         print "extern char *tgoto(const char *, int, int);"
253                         print ""
254                         print "#ifdef __cplusplus"
255                         print "}"
256                         print "#endif"
257                         print ""
258                         print "#endif /* TERM_H */"
259                 }