|
|
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[] = "@(#)tttermcap.c 3.9 (Berkeley) 6/29/88";
20: #endif /* not lint */
21:
22: #include "tt.h"
23:
24: char *tgetstr();
25: char *tgoto();
26: char *malloc();
27:
28: tttputc(c)
29: {
30: ttputc(c);
31: }
32:
33: ttxputc(c)
34: {
35: *tt_strp++ = c;
36: }
37:
38: struct tt_str *
39: tttgetstr(str)
40: char *str;
41: {
42: register struct tt_str *s;
43:
44: if ((str = tgetstr(str, &tt_strp)) == 0)
45: return 0;
46: if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
47: return 0;
48: s->ts_str = str;
49: s->ts_n = tt_strp - s->ts_str - 1;
50: return s;
51: }
52:
53: struct tt_str *
54: ttxgetstr(str)
55: char *str;
56: {
57: register struct tt_str *s;
58: char buf[100];
59: char *bufp = buf;
60:
61: if (tgetstr(str, &bufp) == 0)
62: return 0;
63: if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
64: return 0;
65: s->ts_str = tt_strp;
66: tputs(buf, 1, ttxputc);
67: s->ts_n = tt_strp - s->ts_str;
68: *tt_strp++ = 0;
69: return s;
70: }
71:
72: tttgoto(s, col, row)
73: struct tt_str *s;
74: {
75: register char *p = s->ts_str;
76:
77: ttputs(tgoto(p, col, row));
78: for (p += s->ts_n; *--p == 0;)
79: ttputc(0);
80: }
81:
82: ttstrcmp(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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.