xref: /csrg-svn/usr.bin/dc/dc.h (revision 61961)
148238Sbostic /*-
2*61961Sbostic  * Copyright (c) 1989, 1993
3*61961Sbostic  *	The Regents of the University of California.  All rights reserved.
448238Sbostic  *
548238Sbostic  * %sccs.include.proprietary.c%
648238Sbostic  *
7*61961Sbostic  *	@(#)dc.h	8.1 (Berkeley) 06/06/93
848238Sbostic  */
911775Ssam 
1010926Srrh #define FATAL 0
1110926Srrh #define NFATAL 1
1210926Srrh #define BLK sizeof(struct blk)
1310926Srrh #define PTRSZ sizeof(int *)
1410926Srrh #define HEADSZ 1024
1510926Srrh #define STKSZ 100
1610926Srrh #define RDSKSZ 100
1710926Srrh #define TBLSZ 256
1810926Srrh #define ARRAYST 0241
1910926Srrh #define MAXIND 2048
2010926Srrh #define NL 1
2110926Srrh #define NG 2
2210926Srrh #define NE 3
2310926Srrh #define length(p) ((p)->wt-(p)->beg)
2410926Srrh #define rewind(p) (p)->rd=(p)->beg
2510926Srrh #define create(p)	(p)->rd = (p)->wt = (p)->beg
2610926Srrh #define fsfile(p)	(p)->rd = (p)->wt
2710926Srrh #define truncate(p)	(p)->wt = (p)->rd
2810926Srrh #define sfeof(p)	(((p)->rd==(p)->wt)?1:0)
2910926Srrh #define sfbeg(p)	(((p)->rd==(p)->beg)?1:0)
3010926Srrh #define sungetc(p,c)	*(--(p)->rd)=c
3110926Srrh #ifdef interdata
3210926Srrh #define NEGBYTE 0200
3310926Srrh #define MASK (-1 & ~0377)
3410926Srrh #define sgetc(p)	( ((p)->rd==(p)->wt) ? EOF :( ((*(p)->rd & NEGBYTE) != 0) ? ( *(p)->rd++ | MASK): *(p)->rd++ ))
3510926Srrh #define slookc(p)	( ((p)->rd==(p)->wt) ? EOF :( ((*(p)->rd & NEGBYTE) != 0) ? (*(p)->rd | MASK) : *(p)->rd ))
3610926Srrh #define sbackc(p)	( ((p)->rd==(p)->beg) ? EOF :( ((*(--(p)->rd) & NEGBYTE) != 0) ? (*(p)->rd | MASK): *(p)->rd ))
3710926Srrh #endif
3810926Srrh #ifndef interdata
3910926Srrh #define sgetc(p)	(((p)->rd==(p)->wt)?EOF:*(p)->rd++)
4010926Srrh #define slookc(p)	(((p)->rd==(p)->wt)?EOF:*(p)->rd)
4110926Srrh #define sbackc(p)	(((p)->rd==(p)->beg)?EOF:*(--(p)->rd))
4210926Srrh #endif
4310926Srrh #define sputc(p,c)	{if((p)->wt==(p)->last)more(p); *(p)->wt++ = c; }
4410926Srrh #define salterc(p,c)	{if((p)->rd==(p)->last)more(p); *(p)->rd++ = c; if((p)->rd>(p)->wt)(p)->wt=(p)->rd;}
4510926Srrh #define sunputc(p)	(*( (p)->rd = --(p)->wt))
4610926Srrh #define zero(p)	for(pp=(p)->beg;pp<(p)->last;)*pp++='\0'
4710926Srrh #define OUTC(x) {printf("%c",x); if(--count == 0){printf("\\\n"); count=ll;} }
4810926Srrh #define TEST2	{if((count -= 2) <=0){printf("\\\n");count=ll;}}
4910926Srrh #define EMPTY if(stkerr != 0){printf("stack empty\n"); continue; }
5010926Srrh #define EMPTYR(x) if(stkerr!=0){pushp(x);printf("stack empty\n");continue;}
5110926Srrh #define EMPTYS if(stkerr != 0){printf("stack empty\n"); return(1);}
5210926Srrh #define EMPTYSR(x) if(stkerr !=0){printf("stack empty\n");pushp(x);return(1);}
5310926Srrh #define error(p)	{printf(p); continue; }
5410926Srrh #define errorrt(p)	{printf(p); return(1); }
5510926Srrh struct blk {
5610926Srrh 	char	*rd;
5710926Srrh 	char	*wt;
5810926Srrh 	char	*beg;
5910926Srrh 	char	*last;
6010926Srrh };
6110926Srrh struct	blk *hfree;
6210926Srrh struct	blk *getwd();
6310926Srrh struct	blk *lookwd();
6410926Srrh struct	blk *getdec();
6510926Srrh struct	blk *morehd();
6610926Srrh 
6710926Srrh struct	blk *arg1, *arg2;
6810926Srrh int	svargc;
6910926Srrh char	savk;
7010926Srrh char	**svargv;
7110926Srrh int	dbg;
7210926Srrh int	ifile;
7310926Srrh FILE	*curfile;
7410926Srrh struct	blk *scalptr, *basptr, *tenptr, *inbas;
7510926Srrh struct	blk *sqtemp, *chptr, *strptr, *divxyz;
7610926Srrh struct	blk *stack[STKSZ];
7710926Srrh struct	blk **stkptr,**stkbeg;
7810926Srrh struct	blk **stkend;
7910926Srrh int	stkerr;
8010926Srrh int	lastchar;
8110926Srrh struct	blk *readstk[RDSKSZ];
8210926Srrh struct	blk **readptr;
8310926Srrh struct	blk *rem;
8410926Srrh int	k;
8510926Srrh struct	blk *irem;
8610926Srrh int	skd,skr;
8710926Srrh struct	blk *pop(),*readin(),*add0(),*mult();
8810926Srrh struct	blk *scalint();
8910926Srrh struct	blk *removc();
9010926Srrh struct	blk *add(),*div(),*removr();
9110926Srrh struct	blk *exp();
9258168Storek struct	blk *dcsqrt();
9310926Srrh struct	blk *salloc(),*copy();
9410926Srrh struct	blk *scale();
9510926Srrh int	neg;
9610926Srrh struct	sym {
9710926Srrh 	struct	sym *next;
9810926Srrh 	struct	blk *val;
9910926Srrh } symlst[TBLSZ];
10010926Srrh struct	sym *stable[TBLSZ];
10110926Srrh struct	sym *sptr,*sfree;
10210926Srrh struct	wblk {
10310926Srrh 	struct blk **rdw;
10410926Srrh 	struct blk **wtw;
10510926Srrh 	struct blk **begw;
10610926Srrh 	struct blk **lastw;
10710926Srrh };
10810926Srrh FILE	*fsave;
10910926Srrh long	rel;
11010926Srrh long	nbytes;
11110926Srrh long	all;
11210926Srrh long	headmor;
11310926Srrh long	obase;
11410926Srrh int	fw,fw1,ll;
11510926Srrh int	(*outdit)();
11610926Srrh int	bigot(),hexot();
11710926Srrh int	logo;
11810926Srrh int	log10;
11910926Srrh int	count;
12010926Srrh char	*pp;
12139168Sbostic void	onintr();
12210926Srrh char	*malloc();
12310926Srrh char	*nalloc();
12410926Srrh char	*realloc();
125