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   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.  The file is divided into six parts: the header, termi‐
48       nal 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 capabilties 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

PORTABILITY

143       Note that it is possible for setupterm to expect  a  different  set  of
144       capabilities  than  are actually present in the file.  Either the data‐
145       base may have been updated since setupterm has been recompiled (result‐
146       ing  in extra unrecognized entries in the file) or the program may have
147       been recompiled more recently than the database was updated  (resulting
148       in  missing  entries).  The routine setupterm must be prepared for both
149       possibilities - this is why the numbers and sizes are included.   Also,
150       new  capabilities must always be added at the end of the lists of bool‐
151       ean, number, and string capabilities.
152
153       Despite the consistent use of little-endian for numbers and the  other‐
154       wise  self-describing format, it is not wise to count on portability of
155       binary terminfo entries between commercial UNIX versions.  The  problem
156       is  that  there  are  at least three versions of terminfo (under HP-UX,
157       AIX, and OSF/1) which diverged from System V terminfo after  SVr1,  and
158       have  added  extension  capabilities  to  the string table that (in the
159       binary format) collide with System V and XSI  Curses  extensions.   See
160       terminfo(5)  for  detailed  discussion of terminfo source compatibility
161       issues.
162

EXAMPLE

164       As an example, here is a hex dump of  the  description  for  the  Lear-
165       Siegler ADM-3, a popular though rather stupid early terminal:
166
167       adm3a|lsi adm3a,
168               am,
169               cols#80, lines#24,
170               bel=^G, clear= 32$<1>, cr=^M, cub1=^H, cud1=^J,
171               cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K,
172               home=^^, ind=^J,
173
174       0000  1a 01 10 00 02 00 03 00  82 00 31 00 61 64 6d 33  ........ ..1.adm3
175       0010  61 7c 6c 73 69 20 61 64  6d 33 61 00 00 01 50 00  a|lsi ad m3a...P.
176       0020  ff ff 18 00 ff ff 00 00  02 00 ff ff ff ff 04 00  ........ ........
177       0030  ff ff ff ff ff ff ff ff  0a 00 25 00 27 00 ff ff  ........ ..%.'...
178       0040  29 00 ff ff ff ff 2b 00  ff ff 2d 00 ff ff ff ff  ).....+. ..-.....
179       0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
180       0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
181       0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
182       0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
183       0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
184       00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
185       00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
186       00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
187       00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
188       00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
189       00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
190       0100  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
191       0110  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  ........ ........
192       0120  ff ff ff ff ff ff 2f 00  07 00 0d 00 1a 24 3c 31  ....../. .....$<1
193       0130  3e 00 1b 3d 25 70 31 25  7b 33 32 7d 25 2b 25 63  >..=%p1% {32}%+%c
194       0140  25 70 32 25 7b 33 32 7d  25 2b 25 63 00 0a 00 1e  %p2%{32} %+%c....
195       0150  00 08 00 0c 00 0b 00 0a  00                       ........ .
196
197

LIMITS

199       Some limitations: total compiled entries cannot exceed 4096 bytes.  The
200       name field cannot exceed 128 bytes.
201

FILES

203       /usr/share/terminfo/*/*  compiled terminal capability data base
204

SEE ALSO

206       curses(3X), terminfo(5).
207

AUTHORS

209       Thomas E. Dickey
210       extended terminfo format for ncurses 5.0
211       hashed database support for ncurses 5.6
212
213       Eric S. Raymond
214
215
216
217                                                                       term(5)
Impressum