2 /***************************************************************************
4 ****************************************************************************
5 * ncurses is copyright (C) 1992-1995 *
7 * zmbenhal@netcom.com *
9 * esr@snark.thyrsus.com *
11 * Permission is hereby granted to reproduce and distribute ncurses *
12 * by any means and for any fee, whether alone or as part of a *
13 * larger distribution, in source or in binary form, PROVIDED *
14 * this notice is included with any such distribution, and is not *
15 * removed from any of its header files. Mention of ncurses in any *
16 * applications linked with it is highly appreciated. *
18 * ncurses comes AS IS with no warranty, implied or expressed. *
20 ***************************************************************************/
23 * tic.h - Global variables and structures for the terminfo
31 #include <curses.h> /* for the _tracef() prototype, ERR/OK, bool defs */
34 ** The format of compiled terminfo files is as follows:
36 ** Header (12 bytes), containing information given below
37 ** Names Section, containing the names of the terminal
38 ** Boolean Section, containing the values of all of the
39 ** boolean capabilities
40 ** A null byte may be inserted here to make
41 ** sure that the Number Section begins on an
42 ** even word boundary.
43 ** Number Section, containing the values of all of the numeric
44 ** capabilities, each as a short integer
45 ** String Section, containing short integer offsets into the
46 ** String Table, one per string capability
47 ** String Table, containing the actual characters of the string
50 ** NOTE that all short integers in the file are stored using VAX/PDP-style
51 ** byte-order, i.e., least-significant byte first.
53 ** There is no structure definition here because it would only confuse
54 ** matters. Terminfo format is a raw byte layout, not a structure
55 ** dump. If you happen to be on a little-endian machine with 16-bit
56 ** shorts that requires no padding between short members in a struct,
57 ** then there is a natural C structure that captures the header, but
58 ** not very helpfully.
61 #define MAGIC 0432 /* first two bytes of a compiled entry */
62 #define MAX_NAME_SIZE 127 /* maximum legal name field size */
63 #define MAX_ENTRY_SIZE 4096 /* maximum legal entry size */
64 #define MAX_ALIAS 14 /* maximum size of individual name or alias */
66 /* location of user's personal info directory */
67 #define PRIVATE_INFO "%s/.terminfo" /* plug getenv("HOME") into %s */
69 #define DEBUG(n, a) if (_nc_tracing & (1 << (n - 1))) _tracef a
70 extern unsigned _nc_tracing;
71 extern void _nc_tracef(char *, ...) GCC_PRINTFLIKE(1,2);
72 extern const char *_nc_visbuf(const char *);
75 * These are the types of tokens returned by the scanner. The first
76 * three are also used in the hash table of capability names. The scanner
77 * returns one of these values after loading the specifics into the global
78 * structure curr_token.
81 #define BOOLEAN 0 /* Boolean capability */
82 #define NUMBER 1 /* Numeric capability */
83 #define STRING 2 /* String-valued capability */
84 #define CANCEL 3 /* Capability to be cancelled in following tc's */
85 #define NAMES 4 /* The names for a terminal type */
86 #define UNDEF 5 /* Undefined */
88 #define NO_PUSHBACK -1 /* used in pushtype to indicate no pushback */
91 * The global structure in which the specific parts of a
92 * scanned token are returned.
98 char *tk_name; /* name of capability */
99 int tk_valnumber; /* value of capability (if a number) */
100 char *tk_valstring; /* value of capability (if a string) */
103 extern struct token _nc_curr_token;
106 * The file comp_captab.c contains an array of these structures, one
107 * per possible capability. These are indexed by a hash table array of
108 * pointers to the same structures for use by the parser.
111 struct name_table_entry
113 const char *nte_name; /* name to hash on */
114 int nte_type; /* BOOLEAN, NUMBER or STRING */
115 short nte_index; /* index of associated variable in its array */
116 short nte_link; /* index in table of next hash, or -1 */
126 extern const struct name_table_entry * const _nc_info_hash_table[];
127 extern const struct name_table_entry * const _nc_cap_hash_table[];
129 extern const struct alias _nc_capalias_table[];
130 extern const struct alias _nc_infoalias_table[];
132 extern const struct name_table_entry *_nc_get_table(bool);
134 #define NOTFOUND ((struct name_table_entry *) 0)
136 /* out-of-band values for representing absent capabilities */
137 #define ABSENT_BOOLEAN -1
138 #define ABSENT_NUMERIC -1
139 #define ABSENT_STRING (char *)0
141 /* out-of-band values for representing cancels */
142 #define CANCELLED_BOOLEAN (char)(-2)
143 #define CANCELLED_NUMERIC -2
144 #define CANCELLED_STRING (char *)-1
146 /* termcap entries longer than this may break old binaries */
147 #define MAX_TERMCAP_LENGTH 1023
149 /* this is a documented limitation of terminfo */
150 #define MAX_TERMINFO_LENGTH 4096
153 #define TERMINFO "/usr/share/terminfo"
156 /* comp_hash.c: name lookup */
157 struct name_table_entry const *_nc_find_entry(const char *,
158 const struct name_table_entry *const *);
159 struct name_table_entry const *_nc_find_type_entry(const char *,
161 const struct name_table_entry *);
163 /* comp_scan.c: lexical analysis */
164 extern int _nc_get_token(void);
165 extern void _nc_push_token(int);
166 extern void _nc_reset_input(FILE *, char *);
167 extern void _nc_panic_mode(char);
168 extern int _nc_curr_line;
169 extern int _nc_curr_col;
170 extern long _nc_curr_file_pos;
171 extern long _nc_comment_start, _nc_comment_end;
172 extern int _nc_syntax;
173 extern long _nc_start_line;
174 #define SYN_TERMINFO 0
175 #define SYN_TERMCAP 1
177 /* comp_error.c: warning & abort messages */
178 extern void _nc_set_source(const char *const name);
179 extern void _nc_get_type(char *name);
180 extern void _nc_set_type(const char *const name);
181 extern void _nc_syserr_abort(const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
182 extern void _nc_err_abort(const char *const,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
183 extern void _nc_warning(const char *const,...) GCC_PRINTFLIKE(1,2);
184 extern bool _nc_suppress_warnings;
186 /* captoinfo.c: capability conversion */
187 extern char *_nc_captoinfo(char *const, char *, int const);
188 extern char *_nc_infotocap(char *const, char *, int const);
190 /* comp_main.c: compiler main */
191 extern const char *_nc_progname;
194 extern const char *_nc_tic_dir(const char *);
197 extern int _nc_tic_written(void);