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

EXAMPLE

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

LIMITS

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

FILES

247       /usr/share/terminfo/*/*  compiled terminal capability data base
248

SEE ALSO

250       curses(3X), terminfo(5).
251

AUTHORS

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