# ifndef __UTIL_ESSENTIAL_H__ # define __UTIL_ESSENTIAL_H__ #ifdef __cplusplus extern "C" { #endif # define SAY_HI_FIRST2 \ int _say_hi_first_ = fprintf(stderr,\ "%s Program %s with %d argument%sat line %d in source\n%s %s, which was compiled on %s at %s.\n"\ ,"Hi:",argv[0],argc,(argc == 1 ? " " : "s "),__LINE__,\ "Hi:",__FILE__,__DATE__,__TIME__) /** *** Postscript Constants **/ # define A4WI 8.25 # define A4LI 11.687500000 # define IPERP 72 # define A4WP (A4WI * IPERP) # define A4LP (A4LI * IPERP) /** *** Numeric constants **/ # ifndef INFINITY # define INFINITY HUGE # endif # ifndef PI # define PI 3.1415926 # endif # define MAXSTACK 1000 # define VOID # define ON # undef OFF # define DUMARG 0 # define XPLOR_UNKNOWN 9999.000 # define MAXRAND 2147483645.0 /* = 2^31-1 */ /* ---- */ # define RANF(from,to) ( \ /* ---- */\ ( (to) - (from) ) * ((double) random() / MAXRAND) + (from) \ ) # define RC(R,r,c) (R[(r-1)*3 + c-1]) # define TODEG(x) ((x) * ( 180.0/PI ) ) # define TORAD(x) ((x) * ( PI/180.0 ) ) # define FLOATEQ(a,b) (fabs(a-b)<0.000000001) # define STRNEQ(a,b,n) (strncmp(a,b,n) == 0) # define STREQ(a,b) (strcmp(a,b) == 0) # define STJOIN(buf,s1,s2) (strcat(strcpy(buf,s1),s2)) # define SWAP(a,b) swap((char *)&a,(char *)&b,sizeof(a)) # define PUSH(a) push((char *)&a, sizeof(a)) # define POP(a) pop((char *)&a, sizeof(a)) # define CR printf("\n"); # define HERE2 printf("%s (%s): at __LINE__=%d\n",FILENAME,subr,__LINE__); # define HERE(msg) { printf("%s [%d]: %s\n",__FILE__,__LINE__,msg);} # define TOE(msg) { fprintf(stderr,"%s [%d]: %s\n",__FILE__,__LINE__,msg);} # define HERE_OFF(msg) # define offHERE(msg) # define STDOUT(msg) { printf("%s [%d]: %s\n",__FILE__,__LINE__,msg);} # define STDERR(msg) { fprintf(stderr,"%s [%d]: %s\n",__FILE__,__LINE__,msg);} # define STDERR_PREFIX(msg) { fprintf(stderr,"%s [%d]: %s",__FILE__,__LINE__,msg);} # define DB STDERR("** Got Here **"); /* Works with Concentrix 3.0 ; ANSI C way to make an argument into a string */ # define MAKESTRING(splicearg) #splicearg # define ITOD(splicearg) \ (printf("%s [%d]: %s = %d\n",__FILE__,__LINE__,MAKESTRING(splicearg),splicearg),splicearg) # define PTOD(splicearg) \ (printf("%s [%d]: %s = %8x\n",__FILE__,__LINE__,MAKESTRING(splicearg),splicearg),splicearg) # define ATOD(splicearg) \ (printf("%s [%d]: %s = %s\n",__FILE__,__LINE__,MAKESTRING(splicearg),splicearg),splicearg) # define FTOD(splicearg) \ (printf("%s [%d]: %s = %f\n",__FILE__,__LINE__,MAKESTRING(splicearg),splicearg),splicearg) # define ITOE(splicearg) \ (fprintf(stderr,"%s [%d]: %s = %d\n",__FILE__,__LINE__,MAKESTRING(splicearg),splicearg),splicearg) # define ATOE(splicearg) \ (fprintf(stderr,"%s [%d]: %s = %s\n",__FILE__,__LINE__,MAKESTRING(splicearg),splicearg),splicearg) # define FTOE(splicearg) \ (fprintf(stderr,"%s [%d]: %s = %f\n",__FILE__,__LINE__,MAKESTRING(splicearg),splicearg),splicearg) # define VTOD(splicearg)\ {printf("%s [%d]: %s=( %f %f %f )\n",__FILE__,__LINE__,\ MAKESTRING(splicearg),splicearg[0],splicearg[1],splicearg[2]);} # define NRTOD(splicearg)\ {printf("%s [%d]: %s=( %f %f %f )\n",__FILE__,__LINE__,\ MAKESTRING(splicearg),splicearg[1],splicearg[2],splicearg[3]);} # define NRTOE(splicearg)\ {fprintf(stderr,"%s [%d]: %s=( %f %f %f )\n",__FILE__,__LINE__,\ MAKESTRING(splicearg),splicearg[1],splicearg[2],splicearg[3]);} # define NTOE(splicearg) \ (fprintf(stderr,"%s [%d]: %s = %f\n",__FILE__,__LINE__,MAKESTRING(splicearg),(float)splicearg),splicearg) # define HERE_NTIMES(max) \ { \ static int count = 1 ; \ if (count <= max) { \ fprintf(stderr, \ "In %s, %2d th time at line %4d (max visits is %2d)\n", \ __FILE__,count,__LINE__,max); \ count++ ; \ } \ } \ # define MSG_NTIMES(max,msg) \ { \ static int count = 1 ; \ if (count <= max) { \ fprintf(stderr, \ "In %s, time %2d at line %4d (max visits is %2d): %s\n", \ __FILE__,count,__LINE__,max,msg); \ count++ ; \ } \ } \ # define OFF_MSG_NTIMES(max,msg) typedef enum {false=0, true=1} bool; typedef double * nrVectorD ; typedef double ** nrMatrixD ; #ifdef __cplusplus } #endif # endif /* !__UTIL_ESSENTIAL_H__ */