Next: 8.2.3 Look at a Up: 8.2 The Termcap Library Previous: 8.2.1 Introduction

## 8.2.2 Find a Terminal Description

- `int tgetent(void *buffer, const char *termtype)`
  On the Linux operating system the current terminal name is contained in the environment variable . So, `termtype` is the result of a call to (3).

  For `buffer`, no memory has to be allocated when using the GNU version of termcap. This is what we can assume under Linux! Otherwise, you'll have to allocate 2048 Bytes. (Formerly, `buffer` only needed to be 1024 Bytes, but the size has doubled).

  tgetent(...) returns 1 on success and 0 when the database is found but has no entry for TERM. Other errors will return different values.

  The following example should explain how to use tgetent(...):

  By, default termcap uses /etc/termcap/ as the database. If the environment variable TERMCAP is set, with $HOME/mytermcap for instance, all functions will use instead of /etc/termcap. With no leading slash in TERMCAP, the defined value is used as a name for a terminal.