compile with -R
[unix-history] / usr / src / usr.bin / window / ttinit.c
#ifndef lint
static char *sccsid = "@(#)ttinit.c 3.9 84/03/23";
#endif
#include "ww.h"
#include "tt.h"
ttinit()
{
register struct tt_tab *tp;
register char *p, *q;
register char *t;
tt_strp = tt_strings;
/*
* Set output buffer size to about 1 second of output time.
*/
tt_obp = tt_ob;
tt_obe = tt_ob + MIN(wwbaud/10, sizeof tt_ob);
/*
* 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;
}