<s>
Termcap	B-Application
(	O
terminal	O
capability	O
)	O
is	O
a	O
software	B-Library
library	I-Library
and	O
database	O
used	O
on	O
Unix-like	B-Operating_System
computers	O
.	O
</s>
<s>
It	O
enables	O
programs	O
to	O
use	O
display	O
computer	B-General_Concept
terminals	I-General_Concept
in	O
a	O
device-independent	O
manner	O
,	O
which	O
greatly	O
simplifies	O
the	O
process	O
of	O
writing	O
portable	O
text	B-Application
mode	I-Application
applications	O
.	O
</s>
<s>
Bill	O
Joy	O
wrote	O
the	O
first	O
termcap	B-Application
library	B-Library
in	O
1978	O
for	O
the	O
Berkeley	B-Operating_System
Unix	I-Operating_System
operating	B-General_Concept
system	I-General_Concept
;	O
it	O
has	O
since	O
been	O
ported	O
to	O
most	O
Unix	O
and	O
Unix-like	B-Operating_System
environments	O
,	O
even	O
OS-9	B-Operating_System
.	O
</s>
<s>
Joy	O
's	O
design	O
was	O
reportedly	O
influenced	O
by	O
the	O
design	O
of	O
the	O
terminal	O
data	O
store	O
in	O
the	O
earlier	O
Incompatible	B-Application
Timesharing	I-Application
System	I-Application
.	O
</s>
<s>
A	O
termcap	B-Application
database	O
can	O
describe	O
the	O
capabilities	B-Application
of	O
hundreds	O
of	O
different	O
display	O
terminals	O
.	O
</s>
<s>
On-screen	O
text	O
editors	O
such	O
as	O
vi	B-Application
and	O
Emacs	B-Application
are	O
examples	O
of	O
programs	O
that	O
may	O
use	O
termcap	B-Application
.	O
</s>
<s>
Other	O
programs	O
are	O
listed	O
in	O
the	O
Termcap	B-Application
category	O
.	O
</s>
<s>
Termcap	B-Application
databases	O
consist	O
of	O
one	O
or	O
more	O
descriptions	O
of	O
terminals	O
.	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
termcap	B-Application
database	O
.	O
</s>
<s>
The	O
description	O
contains	O
one	O
or	O
more	O
capabilities	B-Application
,	O
which	O
have	O
conventional	O
names	O
.	O
</s>
<s>
The	O
capabilities	B-Application
are	O
typed	O
:	O
boolean	O
,	O
numeric	O
and	O
string	O
.	O
</s>
<s>
The	O
termcap	B-Application
library	B-Library
has	O
no	O
predetermined	O
type	O
for	O
each	O
capability	O
name	O
.	O
</s>
<s>
string	O
capabilities	B-Application
have	O
an	O
"	O
=	O
"	O
between	O
the	O
capability	O
name	O
and	O
its	O
value	O
,	O
</s>
<s>
boolean	O
capabilities	B-Application
have	O
no	O
associated	O
value	O
(	O
they	O
are	O
always	O
true	O
if	O
specified	O
)	O
.	O
</s>
<s>
Applications	O
which	O
use	O
termcap	B-Application
do	O
expect	O
specific	O
types	O
for	O
the	O
commonly	O
used	O
capabilities	B-Application
,	O
and	O
obtain	O
the	O
values	O
of	O
capabilities	B-Application
from	O
the	O
termcap	B-Application
database	O
using	O
library	B-Library
calls	O
that	O
return	O
successfully	O
only	O
when	O
the	O
database	O
contents	O
matches	O
the	O
assumed	O
type	O
.	O
</s>
<s>
Termcap	B-Application
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	B-Application
from	O
the	O
included	O
description	O
or	O
overriding	O
or	O
adding	O
capabilities	B-Application
.	O
</s>
<s>
No	O
matter	O
what	O
storage	B-General_Concept
model	I-General_Concept
is	O
used	O
,	O
the	O
termcap	B-Application
library	B-Library
constructs	O
the	O
terminal	O
description	O
from	O
the	O
requested	O
description	O
,	O
including	O
,	O
suppressing	O
or	O
overriding	O
at	O
the	O
time	O
of	O
the	O
request	O
.	O
</s>
<s>
Termcap	B-Application
data	O
is	O
stored	O
as	O
text	O
,	O
making	O
it	O
simple	O
to	O
modify	O
.	O
</s>
<s>
The	O
text	O
can	O
be	O
retrieved	O
by	O
the	O
termcap	B-Application
library	B-Library
from	O
files	O
or	O
environment	O
variables	O
.	O
</s>
<s>
The	O
TERMCAP	B-Application
environment	O
variable	O
may	O
contain	O
a	O
termcap	B-Application
database	O
.	O
</s>
<s>
It	O
is	O
most	O
often	O
used	O
to	O
store	O
a	O
single	O
termcap	B-Application
description	O
,	O
set	O
by	O
a	O
terminal	B-Application
emulator	I-Application
to	O
provide	O
the	O
terminal	O
's	O
characteristics	O
to	O
the	O
shell	O
and	O
dependent	O
programs	O
.	O
</s>
<s>
The	O
TERMPATH	O
environment	O
variable	O
is	O
supported	O
by	O
newer	O
termcap	B-Application
implementations	O
and	O
defines	O
a	O
search	O
path	O
for	O
termcap	B-Application
files	O
.	O
</s>
<s>
The	O
original	O
(	O
and	O
most	O
common	O
)	O
implementation	O
of	O
the	O
termcap	B-Application
library	B-Library
retrieves	O
data	O
from	O
a	O
flat	O
text	O
file	O
.	O
</s>
<s>
Searching	O
a	O
large	O
termcap	B-Application
file	O
,	O
e.g.	O
,	O
500	O
kB	O
,	O
can	O
be	O
slow	O
.	O
</s>
<s>
4.4BSD	O
based	O
implementations	O
of	O
termcap	B-Application
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>
The	O
text	O
of	O
the	O
termcap	B-Application
entry	O
is	O
stored	O
literally	O
.	O
</s>
<s>
The	O
original	O
termcap	B-Application
implementation	O
was	O
designed	O
to	O
use	O
little	O
memory	O
:	O
</s>
<s>
only	O
one	O
termcap	B-Application
entry	O
with	O
its	O
definitions	O
can	O
be	O
included	O
,	O
and	O
must	O
be	O
at	O
the	O
end	O
.	O
</s>
<s>
Newer	O
implementations	O
of	O
the	O
termcap	B-Application
interface	O
generally	O
do	O
not	O
require	O
the	O
two-character	O
name	O
at	O
the	O
beginning	O
of	O
the	O
entry	O
.	O
</s>
<s>
Newer	O
implementations	O
of	O
the	O
termcap	B-Application
interface	O
may	O
relax	O
this	O
constraint	O
by	O
allowing	O
a	O
null	O
pointer	O
in	O
place	O
of	O
the	O
fixed	O
buffer	O
,	O
or	O
by	O
hiding	O
the	O
data	O
which	O
would	O
not	O
fit	O
,	O
e.g.	O
,	O
via	O
the	O
ZZ	O
capability	O
in	O
NetBSD	B-Device
termcap	B-Application
.	O
</s>
<s>
The	O
terminfo	B-Device
library	B-Library
interface	O
also	O
emulates	O
the	O
termcap	B-Application
interface	O
,	O
and	O
does	O
not	O
actually	O
use	O
the	O
fixed-size	O
buffer	O
.	O
</s>
<s>
The	O
terminfo	B-Device
library	B-Library
's	O
emulation	O
of	O
termcap	B-Application
allows	O
multiple	O
other	O
entries	O
to	O
be	O
included	O
without	O
restricting	O
the	O
position	O
.	O
</s>
<s>
A	O
few	O
other	O
newer	O
implementations	O
of	O
the	O
termcap	B-Application
library	B-Library
may	O
also	O
provide	O
this	O
ability	O
,	O
though	O
it	O
is	O
not	O
well	O
documented	O
.	O
</s>
<s>
A	O
special	O
capability	O
,	O
the	O
"	O
hz	O
"	O
capability	O
,	O
was	O
defined	O
specifically	O
to	O
support	O
the	O
Hazeltine	B-Device
1500	I-Device
terminal	O
,	O
which	O
had	O
the	O
unfortunate	O
characteristic	O
of	O
using	O
the	O
ASCII	B-Protocol
tilde	O
character	O
('~'	O
)	O
as	O
a	O
control	O
sequence	O
introducer	O
.	O
</s>
<s>
Since	O
the	O
Hazeltine	B-Device
1500	I-Device
was	O
a	O
widely	O
used	O
terminal	O
in	O
the	O
late	O
1970s	O
,	O
it	O
was	O
important	O
for	O
applications	O
to	O
be	O
able	O
to	O
deal	O
with	O
its	O
limitations	O
.	O
</s>
