home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff391.lzh / ListPlot / Csrc / datatypes.h next >
C/C++ Source or Header  |  1990-10-27  |  4KB  |  154 lines

  1. /*
  2.  * datatypes.h
  3.  */
  4.  
  5. typedef    char    generic;
  6. typedef    int    bool;
  7. #define FALSE    (bool)0
  8. #define    TRUE    (!FALSE)
  9. typedef    float    FLOAT;
  10.  
  11. #if    defined(ibmRT)
  12. #    define    MAX_FLOAT    1.701e38
  13. #endif
  14. #if    defined(vax) || defined(vax3200) || defined(dgmv)
  15. #    define    MAX_FLOAT    1.701e38
  16. #endif
  17.  
  18. struct list_atom {
  19.     generic *la_p;
  20.     struct list_atom    *la_next;
  21. };
  22. typedef    struct list_atom LATOM;
  23. typedef    struct list {
  24.     int    list_n;
  25.     LATOM    *list_head;
  26.     LATOM    *list_tail;
  27.     } LIST;
  28.  
  29. typedef enum data_type {
  30.     integer,
  31.     dbl,
  32.     flt,
  33.     byte,
  34.     string,
  35.     interval,
  36.     boolean,
  37.     set,
  38.     rect
  39.     } DATATYPE;
  40. #define    isInteger(V) (V.val_type == integer? TRUE : FALSE)
  41. #define    isDbl(V) (V.val_type == dbl? TRUE : FALSE)
  42. #define    isFlt(V) (V.val_type == flt? TRUE : FALSE)
  43. #define    isByte(V) (V.val_type == byte? TRUE : FALSE)
  44. #define    isString(V) (V.val_type == string? TRUE : FALSE)
  45. #define    isInterval(V) (V.val_type == interval? TRUE : FALSE)
  46. #define    isBoolean(V) (V.val_type == boolean? TRUE : FALSE)
  47. #define    isSet(V) (V.val_type == set? TRUE : FALSE)
  48. #define    isRect(V) (V.val_type == rect? TRUE : FALSE)
  49.  
  50. #define    VtoInteger(V) (V).val_u.udt_int
  51. #define    VtoDbl(V) (V).val_u.udt_dbl
  52. #define    VtoFlt(V) (V).val_u.udt_flt
  53. #define    VtoByte(V) (V).val_u.udt_byte
  54. #define    VtoString(V) (V).val_u.udt_string
  55. #define    VtoInterval(V) (V).val_u.udt_interval
  56. #define    VtoBoolean(V) (V).val_u.udt_bool
  57. #define    VtoSet(V) (V).val_u.udt_set
  58. #define    VtoRect(V) (V).val_u.udt_rect
  59.  
  60.  
  61.  
  62. typedef    struct interval {
  63.     double    int_lo, int_hi;
  64.     } INTERVAL;
  65.  
  66. typedef    LIST    SET;
  67.  
  68. typedef    struct rect {
  69.         FLOAT    r_diag[4];        /* xmin,ymin, xmax,ymax */
  70.     } RECT;
  71. #define    XMin    r_diag[0]
  72. #define    YMin    r_diag[1]
  73. #define    XMax    r_diag[2]
  74. #define    YMax    r_diag[3]
  75.  
  76. typedef union data_types {
  77.     char        udt_byte;
  78.     int        udt_int;
  79.     bool        udt_bool;
  80.     double        udt_dbl;
  81.     float        udt_flt;
  82.     char        *udt_string;
  83.     INTERVAL    udt_interval;
  84.     SET        udt_set;         /* {a,b,c,...}    */
  85.     RECT        udt_rect;
  86.     } UTYPE;
  87.  
  88. typedef    struct    value    {
  89.     DATATYPE    val_type;
  90.     UTYPE        val_u;
  91.     } VALUE;
  92.  
  93. #define    Vstrcmp(V, S)    (V.val_type==string? strcmp(V.val_u.udt_string,S)==0? TRUE : FALSE : FALSE)
  94. #define    Vstrchr(V, C)    (V.val_type==string? strchr(V.val_u.udt_string,C)==(char *)NULL? FALSE : TRUE : FALSE)
  95.  
  96. typedef struct arg_def {
  97.     VALUE    *ad_value;
  98.     char    *ad_id;
  99.     char    *ad_options;
  100.     char    *ad_opttype;
  101.     char    *ad_default;
  102.     char    *ad_defaultType;
  103.     char    **ad_helptext;
  104. } ARGDEF;
  105.  
  106.  
  107. #ifdef    ANSI_C
  108. void    ErrorExit();
  109. bool    Append(LIST *L, generic *Ptr);
  110. char    *malloc(unsigned int);
  111. char    *calloc(unsigned int, unsigned int);
  112. char    *StrDup(char *Str);
  113. void    get_args(
  114.         int argc,
  115.         char **argv,
  116.         ARGDEF *Symbols[],
  117.         char *Usage[],
  118.         char *Function[]
  119.     );
  120. void    PrintArgDef(FILE *Fp, ARGDEF *D);
  121. void    PrintArg(FILE *Fp, ARGDEF *D);
  122. bool    ParseArg(ARGDEF *Symbols[], char *arg);
  123. bool    ParseEntry(ARGDEF *Entry, char  *arg);
  124. bool    ParseString(ARGDEF *Entry, char *Option, int n, char *arg);
  125. bool    ParseDbl(ARGDEF *Entry, char *arg);
  126. bool    ParseFloat(ARGDEF *Entry, char *arg);
  127. bool    ParseInt(ARGDEF *Entry, char *arg);
  128. bool    ParseBool(ARGDEF *Entry, char *arg);
  129. bool    ParseByte(ARGDEF *Entry, char *arg);
  130. bool    ParseInterval(ARGDEF *Entry, char *arg);
  131. bool    ParseSet(ARGDEF *Entry, char *arg, char *Type, int TypeWidth);
  132. bool    ParseRect(ARGDEF *Entry, char *arg);
  133.  
  134. void    PrintUsage(
  135.         FILE    *Fp,
  136.         char    *Usage[],
  137.         char    *Function[],
  138.         ARGDEF    *Symbols[]
  139.     );
  140. void    SetDefaults(ARGDEF *Symbols[]);
  141. bool    SetValue(VALUE *, char *Value, char *Type);
  142. bool    SetString(VALUE *, char *);
  143. bool    SetDbl(VALUE *, char *);
  144. bool    SetFloat(VALUE *, char *);
  145. bool    SetInt(VALUE *, char *);
  146. bool    SetBool(VALUE *, char *);
  147. bool    SetByte(VALUE *, char *);
  148. bool    SetInterval(VALUE *, char *);
  149. bool    SetSet(VALUE *, char *, char *, int);
  150. bool    SetRect(VALUE *, char *);
  151.  
  152. #else
  153. #endif
  154.