Module Name:    src
Committed By:   roy
Date:           Wed Oct  5 10:46:08 UTC 2011

Modified Files:
        src/lib/libterminfo: curterm.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libterminfo/curterm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libterminfo/curterm.c
diff -u src/lib/libterminfo/curterm.c:1.7 src/lib/libterminfo/curterm.c:1.8
--- src/lib/libterminfo/curterm.c:1.7	Tue Oct  4 11:01:14 2011
+++ src/lib/libterminfo/curterm.c	Wed Oct  5 10:46:08 2011
@@ -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 @@ TERMINAL *
 set_curterm(TERMINAL *nterm)
 {
 	TERMINAL *oterm;
+	size_t l, n;
+	char *p;
 
 	oterm = cur_term;
 	cur_term = nterm;
@@ -81,6 +96,33 @@ set_curterm(TERMINAL *nterm)
 			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;

Reply via email to