merge the formfield patch from ooo-build
[ooovba.git] / dmake / struct.h
blob5a113dd30b47dd223e20008c0b35739490b03f3f
1 /* RCS $Id: struct.h,v 1.2 2006-06-29 11:24:50 ihi Exp $
2 --
3 -- SYNOPSIS
4 -- Structure definitions
5 --
6 -- DESCRIPTION
7 -- dmake main data structure definitions. See each of the individual
8 -- struct declarations for more detailed information on the defined
9 -- fields and their use.
10 --
11 -- AUTHOR
12 -- Dennis Vadura, dvadura@dmake.wticorp.com
14 -- WWW
15 -- http://dmake.wticorp.com/
17 -- COPYRIGHT
18 -- Copyright (c) 1996,1997 by WTI Corp. All rights reserved.
19 --
20 -- This program is NOT free software; you can redistribute it and/or
21 -- modify it under the terms of the Software License Agreement Provided
22 -- in the file <distribution-root>/readme/license.txt.
24 -- LOG
25 -- Use cvs log to obtain detailed change logs.
28 #ifndef _STRUCT_INCLUDED_
29 #define _STRUCT_INCLUDED_
31 typedef uint32 t_attr;
33 /* The following struct is the cell used in the hash table.
34 * NOTE: It contains the actual hash value. This allows the hash table
35 * insertion to compare hash values and to do a string compare only
36 * for entries that have matching hash_key values. This elliminates
37 * 99.9999% of all extraneous string compare operations when searching
38 * a hash table chain for matching entries. */
40 typedef struct hcell {
41 struct hcell *ht_next; /* next entry in the hash table */
42 struct hcell *ht_link; /* for temporary lists */
43 char *ht_name; /* name of this cell */
44 char *ht_value; /* cell value if any */
45 uint32 ht_hash; /* actual hash_key of cell */
46 int ht_flag; /* flags belonging to hash entry */
48 /* NOTE: some macros have corresponding variables defined
49 * that control program behaviour. For these macros a
50 * bit of ht_flag indicates the variable value will be set, and the
51 * type of the value that will be set.
53 * The struct below contains a mask for bit variables, and a
54 * pointer to the global STATIC location for that variable.
55 * String and char variables point to the same place as ht_value
56 * and must be updated when ht_value changes, bit variables must
57 * have their value recomputed. See Def_macro code for more
58 * details.
60 * NOTE: Macro variables and Targets are always distinct. Thus
61 * the value union contains pointers back at cells that own
62 * a particular name entry. A conflict in this can never
63 * arise, ie pointers at cells will never be used as
64 * values for a macro variable, since the cell and macro
65 * name spaces are completely distinct. */
67 struct {
68 int mv_mask; /* bit mask for bit variable */
69 union {
70 char** mv_svar;/* ptr to string valued glob var */
71 char* mv_cvar;/* ptr to char valued glob var */
72 t_attr* mv_bvar;/* ptr to bit valued glob var */
73 int* mv_ivar;/* ptr to int valued glob var */
75 struct {
76 struct tcell* ht_owner;/* ptr to CELL owning name */
77 struct tcell* ht_root; /* root ptr for explode */
78 } ht;
79 } val;
80 } var; /* variable's static equivalent */
81 } HASH, *HASHPTR;
83 #define MV_MASK var.mv_mask
84 #define MV_SVAR var.val.mv_svar
85 #define MV_CVAR var.val.mv_cvar
86 #define MV_BVAR var.val.mv_bvar
87 #define MV_IVAR var.val.mv_ivar
88 #define CP_OWNR var.val.ht.ht_owner
89 #define CP_ROOT var.val.ht.ht_root
93 /* This struct holds the list of temporary files that have been created.
94 * It gets unlinked when Quit is called due to an execution error */
95 typedef struct flst {
96 char *fl_name; /* file name */
97 FILE *fl_file; /* the open file */
98 struct flst *fl_next; /* pointer to next file */
99 } FILELIST, *FILELISTPTR;
102 /* The next struct is used to link together prerequisite lists. It
103 * is also used to link multiple targets together. */
104 typedef struct lcell {
105 struct tcell *cl_prq; /* link to a prerequisite */
106 struct lcell *cl_next; /* next cell on dependency list */
107 int cl_flag; /* flags for link cell */
108 } LINK, *LINKPTR;
111 /* This is the structure of a target cell in the dag which represents the
112 * graph of dependencies. Each possible target is represented as a cell.
114 * Each cell contains a pointer to the hash table entry for this cell.
115 * The hash table entry records the name of the cell. */
117 typedef struct tcell {
118 struct hcell *ce_name; /* name of this cell */
119 struct hcell *ce_pushed; /* local pushed macro definitions */
121 /* Def_cell sets ce_all.cl_prq to point back to itself. .UPDATEALL
122 * uses ce_all.cl_next to link the cells together. */
123 struct lcell ce_all;
125 /* If set it points to first element of the list linked by ce_all. */
126 struct tcell *ce_set;
127 struct tcell *ce_setdir; /* SETDIR ROOT pointer for this cell*/
128 struct tcell *ce_link; /* link for temporary list making */
129 struct tcell *ce_parent; /* used by inner loop, not a static */
131 struct lcell *ce_prq; /* list of prerequisites for cell */
132 struct lcell *ce_prqorg; /* list of original prerequisites */
133 struct lcell *ce_indprq; /* indirect prerequisites for % cell*/
135 struct str *ce_recipe; /* recipe for making this cell */
136 FILELISTPTR ce_files; /* list of temporary files for cell */
137 struct str *ce_cond; /* conditional macro assignments */
139 char *ce_per; /* value of % in %-meta expansion */
140 char *ce_fname; /* file name associated with target */
141 char *ce_lib; /* archive name, if A_LIBRARYM */
142 char *ce_dir; /* value for .SETDIR attribute */
144 int ce_count; /* value for :: recipe set */
145 int ce_index; /* value of count for next :: child */
146 int ce_flag; /* all kinds of goodies */
147 t_attr ce_attr; /* attributes for this target */
148 time_t ce_time; /* time stamp value of target if any*/
149 } CELL, *CELLPTR;
151 #define CE_NAME ce_name->ht_name
152 #define CE_RECIPE ce_recipe
153 #define CE_PRQ ce_prq
154 #define CeMeToo(C) &((C)->ce_all)
155 #define CeNotMe(C) (C)->ce_all.cl_next
158 /* This struct represents that used by Get_token to return and control
159 * access to a token list inside a particular string. This gives the
160 * ability to access non overlapping tokens simultaneously from
161 * multiple strings. */
163 typedef struct {
164 char *tk_str; /* the string to search for tokens */
165 char tk_cchar; /* current char under *str */
166 int tk_quote; /* if we are scanning a quoted str */
167 } TKSTR, *TKSTRPTR;
171 /* Below is the struct used to represent a string. It points at possibly
172 * another string, since the set of rules for making a target is a collection
173 * of strings. */
176 typedef struct str {
177 char *st_string; /* the string value */
178 struct str *st_next; /* pointer to the next string */
179 t_attr st_attr; /* attr for rule operations */
180 } STRING, *STRINGPTR;
184 /* These structs are used in processing of the % rules, and in building
185 * the NFA machine that is used to match an arbitrary target string to
186 * one of the % rules that is represented by each DFA */
188 typedef int16 statecnt; /* limits the max number of dfa states */
191 /* Each state of the DFA contains four pieces of information. */
192 typedef struct st {
193 struct st *no_match; /* state to go to if no match */
194 struct st *match; /* state to go to if we do match */
195 char symbol; /* symbol on which we transit */
196 char action; /* action to perform if match */
197 } STATE, *STATEPTR;
200 /* Each DFA machine looks like this. It must have two pointers that represent
201 * the value of % in the matched string, and it contains a pointer into the
202 * current state, as well as the array of all states. */
203 typedef struct {
204 char *pstart; /* start of % string match */
205 char *pend; /* end of % string match */
206 STATEPTR c_state; /* current DFA state */
207 CELLPTR node; /* % target represented by this DFA */
208 STATEPTR states; /* table of states for the DFA */
209 } DFA, *DFAPTR;
212 /* An NFA is a collection of DFA's. For each DFA we must know it's current
213 * state and where the next NFA is. */
214 typedef struct nfa_machine {
215 DFAPTR dfa; /* The DFA for this eps transition */
216 char status; /* DFA state */
217 struct nfa_machine *next; /* the next DFA in NFA */
218 } NFA, *NFAPTR;
222 /* The next struct is used to link together DFA nodes for inference. */
224 typedef struct dfal {
225 struct tcell *dl_meta; /* link to %-meta cell */
226 struct dfal *dl_next; /* next cell on matched DFA list*/
227 struct dfal *dl_prev; /* prev cell on matched DFA list*/
228 struct dfal *dl_member; /* used during subset calc */
229 char dl_delete; /* used during subset calc */
230 char *dl_per; /* value of % for matched DFA */
231 statecnt dl_state; /* matched state of the DFA */
232 int dl_prep; /* repetion count for the cell */
233 } DFALINK, *DFALINKPTR;
236 /* This struct is used to store the stack of DFA sets during inference */
237 typedef struct dfst {
238 DFALINKPTR df_set; /* pointer to the set */
239 struct dfst *df_next; /* next element in the stack */
240 } DFASET, *DFASETPTR;
243 /* We need sets of items during inference, here is the item, we form sets
244 * by linking them together. */
246 typedef struct ic {
247 CELLPTR ic_meta; /* Edge we used to make this cell*/
248 DFALINKPTR ic_dfa; /* Dfa that we matched against */
249 CELLPTR ic_setdirroot; /* setdir root pointer for cell */
250 DFASET ic_dfastack; /* set of dfas we're working with*/
251 int ic_dmax; /* max depth of cycles in graph */
252 char *ic_name; /* name of the cell to insert */
253 char *ic_dir; /* dir to CD to prior to recurse */
254 struct ic *ic_next; /* next pointer to link */
255 struct ic *ic_link; /* link all ICELL'S together */
256 struct ic *ic_parent; /* pointer to post-requisite */
257 char ic_flag; /* flag, used for NOINFER only */
258 char ic_exists; /* TRUE if prerequisite exists */
259 } ICELL, *ICELLPTR;
261 #endif