xref: /titanic_51/usr/src/cmd/dc/dc.h (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
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 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #define	FATAL 0
33 #define	NFATAL 1
34 #define	BLK sizeof (struct blk)
35 #define	PTRSZ sizeof (int *)
36 #define	HEADSZ 1024
37 #define	STKSZ 100
38 #define	RDSKSZ 100
39 #define	TBLSZ 256
40 #define	ARRAYST 0241
41 #define	NL 1
42 #define	NG 2
43 #define	NE 3
44 #define	length(p) ((p)->wt-(p)->beg)
45 #define	rewind(p) ((p)->rd = (p)->beg)
46 #define	create(p)	((p)->rd = (p)->wt = (p)->beg)
47 #define	fsfile(p)	((p)->rd = (p)->wt)
48 #define	truncate(p)	((p)->wt = (p)->rd)
49 #define	sfeof(p)	(((p)->rd >= (p)->wt) ? 1 : 0)
50 #define	sfbeg(p)	(((p)->rd == (p)->beg) ? 1 : 0)
51 #define	sungetc(p, c)	(*(--(p)->rd) = c)
52 #define	sgetc(p)	(((p)->rd == (p)->wt) ? EOF: ctoint((int)*(p)->rd++))
53 #define	slookc(p)	(((p)->rd == (p)->wt) ? EOF: ctoint((int)*(p)->rd))
54 #define	sbackc(p)	(((p)->rd == (p)->beg) ? EOF: ctoint((int)*(--(p)->rd)))
55 #define	sputc(p, c)	{if ((p)->wt == (p)->last) more(p); *(p)->wt++ = c; }
56 #define	salterc(p, c)	{if ((p)->rd == (p)->last) more(p); *(p)->rd++ = c;\
57 			    if ((p)->rd > (p)->wt) (p)->wt = (p)->rd; }
58 #define	sunputc(p)	(*((p)->rd = --(p)->wt))
59 #define	zero(p)		for (pp = (p)->beg; pp < (p)->last; ) *pp++ = '\0'
60 #define	OUTC(x) {printf("%c", x); if (--count == 0)\
61 			    {printf("\\\n"); count = ll; } }
62 #define	TEST2	{if ((count -= 2) <= 0) {printf("\\\n"); count = ll; } }
63 #define	PRINT_MESSAGE	printf(gettext("stack empty\n"))
64 #define	EMPTY		if (stkerr != 0) {PRINT_MESSAGE; continue; }
65 #define	EMPTYR(x)	if (stkerr != 0) {pushp(x); PRINT_MESSAGE; continue; }
66 #define	EMPTYS		if (stkerr != 0) {PRINT_MESSAGE; return (1); }
67 #define	EMPTYSR(x)	if (stkerr != 0) {PRINT_MESSAGE; pushp(x); return (1); }
68 #define	CHECKEND	{ \
69 				if (count == 2) { \
70 					printf("\\\n"); \
71 					count = ll; \
72 				} \
73 			}
74 #define	error(p)	{printf(p); continue; }
75 #define	errorrt(p)	{printf(p); return (1); }
76 struct blk {
77 	char	*rd;
78 	char	*wt;
79 	char	*beg;
80 	char	*last;
81 };
82 struct	wblk {
83 	struct blk **rdw;
84 	struct blk **wtw;
85 	struct blk **begw;
86 	struct blk **lastw;
87 };
88 struct	blk *hfree;
89 struct	blk *getwd(struct blk *);
90 struct	blk *lookwd(struct blk *);
91 struct	blk *getdec(struct blk *, int);
92 struct	blk *morehd(void);
93 
94 struct	blk *arg1, *arg2;
95 int	svargc;
96 char	savk;
97 char	**svargv;
98 int	dbg;
99 int	ifile;
100 FILE	*curfile;
101 struct	blk *scalptr, *basptr, *tenptr, *inbas;
102 struct	blk *sqtemp, *chptr, *strptr, *divxyz;
103 struct	blk *stack[STKSZ];
104 struct	blk **stkptr, **stkbeg;
105 struct	blk **stkend;
106 int	stkerr;
107 int	lastchar;
108 struct	blk *readstk[RDSKSZ];
109 struct	blk **readptr;
110 struct	blk *rem;
111 int	k;
112 struct	blk *irem;
113 int	skd, skr;
114 struct	blk *pop(void), *readin(void), *add0(struct blk *, int),
115     *mult(struct blk *, struct blk *);
116 struct	blk *scalint(struct blk *);
117 struct	blk *removc(struct blk *, int);
118 struct	blk *add(struct blk *, struct blk *),
119     *dcdiv(struct blk *, struct blk *), *removr(struct blk *, int);
120 struct	blk *exp(struct blk *, struct blk *);
121 struct	blk *sqrt(struct blk *);
122 struct	blk *salloc(int), *copy(struct blk *, int);
123 struct	blk *scale(struct blk *, int);
124 void	commnds(void);
125 void	init(int, char **);
126 void	pushp(struct blk *p);
127 void	chsign(struct blk *p);
128 char	readc(void);
129 void	unreadc(char);
130 void	binop(char);
131 void	print(struct blk *hptr);
132 void	tenot(struct blk *p, int sc);
133 void	oneot(struct blk *p, int sc, char ch);
134 void	seekc(struct blk *hptr, int n);
135 void	ospace(char *s);
136 void	garbage(char *s);
137 void	more(struct blk *hptr);
138 int	cond(char c);
139 void	load(void);
140 void	sdump(char *s1, struct blk *hptr);
141 void	salterwd(struct wblk *hptr, struct blk *n);
142 void	redef(struct blk *p);
143 void	release(struct blk *p);
144 void	putwd(struct blk *p, struct blk *c);
145 
146 int	neg;
147 struct	sym {
148 	struct	sym *next;
149 	struct	blk *val;
150 } symlst[TBLSZ];
151 struct	sym *stable[TBLSZ];
152 struct	sym *sptr, *sfree;
153 FILE	*fsave;
154 long	rel;
155 long	nbytes;
156 long	all;
157 long	headmor;
158 long	obase;
159 int	fw, fw1, ll;
160 void	(*outdit)(struct blk *, int);
161 void	bigot(struct blk *, int), hexot(struct blk *, int);
162 int	logo;
163 int	log10;
164 int	count;
165 char	*pp;
166 void	onintr(int);
167 char	*nalloc(char *, unsigned int);
168 char	*dummy;
169