home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 168_01 / sdbio.h < prev    next >
Text File  |  1985-08-21  |  8KB  |  227 lines

  1. /* SDB - definition file */
  2.  
  3. #include "ctype.h"  /*dns*/
  4.  
  5. /* compiler specific stuff  (dns) */
  6. #define Lattice
  7.  
  8. /* useful definitions */
  9. #define TRUE            1
  10. #define FALSE           0
  11. #ifndef NULL
  12. #define NULL            0
  13. #endif
  14.  
  15. /* Character definitions   (dns) */
  16. #define BS  0x8       /*dns*/
  17. #define CR  0xD       /*dns*/
  18. #define FF  0xC       /*dns*/
  19. #define ESC 0x1B      /*dns*/
  20.  
  21. /* program limits */
  22. #define LINEMAX         132     /* maximum input line length */
  23. #define TABLEMAX        132     /* maximum table output line */
  24. #define KEYWORDMAX      10      /* maximum keyword length */
  25. #define NUMBERMAX       20      /* maximum number length */
  26. #define STRINGMAX       132     /* maximum string length */
  27. #define CODEMAX         100     /* maximum length of code array */
  28. #define STACKMAX        20      /* maximum interpreter stack size */
  29.  
  30. /* token definitions */
  31. #define EOS             0
  32. #define LSS             -1
  33. #define LEQ             -2
  34. #define EQL             -3
  35. #define NEQ             -4
  36. #define GEQ             -5
  37. #define GTR             -6
  38. #define SELECT          -7
  39. #define FROM            -8
  40. #define WHERE           -9
  41. #define CREATE          -10
  42. #define DELETE          -11
  43. #define INSERT          -12
  44. #define EXIT            -13
  45. #define CHAR            -14
  46. #define NUM             -15
  47. #define ID              -16
  48. #define STRING          -17
  49. #define NUMBER          -18
  50. #define UPDATE          -19
  51. #define PRINT           -20
  52. #define IMPORT          -21
  53. #define EXPORT          -22
  54. #define INTO            -23
  55. #define HELP            -24
  56. #define COMPRESS        -25
  57. #define EXTRACT         -26
  58. #define DEFINE          -27
  59. #define SHOW            -28
  60. #define USING           -29
  61. #define SORT            -30
  62. #define BY              -31
  63. #define ASCENDING       -32
  64. #define DESCENDING      -33
  65. #define SET             -34
  66.  
  67. /* operand types */
  68. #define LITERAL 1
  69. #define ATTR    2
  70. #define TEMP    3
  71.  
  72. /* attribute data types */
  73. #define TCHAR   1
  74. #define TNUM    2
  75.  
  76. /* tuple status codes */
  77. #define UNUSED  0
  78. #define ACTIVE  1
  79. #define DELETED 2
  80.  
  81. /* relation header page format definitions */
  82. #define RNSIZE          10      /* size of a relation name */
  83. #define HSIZE           16      /* size of a relation entry */
  84. #define ASIZE           16      /* size of a attribute entry */
  85. #define ANSIZE          10      /* size of a attribute name */
  86. #define NATTRS          31      /* number of attributes in header block */
  87.  
  88. /* error code definitions */
  89. #define END             0       /* end of retrieval set */
  90. #define INSMEM          1       /* insufficient memory */
  91. #define RELFNF          2       /* relation file not found */
  92. #define BADHDR          3       /* bad relation file header */
  93. #define TUPINP          4       /* tuple input error */
  94. #define TUPOUT          5       /* tuple output error */
  95. #define RELFUL          6       /* relation file full */
  96. #define RELCRE          7       /* error creating relation file */
  97. #define DUPATT          8       /* duplicate attribute on relation create */
  98. #define MAXATT          9       /* too many attributes on relation create */
  99. #define INSBLK          10      /* insufficient disk blocks */
  100. #define SYNTAX          11      /* command syntax error */
  101. #define ATUNDF          12      /* attribute name undefined */
  102. #define ATAMBG          13      /* attribute name ambiguous */
  103. #define RLUNDF          14      /* relation name undefined */
  104. #define CDSIZE          15      /* boolean expression code too big */
  105. #define INPFNF          16      /* input file not found */
  106. #define OUTCRE          17      /* output file creation error */
  107. #define INDFNF          18      /* indirect command file not found */
  108. #define BADSET          19      /* bad set parameter */
  109.  
  110. struct attribute {
  111.     char at_name[ANSIZE];       /* attribute name */
  112.     char at_type;               /* attribute type */
  113.     char at_size;               /* attribute size in bytes */
  114.     char at_scale;              /* attribute scale factor (for numeric only) */
  115.     char at_unused[ASIZE-ANSIZE-3];     /* unused space */
  116. };
  117.  
  118. struct header {         /* sizeof(struct header) must be 512 bytes */
  119.     char hd_tcnt[2];            /* # of tuples in relation */
  120.     char hd_tmax[2];            /* maximum # of tuples */
  121.     char hd_data[2];            /* offset to first data byte */
  122.     char hd_size[2];            /* size of each tuple in bytes */
  123.     char hd_unused[HSIZE-8];    /* unused space */
  124.     struct attribute hd_attrs[NATTRS];  /* table of attributes */
  125. };
  126.  
  127. struct relation {
  128.     char rl_name[RNSIZE];       /* relation name */
  129.     unsigned int rl_tcnt;       /* # of tuples in relation (from hd_tcnt) */
  130.     unsigned int rl_tmax;       /* maximum # of tuples (from hd_tmax) */
  131.     int rl_data;                /* offset to first data byte (from hd_data) */
  132.     int rl_size;                /* size of eachtuple in bytes (from hd_size) */
  133.     int rl_store;               /* flag indicating a store happened */
  134.     int rl_fd;                  /* file descriptor for relation file */
  135.     int rl_scnref;              /* number of scans referencing this relation */
  136.     struct header rl_header;    /* the relation file header block */
  137.     struct relation *rl_next;   /* pointer to next relation */
  138. };
  139.  
  140. struct scan {
  141.     struct relation *sc_relation;       /* pointer to relation definition */
  142.     unsigned int sc_dtnum;              /* desired tuple number */
  143.     unsigned int sc_atnum;              /* actual tuple number */
  144.     int sc_store;                       /* flag indicating a store happened */
  145.     char *sc_tuple;                     /* tuple buffer */
  146. };
  147.  
  148. struct srel {
  149.     char *sr_name;                      /* alternate relation name */
  150.     struct scan *sr_scan;               /* relation scan structure ptr */
  151.     int sr_ctuple;                      /* current tuple flag */
  152.     int sr_update;                      /* updated tuple flag */
  153.     struct srel *sr_next;               /* next selected relation in list */
  154. };
  155.  
  156. struct sattr {
  157.     char *sa_rname;                     /* relation name */
  158.     char *sa_aname;                     /* attribute name */
  159.     char *sa_name;                      /* alternate attribute name */
  160.     char *sa_aptr;                      /* pointer to attr in tuple buffer */
  161.     struct srel *sa_srel;               /* pointer to the selected relation */
  162.     struct attribute *sa_attr;          /* attribute structure ptr */
  163.     struct sattr *sa_next;              /* next selected attribute in list */
  164. };
  165.  
  166. struct operand {
  167.     int o_type;
  168.     union  {
  169.         struct {
  170.             int ovc_type;
  171.             char *ovc_string;
  172.             int ovc_length;
  173.         } ov_char;
  174.         int ov_boolean;
  175.     } o_value;
  176. };
  177.  
  178. union codecell {
  179.     int (*c_operator)();
  180.     struct operand *c_operand;
  181. };
  182.  
  183. struct binding {
  184.     struct attribute *bd_attr;          /* bound attribute */
  185.     char *bd_vtuple;                    /* pointer to value in tuple */
  186.     char *bd_vuser;                     /* pointer to user buffer */
  187.     struct binding *bd_next;            /* next binding */
  188. };
  189.  
  190. struct sel {
  191.     struct srel *sl_rels;               /* selected relations */
  192.     struct sattr *sl_attrs;             /* selected attributes */
  193.     union codecell *sl_where;           /* where clause */
  194.     struct binding *sl_bindings;        /* user variable bindings */
  195. };
  196.  
  197. struct mtext {
  198.     char *mt_text;
  199.     struct mtext *mt_next;
  200. };
  201.  
  202. struct macro {
  203.     char *mc_name;
  204.     struct mtext *mc_mtext;
  205.     struct macro *mc_next;
  206. };
  207.  
  208. struct ifile {
  209.     char *if_fp;
  210.     struct mtext *if_mtext;
  211.     char *if_cmdline;
  212.     int if_savech;
  213.     char *if_lptr;
  214.     struct ifile *if_next;
  215. };
  216.  
  217. struct skey {
  218.     int sk_type;
  219.     struct attribute *sk_aptr;
  220.     int sk_start;
  221.     struct skey *sk_next;
  222. };
  223.  
  224.  found ]
  225. SDB-DEF>     9á6%s
  226. *** no macro named: %s ***
  227. w<error>nofo