634 |
|
if (mybuf == NULL) |
635 |
|
mybuf = (char *)bmalloc(BUFSIZ+8); |
636 |
|
setbuf(ambfp, mybuf); |
637 |
+ |
retry: |
638 |
|
if (cre8) { /* new file */ |
639 |
|
newheader("RADIANCE", ambfp); |
640 |
|
fprintf(ambfp, "%s -av %g %g %g -aw %d -ab %d -aa %g ", |
660 |
|
fputformat(AMBFMT, ambfp); |
661 |
|
fputc('\n', ambfp); |
662 |
|
putambmagic(ambfp); |
663 |
< |
} else if (getheader(ambfp, amb_headline, NULL) < 0 || !hasambmagic(ambfp)) |
663 |
> |
} else if (getheader(ambfp, amb_headline, NULL) < 0 || !hasambmagic(ambfp)) { |
664 |
> |
#ifndef F_SETLKW |
665 |
> |
static int ntries = 0; |
666 |
> |
if (++ntries < 4 && ftell(ambfp) == 0) { |
667 |
> |
sleep(2); |
668 |
> |
goto retry; |
669 |
> |
} |
670 |
> |
#endif |
671 |
|
error(USER, "bad/incompatible ambient file"); |
672 |
< |
|
672 |
> |
} |
673 |
|
if ((AMB_CNDX != CNDX) | (AMB_WLPART != WLPART)) { |
674 |
|
if (setspectrsamp(AMB_CNDX, AMB_WLPART) < 0) |
675 |
|
error(USER, "bad wavelength sampling in ambient file"); |