ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/gcomp.c
Revision: 1.3
Committed: Sat Nov 15 02:13:37 2003 UTC (20 years, 5 months ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1, rad5R3
Changes since 1.2: +27 -12 lines
Log Message:
Continued ANSIfication, and reduced other compile warnings.

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 schorsch 1.3 static const char RCSid[] = "$Id: gcomp.c,v 1.2 2003/08/01 14:14:24 schorsch Exp $";
3 greg 1.1 #endif
4     /*
5     * gcomp.c - program to calculate things from graph files.
6     *
7     * 7/7/86
8     *
9     * Greg Ward Larson
10     */
11    
12 schorsch 1.3 #include <stdlib.h>
13 greg 1.1 #include <stdio.h>
14    
15 schorsch 1.3 #include "rterror.h"
16     #include "meta.h"
17     #include "mgvars.h"
18    
19 greg 1.1 #define istyp(s) (s[0] == '-')
20    
21     #define isvar(s) (s[0] == '+')
22    
23     char *progname;
24    
25     char *libpath[4];
26    
27 schorsch 1.3 static void dofile(int optc, char *optv[], char *file);
28 greg 1.1
29 schorsch 1.3 int
30     main(
31     int argc,
32     char *argv[]
33     )
34 greg 1.1 {
35     char *getenv();
36     int i, file0;
37    
38     progname = argv[0];
39     libpath[0] = "./";
40     if ((libpath[i=1] = getenv("MDIR")) != NULL)
41     i++;
42     libpath[i++] = MDIR;
43     libpath[i] = NULL;
44    
45     for (file0 = 1; file0 < argc; )
46     if (istyp(argv[file0]))
47     file0++;
48     else if (isvar(argv[file0]) && file0 < argc-1)
49     file0 += 2;
50     else
51     break;
52    
53     if (file0 >= argc)
54     dofile(argc-1, argv+1, NULL);
55     else
56     for (i = file0; i < argc; i++)
57     dofile(file0-1, argv+1, argv[i]);
58    
59     quit(0);
60 schorsch 1.3 return 0; /* pro forma return */
61 greg 1.1 }
62    
63    
64 schorsch 1.3 void
65     dofile( /* plot a file */
66     int optc,
67     char *optv[],
68     char *file
69     )
70 greg 1.1 {
71     char types[16], stmp[256], *strcat();
72     int i;
73    
74     mgclearall();
75    
76     mgload(file);
77    
78     types[0] = '\0';
79     for (i = 0; i < optc; i++)
80     if (istyp(optv[i]))
81     strcat(types, optv[i]+1);
82     else {
83     sprintf(stmp, "%s=%s", optv[i]+1, optv[i+1]);
84     setmgvar("command line", stdin, stmp);
85     i++;
86     }
87    
88     gcalc(types);
89     }
90    
91    
92 schorsch 1.3 void
93     eputs( /* print error message */
94     char *msg
95     )
96 greg 1.1 {
97     fputs(msg, stderr);
98     }
99    
100    
101 schorsch 1.3 void
102     quit( /* quit program */
103     int code
104     )
105 greg 1.1 {
106     exit(code);
107     }