diff options
author | ache <ache@FreeBSD.org> | 1995-08-05 21:22:07 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1995-08-05 21:22:07 +0000 |
commit | 100e6f311c5d20fdb09afe48750d3d733c8b8e45 (patch) | |
tree | 84255860ff0aa7fd3bacde0ab4494a6ab882406e /lib/libtermcap/termcap.c | |
parent | c426abc4240ef56049117a4cc11d9db6a62c0db1 (diff) | |
download | FreeBSD-src-100e6f311c5d20fdb09afe48750d3d733c8b8e45.zip FreeBSD-src-100e6f311c5d20fdb09afe48750d3d733c8b8e45.tar.gz |
Do a little trick which covers 99% cases: initialize ospeed
variable directly in tgetent by stderr or stdout output speed.
It helps hide in non-standard __set_ospeed function and remove it
from other sources (coming soon).
Do prototype cleanup too.
Diffstat (limited to 'lib/libtermcap/termcap.c')
-rw-r--r-- | lib/libtermcap/termcap.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/libtermcap/termcap.c b/lib/libtermcap/termcap.c index 38ae9da..7f8d39d 100644 --- a/lib/libtermcap/termcap.c +++ b/lib/libtermcap/termcap.c @@ -43,8 +43,13 @@ static char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93"; #include <ctype.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> +#include <termios.h> +#include "termcap.h" #include "pathnames.h" +extern void __set_ospeed(speed_t speed); + /* * termcap - routines for dealing with the terminal capability data base * @@ -65,8 +70,7 @@ static char *tbuf; /* termcap buffer */ * Get an entry for terminal name in buffer bp from the termcap file. */ int -tgetent(bp, name) - char *bp, *name; +tgetent(char *bp, const char *name) { register char *p; register char *cp; @@ -78,6 +82,7 @@ tgetent(bp, name) char *pathvec[PVECSIZ]; /* to point to names in pathbuf */ char **pvec; /* holds usable tail of path vector */ char *termpath; + struct termios tty; dummy = NULL; fname = pathvec; @@ -130,7 +135,7 @@ tgetent(bp, name) if (cgetset(cp) < 0) return(-2); - i = cgetent(&dummy, pathvec, name); + i = cgetent(&dummy, pathvec, (char *)name); if (i == 0) { char *pd, *ps, *tok, *s, *tcs; @@ -180,6 +185,12 @@ tgetent(bp, name) } } done: + if ( i == 0 + && ( tcgetattr(STDERR_FILENO, &tty) != -1 + || tcgetattr(STDOUT_FILENO, &tty) != -1 + ) + ) + __set_ospeed(cfgetospeed(&tty)); if (dummy) free(dummy); /* no tc reference loop return code in libterm XXX */ @@ -197,12 +208,11 @@ done: * Note that we handle octal numbers beginning with 0. */ int -tgetnum(id) - char *id; +tgetnum(const char *id) { long num; - if (cgetnum(tbuf, id, &num) == 0) + if (cgetnum(tbuf, (char *)id, &num) == 0) return(num); else return(-1); @@ -215,10 +225,9 @@ tgetnum(id) * not given. */ int -tgetflag(id) - char *id; +tgetflag(const char *id) { - return(cgetcap(tbuf, id, ':') != NULL); + return(cgetcap(tbuf, (char *)id, ':') != NULL); } /* @@ -230,8 +239,7 @@ tgetflag(id) * No checking on area overflow. */ char * -tgetstr(id, area) - char *id, **area; +tgetstr(const char *id, char **area) { char ids[3]; char *s; |