Annotation of 43BSDTahoe/ucb/window/ttinit.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that the above copyright notice and this paragraph are
        !             7:  * duplicated in all such forms and that any documentation,
        !             8:  * advertising materials, and other materials related to such
        !             9:  * distribution and use acknowledge that the software was developed
        !            10:  * by the University of California, Berkeley.  The name of the
        !            11:  * University may not be used to endorse or promote products derived
        !            12:  * from this software without specific prior written permission.
        !            13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            16:  */
        !            17: 
        !            18: #ifndef lint
        !            19: static char sccsid[] = "@(#)ttinit.c   3.20 (Berkeley) 6/29/88";
        !            20: #endif /* not lint */
        !            21: 
        !            22: #include "ww.h"
        !            23: #include "tt.h"
        !            24: 
        !            25: int tt_h19();
        !            26: int tt_h29();
        !            27: int tt_f100();
        !            28: int tt_tvi925();
        !            29: int tt_wyse75();
        !            30: int tt_wyse60();
        !            31: int tt_zentec();
        !            32: int tt_generic();
        !            33: struct tt_tab tt_tab[] = {
        !            34:        { "h19",        3, tt_h19 },
        !            35:        { "h29",        3, tt_h29 },
        !            36:        { "f100",       4, tt_f100 },
        !            37:        { "tvi925",     6, tt_tvi925 },
        !            38:        { "wyse75",     6, tt_wyse75 },
        !            39:        { "wyse60",     6, tt_wyse60 },
        !            40:        { "w60",        3, tt_wyse60 },
        !            41:        { "zentec",     6, tt_zentec },
        !            42:        { "generic",    0, tt_generic },
        !            43:        0
        !            44: };
        !            45: 
        !            46: ttinit()
        !            47: {
        !            48:        register struct tt_tab *tp;
        !            49:        register char *p, *q;
        !            50:        register char *t;
        !            51:        struct winsize winsize;
        !            52: 
        !            53:        tt_strp = tt_strings;
        !            54: 
        !            55:        /*
        !            56:         * Set output buffer size to about 1 second of output time.
        !            57:         */
        !            58:        tt_obp = tt_ob;
        !            59:        tt_obe = tt_ob + MIN(wwbaud/10, sizeof tt_ob);
        !            60: 
        !            61:        /*
        !            62:         * Use the standard name of the terminal (i.e. the second
        !            63:         * name in termcap).
        !            64:         */
        !            65:        for (p = wwtermcap; *p && *p != '|' && *p != ':'; p++)
        !            66:                ;
        !            67:        if (*p == '|')
        !            68:                p++;
        !            69:        for (q = p; *q && *q != '|' && *q != ':'; q++)
        !            70:                ;
        !            71:        if (q != p && (t = malloc((unsigned) (q - p + 1))) != 0) {
        !            72:                wwterm = t;
        !            73:                while (p < q)
        !            74:                        *t++ = *p++;
        !            75:                *t = 0;
        !            76:        }
        !            77:        for (tp = tt_tab; tp->tt_name != 0; tp++)
        !            78:                if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
        !            79:                        break;
        !            80:        if (tp->tt_name == 0) {
        !            81:                wwerrno = WWE_BADTERM;
        !            82:                return -1;
        !            83:        }
        !            84:        if ((*tp->tt_func)() < 0) {
        !            85:                wwerrno = WWE_CANTDO;
        !            86:                return -1;
        !            87:        }
        !            88:        tt.tt_scroll_top = 0;
        !            89:        tt.tt_scroll_bot = tt.tt_nrow - 1;
        !            90:        if (ioctl(0, TIOCGWINSZ, (char *)&winsize) >= 0 &&
        !            91:            winsize.ws_row != 0 && winsize.ws_col != 0) {
        !            92:                tt.tt_nrow = winsize.ws_row;
        !            93:                tt.tt_ncol = winsize.ws_col;
        !            94:        }
        !            95:        return 0;
        !            96: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.