summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libcurses/curses.h1
-rw-r--r--lib/libcurses/setterm.c32
-rw-r--r--lib/libncurses/lib_kernel.c8
-rw-r--r--lib/libtermcap/Makefile6
-rw-r--r--lib/libtermcap/termcap.312
-rw-r--r--lib/libtermcap/termcap.c30
-rw-r--r--lib/libtermcap/termcap.h6
-rw-r--r--lib/libtermcap/tgoto.c8
-rw-r--r--lib/libtermcap/tparm.c1
-rw-r--r--lib/libtermcap/tputs.c10
10 files changed, 51 insertions, 63 deletions
diff --git a/lib/libcurses/curses.h b/lib/libcurses/curses.h
index 1142ca5a894d..49982c43d77f 100644
--- a/lib/libcurses/curses.h
+++ b/lib/libcurses/curses.h
@@ -98,7 +98,6 @@
#define erasechar() (__baset.c_cc[VERASE])
#define killchar() (__baset.c_cc[VKILL])
#define nocrmode() nocbreak()
-#define ospeed (cfgetospeed(&__baset))
/* WINDOW structure members name compatibility */
#define _curx curx
diff --git a/lib/libcurses/setterm.c b/lib/libcurses/setterm.c
index ac85708bb767..14ce6ee37e6b 100644
--- a/lib/libcurses/setterm.c
+++ b/lib/libcurses/setterm.c
@@ -44,9 +44,6 @@ static char sccsid[] = "@(#)setterm.c 8.7 (Berkeley) 7/27/94";
#include "curses.h"
-#undef ospeed
-extern short ospeed;
-
static void zap __P((void));
static char *sflags[] = {
@@ -155,35 +152,6 @@ setterm(type)
PC = _PC ? _PC[0] : 0;
- switch(cfgetospeed(&__baset)) {
- case B0: ospeed = 0; break;
- case B50: ospeed = 1; break;
- case B75: ospeed = 2; break;
- case B110: ospeed = 3; break;
- case B134: ospeed = 4; break;
- case B150: ospeed = 5; break;
- case B200: ospeed = 6; break;
- case B300: ospeed = 7; break;
- case B600: ospeed = 8; break;
- case B1200: ospeed = 9; break;
- case B1800: ospeed = 10; break;
- case B2400: ospeed = 11; break;
- case B4800: ospeed = 12; break;
- case B9600: ospeed = 13; break;
-#ifdef EXTA
- case EXTA: ospeed = 14; break;
-#endif
-#ifdef EXTB
- case EXTB: ospeed = 15; break;
-#endif
-#ifdef B57600
- case B57600: ospeed = 16; break;
-#endif
-#ifdef B115200
- case B115200: ospeed = 17; break;
-#endif
- }
-
aoftspace = tspace;
ttytype = longname(genbuf, __ttytype);
diff --git a/lib/libncurses/lib_kernel.c b/lib/libncurses/lib_kernel.c
index e373935c5da8..bd81fe134dad 100644
--- a/lib/libncurses/lib_kernel.c
+++ b/lib/libncurses/lib_kernel.c
@@ -211,6 +211,7 @@ int flushinp()
*
*/
+#ifndef TERMIOS
struct speed {
speed_t s;
int sp;
@@ -253,25 +254,28 @@ static struct speed speeds[] = {
,{B115200, 115200}
#endif
};
+#endif
int
baudrate()
{
+#ifndef TERMIOS
int i, ret;
+#endif
T(("baudrate() called"));
#ifdef TERMIOS
- ret = cfgetospeed(&cur_term->Nttyb);
+ return cfgetospeed(&cur_term->Nttyb);
#else
ret = cur_term->Nttyb.sg_ospeed;
-#endif
if(ret < 0 || ret > MAX_BAUD)
return ERR;
for (i = 0; i < (sizeof(speeds) / sizeof(struct speed)); i++)
if (speeds[i].s == ret)
return speeds[i].sp;
return ERR;
+#endif
}
diff --git a/lib/libtermcap/Makefile b/lib/libtermcap/Makefile
index 8c90c9d43146..5445de04f25d 100644
--- a/lib/libtermcap/Makefile
+++ b/lib/libtermcap/Makefile
@@ -3,8 +3,8 @@
LIB= termcap
SHLIB_MAJOR= 2
SHLIB_MINOR= 1
-CFLAGS+=-DCM_N -DCM_GT -DCM_B -DCM_D
-SRCS= termcap.c tgoto.c tputs.c tparm.c
+CFLAGS+=-DCM_N -DCM_GT -DCM_B -DCM_D -I${.CURDIR}
+SRCS= termcap.c tgoto.c tputs.c tparm.c tospeed.c
MAN3= termcap.3
MLINKS= termcap.3 tgetent.3 termcap.3 tgetflag.3 termcap.3 tgetnum.3 \
@@ -21,7 +21,7 @@ LINKS+= ${LIBDIR}/libtermcap_p.a ${LIBDIR}/libtermlib_p.a
beforeinstall:
-cd ${.CURDIR}; cmp -s termcap.h ${DESTDIR}/usr/include/termcap.h || \
- install -c -o ${BINOWN} -g ${BINGRP} -m 444 termcap.h \
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 termcap.h \
${DESTDIR}/usr/include
.include <bsd.lib.mk>
diff --git a/lib/libtermcap/termcap.3 b/lib/libtermcap/termcap.3
index 861bc2447bcc..3867f70bdd9f 100644
--- a/lib/libtermcap/termcap.3
+++ b/lib/libtermcap/termcap.3
@@ -41,7 +41,8 @@
.Nm tgetstr ,
.Nm tgoto ,
.Nm tputs ,
-.Nm tparm
+.Nm tparm ,
+.Nm _set_ospeed
.Nd terminal independent operation routines
.Sh SYNOPSIS
.Fd #include <termcap.h>
@@ -63,6 +64,8 @@
.Fn tputs "const char *cp" "int affcnt" "int (*outc)(int)"
.Ft char *
.Fn tparm "const char *cp" "..."
+.Ft void
+.Fn _set_ospeed "long speed"
.Sh DESCRIPTION
These functions extract and use capabilities from a terminal capability data
base, usually
@@ -232,6 +235,13 @@ The external variable
.Va ospeed
should contain the output speed of the terminal as encoded by
.Xr stty 3 .
+The
+.Fn _set_ospeed
+functions converts any (not exactly matched only) numeric speed to
+.Xr stty 3
+encoded speed and set
+.Va ospeed
+variable.
The external variable
.Va PC
should contain a pad character to be used (from the
diff --git a/lib/libtermcap/termcap.c b/lib/libtermcap/termcap.c
index 38ae9da922bd..7f8d39d9031e 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;
diff --git a/lib/libtermcap/termcap.h b/lib/libtermcap/termcap.h
index 7cd1f068a0b3..26ac71c58a6d 100644
--- a/lib/libtermcap/termcap.h
+++ b/lib/libtermcap/termcap.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1994 by Andrew A. Chernov, Moscow, Russia.
+ * Copyright (C) 1994,1995 by Andrey A. Chernov, Moscow, Russia.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -24,7 +24,7 @@
* SUCH DAMAGE.
*/
-/* $Id: termcap.h,v 1.3 1994/12/09 21:55:52 ache Exp $ */
+/* $Id: termcap.h,v 1.6 1995/08/05 21:21:54 ache Exp $ */
#ifndef _TERMCAP_H_
#define _TERMCAP_H_
diff --git a/lib/libtermcap/tgoto.c b/lib/libtermcap/tgoto.c
index c4dd9d7f43ca..e28a85cdfaad 100644
--- a/lib/libtermcap/tgoto.c
+++ b/lib/libtermcap/tgoto.c
@@ -35,6 +35,8 @@
static char sccsid[] = "@(#)tgoto.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
+#include "termcap.h"
+
#define CTRL(c) ((c) & 037)
#define MAXRETURNSIZE 64
@@ -67,13 +69,11 @@ char *BC;
* all other characters are ``self-inserting''.
*/
char *
-tgoto(CM, destcol, destline)
- char *CM;
- int destcol, destline;
+tgoto(const char *CM, int destcol, int destline)
{
static char result[MAXRETURNSIZE];
static char added[10];
- char *cp = CM;
+ const char *cp = CM;
register char *dp = result;
register int c;
int oncol = 0;
diff --git a/lib/libtermcap/tparm.c b/lib/libtermcap/tparm.c
index 36070d962601..6a537ce4e90a 100644
--- a/lib/libtermcap/tparm.c
+++ b/lib/libtermcap/tparm.c
@@ -11,6 +11,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include "termcap.h"
#ifdef USE_SCCS_IDS
static const char SCCSid[] = "@(#) mytinfo tparm.c 3.2 92/02/01 public domain, By Ross Ridge";
diff --git a/lib/libtermcap/tputs.c b/lib/libtermcap/tputs.c
index 857147d9283e..46b6dc28ce50 100644
--- a/lib/libtermcap/tputs.c
+++ b/lib/libtermcap/tputs.c
@@ -35,8 +35,8 @@
static char sccsid[] = "@(#)tputs.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
-#include <sgtty.h>
#include <ctype.h>
+#include "termcap.h"
/*
* The following array gives the number of tens of milliseconds per
@@ -45,7 +45,8 @@ static char sccsid[] = "@(#)tputs.c 8.1 (Berkeley) 6/4/93";
*/
static
short tmspc10[] = {
- 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5
+ 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5,
+ 3, 2, 1
};
short ospeed;
@@ -56,10 +57,7 @@ char PC;
* The number of affected lines is affcnt, and the routine
* used to output one character is outc.
*/
-tputs(cp, affcnt, outc)
- register char *cp;
- int affcnt;
- int (*outc)();
+tputs(const char *cp, int affcnt, int (*outc)(int))
{
register int i = 0;
register int mspc10;