> Hello there,
> I have been working under linux to gain some programming experience.
> But i have got a problem i use
> setupterm function as
> test = setupterm((char *)0, 1, (int *)0);
> or
> test = setupterm(NULL, lineno(stdout), (int *)0);
> both of them returns 0 which means no matching entry in terminfo database.
> It would be nice if you help me to figure out whats wrong with those
> calls.
Nothing is wrong with the calls, just your interpretation of them:
$ man curs_terminfo
...
int setupterm(const char *term, int fildes, int *errret);
...
The setupterm routine reads in the terminfo database, ini-
tializing the terminfo structures, but does not set up the
output virtualization structures used by curses. The ter-
minal type is the character string term; if term is null,
the environment variable TERM is used. All output is to
file descriptor fildes which is initialized for output.
If errret is not null, then setupterm returns OK or ERR
and stores a status value in the integer pointed to by
errret. A return value of OK combined with status of 1 in
errret is normal. If ERR is returned, examine errret:
...
0 means that the terminal could not be found, or
that it is a generic type, having too little
information for curses applications to run.
...
seeing as you've told it to ignore the error code:
test = setupterm((char *)0, 1, (int *)0);
HOW do you know the error return (in errret) is 0? I've just tried:
int err;
int test = setupterm((char *)0, 1, &err);
printf("test = %d, err = %d\n", test, err);
printf("OK = %d, ERR = %d\n", OK, ERR);
and got back:
test = 0, err = 1
OK = 0, ERR = -1
So, setupterm() has returned OK, with a staus (in err) of 1, which is
totally normal (see man extract above) for a successful call.