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

Comparing ray/src/common/lamps.c (file contents):
Revision 2.2 by greg, Tue Nov 10 10:29:22 1992 UTC vs.
Revision 2.8 by schorsch, Sat Jun 7 12:50:20 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1990 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   * Load lamp data.
6   */
7  
8 + #include "copyright.h"
9 +
10   #include  <stdio.h>
11 + #include  <stdlib.h>
12   #include  <ctype.h>
13  
14 < extern char     *eindex(), *expsave(), *malloc();
15 < extern FILE     *fropen();
14 > #include  "standard.h"
15 > #include  "color.h"
16  
17 + extern char     *eindex(), *expsave();
18 + extern FILE     *frlibopen();
19 +
20   typedef struct lamp {
21          char    *pattern;                       /* search pattern */
22          float   *color;                         /* pointer to lamp value */
# Line 48 | Line 51 | char   *file;
51          char    buf[128], str[128];
52          register char   *cp1, *cp2;
53  
54 <        if ((fp = fropen(file)) == NULL)
54 >        if ((fp = frlibopen(file)) == NULL)
55                  return(0);
56          lastp = NULL;
57          while (fgets(buf, sizeof(buf), fp) != NULL) {
# Line 92 | Line 95 | char   *file;
95                                  goto fmterr;
96                          }
97                  } else {                        /* or read specificaion */
98 <                        if ((lp->color=(float *)malloc(3*sizeof(float)))==NULL)
98 >                        if ((lp->color=(float *)malloc(6*sizeof(float)))==NULL)
99                                  goto memerr;
100 <                        if (sscanf(cp1, "%f %f %f", &lp->color[0], &
101 <                                        lp->color[1], &lp->color[2]) != 3) {
100 >                        if (sscanf(cp1, "%f %f %f", &lp->color[3], &
101 >                                        lp->color[4], &lp->color[5]) != 3) {
102                                  cp1 = "bad lamp data";
103                                  goto fmterr;
104                          }
105                                                  /* convert xyY to XYZ */
106 <                        xyz[1] = lp->color[2];
107 <                        xyz[0] = lp->color[0]/lp->color[1] * xyz[1];
108 <                        xyz[2] = xyz[1]*(1./lp->color[1] - 1.) - xyz[0];
106 >                        xyz[1] = lp->color[5];
107 >                        xyz[0] = lp->color[3]/lp->color[4] * xyz[1];
108 >                        xyz[2] = xyz[1]*(1./lp->color[4] - 1.) - xyz[0];
109                                                  /* XYZ to RGB */
110                          cie_rgb(lp->color, xyz);
111                  }
# Line 135 | Line 138 | freelamps()                    /* free our lamps list */
138                          for (lp2 = lp1->next; lp2 != NULL; lp2 = lp2->next)
139                                  if (lp2->color == lp1->color)
140                                          lp2->color = NULL;
141 <                        free((char *)lp1->color);
141 >                        free((void *)lp1->color);
142                  }
143                  lp2 = lp1->next;
144 <                free((char *)lp1);
144 >                free((void *)lp1);
145          }
146          lamps = NULL;
147   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines