| 1 |
greg |
1.1 |
#ifndef lint
|
| 2 |
|
|
static const char RCSid[] = "$Id$";
|
| 3 |
|
|
#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 |
|
|
#if UNIX || MAC
|
| 28 |
|
|
char *getenv();
|
| 29 |
|
|
#endif
|
| 30 |
|
|
int i, file0;
|
| 31 |
|
|
|
| 32 |
|
|
#ifdef CPM
|
| 33 |
|
|
fixargs("gcomp", &argc, &argv);
|
| 34 |
|
|
progname = argv[0];
|
| 35 |
|
|
libpath[0] = "";
|
| 36 |
|
|
libpath[1] = "0/";
|
| 37 |
|
|
libpath[2] = NULL;
|
| 38 |
|
|
#endif
|
| 39 |
|
|
#ifdef MAC
|
| 40 |
|
|
progname = argv[0];
|
| 41 |
|
|
libpath[0] = "./";
|
| 42 |
|
|
if ((libpath[i=1] = getenv("MDIR")) != NULL)
|
| 43 |
|
|
i++;
|
| 44 |
|
|
libpath[i++] = "/meta/";
|
| 45 |
|
|
libpath[i] = NULL;
|
| 46 |
|
|
#endif
|
| 47 |
|
|
#ifdef UNIX
|
| 48 |
|
|
progname = argv[0];
|
| 49 |
|
|
libpath[0] = "./";
|
| 50 |
|
|
if ((libpath[i=1] = getenv("MDIR")) != NULL)
|
| 51 |
|
|
i++;
|
| 52 |
|
|
libpath[i++] = MDIR;
|
| 53 |
|
|
libpath[i] = NULL;
|
| 54 |
|
|
#endif
|
| 55 |
|
|
|
| 56 |
|
|
for (file0 = 1; file0 < argc; )
|
| 57 |
|
|
if (istyp(argv[file0]))
|
| 58 |
|
|
file0++;
|
| 59 |
|
|
else if (isvar(argv[file0]) && file0 < argc-1)
|
| 60 |
|
|
file0 += 2;
|
| 61 |
|
|
else
|
| 62 |
|
|
break;
|
| 63 |
|
|
|
| 64 |
|
|
if (file0 >= argc)
|
| 65 |
|
|
dofile(argc-1, argv+1, NULL);
|
| 66 |
|
|
else
|
| 67 |
|
|
for (i = file0; i < argc; i++)
|
| 68 |
|
|
dofile(file0-1, argv+1, argv[i]);
|
| 69 |
|
|
|
| 70 |
|
|
quit(0);
|
| 71 |
|
|
}
|
| 72 |
|
|
|
| 73 |
|
|
|
| 74 |
|
|
dofile(optc, optv, file) /* plot a file */
|
| 75 |
|
|
int optc;
|
| 76 |
|
|
char *optv[];
|
| 77 |
|
|
char *file;
|
| 78 |
|
|
{
|
| 79 |
|
|
char types[16], stmp[256], *strcat();
|
| 80 |
|
|
int i;
|
| 81 |
|
|
|
| 82 |
|
|
mgclearall();
|
| 83 |
|
|
|
| 84 |
|
|
mgload(file);
|
| 85 |
|
|
|
| 86 |
|
|
types[0] = '\0';
|
| 87 |
|
|
for (i = 0; i < optc; i++)
|
| 88 |
|
|
if (istyp(optv[i]))
|
| 89 |
|
|
strcat(types, optv[i]+1);
|
| 90 |
|
|
else {
|
| 91 |
|
|
sprintf(stmp, "%s=%s", optv[i]+1, optv[i+1]);
|
| 92 |
|
|
setmgvar("command line", stdin, stmp);
|
| 93 |
|
|
i++;
|
| 94 |
|
|
}
|
| 95 |
|
|
|
| 96 |
|
|
gcalc(types);
|
| 97 |
|
|
}
|
| 98 |
|
|
|
| 99 |
|
|
|
| 100 |
|
|
eputs(msg) /* print error message */
|
| 101 |
|
|
char *msg;
|
| 102 |
|
|
{
|
| 103 |
|
|
fputs(msg, stderr);
|
| 104 |
|
|
}
|
| 105 |
|
|
|
| 106 |
|
|
|
| 107 |
|
|
quit(code) /* quit program */
|
| 108 |
|
|
int code;
|
| 109 |
|
|
{
|
| 110 |
|
|
exit(code);
|
| 111 |
|
|
}
|