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