ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/dgraph.c
Revision: 1.1
Committed: Sat Feb 22 02:07:26 2003 UTC (21 years, 4 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2     static const char RCSid[] = "$Id$";
3     #endif
4     /*
5     * dgraph.c - program to send plots to dumb terminal.
6     *
7     * 7/7/86
8     *
9     * Greg Ward Larson
10     */
11    
12     #include <stdio.h>
13    
14    
15     #define isopt(s) (s[0] == '+' || s[0] == '-')
16    
17     char *progname;
18    
19     char *libpath[4];
20    
21    
22     main(argc, argv)
23     int argc;
24     char *argv[];
25     {
26     #if UNIX || MAC
27     char *getenv();
28     #endif
29     int i, file0;
30    
31     #ifdef CPM
32     fixargs("dgraph", &argc, &argv);
33     progname = argv[0];
34     libpath[0] = "";
35     libpath[1] = "0/";
36     libpath[2] = NULL;
37     #endif
38     #ifdef MAC
39     progname = argv[0];
40     libpath[0] = "./";
41     if ((libpath[i=1] = getenv("MDIR")) != NULL)
42     i++;
43     libpath[i++] = "/meta/";
44     libpath[i] = NULL;
45     #endif
46     #ifdef UNIX
47     progname = argv[0];
48     libpath[0] = "./";
49     if ((libpath[i=1] = getenv("MDIR")) != NULL)
50     i++;
51     libpath[i++] = "/usr/local/lib/meta/";
52     libpath[i] = NULL;
53     #endif
54    
55     for (file0 = 1; file0 < argc-1; file0 += 2)
56     if (!isopt(argv[file0]))
57     break;
58    
59     if (file0 >= argc)
60     dofile(argc-1, argv+1, NULL);
61     else
62     for (i = file0; i < argc; i++)
63     dofile(file0-1, argv+1, argv[i]);
64    
65     quit(0);
66     }
67    
68    
69     dofile(optc, optv, file) /* plot a file */
70     int optc;
71     char *optv[];
72     char *file;
73     {
74     int width = 79;
75     int length = 21;
76     char stmp[256];
77     int i;
78     /* start fresh */
79     mgclearall();
80     /* load file */
81     mgload(file);
82     /* do options */
83     for (i = 0; i < optc; i += 2)
84     if (optv[i][0] == '+') {
85     sprintf(stmp, "%s=%s", optv[i]+1, optv[i+1]);
86     setmgvar("command line", stdin, stmp);
87     } else
88     switch (optv[i][1]) {
89     case 'w':
90     width = atoi(optv[i+1]);
91     break;
92     case 'l':
93     length = atoi(optv[i+1]);
94     break;
95     default:
96     fprintf(stderr, "%s: unknown option: %s\n",
97     progname, optv[i]);
98     quit(1);
99     }
100    
101     /* graph it */
102     cgraph(width, length);
103     }
104    
105    
106     eputs(msg) /* print error message */
107     char *msg;
108     {
109     fputs(msg, stderr);
110     }
111    
112    
113     quit(code) /* quit program */
114     int code;
115     {
116     exit(code);
117     }