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