<s>
Terminfo	B-Device
is	O
a	O
library	B-Library
and	O
database	O
that	O
enables	O
programs	O
to	O
use	O
display	O
terminals	B-General_Concept
in	O
a	O
device-independent	O
manner	O
.	O
</s>
<s>
Mary	O
Ann	O
Horton	O
implemented	O
the	O
first	O
terminfo	B-Device
library	B-Library
in	O
1981	O
–	O
1982	O
as	O
an	O
improvement	O
over	O
termcap	B-Application
.	O
</s>
<s>
Terminfo	B-Device
was	O
included	O
with	O
UNIX	B-Operating_System
System	I-Operating_System
V	I-Operating_System
Release	O
2	O
and	O
soon	O
became	O
the	O
preferred	O
form	O
of	O
terminal	O
descriptions	O
in	O
System	B-Operating_System
V	I-Operating_System
,	O
rather	O
than	O
termcap	B-Application
(	O
which	O
BSD	O
continued	O
to	O
use	O
)	O
.	O
</s>
<s>
This	O
was	O
imitated	O
in	O
pcurses	O
in	O
1982	O
–	O
1984	O
by	O
Pavel	O
Curtis	O
,	O
and	O
was	O
available	O
on	O
other	O
UNIX	B-Application
implementations	O
,	O
adapting	O
or	O
incorporating	O
fixes	O
from	O
Mary	O
Horton	O
.	O
</s>
<s>
For	O
more	O
information	O
,	O
refer	O
to	O
the	O
posting	O
on	O
the	O
comp.sources.unix	O
newsgroup	O
from	O
December	O
1986	O
.	O
</s>
<s>
A	O
terminfo	B-Device
database	O
can	O
describe	O
the	O
capabilities	O
of	O
hundreds	O
of	O
different	O
display	O
terminals	B-General_Concept
.	O
</s>
<s>
Terminfo	B-Device
databases	O
consist	O
of	O
one	O
or	O
more	O
descriptions	O
of	O
terminals	B-General_Concept
.	O
</s>
<s>
The	O
canonical	O
name	O
or	O
aliases	O
are	O
the	O
keys	O
by	O
which	O
the	O
library	B-Library
searches	O
the	O
terminfo	B-Device
database	O
.	O
</s>
<s>
The	O
terminfo	B-Device
library	B-Library
has	O
predetermined	O
types	O
for	O
each	O
capability	O
name	O
.	O
</s>
<s>
Applications	O
which	O
use	O
terminfo	B-Device
know	O
the	O
types	O
for	O
the	O
respective	O
capabilities	O
,	O
and	O
obtain	O
the	O
values	O
of	O
capabilities	O
from	O
the	O
terminfo	B-Device
database	O
using	O
library	B-Library
calls	O
that	O
return	O
successfully	O
only	O
when	O
the	O
capability	O
name	O
corresponds	O
to	O
one	O
of	O
the	O
predefined	O
typed	O
capabilities	O
.	O
</s>
<s>
Like	O
termcap	B-Application
,	O
some	O
of	O
the	O
string	O
capabilities	O
represent	O
escape	O
sequences	O
which	O
may	O
be	O
sent	O
to	O
the	O
host	O
by	O
pressing	O
special	O
keys	O
on	O
the	O
keyboard	O
.	O
</s>
<s>
In	O
the	O
latter	O
case	O
,	O
the	O
terminfo	B-Device
library	B-Library
functions	I-Library
(	O
as	O
does	O
a	O
termcap	B-Application
library	B-Library
)	O
for	O
substituting	O
application	O
parameters	O
into	O
the	O
string	O
which	O
is	O
sent	O
.	O
</s>
<s>
These	O
functions	O
provide	O
a	O
stack-based	B-Language
expression	O
parser	O
,	O
which	O
is	O
primarily	O
used	O
to	O
help	O
minimize	O
the	O
number	O
of	O
characters	O
sent	O
for	O
control	O
sequences	O
which	O
have	O
optional	O
parameters	O
such	O
as	O
SGR	O
(	O
Select	O
Graphic	O
Rendition	O
)	O
.	O
</s>
<s>
In	O
contrast	O
,	O
termcap	B-Application
libraries	O
provide	O
a	O
limited	O
set	O
of	O
operations	O
which	O
are	O
useful	O
for	O
most	O
terminals	B-General_Concept
.	O
</s>
<s>
Terminfo	B-Device
descriptions	O
can	O
be	O
constructed	O
by	O
including	O
the	O
contents	O
of	O
one	O
description	O
in	O
another	O
,	O
suppressing	O
capabilities	O
from	O
the	O
included	O
description	O
or	O
overriding	O
or	O
adding	O
capabilities	O
.	O
</s>
<s>
No	O
matter	O
what	O
storage	B-General_Concept
model	I-General_Concept
is	O
used	O
,	O
the	O
terminfo	B-Device
library	B-Library
returns	O
the	O
terminal	O
description	O
from	O
the	O
requested	O
description	O
,	O
using	O
data	O
which	O
is	O
compiled	O
using	O
a	O
standalone	O
tool	O
(	O
e.g.	O
,	O
tic	O
)	O
.	O
</s>
<s>
Terminfo	B-Device
data	O
is	O
stored	O
as	O
a	O
binary	O
file	O
,	O
making	O
it	O
less	O
simple	O
to	O
modify	O
than	O
termcap	B-Application
.	O
</s>
<s>
The	O
data	O
can	O
be	O
retrieved	O
by	O
the	O
terminfo	B-Device
library	B-Library
from	O
the	O
files	O
where	O
it	O
is	O
stored	O
.	O
</s>
<s>
This	O
is	O
the	O
scheme	O
devised	O
by	O
Mary	O
Horton	O
,	O
and	O
except	O
for	O
some	O
differences	O
regarding	O
the	O
available	O
names	O
is	O
used	O
in	O
most	O
terminfo	B-Device
implementations	O
.	O
</s>
<s>
Because	O
the	O
compiled	O
terminfo	B-Device
entries	O
do	O
not	O
contain	O
metadata	O
identifying	O
the	O
indices	B-Data_Structure
within	O
the	O
tables	O
to	O
which	O
each	O
capability	O
is	O
assigned	O
,	O
they	O
are	O
not	O
necessarily	O
compatible	O
between	O
implementations	O
.	O
</s>
<s>
However	O
,	O
since	O
most	O
implementations	O
use	O
the	O
same	O
overall	O
table	O
structure	O
(	O
including	O
sizes	O
of	O
header	B-General_Concept
and	O
data	O
items	O
)	O
,	O
it	O
is	O
possible	O
to	O
automatically	O
construct	O
customized	O
terminfo	B-Device
libraries	O
which	O
can	O
read	O
data	O
for	O
a	O
given	O
implementation	O
.	O
</s>
<s>
For	O
example	O
,	O
ncurses	B-Language
can	O
be	O
built	O
to	O
match	O
the	O
terminfo	B-Device
data	O
for	O
several	O
other	O
implementations	O
.	O
</s>
<s>
The	O
original	O
(	O
and	O
most	O
common	O
)	O
implementation	O
of	O
the	O
terminfo	B-Device
library	B-Library
retrieves	O
data	O
from	O
a	O
directory	B-Application
hierarchy	O
.	O
</s>
<s>
By	O
using	O
the	O
first	O
character	O
of	O
the	O
name	O
of	O
the	O
terminal	O
description	O
as	O
one	O
component	O
of	O
the	O
pathname	O
,	O
and	O
the	O
name	O
of	O
the	O
terminal	O
description	O
as	O
the	O
name	O
of	O
the	O
file	O
to	O
retrieve	O
,	O
the	O
terminfo	B-Device
library	B-Library
usually	O
outperforms	O
searching	O
a	O
large	O
termcap	B-Application
file	O
.	O
</s>
<s>
Some	O
implementations	O
of	O
terminfo	B-Device
store	O
the	O
terminal	O
description	O
in	O
a	O
hashed	O
database	O
(	O
e.g.	O
,	O
something	O
like	O
Berkeley	B-Language
DB	I-Language
version	O
1.85	O
)	O
.	O
</s>
<s>
These	O
store	O
two	O
types	O
of	O
records	O
:	O
aliases	O
which	O
point	O
to	O
the	O
canonical	O
entry	O
,	O
and	O
the	O
canonical	O
entry	O
itself	O
,	O
which	O
contains	O
the	O
data	O
for	O
the	O
terminal	B-Application
capabilities	I-Application
.	O
</s>
<s>
The	B-Application
Open	I-Application
Group	I-Application
documents	O
the	O
limits	O
for	O
terminfo	B-Device
(	O
minimum	O
guaranteed	O
values	O
)	O
,	O
which	O
apply	O
only	O
to	O
the	O
source	O
file	O
.	O
</s>
<s>
The	O
32,767	O
limit	O
is	O
for	O
positive	O
values	O
in	O
a	O
signed	O
two	B-General_Concept
's	I-General_Concept
complement	I-General_Concept
16-bit	O
value	O
.	O
</s>
<s>
A	O
terminfo	B-Device
entry	O
may	O
use	O
negative	O
numbers	O
to	O
represent	O
cancelled	O
or	O
absent	O
values	O
.	O
</s>
<s>
Unlike	O
termcap	B-Application
,	O
terminfo	B-Device
has	O
both	O
a	O
source	O
and	O
compiled	O
representation	O
.	O
</s>
