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 ", |
650 |
|
fprintf(ambfp, "-cw %g %g -cs %d ", WLPART[3], WLPART[0], NCSAMP); |
651 |
|
if (octname != NULL) |
652 |
|
fputs(octname, ambfp); |
653 |
< |
fputc('\n', ambfp); |
653 |
> |
fputc('\n', ambfp); /* end of command line, not header! */ |
654 |
|
fprintf(ambfp, "SOFTWARE= %s\n", VersionID); |
655 |
|
fputnow(ambfp); |
656 |
+ |
AMB_CNDX = CNDX; /* use current spectral sampling */ |
657 |
+ |
AMB_WLPART = WLPART; |
658 |
|
fputwlsplit(WLPART, ambfp); |
659 |
|
fputncomp(NCSAMP, ambfp); |
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 = 3; |
666 |
> |
if (--ntries > 0 && ftell(ambfp) == 0) { |
667 |
> |
clearerr(ambfp); |
668 |
> |
sleep(2); |
669 |
> |
goto retry; |
670 |
> |
} |
671 |
> |
#endif |
672 |
|
error(USER, "bad/incompatible ambient file"); |
673 |
< |
|
673 |
> |
} |
674 |
|
if ((AMB_CNDX != CNDX) | (AMB_WLPART != WLPART)) { |
675 |
|
if (setspectrsamp(AMB_CNDX, AMB_WLPART) < 0) |
676 |
|
error(USER, "bad wavelength sampling in ambient file"); |