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

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: bgraph.c,v 1.3 2003/08/01 14:14:24 schorsch Exp $";
3 #endif
4 /*
5 * bgraph.c - program to send plots to metafile graphics programs.
6 *
7 * 6/25/86
8 *
9 * Greg Ward Larson
10 */
11
12 #include <stdio.h>
13
14 #include "meta.h"
15 #include "mgvars.h"
16 #include "mgraph.h"
17
18 #define istyp(s) (s[0] == '-')
19
20 #define isvar(s) (s[0] == '+')
21
22 char *progname;
23
24 char *libpath[4];
25
26 static void dofile(int optc, char *optv[], char *file);
27
28
29 int
30 main(
31 int argc,
32 char *argv[]
33 )
34 {
35 char *getenv();
36 int i, file0;
37 progname = argv[0];
38 libpath[0] = "";
39 if ((libpath[i=1] = getenv("MDIR")) != NULL)
40 i++;
41 libpath[i++] = MDIR;
42 libpath[i] = NULL;
43
44 for (file0 = 1; file0 < argc; )
45 if (istyp(argv[file0]))
46 file0++;
47 else if (isvar(argv[file0]) && file0 < argc-1)
48 file0 += 2;
49 else
50 break;
51
52 if (file0 >= argc)
53 dofile(argc-1, argv+1, NULL);
54 else
55 for (i = file0; i < argc; i++)
56 dofile(file0-1, argv+1, argv[i]);
57
58 quit(0);
59 return 0; /* pro forma return */
60 }
61
62
63 static void
64 dofile( /* plot a file */
65 int optc,
66 char *optv[],
67 char *file
68 )
69 {
70 char stmp[256];
71 int i;
72 /* start fresh */
73 mgclearall();
74 /* type options first */
75 for (i = 0; i < optc; i++)
76 if (istyp(optv[i])) {
77 sprintf(stmp, "include=%s.plt", optv[i]+1);
78 setmgvar(progname, stdin, stmp);
79 } else
80 i++;
81 /* file next */
82 mgload(file);
83 /* variable options last */
84 for (i = 0; i < optc; i++)
85 if (isvar(optv[i])) {
86 sprintf(stmp, "%s=%s", optv[i]+1, optv[i+1]);
87 setmgvar(progname, stdin, stmp);
88 i++;
89 }
90 /* graph it */
91 mgraph();
92 }
93
94
95 void
96 quit(code) /* quit program */
97 int code;
98 {
99 mdone();
100 exit(code);
101 }