Commit | Line | Data |
---|---|---|
359d1214 | 1 | #ifndef lint |
ff3a53e4 | 2 | static char sccsid[] = "@(#)tttermcap.c 3.7 %G%"; |
359d1214 EW |
3 | #endif |
4 | ||
60de5df9 EW |
5 | /* |
6 | * Copyright (c) 1983 Regents of the University of California, | |
7 | * All rights reserved. Redistribution permitted subject to | |
8 | * the terms of the Berkeley Software License Agreement. | |
9 | */ | |
10 | ||
359d1214 EW |
11 | #include "tt.h" |
12 | ||
13 | char *tgetstr(); | |
e1daf7d6 EW |
14 | char *tgoto(); |
15 | char *malloc(); | |
359d1214 | 16 | |
b1189050 | 17 | tttputc(c) |
359d1214 | 18 | { |
b1189050 | 19 | ttputc(c); |
359d1214 EW |
20 | } |
21 | ||
b1189050 | 22 | ttxputc(c) |
359d1214 EW |
23 | { |
24 | *tt_strp++ = c; | |
25 | } | |
26 | ||
e1daf7d6 EW |
27 | struct tt_str * |
28 | tttgetstr(str) | |
29 | char *str; | |
30 | { | |
31 | register struct tt_str *s; | |
32 | ||
33 | if ((str = tgetstr(str, &tt_strp)) == 0) | |
34 | return 0; | |
35 | if ((s = (struct tt_str *) malloc(sizeof *s)) == 0) | |
36 | return 0; | |
37 | s->ts_str = str; | |
38 | s->ts_n = tt_strp - s->ts_str - 1; | |
39 | return s; | |
40 | } | |
41 | ||
42 | struct tt_str * | |
b1189050 | 43 | ttxgetstr(str) |
e1daf7d6 | 44 | char *str; |
359d1214 | 45 | { |
e1daf7d6 | 46 | register struct tt_str *s; |
359d1214 EW |
47 | char buf[100]; |
48 | char *bufp = buf; | |
49 | ||
e1daf7d6 | 50 | if (tgetstr(str, &bufp) == 0) |
359d1214 | 51 | return 0; |
e1daf7d6 EW |
52 | if ((s = (struct tt_str *) malloc(sizeof *s)) == 0) |
53 | return 0; | |
54 | s->ts_str = tt_strp; | |
b1189050 | 55 | tputs(buf, 1, ttxputc); |
e1daf7d6 EW |
56 | s->ts_n = tt_strp - s->ts_str; |
57 | *tt_strp++ = 0; | |
58 | return s; | |
59 | } | |
60 | ||
61 | tttgoto(s, col, row) | |
62 | struct tt_str *s; | |
63 | { | |
64 | register char *p = s->ts_str; | |
65 | ||
66 | ttputs(tgoto(p, col, row)); | |
67 | for (p += s->ts_n; *--p == 0;) | |
68 | ttputc(0); | |
359d1214 | 69 | } |
b16d80c6 EW |
70 | |
71 | ttstrcmp(a, b) | |
72 | register struct tt_str *a, *b; | |
73 | { | |
74 | int n, r; | |
75 | ||
76 | if (r = bcmp(a->ts_str, b->ts_str, | |
77 | (n = a->ts_n - b->ts_n) < 0 ? a->ts_n : b->ts_n)) | |
78 | return r; | |
79 | return n; | |
80 | } |