WWM_GRP added
[unix-history] / usr / src / usr.bin / window / ttinit.c
#ifndef lint
static char *sccsid = "@(#)ttinit.c 3.7 83/12/17";
#endif
#include "ww.h"
#include "tt.h"
ttinit()
{
register struct tt_tab *tp;
register char *p, *q;
register char *t;
/*
* Use the standard name of the terminal (i.e. the second
* name in termcap).
*/
for (p = wwtermcap; *p && *p != '|' && *p != ':'; p++)
;
if (*p == '|')
p++;
for (q = p; *q && *q != '|' && *q != ':'; q++)
;
if (q != p && (t = malloc((unsigned) (q - p + 1))) != 0) {
wwterm = t;
while (p < q)
*t++ = *p++;
*t = 0;
}
for (tp = tt_tab; tp->tt_name != 0; tp++)
if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
break;
if (tp->tt_name == 0) {
wwerrno = WWE_BADTERM;
return -1;
}
if ((*tp->tt_func)() < 0) {
wwerrno = WWE_CANTDO;
return -1;
}
return 0;
}