xref: /original-bsd/usr.bin/dc/dc.h (revision bbb96de4)
1 /*	dc.h	1.4	89/09/15	*/
2 
3 #define FATAL 0
4 #define NFATAL 1
5 #define BLK sizeof(struct blk)
6 #define PTRSZ sizeof(int *)
7 #define HEADSZ 1024
8 #define STKSZ 100
9 #define RDSKSZ 100
10 #define TBLSZ 256
11 #define ARRAYST 0241
12 #define MAXIND 2048
13 #define NL 1
14 #define NG 2
15 #define NE 3
16 #define length(p) ((p)->wt-(p)->beg)
17 #define rewind(p) (p)->rd=(p)->beg
18 #define create(p)	(p)->rd = (p)->wt = (p)->beg
19 #define fsfile(p)	(p)->rd = (p)->wt
20 #define truncate(p)	(p)->wt = (p)->rd
21 #define sfeof(p)	(((p)->rd==(p)->wt)?1:0)
22 #define sfbeg(p)	(((p)->rd==(p)->beg)?1:0)
23 #define sungetc(p,c)	*(--(p)->rd)=c
24 #ifdef interdata
25 #define NEGBYTE 0200
26 #define MASK (-1 & ~0377)
27 #define sgetc(p)	( ((p)->rd==(p)->wt) ? EOF :( ((*(p)->rd & NEGBYTE) != 0) ? ( *(p)->rd++ | MASK): *(p)->rd++ ))
28 #define slookc(p)	( ((p)->rd==(p)->wt) ? EOF :( ((*(p)->rd & NEGBYTE) != 0) ? (*(p)->rd | MASK) : *(p)->rd ))
29 #define sbackc(p)	( ((p)->rd==(p)->beg) ? EOF :( ((*(--(p)->rd) & NEGBYTE) != 0) ? (*(p)->rd | MASK): *(p)->rd ))
30 #endif
31 #ifndef interdata
32 #define sgetc(p)	(((p)->rd==(p)->wt)?EOF:*(p)->rd++)
33 #define slookc(p)	(((p)->rd==(p)->wt)?EOF:*(p)->rd)
34 #define sbackc(p)	(((p)->rd==(p)->beg)?EOF:*(--(p)->rd))
35 #endif
36 #define sputc(p,c)	{if((p)->wt==(p)->last)more(p); *(p)->wt++ = c; }
37 #define salterc(p,c)	{if((p)->rd==(p)->last)more(p); *(p)->rd++ = c; if((p)->rd>(p)->wt)(p)->wt=(p)->rd;}
38 #define sunputc(p)	(*( (p)->rd = --(p)->wt))
39 #define zero(p)	for(pp=(p)->beg;pp<(p)->last;)*pp++='\0'
40 #define OUTC(x) {printf("%c",x); if(--count == 0){printf("\\\n"); count=ll;} }
41 #define TEST2	{if((count -= 2) <=0){printf("\\\n");count=ll;}}
42 #define EMPTY if(stkerr != 0){printf("stack empty\n"); continue; }
43 #define EMPTYR(x) if(stkerr!=0){pushp(x);printf("stack empty\n");continue;}
44 #define EMPTYS if(stkerr != 0){printf("stack empty\n"); return(1);}
45 #define EMPTYSR(x) if(stkerr !=0){printf("stack empty\n");pushp(x);return(1);}
46 #define error(p)	{printf(p); continue; }
47 #define errorrt(p)	{printf(p); return(1); }
48 struct blk {
49 	char	*rd;
50 	char	*wt;
51 	char	*beg;
52 	char	*last;
53 };
54 struct	blk *hfree;
55 struct	blk *getwd();
56 struct	blk *lookwd();
57 struct	blk *getdec();
58 struct	blk *morehd();
59 
60 struct	blk *arg1, *arg2;
61 int	svargc;
62 char	savk;
63 char	**svargv;
64 int	dbg;
65 int	ifile;
66 FILE	*curfile;
67 struct	blk *scalptr, *basptr, *tenptr, *inbas;
68 struct	blk *sqtemp, *chptr, *strptr, *divxyz;
69 struct	blk *stack[STKSZ];
70 struct	blk **stkptr,**stkbeg;
71 struct	blk **stkend;
72 int	stkerr;
73 int	lastchar;
74 struct	blk *readstk[RDSKSZ];
75 struct	blk **readptr;
76 struct	blk *rem;
77 int	k;
78 struct	blk *irem;
79 int	skd,skr;
80 struct	blk *pop(),*readin(),*add0(),*mult();
81 struct	blk *scalint();
82 struct	blk *removc();
83 struct	blk *add(),*div(),*removr();
84 struct	blk *exp();
85 struct	blk *sqrt();
86 struct	blk *salloc(),*copy();
87 struct	blk *scale();
88 int	neg;
89 struct	sym {
90 	struct	sym *next;
91 	struct	blk *val;
92 } symlst[TBLSZ];
93 struct	sym *stable[TBLSZ];
94 struct	sym *sptr,*sfree;
95 struct	wblk {
96 	struct blk **rdw;
97 	struct blk **wtw;
98 	struct blk **begw;
99 	struct blk **lastw;
100 };
101 FILE	*fsave;
102 long	rel;
103 long	nbytes;
104 long	all;
105 long	headmor;
106 long	obase;
107 int	fw,fw1,ll;
108 int	(*outdit)();
109 int	bigot(),hexot();
110 int	logo;
111 int	log10;
112 int	count;
113 char	*pp;
114 void	onintr();
115 char	*malloc();
116 char	*nalloc();
117 char	*realloc();
118