This topic describes functions that are important in curses programming.
This routine is called to initialize a terminal’s description without setting up the curses screen structures or changing the tty-driver mode bits. The term argument is the character string representing the name of the terminal being used. The filenum argument is the file descriptor of the terminal to be used for output. The errret argument is a pointer to an integer, in which a success or failure indication is returned. The values returned can be: 1 (all is well), 0 (no such terminal), or –1 (some problem locating the terminfo database).
The value of term can be given as NULL, which causes the
value of TERM in the environment to be used. The errret
pointer can also be given as NULL, meaning no error code is wanted.
If errret is defaulted, and something goes wrong,
setupterm() prints an appropriate error message and exits
rather than returning. Thus, a simple program can call
setuterm(0,1,0)
, which should eliminate concerns about
initialization errors.
After the call to setupterm(), the global variable cur_term is set to point to the current structure of terminal capabilities. By calling setupterm() for each terminal, and saving and restoring cur_term, a program can use two or more terminals at once. The setupterm() function also stores the names section of the terminal description in the global character array ttytype[]. Subsequent calls to setupterm() will overwrite this array, so you must save it yourself if need be.
The following function is not part of the standard curses application programming interface (API):