ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/mgfilt.c
Revision: 2.1
Committed: Fri Feb 18 00:40:25 2011 UTC (13 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R1, rad4R2P1, rad5R3, HEAD
Log Message:
Major code reorg, moving mgflib to common and introducing BSDF material

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: mgfilt.c,v 1.8 2003/11/15 17:54:06 schorsch Exp $";
3 #endif
4 /*
5 * Filter MGF stream, removing entities that won't be understood
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include "mgf_parser.h"
11
12 /* Number of entities for major versions */
13 short nentlist[MG_VMAJOR] = MG_NELIST;
14
15
16 int
17 put_entity( /* general output routine */
18 register int ac,
19 register char **av
20 )
21 {
22 while (ac-- > 0) {
23 fputs(*av++, stdout);
24 putchar(ac ? ' ' : '\n');
25 }
26 return(MG_OK);
27 }
28
29
30 int
31 main( /* first argument is understood entities, comma-sep. */
32 int argc,
33 char *argv[]
34 )
35 {
36 char *cp1, *cp2;
37 int i, en;
38
39 if (argc < 2) {
40 fprintf(stderr,
41 "Usage: %s { version | entity,list } [file ..]\n",
42 argv[0]);
43 exit(1);
44 }
45 if (isint(argv[1])) {
46 i = atoi(argv[1]);
47 if ((i < 1) | (i > MG_VMAJOR)) {
48 fprintf(stderr, "%s: bad version number: %d\n",
49 argv[0], i);
50 exit(1);
51 }
52 for (en = nentlist[i-1]; en--; )
53 mg_ehand[en] = put_entity;
54 mg_ehand[MG_E_INCLUDE] = NULL; /* expand include's */
55 } else
56 for (cp1 = cp2 = argv[1]; *cp1; cp1 = cp2) {
57 while (*cp2) {
58 if (*cp2 == ',') {
59 *cp2++ = '\0';
60 break;
61 }
62 cp2++;
63 }
64 en = mg_entity(cp1);
65 if (en < 0) {
66 fprintf(stderr, "%s: %s: no such entity\n",
67 argv[0], cp1);
68 exit(1);
69 }
70 mg_ehand[en] = put_entity;
71 }
72 mg_init();
73 if (argc < 3) {
74 if (mg_load((char *)NULL) != MG_OK)
75 exit(1);
76 if (mg_nunknown)
77 printf("%s %s: %u unknown entities on input\n",
78 mg_ename[MG_E_COMMENT],
79 argv[0], mg_nunknown);
80 exit(0);
81 }
82 for (i = 2; i < argc; i++) {
83 if (mg_load(argv[i]) != MG_OK)
84 exit(1);
85 if (mg_nunknown) {
86 printf("%s %s: %u unknown entities\n",
87 mg_ename[MG_E_COMMENT],
88 argv[i], mg_nunknown);
89 mg_nunknown = 0;
90 }
91 }
92 exit(0);
93 }