ncurses 4.1
[ncurses.git] / include / MKterm.h.awk.in
1
2 BEGIN           {
3
4                     print "/***************************************************************************"
5                     print "*                            COPYRIGHT NOTICE                              *"
6                     print "****************************************************************************"
7                     print "*                ncurses is copyright (C) 1992-1995                        *"
8                     print "*                          Zeyd M. Ben-Halim                               *"
9                     print "*                          zmbenhal@netcom.com                             *"
10                     print "*                          Eric S. Raymond                                 *"
11                     print "*                          esr@snark.thyrsus.com                           *"
12                     print "*                                                                          *"
13                     print "*        Permission is hereby granted to reproduce and distribute ncurses  *"
14                     print "*        by any means and for any fee, whether alone or as part of a       *"
15                     print "*        larger distribution, in source or in binary form, PROVIDED        *"
16                     print "*        this notice is included with any such distribution, and is not    *"
17                     print "*        removed from any of its header files. Mention of ncurses in any   *"
18                     print "*        applications linked with it is highly appreciated.                *"
19                     print "*                                                                          *"
20                     print "*        ncurses comes AS IS with no warranty, implied or expressed.       *"
21                     print "*                                                                          *"
22                     print "***************************************************************************/"
23                     print ""
24                     print "/* $Id: MKterm.h.awk.in,v 1.17 1997/02/08 21:20:22 tom Exp $ */"
25                     print ""
26                     print "/*"
27                     print "**   term.h -- Definition of struct term"
28                     print "*/"
29                     print ""
30                     print "#ifndef _TERM_H"
31                     print "#define _TERM_H"
32                     print ""
33                     print "#undef  NCURSES_VERSION"
34                     print "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
35                     print ""
36                     print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
37                     print " * and BROKEN_LINKER definition (based on the system for which this was configured)."
38                     print " */"
39                     print ""
40                     print "#ifndef HAVE_TERMIOS_H"
41                     print "#define HAVE_TERMIOS_H 1/*default*/"
42                     print "#endif"
43                     print ""
44                     print "#ifndef HAVE_TERMIO_H"
45                     print "#define HAVE_TERMIO_H 0/*default*/"
46                     print "#endif"
47                     print ""
48                     print "#ifndef HAVE_TCGETATTR"
49                     print "#define HAVE_TCGETATTR 1/*default*/"
50                     print "#endif"
51                     print ""
52                     print "#ifndef BROKEN_LINKER"
53                     print "#define BROKEN_LINKER 0/*default*/"
54                     print "#endif"
55                     print ""
56                     print ""
57                     print "/* Assume Posix termio if we have the header and function */"
58                     print "#if HAVE_TERMIOS_H && HAVE_TCGETATTR"
59                     print "#ifndef TERMIOS"
60                     print "#define TERMIOS 1"
61                     print "#endif"
62                     print "#include <termios.h>"
63                     print "#define TTY struct termios"
64                     print ""
65                     print "#else /* !HAVE_TERMIOS_H */"
66                     print ""
67                     print "#if HAVE_TERMIO_H"
68                     print "#ifndef TERMIOS"
69                     print "#define TERMIOS 1"
70                     print "#endif"
71                     print "#include <termio.h>"
72                     print "#define TTY struct termio"
73                     print "#define TCSANOW TCSETA"
74                     print "#define TCSADRAIN TCSETAW"
75                     print "#define TCSAFLUSH TCSETAF"
76                     print "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
77                     print "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
78                     print "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
79                     print "#define TCIFLUSH 0"
80                     print "#define TCOFLUSH 1"
81                     print "#define TCIOFLUSH 2"
82                     print "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
83                     print ""
84                     print "#else /* !HAVE_TERMIO_H */"
85                     print ""
86                     print "#undef TERMIOS"
87                     print "#include <sgtty.h>"
88                     print "#include <sys/ioctl.h>"
89                     print "#define TTY struct sgttyb"
90                     print ""
91                     print "#endif /* HAVE_TERMIO_H */"
92                     print ""
93                     print "#endif /* HAVE_TERMIOS_H */"
94                     print ""
95                     print "#ifdef TERMIOS"
96                     print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
97                     print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
98                     print "#else"
99                     print "#define GET_TTY(fd, buf) gtty(fd, buf)"
100                     print "#define SET_TTY(fd, buf) stty(fd, buf)"
101                     print "#endif"
102                     print ""
103                     print "extern char ttytype[];"
104                     print "#define NAMESIZE 256"
105                     print ""
106                     print "#define CUR cur_term->type."
107                     print ""
108                 }
109
110 $2 == "%%-STOP-HERE-%%" {
111                         print  ""
112                         printf "#define BOOLWRITE %d\n", BoolCount
113                         printf "#define NUMWRITE  %d\n", NumberCount
114                         printf "#define STRWRITE  %d\n", StringCount
115                         print  ""
116                         print  "/* older synonyms for some capabilities */"
117                         print  "#define beehive_glitch  no_esc_ctlc"
118                         print  "#define teleray_glitch  dest_tabs_magic_smso"
119                         print  ""
120                         print  "/* XSI synonyms */"
121                         print  "#define micro_col_size  micro_char_size"
122                         print  ""
123                         print  "#ifdef __INTERNAL_CAPS_VISIBLE"
124                 }
125
126 /^#/            {next;}
127
128 $3 == "bool"    {
129                     printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
130                 }
131
132 $3 == "num"     {
133                     printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
134                 }
135
136 $3 == "str"     {
137                     printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
138                 }
139
140 END             {
141                         print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
142                         print  ""
143                         print  ""
144                         printf "#define BOOLCOUNT %d\n", BoolCount
145                         printf "#define NUMCOUNT  %d\n", NumberCount
146                         printf "#define STRCOUNT  %d\n", StringCount
147                         print  ""
148                         print "typedef struct termtype {        /* in-core form of terminfo data */"
149                         print "    char  *term_names;           /* str_table offset of term names */"
150                         print "    char  *str_table;            /* pointer to string table */"
151                         print "    char  Booleans[BOOLCOUNT];   /* array of values */"
152                         print "    short Numbers[NUMCOUNT];     /* array of values */"
153                         print "    char  *Strings[STRCOUNT];    /* array of string offsets */"
154                         print "} TERMTYPE;"
155                         print ""
156                         print "typedef struct term {            /* describe an actual terminal */"
157                         print "    TERMTYPE     type;           /* terminal type description */"
158                         print "    short        Filedes;        /* file description being written to */"
159                         print "    TTY          Ottyb,          /* original state of the terminal */"
160                         print "                 Nttyb;          /* current state of the terminal */"
161                         print "} TERMINAL;"
162                         print ""
163                         print "extern TERMINAL  *cur_term;"
164                         print ""
165                         print ""
166                         print "#ifdef __cplusplus"
167                         print "extern \"C\" {"
168                         print "#endif"
169                         print ""
170                         print "#if BROKEN_LINKER"
171                         print "#define boolnames  _nc_boolnames()"
172                         print "#define boolcodes  _nc_boolcodes()"
173                         print "#define boolfnames _nc_boolfnames()"
174                         print "#define numnames   _nc_numnames()"
175                         print "#define numcodes   _nc_numcodes()"
176                         print "#define numfnames  _nc_numfnames()"
177                         print "#define strnames   _nc_strnames()"
178                         print "#define strcodes   _nc_strcodes()"
179                         print "#define strfnames  _nc_strfnames()"
180                         print ""
181                         print "extern char * const *_nc_boolnames(void);"
182                         print "extern char * const *_nc_boolcodes(void);"
183                         print "extern char * const *_nc_boolfnames(void);"
184                         print "extern char * const *_nc_numnames(void);"
185                         print "extern char * const *_nc_numcodes(void);"
186                         print "extern char * const *_nc_numfnames(void);"
187                         print "extern char * const *_nc_strnames(void);"
188                         print "extern char * const *_nc_strcodes(void);"
189                         print "extern char * const *_nc_strfnames(void);"
190                         print ""
191                         print "#else"
192                         print ""
193                         print "extern char *const boolnames[];"
194                         print "extern char *const boolcodes[];"
195                         print "extern char *const boolfnames[];"
196                         print "extern char *const numnames[];"
197                         print "extern char *const numcodes[];"
198                         print "extern char *const numfnames[];"
199                         print "extern char *const strnames[];"
200                         print "extern char *const strcodes[];"
201                         print "extern char *const strfnames[];"
202                         print ""
203                         print "#endif"
204                         print ""
205                         print "/* internals */"
206                         print "extern int _nc_read_entry(const char * const, char * const, TERMTYPE *const);"
207                         print "extern int _nc_read_file_entry(const char *const, TERMTYPE *);"
208                         print "extern char *_nc_first_name(const char *const);"
209                         print "extern int _nc_name_match(const char *const, const char *const, const char *const);"
210                         print "extern int _nc_read_termcap_entry(const char *const, TERMTYPE *const);"
211                         print "extern const TERMTYPE *_nc_fallback(const char *);"
212                         print  ""
213                         print "/* entry points */"
214                         print "extern TERMINAL *set_curterm(TERMINAL *);"
215                         print "extern int del_curterm(TERMINAL *);"
216                         print  ""
217                         print "/* entry points */"
218                         print "extern int putp(const char *);"
219                         print "extern int restartterm(const char *, int, int *);"
220                         print "extern int setupterm(const char *,int,int *);"
221                         print "extern int tgetent(char *, const char *);"
222                         print "extern int tgetflag(const char *);"
223                         print "extern int tgetnum(const char *);"
224                         print "extern char *tgetstr(const char *, char **);"
225                         print "extern char *tgoto(const char *, int, int);"
226                         print "extern int tigetflag(const char *);"
227                         print "extern int tigetnum(const char *);"
228                         print "extern char *tigetstr(const char *);"
229                         print "extern char *tparm(const char *, ...);"
230                         print "extern int tputs(const char *, int, int (*)(int));"
231                         print ""
232                         print "#ifdef __cplusplus"
233                         print "}"
234                         print "#endif"
235                         print ""
236                         print "#endif /* TERM_H */"
237                 }