1term(5)                       File Formats Manual                      term(5)
2
3
4

NAME

6       term - format of compiled term file.
7

SYNOPSIS

9       term
10

DESCRIPTION

12   STORAGE LOCATION
13       Compiled   terminfo   descriptions   are  placed  under  the  directory
14       /usr/share/terminfo.  Two configurations are supported  (when  building
15       the ncurses libraries):
16
17       directory tree
18            A two-level scheme is used to avoid a linear search of a huge UNIX
19            system directory: /usr/share/terminfo/c/name  where  name  is  the
20            name of the terminal, and c is the first character of name.  Thus,
21            act4 can be found in the  file  /usr/share/terminfo/a/act4.   Syn‐
22            onyms  for  the same terminal are implemented by multiple links to
23            the same compiled file.
24
25       hashed database
26            Using Berkeley database, two types of records are stored: the ter‐
27            minfo  data  in the same format as stored in a directory tree with
28            the terminfo's primary name as a key, and records containing  only
29            aliases pointing to the primary name.
30
31            If  built  to  write hashed databases, ncurses can still read ter‐
32            minfo databases organized as a directory tree,  but  cannot  write
33            entries  into  the  directory  tree.   It  can  write (or rewrite)
34            entries in the hashed database.
35
36            ncurses distinguishes the two  cases  in  the  TERMINFO  and  TER‐
37            MINFO_DIRS  environment  variable by assuming a directory tree for
38            entries that correspond to an existing directory, and hashed data‐
39            base otherwise.
40
41   LEGACY STORAGE FORMAT
42       The format has been chosen so that it will be the same on all hardware.
43       An 8 or more bit byte is assumed, but no assumptions about byte  order‐
44       ing or sign extension are made.
45
46       The compiled file is created with the tic program, and read by the rou‐
47       tine setupterm(3X).  The file is divided into six  parts:  the  header,
48       terminal names, boolean flags, numbers, strings, and string table.
49
50       The  header  section  begins the file.  This section contains six short
51       integers in the format described below.  These integers are
52
53            (1) the magic number (octal 0432);
54
55            (2) the size, in bytes, of the names section;
56
57            (3) the number of bytes in the boolean section;
58
59            (4) the number of short integers in the numbers section;
60
61            (5) the number of offsets (short integers) in the strings section;
62
63            (6) the size, in bytes, of the string table.
64
65       Short integers are stored in two 8-bit bytes.  The first byte  contains
66       the least significant 8 bits of the value, and the second byte contains
67       the most significant 8 bits.  (Thus, the value represented is  256*sec‐
68       ond+first.)   The  value -1 is represented by the two bytes 0377, 0377;
69       other negative values are illegal. This value generally means that  the
70       corresponding capability is missing from this terminal.  Note that this
71       format corresponds to the hardware of the VAX and PDP-11 (that is, lit‐
72       tle-endian  machines).   Machines where this does not correspond to the
73       hardware must read the integers as two bytes and  compute  the  little-
74       endian value.
75
76       The  terminal  names section comes next.  It contains the first line of
77       the terminfo description, listing the various names for  the  terminal,
78       separated  by  the  “|”  character.   The section is terminated with an
79       ASCII NUL character.
80
81       The boolean flags have one byte for each flag.  This byte is  either  0
82       or  1  as  the  flag is present or absent.  The capabilities are in the
83       same order as the file <term.h>.
84
85       Between the boolean section and the number section, a null byte will be
86       inserted,  if necessary, to ensure that the number section begins on an
87       even byte (this is a relic of the PDP-11's word-addressed architecture,
88       originally  designed in to avoid IOT traps induced by addressing a word
89       on an odd byte boundary).  All short integers are aligned  on  a  short
90       word boundary.
91
92       The  numbers  section is similar to the flags section.  Each capability
93       takes up two bytes, and is stored as a little-endian short integer.  If
94       the value represented is -1, the capability is taken to be missing.
95
96       The  strings  section  is also similar.  Each capability is stored as a
97       short integer, in the format above.  A value of -1 means the capability
98       is missing.  Otherwise, the value is taken as an offset from the begin‐
99       ning of the string table.  Special characters in ^X or \c notation  are
100       stored  in  their  interpreted  form,  not the printing representation.
101       Padding information $<nn>  and  parameter  information  %x  are  stored
102       intact in uninterpreted form.
103
104       The  final  section is the string table.  It contains all the values of
105       string capabilities referenced in the string section.  Each  string  is
106       null terminated.
107
108   EXTENDED STORAGE FORMAT
109       The previous section describes the conventional terminfo binary format.
110       With some minor variations of the offsets (see PORTABILITY),  the  same
111       binary  format  is used in all modern UNIX systems.  Each system uses a
112       predefined set of boolean, number or string capabilities.
113
114       The ncurses libraries and applications support extended terminfo binary
115       format,  allowing users to define capabilities which are loaded at run‐
116       time.  This extension is made possible by using the fact that the other
117       implementations  stop  reading the terminfo data when they have reached
118       the end of the size given in the header.  ncurses checks the size,  and
119       if  it  exceeds  that  due  to  the predefined data, continues to parse
120       according to its own scheme.
121
122       First, it reads the extended header (5 short integers):
123
124            (1)  count of extended boolean capabilities
125
126            (2)  count of extended numeric capabilities
127
128            (3)  count of extended string capabilities
129
130            (4)  size of the extended string table in bytes.
131
132            (5)  last offset of the extended string table in bytes.
133
134       Using the counts and sizes, ncurses allocates arrays and reads data for
135       the extended capabilities in the same order as the header information.
136
137       The  extended  string  table  contains  values for string capabilities.
138       After the end of these values, it contains the names for  each  of  the
139       extended  capabilities  in  order,  e.g.,  booleans,  then  numbers and
140       finally strings.
141
142       Applications which manipulate terminal data  can  use  the  definitions
143       described  in  term_variables(3X)  which  associate the long capability
144       names with members of a TERMTYPE structure.
145
146   EXTENDED NUMBER FORMAT
147       On occasion, 16-bit signed integers are not large enough.  With ncurses
148       6.1,  a  new format is introduced by making a few changes to the legacy
149       format:
150
151       ·   a different magic number (0542)
152
153       ·   changing the type for the number array from signed 16-bit  integers
154           to signed 32-bit integers.
155
156       To  maintain  compatibility,  the library presents the same data struc‐
157       tures to direct users of the TERMTYPE structure as in previous formats.
158       However,  that  cannot  provide callers with the extended numbers.  The
159       library uses a similar but hidden data structure TERMTYPE2  to  provide
160       data for the terminfo functions.
161

PORTABILITY

163       Note  that  it  is  possible for setupterm to expect a different set of
164       capabilities than are actually present in the file.  Either  the  data‐
165       base may have been updated since setupterm has been recompiled (result‐
166       ing in extra unrecognized entries in the file) or the program may  have
167       been  recompiled more recently than the database was updated (resulting
168       in missing entries).  The routine setupterm must be prepared  for  both
169       possibilities  - this is why the numbers and sizes are included.  Also,
170       new capabilities must always be added at the end of the lists of  bool‐
171       ean, number, and string capabilities.
172
173       Despite  the consistent use of little-endian for numbers and the other‐
174       wise self-describing format, it is not wise to count on portability  of
175       binary  terminfo entries between commercial UNIX versions.  The problem
176       is that there are at least three versions  of  terminfo  (under  HP-UX,
177       AIX,  and  OSF/1) which diverged from System V terminfo after SVr1, and
178       have added extension capabilities to the  string  table  that  (in  the
179       binary  format)  collide  with System V and XSI Curses extensions.  See
180       terminfo(5) for detailed discussion of  terminfo  source  compatibility
181       issues.
182
183       Direct access to the TERMTYPE structure is provided for legacy applica‐
184       tions.  Portable applications should  use  the  tigetflag  and  related
185       functions described in curs_terminfo(3X) for reading terminal capabili‐
186       ties.
187
188       A small number of terminal descriptions  use  uppercase  characters  in
189       their  names.   If  the  underlying  filesystem  ignores the difference
190       between uppercase and lowercase, ncurses represents the “first  charac‐
191       ter” of the terminal name used as the intermediate level of a directory
192       tree in (two-character) hexadecimal form.
193

EXAMPLE

195       As an example, here is a description for the Lear-Siegler ADM-3, a pop‐
196       ular though rather stupid early terminal:
197
198           adm3a|lsi adm3a,
199                   am,
200                   cols#80, lines#24,
201                   bel=^G, clear= 32$<1>, cr=^M, cub1=^H, cud1=^J,
202                   cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
203                   home=^^, ind=^J,
204
205
206       and a hexadecimal dump of the compiled terminal description:
207
208           0000  1a 01 10 00 02 00 03 00  82 00 31 00 61 64 6d 33  ........ ..1.adm3
209           0010  61 7c 6c 73 69 20 61 64  6d 33 61 00 00 01 50 00  a|lsi ad m3a...P.
210           0020  ff ff 18 00 ff ff 00 00  02 00 ff ff ff ff 04 00  ........ ........
211           0030  ff ff ff ff ff ff ff ff  0a 00 25 00 27 00 ff ff  ........ ..%.'...
212           0040  29 00 ff ff ff ff 2b 00  ff ff 2d 00 ff ff ff ff  ).....+. ..-.....
213           0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
214           0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
215           0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
216           0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
217           0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
218           00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
219           00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
220           00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
221           00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
222           00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
223           00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
224           0100  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
225           0110  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
226           0120  ff ff ff ff ff ff 2f 00  07 00 0d 00 1a 24 3c 31  ....../. .....$<1
227           0130  3e 00 1b 3d 25 70 31 25  7b 33 32 7d 25 2b 25 63  >..=%p1% {32}%+%c
228           0140  25 70 32 25 7b 33 32 7d  25 2b 25 63 00 0a 00 1e  %p2%{32} %+%c....
229           0150  00 08 00 0c 00 0b 00 0a  00                       ........ .
230
231

LIMITS

233       Some limitations:
234
235       ·   total  compiled entries cannot exceed 4096 bytes in the legacy for‐
236           mat.
237
238       ·   total compiled entries cannot exceed 32768 bytes  in  the  extended
239           format.
240
241       ·   the name field cannot exceed 128 bytes.
242

FILES

244       /usr/share/terminfo/*/*  compiled terminal capability data base
245

SEE ALSO

247       curses(3X), terminfo(5).
248

AUTHORS

250       Thomas E. Dickey
251       extended terminfo format for ncurses 5.0
252       hashed database support for ncurses 5.6
253       extended number support for ncurses 6.1
254
255       Eric S. Raymond
256       documented legacy terminfo format, e.g., from pcurses.
257
258
259
260                                                                       term(5)
Impressum