home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2278 / iiddef.h next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  6.2 KB  |  204 lines

  1. /* Definitions used by the iid program.
  2.  */
  3.  
  4. #include <stdio.h>
  5. #include <ctype.h>
  6. #include <string.h>
  7. extern char * getenv() ;
  8. extern int getopt() ;
  9. extern char * optarg ;
  10. extern int optind ;
  11. #define TRUE 1
  12. #define FALSE 0
  13.  
  14. #ifdef DEF
  15. #define EXTERN
  16. #define INIT(a) =(a)
  17. #else
  18. #define EXTERN extern
  19. #define INIT(a)
  20. #endif
  21.  
  22. #define BITS_PER_BYTE 8                /* used by bit set manipulation */
  23.  
  24. #define HASH_SIZE 947                  /* size of hash table for file names */
  25.  
  26. #ifndef HELPFILE
  27. #define HELPFILE "/usr/local/iid.help" /* The help file location */
  28. #endif
  29.  
  30. #define INIT_FILES 8000                /* start with bits for this many */
  31.  
  32. #define INIT_SETSPACE 500              /* start with room for this many */
  33.  
  34. #define MAX(a,b) (((a)<(b))?(b):(a))
  35.  
  36. #define MAXCMD 1024                    /* input command buffer size */
  37.  
  38. #define MIN(a,b) (((a)>(b))?(b):(a))
  39.  
  40. #ifndef PAGER
  41. #define PAGER "pg"
  42. #endif
  43.  
  44. #define PROMPT "iid> "
  45.  
  46. /* set_type is the struct defining a set of file names
  47.  * The file names are stored in a symbol table and assigned
  48.  * unique numbers. The set is a bit set of file numbers.
  49.  * One of these set structs is calloced for each new set
  50.  * constructed, the size allocated depends on the max file
  51.  * bit number. An array of pointers to sets are kept to
  52.  * represent the complete set of sets.
  53.  */
  54.  
  55. typedef struct set_struct {
  56.    char *                 set_desc ;   /* string describing the set */
  57.    int                    set_num ;    /* the set number */
  58.    int                    set_size ;   /* number of long words in set */
  59.    unsigned long int      set_tail ;   /* set extended with these bits */
  60.    unsigned long int      set_data[1] ;/* the actual set data (calloced) */
  61. } set_type ;
  62.  
  63. /* id_type is one element of an id_list
  64.  */
  65.  
  66. typedef struct id_struct {
  67.    struct id_struct *     next_id ;    /* Linked list of IDs */
  68.    char                   id [ 1 ] ;   /* calloced data holding id string */
  69. } id_type ;
  70.  
  71. /* id_list_type is used during parsing to build lists of
  72.  * identifiers that will eventually represent arguments
  73.  * to be passed to the database query programs.
  74.  */
  75.  
  76. typedef struct id_list_struct {
  77.    int                    id_count ;   /* count of IDs in the list */
  78.    id_type * *            end_ptr_ptr ;/* pointer to link word at end of list */
  79.    id_type *              id_list ;    /* pointer to list of IDs */
  80. } id_list_type ;
  81.  
  82. /* symtab_type is used to record file names in the symbol table.
  83.  */
  84. typedef struct symtab_struct {
  85.    struct symtab_struct * hash_link ;  /* list of files with same hash code */
  86.    int                    mask_word ;  /* word in bit vector */
  87.    unsigned long          mask_bit ;   /* bit in word */
  88.    char                   name [ 1 ] ; /* the file name */
  89. } symtab_type ;
  90.  
  91. extern void DescribeSets();
  92. extern id_list_type * ExtendList();
  93. extern void FlushSets();
  94. extern void InitIid();
  95. extern id_list_type * InitList();
  96. extern symtab_type * InstallFile();
  97. extern void OneDescription();
  98. extern void PrintSet();
  99. extern void RunPager();
  100. extern set_type * RunProg();
  101. extern void RunShell();
  102. extern void ScanInit();
  103. extern void SetDirectory();
  104. extern set_type * SetIntersect();
  105. extern set_type * SetInverse();
  106. extern id_list_type * SetList();
  107. extern set_type * SetUnion();
  108. extern int yylex();
  109.  
  110. /* LidCommand is the command to run for a Lid_group. It is set
  111.  * to "lid -kmn" if explicitly preceeded by "lid", otherwise
  112.  * it is the default command which is determined by an option.
  113.  */
  114. EXTERN char * LidCommand ;
  115.  
  116. /* DefaultCommand is the default command for a Lid_group. If
  117.  * the -a option is given to iid, it is set to use 'aid'.
  118.  */
  119. EXTERN char * DefaultCommand INIT("lid -kmn") ;
  120.  
  121. /* FileList is a lexically ordered list of file symbol table
  122.  * pointers. It is dynamically expanded when necessary.
  123.  */
  124. EXTERN symtab_type * *    FileList INIT(NULL) ;
  125.  
  126. /* FileSpace is the number of long ints in TheFiles array.
  127.  */
  128. EXTERN int                FileSpace INIT(0) ;
  129.  
  130. /* HashTable is the symbol table used to store file names. Each
  131.  * new name installed is assigned the next consecutive file number.
  132.  */
  133. EXTERN symtab_type *      HashTable [ HASH_SIZE ] ;
  134.  
  135. /* HelpSet is a dummy set containing only one bit set which corresponds
  136.  * to the help file name. Simply a cheesy way to maximize sharing of
  137.  * the code that runs the pager.
  138.  */
  139. EXTERN set_type *         HelpSet ;
  140.  
  141. /* high_bit is a unsigned long with the most significant bit set.
  142.  */
  143. EXTERN unsigned long      high_bit ;
  144.  
  145. /* ListSpace is the amount of space avail in the FileList.
  146.  */
  147. EXTERN int                ListSpace INIT(0) ;
  148.  
  149. /* MaxCurFile - max word that has any bit currently set in the
  150.  * TheFiles array.
  151.  */
  152. EXTERN int                MaxCurFile INIT(0) ;
  153.  
  154. /* NextFileNum is the file number that will be assigned to the next
  155.  * new file name seen when it is installed in the symtab.
  156.  */
  157. EXTERN int                NextFileNum INIT(0) ;
  158.  
  159. /* NextMaskBit is the bit within the next mask word that will
  160.  * correspond to the next file added to the symbol table.
  161.  */
  162. EXTERN unsigned long      NextMaskBit ;
  163.  
  164. /* NextMaskWord is the next word number to be assigned to a file
  165.  * bit mask entry.
  166.  */
  167. EXTERN int                NextMaskWord INIT(0) ;
  168.  
  169. /* NextSetNum is the number that will be assigned to the next set
  170.  * created. Starts at 0 because I am a C programmer.
  171.  */
  172. EXTERN int                NextSetNum INIT(0) ;
  173.  
  174. /* The PAGER program to run on a SHOW command.
  175.  */
  176. EXTERN char               Pager[MAXCMD] ;
  177.  
  178. /* Prompt - the string to use for a prompt.
  179.  */
  180. EXTERN char               Prompt[MAXCMD] ;
  181.  
  182. /* SetSpace is the number of pointers available in TheSets. TheSets
  183.  * is realloced when we run out of space.
  184.  */
  185. EXTERN int                SetSpace INIT(0) ;
  186.  
  187. /* TheFiles is a bit set used to construct the initial set of files
  188.  * generated while running one of the subprograms. It is copied to
  189.  * the alloced set once we know how many bits are set.
  190.  */
  191. EXTERN unsigned long *    TheFiles INIT(NULL) ;
  192.  
  193. /* TheSets is a dynamically allocated array of pointers pointing
  194.  * the sets that have been allocated. It represents the set of
  195.  * sets.
  196.  */
  197. EXTERN set_type * *       TheSets INIT(NULL) ;
  198.  
  199. /* VerboseQuery controls the actions of the semantic routines during
  200.  * the process of a query. If TRUE the sets are described as they
  201.  * are constructed.
  202.  */
  203. EXTERN int                VerboseQuery ;
  204.