- Using Berkeley database, two types of records are
- stored: the terminfo data in the same format as
- stored in a directory tree with the terminfo's pri-
- mary name as a key, and records containing only
- aliases pointing to the primary name.
-
- If built to write hashed databases, ncurses can still
- read terminfo databases organized as a directory
- tree, but cannot write entries into the directory
- tree. It can write (or rewrite) entries in the
- hashed database.
-
- ncurses distinguishes the two cases in the TERMINFO
- and TERMINFO_DIRS environment variable by assuming a
- directory tree for entries that correspond to an
- existing directory, and hashed database otherwise.
-
- <STRONG>STORAGE</STRONG> <STRONG>FORMAT</STRONG>
- The format has been chosen so that it will be the same on
- all hardware. An 8 or more bit byte is assumed, but no
- assumptions about byte ordering or sign extension are
- made.
-
- The compiled file is created with the <STRONG>tic</STRONG> program, and
- read by the routine <EM>setupterm</EM>. The file is divided into
- six parts: the header, terminal names, boolean flags, num-
- bers, strings, and string table.
-
- The header section begins the file. This section contains
- six short integers in the format described below. These
- integers are
-
- (1) the magic number (octal 0432);
-
- (2) the size, in bytes, of the names section;
-
- (3) the number of bytes in the boolean section;
-
- (4) the number of short integers in the numbers sec-
- tion;
-
- (5) the number of offsets (short integers) in the
- strings section;
-
- (6) the size, in bytes, of the string table.
-
- Short integers are stored in two 8-bit bytes. The first
- byte contains the least significant 8 bits of the value,
- and the second byte contains the most significant 8 bits.
- (Thus, the value represented is 256*second+first.) The
- value -1 is represented by the two bytes 0377, 0377; other
- negative values are illegal. This value generally means
- that the corresponding capability is missing from this
- terminal. Note that this format corresponds to the hard-
- ware of the VAX and PDP-11 (that is, little-endian
- machines). Machines where this does not correspond to the
- hardware must read the integers as two bytes and compute
- the little-endian value.
-
- The terminal names section comes next. It contains the
- first line of the terminfo description, listing the vari-
- ous names for the terminal, separated by the `|' charac-
- ter. The section is terminated with an ASCII NUL charac-
- ter.
-
- The boolean flags have one byte for each flag. This byte
- is either 0 or 1 as the flag is present or absent. The
- capabilities are in the same order as the file <term.h>.
-
- Between the boolean section and the number section, a null
- byte will be inserted, if necessary, to ensure that the
- number section begins on an even byte (this is a relic of
- the PDP-11's word-addressed architecture, originally
- designed in to avoid IOT traps induced by addressing a
- word on an odd byte boundary). All short integers are
- aligned on a short word boundary.
-
- The numbers section is similar to the flags section. Each
- capability takes up two bytes, and is stored as a little-
- endian short integer. If the value represented is -1, the
- capability is taken to be missing.
-
- The strings section is also similar. Each capability is
- stored as a short integer, in the format above. A value
- of -1 means the capability is missing. Otherwise, the
- value is taken as an offset from the beginning of the
- string table. Special characters in ^X or \c notation are
- stored in their interpreted form, not the printing repre-
- sentation. Padding information $<nn> and parameter infor-
- mation %x are stored intact in uninterpreted form.
-
- The final section is the string table. It contains all
- the values of string capabilities referenced in the string
- section. Each string is null terminated.
-
- <STRONG>EXTENDED</STRONG> <STRONG>STORAGE</STRONG> <STRONG>FORMAT</STRONG>
- The previous section describes the conventional terminfo
- binary format. With some minor variations of the offsets
- (see PORTABILITY), the same binary format is used in all
- modern UNIX systems. Each system uses a predefined set of
- boolean, number or string capabilities.
-
- The ncurses libraries and applications support extended
- terminfo binary format, allowing users to define capabili-
- ties which are loaded at runtime. This extension is made
- possible by using the fact that the other implementations
- stop reading the terminfo data when they have reached the
- end of the size given in the header. ncurses checks the
- size, and if it exceeds that due to the predefined data,
- continues to parse according to its own scheme.
+ Using Berkeley database, two types of records are stored: the
+ terminfo data in the same format as stored in a directory tree
+ with the terminfo's primary name as a key, and records containing
+ only aliases pointing to the primary name.
+
+ If built to write hashed databases, <STRONG>ncurses</STRONG> can still read
+ terminfo databases organized as a directory tree, but cannot write
+ entries into the directory tree. It can write (or rewrite)
+ entries in the hashed database.
+
+ <STRONG>ncurses</STRONG> distinguishes the two cases in the TERMINFO and
+ TERMINFO_DIRS environment variable by assuming a directory tree
+ for entries that correspond to an existing directory, and hashed
+ database otherwise.
+
+
+</PRE><H3><a name="h3-LEGACY-STORAGE-FORMAT">LEGACY STORAGE FORMAT</a></H3><PRE>
+ The format has been chosen so that it will be the same on all hardware.
+ An 8 or more bit byte is assumed, but no assumptions about byte
+ ordering or sign extension are made.
+
+ The compiled file is created with the <STRONG>tic</STRONG> program, and read by the
+ routine <STRONG><A HREF="curs_terminfo.3x.html">setupterm(3x)</A></STRONG>. The file is divided into six parts:
+
+ a) <EM>header</EM>,
+
+ b) <EM>terminal</EM> <EM>names</EM>,
+
+ c) <EM>boolean</EM> <EM>flags</EM>,
+
+ d) <EM>numbers</EM>,
+
+ e) <EM>strings</EM>, and
+
+ f) <EM>string</EM> <EM>table</EM>.
+
+ The <EM>header</EM> section begins the file. This section contains six short
+ integers in the format described below. These integers are
+
+ (1) the <EM>magic</EM> <EM>number</EM> (octal 0432);
+
+ (2) the size, in bytes, of the <EM>terminal</EM> <EM>names</EM> section;
+
+ (3) the number of bytes in the <EM>boolean</EM> <EM>flags</EM> section;
+
+ (4) the number of short integers in the <EM>numbers</EM> section;
+
+ (5) the number of offsets (short integers) in the <EM>strings</EM> section;
+
+ (6) the size, in bytes, of the <EM>string</EM> <EM>table</EM>.
+
+ The capabilities in the <EM>boolean</EM> <EM>flags</EM>, <EM>numbers</EM>, and <EM>strings</EM> sections
+ are in the same order as the file <term.h>.
+
+ Short integers are signed, in the range -32768 to 32767. They are
+ stored as two 8-bit bytes. The first byte contains the least
+ significant 8 bits of the value, and the second byte contains the most
+ significant 8 bits. (Thus, the value represented is 256*second+first.)
+ This format corresponds to the hardware of the VAX and PDP-11 (that is,
+ little-endian machines). Machines where this does not correspond to
+ the hardware must read the integers as two bytes and compute the
+ little-endian value.
+
+ Numbers in a terminal description, whether they are entries in the
+ <EM>numbers</EM> or <EM>strings</EM> table, are positive integers. Boolean flags are
+ treated as positive one-byte integers. In each case, those positive
+ integers represent a terminal capability. The terminal compiler tic
+ uses negative integers to handle the cases where a capability is not
+ available:
+
+ <STRONG>o</STRONG> If a capability is absent from this terminal, tic stores a -1 in
+ the corresponding table.
+
+ The integer value -1 is represented by two bytes 0377, 0377.
+ Absent boolean values are represented by the byte 0 (false).
+
+ <STRONG>o</STRONG> If a capability has been canceled from this terminal, tic stores a
+ -2 in the corresponding table.
+
+ The integer value -2 is represented by two bytes 0377, 0376.
+ The boolean value -2 is represented by the byte 0376.
+
+ <STRONG>o</STRONG> Other negative values are illegal.
+
+ The <EM>terminal</EM> <EM>names</EM> section comes after the <EM>header</EM>. It contains the
+ first line of the terminfo description, listing the various names for
+ the terminal, separated by the "|" character. The <EM>terminal</EM> <EM>names</EM>
+ section is terminated with an ASCII NUL character.
+
+ The <EM>boolean</EM> <EM>flags</EM> section has one byte for each flag. Boolean
+ capabilities are either 1 or 0 (true or false) according to whether the
+ terminal supports the given capability or not.
+
+ Between the <EM>boolean</EM> <EM>flags</EM> section and the <EM>number</EM> section, a null byte
+ will be inserted, if necessary, to ensure that the <EM>number</EM> section
+ begins on an even byte This is a relic of the PDP-11's word-addressed
+ architecture, originally designed to avoid traps induced by addressing
+ a word on an odd byte boundary. All short integers are aligned on a
+ short word boundary.
+
+ The <EM>numbers</EM> section is similar to the <EM>boolean</EM> <EM>flags</EM> section. Each
+ capability takes up two bytes, and is stored as a little-endian short
+ integer.
+
+ The <EM>strings</EM> section is also similar. Each capability is stored as a
+ short integer. The capability value is an index into the <EM>string</EM> <EM>table</EM>.
+
+ The <EM>string</EM> <EM>table</EM> is the last section. It contains all of the values of
+ string capabilities referenced in the <EM>strings</EM> section. Each string is
+ null-terminated. Special characters in ^X or \c notation are stored in
+ their interpreted form, not the printing representation. Padding
+ information $<nn> and parameter information %x are stored intact in
+ uninterpreted form.
+
+
+</PRE><H3><a name="h3-EXTENDED-STORAGE-FORMAT">EXTENDED STORAGE FORMAT</a></H3><PRE>
+ The previous section describes the conventional terminfo binary format.
+ With some minor variations of the offsets (see PORTABILITY), the same
+ binary format is used in all modern UNIX systems. Each system uses a
+ predefined set of boolean, number or string capabilities.
+
+ The <STRONG>ncurses</STRONG> libraries and applications support extended terminfo binary
+ format, allowing users to define capabilities which are loaded at
+ runtime. This extension is made possible by using the fact that the
+ other implementations stop reading the terminfo data when they have
+ reached the end of the size given in the header. <STRONG>ncurses</STRONG> checks the
+ size, and if it exceeds that due to the predefined data, continues to
+ parse according to its own scheme.