Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
| 2 | <!-- |
| 3 | **************************************************************************** |
| 4 | * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. * |
| 5 | * * |
| 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: * |
| 13 | * * |
| 14 | * The above copyright notice and this permission notice shall be included * |
| 15 | * in all copies or substantial portions of the Software. * |
| 16 | * * |
| 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. * |
| 24 | * * |
| 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 * |
| 28 | * authorization. * |
| 29 | **************************************************************************** |
| 30 | * @Id: term.5,v 1.19 2006/12/24 18:12:38 tom Exp @ |
| 31 | --> |
| 32 | <HTML> |
| 33 | <HEAD> |
| 34 | <TITLE>term 5</TITLE> |
| 35 | <link rev=made href="mailto:bug-ncurses@gnu.org"> |
| 36 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 37 | </HEAD> |
| 38 | <BODY> |
| 39 | <H1>term 5</H1> |
| 40 | <HR> |
| 41 | <PRE> |
| 42 | <!-- Manpage converted by man2html 3.0.1 --> |
| 43 | <STRONG><A HREF="term.5.html">term(5)</A></STRONG> <STRONG><A HREF="term.5.html">term(5)</A></STRONG> |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | </PRE> |
| 49 | <H2>NAME</H2><PRE> |
| 50 | term - format of compiled term file. |
| 51 | |
| 52 | |
| 53 | </PRE> |
| 54 | <H2>SYNOPSIS</H2><PRE> |
| 55 | <STRONG>term</STRONG> |
| 56 | |
| 57 | |
| 58 | </PRE> |
| 59 | <H2>DESCRIPTION</H2><PRE> |
| 60 | <STRONG>STORAGE</STRONG> <STRONG>LOCATION</STRONG> |
| 61 | Compiled terminfo descriptions are placed under the direc- |
| 62 | tory <STRONG>/usr/share/terminfo</STRONG>. Two configurations are sup- |
| 63 | ported (when building the ncurses libraries): |
| 64 | |
| 65 | <STRONG>directory</STRONG> <STRONG>tree</STRONG> |
| 66 | A two-level scheme is used to avoid a linear search |
| 67 | of a huge UNIX system directory: <STRONG>/usr/share/ter-</STRONG> |
| 68 | <STRONG>minfo/c/name</STRONG> where <EM>name</EM> is the name of the terminal, |
| 69 | and <EM>c</EM> is the first character of <EM>name</EM>. Thus, <EM>act4</EM> can |
| 70 | be found in the file <STRONG>/usr/share/terminfo/a/act4</STRONG>. |
| 71 | Synonyms for the same terminal are implemented by |
| 72 | multiple links to the same compiled file. |
| 73 | |
| 74 | <STRONG>hashed</STRONG> <STRONG>database</STRONG> |
| 75 | Using Berkeley database, two types of records are |
| 76 | stored: the terminfo data in the same format as |
| 77 | stored in a directory tree with the terminfo's pri- |
| 78 | mary name as a key, and records containing only |
| 79 | aliases pointing to the primary name. |
| 80 | |
| 81 | If built to write hashed databases, ncurses can still |
| 82 | read terminfo databases organized as a directory |
| 83 | tree, but cannot write entries into the directory |
| 84 | tree. It can write (or rewrite) entries in the |
| 85 | hashed database. |
| 86 | |
| 87 | ncurses distinguishes the two cases in the TERMINFO |
| 88 | and TERMINFO_DIRS environment variable by assuming a |
| 89 | directory tree for entries that correspond to an |
| 90 | existing directory, and hashed database otherwise. |
| 91 | |
| 92 | <STRONG>STORAGE</STRONG> <STRONG>FORMAT</STRONG> |
| 93 | The format has been chosen so that it will be the same on |
| 94 | all hardware. An 8 or more bit byte is assumed, but no |
| 95 | assumptions about byte ordering or sign extension are |
| 96 | made. |
| 97 | |
| 98 | The compiled file is created with the <STRONG>tic</STRONG> program, and |
| 99 | read by the routine <EM>setupterm</EM>. The file is divided into |
| 100 | six parts: the header, terminal names, boolean flags, num- |
| 101 | bers, strings, and string table. |
| 102 | |
| 103 | The header section begins the file. This section contains |
| 104 | six short integers in the format described below. These |
| 105 | integers are |
| 106 | |
| 107 | (1) the magic number (octal 0432); |
| 108 | |
| 109 | (2) the size, in bytes, of the names section; |
| 110 | |
| 111 | (3) the number of bytes in the boolean section; |
| 112 | |
| 113 | (4) the number of short integers in the numbers sec- |
| 114 | tion; |
| 115 | |
| 116 | (5) the number of offsets (short integers) in the |
| 117 | strings section; |
| 118 | |
| 119 | (6) the size, in bytes, of the string table. |
| 120 | |
| 121 | Short integers are stored in two 8-bit bytes. The first |
| 122 | byte contains the least significant 8 bits of the value, |
| 123 | and the second byte contains the most significant 8 bits. |
| 124 | (Thus, the value represented is 256*second+first.) The |
| 125 | value -1 is represented by the two bytes 0377, 0377; other |
| 126 | negative values are illegal. This value generally means |
| 127 | that the corresponding capability is missing from this |
| 128 | terminal. Note that this format corresponds to the hard- |
| 129 | ware of the VAX and PDP-11 (that is, little-endian |
| 130 | machines). Machines where this does not correspond to the |
| 131 | hardware must read the integers as two bytes and compute |
| 132 | the little-endian value. |
| 133 | |
| 134 | The terminal names section comes next. It contains the |
| 135 | first line of the terminfo description, listing the vari- |
| 136 | ous names for the terminal, separated by the `|' charac- |
| 137 | ter. The section is terminated with an ASCII NUL charac- |
| 138 | ter. |
| 139 | |
| 140 | The boolean flags have one byte for each flag. This byte |
| 141 | is either 0 or 1 as the flag is present or absent. The |
| 142 | capabilities are in the same order as the file <term.h>. |
| 143 | |
| 144 | Between the boolean section and the number section, a null |
| 145 | byte will be inserted, if necessary, to ensure that the |
| 146 | number section begins on an even byte (this is a relic of |
| 147 | the PDP-11's word-addressed architecture, originally |
| 148 | designed in to avoid IOT traps induced by addressing a |
| 149 | word on an odd byte boundary). All short integers are |
| 150 | aligned on a short word boundary. |
| 151 | |
| 152 | The numbers section is similar to the flags section. Each |
| 153 | capability takes up two bytes, and is stored as a little- |
| 154 | endian short integer. If the value represented is -1, the |
| 155 | capability is taken to be missing. |
| 156 | |
| 157 | The strings section is also similar. Each capability is |
| 158 | stored as a short integer, in the format above. A value |
| 159 | of -1 means the capability is missing. Otherwise, the |
| 160 | value is taken as an offset from the beginning of the |
| 161 | string table. Special characters in ^X or \c notation are |
| 162 | stored in their interpreted form, not the printing repre- |
| 163 | sentation. Padding information $<nn> and parameter infor- |
| 164 | mation %x are stored intact in uninterpreted form. |
| 165 | |
| 166 | The final section is the string table. It contains all |
| 167 | the values of string capabilities referenced in the string |
| 168 | section. Each string is null terminated. |
| 169 | |
| 170 | <STRONG>EXTENDED</STRONG> <STRONG>STORAGE</STRONG> <STRONG>FORMAT</STRONG> |
| 171 | The previous section describes the conventional terminfo |
| 172 | binary format. With some minor variations of the offsets |
| 173 | (see PORTABILITY), the same binary format is used in all |
| 174 | modern UNIX systems. Each system uses a predefined set of |
| 175 | boolean, number or string capabilities. |
| 176 | |
| 177 | The ncurses libraries and applications support extended |
| 178 | terminfo binary format, allowing users to define capabili- |
| 179 | ties which are loaded at runtime. This extension is made |
| 180 | possible by using the fact that the other implementations |
| 181 | stop reading the terminfo data when they have reached the |
| 182 | end of the size given in the header. ncurses checks the |
| 183 | size, and if it exceeds that due to the predefined data, |
| 184 | continues to parse according to its own scheme. |
| 185 | |
| 186 | First, it reads the extended header (5 short integers): |
| 187 | |
| 188 | (1) count of extended boolean capabilities |
| 189 | |
| 190 | (2) count of extended numeric capabilities |
| 191 | |
| 192 | (3) count of extended string capabilities |
| 193 | |
| 194 | (4) size of the extended string table in bytes. |
| 195 | |
| 196 | (5) last offset of the extended string table in |
| 197 | bytes. |
| 198 | |
| 199 | Using the counts and sizes, ncurses allocates arrays and |
| 200 | reads data for the extended capabilties in the same order |
| 201 | as the header information. |
| 202 | |
| 203 | The extended string table contains values for string capa- |
| 204 | bilities. After the end of these values, it contains the |
| 205 | names for each of the extended capabilities in order, |
| 206 | e.g., booleans, then numbers and finally strings. |
| 207 | |
| 208 | |
| 209 | </PRE> |
| 210 | <H2>PORTABILITY</H2><PRE> |
| 211 | Note that it is possible for <EM>setupterm</EM> to expect a differ- |
| 212 | ent set of capabilities than are actually present in the |
| 213 | file. Either the database may have been updated since |
| 214 | <EM>setupterm</EM> has been recompiled (resulting in extra unrecog- |
| 215 | nized entries in the file) or the program may have been |
| 216 | recompiled more recently than the database was updated |
| 217 | (resulting in missing entries). The routine <EM>setupterm</EM> |
| 218 | must be prepared for both possibilities - this is why the |
| 219 | numbers and sizes are included. Also, new capabilities |
| 220 | must always be added at the end of the lists of boolean, |
| 221 | number, and string capabilities. |
| 222 | |
| 223 | Despite the consistent use of little-endian for numbers |
| 224 | and the otherwise self-describing format, it is not wise |
| 225 | to count on portability of binary terminfo entries between |
| 226 | commercial UNIX versions. The problem is that there are |
| 227 | at least three versions of terminfo (under HP-UX, AIX, and |
| 228 | OSF/1) which diverged from System V terminfo after SVr1, |
| 229 | and have added extension capabilities to the string table |
| 230 | that (in the binary format) collide with System V and XSI |
| 231 | Curses extensions. See <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG> for detailed discus- |
| 232 | sion of terminfo source compatibility issues. |
| 233 | |
| 234 | |
| 235 | </PRE> |
| 236 | <H2>EXAMPLE</H2><PRE> |
| 237 | As an example, here is a hex dump of the description for |
| 238 | the Lear-Siegler ADM-3, a popular though rather stupid |
| 239 | early terminal: |
| 240 | |
| 241 | adm3a|lsi adm3a, |
| 242 | am, |
| 243 | cols#80, lines#24, |
| 244 | bel=^G, clear= 32$<1>, cr=^M, cub1=^H, cud1=^J, |
| 245 | cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, |
| 246 | home=^^, ind=^J, |
| 247 | |
| 248 | 0000 1a 01 10 00 02 00 03 00 82 00 31 00 61 64 6d 33 ........ ..1.adm3 |
| 249 | 0010 61 7c 6c 73 69 20 61 64 6d 33 61 00 00 01 50 00 a|lsi ad m3a...P. |
| 250 | 0020 ff ff 18 00 ff ff 00 00 02 00 ff ff ff ff 04 00 ........ ........ |
| 251 | 0030 ff ff ff ff ff ff ff ff 0a 00 25 00 27 00 ff ff ........ ..%.'... |
| 252 | 0040 29 00 ff ff ff ff 2b 00 ff ff 2d 00 ff ff ff ff ).....+. ..-..... |
| 253 | 0050 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 254 | 0060 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 255 | 0070 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 256 | 0080 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 257 | 0090 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 258 | 00a0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 259 | 00b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 260 | 00c0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 261 | 00d0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 262 | 00e0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 263 | 00f0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 264 | 0100 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 265 | 0110 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ |
| 266 | 0120 ff ff ff ff ff ff 2f 00 07 00 0d 00 1a 24 3c 31 ....../. .....$<1 |
| 267 | 0130 3e 00 1b 3d 25 70 31 25 7b 33 32 7d 25 2b 25 63 >..=%p1% {32}%+%c |
| 268 | 0140 25 70 32 25 7b 33 32 7d 25 2b 25 63 00 0a 00 1e %p2%{32} %+%c.... |
| 269 | 0150 00 08 00 0c 00 0b 00 0a 00 ........ . |
| 270 | |
| 271 | |
| 272 | |
| 273 | </PRE> |
| 274 | <H2>LIMITS</H2><PRE> |
| 275 | Some limitations: total compiled entries cannot exceed |
| 276 | 4096 bytes. The name field cannot exceed 128 bytes. |
| 277 | |
| 278 | |
| 279 | </PRE> |
| 280 | <H2>FILES</H2><PRE> |
| 281 | /usr/share/terminfo/*/* compiled terminal capability data |
| 282 | base |
| 283 | |
| 284 | |
| 285 | </PRE> |
| 286 | <H2>SEE ALSO</H2><PRE> |
| 287 | <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>. |
| 288 | |
| 289 | |
| 290 | </PRE> |
| 291 | <H2>AUTHORS</H2><PRE> |
| 292 | Thomas E. Dickey |
| 293 | extended terminfo format for ncurses 5.0 |
| 294 | hashed database support for ncurses 5.6 |
| 295 | |
| 296 | Eric S. Raymond |
| 297 | |
| 298 | |
| 299 | |
| 300 | <STRONG><A HREF="term.5.html">term(5)</A></STRONG> |
| 301 | </PRE> |
| 302 | <HR> |
| 303 | <ADDRESS> |
| 304 | Man(1) output converted with |
| 305 | <a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a> |
| 306 | </ADDRESS> |
| 307 | </BODY> |
| 308 | </HTML> |