Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/mam/mamtst.c
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
* convert a make abstract machine stream on stdin
26
* to an oldmake makefile on stdout
27
*/
28
29
static const char id[] = "\n@(#)$Id: mamtst ([email protected]) 1992-08-11 $\0\n";
30
31
#include <mam.h>
32
#include <ctype.h>
33
#include <error.h>
34
35
static void
36
dumprule(register struct rule* r)
37
{
38
sfprintf(sfstdout, "\t%s\n", r->name);
39
}
40
41
static void
42
dumpproc(register struct proc* pp)
43
{
44
register struct list* p;
45
register struct proc* cp;
46
47
if (pp->parent) sfputc(sfstdout, '\n');
48
sfprintf(sfstdout, "process %s pid %d ppid %d start %lu finish %lu status %d\n", pp->pwd, pp->pid, pp->parent ? pp->parent->pid : 0, pp->start, pp->finish, pp->status);
49
for (p = pp->root->prereqs; p; p = p->next)
50
dumprule(p->rule);
51
for (cp = pp->child; cp; cp = cp->sibling)
52
dumpproc(cp);
53
}
54
55
main(int argc, char** argv)
56
{
57
register int c;
58
struct mam* mp;
59
60
NoP(argc);
61
error_info.id = "mamtst";
62
while (c = optget(argv, "d#[debug]")) switch (c)
63
{
64
case 'd':
65
error_info.trace = -opt_info.num;
66
break;
67
case '?':
68
error(ERROR_USAGE|4, opt_info.arg);
69
break;
70
case ':':
71
error(2, opt_info.arg);
72
break;
73
}
74
if (error_info.errors) error(ERROR_USAGE|4, "%s", optusage(NiL));
75
if (!(mp = mamalloc()))
76
error(3, "cannot initialize");
77
if (mamscan(mp, NiL) < 0)
78
error(3, "invalid input");
79
dumpproc(mp->main);
80
exit(error_info.errors != 0);
81
}
82
83