ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/mgflib/mgfilt.c
Revision: 1.2
Committed: Sat Feb 11 09:54:29 1995 UTC (29 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.1: +24 -8 lines
Log Message:
changed command argument parsing

File Contents

# Content
1 /* Copyright (c) 1995 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * Filter MGF stream, removing entities that won't be understood
9 */
10
11 #include <stdio.h>
12 #include "parser.h"
13
14
15 int
16 put_entity(ac, av) /* general output routine */
17 register int ac;
18 register char **av;
19 {
20 while (ac-- > 0) {
21 fputs(*av++, stdout);
22 putchar(ac ? ' ' : '\n');
23 }
24 return(MG_OK);
25 }
26
27
28 main(argc, argv) /* first argument is understood entities, comma-sep. */
29 int argc;
30 char *argv[];
31 {
32 char *cp1, *cp2;
33 int i, en;
34
35 if (argc < 2) {
36 fprintf(stderr, "Usage: %s entity,list [file ..]\n", argv[0]);
37 exit(1);
38 }
39 for (cp1 = cp2 = argv[1]; *cp1; cp1 = cp2) {
40 while (*cp2) {
41 if (*cp2 == ',') {
42 *cp2++ = '\0';
43 break;
44 }
45 cp2++;
46 }
47 en = mg_entity(cp1);
48 if (en < 0) {
49 fprintf(stderr, "%s: %s: no such entity\n",
50 argv[0], cp1);
51 exit(1);
52 }
53 mg_ehand[en] = put_entity;
54 }
55 mg_init();
56 if (argc < 3)
57 exit(mg_load((char *)NULL) != MG_OK);
58 for (i = 2; i < argc; i++)
59 if (mg_load(argv[i]) != MG_OK)
60 exit(1);
61 exit(0);
62 }