new sccs id
[unix-history] / usr / src / usr.bin / window / ttinit.c
CommitLineData
11dcbb27 1#ifndef lint
7edc52ec 2static char sccsid[] = "@(#)ttinit.c 3.10 %G%";
11dcbb27
EW
3#endif
4
5#include "ww.h"
e908bfac 6#include "tt.h"
11dcbb27
EW
7
8ttinit()
9{
10 register struct tt_tab *tp;
078fe826
EW
11 register char *p, *q;
12 register char *t;
11dcbb27 13
4222244b
EW
14 tt_strp = tt_strings;
15
b1189050
EW
16 /*
17 * Set output buffer size to about 1 second of output time.
18 */
19 tt_obp = tt_ob;
20 tt_obe = tt_ob + MIN(wwbaud/10, sizeof tt_ob);
21
078fe826
EW
22 /*
23 * Use the standard name of the terminal (i.e. the second
24 * name in termcap).
25 */
26 for (p = wwtermcap; *p && *p != '|' && *p != ':'; p++)
27 ;
28 if (*p == '|')
29 p++;
30 for (q = p; *q && *q != '|' && *q != ':'; q++)
31 ;
94c16993 32 if (q != p && (t = malloc((unsigned) (q - p + 1))) != 0) {
078fe826
EW
33 wwterm = t;
34 while (p < q)
35 *t++ = *p++;
36 *t = 0;
37 }
11dcbb27
EW
38 for (tp = tt_tab; tp->tt_name != 0; tp++)
39 if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
40 break;
03e75950
EW
41 if (tp->tt_name == 0) {
42 wwerrno = WWE_BADTERM;
11dcbb27 43 return -1;
03e75950
EW
44 }
45 if ((*tp->tt_func)() < 0) {
46 wwerrno = WWE_CANTDO;
47 return -1;
48 }
49 return 0;
11dcbb27 50}