ncurses 5.9 - patch 20130324
[ncurses.git] / include / MKterm.h.awk.in
1 # vile:awkmode
2 BEGIN           {
3                     print  "/****************************************************************************"
4                     print  " * Copyright (c) 1998-2010,2011 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  "/*    and: Thomas E. Dickey                        1995-on                  */"
35                     print  "/****************************************************************************/"
36                     print  ""
37                     print  "/* $Id: MKterm.h.awk.in,v 1.60 2011/06/25 20:51:00 tom Exp $ */"
38                     print  ""
39                     print  "/*"
40                     print  "**  term.h -- Definition of struct term"
41                     print  "*/"
42                     print  ""
43                     print  "#ifndef NCURSES_TERM_H_incl"
44                     print  "#define NCURSES_TERM_H_incl 1"
45                     print  ""
46                     print  "#undef  NCURSES_VERSION"
47                     print  "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
48                     print  ""
49                     print  "#include <ncurses_dll.h>"
50                     print  ""
51                     print  "#ifdef __cplusplus"
52                     print  "extern \"C\" {"
53                     print  "#endif"
54                     print  ""
55                     print  "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
56                     print  " * definition (based on the system for which this was configured)."
57                     print  " */"
58                     print  ""
59                     print  "#undef  NCURSES_CONST"
60                     print  "#define NCURSES_CONST @NCURSES_CONST@"
61                     print  ""
62                     print  "#undef  NCURSES_SBOOL"
63                     print  "#define NCURSES_SBOOL @NCURSES_SBOOL@"
64                     print  ""
65                     print  "#undef  NCURSES_XNAMES"
66                     print  "#define NCURSES_XNAMES @NCURSES_XNAMES@"
67                     print  ""
68                     print  "/* We will use these symbols to hide differences between"
69                     print  " * termios/termio/sgttyb interfaces."
70                     print  " */"
71                     print  "#undef  TTY"
72                     print  "#undef  SET_TTY"
73                     print  "#undef  GET_TTY"
74                     print  ""
75                     print  "/* Assume POSIX termio if we have the header and function */"
76                     print  "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
77                     print  "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
78                     print  ""
79                     print  "#undef  TERMIOS"
80                     print  "#define TERMIOS 1"
81                     print  ""
82                     print  "#include <termios.h>"
83                     print  "#define TTY struct termios"
84                     print  ""
85                     print  "#else /* !HAVE_TERMIOS_H */"
86                     print  ""
87                     print  "/* #if HAVE_TERMIO_H */"
88                     print  "#if @HAVE_TERMIO_H@"
89                     print  ""
90                     print  "#undef  TERMIOS"
91                     print  "#define TERMIOS 1"
92                     print  ""
93                     print  "#include <termio.h>"
94                     print  "#define TTY struct termio"
95                     print  ""
96                     print  "#else /* !HAVE_TERMIO_H */"
97                     print  ""
98                     print  "#if __MINGW32__"
99                     print  "#  include <ncurses_mingw.h>"
100                     print  "#  define TTY struct termios"
101                     print  "#else"
102                     print  "#undef TERMIOS"
103                     print  "#include <sgtty.h>"
104                     print  "#include <sys/ioctl.h>"
105                     print  "#define TTY struct sgttyb"
106                     print  "#endif /* MINGW32 */"
107                     print  "#endif /* HAVE_TERMIO_H */"
108                     print  ""
109                     print  "#endif /* HAVE_TERMIOS_H */"
110                     print  ""
111                     print  "#ifdef TERMIOS"
112                     print  "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
113                     print  "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
114                     print  "#else"
115                     print  "#define GET_TTY(fd, buf) gtty(fd, buf)"
116                     print  "#define SET_TTY(fd, buf) stty(fd, buf)"
117                     print  "#endif"
118                     print  ""
119                     print  "#define NAMESIZE 256"
120                     print  ""
121                     print  "#define CUR cur_term->type."
122                     print  ""
123                 }
124
125 $2 == "%%-STOP-HERE-%%" {
126                         print  ""
127                         printf "#define BOOLWRITE %d\n", BoolCount
128                         printf "#define NUMWRITE  %d\n", NumberCount
129                         printf "#define STRWRITE  %d\n", StringCount
130                         print  ""
131                         print  "/* older synonyms for some capabilities */"
132                         print  "#define beehive_glitch  no_esc_ctlc"
133                         print  "#define teleray_glitch  dest_tabs_magic_smso"
134                         print  "#define micro_char_size micro_col_size"
135                         print  ""
136                         print  "#ifdef __INTERNAL_CAPS_VISIBLE"
137                 }
138
139 /^#/            {next;}
140
141 $1 == "acs_chars"       {acsindex = StringCount}
142
143 $3 == "bool"    {
144                     printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
145                 }
146
147 $3 == "num"     {
148                     printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
149                 }
150
151 $3 == "str"     {
152                     printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
153                 }
154
155 END             {
156                         print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
157                         print  ""
158                         print  ""
159                         print  "/*"
160                         print  " * Predefined terminfo array sizes"
161                         print  " */"
162                         printf "#define BOOLCOUNT %d\n", BoolCount
163                         printf "#define NUMCOUNT  %d\n", NumberCount
164                         printf "#define STRCOUNT  %d\n", StringCount
165                         print  ""
166                         print  "/* used by code for comparing entries */"
167                         print  "#define acs_chars_index ", acsindex
168                         print  ""
169                         print  "typedef struct termtype {       /* in-core form of terminfo data */"
170                         print  "    char  *term_names;          /* str_table offset of term names */"
171                         print  "    char  *str_table;           /* pointer to string table */"
172                         print  "    NCURSES_SBOOL  *Booleans;   /* array of boolean values */"
173                         print  "    short *Numbers;             /* array of integer values */"
174                         print  "    char  **Strings;            /* array of string offsets */"
175                         print  ""
176                         print  "#if NCURSES_XNAMES"
177                         print  "    char  *ext_str_table;       /* pointer to extended string table */"
178                         print  "    char  **ext_Names;          /* corresponding names */"
179                         print  ""
180                         print  "    unsigned short num_Booleans;/* count total Booleans */"
181                         print  "    unsigned short num_Numbers; /* count total Numbers */"
182                         print  "    unsigned short num_Strings; /* count total Strings */"
183                         print  ""
184                         print  "    unsigned short ext_Booleans;/* count extensions to Booleans */"
185                         print  "    unsigned short ext_Numbers; /* count extensions to Numbers */"
186                         print  "    unsigned short ext_Strings; /* count extensions to Strings */"
187                         print  "#endif /* NCURSES_XNAMES */"
188                         print  ""
189                         print  "} TERMTYPE;"
190                         print  ""
191                         print  "typedef struct term {           /* describe an actual terminal */"
192                         print  "    TERMTYPE    type;           /* terminal type description */"
193                         print  "    short       Filedes;        /* file description being written to */"
194                         print  "    TTY         Ottyb,          /* original state of the terminal */"
195                         print  "                Nttyb;          /* current state of the terminal */"
196                         print  "    int         _baudrate;      /* used to compute padding */"
197                         print  "    char *      _termname;      /* used for termname() */"
198                         print  "} TERMINAL;"
199                         print  ""
200                         print  "#if @BROKEN_LINKER@ && !@cf_cv_enable_reentrant@"
201                         print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
202                         print  "#elif @cf_cv_enable_reentrant@"
203                         print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
204                         print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
205                         print  "#else"
206                         print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
207                         print  "#endif"
208                         print  ""
209                         print  "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@"
210                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
211                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
212                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
213                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
214                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
215                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
216                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
217                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
218                         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
219                         print  ""
220                         print  "#define boolnames  NCURSES_PUBLIC_VAR(boolnames())"
221                         print  "#define boolcodes  NCURSES_PUBLIC_VAR(boolcodes())"
222                         print  "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
223                         print  "#define numnames   NCURSES_PUBLIC_VAR(numnames())"
224                         print  "#define numcodes   NCURSES_PUBLIC_VAR(numcodes())"
225                         print  "#define numfnames  NCURSES_PUBLIC_VAR(numfnames())"
226                         print  "#define strnames   NCURSES_PUBLIC_VAR(strnames())"
227                         print  "#define strcodes   NCURSES_PUBLIC_VAR(strcodes())"
228                         print  "#define strfnames  NCURSES_PUBLIC_VAR(strfnames())"
229                         print  ""
230                         print  "#else"
231                         print  ""
232                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
233                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
234                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
235                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
236                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
237                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
238                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
239                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
240                         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
241                         print  ""
242                         print  "#endif"
243                         print  ""
244                         print  "/* internals */"
245                         print  "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
246                         print  "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);"
247                         print  "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
248                         print  "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
249                         print  "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);"
250                         print  "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
251                         print  "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
252                         print  "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
253                         print  ""
254                         print  "/* entry points */"
255                         print  "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
256                         print  "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
257                         print  ""
258                         print  "/* miscellaneous entry points */"
259                         print  "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
260                         print  "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
261                         print  ""
262                         print  "/* terminfo entry points, also declared in curses.h */"
263                         print  "#if !defined(__NCURSES_H)"
264                         print  "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
265                         print  "extern NCURSES_EXPORT_VAR(char) ttytype[];"
266                         print  "extern NCURSES_EXPORT(int) putp (const char *);"
267                         print  "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
268                         print  "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
269                         print  ""
270                         print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
271                         print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);        /* special */"
272                         print  "#else"
273                         print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);       /* special */"
274                         print  "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);        /* special */"
275                         print  "#endif"
276                         print  ""
277                         print  "extern NCURSES_EXPORT(char *) tiparm (const char *, ...);               /* special */"
278                         print  ""
279                         print  "#endif /* __NCURSES_H */"
280                         print  ""
281                         print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
282                         print  "#if !defined(NCURSES_TERMCAP_H_incl)"
283                         print  "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
284                         print  "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
285                         print  "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
286                         print  "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
287                         print  "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
288                         print  "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
289                         print  "#endif /* NCURSES_TERMCAP_H_incl */"
290                         print  ""
291                         print  "/*"
292                         print  " * Include curses.h before term.h to enable these extensions."
293                         print  " */"
294                         print  "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)"
295                         print  ""
296                         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tigetstr) (SCREEN*, NCURSES_CONST char *);"
297                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(putp) (SCREEN*, const char *);"
298                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetflag) (SCREEN*, NCURSES_CONST char *);"
299                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetnum) (SCREEN*, NCURSES_CONST char *);"
300                         print  ""
301                         print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
302                         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, ...);     /* special */"
303                         print  "#else"
304                         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);    /* special */"
305                         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm_varargs) (SCREEN*, NCURSES_CONST char *, ...);     /* special */"
306                         print  "#endif"
307                         print  ""
308                         print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
309                         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgetstr) (SCREEN*, NCURSES_CONST char *, char **);"
310                         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);"
311                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);"
312                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);"
313                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);"
314                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);"
315                         print  ""
316                         print  "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);"
317                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);"
318                         print  ""
319                         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);"
320                         print  "#endif /* NCURSES_SP_FUNCS */"
321                         print  ""
322                         print  "#ifdef __cplusplus"
323                         print  "}"
324                         print  "#endif"
325                         print  ""
326                         print  "#endif /* NCURSES_TERM_H_incl */"
327                 }