ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/getinfo.c
Revision: 1.1
Committed: Thu Feb 2 10:49:19 1989 UTC (33 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 greg 1.1 /* Copyright (c) 1986 Regents of the University of California */
2    
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6    
7     /*
8     * getinfo.c - program to read info. header from file.
9     *
10     * 1/3/86
11     */
12    
13     #include <stdio.h>
14    
15    
16     tabstr(s) /* put out line followed by tab */
17     register char *s;
18     {
19     while (*s) {
20     putchar(*s);
21     s++;
22     }
23     if (*--s == '\n')
24     putchar('\t');
25     }
26    
27    
28     main(argc, argv)
29     int argc;
30     char *argv[];
31     {
32     int dim = 0;
33     FILE *fp;
34     int i;
35    
36     if (argc > 1 && !strcmp(argv[1], "-d")) {
37     argc--; argv++;
38     dim = 1;
39     }
40     for (i = 1; i < argc; i++) {
41     fputs(argv[i], stdout);
42     if ((fp = fopen(argv[i], "r")) == NULL)
43     fputs(": cannot open\n", stdout);
44     else {
45     if (dim) {
46     fputs(": ", stdout);
47     getdim(fp);
48     } else {
49     tabstr(":\n");
50     getheader(fp, tabstr);
51     putchar('\n');
52     }
53     fclose(fp);
54     }
55     }
56     if (argc == 1)
57     if (dim) {
58     getdim(stdin);
59     } else {
60     copyheader(stdin, stdout);
61     putchar('\n');
62     }
63     exit(0);
64     }
65    
66    
67     getdim(fp) /* get dimensions from file */
68     register FILE *fp;
69     {
70     int j;
71     register int c;
72    
73     getheader(fp, NULL); /* skip header */
74    
75     switch (c = getc(fp)) {
76     case '+': /* picture */
77     case '-':
78     do
79     putchar(c);
80     while (c != '\n' && (c = getc(fp)) != EOF);
81     break;
82     case 1: /* octree */
83     getc(fp);
84     j = 0;
85     while ((c = getc(fp)) != EOF)
86     if (c == 0)
87     if (++j >= 4)
88     break;
89     else
90     putchar(' ');
91     else
92     putchar(c);
93     putchar('\n');
94     break;
95     default: /* ??? */
96     fputs("unknown file type\n", stdout);
97     break;
98     }
99     }