--- ray/src/common/lamps.c 1992/11/10 10:29:22 2.2 +++ ray/src/common/lamps.c 2003/06/07 12:50:20 2.8 @@ -1,19 +1,22 @@ -/* Copyright (c) 1990 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: lamps.c,v 2.8 2003/06/07 12:50:20 schorsch Exp $"; #endif - /* * Load lamp data. */ +#include "copyright.h" + #include +#include #include -extern char *eindex(), *expsave(), *malloc(); -extern FILE *fropen(); +#include "standard.h" +#include "color.h" +extern char *eindex(), *expsave(); +extern FILE *frlibopen(); + typedef struct lamp { char *pattern; /* search pattern */ float *color; /* pointer to lamp value */ @@ -48,7 +51,7 @@ char *file; char buf[128], str[128]; register char *cp1, *cp2; - if ((fp = fropen(file)) == NULL) + if ((fp = frlibopen(file)) == NULL) return(0); lastp = NULL; while (fgets(buf, sizeof(buf), fp) != NULL) { @@ -92,17 +95,17 @@ char *file; goto fmterr; } } else { /* or read specificaion */ - if ((lp->color=(float *)malloc(3*sizeof(float)))==NULL) + if ((lp->color=(float *)malloc(6*sizeof(float)))==NULL) goto memerr; - if (sscanf(cp1, "%f %f %f", &lp->color[0], & - lp->color[1], &lp->color[2]) != 3) { + if (sscanf(cp1, "%f %f %f", &lp->color[3], & + lp->color[4], &lp->color[5]) != 3) { cp1 = "bad lamp data"; goto fmterr; } /* convert xyY to XYZ */ - xyz[1] = lp->color[2]; - xyz[0] = lp->color[0]/lp->color[1] * xyz[1]; - xyz[2] = xyz[1]*(1./lp->color[1] - 1.) - xyz[0]; + xyz[1] = lp->color[5]; + xyz[0] = lp->color[3]/lp->color[4] * xyz[1]; + xyz[2] = xyz[1]*(1./lp->color[4] - 1.) - xyz[0]; /* XYZ to RGB */ cie_rgb(lp->color, xyz); } @@ -135,10 +138,10 @@ freelamps() /* free our lamps list */ for (lp2 = lp1->next; lp2 != NULL; lp2 = lp2->next) if (lp2->color == lp1->color) lp2->color = NULL; - free((char *)lp1->color); + free((void *)lp1->color); } lp2 = lp1->next; - free((char *)lp1); + free((void *)lp1); } lamps = NULL; }