MKterm.h.awk.in revision 166124
150276SpeterBEGIN { 250276Speter print "/****************************************************************************" 3166124Srafan print " * Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *" 450276Speter print " * *" 550276Speter print " * Permission is hereby granted, free of charge, to any person obtaining a *" 650276Speter print " * copy of this software and associated documentation files (the *" 756639Speter print " * \"Software\"), to deal in the Software without restriction, including *" 850276Speter print " * without limitation the rights to use, copy, modify, merge, publish, *" 950276Speter print " * distribute, distribute with modifications, sublicense, and/or sell *" 1050276Speter print " * copies of the Software, and to permit persons to whom the Software is *" 1150276Speter print " * furnished to do so, subject to the following conditions: *" 1250276Speter print " * *" 1350276Speter print " * The above copyright notice and this permission notice shall be included *" 1450276Speter print " * in all copies or substantial portions of the Software. *" 1550276Speter print " * *" 1656639Speter print " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS *" 1750276Speter print " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *" 1850276Speter print " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *" 1950276Speter print " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *" 2050276Speter print " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *" 2150276Speter print " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *" 2250276Speter print " * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *" 2350276Speter print " * *" 2450276Speter print " * Except as contained in this notice, the name(s) of the above copyright *" 2550276Speter print " * holders shall not be used in advertising or otherwise to promote the *" 2650276Speter print " * sale, use or other dealings in this Software without prior written *" 2750276Speter print " * authorization. *" 2850276Speter print " ****************************************************************************/" 2950276Speter print "" 3050276Speter print "/****************************************************************************/" 3150276Speter print "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */" 3250276Speter print "/* and: Eric S. Raymond <esr@snark.thyrsus.com> */" 33166124Srafan print "/* and: Thomas E. Dickey 1995-on */" 3450276Speter print "/****************************************************************************/" 3550276Speter print "" 36166124Srafan print "/* $Id: MKterm.h.awk.in,v 1.47 2006/11/26 01:18:23 tom Exp $ */" 3750276Speter print "" 3850276Speter print "/*" 3950276Speter print "** term.h -- Definition of struct term" 4050276Speter print "*/" 4150276Speter print "" 4276726Speter print "#ifndef NCURSES_TERM_H_incl" 4376726Speter print "#define NCURSES_TERM_H_incl 1" 4450276Speter print "" 4550276Speter print "#undef NCURSES_VERSION" 4650276Speter print "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\"" 4750276Speter print "" 4876726Speter print "#include <ncurses_dll.h>" 4976726Speter print "" 5050276Speter print "#ifdef __cplusplus" 5150276Speter print "extern \"C\" {" 5250276Speter print "#endif" 5350276Speter print "" 5450276Speter print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H" 5597049Speter print " * definition (based on the system for which this was configured)." 5650276Speter print " */" 5750276Speter print "" 5850276Speter print "#undef NCURSES_CONST" 5950276Speter print "#define NCURSES_CONST @NCURSES_CONST@" 6050276Speter print "" 61166124Srafan print "#undef NCURSES_SBOOL" 62166124Srafan print "#define NCURSES_SBOOL @NCURSES_SBOOL@" 63166124Srafan print "" 6450276Speter print "#undef NCURSES_XNAMES" 6550276Speter print "#define NCURSES_XNAMES @NCURSES_XNAMES@" 6650276Speter print "" 6750276Speter print "/* We will use these symbols to hide differences between" 6850276Speter print " * termios/termio/sgttyb interfaces." 6950276Speter print " */" 7050276Speter print "#undef TTY" 7150276Speter print "#undef SET_TTY" 7250276Speter print "#undef GET_TTY" 7350276Speter print "" 7497049Speter print "/* Assume POSIX termio if we have the header and function */" 75166124Srafan print "/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */" 76166124Srafan print "#if @HAVE_TERMIOS_H@ && @HAVE_TCGETATTR@" 7750276Speter print "" 7850276Speter print "#undef TERMIOS" 7950276Speter print "#define TERMIOS 1" 8050276Speter print "" 8150276Speter print "#include <termios.h>" 8250276Speter print "#define TTY struct termios" 8350276Speter print "" 8450276Speter print "#else /* !HAVE_TERMIOS_H */" 8550276Speter print "" 86166124Srafan print "/* #if HAVE_TERMIO_H */" 87166124Srafan print "#if @HAVE_TERMIO_H@" 8850276Speter print "" 8950276Speter print "#undef TERMIOS" 9050276Speter print "#define TERMIOS 1" 9150276Speter print "" 9250276Speter print "#include <termio.h>" 9350276Speter print "#define TTY struct termio" 9450276Speter print "" 9550276Speter print "/* Add definitions to make termio look like termios." 9650276Speter print " * But ifdef it, since there are some implementations" 9750276Speter print " * that try to do this for us in a fake <termio.h>." 9850276Speter print " */" 9950276Speter print "#ifndef TCSANOW" 10050276Speter print "#define TCSANOW TCSETA" 10150276Speter print "#endif" 10250276Speter print "#ifndef TCSADRAIN" 10350276Speter print "#define TCSADRAIN TCSETAW" 10450276Speter print "#endif" 10550276Speter print "#ifndef TCSAFLUSH" 10650276Speter print "#define TCSAFLUSH TCSETAF" 10750276Speter print "#endif" 10850276Speter print "#ifndef tcsetattr" 10950276Speter print "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)" 11050276Speter print "#endif" 11150276Speter print "#ifndef tcgetattr" 11250276Speter print "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)" 11350276Speter print "#endif" 11450276Speter print "#ifndef cfgetospeed" 11550276Speter print "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)" 11650276Speter print "#endif" 11750276Speter print "#ifndef TCIFLUSH " 11850276Speter print "#define TCIFLUSH 0" 11950276Speter print "#endif" 12050276Speter print "#ifndef TCOFLUSH " 12150276Speter print "#define TCOFLUSH 1" 12250276Speter print "#endif" 12350276Speter print "#ifndef TCIOFLUSH " 12450276Speter print "#define TCIOFLUSH 2" 12550276Speter print "#endif" 12650276Speter print "#ifndef tcflush" 12750276Speter print "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)" 12850276Speter print "#endif" 12950276Speter print "" 13050276Speter print "#else /* !HAVE_TERMIO_H */" 13150276Speter print "" 13250276Speter print "#undef TERMIOS" 13350276Speter print "#include <sgtty.h>" 13450276Speter print "#include <sys/ioctl.h>" 13550276Speter print "#define TTY struct sgttyb" 13650276Speter print "" 13750276Speter print "#endif /* HAVE_TERMIO_H */" 13850276Speter print "" 13950276Speter print "#endif /* HAVE_TERMIOS_H */" 14050276Speter print "" 14150276Speter print "#ifdef TERMIOS" 14250276Speter print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)" 14350276Speter print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)" 14450276Speter print "#else" 14550276Speter print "#define GET_TTY(fd, buf) gtty(fd, buf)" 14650276Speter print "#define SET_TTY(fd, buf) stty(fd, buf)" 14750276Speter print "#endif" 14850276Speter print "" 14950276Speter print "#define NAMESIZE 256" 15050276Speter print "" 15150276Speter print "#define CUR cur_term->type." 15250276Speter print "" 15350276Speter } 15450276Speter 15550276Speter$2 == "%%-STOP-HERE-%%" { 15650276Speter print "" 15750276Speter printf "#define BOOLWRITE %d\n", BoolCount 15850276Speter printf "#define NUMWRITE %d\n", NumberCount 15950276Speter printf "#define STRWRITE %d\n", StringCount 16050276Speter print "" 16150276Speter print "/* older synonyms for some capabilities */" 16250276Speter print "#define beehive_glitch no_esc_ctlc" 16350276Speter print "#define teleray_glitch dest_tabs_magic_smso" 16450276Speter print "#define micro_char_size micro_col_size" 16550276Speter print "" 16650276Speter print "#ifdef __INTERNAL_CAPS_VISIBLE" 16750276Speter } 16850276Speter 16950276Speter/^#/ {next;} 17050276Speter 17162449Speter$1 == "acs_chars" {acsindex = StringCount} 17262449Speter 17350276Speter$3 == "bool" { 17450276Speter printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++ 17550276Speter } 17650276Speter 17750276Speter$3 == "num" { 17850276Speter printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++ 17950276Speter } 18050276Speter 18150276Speter$3 == "str" { 18250276Speter printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++ 18350276Speter } 18450276Speter 18550276SpeterEND { 18650276Speter print "#endif /* __INTERNAL_CAPS_VISIBLE */" 18750276Speter print "" 18850276Speter print "" 18950276Speter print "/*" 19050276Speter print " * Predefined terminfo array sizes" 19150276Speter print " */" 19250276Speter printf "#define BOOLCOUNT %d\n", BoolCount 19350276Speter printf "#define NUMCOUNT %d\n", NumberCount 19450276Speter printf "#define STRCOUNT %d\n", StringCount 19550276Speter print "" 19662449Speter print "/* used by code for comparing entries */" 19762449Speter print "#define acs_chars_index ", acsindex 19862449Speter print "" 19950276Speter print "typedef struct termtype { /* in-core form of terminfo data */" 20050276Speter print " char *term_names; /* str_table offset of term names */" 20150276Speter print " char *str_table; /* pointer to string table */" 202166124Srafan print " NCURSES_SBOOL *Booleans; /* array of boolean values */" 20350276Speter print " short *Numbers; /* array of integer values */" 20450276Speter print " char **Strings; /* array of string offsets */" 20550276Speter print "" 20650276Speter print "#if NCURSES_XNAMES" 20750276Speter print " char *ext_str_table; /* pointer to extended string table */" 20850276Speter print " char **ext_Names; /* corresponding names */" 20950276Speter print "" 21050276Speter print " unsigned short num_Booleans;/* count total Booleans */" 21150276Speter print " unsigned short num_Numbers; /* count total Numbers */" 21250276Speter print " unsigned short num_Strings; /* count total Strings */" 21350276Speter print "" 21450276Speter print " unsigned short ext_Booleans;/* count extensions to Booleans */" 21550276Speter print " unsigned short ext_Numbers; /* count extensions to Numbers */" 21650276Speter print " unsigned short ext_Strings; /* count extensions to Strings */" 21750276Speter print "#endif /* NCURSES_XNAMES */" 21850276Speter print "" 21950276Speter print "} TERMTYPE;" 22050276Speter print "" 22150276Speter print "typedef struct term { /* describe an actual terminal */" 22250276Speter print " TERMTYPE type; /* terminal type description */" 22397049Speter print " short Filedes; /* file description being written to */" 22450276Speter print " TTY Ottyb, /* original state of the terminal */" 22550276Speter print " Nttyb; /* current state of the terminal */" 22650276Speter print " int _baudrate; /* used to compute padding */" 227166124Srafan print " char * _termname; /* used for termname() */" 22850276Speter print "} TERMINAL;" 22950276Speter print "" 23076726Speter print "extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;" 23150276Speter print "" 23250276Speter print "#if BROKEN_LINKER" 23350276Speter print "#define boolnames _nc_boolnames()" 23450276Speter print "#define boolcodes _nc_boolcodes()" 23550276Speter print "#define boolfnames _nc_boolfnames()" 23650276Speter print "#define numnames _nc_numnames()" 23750276Speter print "#define numcodes _nc_numcodes()" 23850276Speter print "#define numfnames _nc_numfnames()" 23950276Speter print "#define strnames _nc_strnames()" 24050276Speter print "#define strcodes _nc_strcodes()" 24150276Speter print "#define strfnames _nc_strfnames()" 24250276Speter print "" 24376726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolnames (void);" 24476726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolcodes (void);" 24576726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_boolfnames (void);" 24676726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numnames (void);" 24776726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numcodes (void);" 24876726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_numfnames (void);" 24976726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strnames (void);" 25076726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strcodes (void);" 25176726Speter print "extern NCURSES_EXPORT(NCURSES_CONST char * const *) _nc_strfnames (void);" 25250276Speter print "" 25350276Speter print "#else" 25450276Speter print "" 25576726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];" 25676726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];" 25776726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];" 25876726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];" 25976726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];" 26076726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];" 26176726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];" 26276726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];" 26376726Speter print "extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];" 26450276Speter print "" 26550276Speter print "#endif" 26650276Speter print "" 26750276Speter print "/* internals */" 26876726Speter print "extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);" 26976726Speter print "extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);" 27076726Speter print "extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);" 27176726Speter print "extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);" 272166124Srafan print "extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);" 27376726Speter print "extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);" 27476726Speter print "extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);" 27576726Speter print "extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);" 27650276Speter print "" 27750276Speter print "/* entry points */" 27876726Speter print "extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);" 27976726Speter print "extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);" 28050276Speter print "" 28150276Speter print "/* miscellaneous entry points */" 28276726Speter print "extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);" 28376726Speter print "extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);" 28450276Speter print "" 28550276Speter print "/* terminfo entry points, also declared in curses.h */" 28650276Speter print "#if !defined(__NCURSES_H)" 28776726Speter print "extern NCURSES_EXPORT(char *) tigetstr (NCURSES_CONST char *);" 28876726Speter print "extern NCURSES_EXPORT_VAR(char) ttytype[];" 28976726Speter print "extern NCURSES_EXPORT(int) putp (const char *);" 29076726Speter print "extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);" 29176726Speter print "extern NCURSES_EXPORT(int) tigetnum (NCURSES_CONST char *);" 292166124Srafan print "" 293166124Srafan print "#if @NCURSES_TPARM_VARARGS@ /* NCURSES_TPARM_VARARGS */" 294166124Srafan print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, ...); /* implemented */" 295166124Srafan print "#else" 296166124Srafan print "extern NCURSES_EXPORT(char *) tparm (NCURSES_CONST char *, long,long,long,long,long,long,long,long,long); /* implemented */" 297166124Srafan print "extern NCURSES_EXPORT(char *) tparm_varargs (NCURSES_CONST char *, ...); /* implemented */" 298166124Srafan print "#endif" 299166124Srafan print "" 30050276Speter print "#endif /* __NCURSES_H */" 30150276Speter print "" 30250276Speter print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */" 30376726Speter print "#if !defined(NCURSES_TERMCAP_H_incl)" 30476726Speter print "extern NCURSES_EXPORT(char *) tgetstr (NCURSES_CONST char *, char **);" 30576726Speter print "extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);" 30676726Speter print "extern NCURSES_EXPORT(int) tgetent (char *, const char *);" 30776726Speter print "extern NCURSES_EXPORT(int) tgetflag (NCURSES_CONST char *);" 30876726Speter print "extern NCURSES_EXPORT(int) tgetnum (NCURSES_CONST char *);" 30976726Speter print "extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));" 31076726Speter print "#endif /* NCURSES_TERMCAP_H_incl */" 31150276Speter print "" 31250276Speter print "#ifdef __cplusplus" 31350276Speter print "}" 31450276Speter print "#endif" 31550276Speter print "" 31676726Speter print "#endif /* NCURSES_TERM_H_incl */" 31750276Speter } 318