summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libtiff/libtiff/tif_dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libtiff/libtiff/tif_dir.c')
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_dir.c464
1 files changed, 232 insertions, 232 deletions
diff --git a/src/3rdparty/libtiff/libtiff/tif_dir.c b/src/3rdparty/libtiff/libtiff/tif_dir.c
index 347b711..a6c254f 100644
--- a/src/3rdparty/libtiff/libtiff/tif_dir.c
+++ b/src/3rdparty/libtiff/libtiff/tif_dir.c
@@ -54,21 +54,21 @@ setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size)
_TIFFmemcpy(*vpp, vp, bytes);
}
}
-void _TIFFsetByteArray(void** vpp, void* vp, uint32 n)
+void _TIFFsetByteArray(void** vpp, void* vp, uint32_t n)
{ setByteArray(vpp, vp, n, 1); }
void _TIFFsetString(char** cpp, char* cp)
{ setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); }
-static void _TIFFsetNString(char** cpp, char* cp, uint32 n)
+static void _TIFFsetNString(char** cpp, char* cp, uint32_t n)
{ setByteArray((void**) cpp, (void*) cp, n, 1); }
-void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n)
- { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); }
-void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n)
- { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); }
-static void _TIFFsetLong8Array(uint64** lpp, uint64* lp, uint32 n)
- { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64)); }
-void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n)
+void _TIFFsetShortArray(uint16_t** wpp, uint16_t* wp, uint32_t n)
+ { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16_t)); }
+void _TIFFsetLongArray(uint32_t** lpp, uint32_t* lp, uint32_t n)
+ { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32_t)); }
+static void _TIFFsetLong8Array(uint64_t** lpp, uint64_t* lp, uint32_t n)
+ { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64_t)); }
+void _TIFFsetFloatArray(float** fpp, float* fp, uint32_t n)
{ setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); }
-void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n)
+void _TIFFsetDoubleArray(double** dpp, double* dp, uint32_t n)
{ setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); }
static void
@@ -88,20 +88,20 @@ setDoubleArrayOneValue(double** vpp, double value, size_t nmemb)
* Install extra samples information.
*/
static int
-setExtraSamples(TIFF* tif, va_list ap, uint32* v)
+setExtraSamples(TIFF* tif, va_list ap, uint32_t* v)
{
/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */
#define EXTRASAMPLE_COREL_UNASSALPHA 999
- uint16* va;
- uint32 i;
+ uint16_t* va;
+ uint32_t i;
TIFFDirectory* td = &tif->tif_dir;
static const char module[] = "setExtraSamples";
- *v = (uint16) va_arg(ap, uint16_vap);
- if ((uint16) *v > td->td_samplesperpixel)
+ *v = (uint16_t) va_arg(ap, uint16_vap);
+ if ((uint16_t) *v > td->td_samplesperpixel)
return 0;
- va = va_arg(ap, uint16*);
+ va = va_arg(ap, uint16_t*);
if (*v > 0 && va == NULL) /* typically missing param */
return 0;
for (i = 0; i < *v; i++) {
@@ -130,7 +130,7 @@ setExtraSamples(TIFF* tif, va_list ap, uint32* v)
td->td_transferfunction[0] = NULL;
}
- td->td_extrasamples = (uint16) *v;
+ td->td_extrasamples = (uint16_t) *v;
_TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples);
return 1;
@@ -141,11 +141,11 @@ setExtraSamples(TIFF* tif, va_list ap, uint32* v)
* Confirm we have "samplesperpixel" ink names separated by \0. Returns
* zero if the ink names are not as expected.
*/
-static uint32
-checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
+static uint32_t
+checkInkNamesString(TIFF* tif, uint32_t slen, const char* s)
{
TIFFDirectory* td = &tif->tif_dir;
- uint16 i = td->td_samplesperpixel;
+ uint16_t i = td->td_samplesperpixel;
if (slen > 0) {
const char* ep = s+slen;
@@ -156,29 +156,29 @@ checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
goto bad;
cp++; /* skip \0 */
}
- return ((uint32)(cp-s));
+ return ((uint32_t)(cp - s));
}
bad:
TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
- "%s: Invalid InkNames value; expecting %d names, found %d",
+ "%s: Invalid InkNames value; expecting %"PRIu16" names, found %"PRIu16,
tif->tif_name,
td->td_samplesperpixel,
- td->td_samplesperpixel-i);
+ (uint16_t)(td->td_samplesperpixel-i));
return (0);
}
static int
-_TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
+_TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap)
{
static const char module[] = "_TIFFVSetField";
TIFFDirectory* td = &tif->tif_dir;
int status = 1;
- uint32 v32, i, v;
+ uint32_t v32, i, v;
double dblval;
char* s;
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
- uint32 standard_tag = tag;
+ uint32_t standard_tag = tag;
if( fip == NULL ) /* cannot happen since OkToChangeTag() already checks it */
return 0;
/*
@@ -193,16 +193,16 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
switch (standard_tag) {
case TIFFTAG_SUBFILETYPE:
- td->td_subfiletype = (uint32) va_arg(ap, uint32);
+ td->td_subfiletype = (uint32_t) va_arg(ap, uint32_t);
break;
case TIFFTAG_IMAGEWIDTH:
- td->td_imagewidth = (uint32) va_arg(ap, uint32);
+ td->td_imagewidth = (uint32_t) va_arg(ap, uint32_t);
break;
case TIFFTAG_IMAGELENGTH:
- td->td_imagelength = (uint32) va_arg(ap, uint32);
+ td->td_imagelength = (uint32_t) va_arg(ap, uint32_t);
break;
case TIFFTAG_BITSPERSAMPLE:
- td->td_bitspersample = (uint16) va_arg(ap, uint16_vap);
+ td->td_bitspersample = (uint16_t) va_arg(ap, uint16_vap);
/*
* If the data require post-decoding processing to byte-swap
* samples, set it up here. Note that since tags are required
@@ -226,14 +226,14 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
}
break;
case TIFFTAG_COMPRESSION:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
/*
* If we're changing the compression scheme, the notify the
* previous module so that it can cleanup any state it's
* setup.
*/
if (TIFFFieldSet(tif, FIELD_COMPRESSION)) {
- if ((uint32)td->td_compression == v)
+ if ((uint32_t)td->td_compression == v)
break;
(*tif->tif_cleanup)(tif);
tif->tif_flags &= ~TIFF_CODERSETUP;
@@ -242,31 +242,31 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
* Setup new compression routine state.
*/
if( (status = TIFFSetCompressionScheme(tif, v)) != 0 )
- td->td_compression = (uint16) v;
+ td->td_compression = (uint16_t) v;
else
status = 0;
break;
case TIFFTAG_PHOTOMETRIC:
- td->td_photometric = (uint16) va_arg(ap, uint16_vap);
+ td->td_photometric = (uint16_t) va_arg(ap, uint16_vap);
break;
case TIFFTAG_THRESHHOLDING:
- td->td_threshholding = (uint16) va_arg(ap, uint16_vap);
+ td->td_threshholding = (uint16_t) va_arg(ap, uint16_vap);
break;
case TIFFTAG_FILLORDER:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
goto badvalue;
- td->td_fillorder = (uint16) v;
+ td->td_fillorder = (uint16_t) v;
break;
case TIFFTAG_ORIENTATION:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
goto badvalue;
else
- td->td_orientation = (uint16) v;
+ td->td_orientation = (uint16_t) v;
break;
case TIFFTAG_SAMPLESPERPIXEL:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
if (v == 0)
goto badvalue;
if( v != td->td_samplesperpixel )
@@ -303,10 +303,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
td->td_transferfunction[0] = NULL;
}
}
- td->td_samplesperpixel = (uint16) v;
+ td->td_samplesperpixel = (uint16_t) v;
break;
case TIFFTAG_ROWSPERSTRIP:
- v32 = (uint32) va_arg(ap, uint32);
+ v32 = (uint32_t) va_arg(ap, uint32_t);
if (v32 == 0)
goto badvalue32;
td->td_rowsperstrip = v32;
@@ -316,10 +316,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
}
break;
case TIFFTAG_MINSAMPLEVALUE:
- td->td_minsamplevalue = (uint16) va_arg(ap, uint16_vap);
+ td->td_minsamplevalue = (uint16_t) va_arg(ap, uint16_vap);
break;
case TIFFTAG_MAXSAMPLEVALUE:
- td->td_maxsamplevalue = (uint16) va_arg(ap, uint16_vap);
+ td->td_maxsamplevalue = (uint16_t) va_arg(ap, uint16_vap);
break;
case TIFFTAG_SMINSAMPLEVALUE:
if (tif->tif_flags & TIFF_PERSAMPLE)
@@ -346,10 +346,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
td->td_yresolution = _TIFFClampDoubleToFloat( dblval );
break;
case TIFFTAG_PLANARCONFIG:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE)
goto badvalue;
- td->td_planarconfig = (uint16) v;
+ td->td_planarconfig = (uint16_t) v;
break;
case TIFFTAG_XPOSITION:
td->td_xposition = _TIFFClampDoubleToFloat( va_arg(ap, double) );
@@ -358,66 +358,66 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
td->td_yposition = _TIFFClampDoubleToFloat( va_arg(ap, double) );
break;
case TIFFTAG_RESOLUTIONUNIT:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
goto badvalue;
- td->td_resolutionunit = (uint16) v;
+ td->td_resolutionunit = (uint16_t) v;
break;
case TIFFTAG_PAGENUMBER:
- td->td_pagenumber[0] = (uint16) va_arg(ap, uint16_vap);
- td->td_pagenumber[1] = (uint16) va_arg(ap, uint16_vap);
+ td->td_pagenumber[0] = (uint16_t) va_arg(ap, uint16_vap);
+ td->td_pagenumber[1] = (uint16_t) va_arg(ap, uint16_vap);
break;
case TIFFTAG_HALFTONEHINTS:
- td->td_halftonehints[0] = (uint16) va_arg(ap, uint16_vap);
- td->td_halftonehints[1] = (uint16) va_arg(ap, uint16_vap);
+ td->td_halftonehints[0] = (uint16_t) va_arg(ap, uint16_vap);
+ td->td_halftonehints[1] = (uint16_t) va_arg(ap, uint16_vap);
break;
case TIFFTAG_COLORMAP:
- v32 = (uint32)(1L<<td->td_bitspersample);
- _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32);
- _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32);
- _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32);
+ v32 = (uint32_t)(1L << td->td_bitspersample);
+ _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16_t*), v32);
+ _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16_t*), v32);
+ _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16_t*), v32);
break;
case TIFFTAG_EXTRASAMPLES:
if (!setExtraSamples(tif, ap, &v))
goto badvalue;
break;
case TIFFTAG_MATTEING:
- td->td_extrasamples = (((uint16) va_arg(ap, uint16_vap)) != 0);
+ td->td_extrasamples = (((uint16_t) va_arg(ap, uint16_vap)) != 0);
if (td->td_extrasamples) {
- uint16 sv = EXTRASAMPLE_ASSOCALPHA;
+ uint16_t sv = EXTRASAMPLE_ASSOCALPHA;
_TIFFsetShortArray(&td->td_sampleinfo, &sv, 1);
}
break;
case TIFFTAG_TILEWIDTH:
- v32 = (uint32) va_arg(ap, uint32);
+ v32 = (uint32_t) va_arg(ap, uint32_t);
if (v32 % 16) {
if (tif->tif_mode != O_RDONLY)
goto badvalue32;
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
- "Nonstandard tile width %u, convert file", v32);
+ "Nonstandard tile width %"PRIu32", convert file", v32);
}
td->td_tilewidth = v32;
tif->tif_flags |= TIFF_ISTILED;
break;
case TIFFTAG_TILELENGTH:
- v32 = (uint32) va_arg(ap, uint32);
+ v32 = (uint32_t) va_arg(ap, uint32_t);
if (v32 % 16) {
if (tif->tif_mode != O_RDONLY)
goto badvalue32;
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
- "Nonstandard tile length %u, convert file", v32);
+ "Nonstandard tile length %"PRIu32", convert file", v32);
}
td->td_tilelength = v32;
tif->tif_flags |= TIFF_ISTILED;
break;
case TIFFTAG_TILEDEPTH:
- v32 = (uint32) va_arg(ap, uint32);
+ v32 = (uint32_t) va_arg(ap, uint32_t);
if (v32 == 0)
goto badvalue32;
td->td_tiledepth = v32;
break;
case TIFFTAG_DATATYPE:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
switch (v) {
case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break;
case DATATYPE_INT: v = SAMPLEFORMAT_INT; break;
@@ -425,13 +425,13 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break;
default: goto badvalue;
}
- td->td_sampleformat = (uint16) v;
+ td->td_sampleformat = (uint16_t) v;
break;
case TIFFTAG_SAMPLEFORMAT:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v)
goto badvalue;
- td->td_sampleformat = (uint16) v;
+ td->td_sampleformat = (uint16_t) v;
/* Try to fix up the SWAB function for complex data. */
if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT
@@ -445,13 +445,13 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
tif->tif_postdecode = _TIFFSwab32BitData;
break;
case TIFFTAG_IMAGEDEPTH:
- td->td_imagedepth = (uint32) va_arg(ap, uint32);
+ td->td_imagedepth = (uint32_t) va_arg(ap, uint32_t);
break;
case TIFFTAG_SUBIFD:
if ((tif->tif_flags & TIFF_INSUBIFD) == 0) {
- td->td_nsubifd = (uint16) va_arg(ap, uint16_vap);
- _TIFFsetLong8Array(&td->td_subifd, (uint64*) va_arg(ap, uint64*),
- (uint32) td->td_nsubifd);
+ td->td_nsubifd = (uint16_t) va_arg(ap, uint16_vap);
+ _TIFFsetLong8Array(&td->td_subifd, (uint64_t*) va_arg(ap, uint64_t*),
+ (uint32_t) td->td_nsubifd);
} else {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Sorry, cannot nest SubIFDs",
@@ -460,24 +460,24 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
}
break;
case TIFFTAG_YCBCRPOSITIONING:
- td->td_ycbcrpositioning = (uint16) va_arg(ap, uint16_vap);
+ td->td_ycbcrpositioning = (uint16_t) va_arg(ap, uint16_vap);
break;
case TIFFTAG_YCBCRSUBSAMPLING:
- td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, uint16_vap);
- td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, uint16_vap);
+ td->td_ycbcrsubsampling[0] = (uint16_t) va_arg(ap, uint16_vap);
+ td->td_ycbcrsubsampling[1] = (uint16_t) va_arg(ap, uint16_vap);
break;
case TIFFTAG_TRANSFERFUNCTION:
v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
for (i = 0; i < v; i++)
_TIFFsetShortArray(&td->td_transferfunction[i],
- va_arg(ap, uint16*), 1U<<td->td_bitspersample);
+ va_arg(ap, uint16_t*), 1U << td->td_bitspersample);
break;
case TIFFTAG_REFERENCEBLACKWHITE:
/* XXX should check for null range */
_TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6);
break;
case TIFFTAG_INKNAMES:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
s = va_arg(ap, char*);
v = checkInkNamesString(tif, v, s);
status = v > 0;
@@ -487,7 +487,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
}
break;
case TIFFTAG_PERSAMPLE:
- v = (uint16) va_arg(ap, uint16_vap);
+ v = (uint16_t) va_arg(ap, uint16_vap);
if( v == PERSAMPLE_MULTI )
tif->tif_flags |= TIFF_PERSAMPLE;
else
@@ -575,18 +575,18 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
if (fip->field_type == TIFF_ASCII)
{
- uint32 ma;
+ uint32_t ma;
char* mb;
if (fip->field_passcount)
{
assert(fip->field_writecount==TIFF_VARIABLE2);
- ma=(uint32)va_arg(ap,uint32);
+ ma=(uint32_t)va_arg(ap, uint32_t);
mb=(char*)va_arg(ap,char*);
}
else
{
mb=(char*)va_arg(ap,char*);
- ma=(uint32)(strlen(mb)+1);
+ ma=(uint32_t)(strlen(mb) + 1);
}
tv->count=ma;
setByteArray(&tv->value,mb,ma,1);
@@ -595,7 +595,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
{
if (fip->field_passcount) {
if (fip->field_writecount == TIFF_VARIABLE2)
- tv->count = (uint32) va_arg(ap, uint32);
+ tv->count = (uint32_t) va_arg(ap, uint32_t);
else
tv->count = (int) va_arg(ap, int);
} else if (fip->field_writecount == TIFF_VARIABLE
@@ -632,9 +632,9 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
handled this way ... likely best if we move it into
the directory structure with an explicit field in
libtiff 4.1 and assign it a FIELD_ value */
- uint16 v2[2];
- v2[0] = (uint16)va_arg(ap, int);
- v2[1] = (uint16)va_arg(ap, int);
+ uint16_t v2[2];
+ v2[0] = (uint16_t)va_arg(ap, int);
+ v2[1] = (uint16_t)va_arg(ap, int);
_TIFFmemcpy(tv->value, &v2, 4);
}
@@ -654,51 +654,51 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
case TIFF_BYTE:
case TIFF_UNDEFINED:
{
- uint8 v2 = (uint8)va_arg(ap, int);
+ uint8_t v2 = (uint8_t)va_arg(ap, int);
_TIFFmemcpy(val, &v2, tv_size);
}
break;
case TIFF_SBYTE:
{
- int8 v2 = (int8)va_arg(ap, int);
+ int8_t v2 = (int8_t)va_arg(ap, int);
_TIFFmemcpy(val, &v2, tv_size);
}
break;
case TIFF_SHORT:
{
- uint16 v2 = (uint16)va_arg(ap, int);
+ uint16_t v2 = (uint16_t)va_arg(ap, int);
_TIFFmemcpy(val, &v2, tv_size);
}
break;
case TIFF_SSHORT:
{
- int16 v2 = (int16)va_arg(ap, int);
+ int16_t v2 = (int16_t)va_arg(ap, int);
_TIFFmemcpy(val, &v2, tv_size);
}
break;
case TIFF_LONG:
case TIFF_IFD:
{
- uint32 v2 = va_arg(ap, uint32);
+ uint32_t v2 = va_arg(ap, uint32_t);
_TIFFmemcpy(val, &v2, tv_size);
}
break;
case TIFF_SLONG:
{
- int32 v2 = va_arg(ap, int32);
+ int32_t v2 = va_arg(ap, int32_t);
_TIFFmemcpy(val, &v2, tv_size);
}
break;
case TIFF_LONG8:
case TIFF_IFD8:
{
- uint64 v2 = va_arg(ap, uint64);
+ uint64_t v2 = va_arg(ap, uint64_t);
_TIFFmemcpy(val, &v2, tv_size);
}
break;
case TIFF_SLONG8:
{
- int64 v2 = va_arg(ap, int64);
+ int64_t v2 = va_arg(ap, int64_t);
_TIFFmemcpy(val, &v2, tv_size);
}
break;
@@ -755,7 +755,7 @@ badvalue:
{
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
TIFFErrorExt(tif->tif_clientdata, module,
- "%s: Bad value %u for \"%s\" tag",
+ "%s: Bad value %"PRIu32" for \"%s\" tag",
tif->tif_name, v,
fip2 ? fip2->field_name : "Unknown");
va_end(ap);
@@ -765,7 +765,7 @@ badvalue32:
{
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
TIFFErrorExt(tif->tif_clientdata, module,
- "%s: Bad value %u for \"%s\" tag",
+ "%s: Bad value %"PRIu32" for \"%s\" tag",
tif->tif_name, v32,
fip2 ? fip2->field_name : "Unknown");
va_end(ap);
@@ -793,11 +793,11 @@ badvaluedouble:
* on the format of the data that is written.
*/
static int
-OkToChangeTag(TIFF* tif, uint32 tag)
+OkToChangeTag(TIFF* tif, uint32_t tag)
{
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
if (!fip) { /* unknown tag */
- TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u",
+ TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %"PRIu32,
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
return (0);
}
@@ -825,7 +825,7 @@ OkToChangeTag(TIFF* tif, uint32 tag)
* updated.
*/
int
-TIFFSetField(TIFF* tif, uint32 tag, ...)
+TIFFSetField(TIFF* tif, uint32_t tag, ...)
{
va_list ap;
int status;
@@ -840,7 +840,7 @@ TIFFSetField(TIFF* tif, uint32 tag, ...)
* Clear the contents of the field in the internal structure.
*/
int
-TIFFUnsetField(TIFF* tif, uint32 tag)
+TIFFUnsetField(TIFF* tif, uint32_t tag)
{
const TIFFField *fip = TIFFFieldWithTag(tif, tag);
TIFFDirectory* td = &tif->tif_dir;
@@ -884,18 +884,18 @@ TIFFUnsetField(TIFF* tif, uint32 tag)
* top of the library.
*/
int
-TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
+TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap)
{
return OkToChangeTag(tif, tag) ?
(*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0;
}
static int
-_TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
+_TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap)
{
TIFFDirectory* td = &tif->tif_dir;
int ret_val = 1;
- uint32 standard_tag = tag;
+ uint32_t standard_tag = tag;
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */
return 0;
@@ -914,13 +914,13 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
{
int i;
for (i = 0; i < td->td_customValueCount; i++) {
- uint16 val;
+ uint16_t val;
TIFFTagValue *tv = td->td_customValues + i;
if (tv->info->field_tag != standard_tag)
continue;
if( tv->value == NULL )
return 0;
- val = *(uint16 *)tv->value;
+ val = *(uint16_t *)tv->value;
/* Truncate to SamplesPerPixel, since the */
/* setting code for INKNAMES assume that there are SamplesPerPixel */
/* inknames. */
@@ -928,11 +928,11 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
if( val > td->td_samplesperpixel )
{
TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField",
- "Truncating NumberOfInks from %u to %u",
+ "Truncating NumberOfInks from %u to %"PRIu16,
val, td->td_samplesperpixel);
val = td->td_samplesperpixel;
}
- *va_arg(ap, uint16*) = val;
+ *va_arg(ap, uint16_t*) = val;
return 1;
}
return 0;
@@ -940,43 +940,43 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
switch (standard_tag) {
case TIFFTAG_SUBFILETYPE:
- *va_arg(ap, uint32*) = td->td_subfiletype;
+ *va_arg(ap, uint32_t*) = td->td_subfiletype;
break;
case TIFFTAG_IMAGEWIDTH:
- *va_arg(ap, uint32*) = td->td_imagewidth;
+ *va_arg(ap, uint32_t*) = td->td_imagewidth;
break;
case TIFFTAG_IMAGELENGTH:
- *va_arg(ap, uint32*) = td->td_imagelength;
+ *va_arg(ap, uint32_t*) = td->td_imagelength;
break;
case TIFFTAG_BITSPERSAMPLE:
- *va_arg(ap, uint16*) = td->td_bitspersample;
+ *va_arg(ap, uint16_t*) = td->td_bitspersample;
break;
case TIFFTAG_COMPRESSION:
- *va_arg(ap, uint16*) = td->td_compression;
+ *va_arg(ap, uint16_t*) = td->td_compression;
break;
case TIFFTAG_PHOTOMETRIC:
- *va_arg(ap, uint16*) = td->td_photometric;
+ *va_arg(ap, uint16_t*) = td->td_photometric;
break;
case TIFFTAG_THRESHHOLDING:
- *va_arg(ap, uint16*) = td->td_threshholding;
+ *va_arg(ap, uint16_t*) = td->td_threshholding;
break;
case TIFFTAG_FILLORDER:
- *va_arg(ap, uint16*) = td->td_fillorder;
+ *va_arg(ap, uint16_t*) = td->td_fillorder;
break;
case TIFFTAG_ORIENTATION:
- *va_arg(ap, uint16*) = td->td_orientation;
+ *va_arg(ap, uint16_t*) = td->td_orientation;
break;
case TIFFTAG_SAMPLESPERPIXEL:
- *va_arg(ap, uint16*) = td->td_samplesperpixel;
+ *va_arg(ap, uint16_t*) = td->td_samplesperpixel;
break;
case TIFFTAG_ROWSPERSTRIP:
- *va_arg(ap, uint32*) = td->td_rowsperstrip;
+ *va_arg(ap, uint32_t*) = td->td_rowsperstrip;
break;
case TIFFTAG_MINSAMPLEVALUE:
- *va_arg(ap, uint16*) = td->td_minsamplevalue;
+ *va_arg(ap, uint16_t*) = td->td_minsamplevalue;
break;
case TIFFTAG_MAXSAMPLEVALUE:
- *va_arg(ap, uint16*) = td->td_maxsamplevalue;
+ *va_arg(ap, uint16_t*) = td->td_maxsamplevalue;
break;
case TIFFTAG_SMINSAMPLEVALUE:
if (tif->tif_flags & TIFF_PERSAMPLE)
@@ -984,7 +984,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
else
{
/* libtiff historically treats this as a single value. */
- uint16 i;
+ uint16_t i;
double v = td->td_sminsamplevalue[0];
for (i=1; i < td->td_samplesperpixel; ++i)
if( td->td_sminsamplevalue[i] < v )
@@ -998,7 +998,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
else
{
/* libtiff historically treats this as a single value. */
- uint16 i;
+ uint16_t i;
double v = td->td_smaxsamplevalue[0];
for (i=1; i < td->td_samplesperpixel; ++i)
if( td->td_smaxsamplevalue[i] > v )
@@ -1013,7 +1013,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
*va_arg(ap, float*) = td->td_yresolution;
break;
case TIFFTAG_PLANARCONFIG:
- *va_arg(ap, uint16*) = td->td_planarconfig;
+ *va_arg(ap, uint16_t*) = td->td_planarconfig;
break;
case TIFFTAG_XPOSITION:
*va_arg(ap, float*) = td->td_xposition;
@@ -1022,90 +1022,90 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
*va_arg(ap, float*) = td->td_yposition;
break;
case TIFFTAG_RESOLUTIONUNIT:
- *va_arg(ap, uint16*) = td->td_resolutionunit;
+ *va_arg(ap, uint16_t*) = td->td_resolutionunit;
break;
case TIFFTAG_PAGENUMBER:
- *va_arg(ap, uint16*) = td->td_pagenumber[0];
- *va_arg(ap, uint16*) = td->td_pagenumber[1];
+ *va_arg(ap, uint16_t*) = td->td_pagenumber[0];
+ *va_arg(ap, uint16_t*) = td->td_pagenumber[1];
break;
case TIFFTAG_HALFTONEHINTS:
- *va_arg(ap, uint16*) = td->td_halftonehints[0];
- *va_arg(ap, uint16*) = td->td_halftonehints[1];
+ *va_arg(ap, uint16_t*) = td->td_halftonehints[0];
+ *va_arg(ap, uint16_t*) = td->td_halftonehints[1];
break;
case TIFFTAG_COLORMAP:
- *va_arg(ap, const uint16**) = td->td_colormap[0];
- *va_arg(ap, const uint16**) = td->td_colormap[1];
- *va_arg(ap, const uint16**) = td->td_colormap[2];
+ *va_arg(ap, const uint16_t**) = td->td_colormap[0];
+ *va_arg(ap, const uint16_t**) = td->td_colormap[1];
+ *va_arg(ap, const uint16_t**) = td->td_colormap[2];
break;
case TIFFTAG_STRIPOFFSETS:
case TIFFTAG_TILEOFFSETS:
_TIFFFillStriles( tif );
- *va_arg(ap, const uint64**) = td->td_stripoffset_p;
+ *va_arg(ap, const uint64_t**) = td->td_stripoffset_p;
break;
case TIFFTAG_STRIPBYTECOUNTS:
case TIFFTAG_TILEBYTECOUNTS:
_TIFFFillStriles( tif );
- *va_arg(ap, const uint64**) = td->td_stripbytecount_p;
+ *va_arg(ap, const uint64_t**) = td->td_stripbytecount_p;
break;
case TIFFTAG_MATTEING:
- *va_arg(ap, uint16*) =
+ *va_arg(ap, uint16_t*) =
(td->td_extrasamples == 1 &&
td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
break;
case TIFFTAG_EXTRASAMPLES:
- *va_arg(ap, uint16*) = td->td_extrasamples;
- *va_arg(ap, const uint16**) = td->td_sampleinfo;
+ *va_arg(ap, uint16_t*) = td->td_extrasamples;
+ *va_arg(ap, const uint16_t**) = td->td_sampleinfo;
break;
case TIFFTAG_TILEWIDTH:
- *va_arg(ap, uint32*) = td->td_tilewidth;
+ *va_arg(ap, uint32_t*) = td->td_tilewidth;
break;
case TIFFTAG_TILELENGTH:
- *va_arg(ap, uint32*) = td->td_tilelength;
+ *va_arg(ap, uint32_t*) = td->td_tilelength;
break;
case TIFFTAG_TILEDEPTH:
- *va_arg(ap, uint32*) = td->td_tiledepth;
+ *va_arg(ap, uint32_t*) = td->td_tiledepth;
break;
case TIFFTAG_DATATYPE:
switch (td->td_sampleformat) {
case SAMPLEFORMAT_UINT:
- *va_arg(ap, uint16*) = DATATYPE_UINT;
+ *va_arg(ap, uint16_t*) = DATATYPE_UINT;
break;
case SAMPLEFORMAT_INT:
- *va_arg(ap, uint16*) = DATATYPE_INT;
+ *va_arg(ap, uint16_t*) = DATATYPE_INT;
break;
case SAMPLEFORMAT_IEEEFP:
- *va_arg(ap, uint16*) = DATATYPE_IEEEFP;
+ *va_arg(ap, uint16_t*) = DATATYPE_IEEEFP;
break;
case SAMPLEFORMAT_VOID:
- *va_arg(ap, uint16*) = DATATYPE_VOID;
+ *va_arg(ap, uint16_t*) = DATATYPE_VOID;
break;
}
break;
case TIFFTAG_SAMPLEFORMAT:
- *va_arg(ap, uint16*) = td->td_sampleformat;
+ *va_arg(ap, uint16_t*) = td->td_sampleformat;
break;
case TIFFTAG_IMAGEDEPTH:
- *va_arg(ap, uint32*) = td->td_imagedepth;
+ *va_arg(ap, uint32_t*) = td->td_imagedepth;
break;
case TIFFTAG_SUBIFD:
- *va_arg(ap, uint16*) = td->td_nsubifd;
- *va_arg(ap, const uint64**) = td->td_subifd;
+ *va_arg(ap, uint16_t*) = td->td_nsubifd;
+ *va_arg(ap, const uint64_t**) = td->td_subifd;
break;
case TIFFTAG_YCBCRPOSITIONING:
- *va_arg(ap, uint16*) = td->td_ycbcrpositioning;
+ *va_arg(ap, uint16_t*) = td->td_ycbcrpositioning;
break;
case TIFFTAG_YCBCRSUBSAMPLING:
- *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0];
- *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1];
+ *va_arg(ap, uint16_t*) = td->td_ycbcrsubsampling[0];
+ *va_arg(ap, uint16_t*) = td->td_ycbcrsubsampling[1];
break;
case TIFFTAG_TRANSFERFUNCTION:
- *va_arg(ap, const uint16**) = td->td_transferfunction[0];
+ *va_arg(ap, const uint16_t**) = td->td_transferfunction[0];
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
- *va_arg(ap, const uint16**) = td->td_transferfunction[1];
- *va_arg(ap, const uint16**) = td->td_transferfunction[2];
+ *va_arg(ap, const uint16_t**) = td->td_transferfunction[1];
+ *va_arg(ap, const uint16_t**) = td->td_transferfunction[2];
} else {
- *va_arg(ap, const uint16**) = NULL;
- *va_arg(ap, const uint16**) = NULL;
+ *va_arg(ap, const uint16_t**) = NULL;
+ *va_arg(ap, const uint16_t**) = NULL;
}
break;
case TIFFTAG_REFERENCEBLACKWHITE:
@@ -1151,9 +1151,9 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
if (fip->field_passcount) {
if (fip->field_readcount == TIFF_VARIABLE2)
- *va_arg(ap, uint32*) = (uint32)tv->count;
+ *va_arg(ap, uint32_t*) = (uint32_t)tv->count;
else /* Assume TIFF_VARIABLE */
- *va_arg(ap, uint16*) = (uint16)tv->count;
+ *va_arg(ap, uint16_t*) = (uint16_t)tv->count;
*va_arg(ap, const void **) = tv->value;
ret_val = 1;
} else if (fip->field_tag == TIFFTAG_DOTRANGE
@@ -1162,8 +1162,8 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
handled this way ... likely best if we move it into
the directory structure with an explicit field in
libtiff 4.1 and assign it a FIELD_ value */
- *va_arg(ap, uint16*) = ((uint16 *)tv->value)[0];
- *va_arg(ap, uint16*) = ((uint16 *)tv->value)[1];
+ *va_arg(ap, uint16_t*) = ((uint16_t *)tv->value)[0];
+ *va_arg(ap, uint16_t*) = ((uint16_t *)tv->value)[1];
ret_val = 1;
} else {
if (fip->field_type == TIFF_ASCII
@@ -1179,45 +1179,45 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
switch (fip->field_type) {
case TIFF_BYTE:
case TIFF_UNDEFINED:
- *va_arg(ap, uint8*) =
- *(uint8 *)val;
+ *va_arg(ap, uint8_t*) =
+ *(uint8_t *)val;
ret_val = 1;
break;
case TIFF_SBYTE:
- *va_arg(ap, int8*) =
- *(int8 *)val;
+ *va_arg(ap, int8_t*) =
+ *(int8_t *)val;
ret_val = 1;
break;
case TIFF_SHORT:
- *va_arg(ap, uint16*) =
- *(uint16 *)val;
+ *va_arg(ap, uint16_t*) =
+ *(uint16_t *)val;
ret_val = 1;
break;
case TIFF_SSHORT:
- *va_arg(ap, int16*) =
- *(int16 *)val;
+ *va_arg(ap, int16_t*) =
+ *(int16_t *)val;
ret_val = 1;
break;
case TIFF_LONG:
case TIFF_IFD:
- *va_arg(ap, uint32*) =
- *(uint32 *)val;
+ *va_arg(ap, uint32_t*) =
+ *(uint32_t *)val;
ret_val = 1;
break;
case TIFF_SLONG:
- *va_arg(ap, int32*) =
- *(int32 *)val;
+ *va_arg(ap, int32_t*) =
+ *(int32_t *)val;
ret_val = 1;
break;
case TIFF_LONG8:
case TIFF_IFD8:
- *va_arg(ap, uint64*) =
- *(uint64 *)val;
+ *va_arg(ap, uint64_t*) =
+ *(uint64_t *)val;
ret_val = 1;
break;
case TIFF_SLONG8:
- *va_arg(ap, int64*) =
- *(int64 *)val;
+ *va_arg(ap, int64_t*) =
+ *(int64_t *)val;
ret_val = 1;
break;
case TIFF_RATIONAL:
@@ -1267,7 +1267,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
* internal directory structure.
*/
int
-TIFFGetField(TIFF* tif, uint32 tag, ...)
+TIFFGetField(TIFF* tif, uint32_t tag, ...)
{
int status;
va_list ap;
@@ -1285,7 +1285,7 @@ TIFFGetField(TIFF* tif, uint32 tag, ...)
* top of the library.
*/
int
-TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
+TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap)
{
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ?
@@ -1368,8 +1368,8 @@ TIFFCreateDirectory(TIFF* tif)
tif->tif_diroff = 0;
tif->tif_nextdiroff = 0;
tif->tif_curoff = 0;
- tif->tif_row = (uint32) -1;
- tif->tif_curstrip = (uint32) -1;
+ tif->tif_row = (uint32_t) -1;
+ tif->tif_curstrip = (uint32_t) -1;
return 0;
}
@@ -1381,7 +1381,7 @@ TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray)
/*
* Reset the field definitions to match the application provided list.
- * Hopefully TIFFDefaultDirectory() won't have done anything irreversable
+ * Hopefully TIFFDefaultDirectory() won't have done anything irreversible
* based on it's assumption this is an image directory.
*/
_TIFFSetupFields(tif, infoarray);
@@ -1389,8 +1389,8 @@ TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray)
tif->tif_diroff = 0;
tif->tif_nextdiroff = 0;
tif->tif_curoff = 0;
- tif->tif_row = (uint32) -1;
- tif->tif_curstrip = (uint32) -1;
+ tif->tif_row = (uint32_t) -1;
+ tif->tif_curstrip = (uint32_t) -1;
return 0;
}
@@ -1432,7 +1432,7 @@ TIFFDefaultDirectory(TIFF* tif)
td->td_threshholding = THRESHHOLD_BILEVEL;
td->td_orientation = ORIENTATION_TOPLEFT;
td->td_samplesperpixel = 1;
- td->td_rowsperstrip = (uint32) -1;
+ td->td_rowsperstrip = (uint32_t) -1;
td->td_tilewidth = 0;
td->td_tilelength = 0;
td->td_tiledepth = 1;
@@ -1456,7 +1456,7 @@ TIFFDefaultDirectory(TIFF* tif)
* but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054)
*/
if (tif->tif_nfieldscompat > 0) {
- uint32 i;
+ uint32_t i;
for (i = 0; i < tif->tif_nfieldscompat; i++) {
if (tif->tif_fieldscompat[i].allocated_size)
@@ -1490,38 +1490,38 @@ TIFFDefaultDirectory(TIFF* tif)
}
static int
-TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
+TIFFAdvanceDirectory(TIFF* tif, uint64_t* nextdir, uint64_t* off)
{
static const char module[] = "TIFFAdvanceDirectory";
if (isMapped(tif))
{
- uint64 poff=*nextdir;
+ uint64_t poff=*nextdir;
if (!(tif->tif_flags&TIFF_BIGTIFF))
{
tmsize_t poffa,poffb,poffc,poffd;
- uint16 dircount;
- uint32 nextdir32;
+ uint16_t dircount;
+ uint32_t nextdir32;
poffa=(tmsize_t)poff;
- poffb=poffa+sizeof(uint16);
- if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint16))||(poffb>tif->tif_size))
+ poffb=poffa+sizeof(uint16_t);
+ if (((uint64_t)poffa != poff) || (poffb < poffa) || (poffb < (tmsize_t)sizeof(uint16_t)) || (poffb > tif->tif_size))
{
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
*nextdir=0;
return(0);
}
- _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16));
+ _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16_t));
if (tif->tif_flags&TIFF_SWAB)
TIFFSwabShort(&dircount);
poffc=poffb+dircount*12;
- poffd=poffc+sizeof(uint32);
- if ((poffc<poffb)||(poffc<dircount*12)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint32))||(poffd>tif->tif_size))
+ poffd=poffc+sizeof(uint32_t);
+ if ((poffc<poffb) || (poffc<dircount*12) || (poffd<poffc) || (poffd<(tmsize_t)sizeof(uint32_t)) || (poffd > tif->tif_size))
{
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link");
return(0);
}
if (off!=NULL)
- *off=(uint64)poffc;
- _TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32));
+ *off=(uint64_t)poffc;
+ _TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32_t));
if (tif->tif_flags&TIFF_SWAB)
TIFFSwabLong(&nextdir32);
*nextdir=nextdir32;
@@ -1529,16 +1529,16 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
else
{
tmsize_t poffa,poffb,poffc,poffd;
- uint64 dircount64;
- uint16 dircount16;
+ uint64_t dircount64;
+ uint16_t dircount16;
poffa=(tmsize_t)poff;
- poffb=poffa+sizeof(uint64);
- if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint64))||(poffb>tif->tif_size))
+ poffb=poffa+sizeof(uint64_t);
+ if (((uint64_t)poffa != poff) || (poffb < poffa) || (poffb < (tmsize_t)sizeof(uint64_t)) || (poffb > tif->tif_size))
{
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
return(0);
}
- _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64));
+ _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64_t));
if (tif->tif_flags&TIFF_SWAB)
TIFFSwabLong8(&dircount64);
if (dircount64>0xFFFF)
@@ -1546,17 +1546,17 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
TIFFErrorExt(tif->tif_clientdata,module,"Sanity check on directory count failed");
return(0);
}
- dircount16=(uint16)dircount64;
+ dircount16=(uint16_t)dircount64;
poffc=poffb+dircount16*20;
- poffd=poffc+sizeof(uint64);
- if ((poffc<poffb)||(poffc<dircount16*20)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint64))||(poffd>tif->tif_size))
+ poffd=poffc+sizeof(uint64_t);
+ if ((poffc<poffb) || (poffc<dircount16*20) || (poffd<poffc) || (poffd<(tmsize_t)sizeof(uint64_t)) || (poffd > tif->tif_size))
{
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link");
return(0);
}
if (off!=NULL)
- *off=(uint64)poffc;
- _TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64));
+ *off=(uint64_t)poffc;
+ _TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64_t));
if (tif->tif_flags&TIFF_SWAB)
TIFFSwabLong8(nextdir);
}
@@ -1566,10 +1566,10 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
{
if (!(tif->tif_flags&TIFF_BIGTIFF))
{
- uint16 dircount;
- uint32 nextdir32;
+ uint16_t dircount;
+ uint32_t nextdir32;
if (!SeekOK(tif, *nextdir) ||
- !ReadOK(tif, &dircount, sizeof (uint16))) {
+ !ReadOK(tif, &dircount, sizeof (uint16_t))) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
tif->tif_name);
return (0);
@@ -1582,7 +1582,7 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
else
(void) TIFFSeekFile(tif,
dircount*12, SEEK_CUR);
- if (!ReadOK(tif, &nextdir32, sizeof (uint32))) {
+ if (!ReadOK(tif, &nextdir32, sizeof (uint32_t))) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
tif->tif_name);
return (0);
@@ -1593,10 +1593,10 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
}
else
{
- uint64 dircount64;
- uint16 dircount16;
+ uint64_t dircount64;
+ uint16_t dircount16;
if (!SeekOK(tif, *nextdir) ||
- !ReadOK(tif, &dircount64, sizeof (uint64))) {
+ !ReadOK(tif, &dircount64, sizeof (uint64_t))) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
tif->tif_name);
return (0);
@@ -1608,14 +1608,14 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count");
return(0);
}
- dircount16 = (uint16)dircount64;
+ dircount16 = (uint16_t)dircount64;
if (off != NULL)
*off = TIFFSeekFile(tif,
dircount16*20, SEEK_CUR);
else
(void) TIFFSeekFile(tif,
dircount16*20, SEEK_CUR);
- if (!ReadOK(tif, nextdir, sizeof (uint64))) {
+ if (!ReadOK(tif, nextdir, sizeof (uint64_t))) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Error fetching directory link",
tif->tif_name);
@@ -1631,12 +1631,12 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
/*
* Count the number of directories in a file.
*/
-uint16
+uint16_t
TIFFNumberOfDirectories(TIFF* tif)
{
static const char module[] = "TIFFNumberOfDirectories";
- uint64 nextdir;
- uint16 n;
+ uint64_t nextdir;
+ uint16_t n;
if (!(tif->tif_flags&TIFF_BIGTIFF))
nextdir = tif->tif_header.classic.tiff_diroff;
else
@@ -1663,10 +1663,10 @@ TIFFNumberOfDirectories(TIFF* tif)
* NB: Directories are numbered starting at 0.
*/
int
-TIFFSetDirectory(TIFF* tif, uint16 dirn)
+TIFFSetDirectory(TIFF* tif, uint16_t dirn)
{
- uint64 nextdir;
- uint16 n;
+ uint64_t nextdir;
+ uint16_t n;
if (!(tif->tif_flags&TIFF_BIGTIFF))
nextdir = tif->tif_header.classic.tiff_diroff;
@@ -1697,7 +1697,7 @@ TIFFSetDirectory(TIFF* tif, uint16 dirn)
* the SubIFD tag (e.g. thumbnail images).
*/
int
-TIFFSetSubDirectory(TIFF* tif, uint64 diroff)
+TIFFSetSubDirectory(TIFF* tif, uint64_t diroff)
{
tif->tif_nextdiroff = diroff;
/*
@@ -1711,7 +1711,7 @@ TIFFSetSubDirectory(TIFF* tif, uint64 diroff)
/*
* Return file offset of the current directory.
*/
-uint64
+uint64_t
TIFFCurrentDirOffset(TIFF* tif)
{
return (tif->tif_diroff);
@@ -1731,12 +1731,12 @@ TIFFLastDirectory(TIFF* tif)
* Unlink the specified directory from the directory chain.
*/
int
-TIFFUnlinkDirectory(TIFF* tif, uint16 dirn)
+TIFFUnlinkDirectory(TIFF* tif, uint16_t dirn)
{
static const char module[] = "TIFFUnlinkDirectory";
- uint64 nextdir;
- uint64 off;
- uint16 n;
+ uint64_t nextdir;
+ uint64_t off;
+ uint16_t n;
if (tif->tif_mode == O_RDONLY) {
TIFFErrorExt(tif->tif_clientdata, module,
@@ -1760,7 +1760,7 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn)
}
for (n = dirn-1; n > 0; n--) {
if (nextdir == 0) {
- TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn);
+ TIFFErrorExt(tif->tif_clientdata, module, "Directory %"PRIu16" does not exist", dirn);
return (0);
}
if (!TIFFAdvanceDirectory(tif, &nextdir, &off))
@@ -1780,12 +1780,12 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn)
(void) TIFFSeekFile(tif, off, SEEK_SET);
if (!(tif->tif_flags&TIFF_BIGTIFF))
{
- uint32 nextdir32;
- nextdir32=(uint32)nextdir;
- assert((uint64)nextdir32==nextdir);
+ uint32_t nextdir32;
+ nextdir32=(uint32_t)nextdir;
+ assert((uint64_t)nextdir32 == nextdir);
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabLong(&nextdir32);
- if (!WriteOK(tif, &nextdir32, sizeof (uint32))) {
+ if (!WriteOK(tif, &nextdir32, sizeof (uint32_t))) {
TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
return (0);
}
@@ -1794,7 +1794,7 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn)
{
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabLong8(&nextdir);
- if (!WriteOK(tif, &nextdir, sizeof (uint64))) {
+ if (!WriteOK(tif, &nextdir, sizeof (uint64_t))) {
TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
return (0);
}
@@ -1820,8 +1820,8 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn)
tif->tif_diroff = 0; /* force link on next write */
tif->tif_nextdiroff = 0; /* next write must be at end */
tif->tif_curoff = 0;
- tif->tif_row = (uint32) -1;
- tif->tif_curstrip = (uint32) -1;
+ tif->tif_row = (uint32_t) -1;
+ tif->tif_curstrip = (uint32_t) -1;
return (1);
}