Fixed win32 I/O functions usage as per bug

http://bugzilla.remotesensing.org/show_bug.cgi?id=1127
This commit is contained in:
Andrey Kiselev 2006-03-21 16:37:51 +00:00
parent a1151ff372
commit bc6736f91d
7 changed files with 30 additions and 16 deletions

View File

@ -8,6 +8,9 @@
machine */
#define HAVE_IEEEFP 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

View File

@ -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 <windows.h>
/*
* Open a TIFF file with a Unicode filename, for read/writing.
*/

View File

@ -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

View File

@ -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 <dron@remotesensing.org>
#
@ -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

View File

@ -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, "<stdin>");
TIFFClose(tif);

View File

@ -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);

View File

@ -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 <windows.h>
#include <tchar.h>
#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