3 * Copyright (c) 1988-1997 Sam Leffler
4 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that (i) the above copyright notices and this permission notice appear in
9 * all copies of the software and related documentation, and (ii) the names of
10 * Sam Leffler and Silicon Graphics may not be used in any advertising or
11 * publicity relating to the software without the specific, prior written
12 * permission of Sam Leffler and Silicon Graphics.
14 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
26 #include "tif_config.h"
40 #ifdef HAVE_SYS_TYPES_H
41 # include <sys/types.h>
53 extern int getopt(int, char**, char*);
64 TIFFHeaderClassic classic
;
66 TIFFHeaderCommon common
;
73 uint32 maxitems
= 24; /* maximum indirect data items to print */
75 const char* bytefmt
= "%s%#02x"; /* BYTE */
76 const char* sbytefmt
= "%s%d"; /* SBYTE */
77 const char* shortfmt
= "%s%u"; /* SHORT */
78 const char* sshortfmt
= "%s%d"; /* SSHORT */
79 const char* longfmt
= "%s%lu"; /* LONG */
80 const char* slongfmt
= "%s%ld"; /* SLONG */
81 const char* ifdfmt
= "%s%#04lx"; /* IFD offset */
82 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
83 const char* long8fmt
= "%s%I64u"; /* LONG8 */
84 const char* slong8fmt
= "%s%I64d"; /* SLONG8 */
85 const char* ifd8fmt
= "%s%#08I64x"; /* IFD offset8*/
87 const char* long8fmt
= "%s%llu"; /* LONG8 */
88 const char* slong8fmt
= "%s%lld"; /* SLONG8 */
89 const char* ifd8fmt
= "%s%#08llx"; /* IFD offset8*/
91 const char* rationalfmt
= "%s%g"; /* RATIONAL */
92 const char* srationalfmt
= "%s%g"; /* SRATIONAL */
93 const char* floatfmt
= "%s%g"; /* FLOAT */
94 const char* doublefmt
= "%s%g"; /* DOUBLE */
96 static void dump(int, uint64
);
103 fprintf(stderr
, "usage: %s [-h] [-o offset] [-m maxitems] file.tif ...\n", appname
);
108 main(int argc
, char* argv
[])
111 int multiplefiles
= (argc
> 1);
114 bigendian
= (*(char *)&one
== 0);
117 while ((c
= getopt(argc
, argv
, "m:o:h")) != -1) {
119 case 'h': /* print values in hex */
126 diroff
= (uint64
) strtoul(optarg
, NULL
, 0);
129 maxitems
= strtoul(optarg
, NULL
, 0);
137 for (; optind
< argc
; optind
++) {
138 fd
= open(argv
[optind
], O_RDONLY
|O_BINARY
, 0);
144 printf("%s:\n", argv
[optind
]);
145 curfile
= argv
[optind
];
154 #define ord(e) ((int)e)
156 static uint64
ReadDirectory(int, unsigned, uint64
);
157 static void ReadError(char*);
158 static void Error(const char*, ...);
159 static void Fatal(const char*, ...);
162 dump(int fd
, uint64 diroff
)
166 lseek(fd
, (off_t
) 0, 0);
167 if (read(fd
, (char*) &hdr
, sizeof (TIFFHeaderCommon
)) != sizeof (TIFFHeaderCommon
))
168 ReadError("TIFF header");
169 if (hdr
.common
.tiff_magic
!= TIFF_BIGENDIAN
170 && hdr
.common
.tiff_magic
!= TIFF_LITTLEENDIAN
&&
172 /* MDI is sensitive to the host byte order, unlike TIFF */
173 MDI_BIGENDIAN
!= hdr
.common
.tiff_magic
175 MDI_LITTLEENDIAN
!= hdr
.common
.tiff_magic
178 Fatal("Not a TIFF or MDI file, bad magic number %u (%#x)",
179 hdr
.common
.tiff_magic
, hdr
.common
.tiff_magic
);
181 if (hdr
.common
.tiff_magic
== TIFF_BIGENDIAN
182 || hdr
.common
.tiff_magic
== MDI_BIGENDIAN
)
183 swabflag
= !bigendian
;
185 swabflag
= bigendian
;
187 TIFFSwabShort(&hdr
.common
.tiff_version
);
188 if (hdr
.common
.tiff_version
==42)
190 if (read(fd
, (char*) &hdr
.classic
.tiff_diroff
, 4) != 4)
191 ReadError("TIFF header");
193 TIFFSwabLong(&hdr
.classic
.tiff_diroff
);
194 printf("Magic: %#x <%s-endian> Version: %#x <%s>\n",
195 hdr
.classic
.tiff_magic
,
196 hdr
.classic
.tiff_magic
== TIFF_BIGENDIAN
? "big" : "little",
199 diroff
= hdr
.classic
.tiff_diroff
;
201 else if (hdr
.common
.tiff_version
==43)
203 if (read(fd
, (char*) &hdr
.big
.tiff_offsetsize
, 12) != 12)
204 ReadError("TIFF header");
207 TIFFSwabShort(&hdr
.big
.tiff_offsetsize
);
208 TIFFSwabShort(&hdr
.big
.tiff_unused
);
209 TIFFSwabLong8(&hdr
.big
.tiff_diroff
);
211 printf("Magic: %#x <%s-endian> Version: %#x <%s>\n",
213 hdr
.big
.tiff_magic
== TIFF_BIGENDIAN
? "big" : "little",
215 printf("OffsetSize: %#x Unused: %#x\n",
216 hdr
.big
.tiff_offsetsize
,hdr
.big
.tiff_unused
);
218 diroff
= hdr
.big
.tiff_diroff
;
222 Fatal("Not a TIFF file, bad version number %u (%#x)",
223 hdr
.common
.tiff_version
, hdr
.common
.tiff_version
);
224 for (i
= 0; diroff
!= 0; i
++) {
227 diroff
= ReadDirectory(fd
, i
, diroff
);
231 static const int datawidth
[] = {
232 0, /* 00 = undefined */
233 1, /* 01 = TIFF_BYTE */
234 1, /* 02 = TIFF_ASCII */
235 2, /* 03 = TIFF_SHORT */
236 4, /* 04 = TIFF_LONG */
237 8, /* 05 = TIFF_RATIONAL */
238 1, /* 06 = TIFF_SBYTE */
239 1, /* 07 = TIFF_UNDEFINED */
240 2, /* 08 = TIFF_SSHORT */
241 4, /* 09 = TIFF_SLONG */
242 8, /* 10 = TIFF_SRATIONAL */
243 4, /* 11 = TIFF_FLOAT */
244 8, /* 12 = TIFF_DOUBLE */
245 4, /* 13 = TIFF_IFD */
246 0, /* 14 = undefined */
247 0, /* 15 = undefined */
248 8, /* 16 = TIFF_LONG8 */
249 8, /* 17 = TIFF_SLONG8 */
250 8, /* 18 = TIFF_IFD8 */
252 #define NWIDTHS (sizeof (datawidth) / sizeof (datawidth[0]))
253 static void PrintTag(FILE*, uint16
);
254 static void PrintType(FILE*, uint16
);
255 static void PrintData(FILE*, uint16
, uint32
, unsigned char*);
258 * Read the next TIFF directory from a file
259 * and convert it to the internal format.
260 * We read directories sequentially.
263 ReadDirectory(int fd
, unsigned int ix
, uint64 off
)
268 uint64 nextdiroff
= 0;
272 if (off
== 0) /* no more directories */
274 #if defined(__WIN32__) && defined(_MSC_VER)
275 if (_lseeki64(fd
, (__int64
)off
, SEEK_SET
) != (__int64
)off
) {
277 if (lseek(fd
, (off_t
)off
, SEEK_SET
) != (off_t
)off
) {
279 Fatal("Seek error accessing TIFF directory");
283 if (read(fd
, (char*) &dircount
, sizeof (uint16
)) != sizeof (uint16
)) {
284 ReadError("directory count");
288 TIFFSwabShort(&dircount
);
291 uint64 dircount64
= 0;
292 if (read(fd
, (char*) &dircount64
, sizeof (uint64
)) != sizeof (uint64
)) {
293 ReadError("directory count");
297 TIFFSwabLong8(&dircount64
);
298 if (dircount64
>0xFFFF) {
299 Error("Sanity check on directory count failed");
302 dircount
= (uint16
)dircount64
;
305 dirmem
= _TIFFmalloc(dircount
* direntrysize
);
306 if (dirmem
== NULL
) {
307 Fatal("No space for TIFF directory");
310 n
= read(fd
, (char*) dirmem
, dircount
*direntrysize
);
311 if (n
!= dircount
*direntrysize
) {
314 #if defined(__WIN32__) && defined(_MSC_VER)
315 "Could only read %lu of %u entries in directory at offset %#I64x",
316 (unsigned long)n
, dircount
, (unsigned __int64
) off
);
318 "Could only read %lu of %u entries in directory at offset %#llx",
319 (unsigned long)n
, dircount
, (unsigned long long) off
);
326 if (read(fd
, (char*) &nextdiroff32
, sizeof (uint32
)) != sizeof (uint32
))
329 TIFFSwabLong(&nextdiroff32
);
330 nextdiroff
= nextdiroff32
;
332 if (read(fd
, (char*) &nextdiroff
, sizeof (uint64
)) != sizeof (uint64
))
335 TIFFSwabLong8(&nextdiroff
);
338 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
339 printf("Directory %u: offset %I64u (%#I64x) next %I64u (%#I64x)\n", ix
,
340 (unsigned __int64
)off
, (unsigned __int64
)off
,
341 (unsigned __int64
)nextdiroff
, (unsigned __int64
)nextdiroff
);
343 printf("Directory %u: offset %llu (%#llx) next %llu (%#llx)\n", ix
,
344 (unsigned long long)off
, (unsigned long long)off
,
345 (unsigned long long)nextdiroff
, (unsigned long long)nextdiroff
);
347 for (dp
= (uint8
*)dirmem
, n
= dircount
; n
> 0; n
--) {
360 dp
+= sizeof(uint16
);
362 dp
+= sizeof(uint16
);
364 TIFFSwabShort(&type
);
365 PrintTag(stdout
, tag
);
367 PrintType(stdout
, type
);
372 count32
= *(uint32
*)dp
;
374 TIFFSwabLong(&count32
);
375 dp
+= sizeof(uint32
);
380 count
= *(uint64
*)dp
;
382 TIFFSwabLong8(&count
);
383 dp
+= sizeof(uint64
);
385 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
386 printf("%I64u<", (unsigned __int64
)count
);
388 printf("%llu<", (unsigned long long)count
);
393 typewidth
= datawidth
[type
];
394 datasize
= count
*typewidth
;
406 dataoffset32
= *(uint32
*)dp
;
408 TIFFSwabLong(&dataoffset32
);
409 dataoffset
= dataoffset32
;
411 dp
+= sizeof(uint32
);
419 dataoffset
= *(uint64
*)dp
;
421 TIFFSwabLong8(&dataoffset
);
423 dp
+= sizeof(uint64
);
425 if (datasize
>0x10000)
428 count
= 0x10000/typewidth
;
429 datasize
= count
*typewidth
;
435 datasize
= count
*typewidth
;
439 datamem
= _TIFFmalloc((uint32
)datasize
);
441 #if defined(__WIN32__) && defined(_MSC_VER)
442 if (_lseeki64(fd
, (__int64
)dataoffset
, SEEK_SET
)
443 != (__int64
)dataoffset
)
445 if (lseek(fd
, (off_t
)dataoffset
, 0) !=
450 "Seek error accessing tag %u value", tag
);
454 if (read(fd
, datamem
, (size_t)datasize
) != (TIFF_SSIZE_T
)datasize
)
457 "Read error accessing tag %u value", tag
);
462 Error("No space for data for tag %u",tag
);
477 TIFFSwabArrayOfShort((uint16
*)datamem
,(tmsize_t
)count
);
483 TIFFSwabArrayOfLong((uint32
*)datamem
,(tmsize_t
)count
);
487 TIFFSwabArrayOfLong((uint32
*)datamem
,(tmsize_t
)count
*2);
493 TIFFSwabArrayOfLong8((uint64
*)datamem
,(tmsize_t
)count
);
497 PrintData(stdout
,type
,(uint32
)count
,datamem
);
507 _TIFFfree((char *)dirmem
);
511 static const struct tagname
{
515 { TIFFTAG_SUBFILETYPE
, "SubFileType" },
516 { TIFFTAG_OSUBFILETYPE
, "OldSubFileType" },
517 { TIFFTAG_IMAGEWIDTH
, "ImageWidth" },
518 { TIFFTAG_IMAGELENGTH
, "ImageLength" },
519 { TIFFTAG_BITSPERSAMPLE
, "BitsPerSample" },
520 { TIFFTAG_COMPRESSION
, "Compression" },
521 { TIFFTAG_PHOTOMETRIC
, "Photometric" },
522 { TIFFTAG_THRESHHOLDING
, "Threshholding" },
523 { TIFFTAG_CELLWIDTH
, "CellWidth" },
524 { TIFFTAG_CELLLENGTH
, "CellLength" },
525 { TIFFTAG_FILLORDER
, "FillOrder" },
526 { TIFFTAG_DOCUMENTNAME
, "DocumentName" },
527 { TIFFTAG_IMAGEDESCRIPTION
, "ImageDescription" },
528 { TIFFTAG_MAKE
, "Make" },
529 { TIFFTAG_MODEL
, "Model" },
530 { TIFFTAG_STRIPOFFSETS
, "StripOffsets" },
531 { TIFFTAG_ORIENTATION
, "Orientation" },
532 { TIFFTAG_SAMPLESPERPIXEL
, "SamplesPerPixel" },
533 { TIFFTAG_ROWSPERSTRIP
, "RowsPerStrip" },
534 { TIFFTAG_STRIPBYTECOUNTS
, "StripByteCounts" },
535 { TIFFTAG_MINSAMPLEVALUE
, "MinSampleValue" },
536 { TIFFTAG_MAXSAMPLEVALUE
, "MaxSampleValue" },
537 { TIFFTAG_XRESOLUTION
, "XResolution" },
538 { TIFFTAG_YRESOLUTION
, "YResolution" },
539 { TIFFTAG_PLANARCONFIG
, "PlanarConfig" },
540 { TIFFTAG_PAGENAME
, "PageName" },
541 { TIFFTAG_XPOSITION
, "XPosition" },
542 { TIFFTAG_YPOSITION
, "YPosition" },
543 { TIFFTAG_FREEOFFSETS
, "FreeOffsets" },
544 { TIFFTAG_FREEBYTECOUNTS
, "FreeByteCounts" },
545 { TIFFTAG_GRAYRESPONSEUNIT
, "GrayResponseUnit" },
546 { TIFFTAG_GRAYRESPONSECURVE
,"GrayResponseCurve" },
547 { TIFFTAG_GROUP3OPTIONS
, "Group3Options" },
548 { TIFFTAG_GROUP4OPTIONS
, "Group4Options" },
549 { TIFFTAG_RESOLUTIONUNIT
, "ResolutionUnit" },
550 { TIFFTAG_PAGENUMBER
, "PageNumber" },
551 { TIFFTAG_COLORRESPONSEUNIT
,"ColorResponseUnit" },
552 { TIFFTAG_TRANSFERFUNCTION
, "TransferFunction" },
553 { TIFFTAG_SOFTWARE
, "Software" },
554 { TIFFTAG_DATETIME
, "DateTime" },
555 { TIFFTAG_ARTIST
, "Artist" },
556 { TIFFTAG_HOSTCOMPUTER
, "HostComputer" },
557 { TIFFTAG_PREDICTOR
, "Predictor" },
558 { TIFFTAG_WHITEPOINT
, "Whitepoint" },
559 { TIFFTAG_PRIMARYCHROMATICITIES
,"PrimaryChromaticities" },
560 { TIFFTAG_COLORMAP
, "Colormap" },
561 { TIFFTAG_HALFTONEHINTS
, "HalftoneHints" },
562 { TIFFTAG_TILEWIDTH
, "TileWidth" },
563 { TIFFTAG_TILELENGTH
, "TileLength" },
564 { TIFFTAG_TILEOFFSETS
, "TileOffsets" },
565 { TIFFTAG_TILEBYTECOUNTS
, "TileByteCounts" },
566 { TIFFTAG_BADFAXLINES
, "BadFaxLines" },
567 { TIFFTAG_CLEANFAXDATA
, "CleanFaxData" },
568 { TIFFTAG_CONSECUTIVEBADFAXLINES
, "ConsecutiveBadFaxLines" },
569 { TIFFTAG_SUBIFD
, "SubIFD" },
570 { TIFFTAG_INKSET
, "InkSet" },
571 { TIFFTAG_INKNAMES
, "InkNames" },
572 { TIFFTAG_NUMBEROFINKS
, "NumberOfInks" },
573 { TIFFTAG_DOTRANGE
, "DotRange" },
574 { TIFFTAG_TARGETPRINTER
, "TargetPrinter" },
575 { TIFFTAG_EXTRASAMPLES
, "ExtraSamples" },
576 { TIFFTAG_SAMPLEFORMAT
, "SampleFormat" },
577 { TIFFTAG_SMINSAMPLEVALUE
, "SMinSampleValue" },
578 { TIFFTAG_SMAXSAMPLEVALUE
, "SMaxSampleValue" },
579 { TIFFTAG_JPEGPROC
, "JPEGProcessingMode" },
580 { TIFFTAG_JPEGIFOFFSET
, "JPEGInterchangeFormat" },
581 { TIFFTAG_JPEGIFBYTECOUNT
, "JPEGInterchangeFormatLength" },
582 { TIFFTAG_JPEGRESTARTINTERVAL
,"JPEGRestartInterval" },
583 { TIFFTAG_JPEGLOSSLESSPREDICTORS
,"JPEGLosslessPredictors" },
584 { TIFFTAG_JPEGPOINTTRANSFORM
,"JPEGPointTransform" },
585 { TIFFTAG_JPEGTABLES
, "JPEGTables" },
586 { TIFFTAG_JPEGQTABLES
, "JPEGQTables" },
587 { TIFFTAG_JPEGDCTABLES
, "JPEGDCTables" },
588 { TIFFTAG_JPEGACTABLES
, "JPEGACTables" },
589 { TIFFTAG_YCBCRCOEFFICIENTS
,"YCbCrCoefficients" },
590 { TIFFTAG_YCBCRSUBSAMPLING
, "YCbCrSubsampling" },
591 { TIFFTAG_YCBCRPOSITIONING
, "YCbCrPositioning" },
592 { TIFFTAG_REFERENCEBLACKWHITE
, "ReferenceBlackWhite" },
593 { TIFFTAG_REFPTS
, "IgReferencePoints (Island Graphics)" },
594 { TIFFTAG_REGIONTACKPOINT
, "IgRegionTackPoint (Island Graphics)" },
595 { TIFFTAG_REGIONWARPCORNERS
,"IgRegionWarpCorners (Island Graphics)" },
596 { TIFFTAG_REGIONAFFINE
, "IgRegionAffine (Island Graphics)" },
597 { TIFFTAG_MATTEING
, "OBSOLETE Matteing (Silicon Graphics)" },
598 { TIFFTAG_DATATYPE
, "OBSOLETE DataType (Silicon Graphics)" },
599 { TIFFTAG_IMAGEDEPTH
, "ImageDepth (Silicon Graphics)" },
600 { TIFFTAG_TILEDEPTH
, "TileDepth (Silicon Graphics)" },
601 { 32768, "OLD BOGUS Matteing tag" },
602 { TIFFTAG_COPYRIGHT
, "Copyright" },
603 { TIFFTAG_ICCPROFILE
, "ICC Profile" },
604 { TIFFTAG_JBIGOPTIONS
, "JBIG Options" },
605 { TIFFTAG_STONITS
, "StoNits" },
607 #define NTAGS (sizeof (tagnames) / sizeof (tagnames[0]))
610 PrintTag(FILE* fd
, uint16 tag
)
612 const struct tagname
*tp
;
614 for (tp
= tagnames
; tp
< &tagnames
[NTAGS
]; tp
++)
615 if (tp
->tag
== tag
) {
616 fprintf(fd
, "%s (%u)", tp
->name
, tag
);
619 fprintf(fd
, "%u (%#x)", tag
, tag
);
623 PrintType(FILE* fd
, uint16 type
)
625 static const char *typenames
[] = {
646 #define NTYPES (sizeof (typenames) / sizeof (typenames[0]))
649 fprintf(fd
, "%s (%u)", typenames
[type
], type
);
651 fprintf(fd
, "%u (%#x)", type
, type
);
658 PrintASCII(FILE* fd
, uint32 cc
, const unsigned char* cp
)
660 for (; cc
> 0; cc
--, cp
++) {
667 for (tp
= "\tt\bb\rr\nn\vv"; *tp
; tp
++)
671 fprintf(fd
, "\\%c", *tp
);
673 fprintf(fd
, "\\%03o", *cp
);
680 PrintData(FILE* fd
, uint16 type
, uint32 count
, unsigned char* data
)
687 fprintf(fd
, bytefmt
, sep
, *data
++), sep
= " ";
691 fprintf(fd
, sbytefmt
, sep
, *(char *)data
++), sep
= " ";
695 fprintf(fd
, bytefmt
, sep
, *data
++), sep
= " ";
698 PrintASCII(fd
, count
, data
);
701 uint16
*wp
= (uint16
*)data
;
703 fprintf(fd
, shortfmt
, sep
, *wp
++), sep
= " ";
707 int16
*wp
= (int16
*)data
;
709 fprintf(fd
, sshortfmt
, sep
, *wp
++), sep
= " ";
713 uint32
*lp
= (uint32
*)data
;
714 while (count
-- > 0) {
715 fprintf(fd
, longfmt
, sep
, (unsigned long) *lp
++);
721 int32
*lp
= (int32
*)data
;
723 fprintf(fd
, slongfmt
, sep
, (long) *lp
++), sep
= " ";
727 uint64
*llp
= (uint64
*)data
;
728 while (count
-- > 0) {
729 #if defined(__WIN32__) && defined(_MSC_VER)
730 fprintf(fd
, long8fmt
, sep
, (unsigned __int64
) *llp
++);
732 fprintf(fd
, long8fmt
, sep
, (unsigned long long) *llp
++);
739 int64
*llp
= (int64
*)data
;
741 #if defined(__WIN32__) && defined(_MSC_VER)
742 fprintf(fd
, slong8fmt
, sep
, (__int64
) *llp
++), sep
= " ";
744 fprintf(fd
, slong8fmt
, sep
, (long long) *llp
++), sep
= " ";
748 case TIFF_RATIONAL
: {
749 uint32
*lp
= (uint32
*)data
;
750 while (count
-- > 0) {
752 fprintf(fd
, "%sNan (%lu/%lu)", sep
,
753 (unsigned long) lp
[0],
754 (unsigned long) lp
[1]);
756 fprintf(fd
, rationalfmt
, sep
,
757 (double)lp
[0] / (double)lp
[1]);
763 case TIFF_SRATIONAL
: {
764 int32
*lp
= (int32
*)data
;
765 while (count
-- > 0) {
767 fprintf(fd
, "%sNan (%ld/%ld)", sep
,
768 (long) lp
[0], (long) lp
[1]);
770 fprintf(fd
, srationalfmt
, sep
,
771 (double)lp
[0] / (double)lp
[1]);
778 float *fp
= (float *)data
;
780 fprintf(fd
, floatfmt
, sep
, *fp
++), sep
= " ";
784 double *dp
= (double *)data
;
786 fprintf(fd
, doublefmt
, sep
, *dp
++), sep
= " ";
790 uint32
*lp
= (uint32
*)data
;
791 while (count
-- > 0) {
792 fprintf(fd
, ifdfmt
, sep
, (unsigned long) *lp
++);
798 uint64
*llp
= (uint64
*)data
;
799 while (count
-- > 0) {
800 #if defined(__WIN32__) && defined(_MSC_VER)
801 fprintf(fd
, ifd8fmt
, sep
, (unsigned __int64
) *llp
++);
803 fprintf(fd
, ifd8fmt
, sep
, (unsigned long long) *llp
++);
813 ReadError(char* what
)
815 Fatal("Error while reading %s", what
);
821 vError(FILE* fd
, const char* fmt
, va_list ap
)
823 fprintf(fd
, "%s: ", curfile
);
824 vfprintf(fd
, fmt
, ap
);
829 Error(const char* fmt
, ...)
833 vError(stderr
, fmt
, ap
);
838 Fatal(const char* fmt
, ...)
842 vError(stderr
, fmt
, ap
);
847 /* vim: set ts=8 sts=8 sw=8 noet: */