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.4 by greg, Sat Feb 22 02:07:26 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   */
# Line 16 | Line 13 | static char SCCSid[] = "$SunId$ LBL";
13  
14   #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);
72 >        fgetword(sbuf, MAXSTR, fp);
73          if (!strcmp(sbuf, ALIASID))
74                  thisobj.otype = -1;
75          else if ((thisobj.otype = otype(sbuf)) < 0) {
# Line 83 | Line 77 | int  (*f)();
77                  error(USER, errmsg);
78          }
79                                          /* get identifier */
80 <        fscanf(fp, "%s", sbuf);
80 >        fgetword(sbuf, MAXSTR, fp);
81          thisobj.oname = sbuf;
82                                          /* get arguments */
83          if (thisobj.otype == -1) {
# Line 95 | Line 89 | int  (*f)();
89                  objerror(&thisobj, USER, errmsg);
90          }
91          thisobj.os = NULL;
98        thisobj.lastrno = -1;
92                                          /* call function */
93          (*f)(&thisobj);
94                                          /* 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                }
95          freefargs(&thisobj.oargs);
96 +        free_os(&thisobj);
97   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines