Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libmam/mam.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1989-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Glenn Fowler
23
* AT&T Bell Laboratories
24
*
25
* make abstract machine definitions
26
*/
27
28
#ifndef _MAM_H
29
#define _MAM_H
30
31
#include <ast.h>
32
#include <hash.h>
33
34
#define getrule(p,n) (struct rule*)hashget((p)->rules,(n))
35
#define putrule(p,n,r) hashput((p)->rules,(char*)(n),(char*)(r))
36
#define getvar(p,n) (struct var*)hashget((p)->vars,(n))
37
#define putvar(p,n,v) hashput((p)->vars,(char*)(n),(char*)(v))
38
39
#define A_archive (1<<0) /* archive target */
40
#define A_dontcare (1<<1) /* don't care if error */
41
#define A_metarule (1<<2) /* metarule info */
42
#define A_virtual (1<<3) /* a file not */
43
#define A_LAST (1<<7) /* last A_* bit used */
44
45
#define B_LAST (1<<7) /* last B_* bit used */
46
47
#define V_LAST (1<<7) /* last V_* bit used */
48
49
struct rule /* rule info */
50
{
51
char* name; /* rule name */
52
char* bound; /* bound name */
53
time_t time; /* modify time */
54
long attributes; /* A_* attributes */
55
int status; /* action exit status */
56
struct list* prereqs; /* explicit prerequisite list */
57
struct list* implicit; /* implicit prerequisite list */
58
struct block* action; /* action */
59
union
60
{
61
char* pointer;
62
long number;
63
} local; /* user defined */
64
65
#ifdef _MAM_RULE_PRIVATE
66
_MAM_RULE_PRIVATE
67
#endif
68
69
};
70
71
struct var /* variable info */
72
{
73
char* name; /* var name */
74
char* value; /* var value */
75
long attributes; /* V_* attributes */
76
union
77
{
78
char* pointer;
79
long number;
80
} local; /* user defined */
81
82
#ifdef _MAM_VAR_PRIVATE
83
_MAM_VAR_PRIVATE
84
#endif
85
86
};
87
88
struct list /* prereq list */
89
{
90
struct list* next; /* next prereq */
91
struct rule* rule; /* this prereq */
92
};
93
94
struct block /* data block list */
95
{
96
struct block* next; /* next item */
97
char* data; /* this item */
98
long attributes; /* B_* attributes */
99
};
100
101
struct proc /* mam process trace */
102
{
103
struct rule* root; /* root target */
104
struct proc* parent; /* parent proc */
105
struct proc* child; /* child proc list */
106
struct proc* sibling; /* sibling procs */
107
char* pwd; /* pwd */
108
char* view; /* 3d view */
109
Hash_table_t* rules; /* rule hash */
110
Hash_table_t* vars; /* variable hash */
111
long pid; /* pid (invalid now) */
112
int status; /* exit status */
113
time_t start; /* start time */
114
time_t finish; /* finish time */
115
116
#ifdef _MAM_PROC_PRIVATE
117
_MAM_PROC_PRIVATE
118
#endif
119
120
};
121
122
struct mam /* mam state */
123
{
124
const char* id; /* library id */
125
char* version; /* input version */
126
struct proc* main; /* main proc */
127
128
#ifdef _MAM_MAM_PRIVATE
129
_MAM_MAM_PRIVATE
130
#endif
131
132
};
133
134
/*
135
* library globals
136
*/
137
138
extern struct mam* mamalloc(void);
139
extern void mamfree(struct mam*);
140
extern int mamscan(struct mam*, const char*);
141
extern struct rule* mamrule(struct proc*, const char*);
142
extern struct var* mamvar(struct proc*, const char*, const char*);
143
extern void mamprereq(struct proc*, struct rule*, struct rule*, struct list**);
144
145
#endif
146
147