home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume8 / gnuplot1.10A / part04 / plot.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-09  |  5.7 KB  |  250 lines

  1. /*
  2.  *
  3.  *    G N U P L O T  --  plot.h
  4.  *
  5.  *  Copyright (C) 1986, 1987  Thomas Williams, Colin Kelley
  6.  *
  7.  *  You may use this code as you wish if credit is given and this message
  8.  *  is retained.
  9.  *
  10.  *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  11.  *  included in later releases.
  12.  *
  13.  *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  14.  */
  15.  
  16. #define PROGRAM "G N U P L O T"
  17. #define PROMPT "gnuplot> "
  18. #define SHELL "/bin/sh"        /* used if SHELL env variable not set */
  19.  
  20. #ifdef vms
  21. #define HELP  "gnuplot "
  22. #else /* vms */
  23. #define HELP  "/usr/local/bin/help gnuplot"
  24. #endif /* vms */
  25.  
  26. #define SAMPLES 160            /* default number of samples for a plot */
  27. #define ZERO    1e-8        /* default for 'zero' set option */
  28.  
  29. #ifdef __TURBOC__
  30. #ifndef PC
  31. #define PC 1
  32. #endif
  33. #endif
  34.  
  35. #ifdef PC
  36. #define TERM "egalib"
  37. #else
  38. #ifdef UNIXPC
  39. #define TERM "unixpc"
  40. #else
  41. #define TERM "tek40xx"        /* put your most common term type here! */
  42. #endif 
  43. #endif
  44.  
  45. #define TRUE 1
  46. #define FALSE 0
  47.  
  48. #define Pi 3.141592653589793
  49.  
  50. #define MAX_POINTS 1
  51. #define MAX_LINE_LEN 255    /* maximum number of chars allowed on line */
  52. #define MAX_TOKENS 200
  53. #define MAX_ID_LEN 20        /* max length of an identifier */
  54.  
  55. #define MAX_AT_LEN 150        /* max number of entries in action table */
  56. #define STACK_DEPTH 100
  57. #define NO_CARET (-1)
  58.  
  59.  
  60. #ifdef vms
  61. #define OS "VMS "
  62. #endif
  63.  
  64. #ifdef unix
  65. #define OS "unix "
  66. #endif
  67.  
  68. #ifdef MSDOS
  69. #define OS "MS-DOS "
  70. #endif
  71.  
  72. #ifndef OS
  73. #define OS ""
  74. #endif
  75.  
  76. /*
  77.  * note about HUGE:  this number is just used as a flag for really
  78.  *   big numbers, so it doesn't have to be the absolutely biggest number
  79.  *   on the machine.
  80.  *
  81.  * define HUGE here if your compiler doesn't define it in <math.h>
  82.  * example:
  83. #define HUGE 1e38
  84.  */
  85. #ifndef HUGE 
  86. #ifdef HUGE_VAL  /* __TURBOC__ and VMS C ver 3.0 (ansi type compilers) */
  87. #define HUGE HUGE_VAL
  88. #else
  89. #define HUGE 1e38
  90. #endif
  91. #endif
  92.  
  93. #define END_OF_COMMAND (c_token >= num_tokens || equals(c_token,";"))
  94.  
  95.  
  96. #ifdef vms
  97.  
  98. #define is_comment(c) ((c) == '#' || (c) == '!')
  99. #define is_system(c) ((c) == '$')
  100.  
  101. #else /* vms */
  102.  
  103. #define is_comment(c) ((c) == '#')
  104. #define is_system(c) ((c) == '!')
  105.  
  106. #endif /* vms */
  107.  
  108. /*
  109.  * If you're memcpy() has another name, define it below as bcopy() is.
  110.  * If you don't have a memcpy():
  111. #define NOCOPY
  112.  */
  113.  
  114. #ifdef BCOPY
  115. #define memcpy(dest,src,len) bcopy(src,dest,len)
  116. #endif /* BCOPY */
  117.  
  118. #ifdef vms
  119. #define memcpy(dest,src,len) lib$movc3(&len,src,dest)
  120. #endif /* vms */
  121.  
  122. #define top_of_stack stack[s_p]
  123.  
  124. typedef int BOOLEAN;
  125. typedef int (*FUNC_PTR)();
  126.  
  127. enum operators {
  128.     PUSH, PUSHC, PUSHD, CALL, LNOT, BNOT, UMINUS, LOR, LAND, BOR, XOR,
  129.     BAND, EQ, NE, GT, LT, GE, LE, PLUS, MINUS, MULT, DIV, MOD, POWER,
  130.     FACTORIAL, BOOL, JUMP, JUMPZ, JUMPNZ, JTERN, SF_START
  131. };
  132.  
  133. #define is_jump(operator) ((operator) >=(int)JUMP && (operator) <(int)SF_START)
  134.  
  135. enum DATA_TYPES {
  136.     INT, CMPLX
  137. };
  138.  
  139. enum PLOT_TYPE {
  140.     FUNC, DATA
  141. };
  142.  
  143. enum PLOT_STYLE {
  144.     LINES, POINTS, IMPULSES
  145. };
  146.  
  147. struct cmplx {
  148.     double real, imag;
  149. };
  150.  
  151. struct value {
  152.     enum DATA_TYPES type;
  153.     union {
  154.         int int_val;
  155.         struct cmplx cmplx_val;
  156.     } v;
  157. };
  158.  
  159. struct lexical_unit {    /* produced by scanner */
  160.     BOOLEAN is_token;    /* true if token, false if a value */ 
  161.     struct value l_val;
  162.     int start_index;    /* index of first char in token */
  163.     int length;            /* length of token in chars */
  164. };
  165.  
  166. struct ft_entry {        /* standard/internal function table entry */
  167.     char *f_name;        /* pointer to name of this function */
  168.     FUNC_PTR func;        /* address of function to call */
  169. };
  170.  
  171. struct udft_entry {                /* user-defined function table entry */
  172.     struct udft_entry *next_udf; /* pointer to next udf in linked list */
  173.     char udf_name[MAX_ID_LEN+1]; /* name of this function entry */
  174.     struct at_type *at;            /* pointer to action table to execute */
  175.     char *definition;             /* definition of function as typed */
  176.     struct value dummy_value;    /* current value of dummy variable */
  177. };
  178.  
  179. struct udvt_entry {            /* user-defined value table entry */
  180.     struct udvt_entry *next_udv; /* pointer to next value in linked list */
  181.     char udv_name[MAX_ID_LEN+1]; /* name of this value entry */
  182.     BOOLEAN udv_undef;        /* true if not defined yet */
  183.     struct value udv_value;    /* value it has */
  184. };
  185.  
  186. union argument {            /* p-code argument */
  187.     int j_arg;                /* offset for jump */
  188.     struct value v_arg;        /* constant value */
  189.     struct udvt_entry *udv_arg;    /* pointer to dummy variable */
  190.     struct udft_entry *udf_arg; /* pointer to udf to execute */
  191. };
  192.  
  193. struct at_entry {            /* action table entry */
  194.     enum operators index;    /* index of p-code function */
  195.     union argument arg;
  196. };
  197.  
  198. struct at_type {
  199.     int a_count;                /* count of entries in .actions[] */
  200.     struct at_entry actions[MAX_AT_LEN];
  201.         /* will usually be less than MAX_AT_LEN is malloc()'d copy */
  202. };
  203.  
  204. struct coordinate {
  205.     BOOLEAN undefined;    /* TRUE if value off screen */
  206. #ifdef PC
  207.     float x, y;            /* memory is tight on PCs! */
  208. #else
  209.     double x, y;
  210. #endif /* PC */
  211. };
  212.  
  213. struct curve_points {
  214.     struct curve_points *next_cp;    /* pointer to next plot in linked list */
  215.     enum PLOT_TYPE plot_type;
  216.     enum PLOT_STYLE plot_style;
  217.     char *title;
  218.     int p_count;                    /* count of points in .points[] */
  219.     struct coordinate points[MAX_POINTS];
  220.         /* will usually be less in malloc()'d copy */
  221. };
  222.  
  223. struct termentry {
  224.     char *name;
  225.     unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic;
  226.     FUNC_PTR init,reset,text,graphics,move,vector,linetype,lrput_text,
  227.         ulput_text,point;
  228. };
  229.  
  230. /*
  231.  * SS$_NORMAL is "normal completion", STS$M_INHIB_MSG supresses
  232.  * printing a status message.
  233.  * SS$_ABORT is the general abort status code.
  234.  from:    Martin Minow
  235.     decvax!minow
  236.  */
  237. #ifdef    vms
  238. #include        <ssdef.h>
  239. #include        <stsdef.h>
  240. #define    IO_SUCCESS    (SS$_NORMAL | STS$M_INHIB_MSG)
  241. #define    IO_ERROR    SS$_ABORT
  242. #endif /* vms */
  243.  
  244. #ifndef    IO_SUCCESS    /* DECUS or VMS C will have defined these already */
  245. #define    IO_SUCCESS    0
  246. #endif
  247. #ifndef    IO_ERROR
  248. #define    IO_ERROR    1
  249. #endif
  250.