version 1.8, 1999/12/30 16:58:22 |
version 1.9, 2000/10/10 15:41:11 |
|
|
*/ |
*/ |
|
|
#include "telnet_locl.h" |
#include "telnet_locl.h" |
|
#include <curses.h> |
|
#include <term.h> |
|
|
#define strip(x) (eight ? (x) : ((x) & 0x7f)) |
#define strip(x) (eight ? (x) : ((x) & 0x7f)) |
|
|
|
|
} |
} |
|
|
/* |
/* |
* Given a buffer returned by tgetent(), this routine will turn |
* This routine will turn a pipe seperated list of names in the buffer |
* the pipe seperated list of names in the buffer into an array |
* into an array of pointers to NUL terminated names. We toss out any |
* of pointers to null terminated names. We toss out any bad, |
* bad, duplicate, or verbose names (names with spaces). |
* duplicate, or verbose names (names with spaces). |
|
*/ |
*/ |
|
|
int is_unique P((char *, char **, char **)); |
int is_unique P((char *, char **, char **)); |
|
|
/* |
/* |
* Count up the number of names. |
* Count up the number of names. |
*/ |
*/ |
for (n = 1, cp = buf; *cp && *cp != ':'; cp++) { |
for (n = 1, cp = buf; *cp; cp++) { |
if (*cp == '|') |
if (*cp == '|') |
n++; |
n++; |
} |
} |
|
|
return (1); |
return (1); |
} |
} |
|
|
static char termbuf[1024]; |
|
|
|
/*ARGSUSED*/ |
|
int |
|
telnet_setupterm(tname, fd, errp) |
|
char *tname; |
|
int fd, *errp; |
|
{ |
|
if (tgetent(termbuf, tname) == 1) { |
|
termbuf[1023] = '\0'; |
|
if (errp) |
|
*errp = 1; |
|
return(0); |
|
} |
|
if (errp) |
|
*errp = 0; |
|
return(-1); |
|
} |
|
|
|
int resettermname = 1; |
int resettermname = 1; |
|
|
char * |
char * |
|
|
char *tname; |
char *tname; |
static char **tnamep = 0; |
static char **tnamep = 0; |
static char **next; |
static char **next; |
int err; |
|
|
|
if (resettermname) { |
if (resettermname) { |
resettermname = 0; |
resettermname = 0; |
if (tnamep && tnamep != unknown) |
if (tnamep && tnamep != unknown) |
free(tnamep); |
free(tnamep); |
if ((tname = (char *)env_getvalue((unsigned char *)"TERM")) && |
if ((tname = (char *)env_getvalue((unsigned char *)"TERM")) && |
(telnet_setupterm(tname, 1, &err) == 0)) { |
(setupterm(tname, 1, NULL) == OK)) { |
tnamep = mklist(termbuf, tname); |
tnamep = mklist(ttytype, tname); |
} else { |
} else { |
if (tname && ((int)strlen(tname) <= 40)) { |
if (tname && ((int)strlen(tname) <= 40)) { |
unknown[0] = tname; |
unknown[0] = tname; |