moving windows
[unix-history] / usr / src / usr.bin / window / ttinit.c
CommitLineData
11dcbb27 1#ifndef lint
03e75950 2static char *sccsid = "@(#)ttinit.c 3.6 83/08/26";
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
078fe826
EW
14 /*
15 * Use the standard name of the terminal (i.e. the second
16 * name in termcap).
17 */
18 for (p = wwtermcap; *p && *p != '|' && *p != ':'; p++)
19 ;
20 if (*p == '|')
21 p++;
22 for (q = p; *q && *q != '|' && *q != ':'; q++)
23 ;
94c16993 24 if (q != p && (t = malloc((unsigned) (q - p + 1))) != 0) {
078fe826
EW
25 wwterm = t;
26 while (p < q)
27 *t++ = *p++;
28 *t = 0;
29 }
11dcbb27
EW
30 for (tp = tt_tab; tp->tt_name != 0; tp++)
31 if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
32 break;
03e75950
EW
33 if (tp->tt_name == 0) {
34 wwerrno = WWE_BADTERM;
11dcbb27 35 return -1;
03e75950
EW
36 }
37 if ((*tp->tt_func)() < 0) {
38 wwerrno = WWE_CANTDO;
39 return -1;
40 }
41 return 0;
11dcbb27 42}