Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libterminfo Embed ansi, dumb, vt100, vt220 and wsvt25 co...
details: https://anonhg.NetBSD.org/src/rev/ee6fd1ea804c
branches: trunk
changeset: 752005:ee6fd1ea804c
user: roy <roy%NetBSD.org@localhost>
date: Thu Feb 11 00:27:09 2010 +0000
description:
Embed ansi, dumb, vt100, vt220 and wsvt25 compiled terminal descriptions
into libterminfo.
Constify some foo.
diffstat:
lib/libterminfo/Makefile | 17 ++++++++++++++---
lib/libterminfo/curterm.c | 7 ++++---
lib/libterminfo/setupterm.c | 10 ++++++----
lib/libterminfo/term.c | 40 +++++++++++++++++++++++++++-------------
lib/libterminfo/term.h | 12 ++++++------
lib/libterminfo/term_private.h | 11 ++++++-----
6 files changed, 63 insertions(+), 34 deletions(-)
diffs (273 lines):
diff -r d684dfd3df53 -r ee6fd1ea804c lib/libterminfo/Makefile
--- a/lib/libterminfo/Makefile Thu Feb 11 00:24:46 2010 +0000
+++ b/lib/libterminfo/Makefile Thu Feb 11 00:27:09 2010 +0000
@@ -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 @@
gen: hash man
-.include <bsd.own.mk>
.include <bsd.shlib.mk>
.if ${MKLINKLIB} != "no"
diff -r d684dfd3df53 -r ee6fd1ea804c lib/libterminfo/curterm.c
--- a/lib/libterminfo/curterm.c Thu Feb 11 00:24:46 2010 +0000
+++ b/lib/libterminfo/curterm.c Thu Feb 11 00:27:09 2010 +0000
@@ -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 @@
oterm = cur_term;
cur_term = nterm;
+ printf ("%s\n", nterm->name);
ospeed = 0;
if (cur_term == NULL)
PC = '\0';
diff -r d684dfd3df53 -r ee6fd1ea804c lib/libterminfo/setupterm.c
--- a/lib/libterminfo/setupterm.c Thu Feb 11 00:24:46 2010 +0000
+++ b/lib/libterminfo/setupterm.c Thu Feb 11 00:27:09 2010 +0000
@@ -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 @@
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;
diff -r d684dfd3df53 -r ee6fd1ea804c lib/libterminfo/term.c
--- a/lib/libterminfo/term.c Thu Feb 11 00:24:46 2010 +0000
+++ b/lib/libterminfo/term.c Thu Feb 11 00:27:09 2010 +0000
@@ -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 @@
#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 @@
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 @@
{
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 @@
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;
}
diff -r d684dfd3df53 -r ee6fd1ea804c lib/libterminfo/term.h
--- a/lib/libterminfo/term.h Thu Feb 11 00:24:46 2010 +0000
+++ b/lib/libterminfo/term.h Thu Feb 11 00:27:09 2010 +0000
@@ -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 @@
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
diff -r d684dfd3df53 -r ee6fd1ea804c lib/libterminfo/term_private.h
--- a/lib/libterminfo/term_private.h Thu Feb 11 00:24:46 2010 +0000
+++ b/lib/libterminfo/term_private.h Thu Feb 11 00:27:09 2010 +0000
@@ -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 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 @@
/* 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;
Home |
Main Index |
Thread Index |
Old Index