Embed ansi, dumb, vt100, vt220 and wsvt25 compiled terminal descriptions
into libterminfo. Constify some foo.
This commit is contained in:
parent
55a396b95f
commit
90cead5eeb
@ -1,17 +1,29 @@
|
||||
# $NetBSD: Makefile,v 1.4 2010/02/09 22:16:12 roy Exp $
|
||||
# $NetBSD: Makefile,v 1.5 2010/02/11 00:27:09 roy Exp $
|
||||
|
||||
USE_SHLIBDIR= yes
|
||||
|
||||
LIB= terminfo
|
||||
WARNS= 4
|
||||
|
||||
CPPFLAGS+= -I${.CURDIR}
|
||||
CPPFLAGS+= -I${.CURDIR} -I${.OBJDIR}
|
||||
|
||||
SRCS= term.c ti.c setupterm.c curterm.c tparm.c tputs.c
|
||||
SRCS+= hash.c
|
||||
INCS= term.h
|
||||
INCSDIR= /usr/include
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
rescue.c: ${NETBSDSRCDIR}/share/terminfo/terminfo
|
||||
@echo "static const char *rescue_terms[] = {" >$@
|
||||
${TOOL_TIC} -Sx ${NETBSDSRCDIR}/share/terminfo/terminfo \
|
||||
ansi dumb vt100 vt220 wsvt25 >>$@
|
||||
@echo " NULL," >>$@
|
||||
@echo " NULL" >>$@
|
||||
@echo "};" >>$@
|
||||
|
||||
term.c: rescue.c
|
||||
|
||||
MAN= terminfo.3 terminfo.5
|
||||
MLINKS= terminfo.3 setupterm.3 \
|
||||
terminfo.3 set_curterm.3 terminfo.3 del_curterm.3 \
|
||||
@ -46,7 +58,6 @@ man: terminfo.5
|
||||
|
||||
gen: hash man
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include <bsd.shlib.mk>
|
||||
|
||||
.if ${MKLINKLIB} != "no"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: curterm.c,v 1.1 2010/02/03 15:16:32 roy Exp $ */
|
||||
/* $NetBSD: curterm.c,v 1.2 2010/02/11 00:27:09 roy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
@ -28,14 +28,14 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: curterm.c,v 1.1 2010/02/03 15:16:32 roy Exp $");
|
||||
__RCSID("$NetBSD: curterm.c,v 1.2 2010/02/11 00:27:09 roy Exp $");
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <term_private.h>
|
||||
#include <term.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include <stdio.h>
|
||||
TERMINAL *cur_term;
|
||||
|
||||
static const speed_t bauds[] = {
|
||||
@ -71,6 +71,7 @@ set_curterm(TERMINAL *nterm)
|
||||
oterm = cur_term;
|
||||
cur_term = nterm;
|
||||
|
||||
printf ("%s\n", nterm->name);
|
||||
ospeed = 0;
|
||||
if (cur_term == NULL)
|
||||
PC = '\0';
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: setupterm.c,v 1.1 2010/02/03 15:16:32 roy Exp $ */
|
||||
/* $NetBSD: setupterm.c,v 1.2 2010/02/11 00:27:09 roy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: setupterm.c,v 1.1 2010/02/03 15:16:32 roy Exp $");
|
||||
__RCSID("$NetBSD: setupterm.c,v 1.2 2010/02/11 00:27:09 roy Exp $");
|
||||
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
@ -69,8 +69,10 @@ ti_setupterm(TERMINAL **nterm, const char *term, int fildes, int *errret)
|
||||
|
||||
if (term == NULL)
|
||||
term = getenv("TERM");
|
||||
if (term == NULL || *term == '\0')
|
||||
reterr(-1, "TERM environment variable not set");
|
||||
if (term == NULL || *term == '\0') {
|
||||
*nterm = NULL;
|
||||
reterr(0, "TERM environment variable not set");
|
||||
}
|
||||
if (fildes == STDOUT_FILENO && !isatty(fildes))
|
||||
fildes = STDERR_FILENO;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: term.c,v 1.4 2010/02/05 19:21:02 roy Exp $ */
|
||||
/* $NetBSD: term.c,v 1.5 2010/02/11 00:27:09 roy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Roy Marples.
|
||||
@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: term.c,v 1.4 2010/02/05 19:21:02 roy Exp $");
|
||||
__RCSID("$NetBSD: term.c,v 1.5 2010/02/11 00:27:09 roy Exp $");
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -45,14 +45,25 @@ __RCSID("$NetBSD: term.c,v 1.4 2010/02/05 19:21:02 roy Exp $");
|
||||
#include <term.h>
|
||||
|
||||
#define TERMINFO_DIRS "/usr/share/misc/terminfo"
|
||||
#define TERMINFO_RESCUE "/rescue/terminfo"
|
||||
|
||||
static char database[PATH_MAX];
|
||||
static char pathbuf[PATH_MAX];
|
||||
const char *_ti_database;
|
||||
|
||||
/* rescue.c is generated from /usr/src/share/terminfo/terminfo
|
||||
* at build time as an array of strings.
|
||||
* static const char *rescue_terms[] = {
|
||||
* "ansi",
|
||||
* "\002\005\000\141\156\163\151\000\000\000\043\000\141\156\163\151\057",
|
||||
* NULL,
|
||||
* NULL
|
||||
* };
|
||||
*/
|
||||
|
||||
#include "rescue.c"
|
||||
|
||||
static int
|
||||
_ti_readterm(TERMINAL *term, char *cap, size_t caplen, int flags)
|
||||
_ti_readterm(TERMINAL *term, const char *cap, size_t caplen, int flags)
|
||||
{
|
||||
uint8_t ver;
|
||||
uint16_t ind, num;
|
||||
@ -76,10 +87,11 @@ _ti_readterm(TERMINAL *term, char *cap, size_t caplen, int flags)
|
||||
term->strs = calloc(TISTRMAX + 1, sizeof(char *));
|
||||
if (term->strs == NULL)
|
||||
goto err;
|
||||
term->_area = malloc(caplen);
|
||||
term->_arealen = caplen;
|
||||
term->_area = malloc(term->_arealen);
|
||||
if (term->_area == NULL)
|
||||
goto err;
|
||||
memcpy(term->_area, cap, caplen);
|
||||
memcpy(term->_area, cap, term->_arealen);
|
||||
|
||||
cap = term->_area;
|
||||
len = le16dec(cap);
|
||||
@ -280,12 +292,14 @@ _ti_getterm(TERMINAL *term, const char *name, int flags)
|
||||
{
|
||||
int r;
|
||||
char *e, h[PATH_MAX];
|
||||
const char **p;
|
||||
|
||||
_DIAGASSERT(term != NULL);
|
||||
_DIAGASSERT(name != NULL);
|
||||
|
||||
database[0] = '\0';
|
||||
_ti_database = NULL;
|
||||
|
||||
e = getenv("TERMINFO");
|
||||
if (e != NULL)
|
||||
return _ti_dbgetterm(term, e, name, flags);
|
||||
@ -302,12 +316,12 @@ _ti_getterm(TERMINAL *term, const char *name, int flags)
|
||||
if (r == 1)
|
||||
return 1;
|
||||
|
||||
/* If we don't find the term in the rescue db and there is
|
||||
* no error, then report the last database accessed. */
|
||||
strlcpy(h, database, sizeof(h));
|
||||
r = _ti_dbgetterm(term, TERMINFO_RESCUE, name, flags);
|
||||
if (r == 0 && h[0] != '\0')
|
||||
strlcpy(database, h, sizeof(h));
|
||||
for (p = rescue_terms; *p != NULL; p++, p++)
|
||||
if (strcmp(name, *p) == 0) {
|
||||
r = _ti_readterm(term, *(p + 1), 4096, flags);
|
||||
break;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: term.h,v 1.3 2010/02/05 14:39:07 he Exp $ */
|
||||
/* $NetBSD: term.h,v 1.4 2010/02/11 00:27:09 roy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Roy Marples.
|
||||
@ -1452,10 +1452,10 @@ enum TISTRS{
|
||||
typedef struct terminal {
|
||||
int fildes;
|
||||
/* We need to expose these so that the macros work */
|
||||
char *name;
|
||||
char *desc;
|
||||
signed char *flags;
|
||||
short *nums;
|
||||
const char *name;
|
||||
const char *desc;
|
||||
const signed char *flags;
|
||||
const short *nums;
|
||||
const char **strs;
|
||||
} TERMINAL;
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* $NetBSD: term_private.h,v 1.4 2010/02/05 14:39:07 he Exp $ */
|
||||
/* $NetBSD: term_private.h,v 1.5 2010/02/11 00:27:09 roy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Roy Marples.
|
||||
@ -82,13 +82,14 @@ typedef struct termextra {
|
||||
typedef struct terminal {
|
||||
int fildes;
|
||||
/* We need to expose these so that the macros work */
|
||||
char *name;
|
||||
char *desc;
|
||||
const char *name;
|
||||
const char *desc;
|
||||
signed char *flags;
|
||||
short *nums;
|
||||
const char **strs;
|
||||
/* Storage area for terminfo data */
|
||||
char *_area;
|
||||
size_t _arealen;
|
||||
size_t _nuserdefs;
|
||||
TERMUSERDEF *_userdefs;
|
||||
/* So we don't rely on the global ospeed */
|
||||
@ -100,7 +101,7 @@ typedef struct terminal {
|
||||
/* A-Z static variables for tparm */
|
||||
long _snums[26];
|
||||
/* aliases of the terminal, | separated */
|
||||
char *_alias;
|
||||
const char *_alias;
|
||||
} TERMINAL;
|
||||
|
||||
extern const char * _ti_database;
|
||||
|
Loading…
Reference in New Issue
Block a user