ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/ot/readobj2.c
(Generate patch)

Comparing ray/src/ot/readobj2.c (file contents):
Revision 1.4 by greg, Fri Jul 19 09:29:24 1991 UTC vs.
Revision 2.6 by schorsch, Thu Jun 26 00:58:10 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  readobj2.c - routines for reading in object descriptions.
6   */
7  
8 < #include  "standard.h"
8 > #include  <ctype.h>
9  
10 + #include  "standard.h"
11 + #include  "platform.h"
12   #include  "object.h"
14
13   #include  "otypes.h"
14  
17 #include  <ctype.h>
15  
16 < OBJREC  *objblock[MAXOBJBLK];           /* our objects */
20 < OBJECT  nobjects = 0;                   /* # of objects */
21 < int newobject() {return(0);}
16 > extern char  *fgetword();
17  
18 <
24 < readobj(input, callback)        /* read in an object file or stream */
18 > readobj2(input, callback)       /* read in an object file or stream */
19   char  *input;
20   int  (*callback)();
21   {
22          FILE  *popen();
23 <        char  *fgets(), *fgetline();
23 >        char  *fgetline();
24          FILE  *infp;
25          char  buf[512];
26          register int  c;
# Line 51 | Line 45 | int  (*callback)();
45                  } else if (c == '!') {                  /* command */
46                          ungetc(c, infp);
47                          fgetline(buf, sizeof(buf), infp);
48 <                        readobj(buf, callback);
48 >                        readobj2(buf, callback);
49                  } else {                                /* object */
50                          ungetc(c, infp);
51 <                        getobject(input, infp, callback);
51 >                        getobject2(input, infp, callback);
52                  }
53          }
54          if (input[0] == '!')
# Line 64 | Line 58 | int  (*callback)();
58   }
59  
60  
61 < getobject(name, fp, f)                  /* read the next object */
61 > getobject2(name, fp, f)                 /* read the next object */
62   char  *name;
63   FILE  *fp;
64   int  (*f)();
# Line 72 | Line 66 | int  (*f)();
66          char  sbuf[MAXSTR];
67          OBJREC  thisobj;
68                                          /* get modifier */
69 <        fscanf(fp, "%*s");
69 >        fgetword(sbuf, MAXSTR, fp);
70          thisobj.omod = OVOID;
71                                          /* get type */
72 <        fscanf(fp, "%s", sbuf);
73 <        if (!strcmp(sbuf, ALIASID))
80 <                thisobj.otype = -1;
81 <        else if ((thisobj.otype = otype(sbuf)) < 0) {
72 >        fgetword(sbuf, MAXSTR, fp);
73 >        if ((thisobj.otype = otype(sbuf)) < 0) {
74                  sprintf(errmsg, "(%s): unknown type \"%s\"", name, sbuf);
75                  error(USER, errmsg);
76          }
77                                          /* get identifier */
78 <        fscanf(fp, "%s", sbuf);
78 >        fgetword(sbuf, MAXSTR, fp);
79          thisobj.oname = sbuf;
80                                          /* get arguments */
81 <        if (thisobj.otype == -1) {
81 >        if (thisobj.otype == MOD_ALIAS) {
82                  fscanf(fp, "%*s");
83                  return;
84          }
# Line 95 | Line 87 | int  (*f)();
87                  objerror(&thisobj, USER, errmsg);
88          }
89          thisobj.os = NULL;
98        thisobj.lastrno = -1;
90                                          /* call function */
91          (*f)(&thisobj);
92                                          /* free memory */
102        if (thisobj.os != NULL)
103                switch (thisobj.otype) {
104                case OBJ_CONE:
105                case OBJ_CUP:
106                case OBJ_CYLINDER:
107                case OBJ_TUBE:
108                case OBJ_RING:
109                        freecone(&thisobj);
110                        break;
111                case OBJ_FACE:
112                        freeface(&thisobj);
113                        break;
114                case OBJ_INSTANCE:
115                        freeinstance(&thisobj);
116                        break;
117                }
93          freefargs(&thisobj.oargs);
94 +        free_os(&thisobj);
95   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines