]> ncurses.scripts.mit.edu Git - ncurses.git/blob - include/MKterm.h.awk.in
3146ee8ded811ba7b993d559e8d4e357885575a4
[ncurses.git] / include / MKterm.h.awk.in
1 # vile:awkmode
2 BEGIN {
3         lcurl = "{";
4         rcurl = "}";
5         print  "/****************************************************************************"
6         print  " * Copyright (c) 1998-2013,2017 Free Software Foundation, Inc.              *"
7         print  " *                                                                          *"
8         print  " * Permission is hereby granted, free of charge, to any person obtaining a  *"
9         print  " * copy of this software and associated documentation files (the            *"
10         print  " * \"Software\"), to deal in the Software without restriction, including      *"
11         print  " * without limitation the rights to use, copy, modify, merge, publish,      *"
12         print  " * distribute, distribute with modifications, sublicense, and/or sell       *"
13         print  " * copies of the Software, and to permit persons to whom the Software is    *"
14         print  " * furnished to do so, subject to the following conditions:                 *"
15         print  " *                                                                          *"
16         print  " * The above copyright notice and this permission notice shall be included  *"
17         print  " * in all copies or substantial portions of the Software.                   *"
18         print  " *                                                                          *"
19         print  " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *"
20         print  " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *"
21         print  " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *"
22         print  " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *"
23         print  " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *"
24         print  " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *"
25         print  " * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *"
26         print  " *                                                                          *"
27         print  " * Except as contained in this notice, the name(s) of the above copyright   *"
28         print  " * holders shall not be used in advertising or otherwise to promote the     *"
29         print  " * sale, use or other dealings in this Software without prior written       *"
30         print  " * authorization.                                                           *"
31         print  " ****************************************************************************/"
32         print  ""
33         print  "/****************************************************************************/"
34         print  "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995                */"
35         print  "/*    and: Eric S. Raymond <esr@snark.thyrsus.com>                          */"
36         print  "/*    and: Thomas E. Dickey                        1995-on                  */"
37         print  "/****************************************************************************/"
38         print  ""
39         print  "/* $Id: MKterm.h.awk.in,v 1.66 2017/04/03 08:16:54 tom Exp $ */"
40         print  ""
41         print  "/*"
42         print  "**      term.h -- Definition of struct term"
43         print  "*/"
44         print  ""
45         print  "#ifndef NCURSES_TERM_H_incl"
46         print  "#define NCURSES_TERM_H_incl 1"
47         print  ""
48         print  "#undef  NCURSES_VERSION"
49         print  "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
50         print  ""
51         print  "#include <ncurses_dll.h>"
52         print  ""
53         print  "#ifdef __cplusplus"
54         printf "extern \"C\" %s\n", lcurl;
55         print  "#endif"
56         print  ""
57         print  "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
58         print  " * definition (based on the system for which this was configured)."
59         print  " */"
60         print  ""
61         print  "#undef  NCURSES_CONST"
62         print  "#define NCURSES_CONST @NCURSES_CONST@"
63         print  ""
64         print  "#undef  NCURSES_SBOOL"
65         print  "#define NCURSES_SBOOL @NCURSES_SBOOL@"
66         print  ""
67         print  "#undef  NCURSES_USE_DATABASE"
68         print  "#define NCURSES_USE_DATABASE @NCURSES_USE_DATABASE@"
69         print  ""
70         print  "#undef  NCURSES_USE_TERMCAP"
71         print  "#define NCURSES_USE_TERMCAP @NCURSES_USE_TERMCAP@"
72         print  ""
73         print  "#undef  NCURSES_XNAMES"
74         print  "#define NCURSES_XNAMES @NCURSES_XNAMES@"
75         print  ""
76         print  "/* We will use these symbols to hide differences between"
77         print  " * termios/termio/sgttyb interfaces."
78         print  " */"
79         print  "#undef  TTY"
80         print  "#undef  SET_TTY"
81         print  "#undef  GET_TTY"
82         print  ""
83         print  "/* Assume POSIX termio if we have the header and function */"
84         print  "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */"
85         print  "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@"
86         print  ""
87         print  "#undef  TERMIOS"
88         print  "#define TERMIOS 1"
89         print  ""
90         print  "#include <termios.h>"
91         print  "#define TTY struct termios"
92         print  ""
93         print  "#else /* !HAVE_TERMIOS_H */"
94         print  ""
95         print  "/* #if HAVE_TERMIO_H */"
96         print  "#if @HAVE_TERMIO_H@"
97         print  ""
98         print  "#undef  TERMIOS"
99         print  "#define TERMIOS 1"
100         print  ""
101         print  "#include <termio.h>"
102         print  "#define TTY struct termio"
103         print  ""
104         print  "#else /* !HAVE_TERMIO_H */"
105         print  ""
106         print  "#if __MINGW32__"
107         print  "#  include <ncurses_mingw.h>"
108         print  "#  define TTY struct termios"
109         print  "#else"
110         print  "#undef TERMIOS"
111         print  "#include <sgtty.h>"
112         print  "#include <sys/ioctl.h>"
113         print  "#define TTY struct sgttyb"
114         print  "#endif /* MINGW32 */"
115         print  "#endif /* HAVE_TERMIO_H */"
116         print  ""
117         print  "#endif /* HAVE_TERMIOS_H */"
118         print  ""
119         print  "#ifdef TERMIOS"
120         print  "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
121         print  "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
122         print  "#else"
123         print  "#define GET_TTY(fd, buf) gtty(fd, buf)"
124         print  "#define SET_TTY(fd, buf) stty(fd, buf)"
125         print  "#endif"
126         print  ""
127         print  "#define NAMESIZE 256"
128         print  ""
129         print  "/* The cast works because TERMTYPE is the first data in TERMINAL */"
130         print  "#define CUR ((TERMTYPE *)(cur_term))->"
131         print  ""
132 }
133
134 $2 == "%%-STOP-HERE-%%" {
135         print  ""
136         printf "#define BOOLWRITE %d\n", BoolCount
137         printf "#define NUMWRITE  %d\n", NumberCount
138         printf "#define STRWRITE  %d\n", StringCount
139         print  ""
140         print  "/* older synonyms for some capabilities */"
141         print  "#define beehive_glitch  no_esc_ctlc"
142         print  "#define teleray_glitch  dest_tabs_magic_smso"
143         print  "#define micro_char_size micro_col_size"
144         print  ""
145         print  "#ifdef __INTERNAL_CAPS_VISIBLE"
146 }
147
148 /^#/ {
149         next;
150 }
151
152 $1 == "acs_chars" {
153         acsindex = StringCount;
154 }
155
156 $3 == "bool" {
157         printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
158 }
159
160 $3 == "num" {
161         printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
162 }
163
164 $3 == "str" {
165         printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
166 }
167
168 END {
169         print  "#endif /* __INTERNAL_CAPS_VISIBLE */"
170         print  ""
171         print  ""
172         print  "/*"
173         print  " * Predefined terminfo array sizes"
174         print  " */"
175         printf "#define BOOLCOUNT %d\n", BoolCount
176         printf "#define NUMCOUNT  %d\n", NumberCount
177         printf "#define STRCOUNT  %d\n", StringCount
178         print  ""
179         print  "/* used by code for comparing entries */"
180         print  "#define acs_chars_index ", acsindex
181         print  ""
182         print  "typedef struct termtype {       /* in-core form of terminfo data */"
183         print  "    char  *term_names;          /* str_table offset of term names */"
184         print  "    char  *str_table;           /* pointer to string table */"
185         print  "    NCURSES_SBOOL  *Booleans;   /* array of boolean values */"
186         print  "    short *Numbers;             /* array of integer values */"
187         print  "    char  **Strings;            /* array of string offsets */"
188         print  ""
189         print  "#if NCURSES_XNAMES"
190         print  "    char  *ext_str_table;       /* pointer to extended string table */"
191         print  "    char  **ext_Names;          /* corresponding names */"
192         print  ""
193         print  "    unsigned short num_Booleans;/* count total Booleans */"
194         print  "    unsigned short num_Numbers; /* count total Numbers */"
195         print  "    unsigned short num_Strings; /* count total Strings */"
196         print  ""
197         print  "    unsigned short ext_Booleans;/* count extensions to Booleans */"
198         print  "    unsigned short ext_Numbers; /* count extensions to Numbers */"
199         print  "    unsigned short ext_Strings; /* count extensions to Strings */"
200         print  "#endif /* NCURSES_XNAMES */"
201         print  ""
202         print  "} TERMTYPE;"
203         print  ""
204         print  "/*"
205         print  " * The only reason these structures are visible is for read-only use."
206         print  " * Programs which modify the data are not, never were, portable across"
207         print  " * curses implementations."
208         print  " */"
209         print  "#ifdef NCURSES_INTERNALS"
210         print  "typedef struct term {           /* describe an actual terminal */"
211         print  "    TERMTYPE    type;           /* terminal type description */"
212         print  "    short       Filedes;        /* file description being written to */"
213         print  "    TTY         Ottyb;          /* original state of the terminal */"
214         print  "    TTY         Nttyb;          /* current state of the terminal */"
215         print  "    int         _baudrate;      /* used to compute padding */"
216         print  "    char *      _termname;      /* used for termname() */"
217         print  "} TERMINAL;"
218         print  "#else"
219         print  "typedef struct term TERMINAL;"
220         print  "#endif /* NCURSES_INTERNALS */"
221         print  ""
222         print  ""
223         print  "#if @BROKEN_LINKER@ && !@cf_cv_enable_reentrant@"
224         print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
225         print  "#elif @cf_cv_enable_reentrant@"
226         print  "NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);"
227         print  "#define cur_term   NCURSES_PUBLIC_VAR(cur_term())"
228         print  "#else"
229         print  "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;"
230         print  "#endif"
231         print  ""
232         print  "#if @BROKEN_LINKER@ || @cf_cv_enable_reentrant@"
233         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);"
234         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);"
235         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);"
236         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);"
237         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);"
238         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);"
239         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);"
240         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);"
241         print  "NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);"
242         print  ""
243         print  "#define boolnames  NCURSES_PUBLIC_VAR(boolnames())"
244         print  "#define boolcodes  NCURSES_PUBLIC_VAR(boolcodes())"
245         print  "#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())"
246         print  "#define numnames   NCURSES_PUBLIC_VAR(numnames())"
247         print  "#define numcodes   NCURSES_PUBLIC_VAR(numcodes())"
248         print  "#define numfnames  NCURSES_PUBLIC_VAR(numfnames())"
249         print  "#define strnames   NCURSES_PUBLIC_VAR(strnames())"
250         print  "#define strcodes   NCURSES_PUBLIC_VAR(strcodes())"
251         print  "#define strfnames  NCURSES_PUBLIC_VAR(strfnames())"
252         print  ""
253         print  "#else"
254         print  ""
255         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];"
256         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];"
257         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];"
258         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];"
259         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];"
260         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];"
261         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];"
262         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];"
263         print  "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];"
264         print  ""
265         print  "#endif"
266         print  ""
267         print  "/*"
268         print  " * These entrypoints are used only by the ncurses utilities such as tic."
269         print  " */"
270         print  "#ifdef NCURSES_INTERNALS"
271         print  ""
272         print  "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);"
273         print  "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);"
274         print  "extern NCURSES_EXPORT(void) _nc_init_termtype (TERMTYPE *const);"
275         print  "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);"
276         print  "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);"
277         print  "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);"
278         print  ""
279         print  "#endif /* NCURSES_INTERNALS */"
280         print  ""
281         print  ""
282         print  "/*"
283         print  " * These entrypoints are used by tack."
284         print  " */"
285         print  "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);"
286         print  "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);"
287         print  ""
288         print  "/* Normal entry points */"
289         print  "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);"
290         print  "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);"
291         print  ""
292         print  "/* miscellaneous entry points */"
293         print  "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);"
294         print  "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);"
295         print  ""
296         print  "/* terminfo entry points, also declared in curses.h */"
297         print  "#if !defined(__NCURSES_H)"
298         print  "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);"
299         print  "extern NCURSES_EXPORT_VAR(char) ttytype[];"
300         print  "extern NCURSES_EXPORT(int) putp (const char *);"
301         print  "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);"
302         print  "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);"
303         print  ""
304         print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
305         print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...);        /* special */"
306         print  "#else"
307         print  "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);       /* special */"
308         print  "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...);        /* special */"
309         print  "#endif"
310         print  ""
311         print  "extern NCURSES_EXPORT(char *) tiparm (const char *, ...);               /* special */"
312         print  ""
313         print  "#endif /* __NCURSES_H */"
314         print  ""
315         print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
316         print  "#if !defined(NCURSES_TERMCAP_H_incl)"
317         print  "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);"
318         print  "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);"
319         print  "extern NCURSES_EXPORT(int) tgetent (char *, const char *);"
320         print  "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);"
321         print  "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);"
322         print  "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));"
323         print  "#endif /* NCURSES_TERMCAP_H_incl */"
324         print  ""
325         print  "/*"
326         print  " * Include curses.h before term.h to enable these extensions."
327         print  " */"
328         print  "#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)"
329         print  ""
330         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tigetstr) (SCREEN*, NCURSES_CONST char *);"
331         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(putp) (SCREEN*, const char *);"
332         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetflag) (SCREEN*, NCURSES_CONST char *);"
333         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tigetnum) (SCREEN*, NCURSES_CONST char *);"
334         print  ""
335         print  "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */"
336         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, ...);     /* special */"
337         print  "#else"
338         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm) (SCREEN*, NCURSES_CONST char *, long,long,long,long,long,long,long,long,long);    /* special */"
339         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tparm_varargs) (SCREEN*, NCURSES_CONST char *, ...);     /* special */"
340         print  "#endif"
341         print  ""
342         print  "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
343         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgetstr) (SCREEN*, NCURSES_CONST char *, char **);"
344         print  "extern NCURSES_EXPORT(char *)  NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);"
345         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);"
346         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetflag) (SCREEN*, NCURSES_CONST char *);"
347         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tgetnum) (SCREEN*, NCURSES_CONST char *);"
348         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);"
349         print  ""
350         print  "extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);"
351         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);"
352         print  ""
353         print  "extern NCURSES_EXPORT(int)     NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);"
354         print  "#endif /* NCURSES_SP_FUNCS */"
355         print  ""
356         print  "#ifdef __cplusplus"
357         printf "%s\n", rcurl;
358         print  "#endif"
359         print  ""
360         print  "#endif /* NCURSES_TERM_H_incl */"
361 }