Commit | Line | Data |
---|---|---|
11dcbb27 | 1 | #ifndef lint |
6668bd52 | 2 | static char sccsid[] = "@(#)ttinit.c 3.15 %G%"; |
11dcbb27 EW |
3 | #endif |
4 | ||
60de5df9 EW |
5 | /* |
6 | * Copyright (c) 1983 Regents of the University of California, | |
7 | * All rights reserved. Redistribution permitted subject to | |
8 | * the terms of the Berkeley Software License Agreement. | |
9 | */ | |
10 | ||
11dcbb27 | 11 | #include "ww.h" |
e908bfac | 12 | #include "tt.h" |
11dcbb27 | 13 | |
b27a9cfb EW |
14 | int tt_h19(); |
15 | int tt_h29(); | |
16 | int tt_f100(); | |
3ea27f21 | 17 | int tt_tvi925(); |
6668bd52 | 18 | int tt_zentec(); |
b27a9cfb EW |
19 | int tt_generic(); |
20 | struct tt_tab tt_tab[] = { | |
21 | { "h19", 3, tt_h19 }, | |
22 | { "h29", 3, tt_h29 }, | |
23 | { "f100", 4, tt_f100 }, | |
3ea27f21 | 24 | { "tvi925", 6, tt_tvi925 }, |
6668bd52 | 25 | { "zentec", 6, tt_zentec }, |
b27a9cfb EW |
26 | { "generic", 0, tt_generic }, |
27 | 0 | |
28 | }; | |
29 | ||
11dcbb27 EW |
30 | ttinit() |
31 | { | |
32 | register struct tt_tab *tp; | |
078fe826 EW |
33 | register char *p, *q; |
34 | register char *t; | |
b27a9cfb | 35 | struct winsize winsize; |
11dcbb27 | 36 | |
4222244b EW |
37 | tt_strp = tt_strings; |
38 | ||
b1189050 EW |
39 | /* |
40 | * Set output buffer size to about 1 second of output time. | |
41 | */ | |
42 | tt_obp = tt_ob; | |
43 | tt_obe = tt_ob + MIN(wwbaud/10, sizeof tt_ob); | |
44 | ||
078fe826 EW |
45 | /* |
46 | * Use the standard name of the terminal (i.e. the second | |
47 | * name in termcap). | |
48 | */ | |
49 | for (p = wwtermcap; *p && *p != '|' && *p != ':'; p++) | |
50 | ; | |
51 | if (*p == '|') | |
52 | p++; | |
53 | for (q = p; *q && *q != '|' && *q != ':'; q++) | |
54 | ; | |
94c16993 | 55 | if (q != p && (t = malloc((unsigned) (q - p + 1))) != 0) { |
078fe826 EW |
56 | wwterm = t; |
57 | while (p < q) | |
58 | *t++ = *p++; | |
59 | *t = 0; | |
60 | } | |
11dcbb27 EW |
61 | for (tp = tt_tab; tp->tt_name != 0; tp++) |
62 | if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0) | |
63 | break; | |
03e75950 EW |
64 | if (tp->tt_name == 0) { |
65 | wwerrno = WWE_BADTERM; | |
11dcbb27 | 66 | return -1; |
03e75950 EW |
67 | } |
68 | if ((*tp->tt_func)() < 0) { | |
69 | wwerrno = WWE_CANTDO; | |
70 | return -1; | |
71 | } | |
edc20be7 EW |
72 | if (ioctl(0, (int)TIOCGWINSZ, (char *)&winsize) >= 0 && |
73 | winsize.ws_row != 0 && winsize.ws_col != 0) { | |
b27a9cfb EW |
74 | tt.tt_nrow = winsize.ws_row; |
75 | tt.tt_ncol = winsize.ws_col; | |
76 | } | |
03e75950 | 77 | return 0; |
11dcbb27 | 78 | } |