main shrubtools / nviz / env.h
 1struct evalstring;
 2struct string;
 3
 4struct rule {
 5	char *name;
 6	struct treenode *bindings;
 7};
 8
 9struct pool {
10	char *name;
11	int numjobs, maxjobs;
12
13	/* a queue of ready edges blocked by the pool's capacity */
14	struct edge *work;
15};
16
17void envinit(void);
18
19/* create a new environment with an optional parent */
20struct environment *mkenv(struct environment *);
21/* search environment and its parents for a variable, returning the value or NULL if not found */
22struct string *envvar(struct environment *, char *);
23/* add to environment a variable and its value, replacing the old value if there is one */
24void envaddvar(struct environment *, char *, struct string *);
25/* evaluate an unevaluated string within an environment, returning the result */
26struct string *enveval(struct environment *, struct evalstring *);
27/* search an environment and its parents for a rule, returning the rule or NULL if not found */
28struct rule *envrule(struct environment *, char *);
29/* add a rule to an environment, or fail if the rule already exists */
30void envaddrule(struct environment *, struct rule *);
31
32/* create a new rule with the given name */
33struct rule *mkrule(char *);
34/* add to rule a variable and its value */
35void ruleaddvar(struct rule *, char *, struct evalstring *);
36
37/* create a new pool with the given name */
38struct pool *mkpool(char *);
39/* lookup a pool by name, or fail if it does not exist */
40struct pool *poolget(char *);
41
42/* evaluate and return an edge's variable, optionally shell-escaped */
43struct string *edgevar(struct edge *, char *, _Bool);
44
45extern struct environment *rootenv;
46extern struct rule phonyrule;
47extern struct pool consolepool;