Add termname(3) as defined by POSIX.

This commit is contained in:
roy 2011-10-02 19:24:25 +00:00
parent 8086112a88
commit fd2d10c6b0
4 changed files with 27 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.13 2011/08/16 10:36:30 christos Exp $
# $NetBSD: Makefile,v 1.14 2011/10/02 19:24:25 roy Exp $
USE_SHLIBDIR= yes
@ -15,6 +15,7 @@ INCSDIR= /usr/include
MAN= terminfo.3 terminfo.5
MLINKS= terminfo.3 setupterm.3 \
terminfo.3 set_curterm.3 terminfo.3 del_curterm.3 \
terminfo.3 termname.3 \
terminfo.3 tigetnum.3 terminfo.3 tigetflag.3 \
terminfo.3 tigetstr.3 terminfo.3 tparm.3 terminfo.3 tputs.3 \
terminfo.3 putp.3 \

View File

@ -1,7 +1,7 @@
/* $NetBSD: curterm.c,v 1.4 2010/02/22 23:05:39 roy Exp $ */
/* $NetBSD: curterm.c,v 1.5 2011/10/02 19:24:25 roy Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* Copyright (c) 2009, 2011 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: curterm.c,v 1.4 2010/02/22 23:05:39 roy Exp $");
__RCSID("$NetBSD: curterm.c,v 1.5 2011/10/02 19:24:25 roy Exp $");
#include <assert.h>
#include <stdlib.h>
@ -90,6 +90,15 @@ int
del_curterm(TERMINAL *oterm)
{
_DIAGASSERT(oterm != NULL);
_ti_freeterm(oterm);
return 0;
}
char *
termname(void)
{
_DIAGASSERT(cur_term != NULL);
return __UNCONST(cur_term->name);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: term.h,v 1.7 2011/04/11 21:13:09 roy Exp $ */
/* $NetBSD: term.h,v 1.8 2011/10/02 19:24:25 roy Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@ -1468,6 +1468,7 @@ extern TERMINAL *cur_term;
int setupterm(const char *, int, int *);
TERMINAL * set_curterm(TERMINAL *);
int del_curterm(TERMINAL *);
char * termname(void);
/* information functions */
int tigetflag(const char *);

View File

@ -1,6 +1,6 @@
.\" $NetBSD: terminfo.3,v 1.4 2010/02/04 09:12:56 wiz Exp $
.\" $NetBSD: terminfo.3,v 1.5 2011/10/02 19:24:25 roy Exp $
.\"
.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
.\" Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
@ -27,13 +27,14 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd December 7, 2009
.Dd October 2, 2011
.Dt TERMINFO 3
.Os
.Sh NAME
.Nm setupterm ,
.Nm set_curterm ,
.Nm del_curterm ,
.Nm termname ,
.Nm tigetflag ,
.Nm tigetnum ,
.Nm tigetstr ,
@ -54,6 +55,8 @@
.Fn set_curterm "TERMINAL *term"
.Ft int
.Fn del_curterm "TERMINAL *term"
.Ft char *
.Fn termname "void"
.Ft int
.Fn tigetnum "const char *id"
.Ft int
@ -144,6 +147,11 @@ function frees space pointed to by
.Va oterm .
.Pp
The
.Fn termname
function returns the name of
.Va cur_term .
.Pp
The
.Fn tigetflag
function gets the boolean value of capability
.Va id ,