9 |
|
#include <string.h> |
10 |
|
#include <math.h> |
11 |
|
|
12 |
< |
#include "standard.h" |
12 |
> |
#include "rtmath.h" |
13 |
> |
#include "rtio.h" |
14 |
|
#include "color.h" |
15 |
|
|
16 |
|
/* lamp parameters */ |
26 |
|
static int outpcheck(char *s); |
27 |
|
static void compute(void); |
28 |
|
static int getpolygon(void), getsphere(void), getcylinder(void), getring(void); |
29 |
+ |
static int getd(char *name, double *dp, char *help); |
30 |
|
|
31 |
|
|
32 |
|
float *lampcolor; /* the lamp color (RGB) */ |
58 |
|
}; |
59 |
|
|
60 |
|
|
61 |
< |
main(argc, argv) |
62 |
< |
int argc; |
63 |
< |
char *argv[]; |
61 |
> |
int |
62 |
> |
main( |
63 |
> |
int argc, |
64 |
> |
char *argv[] |
65 |
> |
) |
66 |
|
{ |
67 |
|
char *lamptab = "lamp.tab"; |
68 |
|
char buf[64]; |
79 |
|
while (i < NPARAMS) { |
80 |
|
printf("Enter %s [%s]: ", param[i].name, |
81 |
|
param[i].value); |
82 |
< |
if (gets(buf) == NULL) |
82 |
> |
if (fgets(buf, sizeof(buf), stdin) == NULL) |
83 |
|
exit(0); |
84 |
|
if (buf[0] == '?') { |
85 |
|
puts(param[i].help); |
101 |
|
|
102 |
|
static int |
103 |
|
typecheck( /* check lamp type */ |
104 |
< |
char *s |
104 |
> |
char *s |
105 |
|
) |
106 |
|
{ |
107 |
|
lampcolor = matchlamp(s); |
111 |
|
|
112 |
|
static int |
113 |
|
unitcheck( /* compute conversion to meters */ |
114 |
< |
char *s |
114 |
> |
char *s |
115 |
|
) |
116 |
|
{ |
117 |
|
int len = strlen(s); |
144 |
|
|
145 |
|
static int |
146 |
|
geomcheck( /* check/set lamp geometry */ |
147 |
< |
char *s |
147 |
> |
char *s |
148 |
|
) |
149 |
|
{ |
150 |
|
int len = strlen(s); |
173 |
|
|
174 |
|
static int |
175 |
|
outpcheck( /* check lumen output value */ |
176 |
< |
register char *s |
176 |
> |
register char *s |
177 |
|
) |
178 |
|
{ |
179 |
|
if ((*s < '0' || *s > '9') && *s != '.') |
197 |
|
} |
198 |
|
|
199 |
|
|
200 |
< |
getd(name, dp, help) /* get a positive double from stdin */ |
201 |
< |
char *name; |
202 |
< |
double *dp; |
203 |
< |
char *help; |
200 |
> |
static int |
201 |
> |
getd( /* get a positive double from stdin */ |
202 |
> |
char *name, |
203 |
> |
double *dp, |
204 |
> |
char *help |
205 |
> |
) |
206 |
|
{ |
207 |
|
char buf[32]; |
208 |
|
again: |
209 |
|
printf("%s [%g]: ", name, *dp); |
210 |
< |
if (gets(buf) == NULL) |
210 |
> |
if (fgets(buf, sizeof(buf), stdin) == NULL) |
211 |
|
return(0); |
212 |
|
if (buf[0] == '?') { |
213 |
|
puts(help); |