install approved copyright notice
[unix-history] / usr / src / usr.bin / window / tttermcap.c
CommitLineData
60de5df9 1/*
46e9ea25
KB
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
5e8b0e60
KB
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.
60de5df9
EW
16 */
17
46e9ea25 18#ifndef lint
5e8b0e60 19static char sccsid[] = "@(#)tttermcap.c 3.9 (Berkeley) %G%";
46e9ea25
KB
20#endif /* not lint */
21
359d1214
EW
22#include "tt.h"
23
24char *tgetstr();
e1daf7d6
EW
25char *tgoto();
26char *malloc();
359d1214 27
b1189050 28tttputc(c)
359d1214 29{
b1189050 30 ttputc(c);
359d1214
EW
31}
32
b1189050 33ttxputc(c)
359d1214
EW
34{
35 *tt_strp++ = c;
36}
37
e1daf7d6
EW
38struct tt_str *
39tttgetstr(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
53struct tt_str *
b1189050 54ttxgetstr(str)
e1daf7d6 55 char *str;
359d1214 56{
e1daf7d6 57 register struct tt_str *s;
359d1214
EW
58 char buf[100];
59 char *bufp = buf;
60
e1daf7d6 61 if (tgetstr(str, &bufp) == 0)
359d1214 62 return 0;
e1daf7d6
EW
63 if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
64 return 0;
65 s->ts_str = tt_strp;
b1189050 66 tputs(buf, 1, ttxputc);
e1daf7d6
EW
67 s->ts_n = tt_strp - s->ts_str;
68 *tt_strp++ = 0;
69 return s;
70}
71
72tttgoto(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);
359d1214 80}
b16d80c6
EW
81
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}