--- OLD/libtiff/tif_unix.c Thu Jan 1 00:00:00 1970 +++ NEW/libtiff/tif_unix.c Thu Jan 1 00:00:00 1970 @@ -34,40 +34,41 @@ #include static tsize_t -_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) +_tiffReadProc(thandle_t h, tdata_t buf, tsize_t size) { - return (read((int) fd, buf, (size_t) size)); + return (read(*(int *)h, buf, (size_t) size)); } static tsize_t -_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) +_tiffWriteProc(thandle_t h, tdata_t buf, tsize_t size) { - return (write((int) fd, buf, (size_t) size)); + return (write(*(int *)h, buf, (size_t) size)); } static toff_t -_tiffSeekProc(thandle_t fd, off_t off, int whence) +_tiffSeekProc(thandle_t h, toff_t off, int whence) { - return ((toff_t) lseek((int) fd, (off_t) off, whence)); + return ((toff_t) lseek(*(int *)h, (off_t) off, whence)); } static int -_tiffCloseProc(thandle_t fd) +_tiffCloseProc(thandle_t h) { - return (close((int) fd)); + close(*(int *)h); + free(h); } #include static toff_t -_tiffSizeProc(thandle_t fd) +_tiffSizeProc(thandle_t h) { #ifdef _AM29K long fsize; - return ((fsize = lseek((int) fd, 0, SEEK_END)) < 0 ? 0 : fsize); + return ((fsize = lseek(*(int *)h, 0, SEEK_END)) < 0 ? 0 : fsize); #else struct stat sb; - return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); + return (toff_t) (fstat(*(int *)h, &sb) < 0 ? 0 : sb.st_size); #endif } @@ -75,12 +76,12 @@ #include static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +_tiffMapProc(thandle_t h, tdata_t* pbase, toff_t* psize) { - toff_t size = _tiffSizeProc(fd); + toff_t size = _tiffSizeProc(h); if (size != (toff_t) -1) { *pbase = (tdata_t) - mmap(0, size, PROT_READ, MAP_SHARED, (int) fd, 0); + mmap(0, size, PROT_READ, MAP_SHARED, *(int *)h, 0); if (*pbase != (tdata_t) -1) { *psize = size; return (1); @@ -90,19 +91,19 @@ } static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) +_tiffUnmapProc(thandle_t h, tdata_t base, toff_t size) { (void) munmap(base, (off_t) size); } #else /* !MMAP_SUPPORT */ static int -_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +_tiffMapProc(thandle_t h, tdata_t* pbase, toff_t* psize) { return (0); } static void -_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) +_tiffUnmapProc(thandle_t h, tdata_t base, toff_t size) { } #endif /* !MMAP_SUPPORT */ @@ -114,9 +115,12 @@ TIFFFdOpen(int fd, const char* name, const char* mode) { TIFF* tif; + int *fdp; + fdp = malloc(sizeof(int)); + *fdp = fd; tif = TIFFClientOpen(name, mode, - (thandle_t) fd, + (thandle_t) fdp, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, _tiffMapProc, _tiffUnmapProc);