xref: /titanic_41/usr/src/cmd/dc/dc.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.19  */
27 #define	FATAL 0
28 #define	NFATAL 1
29 #define	BLK sizeof (struct blk)
30 #define	PTRSZ sizeof (int *)
31 #define	HEADSZ 1024
32 #define	STKSZ 100
33 #define	RDSKSZ 100
34 #define	TBLSZ 256
35 #define	ARRAYST 0241
36 #define	NL 1
37 #define	NG 2
38 #define	NE 3
39 #define	length(p) ((p)->wt-(p)->beg)
40 #define	rewind(p) ((p)->rd = (p)->beg)
41 #define	create(p)	((p)->rd = (p)->wt = (p)->beg)
42 #define	fsfile(p)	((p)->rd = (p)->wt)
43 #define	truncate(p)	((p)->wt = (p)->rd)
44 #define	sfeof(p)	(((p)->rd >= (p)->wt) ? 1 : 0)
45 #define	sfbeg(p)	(((p)->rd == (p)->beg) ? 1 : 0)
46 #define	sungetc(p, c)	(*(--(p)->rd) = c)
47 #define	sgetc(p)	(((p)->rd == (p)->wt) ? EOF: ctoint((int)*(p)->rd++))
48 #define	slookc(p)	(((p)->rd == (p)->wt) ? EOF: ctoint((int)*(p)->rd))
49 #define	sbackc(p)	(((p)->rd == (p)->beg) ? EOF: ctoint((int)*(--(p)->rd)))
50 #define	sputc(p, c)	{if ((p)->wt == (p)->last) more(p); *(p)->wt++ = c; }
51 #define	salterc(p, c)	{if ((p)->rd == (p)->last) more(p); *(p)->rd++ = c;\
52 			    if ((p)->rd > (p)->wt) (p)->wt = (p)->rd; }
53 #define	sunputc(p)	(*((p)->rd = --(p)->wt))
54 #define	zero(p)		for (pp = (p)->beg; pp < (p)->last; ) *pp++ = '\0'
55 #define	OUTC(x) {printf("%c", x); if (--count == 0)\
56 			    {printf("\\\n"); count = ll; } }
57 #define	TEST2	{if ((count -= 2) <= 0) {printf("\\\n"); count = ll; } }
58 #define	PRINT_MESSAGE	printf(gettext("stack empty\n"))
59 #define	EMPTY		if (stkerr != 0) {PRINT_MESSAGE; continue; }
60 #define	EMPTYR(x)	if (stkerr != 0) {pushp(x); PRINT_MESSAGE; continue; }
61 #define	EMPTYS		if (stkerr != 0) {PRINT_MESSAGE; return (1); }
62 #define	EMPTYSR(x)	if (stkerr != 0) {PRINT_MESSAGE; pushp(x); return (1); }
63 #define	CHECKEND	{ \
64 				if (count == 2) { \
65 					printf("\\\n"); \
66 					count = ll; \
67 				} \
68 			}
69 #define	error(p)	{printf(p); continue; }
70 #define	errorrt(p)	{printf(p); return (1); }
71 struct blk {
72 	char	*rd;
73 	char	*wt;
74 	char	*beg;
75 	char	*last;
76 };
77 struct	wblk {
78 	struct blk **rdw;
79 	struct blk **wtw;
80 	struct blk **begw;
81 	struct blk **lastw;
82 };
83 struct	blk *hfree;
84 struct	blk *getwd();
85 struct	blk *lookwd();
86 struct	blk *getdec();
87 struct	blk *morehd();
88 
89 struct	blk *arg1, *arg2;
90 int	svargc;
91 char	savk;
92 char	**svargv;
93 int	dbg;
94 int	ifile;
95 FILE	*curfile;
96 struct	blk *scalptr, *basptr, *tenptr, *inbas;
97 struct	blk *sqtemp, *chptr, *strptr, *divxyz;
98 struct	blk *stack[STKSZ];
99 struct	blk **stkptr, **stkbeg;
100 struct	blk **stkend;
101 int	stkerr;
102 int	lastchar;
103 struct	blk *readstk[RDSKSZ];
104 struct	blk **readptr;
105 struct	blk *rem;
106 int	k;
107 struct	blk *irem;
108 int	skd, skr;
109 struct	blk *pop(), *readin(), *add0(), *mult();
110 struct	blk *scalint();
111 struct	blk *removc();
112 struct	blk *add(), *div(), *removr();
113 struct	blk *exp();
114 struct	blk *sqrt();
115 struct	blk *salloc(), *copy();
116 struct	blk *scale();
117 void	commnds();
118 void	init(int, char **);
119 void	pushp(struct blk *p);
120 void	chsign(struct blk *p);
121 char	readc();
122 void	unreadc(char);
123 void	binop(char);
124 void	print(struct blk *hptr);
125 void	tenot(struct blk *p, int sc);
126 void	oneot(struct blk *p, int sc, char ch);
127 void	seekc(struct blk *hptr, int n);
128 void	ospace(char *s);
129 void	garbage(char *s);
130 void	more(struct blk *hptr);
131 int	cond(char c);
132 void	load();
133 void	sdump(char *s1, struct blk *hptr);
134 void	salterwd(struct wblk *hptr, struct blk *n);
135 void	redef(struct blk *p);
136 void	release(struct blk *p);
137 void	putwd(struct blk *p, struct blk *c);
138 
139 int	neg;
140 struct	sym {
141 	struct	sym *next;
142 	struct	blk *val;
143 } symlst[TBLSZ];
144 struct	sym *stable[TBLSZ];
145 struct	sym *sptr, *sfree;
146 FILE	*fsave;
147 long	rel;
148 long	nbytes;
149 long	all;
150 long	headmor;
151 long	obase;
152 int	fw, fw1, ll;
153 void	(*outdit)();
154 void	bigot(), hexot();
155 int	logo;
156 int	log10;
157 int	count;
158 char	*pp;
159 void	onintr();
160 char	*malloc();
161 char	*nalloc();
162 char	*realloc();
163 char	*dummy;
164