Next: 8.2.4 Termcap Capabilities
Up: 8.2 The Termcap Library
Previous: 8.2.2 Find a Terminal
Every piece of information is called a capability, every capability is
a two letter code, and every two letter code is followed by the value
for the capability. Possible types are:
- Numeric: For instance co - number of columns
- Boolean or Flag: For instance hc - hardcopy
- String: For instance st - set tab stop
Each capability is associated with a single value type. (co
is always numeric, hc is always a flag and st is always a string).
There are three different types of values, so there are also three functions to
interrogate them. char *name is the two letter code for the capability.
- int tgetnum(char *name)
Get a capability value that is numeric, such as co.
tgetnum(...) returns the numeric value if the capability is
available, otherwise 1.
(Note: the returned value is not negative.)
- int tgetflag(char *name)
Get a capability value that is boolean (or flag).
Returns 1 if the flag is present, 0 otherwise.
- char *tgetstr(char *name, char **area)
Get a capability value that is a string. Returns a pointer to
the string or NULL if not present. In the GNU version, if
area is NULL, termcap will allocate memory by
itself. Termcap will never refer to this pointer again, so
don't forget to free name before leaving the
program. This method is preferred, because you don't know how
much space is needed for the pointer, so let termcap do this
Fri Mar 29 14:43:04 EST 1996