1 |
greg |
1.1 |
#ifndef lint |
2 |
schorsch |
1.3 |
static const char RCSid[] = "$Id: bgraph.c,v 1.2 2003/07/16 01:32:53 greg Exp $"; |
3 |
greg |
1.1 |
#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 |
|
|
|
16 |
|
|
#define istyp(s) (s[0] == '-') |
17 |
|
|
|
18 |
|
|
#define isvar(s) (s[0] == '+') |
19 |
|
|
|
20 |
|
|
char *progname; |
21 |
|
|
|
22 |
|
|
char *libpath[4]; |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
main(argc, argv) |
26 |
|
|
int argc; |
27 |
|
|
char *argv[]; |
28 |
|
|
{ |
29 |
|
|
char *getenv(); |
30 |
|
|
int i, file0; |
31 |
|
|
progname = argv[0]; |
32 |
|
|
libpath[0] = ""; |
33 |
|
|
if ((libpath[i=1] = getenv("MDIR")) != NULL) |
34 |
|
|
i++; |
35 |
|
|
libpath[i++] = MDIR; |
36 |
|
|
libpath[i] = NULL; |
37 |
|
|
|
38 |
|
|
for (file0 = 1; file0 < argc; ) |
39 |
|
|
if (istyp(argv[file0])) |
40 |
|
|
file0++; |
41 |
|
|
else if (isvar(argv[file0]) && file0 < argc-1) |
42 |
|
|
file0 += 2; |
43 |
|
|
else |
44 |
|
|
break; |
45 |
|
|
|
46 |
|
|
if (file0 >= argc) |
47 |
|
|
dofile(argc-1, argv+1, NULL); |
48 |
|
|
else |
49 |
|
|
for (i = file0; i < argc; i++) |
50 |
|
|
dofile(file0-1, argv+1, argv[i]); |
51 |
|
|
|
52 |
|
|
quit(0); |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
|
56 |
|
|
dofile(optc, optv, file) /* plot a file */ |
57 |
|
|
int optc; |
58 |
|
|
char *optv[]; |
59 |
|
|
char *file; |
60 |
|
|
{ |
61 |
|
|
char stmp[256]; |
62 |
|
|
int i; |
63 |
|
|
/* start fresh */ |
64 |
|
|
mgclearall(); |
65 |
|
|
/* type options first */ |
66 |
|
|
for (i = 0; i < optc; i++) |
67 |
|
|
if (istyp(optv[i])) { |
68 |
|
|
sprintf(stmp, "include=%s.plt", optv[i]+1); |
69 |
|
|
setmgvar(progname, stdin, stmp); |
70 |
|
|
} else |
71 |
|
|
i++; |
72 |
|
|
/* file next */ |
73 |
|
|
mgload(file); |
74 |
|
|
/* variable options last */ |
75 |
|
|
for (i = 0; i < optc; i++) |
76 |
|
|
if (isvar(optv[i])) { |
77 |
|
|
sprintf(stmp, "%s=%s", optv[i]+1, optv[i+1]); |
78 |
|
|
setmgvar(progname, stdin, stmp); |
79 |
|
|
i++; |
80 |
|
|
} |
81 |
|
|
/* graph it */ |
82 |
|
|
mgraph(); |
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
|
86 |
greg |
1.2 |
void |
87 |
greg |
1.1 |
quit(code) /* quit program */ |
88 |
|
|
int code; |
89 |
|
|
{ |
90 |
|
|
mdone(); |
91 |
|
|
exit(code); |
92 |
|
|
} |