xref: /csrg-svn/usr.bin/window/tttermcap.c (revision 24975)
114691Sedward #ifndef lint
2*24975Sedward static char sccsid[] = "@(#)tttermcap.c	3.6 09/20/85";
314691Sedward #endif
414691Sedward 
518740Sedward /*
618740Sedward  * Copyright (c) 1983 Regents of the University of California,
718740Sedward  * All rights reserved.  Redistribution permitted subject to
818740Sedward  * the terms of the Berkeley Software License Agreement.
918740Sedward  */
1018740Sedward 
1114691Sedward #include "tt.h"
1214691Sedward 
1314691Sedward char *tgetstr();
14*24975Sedward char *tgoto();
15*24975Sedward char *malloc();
1614691Sedward 
1716123Sedward tttputc(c)
1814691Sedward {
1916123Sedward 	ttputc(c);
2014691Sedward }
2114691Sedward 
2216123Sedward ttxputc(c)
2314691Sedward {
2414691Sedward 	*tt_strp++ = c;
2514691Sedward }
2614691Sedward 
27*24975Sedward struct tt_str *
28*24975Sedward tttgetstr(str)
29*24975Sedward 	char *str;
30*24975Sedward {
31*24975Sedward 	register struct tt_str *s;
32*24975Sedward 
33*24975Sedward 	if ((str = tgetstr(str, &tt_strp)) == 0)
34*24975Sedward 		return 0;
35*24975Sedward 	if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
36*24975Sedward 		return 0;
37*24975Sedward 	s->ts_str = str;
38*24975Sedward 	s->ts_n = tt_strp - s->ts_str - 1;
39*24975Sedward 	return s;
40*24975Sedward }
41*24975Sedward 
42*24975Sedward struct tt_str *
4316123Sedward ttxgetstr(str)
44*24975Sedward 	char *str;
4514691Sedward {
46*24975Sedward 	register struct tt_str *s;
4714691Sedward 	char buf[100];
4814691Sedward 	char *bufp = buf;
4914691Sedward 
50*24975Sedward 	if (tgetstr(str, &bufp) == 0)
5114691Sedward 		return 0;
52*24975Sedward 	if ((s = (struct tt_str *) malloc(sizeof *s)) == 0)
53*24975Sedward 		return 0;
54*24975Sedward 	s->ts_str = tt_strp;
5516123Sedward 	tputs(buf, 1, ttxputc);
56*24975Sedward 	s->ts_n = tt_strp - s->ts_str;
57*24975Sedward 	*tt_strp++ = 0;
58*24975Sedward 	return s;
5914691Sedward }
60*24975Sedward 
61*24975Sedward tttgoto(s, col, row)
62*24975Sedward 	struct tt_str *s;
63*24975Sedward {
64*24975Sedward 	register char *p = s->ts_str;
65*24975Sedward 
66*24975Sedward 	ttputs(tgoto(p, col, row));
67*24975Sedward 	for (p += s->ts_n; *--p == 0;)
68*24975Sedward 		ttputc(0);
69*24975Sedward }
70