home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 334_02 / plot2.h < prev    next >
Text File  |  1991-02-05  |  5KB  |  175 lines

  1. /*
  2.  *
  3.  *    gnutex/gnuplot translator  --  plot.h
  4.  *
  5.  * By David Kotz, 1990.
  6.  * Department of Computer Science, Duke University, Durham, NC 27706.
  7.  * Mail to dfk@cs.duke.edu.
  8.  */
  9.  
  10. #define PROGRAM "gnut2p"
  11. #define PROMPT "gnut2p>"
  12.  
  13. #define TRUE 1
  14. #define FALSE 0
  15.  
  16. #define Pi 3.141592653589793
  17.  
  18. #define MAX_PLOTS 16            /* max number of overlapping plots */
  19. #define MAX_LINE_LEN 512    /* maximum number of chars allowed on line */
  20. #define MAX_TOKENS 200
  21. #define MAX_ID_LEN 200        /* max length of an identifier (long for files)*/
  22.  
  23. #ifdef PC
  24. #define MAX_UDFS 20            /* max number of user-defined functions */
  25. #else /* PC */
  26. #define MAX_UDFS 100
  27. #endif /* PC */
  28.  
  29. #define MAX_STYLES 20        /* max number of user-defined styles */
  30. #define MAX_KEYS 16            /* max number of entries in key */
  31. #define MAX_VALUES 50        /* max number of user-defined constants */
  32. #define MAX_AT_LEN 100        /* max number of entries in action table */
  33. #define STACK_DEPTH 100
  34. #define NO_CARET (-1)
  35.  
  36. #define SAMPLES 160            /* default number of samples for a plot */
  37. #define ZERO    1e-8        /* default for 'zero' set option */
  38.  
  39. /*
  40.  * note about HUGE:  this number is just used as a flag for really
  41.  *   big numbers, so it doesn't have to be the absolutely biggest number
  42.  *   on the machine.
  43.  */
  44.  
  45. #ifdef PC
  46. #define  HUGE 1e38
  47. #endif /* PC */
  48.  
  49. #define END_OF_COMMAND (c_token == num_tokens || equals(c_token,";"))
  50. #define push(arg) f_pushc(arg)    /* same thing! */
  51.  
  52. #define top_of_stack stack[s_p]
  53.  
  54. typedef int BOOLEAN;
  55. typedef int (*FUNC_PTR)();
  56.  
  57. enum {
  58.     C_PI, NEXT_VALUE
  59. };
  60.  
  61. enum operators {
  62.     PUSH, PUSHC, PUSHD, CALL, TERNIARY, LNOT, BNOT, UMINUS, LOR, LAND, BOR,
  63.     XOR, BAND, EQ, NE, GT, LT, GE, LE, PLUS, MINUS, MULT, DIV, MOD, POWER,
  64.     SF_START
  65. };
  66.  
  67. enum DATA_TYPES {
  68.     INT, CMPLX
  69. };
  70.  
  71. enum PLOT_TYPES {
  72.     FUNC, DATA
  73. };
  74.  
  75. enum PLOT_STYLE {
  76.     LINES, POINTS, IMPULSES, LINESPOINTS, DOTS
  77. };
  78. #define FIXED_STYLES ((int)DOTS) /* highest numbered fixed style */
  79.  
  80. struct cmplx {
  81.     double real, imag;
  82. };
  83.  
  84. struct value {
  85.     enum DATA_TYPES type;
  86.     union {
  87.         char *str_val;
  88.         int int_val;
  89.         struct cmplx cmplx_val;
  90.     } v;
  91. };
  92.  
  93. struct lexical_unit {
  94.     BOOLEAN is_token;        /* true if token, false if a value */ 
  95.     struct value l_val;
  96.     int start_index;    /* index of first char in token */
  97.     int length;        /* length of token in chars */
  98. };
  99.  
  100. struct at_entry {        /* action table entry */
  101.     int index;        /* index into function table */
  102.     struct value arg;
  103. };
  104.  
  105. struct at_type {
  106.     int count;
  107.     struct at_entry actions[MAX_AT_LEN];
  108. };
  109.  
  110. struct ft_entry {        /* standard function table entry */
  111.     char *ft_name;        /* pointer to name of this function */
  112.     FUNC_PTR funct;        /* address of function to call */
  113. };
  114.  
  115. struct udft_entry {        /* user-defined function table entry */
  116.     char udft_name[MAX_ID_LEN+1];/* name of this function entry */
  117.     struct at_type at;    /* action table to execute */
  118.     char definition[MAX_LINE_LEN+1]; /* definition of function as typed */
  119.     struct value dummy_value;/* current value of dummy variable */
  120. };
  121.  
  122. struct vt_entry {        /* value table entry */
  123.     char vt_name[MAX_ID_LEN+1];/* name of this value entry */
  124.     BOOLEAN vt_undef;        /* true if not defined yet */
  125.     struct value vt_value;    /* value it has */
  126. };
  127.  
  128. struct st_entry {        /* style table entry */
  129.     char st_name[MAX_ID_LEN+1];/* name of this style entry */
  130.     BOOLEAN st_undef;        /* true if not defined yet */
  131.     char st_point[MAX_ID_LEN+1]; /* string for point */
  132.     float st_spacing;        /* spacing of seqence */
  133.     short st_length;        /* length of sequence */
  134. #define MAX_STYLE_SEQ_LENGTH 5
  135.     char st_seq[MAX_STYLE_SEQ_LENGTH][MAX_ID_LEN+1]; /* dot sequence */
  136. };
  137. extern int next_style;
  138.  
  139. struct curve_points {
  140.     enum PLOT_TYPES plot_type;
  141.     unsigned int plot_style;    /* now an int to include user-defined styles */
  142.     char def[MAX_LINE_LEN + 1];
  143.     char title[MAX_LINE_LEN + 1];
  144. };
  145.  
  146. struct termentry {
  147.     char name[MAX_ID_LEN + 1];
  148.     unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic;
  149.     FUNC_PTR init,reset,text,graphics,move,vector,linetype,lrput_text,
  150.         ulput_text,point;
  151.     FUNC_PTR xyput_text, xtick_text, ytick_text;
  152.     FUNC_PTR plotstyle;
  153. };
  154.  
  155. /*
  156.  * SS$_NORMAL is "normal completion", STS$M_INHIB_MSG supresses
  157.  * printing a status message.
  158.  * SS$_ABORT is the general abort status code.
  159.  from:    Martin Minow
  160.     decvax!minow
  161.  */
  162. #ifdef    vms
  163. #include        <ssdef.h>
  164. #include        <stsdef.h>
  165. #define    IO_SUCCESS    (SS$_NORMAL | STS$M_INHIB_MSG)
  166. #define    IO_ERROR    SS$_ABORT
  167. #endif /* vms */
  168.  
  169. #ifndef    IO_SUCCESS    /* DECUS or VMS C will have defined these already */
  170. #define    IO_SUCCESS    0
  171. #endif
  172. #ifndef    IO_ERROR
  173. #define    IO_ERROR    1
  174. #endif
  175.