summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libcurses/term_entry.h5
-rw-r--r--lib/libcurses/tinfo/lib_setup.c11
-rw-r--r--lib/libcurses/tinfo/read_bsd_terminfo.c133
-rw-r--r--lib/libcurses/tinfo/read_entry.c9
4 files changed, 92 insertions, 66 deletions
diff --git a/lib/libcurses/term_entry.h b/lib/libcurses/term_entry.h
index 69be127a0ff..cd3f5060b6c 100644
--- a/lib/libcurses/term_entry.h
+++ b/lib/libcurses/term_entry.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: term_entry.h,v 1.2 1999/01/18 19:09:16 millert Exp $ */
+/* $OpenBSD: term_entry.h,v 1.3 1999/01/22 04:50:43 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -90,6 +90,9 @@ extern bool _nc_entry_match(char *, char *);
extern int _nc_resolve_uses(void);
extern void _nc_free_entries(ENTRY *);
+/* read_bsd_terminfo.c: terminfo.db reading */
+extern int _nc_read_bsd_terminfo_entry(const char * const, char * const, TERMTYPE *const);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/libcurses/tinfo/lib_setup.c b/lib/libcurses/tinfo/lib_setup.c
index 289309d4f65..7ff479cca77 100644
--- a/lib/libcurses/tinfo/lib_setup.c
+++ b/lib/libcurses/tinfo/lib_setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib_setup.c,v 1.1 1999/01/18 19:10:19 millert Exp $ */
+/* $OpenBSD: lib_setup.c,v 1.2 1999/01/22 04:50:43 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -240,14 +240,9 @@ static int grab_entry(const char *const tn, TERMTYPE *const tp)
/* return 1 if entry found, 0 if not found, -1 if database not accessible */
{
char filename[PATH_MAX];
- int status = 0;
- int _nc_read_bsd_terminfo_entry(const char *, TERMTYPE *); /* XXX */
+ int status;
-#ifdef __OpenBSD__
- status = _nc_read_bsd_terminfo_entry(tn, tp);
-#endif /* __OpenBSD__ */
-
- if (status != 1 && (status = _nc_read_entry(tn, filename, tp)) != 1) {
+ if ((status = _nc_read_entry(tn, filename, tp)) != 1) {
#ifndef PURE_TERMINFO
/*
diff --git a/lib/libcurses/tinfo/read_bsd_terminfo.c b/lib/libcurses/tinfo/read_bsd_terminfo.c
index 4e6c6fb1425..d59271078b6 100644
--- a/lib/libcurses/tinfo/read_bsd_terminfo.c
+++ b/lib/libcurses/tinfo/read_bsd_terminfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read_bsd_terminfo.c,v 1.1 1999/01/18 19:10:22 millert Exp $ */
+/* $OpenBSD: read_bsd_terminfo.c,v 1.2 1999/01/22 04:50:43 millert Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: read_bsd_terminfo.c,v 1.1 1999/01/18 19:10:22 millert Exp $";
+static char rcsid[] = "$OpenBSD: read_bsd_terminfo.c,v 1.2 1999/01/22 04:50:43 millert Exp $";
#endif
#include <curses.priv.h>
@@ -40,7 +40,7 @@ static char rcsid[] = "$OpenBSD: read_bsd_terminfo.c,v 1.1 1999/01/18 19:10:22 m
#include <term.h> /* lines, columns, cur_term */
#include <term_entry.h>
-#define PVECSIZ 32
+#define PVECSIZ 3 * 2
#define _PATH_TERMINFO "/usr/share/misc/terminfo"
/*
@@ -49,92 +49,113 @@ static char rcsid[] = "$OpenBSD: read_bsd_terminfo.c,v 1.1 1999/01/18 19:10:22 m
* Returns 1 on success, 0 on failure.
*/
int
-_nc_read_bsd_terminfo_entry(tn, tp)
- const char *tn;
- TERMTYPE *const tp;
+_nc_read_bsd_terminfo_entry(tn, filename, tp)
+ const char *const tn;
+ char *const filename;
+ TERMTYPE *const tp;
{
char *p;
- char *dummy;
+ char *capbuf;
char **fname;
- int i;
+ int i, pathcnt;
char envterm[PATH_MAX]; /* local copy of $TERMINFO */
char hometerm[PATH_MAX]; /* local copy of $HOME/.terminfo */
- char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
+ char *pathvec[PVECSIZ]; /* list of possible terminfo files */
char namecpy[MAX_NAME_SIZE+1];
long num;
size_t len;
fname = pathvec;
+ pathcnt = 1;
/* $TERMINFO may hold a path to a terminfo file */
if (!issetugid() && (p = getenv("TERMINFO")) != NULL) {
len = strlcpy(envterm, p, sizeof(envterm));
if (len < sizeof(envterm))
+ pathcnt++;
*fname++ = envterm;
+ *fname++ = NULL;
}
/* Also check $HOME/.terminfo if it exists */
if (!issetugid() && (p = getenv("HOME")) != NULL) {
len = snprintf(hometerm, sizeof(hometerm), "%s/.terminfo", p);
if (len < sizeof(hometerm))
+ pathcnt++;
*fname++ = hometerm;
+ *fname++ = NULL;
}
- /* Finally we check the system terminfo file and mark the end of vector */
+ /* Finally we check the system terminfo file */
*fname++ = _PATH_TERMINFO;
- *fname = (char *) 0;
+ *fname = NULL;
+ /* Don't prepent any hardcoded entries. */
(void) cgetset(NULL);
- dummy = NULL;
- i = cgetent(&dummy, pathvec, (char *)tn);
-
- if (i == 0) {
- _nc_init_entry(tp);
- /* Set terminal name(s) */
- if ((p = strchr(dummy, ':')) != NULL)
- *p = '\0';
- if ((tp->str_table = tp->term_names = strdup(dummy)) == NULL)
- return (0);
- _nc_set_type(_nc_first_name(tp->term_names));
- if (p)
- *p = ':';
+ /*
+ * We can't pass a normal vector in to cgetent(3) because
+ * we need to know which of the paths in pathvec we actually
+ * used (for the filename copyout parameter).
+ * Therefore, we kludge things a bit...
+ */
+ for (fname = pathvec, i = 1; fname != pathvec + pathcnt * 2 && i != 0; ) {
+ capbuf = NULL;
+ i = cgetent(&capbuf, fname, (char *)tn);
+
+ if (i == 0) {
+ /* Set copyout parameter and init term description */
+ (void)strlcpy(filename, *fname, PATH_MAX);
+ _nc_init_entry(tp);
- /* Truncate overly-long names and aliases */
- (void)strlcpy(namecpy, tp->term_names, sizeof(namecpy));
- if ((p = strrchr(namecpy, '|')) != (char *)NULL)
- *p = '\0';
- p = strtok(namecpy, "|");
- if (strlen(p) > MAX_ALIAS)
- _nc_warning("primary name may be too long");
- while ((p = strtok((char *)NULL, "|")) != (char *)NULL)
+ /* Set terminal name(s) */
+ if ((p = strchr(capbuf, ':')) != NULL)
+ *p = '\0';
+ if ((tp->str_table = tp->term_names = strdup(capbuf)) == NULL)
+ return (0);
+ _nc_set_type(_nc_first_name(tp->term_names));
+ if (p)
+ *p = ':';
+
+ /* Truncate overly-long names and aliases */
+ (void)strlcpy(namecpy, tp->term_names, sizeof(namecpy));
+ if ((p = strrchr(namecpy, '|')) != (char *)NULL)
+ *p = '\0';
+ p = strtok(namecpy, "|");
if (strlen(p) > MAX_ALIAS)
- _nc_warning("alias `%s' may be too long", p);
+ _nc_warning("primary name may be too long");
+ while ((p = strtok((char *)NULL, "|")) != (char *)NULL)
+ if (strlen(p) > MAX_ALIAS)
+ _nc_warning("alias `%s' may be too long", p);
- /* Copy capabilities */
- for (i = 0 ; i < BOOLCOUNT ; i++) {
- if (cgetcap(dummy, (char *)boolnames[i], ':') == NULL)
- tp->Booleans[i] = FALSE;
- else
- tp->Booleans[i] = TRUE;
- }
- for (i = 0 ; i < NUMCOUNT ; i++) {
- if (cgetnum(dummy, (char *)numnames[i], &num) < 0)
- tp->Numbers[i] = 0;
- else
- tp->Numbers[i] = (int)num;
- }
- for (i = 0 ; i < STRCOUNT ; i++) {
- if (cgetstr(dummy, (char *)strnames[i], &p) < 0)
- tp->Strings[i] = NULL;
- else
- tp->Strings[i] = p;
+ /* Copy capabilities */
+ for (i = 0 ; i < BOOLCOUNT ; i++) {
+ if (cgetcap(capbuf, (char *)boolnames[i], ':') == NULL)
+ tp->Booleans[i] = FALSE;
+ else
+ tp->Booleans[i] = TRUE;
+ }
+ for (i = 0 ; i < NUMCOUNT ; i++) {
+ if (cgetnum(capbuf, (char *)numnames[i], &num) < 0)
+ tp->Numbers[i] = 0;
+ else
+ tp->Numbers[i] = (int)num;
+ }
+ for (i = 0 ; i < STRCOUNT ; i++) {
+ if (cgetstr(capbuf, (char *)strnames[i], &p) < 0)
+ tp->Strings[i] = NULL;
+ else
+ tp->Strings[i] = p;
+ }
+ i = 0;
}
- i = 0;
- }
+ /* Increment by two since we have that NULL in there */
+ fname += 2;
- /* We are done with the returned getcap buffer now; free it */
- if (dummy)
- free(dummy);
+ /* We are done with the returned getcap buffer now; free it */
+ cgetclose();
+ if (capbuf)
+ free(capbuf);
+ }
return ((i == 0));
}
diff --git a/lib/libcurses/tinfo/read_entry.c b/lib/libcurses/tinfo/read_entry.c
index 9ebf0779912..01503550ff9 100644
--- a/lib/libcurses/tinfo/read_entry.c
+++ b/lib/libcurses/tinfo/read_entry.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read_entry.c,v 1.1 1999/01/18 19:10:22 millert Exp $ */
+/* $OpenBSD: read_entry.c,v 1.2 1999/01/22 04:50:43 millert Exp $ */
/****************************************************************************
* Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -48,6 +48,7 @@
#include <term.h>
#include <tic.h>
+#include <term_entry.h>
MODULE_ID("$From: read_entry.c,v 1.47 1998/12/20 02:51:50 tom Exp $")
@@ -325,6 +326,12 @@ int _nc_read_entry(const char *const tn, char *const filename, TERMTYPE *const t
char *envp;
char ttn[MAX_ALIAS + 3];
+#ifdef __OpenBSD__
+ /* First check the BSD terminfo.db file */
+ if (_nc_read_bsd_terminfo_entry(tn, filename, tp) == 1)
+ return 1;
+#endif /* __OpenBSD__ */
+
/* truncate the terminal name to prevent dangerous buffer airline */
(void) sprintf(ttn, "%c/%.*s", *tn, MAX_ALIAS, tn);