optimization for normal masks requires keeping ptr to associated leaf,
[unix-history] / usr / src / usr.bin / window / tttermcap.c
CommitLineData
60de5df9 1/*
9733c4dd
KB
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
46e9ea25 4 *
3dd3a9e5
KB
5 * This code is derived from software contributed to Berkeley by
6 * Edward Wang at The University of California, Berkeley.
7 *
87f529ec 8 * %sccs.include.redist.c%
60de5df9
EW
9 */
10
46e9ea25 11#ifndef lint
9733c4dd 12static char sccsid[] = "@(#)tttermcap.c 8.1 (Berkeley) %G%";
46e9ea25
KB
13#endif /* not lint */
14
359d1214
EW
15#include "tt.h"
16
17char *tgetstr();
e1daf7d6
EW
18char *tgoto();
19char *malloc();
359d1214 20
b1189050 21tttputc(c)
359d1214 22{
b1189050 23 ttputc(c);
359d1214
EW
24}
25
b1189050 26ttxputc(c)
359d1214
EW
27{
28 *tt_strp++ = c;
29}
30
e1daf7d6
EW
31struct tt_str *
32tttgetstr(str)
33 char *str;
34{
35 register struct tt_str *s;
36
37 if ((str = tgetstr(str, &tt_strp)) == 0)
38 return 0;
39 if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
40 return 0;
41 s->ts_str = str;
42 s->ts_n = tt_strp - s->ts_str - 1;
43 return s;
44}
45
46struct tt_str *
b1189050 47ttxgetstr(str)
e1daf7d6 48 char *str;
359d1214 49{
e1daf7d6 50 register struct tt_str *s;
359d1214
EW
51 char buf[100];
52 char *bufp = buf;
53
e1daf7d6 54 if (tgetstr(str, &bufp) == 0)
359d1214 55 return 0;
e1daf7d6
EW
56 if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
57 return 0;
58 s->ts_str = tt_strp;
b1189050 59 tputs(buf, 1, ttxputc);
e1daf7d6
EW
60 s->ts_n = tt_strp - s->ts_str;
61 *tt_strp++ = 0;
62 return s;
63}
64
65tttgoto(s, col, row)
66 struct tt_str *s;
67{
68 register char *p = s->ts_str;
69
70 ttputs(tgoto(p, col, row));
71 for (p += s->ts_n; *--p == 0;)
72 ttputc(0);
359d1214 73}
b16d80c6 74
2d152f42
EW
75ttpgoto(s, col, row, n)
76 struct tt_str *s;
77{
78
79 tputs(tgoto(s->ts_str, col, row), n, tttputc);
80}
81
b16d80c6
EW
82ttstrcmp(a, b)
83 register struct tt_str *a, *b;
84{
85 int n, r;
86
87 if (r = bcmp(a->ts_str, b->ts_str,
88 (n = a->ts_n - b->ts_n) < 0 ? a->ts_n : b->ts_n))
89 return r;
90 return n;
91}