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