Back to index

tetex-bin  3.0
tic.h
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
00031  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
00032  *     and: Thomas E. Dickey 1996 on                                        *
00033  ****************************************************************************/
00034 
00035 /*
00036  * $Id: tic.h,v 1.49 2004/04/03 20:22:58 tom Exp $
00037  *     tic.h - Global variables and structures for the terminfo
00038  *                   compiler.
00039  */
00040 
00041 #ifndef __TIC_H
00042 #define __TIC_H
00043 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047 
00048 #include <curses.h>  /* for the _tracef() prototype, ERR/OK, bool defs */
00049 
00050 /*
00051 ** The format of compiled terminfo files is as follows:
00052 **
00053 **            Header (12 bytes), containing information given below
00054 **            Names Section, containing the names of the terminal
00055 **            Boolean Section, containing the values of all of the
00056 **                          boolean capabilities
00057 **                          A null byte may be inserted here to make
00058 **                          sure that the Number Section begins on an
00059 **                          even word boundary.
00060 **            Number Section, containing the values of all of the numeric
00061 **                          capabilities, each as a short integer
00062 **            String Section, containing short integer offsets into the
00063 **                          String Table, one per string capability
00064 **            String Table, containing the actual characters of the string
00065 **                          capabilities.
00066 **
00067 **     NOTE that all short integers in the file are stored using VAX/PDP-style
00068 **     byte-order, i.e., least-significant byte first.
00069 **
00070 **     There is no structure definition here because it would only confuse
00071 **     matters.  Terminfo format is a raw byte layout, not a structure
00072 **     dump.  If you happen to be on a little-endian machine with 16-bit
00073 **     shorts that requires no padding between short members in a struct,
00074 **     then there is a natural C structure that captures the header, but
00075 **     not very helpfully.
00076 */
00077 
00078 #define MAGIC        0432   /* first two bytes of a compiled entry */
00079 
00080 /*
00081  * The "maximum" here is misleading; XSI guarantees minimum values, which a
00082  * given implementation may exceed.
00083  */
00084 #define MAX_NAME_SIZE       512    /* maximum legal name field size (XSI:127) */
00085 #define MAX_ENTRY_SIZE      4096   /* maximum legal entry size */
00086 
00087 /*
00088  * The maximum size of individual name or alias is guaranteed in XSI to be at
00089  * least 14, since that corresponds to the older filename lengths.  Newer
00090  * systems allow longer aliases, though not many terminal descriptions are
00091  * written to use them.  The MAX_ALIAS symbol is used for warnings.
00092  */
00093 #if HAVE_LONG_FILE_NAMES
00094 #define MAX_ALIAS    32     /* smaller than POSIX minimum for PATH_MAX */
00095 #else
00096 #define MAX_ALIAS    14     /* SVr3 filename length */
00097 #endif
00098 
00099 /* location of user's personal info directory */
00100 #define PRIVATE_INFO "%s/.terminfo"       /* plug getenv("HOME") into %s */
00101 
00102 /*
00103  * Some traces are designed to be used via tic's verbose option (and similar in
00104  * infocmp and toe) rather than the 'trace()' function.  So we use the bits
00105  * above the normal trace() parameter as a debug-level.
00106  */
00107 
00108 #define MAX_DEBUG_LEVEL 15
00109 #define DEBUG_LEVEL(n)      ((n) << TRACE_SHIFT)
00110 
00111 #define set_trace_level(n) \
00112        _nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
00113        _nc_tracing |= DEBUG_LEVEL(n)
00114 
00115 #ifdef TRACE
00116 #define DEBUG(n, a)  if (_nc_tracing >= DEBUG_LEVEL(n)) _tracef a
00117 #else
00118 #define DEBUG(n, a)  /*nothing*/
00119 #endif
00120 
00121 extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
00122 extern NCURSES_EXPORT(void) _nc_tracef (char *, ...) GCC_PRINTFLIKE(1,2);
00123 extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
00124 extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
00125 
00126 /*
00127  * These are the types of tokens returned by the scanner.  The first
00128  * three are also used in the hash table of capability names.  The scanner
00129  * returns one of these values after loading the specifics into the global
00130  * structure curr_token.
00131  */
00132 
00133 #define BOOLEAN 0           /* Boolean capability */
00134 #define NUMBER 1            /* Numeric capability */
00135 #define STRING 2            /* String-valued capability */
00136 #define CANCEL 3            /* Capability to be cancelled in following tc's */
00137 #define NAMES  4            /* The names for a terminal type */
00138 #define UNDEF  5            /* Undefined */
00139 
00140 #define NO_PUSHBACK  -1     /* used in pushtype to indicate no pushback */
00141 
00142        /*
00143         *     The global structure in which the specific parts of a
00144         *     scanned token are returned.
00145         *
00146         */
00147 
00148 struct token
00149 {
00150        char   *tk_name;            /* name of capability */
00151        int    tk_valnumber; /* value of capability (if a number) */
00152        char   *tk_valstring;       /* value of capability (if a string) */
00153 };
00154 
00155 extern NCURSES_EXPORT_VAR(struct token)   _nc_curr_token;
00156 
00157        /*
00158         * List of keynames with their corresponding code.
00159         */
00160 struct kn {
00161        const char *name;
00162        int code;
00163 };
00164 
00165 extern NCURSES_EXPORT_VAR(const struct kn) _nc_key_names[];
00166 
00167        /*
00168         * Offsets to string capabilities, with the corresponding functionkey
00169         * codes.
00170         */
00171 struct tinfo_fkeys {
00172        unsigned offset;
00173        chtype code;
00174        };
00175 
00176 #if    BROKEN_LINKER
00177 
00178 #define       _nc_tinfo_fkeys      _nc_tinfo_fkeysf()
00179 extern NCURSES_EXPORT(struct tinfo_fkeys *) _nc_tinfo_fkeysf (void);
00180 
00181 #else
00182 
00183 extern NCURSES_EXPORT_VAR(struct tinfo_fkeys) _nc_tinfo_fkeys[];
00184 
00185 #endif
00186 
00187        /*
00188         * The file comp_captab.c contains an array of these structures, one
00189         * per possible capability.  These are indexed by a hash table array of
00190         * pointers to the same structures for use by the parser.
00191         */
00192 
00193 struct name_table_entry
00194 {
00195        const char *nte_name;       /* name to hash on */
00196        int    nte_type;     /* BOOLEAN, NUMBER or STRING */
00197        short  nte_index;    /* index of associated variable in its array */
00198        short  nte_link;     /* index in table of next hash, or -1 */
00199 };
00200 
00201 struct alias
00202 {
00203        const char    *from;
00204        const char    *to;
00205        const char    *source;
00206 };
00207 
00208 extern NCURSES_EXPORT_VAR(const struct name_table_entry * const) _nc_info_hash_table[];
00209 extern NCURSES_EXPORT_VAR(const struct name_table_entry * const) _nc_cap_hash_table[];
00210 
00211 extern NCURSES_EXPORT_VAR(const struct alias) _nc_capalias_table[];
00212 extern NCURSES_EXPORT_VAR(const struct alias) _nc_infoalias_table[];
00213 
00214 extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool);
00215 extern NCURSES_EXPORT(const struct name_table_entry * const *) _nc_get_hash_table (bool);
00216 
00217 #define NOTFOUND     ((struct name_table_entry *) 0)
00218 
00219 /* out-of-band values for representing absent capabilities */
00220 #define ABSENT_BOOLEAN             ((signed char)-1)    /* 255 */
00221 #define ABSENT_NUMERIC             (-1)
00222 #define ABSENT_STRING              (char *)0
00223 
00224 /* out-of-band values for representing cancels */
00225 #define CANCELLED_BOOLEAN   ((signed char)-2)    /* 254 */
00226 #define CANCELLED_NUMERIC   (-2)
00227 #define CANCELLED_STRING    (char *)(-1)
00228 
00229 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
00230 #define VALID_NUMERIC(s) ((s) >= 0)
00231 #define VALID_STRING(s)  ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
00232 
00233 /* termcap entries longer than this may break old binaries */
00234 #define MAX_TERMCAP_LENGTH  1023
00235 
00236 /* this is a documented limitation of terminfo */
00237 #define MAX_TERMINFO_LENGTH 4096
00238 
00239 #ifndef TERMINFO
00240 #define TERMINFO "/usr/share/terminfo"
00241 #endif
00242 
00243 /* access.c */
00244 extern NCURSES_EXPORT(unsigned) _nc_pathlast (const char *);
00245 extern NCURSES_EXPORT(char *) _nc_basename (char *);
00246 extern NCURSES_EXPORT(char *) _nc_rootname (char *);
00247 
00248 /* comp_hash.c: name lookup */
00249 extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
00250        (const char *, const struct name_table_entry *const *);
00251 extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry
00252        (const char *, int, const struct name_table_entry *);
00253 
00254 /* comp_scan.c: lexical analysis */
00255 extern NCURSES_EXPORT(int)  _nc_get_token (bool);
00256 extern NCURSES_EXPORT(void) _nc_panic_mode (char);
00257 extern NCURSES_EXPORT(void) _nc_push_token (int);
00258 extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *);
00259 extern NCURSES_EXPORT_VAR(int) _nc_curr_col;
00260 extern NCURSES_EXPORT_VAR(int) _nc_curr_line;
00261 extern NCURSES_EXPORT_VAR(int) _nc_syntax;
00262 extern NCURSES_EXPORT_VAR(long) _nc_comment_end;
00263 extern NCURSES_EXPORT_VAR(long) _nc_comment_start;
00264 extern NCURSES_EXPORT_VAR(long) _nc_curr_file_pos;
00265 extern NCURSES_EXPORT_VAR(long) _nc_start_line;
00266 #define SYN_TERMINFO 0
00267 #define SYN_TERMCAP  1
00268 
00269 /* comp_error.c: warning & abort messages */
00270 extern NCURSES_EXPORT(void) _nc_set_source (const char *const name);
00271 extern NCURSES_EXPORT(void) _nc_get_type (char *name);
00272 extern NCURSES_EXPORT(void) _nc_set_type (const char *const name);
00273 extern NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
00274 extern NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
00275 extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2);
00276 extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings;
00277 
00278 /* comp_expand.c: expand string into readable form */
00279 extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int);
00280 
00281 /* comp_scan.c: decode string from readable form */
00282 extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *);
00283 
00284 /* captoinfo.c: capability conversion */
00285 extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const);
00286 extern NCURSES_EXPORT(char *) _nc_infotocap (const char *, const char *, int const);
00287 
00288 /* lib_tparm.c */
00289 #define NUM_PARM 9
00290 
00291 extern NCURSES_EXPORT_VAR(int) _nc_tparm_err;
00292 
00293 extern NCURSES_EXPORT(int) _nc_tparm_analyze(const char *string, char *p_is_s[NUM_PARM], int *popcount);
00294 
00295 /* lib_tputs.c */
00296 extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent;          /* Add one for every null sent */
00297 
00298 /* comp_main.c: compiler main */
00299 extern const char * _nc_progname;
00300 
00301 /* read_entry.c */
00302 extern NCURSES_EXPORT(const char *) _nc_tic_dir (const char *);
00303 
00304 /* write_entry.c */
00305 extern NCURSES_EXPORT(int) _nc_tic_written (void);
00306 
00307 #ifdef __cplusplus
00308 }
00309 #endif
00310 
00311 #endif /* __TIC_H */