From bc6736f91de3bfbb6c0b8575a481eaf5a8648e6d Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Tue, 21 Mar 2006 16:37:51 +0000 Subject: [PATCH] Fixed win32 I/O functions usage as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1127 --- libtiff/tif_config.h.vc | 3 +++ libtiff/tif_unix.c | 3 ++- libtiff/tiffio.h | 7 +++---- nmake.opt | 7 ++++++- tools/fax2ps.c | 6 +++++- tools/fax2tiff.c | 6 +++++- tools/tiff2pdf.c | 14 ++++++-------- 7 files changed, 30 insertions(+), 16 deletions(-) diff --git a/libtiff/tif_config.h.vc b/libtiff/tif_config.h.vc index da8e046f..98e40fae 100644 --- a/libtiff/tif_config.h.vc +++ b/libtiff/tif_config.h.vc @@ -8,6 +8,9 @@ machine */ #define HAVE_IEEEFP 1 +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 diff --git a/libtiff/tif_unix.c b/libtiff/tif_unix.c index 9ebafcaf..b6e2b707 100644 --- a/libtiff/tif_unix.c +++ b/libtiff/tif_unix.c @@ -1,4 +1,4 @@ -/* $Id: tif_unix.c,v 1.11 2005-12-21 12:23:13 joris Exp $ */ +/* $Id: tif_unix.c,v 1.12 2006-03-21 16:37:51 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -182,6 +182,7 @@ TIFFOpen(const char* name, const char* mode) } #ifdef __WIN32__ +#include /* * Open a TIFF file with a Unicode filename, for read/writing. */ diff --git a/libtiff/tiffio.h b/libtiff/tiffio.h index f482eec2..9fc74350 100644 --- a/libtiff/tiffio.h +++ b/libtiff/tiffio.h @@ -1,4 +1,4 @@ -/* $Id: tiffio.h,v 1.49 2005-12-27 11:13:58 dron Exp $ */ +/* $Id: tiffio.h,v 1.50 2006-03-21 16:37:51 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -75,13 +75,12 @@ typedef uint32 toff_t; /* file offset */ * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). * - * By default tif_win32.c is assumed on windows if not using the cygwin - * environment. + * By default tif_unix.c is assumed. */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) -# define USE_WIN32_FILEIO +# define AVOID_WIN32_FILEIO # endif #endif diff --git a/nmake.opt b/nmake.opt index 73bd3316..732ce43f 100644 --- a/nmake.opt +++ b/nmake.opt @@ -1,4 +1,4 @@ -# $Id: nmake.opt,v 1.14 2005-10-07 17:27:10 dron Exp $ +# $Id: nmake.opt,v 1.15 2006-03-21 16:37:51 dron Exp $ # # Copyright (C) 2004, Andrey Kiselev # @@ -207,3 +207,8 @@ EXTRAFLAGS = -DDEFAULT_EXTRASAMPLE_AS_ALPHA $(EXTRAFLAGS) EXTRAFLAGS = -DCHECK_JPEG_YCBCR_SUBSAMPLING $(EXTRAFLAGS) !ENDIF +!IFDEF USE_WIN_CRT_LIB +EXTRAFLAGS = -DAVOID_WIN32_FILEIO $(EXTRAFLAGS) +!ELSE +EXTRAFLAGS = -DUSE_WIN32_FILEIO $(EXTRAFLAGS) +!ENDIF diff --git a/tools/fax2ps.c b/tools/fax2ps.c index 6de58818..c3ddc62f 100644 --- a/tools/fax2ps.c +++ b/tools/fax2ps.c @@ -1,4 +1,4 @@ -/* $Id: fax2ps.c,v 1.20 2006-03-17 14:56:42 dron Exp $" */ +/* $Id: fax2ps.c,v 1.21 2006-03-21 16:37:51 dron Exp $" */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -383,7 +383,11 @@ main(int argc, char** argv) while ((n = read(fileno(stdin), buf, sizeof (buf))) > 0) write(fileno(fd), buf, n); lseek(fileno(fd), 0, SEEK_SET); +#if defined(_WIN32) && defined(USE_WIN32_FILEIO) + tif = TIFFFdOpen(_get_osfhandle(fileno(fd)), "temp", "r"); +#else tif = TIFFFdOpen(fileno(fd), "temp", "r"); +#endif if (tif) { fax2ps(tif, npages, pages, ""); TIFFClose(tif); diff --git a/tools/fax2tiff.c b/tools/fax2tiff.c index ea3317f5..e14141fe 100644 --- a/tools/fax2tiff.c +++ b/tools/fax2tiff.c @@ -1,4 +1,4 @@ -/* $Id: fax2tiff.c,v 1.17 2006-03-17 14:58:57 dron Exp $ */ +/* $Id: fax2tiff.c,v 1.18 2006-03-21 16:37:51 dron Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -264,7 +264,11 @@ main(int argc, char* argv[]) "%s: %s: Can not open\n", argv[0], argv[optind]); continue; } +#if defined(_WIN32) && defined(USE_WIN32_FILEIO) + TIFFSetClientdata(faxTIFF, (thandle_t)_get_osfhandle(fileno(in))); +#else TIFFSetClientdata(faxTIFF, (thandle_t)fileno(in)); +#endif TIFFSetFileName(faxTIFF, (const char*)argv[optind]); TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1); diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c index 8fa4af97..577006f1 100644 --- a/tools/tiff2pdf.c +++ b/tools/tiff2pdf.c @@ -1,4 +1,4 @@ -/* $Id: tiff2pdf.c,v 1.29 2006-03-20 15:29:53 dron Exp $ +/* $Id: tiff2pdf.c,v 1.30 2006-03-21 16:37:51 dron Exp $ * * tiff2pdf - converts a TIFF image to a PDF document * @@ -45,7 +45,7 @@ #if defined(VMS) #define unlink remove #endif -#if defined(_WIN32) +#if defined(_WIN32) && defined(USE_WIN32_FILEIO) #include #include #define unlink DeleteFileA @@ -666,10 +666,9 @@ int main(int argc, char** argv){ TIFFSeekFile(output, (toff_t) 0, SEEK_SET); } } else { -#ifndef _WIN32 +#if !defined(_WIN32) || defined(AVOID_WIN32_FILEIO) output = TIFFFdOpen((int)fileno(tmpfile()), "-", "w"); -#endif -#ifdef _WIN32 +#else { TCHAR temppath[MAX_PATH]; TCHAR tempfile[MAX_PATH]; @@ -696,11 +695,10 @@ int main(int argc, char** argv){ output->tif_readproc=t2p_empty_readproc; output->tif_seekproc=t2p_empty_seekproc; output->tif_closeproc=t2p_empty_closeproc; -#ifndef _WIN32 +#if !defined(_WIN32) || defined(AVOID_WIN32_FILEIO) close(output->tif_fd); output->tif_fd=(int)fileno(stdout); -#endif -#ifdef _WIN32 +#else CloseHandle((HANDLE) output->tif_fd); output->tif_fd=(int)GetStdHandle(STD_OUTPUT_HANDLE); #endif