Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libterminfo There is no standard way of getting a list o...



details:   https://anonhg.NetBSD.org/src/rev/47f633a0d658
branches:  trunk
changeset: 770136:47f633a0d658
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Oct 05 10:46:08 2011 +0000

description:
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.

diffstat:

 lib/libterminfo/curterm.c |  46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 44 insertions(+), 2 deletions(-)

diffs (83 lines):

diff -r 26ab0da3b81b -r 47f633a0d658 lib/libterminfo/curterm.c
--- a/lib/libterminfo/curterm.c Wed Oct 05 10:10:31 2011 +0000
+++ b/lib/libterminfo/curterm.c Wed Oct 05 10:46:08 2011 +0000
@@ -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.
@@ -28,16 +28,29 @@
  */
 
 #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 <stdlib.h>
+#include <string.h>
 #include <term_private.h>
 #include <term.h>
 #include <termios.h>
 #include <stdio.h>
+
 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[] = {
        0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 2400, 4800, 9600,
        19200, 38400, 57600, 115200, 230400, 460800, 921600
@@ -67,6 +80,8 @@
 set_curterm(TERMINAL *nterm)
 {
        TERMINAL *oterm;
+       size_t l, n;
+       char *p;
 
        oterm = cur_term;
        cur_term = nterm;
@@ -81,6 +96,33 @@
                        PC = *pad_char;
                _ti_setospeed(nterm);
                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;



Home | Main Index | Thread Index | Old Index