hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

dc.h (6974B)


      1 /*	from Unix 7th Edition /usr/src/cmd/dc/dc.h	*/
      2 /*
      3  * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  *   Redistributions of source code and documentation must retain the
      9  *    above copyright notice, this list of conditions and the following
     10  *    disclaimer.
     11  *   Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  *   All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *      This product includes software developed or owned by Caldera
     17  *      International, Inc.
     18  *   Neither the name of Caldera International, Inc. nor the names of
     19  *    other contributors may be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
     23  * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
     24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
     27  * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     33  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     34  */
     35 
     36 /*	Sccsid @(#)dc.h	1.9 (gritter) 2/4/05>	*/
     37 
     38 #include	<stdlib.h>
     39 #include	<signal.h>
     40 
     41 #define FATAL 0
     42 #define NFATAL 1
     43 #define BLK sizeof(struct blk)
     44 #define PTRSZ sizeof(int *)
     45 #define HEADSZ 1024
     46 #define STKSZ 100
     47 #define RDSKSZ 100
     48 #define TBLSZ 256
     49 #define ARRAYST 0241
     50 #define NL 1
     51 #define NG 2
     52 #define NE 3
     53 #define length(p) ((p)->wt-(p)->beg)
     54 #define rewind(p) (p)->rd=(p)->beg
     55 #define create(p)	(p)->rd = (p)->wt = (p)->beg
     56 #define fsfile(p)	(p)->rd = (p)->wt
     57 #define truncate(p)	(p)->wt = (p)->rd
     58 #define sfeof(p)	(((p)->rd>=(p)->wt)?1:0)
     59 #define sfbeg(p)	(((p)->rd==(p)->beg)?1:0)
     60 #define sungetc(p,c)	*(--(p)->rd)=c
     61 #ifdef interdata
     62 #define NEGBYTE 0200
     63 #define MASK (-1 & ~0377)
     64 #define sgetc(p)	( ((p)->rd==(p)->wt) ? EOF :( ((*(p)->rd & NEGBYTE) != 0) ? ( *(p)->rd++ | MASK): *(p)->rd++ ))
     65 #define slookc(p)	( ((p)->rd==(p)->wt) ? EOF :( ((*(p)->rd & NEGBYTE) != 0) ? (*(p)->rd | MASK) : *(p)->rd ))
     66 #define sbackc(p)	( ((p)->rd==(p)->beg) ? EOF :( ((*(--(p)->rd) & NEGBYTE) != 0) ? (*(p)->rd | MASK): *(p)->rd ))
     67 #endif
     68 #ifndef interdata
     69 #define sgetc(p)	(((p)->rd==(p)->wt)?EOF:*(p)->rd++)
     70 #define slookc(p)	(((p)->rd==(p)->wt)?EOF:*(p)->rd)
     71 #define sbackc(p)	(((p)->rd==(p)->beg)?EOF:*(--(p)->rd))
     72 #endif
     73 #define sputc(p,c)	{if((p)->wt==(p)->last)more(p); *(p)->wt++ = c; }
     74 #define salterc(p,c)	{if((p)->rd==(p)->last)more(p); *(p)->rd++ = c; if((p)->rd>(p)->wt)(p)->wt=(p)->rd;}
     75 #define sunputc(p)	(*( (p)->rd = --(p)->wt))
     76 #define zero(p)	for(pp=(p)->beg;pp<(p)->last;)*pp++='\0'
     77 #define OUTC(x) {int _c = (x); if (_c) {printf("%c",_c); if(--count == 0){printf("\\\n"); count=ll;} } }
     78 #define TEST2(b)	{ OUTC(b[0] & 0377); OUTC(b[1] & 0377); }
     79 #define EMPTY if(stkerr != 0){printf("stack empty\n"); continue; }
     80 #define EMPTYR(x) if(stkerr!=0){pushp(x);printf("stack empty\n");continue;}
     81 #define EMPTYS if(stkerr != 0){printf("stack empty\n"); return(1);}
     82 #define EMPTYSR(x) if(stkerr !=0){printf("stack empty\n");pushp(x);return(1);}
     83 #define error(p)	{printf(p); continue; }
     84 #define errorrt(p)	{printf(p); return(1); }
     85 struct blk {
     86 	char	*rd;
     87 	char	*wt;
     88 	char	*beg;
     89 	char	*last;
     90 };
     91 struct	blk *hfree;
     92 struct	blk *arg1, *arg2;
     93 int	svargc;
     94 char	savk;
     95 char	**svargv;
     96 int	dbg;
     97 int	ifile;
     98 FILE	*curfile;
     99 struct	blk *scalptr, *basptr, *tenptr, *inbas;
    100 struct	blk *sqtemp, *chptr, *strptr, *divxyz;
    101 struct	blk *stack[STKSZ];
    102 struct	blk **stkptr,**stkbeg;
    103 struct	blk **stkend;
    104 int	stkerr;
    105 int	lastchar;
    106 struct	blk *readstk[RDSKSZ];
    107 struct	blk **readptr;
    108 struct	blk *rem;
    109 int	k;
    110 struct	blk *irem;
    111 int	skd,skr;
    112 int	neg;
    113 struct	sym {
    114 	struct	sym *next;
    115 	struct	blk *val;
    116 } symlst[TBLSZ];
    117 struct	sym *stable[TBLSZ];
    118 struct	sym *sptr,*sfree;
    119 struct	wblk {
    120 	struct blk **rdw;
    121 	struct blk **wtw;
    122 	struct blk **begw;
    123 	struct blk **lastw;
    124 };
    125 FILE	*fsave;
    126 long	rel;
    127 long	nbytes;
    128 long	all;
    129 long	headmor;
    130 long	obase;
    131 int	fw,fw1,ll;
    132 int	(*outdit)(struct blk *, int, int);
    133 int	logo;
    134 int	log_10;
    135 int	count;
    136 char	*pp;
    137 char	*dummy;
    138 
    139 #define	div(a, b)	dcdiv(a, b)
    140 #define	sqrt(a)		dcsqrt(a)
    141 #define	exp(a, b)	dcexp(a, b)
    142 #define	getwd(a)	dcgetwd(a)
    143 extern void commnds(void);
    144 extern struct blk *div(struct blk *, struct blk *);
    145 extern int dscale(void);
    146 extern struct blk *removr(struct blk *, int);
    147 extern struct blk *sqrt(struct blk *);
    148 extern struct blk *exp(struct blk *, struct blk *);
    149 extern void init(int, char *[]);
    150 extern void onintr(int);
    151 extern void pushp(struct blk *);
    152 extern struct blk *pop(void);
    153 extern struct blk *readin(void);
    154 extern struct blk *add0(struct blk *, int);
    155 extern struct blk *mult(struct blk *, struct blk *);
    156 extern void chsign(struct blk *);
    157 extern int readc(void);
    158 extern void unreadc(char);
    159 extern void binop(char);
    160 extern void print(struct blk *);
    161 extern struct blk *getdec(struct blk *, int);
    162 extern void tenot(struct blk *, int);
    163 extern void oneot(struct blk *, int, char);
    164 extern void hexot(struct blk *, int, int);
    165 extern void bigot(struct blk *, int, int);
    166 extern struct blk *add(struct blk *, struct blk *);
    167 extern int eqk(void);
    168 extern struct blk *removc(struct blk *, int);
    169 extern struct blk *scalint(struct blk *);
    170 extern struct blk *scale(struct blk *, int);
    171 extern int subt(void);
    172 extern int command(void);
    173 extern int cond(char);
    174 extern void load(void);
    175 extern int log_2(long);
    176 extern struct blk *salloc(int);
    177 extern struct blk *morehd(void);
    178 extern struct blk *copy(struct blk *, int);
    179 extern void sdump(char *, struct blk *);
    180 extern void seekc(struct blk *, int);
    181 extern void salterwd(struct wblk *, struct blk *);
    182 extern void more(struct blk *);
    183 extern void ospace(char *);
    184 extern void garbage(char *);
    185 extern void redef(struct blk *);
    186 extern void release(register struct blk *);
    187 extern struct blk *getwd(struct blk *);
    188 extern void putwd(struct blk *, struct blk *);
    189 extern struct blk *lookwd(struct blk *);
    190 extern char *nalloc(register char *, unsigned);
    191 extern void *srealloc(void *, size_t);
    192 
    193 #if defined (__GLIBC__) && defined (_IO_getc_unlocked)
    194 #undef	getc
    195 #define	getc(f)		_IO_getc_unlocked(f)
    196 #endif
    197 
    198 #ifndef	BC_BASE_MAX
    199 #define	BC_BASE_MAX	99
    200 #endif
    201 #ifndef	BC_DIM_MAX
    202 #define	BC_DIM_MAX	2048
    203 #endif