1 /*
2  * Copyright (c) 1988-1997 Sam Leffler
3  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and
6  * its documentation for any purpose is hereby granted without fee, provided
7  * that (i) the above copyright notices and this permission notice appear in
8  * all copies of the software and related documentation, and (ii) the names of
9  * Sam Leffler and Silicon Graphics may not be used in any advertising or
10  * publicity relating to the software without the specific, prior written
11  * permission of Sam Leffler and Silicon Graphics.
12  *
13  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22  * OF THIS SOFTWARE.
23  */
24 
25 #ifndef _TIFFIOP_
26 #define	_TIFFIOP_
27 /*
28  * ``Library-private'' definitions.
29  */
30 
31 #include "tif_config.h"
32 
33 #ifdef HAVE_FCNTL_H
34 # include <fcntl.h>
35 #endif
36 
37 #ifndef O_RDONLY
38 #define O_RDONLY _O_RDONLY
39 #endif
40 #ifndef O_WRONLY
41 #define O_WRONLY _O_WRONLY
42 #endif
43 #ifndef O_RDWR
44 #define O_RDWR _O_RDWR
45 #endif
46 #ifndef O_CREAT
47 #define O_CREAT _O_CREAT
48 #endif
49 #ifndef O_TRUNC
50 #define O_TRUNC _O_TRUNC
51 #endif
52 
53 #ifdef HAVE_SYS_TYPES_H
54 # include <sys/types.h>
55 #endif
56 
57 #ifdef HAVE_STRING_H
58 # include <string.h>
59 #endif
60 
61 #ifdef HAVE_ASSERT_H
62 # include <assert.h>
63 #else
64 # define assert(x)
65 #endif
66 
67 #ifdef HAVE_SEARCH_H
68 # include <search.h>
69 #else
70 extern void *lfind(const void *, const void *, size_t *, size_t,
71 		   int (*)(const void *, const void *));
72 #endif
73 
74 #if !defined(__WIN32__)
75 #if !defined(HAVE_SNPRINTF) && !defined(HAVE__SNPRINTF)
76 #undef snprintf
77 #define snprintf _TIFF_snprintf_f
78 extern int snprintf(char* str, size_t size, const char* format, ...);
79 #endif
80 #endif
81 
82 #include "tiffio.h"
83 
84 #include "tif_dir.h"
85 
86 #ifndef STRIP_SIZE_DEFAULT
87 # define STRIP_SIZE_DEFAULT 8192
88 #endif
89 
90 #define    streq(a,b)      (strcmp(a,b) == 0)
91 #define    strneq(a,b,n)   (strncmp(a,b,n) == 0)
92 
93 #ifndef TRUE
94 #define	TRUE	1
95 #define	FALSE	0
96 #endif
97 
98 #define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
99 #define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
100 
101 /*
102  * Largest 32-bit unsigned integer value.
103  */
104 #define TIFF_UINT32_MAX 0xFFFFFFFFU
105 
106 /*
107  * Largest 64-bit unsigned integer value.
108  */
109 #define TIFF_UINT64_MAX (((uint64)(TIFF_UINT32_MAX)) << 32 | TIFF_UINT32_MAX)
110 
111 typedef struct client_info {
112     struct client_info *next;
113     void *data;
114     char *name;
115 } TIFFClientInfoLink;
116 
117 /*
118  * Typedefs for ``method pointers'' used internally.
119  * these are deprecated and provided only for backwards compatibility.
120  */
121 typedef unsigned char tidataval_t;    /* internal image data value type */
122 typedef tidataval_t* tidata_t;        /* reference to internal image data */
123 
124 typedef void (*TIFFVoidMethod)(TIFF*);
125 typedef int (*TIFFBoolMethod)(TIFF*);
126 typedef int (*TIFFPreMethod)(TIFF*, uint16);
127 typedef int (*TIFFCodeMethod)(TIFF* tif, uint8* buf, tmsize_t size, uint16 sample);
128 typedef int (*TIFFSeekMethod)(TIFF*, uint32);
129 typedef void (*TIFFPostMethod)(TIFF* tif, uint8* buf, tmsize_t size);
130 typedef uint32 (*TIFFStripMethod)(TIFF*, uint32);
131 typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*);
132 
133 struct tiff {
134 	char*                tif_name;         /* name of open file */
135 	int                  tif_fd;           /* open file descriptor */
136 	int                  tif_mode;         /* open mode (O_*) */
137 	uint32               tif_flags;
138 	#define TIFF_FILLORDER   0x00003U /* natural bit fill order for machine */
139 	#define TIFF_DIRTYHEADER 0x00004U /* header must be written on close */
140 	#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
141 	#define TIFF_BUFFERSETUP 0x00010U /* data buffers setup */
142 	#define TIFF_CODERSETUP  0x00020U /* encoder/decoder setup done */
143 	#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */
144 	#define TIFF_SWAB        0x00080U /* byte swap file information */
145 	#define TIFF_NOBITREV    0x00100U /* inhibit bit reversal logic */
146 	#define TIFF_MYBUFFER    0x00200U /* my raw data buffer; free on close */
147 	#define TIFF_ISTILED     0x00400U /* file is tile, not strip- based */
148 	#define TIFF_MAPPED      0x00800U /* file is mapped into memory */
149 	#define TIFF_POSTENCODE  0x01000U /* need call to postencode routine */
150 	#define TIFF_INSUBIFD    0x02000U /* currently writing a subifd */
151 	#define TIFF_UPSAMPLED   0x04000U /* library is doing data up-sampling */
152 	#define TIFF_STRIPCHOP   0x08000U /* enable strip chopping support */
153 	#define TIFF_HEADERONLY  0x10000U /* read header only, do not process the first directory */
154 	#define TIFF_NOREADRAW   0x20000U /* skip reading of raw uncompressed image data */
155 	#define TIFF_INCUSTOMIFD 0x40000U /* currently writing a custom IFD */
156 	#define TIFF_BIGTIFF     0x80000U /* read/write bigtiff */
157         #define TIFF_BUF4WRITE  0x100000U /* rawcc bytes are for writing */
158         #define TIFF_DIRTYSTRIP 0x200000U /* stripoffsets/stripbytecount dirty*/
159         #define TIFF_PERSAMPLE  0x400000U /* get/set per sample tags as arrays */
160         #define TIFF_BUFFERMMAP 0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
161         #define TIFF_DEFERSTRILELOAD 0x1000000U /* defer strip/tile offset/bytecount array loading. */
162         #define TIFF_LAZYSTRILELOAD  0x2000000U /* lazy/ondemand loading of strip/tile offset/bytecount values. Only used if TIFF_DEFERSTRILELOAD is set and in read-only mode */
163         #define TIFF_CHOPPEDUPARRAYS 0x4000000U /* set when allocChoppedUpStripArrays() has modified strip array */
164 	uint64               tif_diroff;       /* file offset of current directory */
165 	uint64               tif_nextdiroff;   /* file offset of following directory */
166 	uint64*              tif_dirlist;      /* list of offsets to already seen directories to prevent IFD looping */
167 	uint16               tif_dirlistsize;  /* number of entries in offset list */
168 	uint16               tif_dirnumber;    /* number of already seen directories */
169 	TIFFDirectory        tif_dir;          /* internal rep of current directory */
170 	TIFFDirectory        tif_customdir;    /* custom IFDs are separated from the main ones */
171 	union {
172 		TIFFHeaderCommon common;
173 		TIFFHeaderClassic classic;
174 		TIFFHeaderBig big;
175 	} tif_header;
176 	uint16               tif_header_size;  /* file's header block and its length */
177 	uint32               tif_row;          /* current scanline */
178 	uint16               tif_curdir;       /* current directory (index) */
179 	uint32               tif_curstrip;     /* current strip for read/write */
180 	uint64               tif_curoff;       /* current offset for read/write */
181 	uint64               tif_dataoff;      /* current offset for writing dir */
182 	/* SubIFD support */
183 	uint16               tif_nsubifd;      /* remaining subifds to write */
184 	uint64               tif_subifdoff;    /* offset for patching SubIFD link */
185 	/* tiling support */
186 	uint32               tif_col;          /* current column (offset by row too) */
187 	uint32               tif_curtile;      /* current tile for read/write */
188 	tmsize_t             tif_tilesize;     /* # of bytes in a tile */
189 	/* compression scheme hooks */
190 	int                  tif_decodestatus;
191 	TIFFBoolMethod       tif_fixuptags;    /* called in TIFFReadDirectory */
192 	TIFFBoolMethod       tif_setupdecode;  /* called once before predecode */
193 	TIFFPreMethod        tif_predecode;    /* pre- row/strip/tile decoding */
194 	TIFFBoolMethod       tif_setupencode;  /* called once before preencode */
195 	int                  tif_encodestatus;
196 	TIFFPreMethod        tif_preencode;    /* pre- row/strip/tile encoding */
197 	TIFFBoolMethod       tif_postencode;   /* post- row/strip/tile encoding */
198 	TIFFCodeMethod       tif_decoderow;    /* scanline decoding routine */
199 	TIFFCodeMethod       tif_encoderow;    /* scanline encoding routine */
200 	TIFFCodeMethod       tif_decodestrip;  /* strip decoding routine */
201 	TIFFCodeMethod       tif_encodestrip;  /* strip encoding routine */
202 	TIFFCodeMethod       tif_decodetile;   /* tile decoding routine */
203 	TIFFCodeMethod       tif_encodetile;   /* tile encoding routine */
204 	TIFFVoidMethod       tif_close;        /* cleanup-on-close routine */
205 	TIFFSeekMethod       tif_seek;         /* position within a strip routine */
206 	TIFFVoidMethod       tif_cleanup;      /* cleanup state routine */
207 	TIFFStripMethod      tif_defstripsize; /* calculate/constrain strip size */
208 	TIFFTileMethod       tif_deftilesize;  /* calculate/constrain tile size */
209 	uint8*               tif_data;         /* compression scheme private data */
210 	/* input/output buffering */
211 	tmsize_t             tif_scanlinesize; /* # of bytes in a scanline */
212 	tmsize_t             tif_scanlineskew; /* scanline skew for reading strips */
213 	uint8*               tif_rawdata;      /* raw data buffer */
214 	tmsize_t             tif_rawdatasize;  /* # of bytes in raw data buffer */
215         tmsize_t             tif_rawdataoff;   /* rawdata offset within strip */
216         tmsize_t             tif_rawdataloaded;/* amount of data in rawdata */
217 	uint8*               tif_rawcp;        /* current spot in raw buffer */
218 	tmsize_t             tif_rawcc;        /* bytes unread from raw buffer */
219 	/* memory-mapped file support */
220 	uint8*               tif_base;         /* base of mapped file */
221 	tmsize_t             tif_size;         /* size of mapped file region (bytes, thus tmsize_t) */
222 	TIFFMapFileProc      tif_mapproc;      /* map file method */
223 	TIFFUnmapFileProc    tif_unmapproc;    /* unmap file method */
224 	/* input/output callback methods */
225 	thandle_t            tif_clientdata;   /* callback parameter */
226 	TIFFReadWriteProc    tif_readproc;     /* read method */
227 	TIFFReadWriteProc    tif_writeproc;    /* write method */
228 	TIFFSeekProc         tif_seekproc;     /* lseek method */
229 	TIFFCloseProc        tif_closeproc;    /* close method */
230 	TIFFSizeProc         tif_sizeproc;     /* filesize method */
231 	/* post-decoding support */
232 	TIFFPostMethod       tif_postdecode;   /* post decoding routine */
233 	/* tag support */
234 	TIFFField**          tif_fields;       /* sorted table of registered tags */
235 	size_t               tif_nfields;      /* # entries in registered tag table */
236 	const TIFFField*     tif_foundfield;   /* cached pointer to already found tag */
237 	TIFFTagMethods       tif_tagmethods;   /* tag get/set/print routines */
238 	TIFFClientInfoLink*  tif_clientinfo;   /* extra client information. */
239 	/* Backward compatibility stuff. We need these two fields for
240 	 * setting up an old tag extension scheme. */
241 	TIFFFieldArray*      tif_fieldscompat;
242 	size_t               tif_nfieldscompat;
243 	void                *(*get_jpeg_mem_ptr)(thandle_t);
244 };
245 
246 #define isPseudoTag(t) (t > 0xffff)            /* is tag value normal or pseudo */
247 
248 #define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
249 #define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
250 #define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
251 #define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
252 #define TIFFReadFile(tif, buf, size) \
253 	((*(tif)->tif_readproc)((tif)->tif_clientdata,(buf),(size)))
254 #define TIFFWriteFile(tif, buf, size) \
255 	((*(tif)->tif_writeproc)((tif)->tif_clientdata,(buf),(size)))
256 #define TIFFSeekFile(tif, off, whence) \
257 	((*(tif)->tif_seekproc)((tif)->tif_clientdata,(off),(whence)))
258 #define TIFFCloseFile(tif) \
259 	((*(tif)->tif_closeproc)((tif)->tif_clientdata))
260 #define TIFFGetFileSize(tif) \
261 	((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
262 #define TIFFMapFileContents(tif, paddr, psize) \
263 	((*(tif)->tif_mapproc)((tif)->tif_clientdata,(paddr),(psize)))
264 #define TIFFUnmapFileContents(tif, addr, size) \
265 	((*(tif)->tif_unmapproc)((tif)->tif_clientdata,(addr),(size)))
266 
267 /*
268  * Default Read/Seek/Write definitions.
269  */
270 #ifndef ReadOK
271 #define ReadOK(tif, buf, size) \
272 	(TIFFReadFile((tif),(buf),(size))==(size))
273 #endif
274 #ifndef SeekOK
275 #define SeekOK(tif, off) _TIFFSeekOK(tif, off)
276 #endif
277 #ifndef WriteOK
278 #define WriteOK(tif, buf, size) \
279 	(TIFFWriteFile((tif),(buf),(size))==(size))
280 #endif
281 
282 /* NB: the uint32 casts are to silence certain ANSI-C compilers */
283 #define TIFFhowmany_32(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \
284 			   ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \
285 			   0U)
286 /* Variant of TIFFhowmany_32() that doesn't return 0 if x close to MAXUINT. */
287 /* Caution: TIFFhowmany_32_maxuint_compat(x,y)*y might overflow */
288 #define TIFFhowmany_32_maxuint_compat(x, y) \
289 			   (((uint32)(x) / (uint32)(y)) + ((((uint32)(x) % (uint32)(y)) != 0) ? 1 : 0))
290 #define TIFFhowmany8_32(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3)
291 #define TIFFroundup_32(x, y) (TIFFhowmany_32(x,y)*(y))
292 #define TIFFhowmany_64(x, y) ((((uint64)(x))+(((uint64)(y))-1))/((uint64)(y)))
293 #define TIFFhowmany8_64(x) (((x)&0x07)?((uint64)(x)>>3)+1:(uint64)(x)>>3)
294 #define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y))
295 
296 /* Safe multiply which returns zero if there is an *unsigned* integer overflow. This macro is not safe for *signed* integer types */
297 #define TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0)
298 
299 #define TIFFmax(A,B) ((A)>(B)?(A):(B))
300 #define TIFFmin(A,B) ((A)<(B)?(A):(B))
301 
302 #define TIFFArrayCount(a) (sizeof (a) / sizeof ((a)[0]))
303 
304 /*
305   Support for large files.
306 
307   Windows read/write APIs support only 'unsigned int' rather than 'size_t'.
308   Windows off_t is only 32-bit, even in 64-bit builds.
309 */
310 #if defined(HAVE_FSEEKO)
311 /*
312   Use fseeko() and ftello() if they are available since they use
313   'off_t' rather than 'long'.  It is wrong to use fseeko() and
314   ftello() only on systems with special LFS support since some systems
315   (e.g. FreeBSD) support a 64-bit off_t by default.
316 
317   For MinGW, __MSVCRT_VERSION__ must be at least 0x800 to expose these
318   interfaces. The MinGW compiler must support the requested version.  MinGW
319   does not distribute the CRT (it is supplied by Microsoft) so the correct CRT
320   must be available on the target computer in order for the program to run.
321 */
322 #if defined(HAVE_FSEEKO)
323 #  define fseek(stream,offset,whence)  fseeko(stream,offset,whence)
324 #  define ftell(stream,offset,whence)  ftello(stream,offset,whence)
325 #endif
326 #endif
327 #if defined(__WIN32__) && \
328         !(defined(_MSC_VER) && _MSC_VER < 1400) && \
329         !(defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x800)
330 typedef unsigned int TIFFIOSize_t;
331 #define _TIFF_lseek_f(fildes,offset,whence)  _lseeki64(fildes,/* __int64 */ offset,whence)
332 /* #define _TIFF_tell_f(fildes) /\* __int64 *\/ _telli64(fildes) */
333 #define _TIFF_fseek_f(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence)
334 #define _TIFF_fstat_f(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff)
335 /* #define _TIFF_ftell_f(stream) /\* __int64 *\/ _ftelli64(stream) */
336 /* #define _TIFF_stat_f(path,stat_buff) _stati64(path,/\* struct _stati64 *\/ stat_buff) */
337 #define _TIFF_stat_s struct _stati64
338 #define _TIFF_off_t __int64
339 #else
340 typedef size_t TIFFIOSize_t;
341 #define _TIFF_lseek_f(fildes,offset,whence) lseek(fildes,offset,whence)
342 /* #define _TIFF_tell_f(fildes) (_TIFF_lseek_f(fildes,0,SEEK_CUR)) */
343 #define _TIFF_fseek_f(stream,offset,whence) fseek(stream,offset,whence)
344 #define _TIFF_fstat_f(fildes,stat_buff) fstat(fildes,stat_buff)
345 /* #define _TIFF_ftell_f(stream) ftell(stream) */
346 /* #define _TIFF_stat_f(path,stat_buff) stat(path,stat_buff) */
347 #define _TIFF_stat_s struct stat
348 #define _TIFF_off_t off_t
349 #endif
350 
351 #if defined(__has_attribute) && defined(__clang__)
352 #if __has_attribute(no_sanitize)
353 #define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow")))
354 #else
355 #define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
356 #endif
357 #else
358 #define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
359 #endif
360 
361 
362 #if defined(__cplusplus)
363 extern "C" {
364 #endif
365 extern int _TIFFgetMode(const char* mode, const char* module);
366 extern int _TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s);
367 extern int _TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s);
368 extern int _TIFFNoTileEncode(TIFF*, uint8* pp, tmsize_t cc, uint16 s);
369 extern int _TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s);
370 extern int _TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s);
371 extern int _TIFFNoTileDecode(TIFF*, uint8* pp, tmsize_t cc, uint16 s);
372 extern void _TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc);
373 extern int _TIFFNoPreCode(TIFF* tif, uint16 s);
374 extern int _TIFFNoSeek(TIFF* tif, uint32 off);
375 extern void _TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc);
376 extern void _TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc);
377 extern void _TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc);
378 extern void _TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc);
379 extern int TIFFFlushData1(TIFF* tif);
380 extern int TIFFDefaultDirectory(TIFF* tif);
381 extern void _TIFFSetDefaultCompressionState(TIFF* tif);
382 extern int _TIFFRewriteField(TIFF *, uint16, TIFFDataType, tmsize_t, void *);
383 extern int TIFFSetCompressionScheme(TIFF* tif, int scheme);
384 extern int TIFFSetDefaultCompressionState(TIFF* tif);
385 extern uint32 _TIFFDefaultStripSize(TIFF* tif, uint32 s);
386 extern void _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th);
387 extern int _TIFFDataSize(TIFFDataType type);
388 
389 extern void _TIFFsetByteArray(void**, void*, uint32);
390 extern void _TIFFsetString(char**, char*);
391 extern void _TIFFsetShortArray(uint16**, uint16*, uint32);
392 extern void _TIFFsetLongArray(uint32**, uint32*, uint32);
393 extern void _TIFFsetFloatArray(float**, float*, uint32);
394 extern void _TIFFsetDoubleArray(double**, double*, uint32);
395 
396 extern void _TIFFprintAscii(FILE*, const char*);
397 extern void _TIFFprintAsciiTag(FILE*, const char*, const char*);
398 
399 extern TIFFErrorHandler _TIFFwarningHandler;
400 extern TIFFErrorHandler _TIFFerrorHandler;
401 extern TIFFErrorHandlerExt _TIFFwarningHandlerExt;
402 extern TIFFErrorHandlerExt _TIFFerrorHandlerExt;
403 
404 extern uint32 _TIFFMultiply32(TIFF*, uint32, uint32, const char*);
405 extern uint64 _TIFFMultiply64(TIFF*, uint64, uint64, const char*);
406 extern tmsize_t _TIFFMultiplySSize(TIFF*, tmsize_t, tmsize_t, const char*);
407 extern tmsize_t _TIFFCastUInt64ToSSize(TIFF*, uint64, const char*);
408 extern void* _TIFFCheckMalloc(TIFF*, tmsize_t, tmsize_t, const char*);
409 extern void* _TIFFCheckRealloc(TIFF*, void*, tmsize_t, tmsize_t, const char*);
410 
411 extern double _TIFFUInt64ToDouble(uint64);
412 extern float _TIFFUInt64ToFloat(uint64);
413 
414 extern float _TIFFClampDoubleToFloat(double);
415 
416 extern tmsize_t
417 _TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip,
418                                     void **buf, tmsize_t bufsizetoalloc,
419                                     tmsize_t size_to_read);
420 extern tmsize_t
421 _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile,
422                                     void **buf, tmsize_t bufsizetoalloc,
423                                     tmsize_t size_to_read);
424 extern tmsize_t
425 _TIFFReadTileAndAllocBuffer(TIFF* tif,
426                             void **buf, tmsize_t bufsizetoalloc,
427                             uint32 x, uint32 y, uint32 z, uint16 s);
428 extern int _TIFFSeekOK(TIFF* tif, toff_t off);
429 
430 extern int TIFFInitDumpMode(TIFF*, int);
431 #ifdef PACKBITS_SUPPORT
432 extern int TIFFInitPackBits(TIFF*, int);
433 #endif
434 #ifdef CCITT_SUPPORT
435 extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int);
436 extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int);
437 #endif
438 #ifdef THUNDER_SUPPORT
439 extern int TIFFInitThunderScan(TIFF*, int);
440 #endif
441 #ifdef NEXT_SUPPORT
442 extern int TIFFInitNeXT(TIFF*, int);
443 #endif
444 #ifdef LZW_SUPPORT
445 extern int TIFFInitLZW(TIFF*, int);
446 #endif
447 #ifdef OJPEG_SUPPORT
448 extern int TIFFInitOJPEG(TIFF*, int);
449 #endif
450 #ifdef JPEG_SUPPORT
451 extern int TIFFInitJPEG(TIFF*, int);
452 extern int TIFFJPEGIsFullStripRequired(TIFF*);
453 #endif
454 #ifdef JBIG_SUPPORT
455 extern int TIFFInitJBIG(TIFF*, int);
456 #endif
457 #ifdef ZIP_SUPPORT
458 extern int TIFFInitZIP(TIFF*, int);
459 #endif
460 #ifdef PIXARLOG_SUPPORT
461 extern int TIFFInitPixarLog(TIFF*, int);
462 #endif
463 #ifdef LOGLUV_SUPPORT
464 extern int TIFFInitSGILog(TIFF*, int);
465 #endif
466 #ifdef LZMA_SUPPORT
467 extern int TIFFInitLZMA(TIFF*, int);
468 #endif
469 #ifdef ZSTD_SUPPORT
470 extern int TIFFInitZSTD(TIFF*, int);
471 #endif
472 #ifdef WEBP_SUPPORT
473 extern int TIFFInitWebP(TIFF*, int);
474 #endif
475 #ifdef VMS
476 extern const TIFFCodec _TIFFBuiltinCODECS[];
477 #else
478 extern TIFFCodec _TIFFBuiltinCODECS[];
479 #endif
480 
481 #if defined(__cplusplus)
482 }
483 #endif
484 #endif /* _TIFFIOP_ */
485 
486 /* vim: set ts=8 sts=8 sw=8 noet: */
487 /*
488  * Local Variables:
489  * mode: c
490  * c-basic-offset: 8
491  * fill-column: 78
492  * End:
493  */
494