4 * Copyright (c) 1988-1997 Sam Leffler
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the names of
11 * Sam Leffler and Silicon Graphics may not be used in any advertising or
12 * publicity relating to the software without the specific, prior written
13 * permission of Sam Leffler and Silicon Graphics.
15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
27 #include "tif_config.h"
41 #ifdef HAVE_SYS_TYPES_H
42 # include <sys/types.h>
59 int typeshift
[14]; /* data type shift counts */
60 long typemask
[14]; /* data type masks */
61 uint32 maxitems
= 24; /* maximum indirect data items to print */
63 char* bytefmt
= "%s%#02x"; /* BYTE */
64 char* sbytefmt
= "%s%d"; /* SBYTE */
65 char* shortfmt
= "%s%u"; /* SHORT */
66 char* sshortfmt
= "%s%d"; /* SSHORT */
67 char* longfmt
= "%s%lu"; /* LONG */
68 char* slongfmt
= "%s%ld"; /* SLONG */
69 char* rationalfmt
= "%s%g"; /* RATIONAL */
70 char* srationalfmt
= "%s%g"; /* SRATIONAL */
71 char* floatfmt
= "%s%g"; /* FLOAT */
72 char* doublefmt
= "%s%g"; /* DOUBLE */
73 char* ifdfmt
= "%s%#04x"; /* IFD offset */
75 static void dump(int, off_t
);
82 fprintf(stderr
, "usage: %s [-h] [-o offset] [-m maxitems] file.tif ...\n", appname
);
87 main(int argc
, char* argv
[])
90 int multiplefiles
= (argc
> 1);
92 uint32 diroff
= (uint32
) 0;
93 bigendian
= (*(char *)&one
== 0);
96 while ((c
= getopt(argc
, argv
, "m:o:h")) != -1) {
98 case 'h': /* print values in hex */
105 diroff
= (uint32
) strtoul(optarg
, NULL
, 0);
108 maxitems
= strtoul(optarg
, NULL
, 0);
116 for (; optind
< argc
; optind
++) {
117 fd
= open(argv
[optind
], O_RDONLY
|O_BINARY
, 0);
123 printf("%s:\n", argv
[optind
]);
124 curfile
= argv
[optind
];
132 static TIFFHeader hdr
;
134 #define ord(e) ((int)e)
137 * Initialize shift & mask tables and byte
138 * swapping state according to the file
142 InitByteOrder(int magic
)
145 typemask
[ord(TIFF_BYTE
)] = 0xff;
146 typemask
[ord(TIFF_SBYTE
)] = 0xff;
147 typemask
[ord(TIFF_UNDEFINED
)] = 0xff;
148 typemask
[ord(TIFF_SHORT
)] = 0xffff;
149 typemask
[ord(TIFF_SSHORT
)] = 0xffff;
150 typemask
[ord(TIFF_LONG
)] = 0xffffffff;
151 typemask
[ord(TIFF_SLONG
)] = 0xffffffff;
152 typemask
[ord(TIFF_IFD
)] = 0xffffffff;
153 typemask
[ord(TIFF_RATIONAL
)] = 0xffffffff;
154 typemask
[ord(TIFF_SRATIONAL
)] = 0xffffffff;
155 typemask
[ord(TIFF_FLOAT
)] = 0xffffffff;
156 typemask
[ord(TIFF_DOUBLE
)] = 0xffffffff;
158 typeshift
[ord(TIFF_LONG
)] = 0;
159 typeshift
[ord(TIFF_SLONG
)] = 0;
160 typeshift
[ord(TIFF_IFD
)] = 0;
161 typeshift
[ord(TIFF_RATIONAL
)] = 0;
162 typeshift
[ord(TIFF_SRATIONAL
)] = 0;
163 typeshift
[ord(TIFF_FLOAT
)] = 0;
164 typeshift
[ord(TIFF_DOUBLE
)] = 0;
165 if (magic
== TIFF_BIGENDIAN
|| magic
== MDI_BIGENDIAN
) {
166 typeshift
[ord(TIFF_BYTE
)] = 24;
167 typeshift
[ord(TIFF_SBYTE
)] = 24;
168 typeshift
[ord(TIFF_SHORT
)] = 16;
169 typeshift
[ord(TIFF_SSHORT
)] = 16;
170 swabflag
= !bigendian
;
172 typeshift
[ord(TIFF_BYTE
)] = 0;
173 typeshift
[ord(TIFF_SBYTE
)] = 0;
174 typeshift
[ord(TIFF_SHORT
)] = 0;
175 typeshift
[ord(TIFF_SSHORT
)] = 0;
176 swabflag
= bigendian
;
180 static off_t
ReadDirectory(int, unsigned, off_t
);
181 static void ReadError(char*);
182 static void Error(const char*, ...);
183 static void Fatal(const char*, ...);
186 dump(int fd
, off_t diroff
)
190 lseek(fd
, (off_t
) 0, 0);
191 if (read(fd
, (char*) &hdr
, sizeof (hdr
)) != sizeof (hdr
))
192 ReadError("TIFF header");
194 * Setup the byte order handling.
196 if (hdr
.tiff_magic
!= TIFF_BIGENDIAN
&& hdr
.tiff_magic
!= TIFF_LITTLEENDIAN
&&
198 // MDI is sensitive to the host byte order, unlike TIFF
199 MDI_BIGENDIAN
!= hdr
.tiff_magic
)
201 MDI_LITTLEENDIAN
!= hdr
.tiff_magic
)
203 Fatal("Not a TIFF or MDI file, bad magic number %u (%#x)",
204 hdr
.tiff_magic
, hdr
.tiff_magic
);
205 InitByteOrder(hdr
.tiff_magic
);
207 * Swap header if required.
210 TIFFSwabShort(&hdr
.tiff_version
);
211 TIFFSwabLong(&hdr
.tiff_diroff
);
214 * Now check version (if needed, it's been byte-swapped).
215 * Note that this isn't actually a version number, it's a
216 * magic number that doesn't change (stupid).
218 if (hdr
.tiff_version
!= TIFF_VERSION
)
219 Fatal("Not a TIFF file, bad version number %u (%#x)",
220 hdr
.tiff_version
, hdr
.tiff_version
);
221 printf("Magic: %#x <%s-endian> Version: %#x\n",
223 hdr
.tiff_magic
== TIFF_BIGENDIAN
? "big" : "little",
226 diroff
= hdr
.tiff_diroff
;
227 for (i
= 0; diroff
!= 0; i
++) {
230 diroff
= ReadDirectory(fd
, i
, diroff
);
234 static int datawidth
[] = {
240 8, /* TIFF_RATIONAL */
242 1, /* TIFF_UNDEFINED */
245 8, /* TIFF_SRATIONAL */
250 #define NWIDTHS (sizeof (datawidth) / sizeof (datawidth[0]))
251 static int TIFFFetchData(int, TIFFDirEntry
*, void*);
252 static void PrintTag(FILE*, uint16
);
253 static void PrintType(FILE*, uint16
);
254 static void PrintData(FILE*, uint16
, uint32
, unsigned char*);
255 static void PrintByte(FILE*, const char*, TIFFDirEntry
*);
256 static void PrintShort(FILE*, const char*, TIFFDirEntry
*);
257 static void PrintLong(FILE*, const char*, TIFFDirEntry
*);
260 * Read the next TIFF directory from a file
261 * and convert it to the internal format.
262 * We read directories sequentially.
265 ReadDirectory(int fd
, unsigned ix
, off_t off
)
267 register TIFFDirEntry
*dp
;
268 register unsigned int n
;
269 TIFFDirEntry
*dir
= 0;
272 uint32 nextdiroff
= 0;
274 if (off
== 0) /* no more directories */
276 if (lseek(fd
, (off_t
) off
, 0) != off
) {
277 Fatal("Seek error accessing TIFF directory");
280 if (read(fd
, (char*) &dircount
, sizeof (uint16
)) != sizeof (uint16
)) {
281 ReadError("directory count");
285 TIFFSwabShort(&dircount
);
286 dir
= (TIFFDirEntry
*)_TIFFmalloc(dircount
* sizeof (TIFFDirEntry
));
288 Fatal("No space for TIFF directory");
291 n
= read(fd
, (char*) dir
, dircount
*sizeof (*dp
));
292 if (n
!= dircount
*sizeof (*dp
)) {
295 "Could only read %u of %u entries in directory at offset %#lx",
296 n
, dircount
, (unsigned long) off
);
299 if (read(fd
, (char*) &nextdiroff
, sizeof (uint32
)) != sizeof (uint32
))
302 TIFFSwabLong(&nextdiroff
);
303 printf("Directory %u: offset %lu (%#lx) next %lu (%#lx)\n", ix
,
304 (unsigned long)off
, (unsigned long)off
,
305 (unsigned long)nextdiroff
, (unsigned long)nextdiroff
);
306 for (dp
= dir
, n
= dircount
; n
> 0; n
--, dp
++) {
308 TIFFSwabArrayOfShort(&dp
->tdir_tag
, 2);
309 TIFFSwabArrayOfLong(&dp
->tdir_count
, 2);
311 PrintTag(stdout
, dp
->tdir_tag
);
313 PrintType(stdout
, dp
->tdir_type
);
315 printf("%lu<", (unsigned long) dp
->tdir_count
);
316 if (dp
->tdir_type
>= NWIDTHS
) {
320 space
= dp
->tdir_count
* datawidth
[dp
->tdir_type
];
323 Error("Invalid count for tag %u", dp
->tdir_tag
);
327 switch (dp
->tdir_type
) {
331 unsigned char data
[4];
332 _TIFFmemcpy(data
, &dp
->tdir_offset
, 4);
334 TIFFSwabLong((uint32
*) data
);
336 dp
->tdir_type
, dp
->tdir_count
, data
);
340 PrintByte(stdout
, bytefmt
, dp
);
343 PrintByte(stdout
, sbytefmt
, dp
);
346 PrintShort(stdout
, shortfmt
, dp
);
349 PrintShort(stdout
, sshortfmt
, dp
);
352 PrintLong(stdout
, longfmt
, dp
);
355 PrintLong(stdout
, slongfmt
, dp
);
358 PrintLong(stdout
, ifdfmt
, dp
);
362 unsigned char *data
= (unsigned char *)_TIFFmalloc(space
);
364 if (TIFFFetchData(fd
, dp
, data
)) {
365 if (dp
->tdir_count
> maxitems
) {
366 PrintData(stdout
, dp
->tdir_type
,
370 PrintData(stdout
, dp
->tdir_type
,
371 dp
->tdir_count
, data
);
375 Error("No space for data for tag %u",
382 _TIFFfree((char *)dir
);
386 static struct tagname
{
390 { TIFFTAG_SUBFILETYPE
, "SubFileType" },
391 { TIFFTAG_OSUBFILETYPE
, "OldSubFileType" },
392 { TIFFTAG_IMAGEWIDTH
, "ImageWidth" },
393 { TIFFTAG_IMAGELENGTH
, "ImageLength" },
394 { TIFFTAG_BITSPERSAMPLE
, "BitsPerSample" },
395 { TIFFTAG_COMPRESSION
, "Compression" },
396 { TIFFTAG_PHOTOMETRIC
, "Photometric" },
397 { TIFFTAG_THRESHHOLDING
, "Threshholding" },
398 { TIFFTAG_CELLWIDTH
, "CellWidth" },
399 { TIFFTAG_CELLLENGTH
, "CellLength" },
400 { TIFFTAG_FILLORDER
, "FillOrder" },
401 { TIFFTAG_DOCUMENTNAME
, "DocumentName" },
402 { TIFFTAG_IMAGEDESCRIPTION
, "ImageDescription" },
403 { TIFFTAG_MAKE
, "Make" },
404 { TIFFTAG_MODEL
, "Model" },
405 { TIFFTAG_STRIPOFFSETS
, "StripOffsets" },
406 { TIFFTAG_ORIENTATION
, "Orientation" },
407 { TIFFTAG_SAMPLESPERPIXEL
, "SamplesPerPixel" },
408 { TIFFTAG_ROWSPERSTRIP
, "RowsPerStrip" },
409 { TIFFTAG_STRIPBYTECOUNTS
, "StripByteCounts" },
410 { TIFFTAG_MINSAMPLEVALUE
, "MinSampleValue" },
411 { TIFFTAG_MAXSAMPLEVALUE
, "MaxSampleValue" },
412 { TIFFTAG_XRESOLUTION
, "XResolution" },
413 { TIFFTAG_YRESOLUTION
, "YResolution" },
414 { TIFFTAG_PLANARCONFIG
, "PlanarConfig" },
415 { TIFFTAG_PAGENAME
, "PageName" },
416 { TIFFTAG_XPOSITION
, "XPosition" },
417 { TIFFTAG_YPOSITION
, "YPosition" },
418 { TIFFTAG_FREEOFFSETS
, "FreeOffsets" },
419 { TIFFTAG_FREEBYTECOUNTS
, "FreeByteCounts" },
420 { TIFFTAG_GRAYRESPONSEUNIT
, "GrayResponseUnit" },
421 { TIFFTAG_GRAYRESPONSECURVE
,"GrayResponseCurve" },
422 { TIFFTAG_GROUP3OPTIONS
, "Group3Options" },
423 { TIFFTAG_GROUP4OPTIONS
, "Group4Options" },
424 { TIFFTAG_RESOLUTIONUNIT
, "ResolutionUnit" },
425 { TIFFTAG_PAGENUMBER
, "PageNumber" },
426 { TIFFTAG_COLORRESPONSEUNIT
,"ColorResponseUnit" },
427 { TIFFTAG_TRANSFERFUNCTION
, "TransferFunction" },
428 { TIFFTAG_SOFTWARE
, "Software" },
429 { TIFFTAG_DATETIME
, "DateTime" },
430 { TIFFTAG_ARTIST
, "Artist" },
431 { TIFFTAG_HOSTCOMPUTER
, "HostComputer" },
432 { TIFFTAG_PREDICTOR
, "Predictor" },
433 { TIFFTAG_WHITEPOINT
, "Whitepoint" },
434 { TIFFTAG_PRIMARYCHROMATICITIES
,"PrimaryChromaticities" },
435 { TIFFTAG_COLORMAP
, "Colormap" },
436 { TIFFTAG_HALFTONEHINTS
, "HalftoneHints" },
437 { TIFFTAG_TILEWIDTH
, "TileWidth" },
438 { TIFFTAG_TILELENGTH
, "TileLength" },
439 { TIFFTAG_TILEOFFSETS
, "TileOffsets" },
440 { TIFFTAG_TILEBYTECOUNTS
, "TileByteCounts" },
441 { TIFFTAG_BADFAXLINES
, "BadFaxLines" },
442 { TIFFTAG_CLEANFAXDATA
, "CleanFaxData" },
443 { TIFFTAG_CONSECUTIVEBADFAXLINES
, "ConsecutiveBadFaxLines" },
444 { TIFFTAG_SUBIFD
, "SubIFD" },
445 { TIFFTAG_INKSET
, "InkSet" },
446 { TIFFTAG_INKNAMES
, "InkNames" },
447 { TIFFTAG_NUMBEROFINKS
, "NumberOfInks" },
448 { TIFFTAG_DOTRANGE
, "DotRange" },
449 { TIFFTAG_TARGETPRINTER
, "TargetPrinter" },
450 { TIFFTAG_EXTRASAMPLES
, "ExtraSamples" },
451 { TIFFTAG_SAMPLEFORMAT
, "SampleFormat" },
452 { TIFFTAG_SMINSAMPLEVALUE
, "SMinSampleValue" },
453 { TIFFTAG_SMAXSAMPLEVALUE
, "SMaxSampleValue" },
454 { TIFFTAG_JPEGPROC
, "JPEGProcessingMode" },
455 { TIFFTAG_JPEGIFOFFSET
, "JPEGInterchangeFormat" },
456 { TIFFTAG_JPEGIFBYTECOUNT
, "JPEGInterchangeFormatLength" },
457 { TIFFTAG_JPEGRESTARTINTERVAL
,"JPEGRestartInterval" },
458 { TIFFTAG_JPEGLOSSLESSPREDICTORS
,"JPEGLosslessPredictors" },
459 { TIFFTAG_JPEGPOINTTRANSFORM
,"JPEGPointTransform" },
460 { TIFFTAG_JPEGTABLES
, "JPEGTables" },
461 { TIFFTAG_JPEGQTABLES
, "JPEGQTables" },
462 { TIFFTAG_JPEGDCTABLES
, "JPEGDCTables" },
463 { TIFFTAG_JPEGACTABLES
, "JPEGACTables" },
464 { TIFFTAG_YCBCRCOEFFICIENTS
,"YCbCrCoefficients" },
465 { TIFFTAG_YCBCRSUBSAMPLING
, "YCbCrSubsampling" },
466 { TIFFTAG_YCBCRPOSITIONING
, "YCbCrPositioning" },
467 { TIFFTAG_REFERENCEBLACKWHITE
, "ReferenceBlackWhite" },
468 { TIFFTAG_REFPTS
, "IgReferencePoints (Island Graphics)" },
469 { TIFFTAG_REGIONTACKPOINT
, "IgRegionTackPoint (Island Graphics)" },
470 { TIFFTAG_REGIONWARPCORNERS
,"IgRegionWarpCorners (Island Graphics)" },
471 { TIFFTAG_REGIONAFFINE
, "IgRegionAffine (Island Graphics)" },
472 { TIFFTAG_MATTEING
, "OBSOLETE Matteing (Silicon Graphics)" },
473 { TIFFTAG_DATATYPE
, "OBSOLETE DataType (Silicon Graphics)" },
474 { TIFFTAG_IMAGEDEPTH
, "ImageDepth (Silicon Graphics)" },
475 { TIFFTAG_TILEDEPTH
, "TileDepth (Silicon Graphics)" },
476 { 32768, "OLD BOGUS Matteing tag" },
477 { TIFFTAG_COPYRIGHT
, "Copyright" },
478 { TIFFTAG_ICCPROFILE
, "ICC Profile" },
479 { TIFFTAG_JBIGOPTIONS
, "JBIG Options" },
480 { TIFFTAG_STONITS
, "StoNits" },
482 #define NTAGS (sizeof (tagnames) / sizeof (tagnames[0]))
485 PrintTag(FILE* fd
, uint16 tag
)
487 register struct tagname
*tp
;
489 for (tp
= tagnames
; tp
< &tagnames
[NTAGS
]; tp
++)
490 if (tp
->tag
== tag
) {
491 fprintf(fd
, "%s (%u)", tp
->name
, tag
);
494 fprintf(fd
, "%u (%#x)", tag
, tag
);
498 PrintType(FILE* fd
, uint16 type
)
500 static char *typenames
[] = {
515 #define NTYPES (sizeof (typenames) / sizeof (typenames[0]))
518 fprintf(fd
, "%s (%u)", typenames
[type
], type
);
520 fprintf(fd
, "%u (%#x)", type
, type
);
525 PrintByte(FILE* fd
, const char* fmt
, TIFFDirEntry
* dp
)
529 if (hdr
.tiff_magic
== TIFF_BIGENDIAN
) {
530 switch ((int)dp
->tdir_count
) {
531 case 4: fprintf(fd
, fmt
, sep
, dp
->tdir_offset
&0xff);
533 case 3: fprintf(fd
, fmt
, sep
, (dp
->tdir_offset
>>8)&0xff);
535 case 2: fprintf(fd
, fmt
, sep
, (dp
->tdir_offset
>>16)&0xff);
537 case 1: fprintf(fd
, fmt
, sep
, dp
->tdir_offset
>>24);
540 switch ((int)dp
->tdir_count
) {
541 case 4: fprintf(fd
, fmt
, sep
, dp
->tdir_offset
>>24);
543 case 3: fprintf(fd
, fmt
, sep
, (dp
->tdir_offset
>>16)&0xff);
545 case 2: fprintf(fd
, fmt
, sep
, (dp
->tdir_offset
>>8)&0xff);
547 case 1: fprintf(fd
, fmt
, sep
, dp
->tdir_offset
&0xff);
553 PrintShort(FILE* fd
, const char* fmt
, TIFFDirEntry
* dp
)
557 if (hdr
.tiff_magic
== TIFF_BIGENDIAN
) {
558 switch (dp
->tdir_count
) {
559 case 2: fprintf(fd
, fmt
, sep
, dp
->tdir_offset
&0xffff);
561 case 1: fprintf(fd
, fmt
, sep
, dp
->tdir_offset
>>16);
564 switch (dp
->tdir_count
) {
565 case 2: fprintf(fd
, fmt
, sep
, dp
->tdir_offset
>>16);
567 case 1: fprintf(fd
, fmt
, sep
, dp
->tdir_offset
&0xffff);
573 PrintLong(FILE* fd
, const char* fmt
, TIFFDirEntry
* dp
)
575 fprintf(fd
, fmt
, "", (long) dp
->tdir_offset
);
581 PrintASCII(FILE* fd
, uint32 cc
, const unsigned char* cp
)
583 for (; cc
> 0; cc
--, cp
++) {
590 for (tp
= "\tt\bb\rr\nn\vv"; *tp
; tp
++)
594 fprintf(fd
, "\\%c", *tp
);
596 fprintf(fd
, "\\%03o", *cp
);
603 PrintData(FILE* fd
, uint16 type
, uint32 count
, unsigned char* data
)
610 fprintf(fd
, bytefmt
, sep
, *data
++), sep
= " ";
614 fprintf(fd
, sbytefmt
, sep
, *(char *)data
++), sep
= " ";
618 fprintf(fd
, bytefmt
, sep
, *data
++), sep
= " ";
621 PrintASCII(fd
, count
, data
);
624 uint16
*wp
= (uint16
*)data
;
626 fprintf(fd
, shortfmt
, sep
, *wp
++), sep
= " ";
630 int16
*wp
= (int16
*)data
;
632 fprintf(fd
, sshortfmt
, sep
, *wp
++), sep
= " ";
636 uint32
*lp
= (uint32
*)data
;
637 while (count
-- > 0) {
638 fprintf(fd
, longfmt
, sep
, (unsigned long) *lp
++);
644 int32
*lp
= (int32
*)data
;
646 fprintf(fd
, slongfmt
, sep
, (long) *lp
++), sep
= " ";
649 case TIFF_RATIONAL
: {
650 uint32
*lp
= (uint32
*)data
;
651 while (count
-- > 0) {
653 fprintf(fd
, "%sNan (%lu/%lu)", sep
,
654 (unsigned long) lp
[0],
655 (unsigned long) lp
[1]);
657 fprintf(fd
, rationalfmt
, sep
,
658 (double)lp
[0] / (double)lp
[1]);
664 case TIFF_SRATIONAL
: {
665 int32
*lp
= (int32
*)data
;
666 while (count
-- > 0) {
668 fprintf(fd
, "%sNan (%ld/%ld)", sep
,
669 (long) lp
[0], (long) lp
[1]);
671 fprintf(fd
, srationalfmt
, sep
,
672 (double)lp
[0] / (double)lp
[1]);
679 float *fp
= (float *)data
;
681 fprintf(fd
, floatfmt
, sep
, *fp
++), sep
= " ";
685 double *dp
= (double *)data
;
687 fprintf(fd
, doublefmt
, sep
, *dp
++), sep
= " ";
691 uint32
*lp
= (uint32
*)data
;
692 while (count
-- > 0) {
693 fprintf(fd
, ifdfmt
, sep
, (unsigned long) *lp
++);
702 * Fetch a contiguous directory item.
705 TIFFFetchData(int fd
, TIFFDirEntry
* dir
, void* cp
)
709 w
= (dir
->tdir_type
< NWIDTHS
? datawidth
[dir
->tdir_type
] : 0);
710 cc
= dir
->tdir_count
* w
;
711 if (lseek(fd
, (off_t
)dir
->tdir_offset
, 0) != (off_t
)-1
712 && read(fd
, cp
, cc
) != -1) {
714 switch (dir
->tdir_type
) {
717 TIFFSwabArrayOfShort((uint16
*) cp
,
724 TIFFSwabArrayOfLong((uint32
*) cp
,
728 TIFFSwabArrayOfLong((uint32
*) cp
,
732 TIFFSwabArrayOfDouble((double*) cp
,
739 Error("Error while reading data for tag %u", dir
->tdir_tag
);
744 ReadError(char* what
)
746 Fatal("Error while reading %s", what
);
752 vError(FILE* fd
, const char* fmt
, va_list ap
)
754 fprintf(fd
, "%s: ", curfile
);
755 vfprintf(fd
, fmt
, ap
);
760 Error(const char* fmt
, ...)
764 vError(stderr
, fmt
, ap
);
769 Fatal(const char* fmt
, ...)
773 vError(stderr
, fmt
, ap
);
778 /* vim: set ts=8 sts=8 sw=8 noet: */