There is no standard way of getting a list of aliases for the
terminal. However, some applications such as telnet want to know this. ncurses dumps the terminfo header into an undefined variable ttytype and these applications then parse it to work out the aliases. We should do the same for now, until a standard mechanism for getting the information is available or the need for it goes away.
This commit is contained in:
parent
efb47b42e6
commit
62480e1c72
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: curterm.c,v 1.7 2011/10/04 11:01:14 roy Exp $ */
|
/* $NetBSD: curterm.c,v 1.8 2011/10/05 10:46:08 roy Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
|
* Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
|
||||||
|
@ -28,16 +28,29 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: curterm.c,v 1.7 2011/10/04 11:01:14 roy Exp $");
|
__RCSID("$NetBSD: curterm.c,v 1.8 2011/10/05 10:46:08 roy Exp $");
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <term_private.h>
|
#include <term_private.h>
|
||||||
#include <term.h>
|
#include <term.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
TERMINAL *cur_term;
|
TERMINAL *cur_term;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* There is no standard way of getting a list of aliases for the
|
||||||
|
* terminal. However, some applications such as telnet want to know this.
|
||||||
|
* ncurses dumps the terminfo header into an undefined variable ttytype
|
||||||
|
* and these applications then parse it to work out the aliases.
|
||||||
|
* We should do the same for now, until a standard mechanism for getting
|
||||||
|
* the information is available or the need for it goes away.
|
||||||
|
*/
|
||||||
|
#define NAMESIZE 256
|
||||||
|
char ttytype[NAMESIZE];
|
||||||
|
|
||||||
static const speed_t bauds[] = {
|
static const speed_t bauds[] = {
|
||||||
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 2400, 4800, 9600,
|
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 2400, 4800, 9600,
|
||||||
19200, 38400, 57600, 115200, 230400, 460800, 921600
|
19200, 38400, 57600, 115200, 230400, 460800, 921600
|
||||||
|
@ -67,6 +80,8 @@ TERMINAL *
|
||||||
set_curterm(TERMINAL *nterm)
|
set_curterm(TERMINAL *nterm)
|
||||||
{
|
{
|
||||||
TERMINAL *oterm;
|
TERMINAL *oterm;
|
||||||
|
size_t l, n;
|
||||||
|
char *p;
|
||||||
|
|
||||||
oterm = cur_term;
|
oterm = cur_term;
|
||||||
cur_term = nterm;
|
cur_term = nterm;
|
||||||
|
@ -81,6 +96,33 @@ set_curterm(TERMINAL *nterm)
|
||||||
PC = *pad_char;
|
PC = *pad_char;
|
||||||
_ti_setospeed(nterm);
|
_ti_setospeed(nterm);
|
||||||
ospeed = nterm->_ospeed;
|
ospeed = nterm->_ospeed;
|
||||||
|
|
||||||
|
p = ttytype;
|
||||||
|
l = sizeof(ttytype);
|
||||||
|
if ((n = strlcpy(p, nterm->name, l)) == strlen(p)) {
|
||||||
|
p += n;
|
||||||
|
l -= n;
|
||||||
|
*p++ = '|';
|
||||||
|
l--;
|
||||||
|
if (nterm->_alias &&
|
||||||
|
(n = strlcpy(p, nterm->_alias, l)) == strlen(p))
|
||||||
|
{
|
||||||
|
p += n;
|
||||||
|
l -= n;
|
||||||
|
*p++ = '|';
|
||||||
|
l--;
|
||||||
|
}
|
||||||
|
if (nterm->desc &&
|
||||||
|
(n = strlcpy(p, nterm->desc, l)) == strlen(p))
|
||||||
|
{
|
||||||
|
p += n;
|
||||||
|
l -= n;
|
||||||
|
*p++ = '|';
|
||||||
|
l--;
|
||||||
|
}
|
||||||
|
p--;
|
||||||
|
}
|
||||||
|
*p = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
return oterm;
|
return oterm;
|
||||||
|
|
Loading…
Reference in New Issue