--- ray/src/cv/lampcolor.c 1994/07/05 15:49:51 2.5 +++ ray/src/cv/lampcolor.c 2003/11/15 17:54:06 2.9 @@ -1,24 +1,18 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: lampcolor.c,v 2.9 2003/11/15 17:54:06 schorsch Exp $"; #endif - /* * Program to convert lamp color from table and compute radiance. */ #include - +#include #include +#include "rtmath.h" +#include "rtio.h" #include "color.h" -#define PI 3.14159265358979323846 - -extern char *gets(), *strcpy(); -extern float *matchlamp(); - /* lamp parameters */ #define LTYPE 0 #define LUNIT 1 @@ -26,8 +20,15 @@ extern float *matchlamp(); #define LOUTP 3 #define NPARAMS 4 -int typecheck(), unitcheck(), geomcheck(), outpcheck(); +static int typecheck(char *s); +static int unitcheck(char *s); +static int geomcheck(char *s); +static int outpcheck(char *s); +static void compute(void); +static int getpolygon(void), getsphere(void), getcylinder(void), getring(void); +static int getd(char *name, double *dp, char *help); + float *lampcolor; /* the lamp color (RGB) */ double unit2meter; /* conversion from units to meters */ double area; /* radiating area for this geometry */ @@ -57,9 +58,11 @@ for fluorescent fixtures." }, }; -main(argc, argv) -int argc; -char *argv[]; +int +main( + int argc, + char *argv[] +) { char *lamptab = "lamp.tab"; char buf[64]; @@ -76,7 +79,7 @@ char *argv[]; while (i < NPARAMS) { printf("Enter %s [%s]: ", param[i].name, param[i].value); - if (gets(buf) == NULL) + if (fgets(buf, sizeof(buf), stdin) == NULL) exit(0); if (buf[0] == '?') { puts(param[i].help); @@ -96,16 +99,20 @@ char *argv[]; } -typecheck(s) /* check lamp type */ -char *s; +static int +typecheck( /* check lamp type */ + char *s +) { lampcolor = matchlamp(s); return(lampcolor != NULL); } -unitcheck(s) /* compute conversion to meters */ -char *s; +static int +unitcheck( /* compute conversion to meters */ + char *s +) { int len = strlen(s); @@ -135,8 +142,10 @@ char *s; } -geomcheck(s) /* check/set lamp geometry */ -char *s; +static int +geomcheck( /* check/set lamp geometry */ + char *s +) { int len = strlen(s); @@ -162,8 +171,10 @@ char *s; } -outpcheck(s) /* check lumen output value */ -register char *s; +static int +outpcheck( /* check lumen output value */ + register char *s +) { if ((*s < '0' || *s > '9') && *s != '.') return(0); @@ -172,7 +183,8 @@ register char *s; } -compute() /* compute lamp radiance */ +static void +compute(void) /* compute lamp radiance */ { double whiteval; @@ -185,15 +197,17 @@ compute() /* compute lamp radiance */ } -getd(name, dp, help) /* get a positive double from stdin */ -char *name; -double *dp; -char *help; +static int +getd( /* get a positive double from stdin */ + char *name, + double *dp, + char *help +) { char buf[32]; again: printf("%s [%g]: ", name, *dp); - if (gets(buf) == NULL) + if (fgets(buf, sizeof(buf), stdin) == NULL) return(0); if (buf[0] == '?') { puts(help); @@ -206,7 +220,8 @@ again: } -getpolygon() /* get projected area for a polygon */ +static int +getpolygon(void) /* get projected area for a polygon */ { static double parea = 1.0; @@ -217,7 +232,8 @@ getpolygon() /* get projected area for a polygon */ } -getsphere() /* get projected area for a sphere */ +static int +getsphere(void) /* get projected area for a sphere */ { static double radius = 1.0; @@ -228,7 +244,8 @@ getsphere() /* get projected area for a sphere */ } -getcylinder() /* get projected area for a cylinder */ +static int +getcylinder(void) /* get projected area for a cylinder */ { static double length = 1.0, radius = 0.1; @@ -241,7 +258,8 @@ getcylinder() /* get projected area for a cylinder * } -getring() /* get projected area for a ring */ +static int +getring(void) /* get projected area for a ring */ { static double radius = 1.0;