Vineet1982
Vineet1982

Reputation: 7918

ncurses - how the TINFO_SETUP_TERM works?

I trying to understand working of ncurses as we called initscr() for ncurses to init screen

function defined in file ncurses lib_initscr.c and tries to open terminal through newterm i.e. lib_newterm.c file and it uses:

if ( TINFO_SETUP_TERM(&new_term, name,fileno(_ofp), &errret, FALSE) != ERR) ){
}

and when I open the curses.priv.h as:

#ifdef USE_TERM_DRIVER
    #define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \
        _nc_setupterm_ex(tpp, name, fd, err, reuse)
#else

    #define TINFO_SETUP_TERM(tpp, name, fd, err, reuse) \
        _nc_setupterm(name, fd, err, reuse)
#endif

and in lib_setup.c the functions are defined as under:

#ifdef USE_TERM_DRIVER
    NCURSES_EXPORT(int) _nc_setupterm(
            NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse){
            }
#endif

I didn't find where is function _nc_setupterm_ex() defined in the source code and how if the USE_TERM_DRIVER is not defined then how it link to the _nc_setupterm();

Upvotes: 0

Views: 401

Answers (1)

Craig
Craig

Reputation: 4840

TINFO_SETUP_TERM is defined in ncurses/tinfo/lib_setup.c (line 577 in the ncurses 5.9 source) the macros you show set the name of the function to either _nc_setupterm or _nc_setupterm_ex.

If USE_TERM_DRIVER is defined then TINFO_SETUP_TERM is defined as _nc_setupterm_ex and _nc_setupterm becomes a wrapper for TINFO_SETUP_TERM (which is nc_setupterm_ex)

If USE_TERM_DRIVERis not defined thenTINFO_SETUP_TERMis defined as_nc_setuptermand the definition of_nc_setupterm` you quoted does not get compiled.

Upvotes: 1

Related Questions