2 .\"***************************************************************************
3 .\" Copyright 2018-2023,2024 Thomas E. Dickey *
4 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
6 .\" Permission is hereby granted, free of charge, to any person obtaining a *
7 .\" copy of this software and associated documentation files (the *
8 .\" "Software"), to deal in the Software without restriction, including *
9 .\" without limitation the rights to use, copy, modify, merge, publish, *
10 .\" distribute, distribute with modifications, sublicense, and/or sell *
11 .\" copies of the Software, and to permit persons to whom the Software is *
12 .\" furnished to do so, subject to the following conditions: *
14 .\" The above copyright notice and this permission notice shall be included *
15 .\" in all copies or substantial portions of the Software. *
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 .\" Except as contained in this notice, the name(s) of the above copyright *
26 .\" holders shall not be used in advertising or otherwise to promote the *
27 .\" sale, use or other dealings in this Software without prior written *
29 .\"***************************************************************************
31 .\" $Id: term.5,v 1.78 2024/05/11 20:39:53 tom Exp $
32 .TH term 5 2024-05-11 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "File formats"
60 compiled \fI\%term\%info\fP terminal description
62 \fB\%@TIC@\fP(1) compiles a
64 terminal type description,
65 and \fB\%setupterm\fP(3X) reads it.
66 A compiled description may be stored in a file or in a database of,
68 many such descriptions.
70 a compiled description may be in one of two formats:
71 one similar to that used by System\ V,
73 extensible format employed exclusively by
75 .SS "Storage Location"
77 .I \%term\%info descriptions are placed
80 One of two configurations is selected
86 A two-level scheme is used to avoid a linear search
87 of a huge Unix system directory:
88 .IR \%@TERMINFO@/ c / name
91 is the name of the terminal,
94 is the first character of
97 the compiled description of terminal type \*(``act4\*(''
99 .IR \%@TERMINFO@/a/act4 .
100 Synonyms for the same terminal are implemented by multiple
101 links to the same compiled file.
104 Using the Berkeley database API,
105 two types of records are stored:
108 data in the same format as that stored in a directory tree with
109 the terminal's primary type name as a key,
110 and records containing only aliases pointing to the primary name.
112 If built to write hashed databases,
116 databases organized as a
118 but cannot write entries into the directory tree.
121 entries in the hashed database.
124 distinguishes the two cases in the
128 environment variable by assuming a directory tree for entries that
129 correspond to an existing directory,
130 and a hashed database otherwise.
131 .SS "Legacy Storage Format"
132 The format has been chosen so that it will be the same on all hardware.
133 A byte of at least eight bits' width is assumed,
134 but no assumptions about bit ordering
135 or sign extension are made.
137 The file is divided into six parts:
142 .IR "terminal names" ,
144 .IR "Boolean flags" ,
155 The \fIheader\fP section begins the file.
156 This section contains six short integers in the format
161 (1) the \fImagic number\fP
166 of the \fIterminal names\fP section;
168 (3) the number of bytes in the \fIBoolean flags\fP section;
170 (4) the number of short integers in the \fInumbers\fP section;
172 (5) the number of offsets
174 in the \fIstrings\fP section;
178 of the \fIstring table\fP.
181 The capabilities in the
186 sections are in the same order as in the header file
189 Short integers are signed,
190 in the range \-32768 to 32767,
191 and stored in little-endian format.
193 Numbers in a terminal description,
194 whether they are entries in the \fInumbers\fP or \fIstrings\fP table,
195 are positive integers.
196 Boolean flags are treated as positive one-byte integers.
198 those positive integers represent a terminal capability.
199 The terminal compiler
201 uses negative integers to handle the cases where a capability is not
204 If a capability is absent from this terminal,
206 stores a \-1 in the corresponding table.
208 The integer value \-1 is represented by two bytes 0377,
211 Absent Boolean values are represented by the byte 0 (false).
213 If a capability has been canceled from this terminal,
215 stores a \-2 in the corresponding table.
217 The integer value \-2 is represented by two bytes 0377,
220 The Boolean value \-2 is represented by the byte 0376.
223 Other negative values are illegal.
225 The \fIterminal names\fP section comes after the \fIheader\fP.
226 It contains the first line of the
229 listing the various names for the terminal,
230 separated by the \*(``|\*('' character.
231 The \fIterminal names\fP section is terminated
232 with an \s-1ASCII NUL\s+1 character.
234 The \fIBoolean flags\fP section has one byte for each flag.
235 Boolean capabilities are either 1 or 0
237 according to whether the terminal supports the given capability or not.
239 Between the \fIBoolean flags\fP section and the \fInumber\fP section,
240 a null byte will be inserted,
242 to ensure that the \fInumber\fP section begins on an even byte
243 This is a relic of the PDP\-11's word-addressed architecture,
244 originally designed to avoid traps induced
245 by addressing a word on an odd byte boundary.
246 All short integers are aligned on a short word boundary.
248 The \fInumbers\fP section is similar to the \fIBoolean flags\fP section.
249 Each capability takes up two bytes,
250 and is stored as a little-endian short integer.
252 The \fIstrings\fP section is also similar.
253 Each capability is stored as a short integer.
254 The capability value is an index into the \fIstring table\fP.
256 The \fIstring table\fP is the last section.
257 It contains all of the values of string capabilities referenced in
258 the \fIstrings\fP section.
259 Each string is null-terminated.
260 Special characters in \*^X or \ec notation are stored in their
262 not the printing representation.
265 and parameter information
267 are stored intact in uninterpreted form.
268 .SS "Extended Storage Format"
269 The previous section describes the conventional
272 With some minor variations of the offsets
274 the same binary format is used in all modern Unix systems.
275 Each system uses a predefined set of Boolean,
276 number or string capabilities.
280 libraries and applications support extended
283 allowing users to define capabilities that are loaded at runtime.
284 This extension is made possible by using the fact that the other
285 implementations stop reading the
287 data when they reach the end of the size given in the header.
290 and if it exceeds that due to the predefined data,
291 continues to parse according to its own scheme.
294 it reads the extended header
299 count of extended Boolean capabilities
302 count of extended numeric capabilities
305 count of extended string capabilities
308 count of the items in extended string table
311 size of the extended string table in bytes
314 The count- and size-values for the extended string table
315 include the extended capability \fInames\fP as well as
316 extended capability \fIvalues\fP.
318 Using the counts and sizes,
320 allocates arrays and reads data for the extended capabilities in the
321 same order as the header information.
323 The extended string table contains values for string capabilities.
324 After the end of these values,
325 it contains the names for each of
326 the extended capabilities in order:
331 By storing terminal descriptions in this way,
333 is able to provide a database useful with legacy applications,
334 as well as providing data for applications that require more information
335 about a terminal type than was anticipated
337 See \fB\%user_caps\fP(5) for an overview of the way
339 uses this extended information.
341 Applications that manipulate terminal data can use the definitions
342 described in \fB\%term_variables\fP(3X) associating the long capability
343 names with members of a
347 .SS "Extended Number Format"
349 16-bit signed integers are not large enough.
351 6.1 introduced a new format
352 by making a few changes to the legacy format:
354 a different magic number
357 changing the type for the \fInumber\fP array from signed 16-bit integers
358 to signed 32-bit integers.
360 To maintain compatibility,
361 the library presents the same data structures
362 to direct users of the
364 structure as in previous formats.
366 that cannot provide callers with the extended numbers.
367 The library uses a similar but hidden data structure
369 to provide data for the
375 compiled terminal description database
378 Note that it is possible for
380 to expect a different set of capabilities
381 than are actually present in the file.
382 Either the database may have been updated since
385 (resulting in extra unrecognized entries in the file)
386 or the program may have been recompiled more recently
387 than the database was updated
388 (resulting in missing entries).
391 must be prepared for both possibilities \-
392 this is why the numbers and sizes are included.
394 new capabilities must always be added at the end of the lists
397 and string capabilities.
399 X/Open Curses does not specify a format for the
404 used a directory-tree of binary files,
405 one per terminal description.
407 Despite the consistent use of little-endian numbers and the otherwise
408 self-describing format,
409 it is not wise to count on portability of binary
411 entries between commercial Unix versions.
412 The problem is that there are at least three versions of
417 each of which diverged from System\ V
420 and added extension capabilities to the string table that
421 (in the binary format)
422 collide with System\ V and X/Open Curses extensions.
423 See \fB\%terminfo\fP(5) for detailed
426 source compatibility issues.
428 This implementation is by default compatible with the binary
430 format used by Solaris
432 except in a few less-used details
433 where it was found that the latter did not match X/Open Curses.
434 The format used by the other Unix versions
435 can be matched by building
437 with different configuration options.
439 The magic number in a binary
441 file is the first 16 bits
443 Besides making it more reliable for the library to check that a file is
445 utilities such as \fIfile\fP(1) also use that to tell what the
447 System\ V defined more than one magic number,
450 (see \fB\%scr_dump\fP(5)).
451 This implementation uses 01036 as a continuation of that sequence,
452 but with a different high-order byte to avoid confusion.
453 .SS "The \fITERMTYPE\fP Structure"
456 structure is provided for legacy applications.
457 Portable applications should use \fB\%tigetflag\fP(3X) and related
458 functions to read terminal capabilities.
459 .SS "Mixed-case Terminal Names"
460 A small number of terminal descriptions use uppercase characters in
462 If the underlying file system ignores the difference between
463 uppercase and lowercase,
465 represents the \*(``first character\*('' of the terminal name used as
466 the intermediate level of a directory tree in (two-character)
470 stores compiled terminal descriptions in three related formats,
471 described in the subsections
473 .BR "Legacy Storage Format" ,
476 .BR "Extended Storage Format" ,
479 .BR "Extended Number Format" .
481 The legacy storage format and the extended number format differ by
482 the types of numeric capability that they can store
484 16- versus 32-bit integers).
485 The extended storage format introduced by
487 5.0 adds data to either of these formats.
489 Some limitations apply:
491 total compiled entries cannot exceed 4096 bytes in the legacy format.
493 total compiled entries cannot exceed 32768 bytes in the extended format.
495 the name field cannot exceed 128 bytes.
497 Compiled entries are limited to 32768 bytes because offsets into the
498 \fIstrings table\fP use two-byte integers.
499 The legacy format could have supported 32768-byte entries,
500 but was limited to a virtual memory page's 4096 bytes.
504 description of the Lear-Siegler ADM-3,
505 a popular though rather stupid early terminal.
511 bel=\*^G, clear=\e032$<1>, cr=\*^M, cub1=\*^H, cud1=\*^J,
512 cuf1=\*^L, cup=\eE=%p1%{32}%+%c%p2%{32}%+%c, cuu1=\*^K,
513 home=\*^\*^, ind=\*^J,
516 A hexadecimal dump of its compiled terminal description
524 0000 1a 01 10 00 02 00 03 00 82 00 31 00 61 64 6d 33 ........ ..1.adm3
525 0010 61 7c 6c 73 69 20 61 64 6d 33 61 00 00 01 50 00 a|lsi ad m3a...P.
526 0020 ff ff 18 00 ff ff 00 00 02 00 ff ff ff ff 04 00 ........ ........
527 0030 ff ff ff ff ff ff ff ff 0a 00 25 00 27 00 ff ff ........ ..%.\*'...
528 0040 29 00 ff ff ff ff 2b 00 ff ff 2d 00 ff ff ff ff ).....+. ..\-.....
529 0050 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
530 0060 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
531 0070 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
532 0080 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
533 0090 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
534 00a0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
535 00b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
536 00c0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
537 00d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
538 00e0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
539 00f0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
540 0100 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
541 0110 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........
542 0120 ff ff ff ff ff ff 2f 00 07 00 0d 00 1a 24 3c 31 ....../. .....$<1
543 0130 3e 00 1b 3d 25 70 31 25 7b 33 32 7d 25 2b 25 63 >..=%p1% {32}%+%c
544 0140 25 70 32 25 7b 33 32 7d 25 2b 25 63 00 0a 00 1e %p2%{32} %+%c....
545 0150 00 08 00 0c 00 0b 00 0a 00 ........ .
558 hashed database support for
562 extended number support for
575 \fB\%curs_terminfo\fP(3X),