167 |
|
FVECT c0; |
168 |
|
double s; |
169 |
|
{ |
170 |
– |
extern double sqrt(); |
170 |
|
double d, e1, e2, wt, wsum; |
171 |
|
COLOR ct; |
172 |
|
FVECT ck0; |
400 |
|
|
401 |
|
#else |
402 |
|
|
404 |
– |
#include <fcntl.h> |
403 |
|
#include <sys/types.h> |
404 |
|
#include <sys/stat.h> |
405 |
|
|
409 |
|
static FILE *ambinp = NULL; |
410 |
|
struct flock fls; |
411 |
|
struct stat sts; |
412 |
+ |
#define flen sts.st_size |
413 |
|
AMBVAL avs; |
414 |
< |
long lastpos, flen; |
414 |
> |
long lastpos; |
415 |
|
register int n; |
416 |
|
/* gain exclusive access */ |
417 |
|
fls.l_type = F_WRLCK; |
424 |
|
lastpos = lseek(fileno(ambfp), 0L, 1); /* get previous position */ |
425 |
|
if (fstat(fileno(ambfp), &sts) < 0) /* get current length */ |
426 |
|
error(SYSTEM, "cannot stat ambient file"); |
428 |
– |
flen = sts.st_size; |
427 |
|
if (n = (flen - lastpos)/AMBVALSIZ) { /* file has grown */ |
428 |
< |
if (ambinp == NULL) /* use duplicate file */ |
428 |
> |
if (ambinp == NULL) { /* use duplicate file */ |
429 |
|
ambinp = fdopen(dup(fileno(ambfp)), "r"); |
430 |
+ |
if (ambinp == NULL) |
431 |
+ |
error(SYSTEM, "fdopen failed in ambsync"); |
432 |
+ |
} |
433 |
|
while (n--) { /* load contributed values */ |
434 |
|
readambval(&avs, ambinp); |
435 |
|
avinsert(&avs,&atrunk,thescene.cuorg,thescene.cusize); |