home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / apps / math / euler / source / header.h < prev    next >
C/C++ Source or Header  |  1993-03-25  |  5KB  |  173 lines

  1. extern char *ramstart,*ramend,*startlocal,*endlocal,
  2.     *newram,*udfend,*varstart;
  3.  
  4. #if defined __MSDOS__
  5. #define SPLIT_MEM
  6. #define FLOAT_TEST
  7. #endif
  8.  
  9. #define LONG size_t
  10. #define TAB 9
  11.  
  12. #ifndef M_PI
  13. #define M_PI            3.14159265358979323846
  14. #endif
  15.  
  16. #define EXTENSION ".e"
  17.  
  18. extern char fktext[10][64];
  19.  
  20. extern int error,surpressed,udf,udfon,linelength,stringon;
  21. extern long loopindex;
  22. extern char *next,*udfline;
  23. extern int actargn;
  24.  
  25. extern int linew,fieldw,hchar,wchar;
  26. extern double maxexpo,minexpo;
  27. extern char expoformat[],fixedformat[];
  28.  
  29. extern FILE *infile,*outfile;
  30. void output(char *s);
  31. void output1(char *form, ...);
  32. #define output2(form,s,t) output1(form,s,t)
  33.  
  34. typedef enum { s_real,s_complex,s_matrix,s_cmatrix,
  35.     s_reference,s_command,s_submatrix,s_csubmatrix,s_string,s_udf } 
  36.     stacktyp;
  37. typedef struct
  38. {    LONG size; char name[16]; int xor; stacktyp type; int flags;
  39. #ifdef SPECIAL_ALIGNMENT
  40.     double dummy;
  41. #endif
  42.     }
  43.     header;
  44. typedef struct { int c,r; 
  45. #ifdef SPECIAL_ALIGNMENT
  46.     double dummy;
  47. #endif
  48.     } dims;
  49. typedef struct { header hd; double val; } realtyp;
  50.  
  51. extern double epsilon;
  52.  
  53. typedef enum { c_none, c_allv, c_quit, c_hold, 
  54.         c_shg, c_load, c_udf, c_return, c_for, c_end, c_break,
  55.         c_loop, c_if, c_repeat, c_endif, c_else,
  56.         c_clear, c_clg, c_cls, c_exec, c_forget, c_global } 
  57.     comtyp;
  58.  
  59. typedef struct { char *name; comtyp nr; void (*f)(void); } commandtyp;
  60.  
  61. typedef struct { char *name; int nargs;  void (*f) (header *); }
  62.     builtintyp;
  63. extern builtintyp builtin_list[];
  64.  
  65. /* edit.c */
  66.  
  67. void edit (char *s);
  68. void prompt (void);
  69.  
  70. /* mainloop.c */
  71.  
  72. extern char *argname[];
  73. extern int xors[];
  74.  
  75. void print_error (char *p);
  76.  
  77. void main_loop (int argc, char *argv[]);
  78. header *new_matrix (int c, int r, char *name);
  79. header *new_cmatrix (int c, int r, char *name);
  80. header *new_real (double x, char *name);
  81. header *new_complex (double x, double y, char *name);
  82. header *new_reference (header *hd, char *name);
  83. header *new_submatrix (header *hd, header *cols, header *rows,
  84.     char *name);
  85. header *new_csubmatrix (header *hd, header *cols, header *rows,
  86.     char *name);
  87. header *new_command (int no);
  88. header *new_string (char *s, size_t size, char *name);
  89. header *new_udf (char *name);
  90. header *new_subm (header *var, LONG l, char *name);
  91. header *new_csubm (header *var, LONG l, char *name);
  92.  
  93. int xor (char *n);
  94.  
  95. void scan_space (void);
  96. void scan_name (char *name);
  97. void next_line (void);
  98. void trace_udfline(char *);
  99. void getmatrix (header *hd, int *r, int *c, double **x);
  100. header *searchvar (char *name);
  101. header *searchudf (char *name);
  102.  
  103. #define realof(hd) ((double *)((hd)+1))
  104. #define matrixof(hd) ((double *)((char *)((hd)+1)+sizeof(dims)))
  105. #define dimsof(hd) ((dims *)((hd)+1))
  106. #define commandof(hd) ((int *)((hd)+1))
  107. #define referenceof(hd) (*((header **)((hd)+1)))
  108. #define imagof(hd) ((double *)((hd)+1)+1)
  109. #define rowsof(hd) ((int *)((dims *)((header **)((hd)+1)+1)+1))
  110. #define colsof(hd) ((int *)((dims *)((header **)((hd)+1)+1)+1)+submdimsof((hd))->r)
  111. #define submrefof(hd) (*((header **)((hd)+1)))
  112. #define submdimsof(hd) ((dims *)((header **)((hd)+1)+1))
  113. #define stringof(hd) ((char *)((hd)+1))
  114. #define udfof(hd) ((char *)(hd)+(*((size_t *)((hd)+1))))
  115. #define udfstartof(hd) ((size_t *)((hd)+1))
  116. #define helpof(hd) ((char *)(hd)+sizeof(header)+sizeof(size_t))
  117. #define nextof(hd) ((header *)((char *)(hd)+(hd)->size))
  118.  
  119. #define mat(m,c,i,j) (m+(((LONG)(c))*(i)+(j)))
  120. #define cmat(m,c,i,j) (m+(2*(((LONG)(c))*(i)+(j))))
  121.  
  122. #define matrixsize(c,r) (sizeof(header)+sizeof(dims)+(c)*(LONG)(r)*sizeof(double))
  123. #define cmatrixsize(c,r) (sizeof(header)+sizeof(dims)+2l*(c)*(LONG)(r)*sizeof(double))
  124.  
  125. header *next_param (header *hd);
  126.  
  127. void give_out (header *hd);
  128.  
  129. int command (void);
  130.  
  131. /* express.c */
  132.  
  133. header *map2 (void f(double *,double *,double *),
  134.     void fc(double *, double *, double *, double *, double *, double *),
  135.     header *hd, header *hd1);
  136. header *map1 (void f(double *, double *), 
  137.     void fc(double *, double *, double *, double *),
  138.     header *hd);
  139. header *map1r (void f(double *, double *), 
  140.     void fc(double *, double *, double *),
  141.     header *hd);
  142. header *getvalue (header *);
  143. header *getvariable (header *);
  144. header *scan(void);
  145. header *scan_value(void);
  146. void moveresult (header *stack, header *result);
  147. void moveresult1 (header *stack, header *result);
  148. void copy_complex (double *, double *);
  149. void complex_divide (double *, double *, double *, double *, double *,
  150.     double *);
  151. void complex_multiply (double *, double *, double *, double *, double *,
  152.     double *);
  153.  
  154. void interpret_udf (header *var, header *args, int nargs);
  155.  
  156. int scan_arguments (void);
  157.  
  158. /* several */
  159.  
  160. void mnot (header *hd);
  161. void mand (header *hd);
  162. void mor (header *hd);
  163. void mvconcat (header *hd);
  164. void mhconcat (header *hd);
  165.  
  166. void sort_builtin (void);
  167. void sort_commands (void);
  168.  
  169. void make_xors (void);
  170.  
  171. extern FILE *metafile;
  172.  
  173.