nicer way to avoid reading data for non-image directories

This commit is contained in:
Frank Warmerdam 2012-06-06 06:05:29 +00:00
parent 7e632eb41c
commit b246f148ff

View File

@ -1,4 +1,4 @@
/* $Id: tiffinfo.c,v 1.20 2012-06-01 23:22:54 fwarmerdam Exp $ */
/* $Id: tiffinfo.c,v 1.21 2012-06-06 06:05:29 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -53,7 +53,7 @@ static int readdata = 0; /* read data in file */
static int stoponerr = 1; /* stop on first read error */
static void usage(void);
static void tiffinfo(TIFF*, uint16, long);
static void tiffinfo(TIFF*, uint16, long, int);
static void
PrivateErrorHandler(const char* module, const char* fmt, va_list ap)
@ -139,22 +139,19 @@ main(int argc, char* argv[])
if (tif != NULL) {
if (dirnum != -1) {
if (TIFFSetDirectory(tif, (tdir_t) dirnum))
tiffinfo(tif, order, flags);
tiffinfo(tif, order, flags, 1);
} else if (diroff != 0) {
if (TIFFSetSubDirectory(tif, diroff))
tiffinfo(tif, order, flags);
tiffinfo(tif, order, flags, 1);
} else {
do {
toff_t offset;
tiffinfo(tif, order, flags);
tiffinfo(tif, order, flags, 1);
if (TIFFGetField(tif, TIFFTAG_EXIFIFD,
&offset)) {
if (TIFFReadEXIFDirectory(tif, offset)) {
int old_readdata = readdata;
readdata = 0;
tiffinfo(tif, order, flags);
readdata = old_readdata;
tiffinfo(tif, order, flags, 0);
}
}
} while (TIFFReadDirectory(tif));
@ -445,10 +442,10 @@ TIFFReadRawData(TIFF* tif, int bitrev)
}
static void
tiffinfo(TIFF* tif, uint16 order, long flags)
tiffinfo(TIFF* tif, uint16 order, long flags, int is_image)
{
TIFFPrintDirectory(tif, stdout, flags);
if (!readdata)
if (!readdata || !is_image)
return;
if (rawdata) {
if (order) {