ReactOS 0.4.16-dev-2617-g01a0906
tif_open.c File Reference
#include "tiffiop.h"
#include <assert.h>
#include <limits.h>
Include dependency graph for tif_open.c:

Go to the source code of this file.

Macros

#define LEADING_AREA_TO_STORE_ALLOC_SIZE   (2 * SIZEOF_SIZE_T)
 

Functions

int _tiffDummyMapProc (thandle_t fd, void **pbase, toff_t *psize)
 
void _tiffDummyUnmapProc (thandle_t fd, void *base, toff_t size)
 
int _TIFFgetMode (TIFFOpenOptions *opts, thandle_t clientdata, const char *mode, const char *module)
 
TIFFOpenOptionsTIFFOpenOptionsAlloc ()
 
void TIFFOpenOptionsFree (TIFFOpenOptions *opts)
 
void TIFFOpenOptionsSetMaxSingleMemAlloc (TIFFOpenOptions *opts, tmsize_t max_single_mem_alloc)
 
void TIFFOpenOptionsSetMaxCumulatedMemAlloc (TIFFOpenOptions *opts, tmsize_t max_cumulated_mem_alloc)
 
void TIFFOpenOptionsSetWarnAboutUnknownTags (TIFFOpenOptions *opts, int warn_about_unknown_tags)
 
void TIFFOpenOptionsSetErrorHandlerExtR (TIFFOpenOptions *opts, TIFFErrorHandlerExtR handler, void *errorhandler_user_data)
 
void TIFFOpenOptionsSetWarningHandlerExtR (TIFFOpenOptions *opts, TIFFErrorHandlerExtR handler, void *warnhandler_user_data)
 
static void _TIFFEmitErrorAboveMaxSingleMemAlloc (TIFF *tif, const char *pszFunction, tmsize_t s)
 
static void _TIFFEmitErrorAboveMaxCumulatedMemAlloc (TIFF *tif, const char *pszFunction, tmsize_t s)
 
void_TIFFmallocExt (TIFF *tif, tmsize_t s)
 
void_TIFFcallocExt (TIFF *tif, tmsize_t nmemb, tmsize_t siz)
 
void_TIFFreallocExt (TIFF *tif, void *p, tmsize_t s)
 
void _TIFFfreeExt (TIFF *tif, void *p)
 
TIFFTIFFClientOpen (const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc)
 
TIFFTIFFClientOpenExt (const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc, TIFFOpenOptions *opts)
 
const charTIFFFileName (TIFF *tif)
 
const charTIFFSetFileName (TIFF *tif, const char *name)
 
int TIFFFileno (TIFF *tif)
 
int TIFFSetFileno (TIFF *tif, int fd)
 
thandle_t TIFFClientdata (TIFF *tif)
 
thandle_t TIFFSetClientdata (TIFF *tif, thandle_t newvalue)
 
int TIFFGetMode (TIFF *tif)
 
int TIFFSetMode (TIFF *tif, int mode)
 
int TIFFIsTiled (TIFF *tif)
 
uint32_t TIFFCurrentRow (TIFF *tif)
 
tdir_t TIFFCurrentDirectory (TIFF *tif)
 
uint32_t TIFFCurrentStrip (TIFF *tif)
 
uint32_t TIFFCurrentTile (TIFF *tif)
 
int TIFFIsByteSwapped (TIFF *tif)
 
int TIFFIsUpSampled (TIFF *tif)
 
int TIFFIsMSB2LSB (TIFF *tif)
 
int TIFFIsBigEndian (TIFF *tif)
 
int TIFFIsBigTIFF (TIFF *tif)
 
TIFFReadWriteProc TIFFGetReadProc (TIFF *tif)
 
TIFFReadWriteProc TIFFGetWriteProc (TIFF *tif)
 
TIFFSeekProc TIFFGetSeekProc (TIFF *tif)
 
TIFFCloseProc TIFFGetCloseProc (TIFF *tif)
 
TIFFSizeProc TIFFGetSizeProc (TIFF *tif)
 
TIFFMapFileProc TIFFGetMapFileProc (TIFF *tif)
 
TIFFUnmapFileProc TIFFGetUnmapFileProc (TIFF *tif)
 

Macro Definition Documentation

◆ LEADING_AREA_TO_STORE_ALLOC_SIZE

#define LEADING_AREA_TO_STORE_ALLOC_SIZE   (2 * SIZEOF_SIZE_T)

Definition at line 170 of file tif_open.c.

Function Documentation

◆ _TIFFcallocExt()

void * _TIFFcallocExt ( TIFF tif,
tmsize_t  nmemb,
tmsize_t  siz 
)

calloc() version that takes into account memory-specific open options

Definition at line 201 of file tif_open.c.

202{
203 if (nmemb <= 0 || siz <= 0 || nmemb > TIFF_TMSIZE_T_MAX / siz)
204 return NULL;
205 if (tif != NULL && tif->tif_max_single_mem_alloc > 0)
206 {
207 if (nmemb * siz > tif->tif_max_single_mem_alloc)
208 {
209 _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFcallocExt",
210 nmemb * siz);
211 return NULL;
212 }
213 }
214 if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
215 {
216 const tmsize_t s = nmemb * siz;
217 if (s > tif->tif_max_cumulated_mem_alloc -
220 {
221 _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFcallocExt", s);
222 return NULL;
223 }
225 if (!ptr)
226 return NULL;
228 memcpy(ptr, &s, sizeof(s));
229 return (char *)ptr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
230 }
231 return _TIFFcalloc(nmemb, siz);
232}
#define NULL
Definition: types.h:112
GLdouble s
Definition: gl.h:2039
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
tmsize_t tif_max_single_mem_alloc
Definition: tiffiop.h:255
tmsize_t tif_cur_cumulated_mem_alloc
Definition: tiffiop.h:257
tmsize_t tif_max_cumulated_mem_alloc
Definition: tiffiop.h:256
static void _TIFFEmitErrorAboveMaxCumulatedMemAlloc(TIFF *tif, const char *pszFunction, tmsize_t s)
Definition: tif_open.c:148
static void _TIFFEmitErrorAboveMaxSingleMemAlloc(TIFF *tif, const char *pszFunction, tmsize_t s)
Definition: tif_open.c:137
#define LEADING_AREA_TO_STORE_ALLOC_SIZE
Definition: tif_open.c:170
void * _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
Definition: tif_unix.c:341
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:67
#define TIFF_TMSIZE_T_MAX
Definition: tiffio.h:68

Referenced by TIFFReadBufferSetup(), and TIFFReadDirectory().

◆ _tiffDummyMapProc()

int _tiffDummyMapProc ( thandle_t  fd,
void **  pbase,
toff_t psize 
)

Definition at line 40 of file tif_open.c.

41{
42 (void)fd;
43 (void)pbase;
44 (void)psize;
45 return (0);
46}
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
static int fd
Definition: io.c:51

Referenced by TIFFClientOpenExt(), and TIFFFdOpenExt().

◆ _tiffDummyUnmapProc()

void _tiffDummyUnmapProc ( thandle_t  fd,
void base,
toff_t  size 
)

Definition at line 48 of file tif_open.c.

49{
50 (void)fd;
51 (void)base;
52 (void)size;
53}
GLsizeiptr size
Definition: glext.h:5919

Referenced by TIFFClientOpenExt(), and TIFFFdOpenExt().

◆ _TIFFEmitErrorAboveMaxCumulatedMemAlloc()

static void _TIFFEmitErrorAboveMaxCumulatedMemAlloc ( TIFF tif,
const char pszFunction,
tmsize_t  s 
)
static

Definition at line 148 of file tif_open.c.

151{
152 TIFFErrorExtR(tif, pszFunction,
153 "Cumulated memory allocation of %" PRIu64 " + %" PRIu64
154 " bytes is beyond the %" PRIu64
155 " cumulated byte limit defined in open options",
158}
UINT64 uint64_t
Definition: types.h:77
#define PRIu64
Definition: inttypes.h:28
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_error.c:107

Referenced by _TIFFcallocExt(), _TIFFmallocExt(), and _TIFFreallocExt().

◆ _TIFFEmitErrorAboveMaxSingleMemAlloc()

static void _TIFFEmitErrorAboveMaxSingleMemAlloc ( TIFF tif,
const char pszFunction,
tmsize_t  s 
)
static

Definition at line 137 of file tif_open.c.

140{
141 TIFFErrorExtR(tif, pszFunction,
142 "Memory allocation of %" PRIu64
143 " bytes is beyond the %" PRIu64
144 " byte limit defined in open options",
146}

Referenced by _TIFFcallocExt(), _TIFFmallocExt(), and _TIFFreallocExt().

◆ _TIFFfreeExt()

void _TIFFfreeExt ( TIFF tif,
void p 
)

free() version that takes into account memory-specific open options

Definition at line 275 of file tif_open.c.

276{
277 if (p != NULL && tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
278 {
279 void *oldPtr = (char *)p - LEADING_AREA_TO_STORE_ALLOC_SIZE;
280 tmsize_t oldSize;
281 memcpy(&oldSize, oldPtr, sizeof(oldSize));
282 assert(oldSize <= tif->tif_cur_cumulated_mem_alloc);
283 tif->tif_cur_cumulated_mem_alloc -= oldSize;
284 p = oldPtr;
285 }
286 _TIFFfree(p);
287}
#define assert(_expr)
Definition: assert.h:32
GLfloat GLfloat p
Definition: glext.h:8902
void _TIFFfree(void *p)
Definition: tif_unix.c:349

Referenced by _TIFFCreateAnonField(), _TIFFFetchStrileValue(), _TIFFFillStrilesInternal(), _TIFFRewriteField(), _TIFFSetupFields(), _TIFFVSetField(), allocChoppedUpStripArrays(), EstimateStripByteCounts(), fpAcc(), fpDiff(), gtStripContig(), gtStripSeparate(), gtTileContig(), gtTileSeparate(), initCIELabConversion(), PredictorEncodeRow(), PredictorEncodeTile(), setByteArray(), setDoubleArrayOneValue(), setExtraSamples(), setupMap(), TIFFAppendToStrip(), TIFFCleanup(), TIFFClientOpenExt(), TIFFDefaultDirectory(), TIFFDefaultTransferFunction(), TIFFFetchDirectory(), TIFFFetchNormalTag(), TIFFFetchStripThing(), TIFFFillStrip(), TIFFFillTile(), TIFFFreeDirectory(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFPrintDirectory(), TIFFReadAndRealloc(), TIFFReadBufferSetup(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFReadDirEntryArrayWithLimit(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong8ArrayWithLimit(), TIFFReadDirEntryLongArray(), TIFFReadDirEntryPersampleShort(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshortArray(), TIFFRGBAImageEnd(), TIFFSetupStrips(), TIFFUnlinkDirectory(), TIFFUnRegisterCODEC(), TIFFUnsetField(), TIFFWriteBufferSetup(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedRationalDoubleArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSrationalDoubleArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLong8Array(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSlong8Array(), TIFFWriteDirectoryTagSubifd(), and TIFFWriteDirectoryTagTransferfunction().

◆ _TIFFgetMode()

int _TIFFgetMode ( TIFFOpenOptions opts,
thandle_t  clientdata,
const char mode,
const char module 
)

Definition at line 55 of file tif_open.c.

57{
58 int m = -1;
59
60 switch (mode[0])
61 {
62 case 'r':
63 m = O_RDONLY;
64 if (mode[1] == '+')
65 m = O_RDWR;
66 break;
67 case 'w':
68 case 'a':
69 m = O_RDWR | O_CREAT;
70 if (mode[0] == 'w')
71 m |= O_TRUNC;
72 break;
73 default:
74 _TIFFErrorEarly(opts, clientdata, module, "\"%s\": Bad mode", mode);
75 break;
76 }
77 return (m);
78}
#define O_CREAT
Definition: fcntl.h:43
#define O_RDONLY
Definition: fcntl.h:34
#define O_RDWR
Definition: fcntl.h:36
#define O_TRUNC
Definition: fcntl.h:44
GLenum mode
Definition: glext.h:6217
const GLfloat * m
Definition: glext.h:10848
void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata, const char *module, const char *fmt,...)
Definition: tif_error.c:80

Referenced by TIFFClientOpenExt(), TIFFOpenExt(), and TIFFOpenWExt().

◆ _TIFFmallocExt()

void * _TIFFmallocExt ( TIFF tif,
tmsize_t  s 
)

malloc() version that takes into account memory-specific open options

Definition at line 173 of file tif_open.c.

174{
175 if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
177 {
178 _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFmallocExt", s);
179 return NULL;
180 }
181 if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
182 {
183 if (s > tif->tif_max_cumulated_mem_alloc -
186 {
187 _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFmallocExt", s);
188 return NULL;
189 }
191 if (!ptr)
192 return NULL;
194 memcpy(ptr, &s, sizeof(s));
195 return (char *)ptr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
196 }
197 return _TIFFmalloc(s);
198}
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:333

Referenced by _TIFFCreateAnonField(), _TIFFReadEncodedStripAndAllocBuffer(), _TIFFReadEncodedTileAndAllocBuffer(), BuildMapBitdepth16To8(), BuildMapUaToAa(), fpAcc(), fpDiff(), initCIELabConversion(), initYCbCrConversion(), makebwmap(), makecmap(), PredictorEncodeRow(), PredictorEncodeTile(), setByteArray(), setDoubleArrayOneValue(), setupMap(), TIFFAppendToStrip(), TIFFClientOpenExt(), TIFFDefaultRefBlackWhite(), TIFFDefaultTransferFunction(), TIFFFetchNormalTag(), TIFFPrintDirectory(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong8ArrayWithLimit(), TIFFReadDirEntryLongArray(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshortArray(), TIFFRegisterCODEC(), TIFFRGBAImageBegin(), TIFFSetClientInfo(), TIFFWriteBufferSetup(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedRationalDoubleArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSrationalDoubleArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLong8Array(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSlong8Array(), TIFFWriteDirectoryTagSubifd(), and TIFFWriteDirectoryTagTransferfunction().

◆ _TIFFreallocExt()

void * _TIFFreallocExt ( TIFF tif,
void p,
tmsize_t  s 
)

realloc() version that takes into account memory-specific open options

Definition at line 235 of file tif_open.c.

236{
237 if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
239 {
240 _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFreallocExt", s);
241 return NULL;
242 }
243 if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
244 {
245 void *oldPtr = p;
246 tmsize_t oldSize = 0;
247 if (p)
248 {
249 oldPtr = (char *)p - LEADING_AREA_TO_STORE_ALLOC_SIZE;
250 memcpy(&oldSize, oldPtr, sizeof(oldSize));
251 assert(oldSize <= tif->tif_cur_cumulated_mem_alloc);
252 }
253 if (s > oldSize &&
255 (tif->tif_cur_cumulated_mem_alloc - oldSize) ||
257 {
258 _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFreallocExt",
259 s - oldSize);
260 return NULL;
261 }
262 void *newPtr =
264 if (newPtr == NULL)
265 return NULL;
266 tif->tif_cur_cumulated_mem_alloc -= oldSize;
268 memcpy(newPtr, &s, sizeof(s));
269 return (char *)newPtr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
270 }
271 return _TIFFrealloc(p, s);
272}
void * _TIFFrealloc(void *p, tmsize_t s)
Definition: tif_unix.c:351

Referenced by _TIFFCheckRealloc(), _TIFFFetchStrileValue(), _TIFFVSetField(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFReadAndRealloc(), and TIFFReadDirEntryDataAndRealloc().

◆ TIFFClientdata()

thandle_t TIFFClientdata ( TIFF tif)

Definition at line 828 of file tif_open.c.

828{ return (tif->tif_clientdata); }
thandle_t tif_clientdata
Definition: tiffiop.h:232

◆ TIFFClientOpen()

TIFF * TIFFClientOpen ( const char name,
const char mode,
thandle_t  clientdata,
TIFFReadWriteProc  readproc,
TIFFReadWriteProc  writeproc,
TIFFSeekProc  seekproc,
TIFFCloseProc  closeproc,
TIFFSizeProc  sizeproc,
TIFFMapFileProc  mapproc,
TIFFUnmapFileProc  unmapproc 
)

Definition at line 289 of file tif_open.c.

294{
295 return TIFFClientOpenExt(name, mode, clientdata, readproc, writeproc,
296 seekproc, closeproc, sizeproc, mapproc, unmapproc,
297 NULL);
298}
static BOOL readproc(HANDLE proc, LPVOID address, PVOID target, DWORD size)
Definition: env.c:217
Definition: name.c:39
TIFF * TIFFClientOpenExt(const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc, TIFFOpenOptions *opts)
Definition: tif_open.c:300

Referenced by _tiffStreamOpen(), and tiff_open_stream().

◆ TIFFClientOpenExt()

TIFF * TIFFClientOpenExt ( const char name,
const char mode,
thandle_t  clientdata,
TIFFReadWriteProc  readproc,
TIFFReadWriteProc  writeproc,
TIFFSeekProc  seekproc,
TIFFCloseProc  closeproc,
TIFFSizeProc  sizeproc,
TIFFMapFileProc  mapproc,
TIFFUnmapFileProc  unmapproc,
TIFFOpenOptions opts 
)

Definition at line 300 of file tif_open.c.

306{
307 static const char module[] = "TIFFClientOpenExt";
308 TIFF *tif;
309 int m;
310 const char *cp;
311
312 /* The following are configuration checks. They should be redundant, but
313 * should not compile to any actual code in an optimised release build
314 * anyway. If any of them fail, (makefile-based or other) configuration is
315 * not correct */
316 assert(sizeof(uint8_t) == 1);
317 assert(sizeof(int8_t) == 1);
318 assert(sizeof(uint16_t) == 2);
319 assert(sizeof(int16_t) == 2);
320 assert(sizeof(uint32_t) == 4);
321 assert(sizeof(int32_t) == 4);
322 assert(sizeof(uint64_t) == 8);
323 assert(sizeof(int64_t) == 8);
324 {
325 union
326 {
327 uint8_t a8[2];
328 uint16_t a16;
329 } n;
330 n.a8[0] = 1;
331 n.a8[1] = 0;
332 (void)n;
333#ifdef WORDS_BIGENDIAN
334 assert(n.a16 == 256);
335#else
336 assert(n.a16 == 1);
337#endif
338 }
339
340 m = _TIFFgetMode(opts, clientdata, mode, module);
341 if (m == -1)
342 goto bad2;
343 tmsize_t size_to_alloc = (tmsize_t)(sizeof(TIFF) + strlen(name) + 1);
344 if (opts && opts->max_single_mem_alloc > 0 &&
345 size_to_alloc > opts->max_single_mem_alloc)
346 {
347 _TIFFErrorEarly(opts, clientdata, module,
348 "%s: Memory allocation of %" PRIu64
349 " bytes is beyond the %" PRIu64
350 " byte limit defined in open options",
351 name, (uint64_t)size_to_alloc,
353 goto bad2;
354 }
355 if (opts && opts->max_cumulated_mem_alloc > 0 &&
356 size_to_alloc > opts->max_cumulated_mem_alloc)
357 {
358 _TIFFErrorEarly(opts, clientdata, module,
359 "%s: Memory allocation of %" PRIu64
360 " bytes is beyond the %" PRIu64
361 " cumulated byte limit defined in open options",
362 name, (uint64_t)size_to_alloc,
364 goto bad2;
365 }
366 tif = (TIFF *)_TIFFmallocExt(NULL, size_to_alloc);
367 if (tif == NULL)
368 {
369 _TIFFErrorEarly(opts, clientdata, module,
370 "%s: Out of memory (TIFF structure)", name);
371 goto bad2;
372 }
373 _TIFFmemset(tif, 0, sizeof(*tif));
374 tif->tif_name = (char *)tif + sizeof(TIFF);
375 strcpy(tif->tif_name, name);
376 tif->tif_mode = m & ~(O_CREAT | O_TRUNC);
377 tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; /* non-existent directory */
379 tif->tif_curoff = 0;
380 tif->tif_curstrip = (uint32_t)-1; /* invalid strip */
381 tif->tif_row = (uint32_t)-1; /* read/write pre-increment */
382 tif->tif_clientdata = clientdata;
383 tif->tif_readproc = readproc;
384 tif->tif_writeproc = writeproc;
385 tif->tif_seekproc = seekproc;
386 tif->tif_closeproc = closeproc;
387 tif->tif_sizeproc = sizeproc;
388 tif->tif_mapproc = mapproc ? mapproc : _tiffDummyMapProc;
389 tif->tif_unmapproc = unmapproc ? unmapproc : _tiffDummyUnmapProc;
390 if (opts)
391 {
392 tif->tif_errorhandler = opts->errorhandler;
394 tif->tif_warnhandler = opts->warnhandler;
399 }
400
401 if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc)
402 {
404 "One of the client procedures is NULL pointer.");
405 _TIFFfreeExt(NULL, tif);
406 goto bad2;
407 }
408
409 _TIFFSetDefaultCompressionState(tif); /* setup default state */
410 /*
411 * Default is to return data MSB2LSB and enable the
412 * use of memory-mapped files and strip chopping when
413 * a file is opened read-only.
414 */
416 if (m == O_RDONLY)
417 tif->tif_flags |= TIFF_MAPPED;
418
419#ifdef STRIPCHOP_DEFAULT
420 if (m == O_RDONLY || m == O_RDWR)
422#endif
423
424 /*
425 * Process library-specific flags in the open mode string.
426 * The following flags may be used to control intrinsic library
427 * behavior that may or may not be desirable (usually for
428 * compatibility with some application that claims to support
429 * TIFF but only supports some brain dead idea of what the
430 * vendor thinks TIFF is):
431 *
432 * 'l' use little-endian byte order for creating a file
433 * 'b' use big-endian byte order for creating a file
434 * 'L' read/write information using LSB2MSB bit order
435 * 'B' read/write information using MSB2LSB bit order
436 * 'H' read/write information using host bit order
437 * 'M' enable use of memory-mapped files when supported
438 * 'm' disable use of memory-mapped files
439 * 'C' enable strip chopping support when reading
440 * 'c' disable strip chopping support
441 * 'h' read TIFF header only, do not load the first IFD
442 * '4' ClassicTIFF for creating a file (default)
443 * '8' BigTIFF for creating a file
444 * 'D' enable use of deferred strip/tile offset/bytecount array loading.
445 * 'O' on-demand loading of values instead of whole array loading (implies
446 * D)
447 *
448 * The use of the 'l' and 'b' flags is strongly discouraged.
449 * These flags are provided solely because numerous vendors,
450 * typically on the PC, do not correctly support TIFF; they
451 * only support the Intel little-endian byte order. This
452 * support is not configured by default because it supports
453 * the violation of the TIFF spec that says that readers *MUST*
454 * support both byte orders. It is strongly recommended that
455 * you not use this feature except to deal with busted apps
456 * that write invalid TIFF. And even in those cases you should
457 * bang on the vendors to fix their software.
458 *
459 * The 'L', 'B', and 'H' flags are intended for applications
460 * that can optimize operations on data by using a particular
461 * bit order. By default the library returns data in MSB2LSB
462 * bit order for compatibility with older versions of this
463 * library. Returning data in the bit order of the native CPU
464 * makes the most sense but also requires applications to check
465 * the value of the FillOrder tag; something they probably do
466 * not do right now.
467 *
468 * The 'M' and 'm' flags are provided because some virtual memory
469 * systems exhibit poor behavior when large images are mapped.
470 * These options permit clients to control the use of memory-mapped
471 * files on a per-file basis.
472 *
473 * The 'C' and 'c' flags are provided because the library support
474 * for chopping up large strips into multiple smaller strips is not
475 * application-transparent and as such can cause problems. The 'c'
476 * option permits applications that only want to look at the tags,
477 * for example, to get the unadulterated TIFF tag information.
478 */
479 for (cp = mode; *cp; cp++)
480 switch (*cp)
481 {
482 case 'b':
483#ifndef WORDS_BIGENDIAN
484 if (m & O_CREAT)
485 tif->tif_flags |= TIFF_SWAB;
486#endif
487 break;
488 case 'l':
489#ifdef WORDS_BIGENDIAN
490 if ((m & O_CREAT))
491 tif->tif_flags |= TIFF_SWAB;
492#endif
493 break;
494 case 'B':
495 tif->tif_flags =
496 (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
497 break;
498 case 'L':
499 tif->tif_flags =
500 (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_LSB2MSB;
501 break;
502 case 'H':
504 "H(ost) mode is deprecated. Since "
505 "libtiff 4.5.1, it is an alias of 'B' / "
506 "FILLORDER_MSB2LSB.");
507 tif->tif_flags =
508 (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
509 break;
510 case 'M':
511 if (m == O_RDONLY)
512 tif->tif_flags |= TIFF_MAPPED;
513 break;
514 case 'm':
515 if (m == O_RDONLY)
516 tif->tif_flags &= ~TIFF_MAPPED;
517 break;
518 case 'C':
519 if (m == O_RDONLY)
521 break;
522 case 'c':
523 if (m == O_RDONLY)
524 tif->tif_flags &= ~TIFF_STRIPCHOP;
525 break;
526 case 'h':
528 break;
529 case '8':
530 if (m & O_CREAT)
531 tif->tif_flags |= TIFF_BIGTIFF;
532 break;
533 case 'D':
535 break;
536 case 'O':
537 if (m == O_RDONLY)
538 tif->tif_flags |=
540 break;
541 }
542
543#ifdef DEFER_STRILE_LOAD
544 /* Compatibility with old DEFER_STRILE_LOAD compilation flag */
545 /* Probably unneeded, since to the best of my knowledge (E. Rouault) */
546 /* GDAL was the only user of this, and will now use the new 'D' flag */
548#endif
549
550 /*
551 * Read in TIFF header.
552 */
553 if ((m & O_TRUNC) ||
554 !ReadOK(tif, &tif->tif_header, sizeof(TIFFHeaderClassic)))
555 {
556 if (tif->tif_mode == O_RDONLY)
557 {
558 TIFFErrorExtR(tif, name, "Cannot read TIFF header");
559 goto bad;
560 }
561 /*
562 * Setup header and write.
563 */
564#ifdef WORDS_BIGENDIAN
567#else
570#endif
571 TIFFHeaderUnion tif_header_swapped;
572 if (!(tif->tif_flags & TIFF_BIGTIFF))
573 {
576 tif->tif_header_size = sizeof(TIFFHeaderClassic);
577 /* Swapped copy for writing */
578 _TIFFmemcpy(&tif_header_swapped, &tif->tif_header,
579 sizeof(TIFFHeaderUnion));
580 if (tif->tif_flags & TIFF_SWAB)
581 TIFFSwabShort(&tif_header_swapped.common.tiff_version);
582 }
583 else
584 {
587 tif->tif_header.big.tiff_unused = 0;
588 tif->tif_header.big.tiff_diroff = 0;
589 tif->tif_header_size = sizeof(TIFFHeaderBig);
590 /* Swapped copy for writing */
591 _TIFFmemcpy(&tif_header_swapped, &tif->tif_header,
592 sizeof(TIFFHeaderUnion));
593 if (tif->tif_flags & TIFF_SWAB)
594 {
595 TIFFSwabShort(&tif_header_swapped.common.tiff_version);
596 TIFFSwabShort(&tif_header_swapped.big.tiff_offsetsize);
597 }
598 }
599 /*
600 * The doc for "fopen" for some STD_C_LIBs says that if you
601 * open a file for modify ("+"), then you must fseek (or
602 * fflush?) between any freads and fwrites. This is not
603 * necessary on most systems, but has been shown to be needed
604 * on Solaris.
605 */
606 TIFFSeekFile(tif, 0, SEEK_SET);
607 if (!WriteOK(tif, &tif_header_swapped,
608 (tmsize_t)(tif->tif_header_size)))
609 {
610 TIFFErrorExtR(tif, name, "Error writing TIFF header");
611 goto bad;
612 }
613 /*
614 * Setup default directory.
615 */
616 if (!TIFFDefaultDirectory(tif))
617 goto bad;
618 tif->tif_diroff = 0;
619 tif->tif_lastdiroff = 0;
621 /* tif_curdircount = 0 means 'empty file opened for writing, but no IFD
622 * written yet' */
623 tif->tif_curdircount = 0;
624 return (tif);
625 }
626
627 /*
628 * Setup the byte order handling according to the opened file for reading.
629 */
632#if MDI_SUPPORT
633 &&
636#else
638#endif
639 )
640 {
641 TIFFErrorExtR(tif, name,
642 "Not a TIFF or MDI file, bad magic number %" PRIu16
643 " (0x%" PRIx16 ")",
644#else
645 )
646 {
647 TIFFErrorExtR(tif, name,
648 "Not a TIFF file, bad magic number %" PRIu16
649 " (0x%" PRIx16 ")",
650#endif
653 goto bad;
654 }
656 {
657#ifndef WORDS_BIGENDIAN
658 tif->tif_flags |= TIFF_SWAB;
659#endif
660 }
661 else
662 {
663#ifdef WORDS_BIGENDIAN
664 tif->tif_flags |= TIFF_SWAB;
665#endif
666 }
667 if (tif->tif_flags & TIFF_SWAB)
671 {
672 TIFFErrorExtR(tif, name,
673 "Not a TIFF file, bad version number %" PRIu16
674 " (0x%" PRIx16 ")",
677 goto bad;
678 }
680 {
681 if (tif->tif_flags & TIFF_SWAB)
683 tif->tif_header_size = sizeof(TIFFHeaderClassic);
684 }
685 else
686 {
687 if (!ReadOK(tif,
688 ((uint8_t *)(&tif->tif_header) + sizeof(TIFFHeaderClassic)),
689 (sizeof(TIFFHeaderBig) - sizeof(TIFFHeaderClassic))))
690 {
691 TIFFErrorExtR(tif, name, "Cannot read TIFF header");
692 goto bad;
693 }
694 if (tif->tif_flags & TIFF_SWAB)
695 {
698 }
699 if (tif->tif_header.big.tiff_offsetsize != 8)
700 {
701 TIFFErrorExtR(tif, name,
702 "Not a TIFF file, bad BigTIFF offsetsize %" PRIu16
703 " (0x%" PRIx16 ")",
706 goto bad;
707 }
708 if (tif->tif_header.big.tiff_unused != 0)
709 {
710 TIFFErrorExtR(tif, name,
711 "Not a TIFF file, bad BigTIFF unused %" PRIu16
712 " (0x%" PRIx16 ")",
715 goto bad;
716 }
717 tif->tif_header_size = sizeof(TIFFHeaderBig);
718 tif->tif_flags |= TIFF_BIGTIFF;
719 }
720 tif->tif_flags |= TIFF_MYBUFFER;
721 tif->tif_rawcp = tif->tif_rawdata = 0;
722 tif->tif_rawdatasize = 0;
723 tif->tif_rawdataoff = 0;
724 tif->tif_rawdataloaded = 0;
725
726 switch (mode[0])
727 {
728 case 'r':
729 if (!(tif->tif_flags & TIFF_BIGTIFF))
731 else
733 /*
734 * Try to use a memory-mapped file if the client
735 * has not explicitly suppressed usage with the
736 * 'm' flag in the open mode (see above).
737 */
738 if (tif->tif_flags & TIFF_MAPPED)
739 {
740 toff_t n;
741 if (TIFFMapFileContents(tif, (void **)(&tif->tif_base), &n))
742 {
743 tif->tif_size = (tmsize_t)n;
744 assert((toff_t)tif->tif_size == n);
745 }
746 else
747 tif->tif_flags &= ~TIFF_MAPPED;
748 }
749 /*
750 * Sometimes we do not want to read the first directory (for
751 * example, it may be broken) and want to proceed to other
752 * directories. I this case we use the TIFF_HEADERONLY flag to open
753 * file and return immediately after reading TIFF header.
754 * However, the pointer to TIFFSetField() and TIFFGetField()
755 * (i.e. tif->tif_tagmethods.vsetfield and
756 * tif->tif_tagmethods.vgetfield) need to be initialized, which is
757 * done in TIFFDefaultDirectory().
758 */
759 if (tif->tif_flags & TIFF_HEADERONLY)
760 {
761 if (!TIFFDefaultDirectory(tif))
762 goto bad;
763 return (tif);
764 }
765
766 /*
767 * Setup initial directory.
768 */
769 if (TIFFReadDirectory(tif))
770 {
771 return (tif);
772 }
773 break;
774 case 'a':
775 /*
776 * New directories are automatically append
777 * to the end of the directory chain when they
778 * are written out (see TIFFWriteDirectory).
779 */
780 if (!TIFFDefaultDirectory(tif))
781 goto bad;
782 return (tif);
783 }
784bad:
785 tif->tif_mode = O_RDONLY; /* XXX avoid flush */
786 TIFFCleanup(tif);
787bad2:
788 return ((TIFF *)0);
789}
#define FALSE
Definition: types.h:117
INT32 int32_t
Definition: types.h:71
UINT32 uint32_t
Definition: types.h:75
INT16 int16_t
Definition: types.h:70
INT64 int64_t
Definition: types.h:72
#define PRIx16
Definition: inttypes.h:100
#define PRIu16
Definition: inttypes.h:83
unsigned short uint16_t
Definition: stdint.h:35
unsigned char uint8_t
Definition: stdint.h:33
signed char int8_t
Definition: stdint.h:32
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
GLdouble n
Definition: glext.h:7729
#define SEEK_SET
Definition: jmemansi.c:26
if(dx< 0)
Definition: linetemp.h:194
POINT cp
Definition: magnifier.c:59
#define uint32_t
Definition: nsiface.idl:61
strcpy
Definition: string.h:131
uint64_t tiff_diroff
Definition: tiff.h:122
uint16_t tiff_unused
Definition: tiff.h:121
uint16_t tiff_offsetsize
Definition: tiff.h:120
uint32_t tiff_diroff
Definition: tiff.h:114
uint16_t tiff_magic
Definition: tiff.h:107
uint16_t tiff_version
Definition: tiff.h:108
void * errorhandler_user_data
Definition: tiffiop.h:264
tmsize_t max_cumulated_mem_alloc
Definition: tiffiop.h:268
TIFFErrorHandlerExtR errorhandler
Definition: tiffiop.h:263
int warn_about_unknown_tags
Definition: tiffiop.h:269
TIFFErrorHandlerExtR warnhandler
Definition: tiffiop.h:265
void * warnhandler_user_data
Definition: tiffiop.h:266
tmsize_t max_single_mem_alloc
Definition: tiffiop.h:267
Definition: tiffiop.h:113
TIFFReadWriteProc tif_readproc
Definition: tiffiop.h:233
int tif_warn_about_unknown_tags
Definition: tiffiop.h:258
TIFFReadWriteProc tif_writeproc
Definition: tiffiop.h:234
tdir_t tif_curdircount
Definition: tiffiop.h:183
TIFFUnmapFileProc tif_unmapproc
Definition: tiffiop.h:230
TIFFSeekProc tif_seekproc
Definition: tiffiop.h:235
int tif_setdirectory_force_absolute
Definition: tiffiop.h:155
TIFFErrorHandlerExtR tif_errorhandler
Definition: tiffiop.h:251
tmsize_t tif_rawdataloaded
Definition: tiffiop.h:223
uint64_t tif_curoff
Definition: tiffiop.h:185
uint64_t tif_nextdiroff
Definition: tiffiop.h:151
void * tif_errorhandler_user_data
Definition: tiffiop.h:252
TIFFCloseProc tif_closeproc
Definition: tiffiop.h:236
uint64_t tif_diroff
Definition: tiffiop.h:150
char * tif_name
Definition: tiffiop.h:114
TIFFErrorHandlerExtR tif_warnhandler
Definition: tiffiop.h:253
tmsize_t tif_size
Definition: tiffiop.h:228
uint16_t tif_header_size
Definition: tiffiop.h:161
tdir_t tif_curdir
Definition: tiffiop.h:179
void * tif_warnhandler_user_data
Definition: tiffiop.h:254
uint8_t * tif_rawcp
Definition: tiffiop.h:224
TIFFMapFileProc tif_mapproc
Definition: tiffiop.h:229
uint8_t * tif_rawdata
Definition: tiffiop.h:220
TIFFHeaderUnion tif_header
Definition: tiffiop.h:160
tmsize_t tif_rawdatasize
Definition: tiffiop.h:221
tmsize_t tif_rawdataoff
Definition: tiffiop.h:222
uint32_t tif_flags
Definition: tiffiop.h:117
uint32_t tif_row
Definition: tiffiop.h:162
uint64_t tif_lastdiroff
Definition: tiffiop.h:152
uint32_t tif_curstrip
Definition: tiffiop.h:184
int tif_mode
Definition: tiffiop.h:116
TIFFSizeProc tif_sizeproc
Definition: tiffiop.h:237
uint8_t * tif_base
Definition: tiffiop.h:227
void TIFFCleanup(TIFF *tif)
Definition: tif_close.c:44
void _TIFFSetDefaultCompressionState(TIFF *tif)
Definition: tif_compress.c:142
int TIFFDefaultDirectory(TIFF *tif)
Definition: tif_dir.c:1752
int TIFFReadDirectory(TIFF *tif)
Definition: tif_dirread.c:4236
void _TIFFfreeExt(TIFF *tif, void *p)
Definition: tif_open.c:275
int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize)
Definition: tif_open.c:40
int _TIFFgetMode(TIFFOpenOptions *opts, thandle_t clientdata, const char *mode, const char *module)
Definition: tif_open.c:55
void * _TIFFmallocExt(TIFF *tif, tmsize_t s)
Definition: tif_open.c:173
void _tiffDummyUnmapProc(thandle_t fd, void *base, toff_t size)
Definition: tif_open.c:48
void TIFFSwabLong8(uint64_t *lp)
Definition: tif_swab.c:60
void TIFFSwabShort(uint16_t *wp)
Definition: tif_swab.c:33
void TIFFSwabLong(uint32_t *lp)
Definition: tif_swab.c:45
void _TIFFmemset(void *p, int v, tmsize_t c)
Definition: tif_unix.c:353
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:355
void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_warning.c:80
#define FILLORDER_LSB2MSB
Definition: tiff.h:242
#define TIFF_LITTLEENDIAN
Definition: tiff.h:52
#define MDI_LITTLEENDIAN
Definition: tiff.h:53
#define FILLORDER_MSB2LSB
Definition: tiff.h:241
#define MDI_BIGENDIAN
Definition: tiff.h:54
#define TIFF_VERSION_BIG
Definition: tiff.h:49
#define TIFF_VERSION_CLASSIC
Definition: tiff.h:48
#define TIFF_BIGENDIAN
Definition: tiff.h:51
#define HOST_BIGENDIAN
Definition: tiffconf.h:70
#define STRIPCHOP_DEFAULT
Definition: tiffconf.h:114
#define MDI_SUPPORT
Definition: tiffconf.h:129
uint64_t toff_t
Definition: tiffio.h:70
#define TIFF_NON_EXISTENT_DIR_NUMBER
Definition: tiffiop.h:64
#define TIFF_LAZYSTRILELOAD
Definition: tiffiop.h:146
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:301
#define TIFF_MYBUFFER
Definition: tiffiop.h:126
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:295
#define TIFF_HEADERONLY
Definition: tiffiop.h:133
#define TIFFMapFileContents(tif, paddr, psize)
Definition: tiffiop.h:286
#define TIFF_STRIPCHOP
Definition: tiffiop.h:132
#define TIFF_DEFERSTRILELOAD
Definition: tiffiop.h:144
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:282
#define TIFF_MAPPED
Definition: tiffiop.h:128
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:124
TIFFHeaderCommon common
Definition: tiffiop.h:107
TIFFHeaderClassic classic
Definition: tiffiop.h:108
TIFFHeaderBig big
Definition: tiffiop.h:109

Referenced by TIFFClientOpen(), and TIFFFdOpenExt().

◆ TIFFCurrentDirectory()

tdir_t TIFFCurrentDirectory ( TIFF tif)

Definition at line 869 of file tif_open.c.

869{ return (tif->tif_curdir); }

◆ TIFFCurrentRow()

uint32_t TIFFCurrentRow ( TIFF tif)

Definition at line 864 of file tif_open.c.

864{ return (tif->tif_row); }

◆ TIFFCurrentStrip()

uint32_t TIFFCurrentStrip ( TIFF tif)

Definition at line 874 of file tif_open.c.

874{ return (tif->tif_curstrip); }

◆ TIFFCurrentTile()

uint32_t TIFFCurrentTile ( TIFF tif)

Definition at line 879 of file tif_open.c.

879{ return (tif->tif_curtile); }
uint32_t tif_curtile
Definition: tiffiop.h:194

◆ TIFFFileName()

◆ TIFFFileno()

int TIFFFileno ( TIFF tif)

Definition at line 813 of file tif_open.c.

813{ return (tif->tif_fd); }
int tif_fd
Definition: tiffiop.h:115

◆ TIFFGetCloseProc()

TIFFCloseProc TIFFGetCloseProc ( TIFF tif)

Definition at line 927 of file tif_open.c.

927{ return (tif->tif_closeproc); }

◆ TIFFGetMapFileProc()

TIFFMapFileProc TIFFGetMapFileProc ( TIFF tif)

Definition at line 937 of file tif_open.c.

937{ return (tif->tif_mapproc); }

◆ TIFFGetMode()

int TIFFGetMode ( TIFF tif)

Definition at line 843 of file tif_open.c.

843{ return (tif->tif_mode); }

◆ TIFFGetReadProc()

TIFFReadWriteProc TIFFGetReadProc ( TIFF tif)

Definition at line 912 of file tif_open.c.

912{ return (tif->tif_readproc); }

◆ TIFFGetSeekProc()

TIFFSeekProc TIFFGetSeekProc ( TIFF tif)

Definition at line 922 of file tif_open.c.

922{ return (tif->tif_seekproc); }

◆ TIFFGetSizeProc()

TIFFSizeProc TIFFGetSizeProc ( TIFF tif)

Definition at line 932 of file tif_open.c.

932{ return (tif->tif_sizeproc); }

◆ TIFFGetUnmapFileProc()

TIFFUnmapFileProc TIFFGetUnmapFileProc ( TIFF tif)

Definition at line 942 of file tif_open.c.

943{
944 return (tif->tif_unmapproc);
945}

◆ TIFFGetWriteProc()

TIFFReadWriteProc TIFFGetWriteProc ( TIFF tif)

Definition at line 917 of file tif_open.c.

917{ return (tif->tif_writeproc); }

◆ TIFFIsBigEndian()

int TIFFIsBigEndian ( TIFF tif)

Definition at line 899 of file tif_open.c.

900{
902}

◆ TIFFIsBigTIFF()

int TIFFIsBigTIFF ( TIFF tif)

Definition at line 907 of file tif_open.c.

907{ return ((tif->tif_flags & TIFF_BIGTIFF) != 0); }

◆ TIFFIsByteSwapped()

int TIFFIsByteSwapped ( TIFF tif)

Definition at line 884 of file tif_open.c.

884{ return ((tif->tif_flags & TIFF_SWAB) != 0); }

Referenced by tiff_decoder_get_metadata_blocks(), and tiff_decoder_read_tile().

◆ TIFFIsMSB2LSB()

int TIFFIsMSB2LSB ( TIFF tif)

Definition at line 894 of file tif_open.c.

894{ return (isFillOrder(tif, FILLORDER_MSB2LSB)); }
#define isFillOrder(tif, o)
Definition: tiffiop.h:276

◆ TIFFIsTiled()

int TIFFIsTiled ( TIFF tif)

Definition at line 859 of file tif_open.c.

859{ return (isTiled(tif)); }
#define isTiled(tif)
Definition: tiffiop.h:274

Referenced by PickContigCase(), PickSeparateCase(), TIFFForceStrileArrayWriting(), TIFFReadFromUserBuffer(), TIFFReadRGBAStripExt(), and TIFFReadRGBATileExt().

◆ TIFFIsUpSampled()

int TIFFIsUpSampled ( TIFF tif)

Definition at line 889 of file tif_open.c.

889{ return (isUpSampled(tif)); }
#define isUpSampled(tif)
Definition: tiffiop.h:277

◆ TIFFOpenOptionsAlloc()

TIFFOpenOptions * TIFFOpenOptionsAlloc ( void  )

Definition at line 80 of file tif_open.c.

81{
82 TIFFOpenOptions *opts =
84 return opts;
85}

◆ TIFFOpenOptionsFree()

void TIFFOpenOptionsFree ( TIFFOpenOptions opts)

Definition at line 87 of file tif_open.c.

87{ _TIFFfree(opts); }

◆ TIFFOpenOptionsSetErrorHandlerExtR()

void TIFFOpenOptionsSetErrorHandlerExtR ( TIFFOpenOptions opts,
TIFFErrorHandlerExtR  handler,
void errorhandler_user_data 
)

Definition at line 121 of file tif_open.c.

124{
125 opts->errorhandler = handler;
126 opts->errorhandler_user_data = errorhandler_user_data;
127}
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7512

◆ TIFFOpenOptionsSetMaxCumulatedMemAlloc()

void TIFFOpenOptionsSetMaxCumulatedMemAlloc ( TIFFOpenOptions opts,
tmsize_t  max_cumulated_mem_alloc 
)

Define a limit in bytes for the cumulated memory allocations done by libtiff on a given TIFF handle. If max_cumulated_mem_alloc is set to 0, which is the default, no other limit that the underlying _TIFFmalloc() or TIFFOpenOptionsSetMaxSingleMemAlloc() will be applied.

Definition at line 106 of file tif_open.c.

108{
109 opts->max_cumulated_mem_alloc = max_cumulated_mem_alloc;
110}

◆ TIFFOpenOptionsSetMaxSingleMemAlloc()

void TIFFOpenOptionsSetMaxSingleMemAlloc ( TIFFOpenOptions opts,
tmsize_t  max_single_mem_alloc 
)

Define a limit in bytes for a single memory allocation done by libtiff. If max_single_mem_alloc is set to 0, which is the default, no other limit that the underlying _TIFFmalloc() or TIFFOpenOptionsSetMaxCumulatedMemAlloc() will be applied.

Definition at line 94 of file tif_open.c.

96{
97 opts->max_single_mem_alloc = max_single_mem_alloc;
98}

◆ TIFFOpenOptionsSetWarnAboutUnknownTags()

void TIFFOpenOptionsSetWarnAboutUnknownTags ( TIFFOpenOptions opts,
int  warn_about_unknown_tags 
)

Whether a warning should be emitted when encountering a unknown tag. Default is FALSE since libtiff 4.7.1

Definition at line 115 of file tif_open.c.

117{
118 opts->warn_about_unknown_tags = warn_about_unknown_tags;
119}

◆ TIFFOpenOptionsSetWarningHandlerExtR()

void TIFFOpenOptionsSetWarningHandlerExtR ( TIFFOpenOptions opts,
TIFFErrorHandlerExtR  handler,
void warnhandler_user_data 
)

Definition at line 129 of file tif_open.c.

132{
133 opts->warnhandler = handler;
134 opts->warnhandler_user_data = warnhandler_user_data;
135}

◆ TIFFSetClientdata()

thandle_t TIFFSetClientdata ( TIFF tif,
thandle_t  newvalue 
)

Definition at line 833 of file tif_open.c.

834{
836 tif->tif_clientdata = newvalue;
837 return m;
838}

◆ TIFFSetFileName()

const char * TIFFSetFileName ( TIFF tif,
const char name 
)

Definition at line 803 of file tif_open.c.

804{
805 const char *old_name = tif->tif_name;
806 tif->tif_name = (char *)name;
807 return (old_name);
808}

◆ TIFFSetFileno()

int TIFFSetFileno ( TIFF tif,
int  fd 
)

Definition at line 818 of file tif_open.c.

819{
820 int old_fd = tif->tif_fd;
821 tif->tif_fd = fd;
822 return old_fd;
823}

◆ TIFFSetMode()

int TIFFSetMode ( TIFF tif,
int  mode 
)

Definition at line 848 of file tif_open.c.

849{
850 int old_mode = tif->tif_mode;
851 tif->tif_mode = mode;
852 return (old_mode);
853}