xref: /titanic_51/usr/src/lib/libcurses/screen/termcap.ed (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gateH
2*7c478bd9Sstevel@tonic-gate!rm -f termcap.c
3*7c478bd9Sstevel@tonic-gate0a
4*7c478bd9Sstevel@tonic-gate/*
5*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
6*7c478bd9Sstevel@tonic-gate * Use is subject to license terms.
7*7c478bd9Sstevel@tonic-gate */
8*7c478bd9Sstevel@tonic-gate
9*7c478bd9Sstevel@tonic-gate/*
10*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
11*7c478bd9Sstevel@tonic-gate * The Regents of the University of California
12*7c478bd9Sstevel@tonic-gate * All Rights Reserved
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
15*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
16*7c478bd9Sstevel@tonic-gate * contributors.
17*7c478bd9Sstevel@tonic-gate */
18*7c478bd9Sstevel@tonic-gate
19*7c478bd9Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
20*7c478bd9Sstevel@tonic-gate
21*7c478bd9Sstevel@tonic-gate/*
22*7c478bd9Sstevel@tonic-gate * Simulation of termcap using terminfo.
23*7c478bd9Sstevel@tonic-gate * This file is created from termcap.ed. DO NOT EDIT ME!
24*7c478bd9Sstevel@tonic-gate */
25*7c478bd9Sstevel@tonic-gate
26*7c478bd9Sstevel@tonic-gate/*
27*7c478bd9Sstevel@tonic-gate * These are declared so people won't get undefineds if they use
28*7c478bd9Sstevel@tonic-gate * old documentation.  We don't do anything with them.
29*7c478bd9Sstevel@tonic-gate */
30*7c478bd9Sstevel@tonic-gate
31*7c478bd9Sstevel@tonic-gate#include	<sys/types.h>
32*7c478bd9Sstevel@tonic-gate#include	<string.h>
33*7c478bd9Sstevel@tonic-gate#include	"curses_inc.h"
34*7c478bd9Sstevel@tonic-gate
35*7c478bd9Sstevel@tonic-gatechar	*UP;
36*7c478bd9Sstevel@tonic-gatechar	*BC;
37*7c478bd9Sstevel@tonic-gatechar	PC;
38*7c478bd9Sstevel@tonic-gateshort	ospeed;
39*7c478bd9Sstevel@tonic-gate
40*7c478bd9Sstevel@tonic-gate/* ARGSUSED */
41*7c478bd9Sstevel@tonic-gateint
42*7c478bd9Sstevel@tonic-gatetgetent(char *bp, char *name)
43*7c478bd9Sstevel@tonic-gate{
44*7c478bd9Sstevel@tonic-gate	int	rv;
45*7c478bd9Sstevel@tonic-gate
46*7c478bd9Sstevel@tonic-gate	if (setupterm(name, 1, &rv) >= 0)
47*7c478bd9Sstevel@tonic-gate	/* Leave things as they were (for compatibility) */
48*7c478bd9Sstevel@tonic-gate		(void) reset_shell_mode();
49*7c478bd9Sstevel@tonic-gate	return (rv);
50*7c478bd9Sstevel@tonic-gate}
51*7c478bd9Sstevel@tonic-gate
52*7c478bd9Sstevel@tonic-gate/* Make a 2 letter code into an integer we can switch on easily */
53*7c478bd9Sstevel@tonic-gate#define	_TWO(s1, s2)	(s1 + 256*s2)
54*7c478bd9Sstevel@tonic-gate#define	_TWOSTR(str)	_TWO(*str, str[1])
55*7c478bd9Sstevel@tonic-gate
56*7c478bd9Sstevel@tonic-gatestatic	char	*
57*7c478bd9Sstevel@tonic-gate_stripdelays(char *inbuf, char *outbuf, int size)
58*7c478bd9Sstevel@tonic-gate{
59*7c478bd9Sstevel@tonic-gate	char	*saveoutbuf = outbuf;
60*7c478bd9Sstevel@tonic-gate
61*7c478bd9Sstevel@tonic-gate	if (inbuf == NULL)
62*7c478bd9Sstevel@tonic-gate		return (0);
63*7c478bd9Sstevel@tonic-gate	else
64*7c478bd9Sstevel@tonic-gate		while (size && *inbuf)
65*7c478bd9Sstevel@tonic-gate			if (*inbuf == '$' && *(inbuf+1) == '<')
66*7c478bd9Sstevel@tonic-gate				/* LINTED */
67*7c478bd9Sstevel@tonic-gate				while (*inbuf && *inbuf++ != '>');
68*7c478bd9Sstevel@tonic-gate			else {
69*7c478bd9Sstevel@tonic-gate				size--;
70*7c478bd9Sstevel@tonic-gate				*outbuf++ = *inbuf++;
71*7c478bd9Sstevel@tonic-gate				*outbuf = 0;
72*7c478bd9Sstevel@tonic-gate			}
73*7c478bd9Sstevel@tonic-gate		return (saveoutbuf);
74*7c478bd9Sstevel@tonic-gate}
75*7c478bd9Sstevel@tonic-gate
76*7c478bd9Sstevel@tonic-gate/* generated by sort on caps */
77*7c478bd9Sstevel@tonic-gatestatic	short	booloffsets[] =
78*7c478bd9Sstevel@tonic-gate		{		/* generated by sort on caps */
79*7c478bd9Sstevel@tonic-gate.
80*7c478bd9Sstevel@tonic-gate!sed -e '1,/^--- begin bool/d' -e '/^--- end bool/,$d' -e '/^#/d' < caps | awk '{printf "\t/* \%s */\t\%d,\n", $3, i++}' | sort > ./tmp/termcap.tmp
81*7c478bd9Sstevel@tonic-gate.r !cat ./tmp/termcap.tmp
82*7c478bd9Sstevel@tonic-gate.a
83*7c478bd9Sstevel@tonic-gate		};
84*7c478bd9Sstevel@tonic-gate
85*7c478bd9Sstevel@tonic-gate/* generated by sort on caps */
86*7c478bd9Sstevel@tonic-gatestatic	short	numoffsets[] =
87*7c478bd9Sstevel@tonic-gate		{
88*7c478bd9Sstevel@tonic-gate.
89*7c478bd9Sstevel@tonic-gate!sed -e '1,/^--- begin num/d' -e '/^--- end num/,$d' -e '/^#/d' < caps | awk '{printf "\t/* \%s */\t\%d,\n", $3, i++}' | sort > ./tmp/termcap.tmp
90*7c478bd9Sstevel@tonic-gate.r !cat ./tmp/termcap.tmp
91*7c478bd9Sstevel@tonic-gate.a
92*7c478bd9Sstevel@tonic-gate		};
93*7c478bd9Sstevel@tonic-gate
94*7c478bd9Sstevel@tonic-gate/* generated by sort on caps */
95*7c478bd9Sstevel@tonic-gatestatic	short	stroffsets[] =
96*7c478bd9Sstevel@tonic-gate		{
97*7c478bd9Sstevel@tonic-gate.
98*7c478bd9Sstevel@tonic-gate!sed -e '1,/^--- begin str/d' -e '/^--- end str/,$d' -e '/^#/d' < caps | awk '{printf "\t/* \%s */\t\%d,\n", $3, i++}' | sort > ./tmp/termcap.tmp
99*7c478bd9Sstevel@tonic-gate.r !cat ./tmp/termcap.tmp
100*7c478bd9Sstevel@tonic-gate!rm ./tmp/termcap.tmp
101*7c478bd9Sstevel@tonic-gate.a
102*7c478bd9Sstevel@tonic-gate		};
103*7c478bd9Sstevel@tonic-gate
104*7c478bd9Sstevel@tonic-gate/*
105*7c478bd9Sstevel@tonic-gate * Return the value of the boolean capability tcstr.
106*7c478bd9Sstevel@tonic-gate * Return 0 if the capability is not found.
107*7c478bd9Sstevel@tonic-gate */
108*7c478bd9Sstevel@tonic-gate
109*7c478bd9Sstevel@tonic-gateint
110*7c478bd9Sstevel@tonic-gatetgetflag(char *tcstr)
111*7c478bd9Sstevel@tonic-gate{
112*7c478bd9Sstevel@tonic-gate	char	*p;
113*7c478bd9Sstevel@tonic-gate	char	stripped[16];
114*7c478bd9Sstevel@tonic-gate
115*7c478bd9Sstevel@tonic-gate	switch (_TWOSTR(tcstr)) {
116*7c478bd9Sstevel@tonic-gate	/* Special cases that do not have exact terminfo equivalents */
117*7c478bd9Sstevel@tonic-gate		case _TWO('b','s'):
118*7c478bd9Sstevel@tonic-gate			/* bs: true if ^H moves the cursor left */
119*7c478bd9Sstevel@tonic-gate			p = _stripdelays(cursor_left, stripped, 16);
120*7c478bd9Sstevel@tonic-gate			return (p && *p == 8 && p[1] == 0);
121*7c478bd9Sstevel@tonic-gate		case _TWO('p','t'):
122*7c478bd9Sstevel@tonic-gate			/* pt: true if terminal has ^I tabs every 8 spaces */
123*7c478bd9Sstevel@tonic-gate			p = _stripdelays(tab, stripped, 16);
124*7c478bd9Sstevel@tonic-gate			return (p && *p == 9 && p[1] == 0);
125*7c478bd9Sstevel@tonic-gate		case _TWO('n','c'):
126*7c478bd9Sstevel@tonic-gate			/* cr: true if ^M does not return the cursor */
127*7c478bd9Sstevel@tonic-gate			p = _stripdelays(carriage_return, stripped, 16);
128*7c478bd9Sstevel@tonic-gate			return (! (p && *p == 13 && p[1] == 0));
129*7c478bd9Sstevel@tonic-gate		case _TWO('n','s'):
130*7c478bd9Sstevel@tonic-gate			/* ns: true if no way to scroll the terminal */
131*7c478bd9Sstevel@tonic-gate			return (scroll_forward == NULL);
132*7c478bd9Sstevel@tonic-gate	}
133*7c478bd9Sstevel@tonic-gate	{
134*7c478bd9Sstevel@tonic-gate		int	n = _NUMELEMENTS(booloffsets);
135*7c478bd9Sstevel@tonic-gate		int	offset = _tcsearch(tcstr, booloffsets, boolcodes, n, 2);
136*7c478bd9Sstevel@tonic-gate		char	*bool_array = (char *) cur_bools;
137*7c478bd9Sstevel@tonic-gate
138*7c478bd9Sstevel@tonic-gate		if (offset == -1)
139*7c478bd9Sstevel@tonic-gate			return (0);
140*7c478bd9Sstevel@tonic-gate		else
141*7c478bd9Sstevel@tonic-gate			return (bool_array[offset]);
142*7c478bd9Sstevel@tonic-gate	}
143*7c478bd9Sstevel@tonic-gate}
144*7c478bd9Sstevel@tonic-gate
145*7c478bd9Sstevel@tonic-gate/*
146*7c478bd9Sstevel@tonic-gate * Return the value of the numeric capability tcstr.
147*7c478bd9Sstevel@tonic-gate * Return -1 if the capability is not found.
148*7c478bd9Sstevel@tonic-gate */
149*7c478bd9Sstevel@tonic-gate
150*7c478bd9Sstevel@tonic-gateint
151*7c478bd9Sstevel@tonic-gatetgetnum(char *tcstr)
152*7c478bd9Sstevel@tonic-gate{
153*7c478bd9Sstevel@tonic-gate	int	n = _NUMELEMENTS(numoffsets);
154*7c478bd9Sstevel@tonic-gate	int	offset = _tcsearch(tcstr, numoffsets, numcodes, n, 2);
155*7c478bd9Sstevel@tonic-gate	short	*num_array = (short *) cur_nums;
156*7c478bd9Sstevel@tonic-gate
157*7c478bd9Sstevel@tonic-gate	if (offset == -1)
158*7c478bd9Sstevel@tonic-gate		return (-1);
159*7c478bd9Sstevel@tonic-gate	else
160*7c478bd9Sstevel@tonic-gate		return (num_array[offset]);
161*7c478bd9Sstevel@tonic-gate}
162*7c478bd9Sstevel@tonic-gate
163*7c478bd9Sstevel@tonic-gate/*
164*7c478bd9Sstevel@tonic-gate * Return the string capability for capability "id".  We also copy
165*7c478bd9Sstevel@tonic-gate * it into *area for upward compatibility with a few programs that
166*7c478bd9Sstevel@tonic-gate * actually expect it to be copied, at a slight cost in speed.
167*7c478bd9Sstevel@tonic-gate */
168*7c478bd9Sstevel@tonic-gate
169*7c478bd9Sstevel@tonic-gatechar	*
170*7c478bd9Sstevel@tonic-gatetgetstr(char *tcstr, char **area)
171*7c478bd9Sstevel@tonic-gate{
172*7c478bd9Sstevel@tonic-gate	int	n = _NUMELEMENTS(stroffsets);
173*7c478bd9Sstevel@tonic-gate	int	offset = _tcsearch(tcstr, stroffsets, strcodes, n, 2);
174*7c478bd9Sstevel@tonic-gate	char	**str_array = (char **) cur_strs;
175*7c478bd9Sstevel@tonic-gate	char	*rv;
176*7c478bd9Sstevel@tonic-gate
177*7c478bd9Sstevel@tonic-gate	if (offset == -1)
178*7c478bd9Sstevel@tonic-gate		return (0);
179*7c478bd9Sstevel@tonic-gate	rv = str_array[offset];
180*7c478bd9Sstevel@tonic-gate	if (area && *area && rv) {
181*7c478bd9Sstevel@tonic-gate		(void) strcpy(*area, rv);
182*7c478bd9Sstevel@tonic-gate		*area += strlen(rv) + 1;
183*7c478bd9Sstevel@tonic-gate	}
184*7c478bd9Sstevel@tonic-gate	return (rv);
185*7c478bd9Sstevel@tonic-gate}
186*7c478bd9Sstevel@tonic-gate.
187*7c478bd9Sstevel@tonic-gatew termcap.c
188*7c478bd9Sstevel@tonic-gateq
189