Added new function t_getterm to return the name string of a termcap
entry since the "new" interface hid this information away.
This commit is contained in:
parent
11b0c60db2
commit
c833debc98
|
@ -1,5 +1,5 @@
|
|||
# $NetBSD: shlib_version,v 1.4 1999/08/16 08:34:33 blymn Exp $
|
||||
# $NetBSD: shlib_version,v 1.5 2000/04/19 13:41:28 blymn Exp $
|
||||
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||
#
|
||||
major=0
|
||||
minor=1
|
||||
minor=2
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: termcap.3,v 1.16 1999/10/04 23:16:50 lukem Exp $
|
||||
.\" $NetBSD: termcap.3,v 1.17 2000/04/19 13:41:28 blymn Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -74,6 +74,8 @@
|
|||
.Ft char *
|
||||
.Fn t_getstr "struct tinfo *info" "char *id" "char **area" "size_t *limit"
|
||||
.Ft int
|
||||
.Fn t_getterm "struct tinfo *info" "char **area" "size_t *limit"
|
||||
.Ft int
|
||||
.Fn t_goto "struct tinfo *info" "char *id" "int destcol" "int destline" "char *buffer" "size_t limit"
|
||||
.Ft int
|
||||
.Fn t_puts "struct tinfo *info" "char *cp" "int affcnt" "void (*outc)(char, void *)" "void *args"
|
||||
|
@ -316,7 +318,29 @@ If t_getstr is called with
|
|||
being NULL then the size required to hold the capability string will be
|
||||
returned in
|
||||
.Fa limit
|
||||
so the caller can allocate enough storage to hold the capability.
|
||||
so the caller can allocate enough storage to hold the capability. The
|
||||
function
|
||||
.Fn t_getterm
|
||||
returns a copy of the termcap name string of the termcap entry
|
||||
associated with
|
||||
.Fa info
|
||||
in the buffer pointed to by
|
||||
.Fa area .
|
||||
.Fn t_getterm
|
||||
returns 0 on success and -1 on error. On error errno will be set to
|
||||
EINVAL if the termcap entry in
|
||||
.Fa info
|
||||
is malformed or E2BIG if the size of the name exceeds the size
|
||||
specified by
|
||||
.Fa limit .
|
||||
If
|
||||
.Fa area
|
||||
is NULL then the size required to hold the terminal name will be
|
||||
returned in
|
||||
.Fa limit
|
||||
allowing sufficient storage to be allocated. If
|
||||
.Fa limit
|
||||
is NULL then no bounds checking will be performed.
|
||||
.Pp
|
||||
The
|
||||
.Fn t_goto
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: termcap.c,v 1.23 2000/04/18 14:42:42 blymn Exp $ */
|
||||
/* $NetBSD: termcap.c,v 1.24 2000/04/19 13:41:28 blymn Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1993
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: termcap.c,v 1.23 2000/04/18 14:42:42 blymn Exp $");
|
||||
__RCSID("$NetBSD: termcap.c,v 1.24 2000/04/19 13:41:28 blymn Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -291,6 +291,10 @@ t_getstr(info, id, area, limit)
|
|||
ids[1] = id[1];
|
||||
ids[2] = '\0';
|
||||
|
||||
if ((ids[0] == 'Z') && (ids[1] == 'Z')) {
|
||||
/* return info->info address??? */
|
||||
}
|
||||
|
||||
if ((i = cgetstr(info->info, ids, &s)) < 0) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
|
@ -348,3 +352,40 @@ t_freent(info)
|
|||
free(info->info);
|
||||
free(info);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the terminal name string from the termcap entry.
|
||||
*
|
||||
*/
|
||||
int
|
||||
t_getterm(struct tinfo *info, char **area, size_t *limit)
|
||||
{
|
||||
char *endp;
|
||||
size_t count;
|
||||
|
||||
if ((endp = index(info->info, ':')) == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
count = endp - info->info + 1;
|
||||
if (area == NULL) {
|
||||
*limit = count;
|
||||
return 0;
|
||||
} else {
|
||||
if ((limit != NULL) && (count > *limit)) {
|
||||
errno = E2BIG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(*area, info->info, count);
|
||||
(*area)[count] = '\0';
|
||||
if (limit != NULL)
|
||||
*limit -= count;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: termcap.h,v 1.9 2000/02/20 13:32:52 kleink Exp $ */
|
||||
/* $NetBSD: termcap.h,v 1.10 2000/04/19 13:41:29 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -60,6 +60,7 @@ int t_getent __P((struct tinfo **, const char *));
|
|||
int t_getnum __P((struct tinfo *, const char *));
|
||||
int t_getflag __P((struct tinfo *, const char *));
|
||||
char *t_getstr __P((struct tinfo *, const char *, char **, size_t *));
|
||||
int t_getterm(struct tinfo *info, char **area, size_t *limit);
|
||||
int t_goto __P((struct tinfo *, const char *, int, int, char *, size_t));
|
||||
int t_puts __P((struct tinfo *, const char *, int,
|
||||
void (*)(char, void *), void *));
|
||||
|
|
Loading…
Reference in New Issue