1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Edward Wang at The University of California, Berkeley. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #ifndef lint 12 static char sccsid[] = "@(#)ttinit.c 3.27 (Berkeley) 08/12/90"; 13 #endif /* not lint */ 14 15 #include "ww.h" 16 #include "tt.h" 17 18 int tt_h19(); 19 int tt_h29(); 20 int tt_f100(); 21 int tt_tvi925(); 22 int tt_wyse75(); 23 int tt_wyse60(); 24 int tt_zapple(); 25 int tt_zentec(); 26 int tt_generic(); 27 struct tt_tab tt_tab[] = { 28 { "h19", 3, tt_h19 }, 29 { "h29", 3, tt_h29 }, 30 { "f100", 4, tt_f100 }, 31 { "tvi925", 6, tt_tvi925 }, 32 { "wyse75", 6, tt_wyse75 }, 33 { "wyse60", 6, tt_wyse60 }, 34 { "w60", 3, tt_wyse60 }, 35 { "zapple", 6, tt_zapple }, 36 { "zentec", 6, tt_zentec }, 37 { "generic", 0, tt_generic }, 38 0 39 }; 40 41 ttinit() 42 { 43 int i; 44 register struct tt_tab *tp; 45 register char *p, *q; 46 register char *t; 47 int ttflush(); 48 49 tt_strp = tt_strings; 50 51 /* 52 * Set output buffer size to about 1 second of output time. 53 */ 54 i = MIN(wwbaud/10, 512); 55 if ((tt_ob = malloc((unsigned) i)) == 0) { 56 wwerrno = WWE_NOMEM; 57 return -1; 58 } 59 tt_obp = tt_ob; 60 tt_obe = tt_ob + i; 61 62 /* 63 * Use the standard name of the terminal (i.e. the second 64 * name in termcap). 65 */ 66 for (p = wwtermcap; *p && *p != '|' && *p != ':'; p++) 67 ; 68 if (*p == '|') 69 p++; 70 for (q = p; *q && *q != '|' && *q != ':'; q++) 71 ; 72 if (q != p && (t = malloc((unsigned) (q - p + 1))) != 0) { 73 wwterm = t; 74 while (p < q) 75 *t++ = *p++; 76 *t = 0; 77 } 78 for (tp = tt_tab; tp->tt_name != 0; tp++) 79 if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0) 80 break; 81 if (tp->tt_name == 0) { 82 wwerrno = WWE_BADTERM; 83 return -1; 84 } 85 if ((*tp->tt_func)() < 0) { 86 wwerrno = WWE_CANTDO; 87 return -1; 88 } 89 if (wwgetttysize(0, &tt.tt_nrow, &tt.tt_ncol) < 0) 90 return -1; 91 tt.tt_scroll_top = 0; 92 tt.tt_scroll_bot = tt.tt_nrow - 1; 93 tt.tt_flush = ttflush; 94 return 0; 95 } 96