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.12 by greg, Wed Jul 29 18:11:23 2020 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 > #include  <stdio.h>
10  
11 + #include  "platform.h"
12 + #include  "paths.h"
13 + #include  "rtmath.h"
14 + #include  "rtio.h"
15 + #include  "rterror.h"
16   #include  "object.h"
14
17   #include  "otypes.h"
18 + #include  "oconv.h"
19  
17 #include  <ctype.h>
20  
21 < OBJREC  *objblock[MAXOBJBLK];           /* our objects */
20 < OBJECT  nobjects = 0;                   /* # of objects */
21 < int newobject() {return(0);}
21 > static void getobject2(char  *name, FILE  *fp, ro_cbfunc f);
22  
23  
24 < readobj(input, callback)        /* read in an object file or stream */
25 < char  *input;
26 < int  (*callback)();
24 > void
25 > readobj2(       /* read in an object file or stream */
26 >        char  *input,
27 >        ro_cbfunc callback
28 > )
29   {
28        FILE  *popen();
29        char  *fgets(), *fgetline();
30          FILE  *infp;
31 <        char  buf[512];
31 >        char  buf[2048];
32          register int  c;
33  
34          if (input == NULL) {
# Line 51 | Line 51 | int  (*callback)();
51                  } else if (c == '!') {                  /* command */
52                          ungetc(c, infp);
53                          fgetline(buf, sizeof(buf), infp);
54 <                        readobj(buf, callback);
54 >                        readobj2(buf, callback);
55                  } else {                                /* object */
56                          ungetc(c, infp);
57 <                        getobject(input, infp, callback);
57 >                        getobject2(input, infp, callback);
58                  }
59          }
60          if (input[0] == '!')
# Line 64 | Line 64 | int  (*callback)();
64   }
65  
66  
67 < getobject(name, fp, f)                  /* read the next object */
68 < char  *name;
69 < FILE  *fp;
70 < int  (*f)();
67 > static void
68 > getobject2(                     /* read the next object */
69 >        char  *name,
70 >        FILE  *fp,
71 >        ro_cbfunc f
72 > )
73   {
74          char  sbuf[MAXSTR];
75          OBJREC  thisobj;
76                                          /* get modifier */
77 <        fscanf(fp, "%*s");
77 >        fgetword(sbuf, MAXSTR, fp);
78          thisobj.omod = OVOID;
79                                          /* get type */
80 <        fscanf(fp, "%s", sbuf);
81 <        if (!strcmp(sbuf, ALIASID))
80 <                thisobj.otype = -1;
81 <        else if ((thisobj.otype = otype(sbuf)) < 0) {
80 >        fgetword(sbuf, MAXSTR, fp);
81 >        if ((thisobj.otype = otype(sbuf)) < 0) {
82                  sprintf(errmsg, "(%s): unknown type \"%s\"", name, sbuf);
83                  error(USER, errmsg);
84          }
85                                          /* get identifier */
86 <        fscanf(fp, "%s", sbuf);
86 >        fgetword(sbuf, MAXSTR, fp);
87          thisobj.oname = sbuf;
88                                          /* get arguments */
89 <        if (thisobj.otype == -1) {
89 >        if (thisobj.otype == MOD_ALIAS) {
90                  fscanf(fp, "%*s");
91                  return;
92          }
# Line 95 | Line 95 | int  (*f)();
95                  objerror(&thisobj, USER, errmsg);
96          }
97          thisobj.os = NULL;
98        thisobj.lastrno = -1;
98                                          /* call function */
99          (*f)(&thisobj);
100                                          /* 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                }
101          freefargs(&thisobj.oargs);
102 +        free_os(&thisobj);
103   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines