Annotation of 43BSDReno/usr.bin/window/tttermcap.c, revision 1.1

1.1     ! root        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:  * Redistribution and use in source and binary forms are permitted provided
        !             9:  * that: (1) source distributions retain this entire copyright notice and
        !            10:  * comment, and (2) distributions including binaries display the following
        !            11:  * acknowledgement:  ``This product includes software developed by the
        !            12:  * University of California, Berkeley and its contributors'' in the
        !            13:  * documentation or other materials provided with the distribution and in
        !            14:  * all advertising materials mentioning features or use of this software.
        !            15:  * Neither the name of the University nor the names of its contributors may
        !            16:  * be used to endorse or promote products derived from this software without
        !            17:  * specific prior written permission.
        !            18:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            19:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            20:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            21:  */
        !            22: 
        !            23: #ifndef lint
        !            24: static char sccsid[] = "@(#)tttermcap.c        3.12 (Berkeley) 6/6/90";
        !            25: #endif /* not lint */
        !            26: 
        !            27: #include "tt.h"
        !            28: 
        !            29: char *tgetstr();
        !            30: char *tgoto();
        !            31: char *malloc();
        !            32: 
        !            33: tttputc(c)
        !            34: {
        !            35:        ttputc(c);
        !            36: }
        !            37: 
        !            38: ttxputc(c)
        !            39: {
        !            40:        *tt_strp++ = c;
        !            41: }
        !            42: 
        !            43: struct tt_str *
        !            44: tttgetstr(str)
        !            45:        char *str;
        !            46: {
        !            47:        register struct tt_str *s;
        !            48: 
        !            49:        if ((str = tgetstr(str, &tt_strp)) == 0)
        !            50:                return 0;
        !            51:        if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
        !            52:                return 0;
        !            53:        s->ts_str = str;
        !            54:        s->ts_n = tt_strp - s->ts_str - 1;
        !            55:        return s;
        !            56: }
        !            57: 
        !            58: struct tt_str *
        !            59: ttxgetstr(str)
        !            60:        char *str;
        !            61: {
        !            62:        register struct tt_str *s;
        !            63:        char buf[100];
        !            64:        char *bufp = buf;
        !            65: 
        !            66:        if (tgetstr(str, &bufp) == 0)
        !            67:                return 0;
        !            68:        if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
        !            69:                return 0;
        !            70:        s->ts_str = tt_strp;
        !            71:        tputs(buf, 1, ttxputc);
        !            72:        s->ts_n = tt_strp - s->ts_str;
        !            73:        *tt_strp++ = 0;
        !            74:        return s;
        !            75: }
        !            76: 
        !            77: tttgoto(s, col, row)
        !            78:        struct tt_str *s;
        !            79: {
        !            80:        register char *p = s->ts_str;
        !            81: 
        !            82:        ttputs(tgoto(p, col, row));
        !            83:        for (p += s->ts_n; *--p == 0;)
        !            84:                ttputc(0);
        !            85: }
        !            86: 
        !            87: ttpgoto(s, col, row, n)
        !            88:        struct tt_str *s;
        !            89: {
        !            90: 
        !            91:        tputs(tgoto(s->ts_str, col, row), n, tttputc);
        !            92: }
        !            93: 
        !            94: ttstrcmp(a, b)
        !            95:        register struct tt_str *a, *b;
        !            96: {
        !            97:        int n, r;
        !            98: 
        !            99:        if (r = bcmp(a->ts_str, b->ts_str,
        !           100:                        (n = a->ts_n - b->ts_n) < 0 ? a->ts_n : b->ts_n))
        !           101:                return r;
        !           102:        return n;
        !           103: }

unix.superglobalmegacorp.com

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