Support large files under Windows using tif_unix.c and libtiff tools.
This commit is contained in:
parent
a0e1185771
commit
8ba4a1c894
@ -1,3 +1,11 @@
|
||||
2015-08-18 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
|
||||
|
||||
* libtiff/tiffiop.h: First cut at supporting large files under
|
||||
Microsoft Windows using tif_unix.c and the libtiff tools. This
|
||||
only works if the Windows CDK is new enough to support the APIs
|
||||
used (Visual C++ 2005 or later). Support for large files is not
|
||||
actually tested yet.
|
||||
|
||||
2015-08-15 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
|
||||
|
||||
* libtiff/tif_jpeg.c: Applied patch by Räisä Olli to assure that
|
||||
|
69
configure
vendored
69
configure
vendored
@ -17244,6 +17244,75 @@ $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
|
||||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
|
||||
$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
|
||||
if ${ac_cv_sys_largefile_source+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
while :; do
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <sys/types.h> /* for off_t */
|
||||
#include <stdio.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int (*fp) (FILE *, off_t, int) = fseeko;
|
||||
return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
ac_cv_sys_largefile_source=no; break
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
#include <sys/types.h> /* for off_t */
|
||||
#include <stdio.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int (*fp) (FILE *, off_t, int) = fseeko;
|
||||
return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
ac_cv_sys_largefile_source=1; break
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
ac_cv_sys_largefile_source=unknown
|
||||
break
|
||||
done
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5
|
||||
$as_echo "$ac_cv_sys_largefile_source" >&6; }
|
||||
case $ac_cv_sys_largefile_source in #(
|
||||
no | unknown) ;;
|
||||
*)
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
|
||||
_ACEOF
|
||||
;;
|
||||
esac
|
||||
rm -rf conftest*
|
||||
|
||||
# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
|
||||
# in glibc 2.1.3, but that breaks too many other things.
|
||||
# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
|
||||
if test $ac_cv_sys_largefile_source != unknown; then
|
||||
|
||||
$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
|
||||
ac_fn_c_check_decl "$LINENO" "optarg" "ac_cv_have_decl_optarg" "$ac_includes_default"
|
||||
if test "x$ac_cv_have_decl_optarg" = xyes; then :
|
||||
ac_have_decl=1
|
||||
|
@ -182,6 +182,10 @@ AC_TYPE_SIZE_T
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
|
||||
dnl If the `fseeko' function is available, define `HAVE_FSEEKO'. Define
|
||||
dnl `_LARGEFILE_SOURCE' if necessary.
|
||||
AC_FUNC_FSEEKO
|
||||
|
||||
dnl Check if optarg (and presumably related externs) already declared in headers
|
||||
AC_CHECK_DECLS([optarg])
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile.vc,v 1.22 2009-06-23 18:25:43 fwarmerdam Exp $
|
||||
# $Id: Makefile.vc,v 1.23 2015-08-19 02:31:04 bfriesen Exp $
|
||||
#
|
||||
# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
|
||||
#
|
||||
@ -87,11 +87,11 @@ tiffconf.h: tiffconf.vc.h
|
||||
copy tiffconf.vc.h tiffconf.h
|
||||
|
||||
libtiff.lib: tif_config.h tiffconf.h $(OBJ)
|
||||
$(AR) /out:libtiff.lib $(OBJ) $(LIBS)
|
||||
$(AR) /out:libtiff.lib ..\port\libport.lib $(OBJ) $(LIBS)
|
||||
|
||||
$(DLLNAME): tif_config.h tiffconf.h libtiff.def $(OBJ)
|
||||
$(LD) /debug /dll /def:libtiff.def /out:$(DLLNAME) \
|
||||
/implib:libtiff_i.lib $(OBJ) $(LIBS)
|
||||
/implib:libtiff_i.lib ..\port\libport.lib $(OBJ) $(LIBS)
|
||||
|
||||
clean:
|
||||
-del tif_config.h tiffconf.h
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_codec.c,v 1.16 2013-05-02 14:44:29 tgl Exp $ */
|
||||
/* $Id: tif_codec.c,v 1.17 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -108,8 +108,7 @@ _notConfigured(TIFF* tif)
|
||||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
char compression_code[20];
|
||||
|
||||
snprintf(compression_code, sizeof(compression_code), "%d",
|
||||
tif->tif_dir.td_compression );
|
||||
sprintf(compression_code, "%d",tif->tif_dir.td_compression );
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%s compression support is not configured",
|
||||
c ? c->name : compression_code );
|
||||
|
@ -40,6 +40,9 @@
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#undef HAVE_FLOOR
|
||||
|
||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||
#undef HAVE_FSEEKO
|
||||
|
||||
/* Define to 1 if you have the `getopt' function. */
|
||||
#undef HAVE_GETOPT
|
||||
|
||||
@ -385,6 +388,9 @@
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||
#undef _LARGEFILE_SOURCE
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#undef _LARGE_FILES
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_print.c,v 1.61 2012-12-12 22:50:18 tgl Exp $ */
|
||||
/* $Id: tif_print.c,v 1.62 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -35,7 +35,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
static void
|
||||
_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars);
|
||||
_TIFFprintAsciiBounded(FILE* fd, const char* cp, size_t max_chars);
|
||||
|
||||
static const char *photoNames[] = {
|
||||
"min-is-white", /* PHOTOMETRIC_MINISWHITE */
|
||||
@ -395,7 +395,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
for (cp = td->td_inknames;
|
||||
i > 0 && cp < td->td_inknames + td->td_inknameslen;
|
||||
cp = strchr(cp,'\0')+1, i--) {
|
||||
int max_chars =
|
||||
size_t max_chars =
|
||||
td->td_inknameslen - (cp - td->td_inknames);
|
||||
fputs(sep, fd);
|
||||
_TIFFprintAsciiBounded(fd, cp, max_chars);
|
||||
@ -679,7 +679,7 @@ _TIFFprintAscii(FILE* fd, const char* cp)
|
||||
}
|
||||
|
||||
static void
|
||||
_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars)
|
||||
_TIFFprintAsciiBounded(FILE* fd, const char* cp, size_t max_chars)
|
||||
{
|
||||
for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) {
|
||||
const char* tp;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_unix.c,v 1.26 2015-06-16 15:33:17 erouault Exp $ */
|
||||
/* $Id: tif_unix.c,v 1.27 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -55,6 +55,10 @@
|
||||
|
||||
#include "tiffiop.h"
|
||||
|
||||
|
||||
#define TIFF_IO_MAX 2147483647U
|
||||
|
||||
|
||||
typedef union fd_as_handle_union
|
||||
{
|
||||
int fd;
|
||||
@ -65,42 +69,71 @@ static tmsize_t
|
||||
_tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
|
||||
{
|
||||
fd_as_handle_union_t fdh;
|
||||
size_t size_io = (size_t) size;
|
||||
if ((tmsize_t) size_io != size)
|
||||
const size_t bytes_total = (size_t) size;
|
||||
size_t bytes_read;
|
||||
tmsize_t count = -1;
|
||||
if ((tmsize_t) bytes_total != size)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (tmsize_t) -1;
|
||||
}
|
||||
fdh.h = fd;
|
||||
return ((tmsize_t) read(fdh.fd, buf, size_io));
|
||||
for (bytes_read=0; bytes_read < bytes_total; bytes_read+=count)
|
||||
{
|
||||
char *buf_offset = (char *) buf+bytes_read;
|
||||
size_t io_size = bytes_total-bytes_read;
|
||||
if (io_size > TIFF_IO_MAX)
|
||||
io_size = TIFF_IO_MAX;
|
||||
count=read(fdh.fd, buf_offset, (TIFFIOSize_t) io_size);
|
||||
if (count <= 0)
|
||||
break;
|
||||
}
|
||||
if (count < 0)
|
||||
return (tmsize_t)-1;
|
||||
return (tmsize_t) bytes_read;
|
||||
}
|
||||
|
||||
static tmsize_t
|
||||
_tiffWriteProc(thandle_t fd, void* buf, tmsize_t size)
|
||||
{
|
||||
fd_as_handle_union_t fdh;
|
||||
size_t size_io = (size_t) size;
|
||||
if ((tmsize_t) size_io != size)
|
||||
const size_t bytes_total = (size_t) size;
|
||||
size_t bytes_written;
|
||||
tmsize_t count = -1;
|
||||
if ((tmsize_t) bytes_total != size)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (tmsize_t) -1;
|
||||
}
|
||||
fdh.h = fd;
|
||||
return ((tmsize_t) write(fdh.fd, buf, size_io));
|
||||
for (bytes_written=0; bytes_written < bytes_total; bytes_written+=count)
|
||||
{
|
||||
const char *buf_offset = (char *) buf+bytes_written;
|
||||
size_t io_size = bytes_total-bytes_written;
|
||||
if (io_size > TIFF_IO_MAX)
|
||||
io_size = TIFF_IO_MAX;
|
||||
count=write(fdh.fd, buf_offset, (TIFFIOSize_t) io_size);
|
||||
if (count <= 0)
|
||||
break;
|
||||
}
|
||||
if (count < 0)
|
||||
return (tmsize_t)-1;
|
||||
return (tmsize_t) bytes_written;
|
||||
/* return ((tmsize_t) write(fdh.fd, buf, bytes_total)); */
|
||||
}
|
||||
|
||||
static uint64
|
||||
_tiffSeekProc(thandle_t fd, uint64 off, int whence)
|
||||
{
|
||||
fd_as_handle_union_t fdh;
|
||||
off_t off_io = (off_t) off;
|
||||
_TIFF_off_t off_io = (_TIFF_off_t) off;
|
||||
if ((uint64) off_io != off)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (uint64) -1; /* this is really gross */
|
||||
}
|
||||
fdh.h = fd;
|
||||
return((uint64)lseek(fdh.fd,off_io,whence));
|
||||
return((uint64)_TIFF_lseek_f(fdh.fd,off_io,whence));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -114,10 +147,10 @@ _tiffCloseProc(thandle_t fd)
|
||||
static uint64
|
||||
_tiffSizeProc(thandle_t fd)
|
||||
{
|
||||
struct stat sb;
|
||||
_TIFF_stat_s sb;
|
||||
fd_as_handle_union_t fdh;
|
||||
fdh.h = fd;
|
||||
if (fstat(fdh.fd,&sb)<0)
|
||||
if (_TIFF_fstat_f(fdh.fd,&sb)<0)
|
||||
return(0);
|
||||
else
|
||||
return((uint64)sb.st_size);
|
||||
@ -245,7 +278,7 @@ TIFFOpenW(const wchar_t* name, const char* mode)
|
||||
|
||||
fd = _wopen(name, m, 0666);
|
||||
if (fd < 0) {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
TIFFErrorExt(0, module, "%ls: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_vms.c,v 1.12 2012-11-18 17:51:52 bfriesen Exp $ */
|
||||
/* $Id: tif_vms.c,v 1.13 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -66,7 +66,7 @@ _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
|
||||
static toff_t
|
||||
_tiffSeekProc(thandle_t fd, toff_t off, int whence)
|
||||
{
|
||||
return ((toff_t) lseek((int) fd, (off_t) off, whence));
|
||||
return ((toff_t) _TIFF_lseek_f((int) fd, (_TIFF_off_t) off, whence));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -80,8 +80,8 @@ _tiffCloseProc(thandle_t fd)
|
||||
static toff_t
|
||||
_tiffSizeProc(thandle_t fd)
|
||||
{
|
||||
struct stat sb;
|
||||
return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size);
|
||||
_TIFF_stat_s sb;
|
||||
return (toff_t) (_TIFF_fstat_f((int) fd, &sb) < 0 ? 0 : sb.st_size);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tiffiop.h,v 1.85 2015-06-25 02:28:01 bfriesen Exp $ */
|
||||
/* $Id: tiffiop.h,v 1.86 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -58,6 +58,8 @@ extern void *lfind(const void *, const void *, size_t *, size_t,
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SNPRINTF) && !defined(HAVE__SNPRINTF)
|
||||
#undef snprintf
|
||||
#define snprintf _TIFF_snprintf_f
|
||||
extern int snprintf(char* str, size_t size, const char* format, ...);
|
||||
#endif
|
||||
|
||||
@ -262,6 +264,48 @@ struct tiff {
|
||||
|
||||
#define TIFFArrayCount(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
|
||||
/*
|
||||
Support for large files.
|
||||
|
||||
Windows read/write APIs support only 'unsigned int' rather than 'size_t'.
|
||||
Windows off_t is only 32-bit, even in 64-bit builds.
|
||||
*/
|
||||
#if defined(HAVE_FSEEKO)
|
||||
/*
|
||||
Use fseeko() and ftello() if they are available since they use
|
||||
'off_t' rather than 'long'. It is wrong to use fseeko() and
|
||||
ftello() only on systems with special LFS support since some systems
|
||||
(e.g. FreeBSD) support a 64-bit off_t by default.
|
||||
*/
|
||||
#if defined(HAVE_FSEEKO)
|
||||
# define fseek(stream,offset,whence) fseeko(stream,offset,whence)
|
||||
# define ftell(stream,offset,whence) ftello(stream,offset,whence)
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__WIN32__) && \
|
||||
!(defined(_MSC_VER) && _MSC_VER < 1400)/* && \ */
|
||||
/* !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800) */
|
||||
typedef unsigned int TIFFIOSize_t;
|
||||
#define _TIFF_lseek_f(fildes,offset,whence) _lseeki64(fildes,/* __int64 */ offset,whence)
|
||||
/* #define _TIFF_tell_f(fildes) /\* __int64 *\/ _telli64(fildes) */
|
||||
#define _TIFF_fseek_f(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence)
|
||||
#define _TIFF_fstat_f(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff)
|
||||
/* #define _TIFF_ftell_f(stream) /\* __int64 *\/ _ftelli64(stream) */
|
||||
/* #define _TIFF_stat_f(path,stat_buff) _stati64(path,/\* struct _stati64 *\/ stat_buff) */
|
||||
#define _TIFF_stat_s struct _stati64
|
||||
#define _TIFF_off_t __int64
|
||||
#else
|
||||
typedef size_t TIFFIOSize_t;
|
||||
#define _TIFF_lseek_f(fildes,offset,whence) lseek(fildes,offset,whence)
|
||||
/* #define _TIFF_tell_f(fildes) (_TIFF_lseek_f(fildes,0,SEEK_CUR)) */
|
||||
#define _TIFF_fseek_f(stream,offset,whence) fseek(stream,offset,whence)
|
||||
#define _TIFF_fstat_f(fildes,stat_buff) fstat(fildes,stat_buff)
|
||||
/* #define _TIFF_ftell_f(stream) ftell(stream) */
|
||||
/* #define _TIFF_stat_f(path,stat_buff) stat(path,stat_buff) */
|
||||
#define _TIFF_stat_s struct stat
|
||||
#define _TIFF_off_t off_t
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile.vc,v 1.4 2006-03-23 14:54:02 dron Exp $
|
||||
# $Id: Makefile.vc,v 1.5 2015-08-19 02:31:04 bfriesen Exp $
|
||||
#
|
||||
# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
|
||||
#
|
||||
@ -29,6 +29,7 @@
|
||||
!INCLUDE ..\nmake.opt
|
||||
|
||||
OBJ = \
|
||||
snprintf.obj \
|
||||
strcasecmp.obj \
|
||||
getopt.obj
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: libport.h,v 1.4 2015-07-04 22:09:27 bfriesen Exp $ */
|
||||
/* $Id: libport.h,v 1.5 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Frank Warmerdam
|
||||
@ -49,6 +49,11 @@ lfind(const void *key, const void *base, size_t *nmemb, size_t size,
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_SNPRINTF)
|
||||
#undef vsnprintf
|
||||
#define vsnprintf _TIFF_vsnprintf_f
|
||||
|
||||
#undef snprintf
|
||||
#define snprintf _TIFF_snprintf_f
|
||||
int snprintf(char* str, size_t size, const char* format, ...);
|
||||
#endif
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "libport.h"
|
||||
|
||||
int vsnprintf(char* str, size_t size, const char* format, va_list ap)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: bmp2tiff.c,v 1.26 2015-06-21 01:09:09 bfriesen Exp $
|
||||
/* $Id: bmp2tiff.c,v 1.27 2015-08-19 02:31:04 bfriesen Exp $
|
||||
*
|
||||
* Project: libtiff tools
|
||||
* Purpose: Convert Windows BMP files in TIFF.
|
||||
@ -57,6 +57,7 @@
|
||||
# include "libport.h"
|
||||
#endif
|
||||
|
||||
#include "tiffiop.h"
|
||||
#include "tiffio.h"
|
||||
|
||||
#ifndef O_BINARY
|
||||
@ -234,7 +235,7 @@ main(int argc, char* argv[])
|
||||
uint32 rowsperstrip = (uint32) -1;
|
||||
uint16 photometric = PHOTOMETRIC_MINISBLACK;
|
||||
int fd = 0;
|
||||
struct stat instat;
|
||||
_TIFF_stat_s instat;
|
||||
char *outfilename = NULL, *infilename = NULL;
|
||||
TIFF *out = NULL;
|
||||
|
||||
@ -307,7 +308,7 @@ main(int argc, char* argv[])
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Read the BMPFileHeader. We need iOffBits value only */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if (lseek(fd, 10, SEEK_SET) == (off_t)-1) {
|
||||
if (_TIFF_lseek_f(fd, 10, SEEK_SET) == (_TIFF_off_t)-1) {
|
||||
TIFFError(infilename, "Failed to seek to offset");
|
||||
goto bad;
|
||||
}
|
||||
@ -319,7 +320,7 @@ main(int argc, char* argv[])
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
TIFFSwabLong(&file_hdr.iOffBits);
|
||||
#endif
|
||||
if (fstat(fd, &instat) == -1) {
|
||||
if (_TIFF_fstat_f(fd, &instat) == -1) {
|
||||
TIFFError(infilename, "Failed obtain file information");
|
||||
goto bad;
|
||||
}
|
||||
@ -329,7 +330,7 @@ main(int argc, char* argv[])
|
||||
/* Read the BMPInfoHeader. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
if (lseek(fd, BFH_SIZE, SEEK_SET) == (off_t)-1) {
|
||||
if (_TIFF_lseek_f(fd, BFH_SIZE, SEEK_SET) == (_TIFF_off_t)-1) {
|
||||
TIFFError(infilename, "Failed to seek to offset");
|
||||
goto bad;
|
||||
}
|
||||
@ -479,7 +480,7 @@ main(int argc, char* argv[])
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (lseek(fd, BFH_SIZE + info_hdr.iSize, SEEK_SET) == (off_t)-1) {
|
||||
if (_TIFF_lseek_f(fd, BFH_SIZE + info_hdr.iSize, SEEK_SET) == (_TIFF_off_t)-1) {
|
||||
TIFFError(infilename, "Failed to seek to offset");
|
||||
goto bad;
|
||||
}
|
||||
@ -613,7 +614,7 @@ main(int argc, char* argv[])
|
||||
offset = file_hdr.iOffBits+(length-row-1)*size;
|
||||
else
|
||||
offset = file_hdr.iOffBits + row * size;
|
||||
if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
|
||||
if (_TIFF_lseek_f(fd, offset, SEEK_SET) == (_TIFF_off_t)-1) {
|
||||
TIFFError(infilename,
|
||||
"scanline %lu: Seek error",
|
||||
(unsigned long) row);
|
||||
@ -681,7 +682,7 @@ main(int argc, char* argv[])
|
||||
goto bad3;
|
||||
}
|
||||
|
||||
if (lseek(fd, file_hdr.iOffBits, SEEK_SET) == (off_t)-1) {
|
||||
if (_TIFF_lseek_f(fd, file_hdr.iOffBits, SEEK_SET) == (_TIFF_off_t)-1) {
|
||||
TIFFError(infilename, "Failed to seek to offset");
|
||||
goto bad3;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: fax2ps.c,v 1.29 2015-06-21 01:09:09 bfriesen Exp $" */
|
||||
/* $Id: fax2ps.c,v 1.30 2015-08-19 02:31:04 bfriesen Exp $" */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@ -47,6 +47,7 @@
|
||||
# include "libport.h"
|
||||
#endif
|
||||
|
||||
#include "tiffiop.h"
|
||||
#include "tiffio.h"
|
||||
|
||||
float defxres = 204.; /* default x resolution (pixels/inch) */
|
||||
@ -399,7 +400,7 @@ main(int argc, char** argv)
|
||||
#endif
|
||||
while ((n = read(fileno(stdin), buf, sizeof (buf))) > 0)
|
||||
write(fileno(fd), buf, n);
|
||||
lseek(fileno(fd), 0, SEEK_SET);
|
||||
_TIFF_lseek_f(fileno(fd), 0, SEEK_SET);
|
||||
#if defined(_WIN32) && defined(USE_WIN32_FILEIO)
|
||||
tif = TIFFFdOpen(_get_osfhandle(fileno(fd)), "temp", "r");
|
||||
#else
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: raw2tiff.c,v 1.27 2015-06-21 01:09:10 bfriesen Exp $
|
||||
/* $Id: raw2tiff.c,v 1.28 2015-08-19 02:31:04 bfriesen Exp $
|
||||
*
|
||||
* Project: libtiff tools
|
||||
* Purpose: Convert raw byte sequences in TIFF images
|
||||
@ -57,6 +57,7 @@
|
||||
# include "libport.h"
|
||||
#endif
|
||||
|
||||
#include "tiffiop.h"
|
||||
#include "tiffio.h"
|
||||
|
||||
#ifndef HAVE_GETOPT
|
||||
@ -78,7 +79,7 @@ static int quality = 75; /* JPEG quality */
|
||||
static uint16 predictor = 0;
|
||||
|
||||
static void swapBytesInScanline(void *, uint32, TIFFDataType);
|
||||
static int guessSize(int, TIFFDataType, off_t, uint32, int,
|
||||
static int guessSize(int, TIFFDataType, _TIFF_off_t, uint32, int,
|
||||
uint32 *, uint32 *);
|
||||
static double correlation(void *, void *, uint32, TIFFDataType);
|
||||
static void usage(void);
|
||||
@ -89,7 +90,7 @@ main(int argc, char* argv[])
|
||||
{
|
||||
uint32 width = 0, length = 0, linebytes, bufsize;
|
||||
uint32 nbands = 1; /* number of bands in input image*/
|
||||
off_t hdr_size = 0; /* size of the header to skip */
|
||||
_TIFF_off_t hdr_size = 0; /* size of the header to skip */
|
||||
TIFFDataType dtype = TIFF_BYTE;
|
||||
int16 depth = 1; /* bytes per pixel in input image */
|
||||
int swab = 0; /* byte swapping flag */
|
||||
@ -283,14 +284,14 @@ main(int argc, char* argv[])
|
||||
}
|
||||
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip );
|
||||
|
||||
lseek(fd, hdr_size, SEEK_SET); /* Skip the file header */
|
||||
_TIFF_lseek_f(fd, hdr_size, SEEK_SET); /* Skip the file header */
|
||||
for (row = 0; row < length; row++) {
|
||||
switch(interleaving) {
|
||||
case BAND: /* band interleaved data */
|
||||
for (band = 0; band < nbands; band++) {
|
||||
if (lseek(fd,
|
||||
if (_TIFF_lseek_f(fd,
|
||||
hdr_size + (length*band+row)*linebytes,
|
||||
SEEK_SET) == (off_t)-1) {
|
||||
SEEK_SET) == (_TIFF_off_t)-1) {
|
||||
fprintf(stderr,
|
||||
"%s: %s: scanline %lu: seek error.\n",
|
||||
argv[0], argv[optind],
|
||||
@ -364,17 +365,17 @@ swapBytesInScanline(void *buf, uint32 width, TIFFDataType dtype)
|
||||
}
|
||||
|
||||
static int
|
||||
guessSize(int fd, TIFFDataType dtype, off_t hdr_size, uint32 nbands,
|
||||
guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands,
|
||||
int swab, uint32 *width, uint32 *length)
|
||||
{
|
||||
const float longt = 40.0; /* maximum possible height/width ratio */
|
||||
char *buf1, *buf2;
|
||||
struct stat filestat;
|
||||
_TIFF_stat_s filestat;
|
||||
uint32 w, h, scanlinesize, imagesize;
|
||||
uint32 depth = TIFFDataWidth(dtype);
|
||||
float cor_coef = 0, tmp;
|
||||
|
||||
if (fstat(fd, &filestat) == -1) {
|
||||
if (_TIFF_fstat_f(fd, &filestat) == -1) {
|
||||
fprintf(stderr, "Failed to obtain file size.\n");
|
||||
return -1;
|
||||
}
|
||||
@ -417,8 +418,8 @@ guessSize(int fd, TIFFDataType dtype, off_t hdr_size, uint32 nbands,
|
||||
buf2 = _TIFFmalloc(scanlinesize);
|
||||
h = imagesize / w;
|
||||
do {
|
||||
if (lseek(fd, hdr_size + (int)(h/2)*scanlinesize,
|
||||
SEEK_SET) == (off_t)-1) {
|
||||
if (_TIFF_lseek_f(fd, hdr_size + (int)(h/2)*scanlinesize,
|
||||
SEEK_SET) == (_TIFF_off_t)-1) {
|
||||
fprintf(stderr, "seek error.\n");
|
||||
fail=1;
|
||||
break;
|
||||
@ -462,7 +463,7 @@ guessSize(int fd, TIFFDataType dtype, off_t hdr_size, uint32 nbands,
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
if (filestat.st_size<(off_t)(hdr_size+(*width)*(*length)*nbands*depth)) {
|
||||
if (filestat.st_size<(_TIFF_off_t)(hdr_size+(*width)*(*length)*nbands*depth)) {
|
||||
fprintf(stderr, "Input file too small.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tiff2pdf.c,v 1.89 2015-06-21 01:09:10 bfriesen Exp $
|
||||
/* $Id: tiff2pdf.c,v 1.90 2015-08-19 02:31:04 bfriesen Exp $
|
||||
*
|
||||
* tiff2pdf - converts a TIFF image to a PDF document
|
||||
*
|
||||
@ -412,7 +412,7 @@ t2p_seekproc(thandle_t handle, uint64 offset, int whence)
|
||||
{
|
||||
T2P *t2p = (T2P*) handle;
|
||||
if (t2p->outputdisable <= 0 && t2p->outputfile)
|
||||
return fseek(t2p->outputfile, (long) offset, whence);
|
||||
return _TIFF_fseek_f(t2p->outputfile, (_TIFF_off_t) offset, whence);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tiffcrop.c,v 1.34 2015-06-21 01:09:10 bfriesen Exp $ */
|
||||
/* $Id: tiffcrop.c,v 1.35 2015-08-19 02:31:04 bfriesen Exp $ */
|
||||
|
||||
/* tiffcrop.c -- a port of tiffcp.c extended to include manipulations of
|
||||
* the image data through additional options listed below
|
||||
@ -131,7 +131,7 @@ static char tiffcrop_rev_date[] = "12-13-2010";
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETOPT
|
||||
extern int getopt(int, char**, char*);
|
||||
extern int getopt(int argc, char * const argv[], const char *optstring);
|
||||
#endif
|
||||
|
||||
#ifdef NEED_LIBPORT
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: tiffdump.c,v 1.31 2015-06-21 01:09:11 bfriesen Exp $ */
|
||||
/* $Id: tiffdump.c,v 1.32 2015-08-19 02:31:05 bfriesen Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -171,7 +171,7 @@ dump(int fd, uint64 diroff)
|
||||
uint64* visited_diroff = NULL;
|
||||
unsigned int count_visited_dir = 0;
|
||||
|
||||
lseek(fd, (off_t) 0, 0);
|
||||
_TIFF_lseek_f(fd, (_TIFF_off_t) 0, 0);
|
||||
if (read(fd, (char*) &hdr, sizeof (TIFFHeaderCommon)) != sizeof (TIFFHeaderCommon))
|
||||
ReadError("TIFF header");
|
||||
if (hdr.common.tiff_magic != TIFF_BIGENDIAN
|
||||
@ -309,11 +309,7 @@ ReadDirectory(int fd, unsigned int ix, uint64 off)
|
||||
|
||||
if (off == 0) /* no more directories */
|
||||
goto done;
|
||||
#if defined(__WIN32__) && defined(_MSC_VER)
|
||||
if (_lseeki64(fd, (__int64)off, SEEK_SET) != (__int64)off) {
|
||||
#else
|
||||
if (lseek(fd, (off_t)off, SEEK_SET) != (off_t)off) {
|
||||
#endif
|
||||
if (_TIFF_lseek_f(fd, (_TIFF_off_t)off, SEEK_SET) != (_TIFF_off_t)off) {
|
||||
Fatal("Seek error accessing TIFF directory");
|
||||
goto done;
|
||||
}
|
||||
@ -479,13 +475,8 @@ ReadDirectory(int fd, unsigned int ix, uint64 off)
|
||||
{
|
||||
datamem = _TIFFmalloc((uint32)datasize);
|
||||
if (datamem) {
|
||||
#if defined(__WIN32__) && defined(_MSC_VER)
|
||||
if (_lseeki64(fd, (__int64)dataoffset, SEEK_SET)
|
||||
!= (__int64)dataoffset)
|
||||
#else
|
||||
if (lseek(fd, (off_t)dataoffset, 0) !=
|
||||
(off_t)dataoffset)
|
||||
#endif
|
||||
if (_TIFF_lseek_f(fd, (_TIFF_off_t)dataoffset, 0) !=
|
||||
(_TIFF_off_t)dataoffset)
|
||||
{
|
||||
Error(
|
||||
"Seek error accessing tag %u value", tag);
|
||||
|
Loading…
Reference in New Issue
Block a user