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)  count of the items in extended string table
131
132            (5)  size of the extended string table in bytes
133
134       The count- and size-values for the extended string  table  include  the
135       extended capability names as well as extended capability values.
136
137       Using the counts and sizes, ncurses allocates arrays and reads data for
138       the extended capabilities in the same order as the header information.
139
140       The extended string table  contains  values  for  string  capabilities.
141       After  the  end  of these values, it contains the names for each of the
142       extended capabilities  in  order,  e.g.,  booleans,  then  numbers  and
143       finally strings.
144
145       Applications  which  manipulate  terminal  data can use the definitions
146       described in term_variables(3X) which  associate  the  long  capability
147       names with members of a TERMTYPE structure.
148
149   EXTENDED NUMBER FORMAT
150       On occasion, 16-bit signed integers are not large enough.  With ncurses
151       6.1, a new format was introduced by making a few changes to the  legacy
152       format:
153
154       ·   a different magic number (octal 01036)
155
156       ·   changing  the type for the number array from signed 16-bit integers
157           to signed 32-bit integers.
158
159       To maintain compatibility, the library presents the  same  data  struc‐
160       tures to direct users of the TERMTYPE structure as in previous formats.
161       However, that cannot provide callers with the  extended  numbers.   The
162       library  uses  a similar but hidden data structure TERMTYPE2 to provide
163       data for the terminfo functions.
164

PORTABILITY

166   setupterm
167       Note that it is possible for setupterm to expect  a  different  set  of
168       capabilities  than  are actually present in the file.  Either the data‐
169       base may have been updated since setupterm has been recompiled (result‐
170       ing  in extra unrecognized entries in the file) or the program may have
171       been recompiled more recently than the database was updated  (resulting
172       in  missing  entries).  The routine setupterm must be prepared for both
173       possibilities - this is why the numbers and sizes are included.   Also,
174       new  capabilities must always be added at the end of the lists of bool‐
175       ean, number, and string capabilities.
176
177   Binary format
178       X/Open Curses does not specify a  format  for  the  terminfo  database.
179       UNIX  System  V  curses  used a directory-tree of binary files, one per
180       terminal description.
181
182       Despite the consistent use of little-endian for numbers and the  other‐
183       wise  self-describing format, it is not wise to count on portability of
184       binary terminfo entries between commercial UNIX versions.  The  problem
185       is  that  there  are  at least three versions of terminfo (under HP-UX,
186       AIX, and OSF/1) which diverged from System V terminfo after  SVr1,  and
187       have  added  extension  capabilities  to  the string table that (in the
188       binary format) collide with System V and XSI  Curses  extensions.   See
189       terminfo(5)  for  detailed  discussion of terminfo source compatibility
190       issues.
191
192       This implementation is by default compatible with the  binary  terminfo
193       format  used by Solaris curses, except in a few less-used details where
194       it was found that the latter did not match X/Open Curses.   The  format
195       used by the other Unix versions can be matched by building ncurses with
196       different configuration options.
197
198   Magic codes
199       The magic number in a binary terminfo file is the  first  16-bits  (two
200       bytes).   Besides making it more reliable for the library to check that
201       a file is terminfo, utilities such as file also use that to  tell  what
202       the  file-format is.  System V defined more than one magic number, with
203       0433, 0435 as screen-dumps (see scr_dump(5)).  This implementation uses
204       01036  as  a  continuation of that sequence, but with a different high-
205       order byte to avoid confusion.
206
207   The TERMTYPE structure
208       Direct access to the TERMTYPE structure is provided for legacy applica‐
209       tions.   Portable  applications  should  use  the tigetflag and related
210       functions described in curs_terminfo(3X) for reading terminal capabili‐
211       ties.
212
213   Mixed-case terminal names
214       A  small  number  of  terminal descriptions use uppercase characters in
215       their names.  If  the  underlying  filesystem  ignores  the  difference
216       between  uppercase and lowercase, ncurses represents the “first charac‐
217       ter” of the terminal name used as the intermediate level of a directory
218       tree in (two-character) hexadecimal form.
219

EXAMPLE

221       As an example, here is a description for the Lear-Siegler ADM-3, a pop‐
222       ular though rather stupid early terminal:
223
224           adm3a|lsi adm3a,
225                   am,
226                   cols#80, lines#24,
227                   bel=^G, clear= 32$<1>, cr=^M, cub1=^H, cud1=^J,
228                   cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
229                   home=^^, ind=^J,
230
231
232       and a hexadecimal dump of the compiled terminal description:
233
234           0000  1a 01 10 00 02 00 03 00  82 00 31 00 61 64 6d 33  ........ ..1.adm3
235           0010  61 7c 6c 73 69 20 61 64  6d 33 61 00 00 01 50 00  a|lsi ad m3a...P.
236           0020  ff ff 18 00 ff ff 00 00  02 00 ff ff ff ff 04 00  ........ ........
237           0030  ff ff ff ff ff ff ff ff  0a 00 25 00 27 00 ff ff  ........ ..%.'...
238           0040  29 00 ff ff ff ff 2b 00  ff ff 2d 00 ff ff ff ff  ).....+. ..-.....
239           0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
240           0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
241           0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
242           0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
243           0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
244           00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
245           00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
246           00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
247           00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
248           00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
249           00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
250           0100  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
251           0110  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
252           0120  ff ff ff ff ff ff 2f 00  07 00 0d 00 1a 24 3c 31  ....../. .....$<1
253           0130  3e 00 1b 3d 25 70 31 25  7b 33 32 7d 25 2b 25 63  >..=%p1% {32}%+%c
254           0140  25 70 32 25 7b 33 32 7d  25 2b 25 63 00 0a 00 1e  %p2%{32} %+%c....
255           0150  00 08 00 0c 00 0b 00 0a  00                       ........ .
256
257

LIMITS

259       Some limitations:
260
261       ·   total compiled entries cannot exceed 4096 bytes in the legacy  for‐
262           mat.
263
264       ·   total  compiled  entries  cannot exceed 32768 bytes in the extended
265           format.
266
267       ·   the name field cannot exceed 128 bytes.
268

FILES

270       /usr/share/terminfo/*/*  compiled terminal capability data base
271

SEE ALSO

273       curses(3X), terminfo(5).
274

AUTHORS

276       Thomas E. Dickey
277       extended terminfo format for ncurses 5.0
278       hashed database support for ncurses 5.6
279       extended number support for ncurses 6.1
280
281       Eric S. Raymond
282       documented legacy terminfo format, e.g., from pcurses.
283
284
285
286                                                                       term(5)
Impressum