[BACK]Return to ttinit.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / window

Annotation of src/usr.bin/window/ttinit.c, Revision 1.1.1.1

1.1       deraadt     1: /*     $NetBSD: ttinit.c,v 1.3 1995/09/28 10:34:50 tls Exp $   */
                      2:
                      3: /*
                      4:  * Copyright (c) 1983, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to Berkeley by
                      8:  * Edward Wang at The University of California, Berkeley.
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  * 3. All advertising materials mentioning features or use of this software
                     19:  *    must display the following acknowledgement:
                     20:  *     This product includes software developed by the University of
                     21:  *     California, Berkeley and its contributors.
                     22:  * 4. Neither the name of the University nor the names of its contributors
                     23:  *    may be used to endorse or promote products derived from this software
                     24:  *    without specific prior written permission.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     27:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     28:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     29:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     30:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     31:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     32:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     36:  * SUCH DAMAGE.
                     37:  */
                     38:
                     39: #ifndef lint
                     40: #if 0
                     41: static char sccsid[] = "@(#)ttinit.c   8.1 (Berkeley) 6/6/93";
                     42: #else
                     43: static char rcsid[] = "$NetBSD: ttinit.c,v 1.3 1995/09/28 10:34:50 tls Exp $";
                     44: #endif
                     45: #endif /* not lint */
                     46:
                     47: #include "ww.h"
                     48: #include "tt.h"
                     49:
                     50: int tt_h19();
                     51: int tt_h29();
                     52: int tt_f100();
                     53: int tt_tvi925();
                     54: int tt_wyse75();
                     55: int tt_wyse60();
                     56: int tt_zapple();
                     57: int tt_zentec();
                     58: int tt_generic();
                     59: struct tt_tab tt_tab[] = {
                     60:        { "h19",        3, tt_h19 },
                     61:        { "h29",        3, tt_h29 },
                     62:        { "f100",       4, tt_f100 },
                     63:        { "tvi925",     6, tt_tvi925 },
                     64:        { "wyse75",     6, tt_wyse75 },
                     65:        { "wyse60",     6, tt_wyse60 },
                     66:        { "w60",        3, tt_wyse60 },
                     67:        { "zapple",     6, tt_zapple },
                     68:        { "zentec",     6, tt_zentec },
                     69:        { "generic",    0, tt_generic },
                     70:        0
                     71: };
                     72:
                     73: ttinit()
                     74: {
                     75:        int i;
                     76:        register struct tt_tab *tp;
                     77:        register char *p, *q;
                     78:        register char *t;
                     79:
                     80:        tt_strp = tt_strings;
                     81:
                     82:        /*
                     83:         * Set output buffer size to about 1 second of output time.
                     84:         */
                     85:        i = MIN(wwbaud/10, 512);
                     86:        if ((tt_ob = malloc((unsigned) i)) == 0) {
                     87:                wwerrno = WWE_NOMEM;
                     88:                return -1;
                     89:        }
                     90:        tt_obp = tt_ob;
                     91:        tt_obe = tt_ob + i;
                     92:
                     93:        /*
                     94:         * Use the standard name of the terminal (i.e. the second
                     95:         * name in termcap).
                     96:         */
                     97:        for (p = wwtermcap; *p && *p != '|' && *p != ':'; p++)
                     98:                ;
                     99:        if (*p == '|')
                    100:                p++;
                    101:        for (q = p; *q && *q != '|' && *q != ':'; q++)
                    102:                ;
                    103:        if (q != p && (t = malloc((unsigned) (q - p + 1))) != 0) {
                    104:                wwterm = t;
                    105:                while (p < q)
                    106:                        *t++ = *p++;
                    107:                *t = 0;
                    108:        }
                    109:        for (tp = tt_tab; tp->tt_name != 0; tp++)
                    110:                if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
                    111:                        break;
                    112:        if (tp->tt_name == 0) {
                    113:                wwerrno = WWE_BADTERM;
                    114:                return -1;
                    115:        }
                    116:        if ((*tp->tt_func)() < 0) {
                    117:                wwerrno = WWE_CANTDO;
                    118:                return -1;
                    119:        }
                    120:        if (wwgetttysize(0, &tt.tt_nrow, &tt.tt_ncol) < 0)
                    121:                return -1;
                    122:        tt.tt_scroll_top = 0;
                    123:        tt.tt_scroll_bot = tt.tt_nrow - 1;
                    124:        return 0;
                    125: }