xref: /original-bsd/usr.bin/struct/struct/main.c (revision 7e7b101a)
1 #ifndef lint
2 static char sccsid[] = "@(#)main.c	4.1	(Berkeley)	02/11/83";
3 #endif not lint
4 
5 #include <signal.h>
6 #include <stdio.h>
7 #include "1.defs.h"
8 #include "def.h"
9 
10 
11 char (*input)(), (*unput)();
12 FILE *outfd	= stdout;
13 
14 
15 
16 main(argc,argv)
17 int argc;
18 char *argv[];
19 	{
20 	int anyoutput;
21 	int dexit();
22 	char *getargs();
23 	char input1(), unput1(), input2(), unput2();
24 	anyoutput = FALSE;
25 	getargs(argc,argv);
26 	if (debug == 2) debfd = stderr;
27 	else if (debug)
28 		debfd = fopen("debug1","w");
29 
30 	if (signal(SIGINT, SIG_IGN) !=SIG_IGN)
31 		signal(SIGINT,dexit);
32 	prog_init();
33 
34 	for (;;)
35 		{
36 		++routnum;
37 		routerr = 0;
38 
39 		input = input1;
40 		unput = unput1;
41 		if (!mkgraph()) break;
42 		if (debug) prgraph();
43 		if (routerr) continue;
44 
45 		if (progress)fprintf(stderr,"build:\n");
46 		build();
47 		if (debug) prtree();
48 		if (routerr) continue;
49 
50 		if (progress)fprintf(stderr,"structure:\n");
51 		structure();
52 		if (debug) prtree();
53 		if (routerr) continue;
54 		input = input2;
55 		unput = unput2;
56 
57 		if (progress)fprintf(stderr,"output:\n");
58 		output();
59 		if (routerr) continue;
60 		anyoutput = TRUE;
61 		freegraf();
62 		}
63 	if (anyoutput)
64 		exit(0);
65 	else
66 		exit(1);
67 	}
68 
69 
70 dexit()
71 	{
72 	exit(1);
73 	}
74