-ltermcap

Greg Noel greg at ncr-sd.UUCP
Tue Aug 5 09:20:55 AEST 1986


In article <2565 at rsch.wisc.edu> dave at rsch.wisc.edu (Dave Cohrs), answering
an article from shawn at mit-eddie.MIT.EDU (Shawn F. Mckay), writes:
>....  The declaration for tgetstr is:
>	char * tgetstr(id, area)
>	char *id, **area;
>Note the '**area'.  So you want to do:
>{
>	char buff[20];
>	char *bufptr = buff;
>	(void) tgetstr("cl", &bufptr);
>}

Almost right.  The advance of the buffer pointer is actually a \side-effect/,
and not the value (the semantic result) of the function.  It is documented the
way it is so that programmers will be sure to allocate enough space to hold
any strings that tgetstr \might/ wish to store there, but it is the return
value from tgetstr that must be used for the string.  That is, you need to say:
	char buff[20];
	char *bufptr = buff;
	char *cl_ptr;
	cl_ptr = tgetstr("cl", &bufptr);
This will make the code compatible with the SysV terminfo emulation of termcap,
which has its own area for storing the strings, and doesn't copy them into the
buffer or update the pointer.
-- 
-- Greg Noel, NCR Rancho Bernardo    Greg at ncr-sd.UUCP or Greg at nosc.ARPA



More information about the Comp.unix.wizards mailing list