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>
54 extern int getopt(int, char**, char*);
65 TIFFHeaderClassic classic
;
67 TIFFHeaderCommon common
;
74 uint32 maxitems
= 24; /* maximum indirect data items to print */
76 const char* bytefmt
= "%s%#02x"; /* BYTE */
77 const char* sbytefmt
= "%s%d"; /* SBYTE */
78 const char* shortfmt
= "%s%u"; /* SHORT */
79 const char* sshortfmt
= "%s%d"; /* SSHORT */
80 const char* longfmt
= "%s%lu"; /* LONG */
81 const char* slongfmt
= "%s%ld"; /* SLONG */
82 const char* ifdfmt
= "%s%#04lx"; /* IFD offset */
83 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
84 const char* long8fmt
= "%s%I64u"; /* LONG8 */
85 const char* slong8fmt
= "%s%I64d"; /* SLONG8 */
86 const char* ifd8fmt
= "%s%#08I64x"; /* IFD offset8*/
88 const char* long8fmt
= "%s%llu"; /* LONG8 */
89 const char* slong8fmt
= "%s%lld"; /* SLONG8 */
90 const char* ifd8fmt
= "%s%#08llx"; /* IFD offset8*/
92 const char* rationalfmt
= "%s%g"; /* RATIONAL */
93 const char* srationalfmt
= "%s%g"; /* SRATIONAL */
94 const char* floatfmt
= "%s%g"; /* FLOAT */
95 const char* doublefmt
= "%s%g"; /* DOUBLE */
97 static void dump(int, uint64
);
104 fprintf(stderr
, "usage: %s [-h] [-o offset] [-m maxitems] file.tif ...\n", appname
);
109 main(int argc
, char* argv
[])
112 int multiplefiles
= (argc
> 1);
115 bigendian
= (*(char *)&one
== 0);
118 while ((c
= getopt(argc
, argv
, "m:o:h")) != -1) {
120 case 'h': /* print values in hex */
127 diroff
= (uint64
) strtoul(optarg
, NULL
, 0);
130 maxitems
= strtoul(optarg
, NULL
, 0);
138 for (; optind
< argc
; optind
++) {
139 fd
= open(argv
[optind
], O_RDONLY
|O_BINARY
, 0);
145 printf("%s:\n", argv
[optind
]);
146 curfile
= argv
[optind
];
155 #define ord(e) ((int)e)
157 static uint64
ReadDirectory(int, unsigned, uint64
);
158 static void ReadError(char*);
159 static void Error(const char*, ...);
160 static void Fatal(const char*, ...);
163 dump(int fd
, uint64 diroff
)
167 lseek(fd
, (off_t
) 0, 0);
168 if (read(fd
, (char*) &hdr
, sizeof (TIFFHeaderCommon
)) != sizeof (TIFFHeaderCommon
))
169 ReadError("TIFF header");
170 if (hdr
.common
.tiff_magic
!= TIFF_BIGENDIAN
171 && hdr
.common
.tiff_magic
!= TIFF_LITTLEENDIAN
&&
173 /* MDI is sensitive to the host byte order, unlike TIFF */
174 MDI_BIGENDIAN
!= hdr
.common
.tiff_magic
176 MDI_LITTLEENDIAN
!= hdr
.common
.tiff_magic
179 Fatal("Not a TIFF or MDI file, bad magic number %u (%#x)",
180 hdr
.common
.tiff_magic
, hdr
.common
.tiff_magic
);
182 if (hdr
.common
.tiff_magic
== TIFF_BIGENDIAN
183 || hdr
.common
.tiff_magic
== MDI_BIGENDIAN
)
184 swabflag
= !bigendian
;
186 swabflag
= bigendian
;
188 TIFFSwabShort(&hdr
.common
.tiff_version
);
189 if (hdr
.common
.tiff_version
==42)
191 if (read(fd
, (char*) &hdr
.classic
.tiff_diroff
, 4) != 4)
192 ReadError("TIFF header");
194 TIFFSwabLong(&hdr
.classic
.tiff_diroff
);
195 printf("Magic: %#x <%s-endian> Version: %#x <%s>\n",
196 hdr
.classic
.tiff_magic
,
197 hdr
.classic
.tiff_magic
== TIFF_BIGENDIAN
? "big" : "little",
200 diroff
= hdr
.classic
.tiff_diroff
;
202 else if (hdr
.common
.tiff_version
==43)
204 if (read(fd
, (char*) &hdr
.big
.tiff_offsetsize
, 12) != 12)
205 ReadError("TIFF header");
208 TIFFSwabShort(&hdr
.big
.tiff_offsetsize
);
209 TIFFSwabShort(&hdr
.big
.tiff_unused
);
210 TIFFSwabLong8(&hdr
.big
.tiff_diroff
);
212 printf("Magic: %#x <%s-endian> Version: %#x <%s>\n",
214 hdr
.big
.tiff_magic
== TIFF_BIGENDIAN
? "big" : "little",
216 printf("OffsetSize: %#x Unused: %#x\n",
217 hdr
.big
.tiff_offsetsize
,hdr
.big
.tiff_unused
);
219 diroff
= hdr
.big
.tiff_diroff
;
223 Fatal("Not a TIFF file, bad version number %u (%#x)",
224 hdr
.common
.tiff_version
, hdr
.common
.tiff_version
);
225 for (i
= 0; diroff
!= 0; i
++) {
228 diroff
= ReadDirectory(fd
, i
, diroff
);
232 static const int datawidth
[] = {
233 0, /* 00 = undefined */
234 1, /* 01 = TIFF_BYTE */
235 1, /* 02 = TIFF_ASCII */
236 2, /* 03 = TIFF_SHORT */
237 4, /* 04 = TIFF_LONG */
238 8, /* 05 = TIFF_RATIONAL */
239 1, /* 06 = TIFF_SBYTE */
240 1, /* 07 = TIFF_UNDEFINED */
241 2, /* 08 = TIFF_SSHORT */
242 4, /* 09 = TIFF_SLONG */
243 8, /* 10 = TIFF_SRATIONAL */
244 4, /* 11 = TIFF_FLOAT */
245 8, /* 12 = TIFF_DOUBLE */
246 4, /* 13 = TIFF_IFD */
247 0, /* 14 = undefined */
248 0, /* 15 = undefined */
249 8, /* 16 = TIFF_LONG8 */
250 8, /* 17 = TIFF_SLONG8 */
251 8, /* 18 = TIFF_IFD8 */
253 #define NWIDTHS (sizeof (datawidth) / sizeof (datawidth[0]))
254 static void PrintTag(FILE*, uint16
);
255 static void PrintType(FILE*, uint16
);
256 static void PrintData(FILE*, uint16
, uint32
, unsigned char*);
259 * Read the next TIFF directory from a file
260 * and convert it to the internal format.
261 * We read directories sequentially.
264 ReadDirectory(int fd
, unsigned int ix
, uint64 off
)
269 uint64 nextdiroff
= 0;
273 if (off
== 0) /* no more directories */
275 #if defined(__WIN32__) && defined(_MSC_VER)
276 if (_lseeki64(fd
, (__int64
)off
, SEEK_SET
) != (__int64
)off
) {
278 if (lseek(fd
, (off_t
)off
, SEEK_SET
) != (off_t
)off
) {
280 Fatal("Seek error accessing TIFF directory");
284 if (read(fd
, (char*) &dircount
, sizeof (uint16
)) != sizeof (uint16
)) {
285 ReadError("directory count");
289 TIFFSwabShort(&dircount
);
292 uint64 dircount64
= 0;
293 if (read(fd
, (char*) &dircount64
, sizeof (uint64
)) != sizeof (uint64
)) {
294 ReadError("directory count");
298 TIFFSwabLong8(&dircount64
);
299 if (dircount64
>0xFFFF) {
300 Error("Sanity check on directory count failed");
303 dircount
= (uint16
)dircount64
;
306 dirmem
= _TIFFmalloc(dircount
* direntrysize
);
307 if (dirmem
== NULL
) {
308 Fatal("No space for TIFF directory");
311 n
= read(fd
, (char*) dirmem
, dircount
*direntrysize
);
312 if (n
!= dircount
*direntrysize
) {
315 #if defined(__WIN32__) && defined(_MSC_VER)
316 "Could only read %lu of %u entries in directory at offset %#I64x",
317 (unsigned long)n
, dircount
, (unsigned __int64
) off
);
319 "Could only read %lu of %u entries in directory at offset %#llx",
320 (unsigned long)n
, dircount
, (unsigned long long) off
);
327 if (read(fd
, (char*) &nextdiroff32
, sizeof (uint32
)) != sizeof (uint32
))
330 TIFFSwabLong(&nextdiroff32
);
331 nextdiroff
= nextdiroff32
;
333 if (read(fd
, (char*) &nextdiroff
, sizeof (uint64
)) != sizeof (uint64
))
336 TIFFSwabLong8(&nextdiroff
);
339 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
340 printf("Directory %u: offset %I64u (%#I64x) next %I64u (%#I64x)\n", ix
,
341 (unsigned __int64
)off
, (unsigned __int64
)off
,
342 (unsigned __int64
)nextdiroff
, (unsigned __int64
)nextdiroff
);
344 printf("Directory %u: offset %llu (%#llx) next %llu (%#llx)\n", ix
,
345 (unsigned long long)off
, (unsigned long long)off
,
346 (unsigned long long)nextdiroff
, (unsigned long long)nextdiroff
);
348 for (dp
= (uint8
*)dirmem
, n
= dircount
; n
> 0; n
--) {
361 dp
+= sizeof(uint16
);
363 dp
+= sizeof(uint16
);
365 TIFFSwabShort(&type
);
366 PrintTag(stdout
, tag
);
368 PrintType(stdout
, type
);
373 count32
= *(uint32
*)dp
;
375 TIFFSwabLong(&count32
);
376 dp
+= sizeof(uint32
);
381 count
= *(uint64
*)dp
;
383 TIFFSwabLong8(&count
);
384 dp
+= sizeof(uint64
);
386 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
387 printf("%I64u<", (unsigned __int64
)count
);
389 printf("%llu<", (unsigned long long)count
);
394 typewidth
= datawidth
[type
];
395 datasize
= count
*typewidth
;
407 dataoffset32
= *(uint32
*)dp
;
409 TIFFSwabLong(&dataoffset32
);
410 dataoffset
= dataoffset32
;
412 dp
+= sizeof(uint32
);
420 dataoffset
= *(uint64
*)dp
;
422 TIFFSwabLong8(&dataoffset
);
424 dp
+= sizeof(uint64
);
426 if (datasize
>0x10000)
429 count
= 0x10000/typewidth
;
430 datasize
= count
*typewidth
;
436 datasize
= count
*typewidth
;
440 datamem
= _TIFFmalloc((uint32
)datasize
);
442 #if defined(__WIN32__) && defined(_MSC_VER)
443 if (_lseeki64(fd
, (__int64
)dataoffset
, SEEK_SET
)
444 != (__int64
)dataoffset
)
446 if (lseek(fd
, (off_t
)dataoffset
, 0) !=
451 "Seek error accessing tag %u value", tag
);
455 if (read(fd
, datamem
, (size_t)datasize
) != (TIFF_SSIZE_T
)datasize
)
458 "Read error accessing tag %u value", tag
);
463 Error("No space for data for tag %u",tag
);
478 TIFFSwabArrayOfShort((uint16
*)datamem
,(tmsize_t
)count
);
484 TIFFSwabArrayOfLong((uint32
*)datamem
,(tmsize_t
)count
);
488 TIFFSwabArrayOfLong((uint32
*)datamem
,(tmsize_t
)count
*2);
494 TIFFSwabArrayOfLong8((uint64
*)datamem
,(tmsize_t
)count
);
498 PrintData(stdout
,type
,(uint32
)count
,datamem
);
508 _TIFFfree((char *)dirmem
);
512 static const struct tagname
{
516 { TIFFTAG_SUBFILETYPE
, "SubFileType" },
517 { TIFFTAG_OSUBFILETYPE
, "OldSubFileType" },
518 { TIFFTAG_IMAGEWIDTH
, "ImageWidth" },
519 { TIFFTAG_IMAGELENGTH
, "ImageLength" },
520 { TIFFTAG_BITSPERSAMPLE
, "BitsPerSample" },
521 { TIFFTAG_COMPRESSION
, "Compression" },
522 { TIFFTAG_PHOTOMETRIC
, "Photometric" },
523 { TIFFTAG_THRESHHOLDING
, "Threshholding" },
524 { TIFFTAG_CELLWIDTH
, "CellWidth" },
525 { TIFFTAG_CELLLENGTH
, "CellLength" },
526 { TIFFTAG_FILLORDER
, "FillOrder" },
527 { TIFFTAG_DOCUMENTNAME
, "DocumentName" },
528 { TIFFTAG_IMAGEDESCRIPTION
, "ImageDescription" },
529 { TIFFTAG_MAKE
, "Make" },
530 { TIFFTAG_MODEL
, "Model" },
531 { TIFFTAG_STRIPOFFSETS
, "StripOffsets" },
532 { TIFFTAG_ORIENTATION
, "Orientation" },
533 { TIFFTAG_SAMPLESPERPIXEL
, "SamplesPerPixel" },
534 { TIFFTAG_ROWSPERSTRIP
, "RowsPerStrip" },
535 { TIFFTAG_STRIPBYTECOUNTS
, "StripByteCounts" },
536 { TIFFTAG_MINSAMPLEVALUE
, "MinSampleValue" },
537 { TIFFTAG_MAXSAMPLEVALUE
, "MaxSampleValue" },
538 { TIFFTAG_XRESOLUTION
, "XResolution" },
539 { TIFFTAG_YRESOLUTION
, "YResolution" },
540 { TIFFTAG_PLANARCONFIG
, "PlanarConfig" },
541 { TIFFTAG_PAGENAME
, "PageName" },
542 { TIFFTAG_XPOSITION
, "XPosition" },
543 { TIFFTAG_YPOSITION
, "YPosition" },
544 { TIFFTAG_FREEOFFSETS
, "FreeOffsets" },
545 { TIFFTAG_FREEBYTECOUNTS
, "FreeByteCounts" },
546 { TIFFTAG_GRAYRESPONSEUNIT
, "GrayResponseUnit" },
547 { TIFFTAG_GRAYRESPONSECURVE
,"GrayResponseCurve" },
548 { TIFFTAG_GROUP3OPTIONS
, "Group3Options" },
549 { TIFFTAG_GROUP4OPTIONS
, "Group4Options" },
550 { TIFFTAG_RESOLUTIONUNIT
, "ResolutionUnit" },
551 { TIFFTAG_PAGENUMBER
, "PageNumber" },
552 { TIFFTAG_COLORRESPONSEUNIT
,"ColorResponseUnit" },
553 { TIFFTAG_TRANSFERFUNCTION
, "TransferFunction" },
554 { TIFFTAG_SOFTWARE
, "Software" },
555 { TIFFTAG_DATETIME
, "DateTime" },
556 { TIFFTAG_ARTIST
, "Artist" },
557 { TIFFTAG_HOSTCOMPUTER
, "HostComputer" },
558 { TIFFTAG_PREDICTOR
, "Predictor" },
559 { TIFFTAG_WHITEPOINT
, "Whitepoint" },
560 { TIFFTAG_PRIMARYCHROMATICITIES
,"PrimaryChromaticities" },
561 { TIFFTAG_COLORMAP
, "Colormap" },
562 { TIFFTAG_HALFTONEHINTS
, "HalftoneHints" },
563 { TIFFTAG_TILEWIDTH
, "TileWidth" },
564 { TIFFTAG_TILELENGTH
, "TileLength" },
565 { TIFFTAG_TILEOFFSETS
, "TileOffsets" },
566 { TIFFTAG_TILEBYTECOUNTS
, "TileByteCounts" },
567 { TIFFTAG_BADFAXLINES
, "BadFaxLines" },
568 { TIFFTAG_CLEANFAXDATA
, "CleanFaxData" },
569 { TIFFTAG_CONSECUTIVEBADFAXLINES
, "ConsecutiveBadFaxLines" },
570 { TIFFTAG_SUBIFD
, "SubIFD" },
571 { TIFFTAG_INKSET
, "InkSet" },
572 { TIFFTAG_INKNAMES
, "InkNames" },
573 { TIFFTAG_NUMBEROFINKS
, "NumberOfInks" },
574 { TIFFTAG_DOTRANGE
, "DotRange" },
575 { TIFFTAG_TARGETPRINTER
, "TargetPrinter" },
576 { TIFFTAG_EXTRASAMPLES
, "ExtraSamples" },
577 { TIFFTAG_SAMPLEFORMAT
, "SampleFormat" },
578 { TIFFTAG_SMINSAMPLEVALUE
, "SMinSampleValue" },
579 { TIFFTAG_SMAXSAMPLEVALUE
, "SMaxSampleValue" },
580 { TIFFTAG_JPEGPROC
, "JPEGProcessingMode" },
581 { TIFFTAG_JPEGIFOFFSET
, "JPEGInterchangeFormat" },
582 { TIFFTAG_JPEGIFBYTECOUNT
, "JPEGInterchangeFormatLength" },
583 { TIFFTAG_JPEGRESTARTINTERVAL
,"JPEGRestartInterval" },
584 { TIFFTAG_JPEGLOSSLESSPREDICTORS
,"JPEGLosslessPredictors" },
585 { TIFFTAG_JPEGPOINTTRANSFORM
,"JPEGPointTransform" },
586 { TIFFTAG_JPEGTABLES
, "JPEGTables" },
587 { TIFFTAG_JPEGQTABLES
, "JPEGQTables" },
588 { TIFFTAG_JPEGDCTABLES
, "JPEGDCTables" },
589 { TIFFTAG_JPEGACTABLES
, "JPEGACTables" },
590 { TIFFTAG_YCBCRCOEFFICIENTS
,"YCbCrCoefficients" },
591 { TIFFTAG_YCBCRSUBSAMPLING
, "YCbCrSubsampling" },
592 { TIFFTAG_YCBCRPOSITIONING
, "YCbCrPositioning" },
593 { TIFFTAG_REFERENCEBLACKWHITE
, "ReferenceBlackWhite" },
594 { TIFFTAG_REFPTS
, "IgReferencePoints (Island Graphics)" },
595 { TIFFTAG_REGIONTACKPOINT
, "IgRegionTackPoint (Island Graphics)" },
596 { TIFFTAG_REGIONWARPCORNERS
,"IgRegionWarpCorners (Island Graphics)" },
597 { TIFFTAG_REGIONAFFINE
, "IgRegionAffine (Island Graphics)" },
598 { TIFFTAG_MATTEING
, "OBSOLETE Matteing (Silicon Graphics)" },
599 { TIFFTAG_DATATYPE
, "OBSOLETE DataType (Silicon Graphics)" },
600 { TIFFTAG_IMAGEDEPTH
, "ImageDepth (Silicon Graphics)" },
601 { TIFFTAG_TILEDEPTH
, "TileDepth (Silicon Graphics)" },
602 { 32768, "OLD BOGUS Matteing tag" },
603 { TIFFTAG_COPYRIGHT
, "Copyright" },
604 { TIFFTAG_ICCPROFILE
, "ICC Profile" },
605 { TIFFTAG_JBIGOPTIONS
, "JBIG Options" },
606 { TIFFTAG_STONITS
, "StoNits" },
608 #define NTAGS (sizeof (tagnames) / sizeof (tagnames[0]))
611 PrintTag(FILE* fd
, uint16 tag
)
613 const struct tagname
*tp
;
615 for (tp
= tagnames
; tp
< &tagnames
[NTAGS
]; tp
++)
616 if (tp
->tag
== tag
) {
617 fprintf(fd
, "%s (%u)", tp
->name
, tag
);
620 fprintf(fd
, "%u (%#x)", tag
, tag
);
624 PrintType(FILE* fd
, uint16 type
)
626 static const char *typenames
[] = {
647 #define NTYPES (sizeof (typenames) / sizeof (typenames[0]))
650 fprintf(fd
, "%s (%u)", typenames
[type
], type
);
652 fprintf(fd
, "%u (%#x)", type
, type
);
659 PrintASCII(FILE* fd
, uint32 cc
, const unsigned char* cp
)
661 for (; cc
> 0; cc
--, cp
++) {
668 for (tp
= "\tt\bb\rr\nn\vv"; *tp
; tp
++)
672 fprintf(fd
, "\\%c", *tp
);
674 fprintf(fd
, "\\%03o", *cp
);
681 PrintData(FILE* fd
, uint16 type
, uint32 count
, unsigned char* data
)
688 fprintf(fd
, bytefmt
, sep
, *data
++), sep
= " ";
692 fprintf(fd
, sbytefmt
, sep
, *(char *)data
++), sep
= " ";
696 fprintf(fd
, bytefmt
, sep
, *data
++), sep
= " ";
699 PrintASCII(fd
, count
, data
);
702 uint16
*wp
= (uint16
*)data
;
704 fprintf(fd
, shortfmt
, sep
, *wp
++), sep
= " ";
708 int16
*wp
= (int16
*)data
;
710 fprintf(fd
, sshortfmt
, sep
, *wp
++), sep
= " ";
714 uint32
*lp
= (uint32
*)data
;
715 while (count
-- > 0) {
716 fprintf(fd
, longfmt
, sep
, (unsigned long) *lp
++);
722 int32
*lp
= (int32
*)data
;
724 fprintf(fd
, slongfmt
, sep
, (long) *lp
++), sep
= " ";
728 uint64
*llp
= (uint64
*)data
;
729 while (count
-- > 0) {
730 #if defined(__WIN32__) && defined(_MSC_VER)
731 fprintf(fd
, long8fmt
, sep
, (unsigned __int64
) *llp
++);
733 fprintf(fd
, long8fmt
, sep
, (unsigned long long) *llp
++);
740 int64
*llp
= (int64
*)data
;
742 #if defined(__WIN32__) && defined(_MSC_VER)
743 fprintf(fd
, slong8fmt
, sep
, (__int64
) *llp
++), sep
= " ";
745 fprintf(fd
, slong8fmt
, sep
, (long long) *llp
++), sep
= " ";
749 case TIFF_RATIONAL
: {
750 uint32
*lp
= (uint32
*)data
;
751 while (count
-- > 0) {
753 fprintf(fd
, "%sNan (%lu/%lu)", sep
,
754 (unsigned long) lp
[0],
755 (unsigned long) lp
[1]);
757 fprintf(fd
, rationalfmt
, sep
,
758 (double)lp
[0] / (double)lp
[1]);
764 case TIFF_SRATIONAL
: {
765 int32
*lp
= (int32
*)data
;
766 while (count
-- > 0) {
768 fprintf(fd
, "%sNan (%ld/%ld)", sep
,
769 (long) lp
[0], (long) lp
[1]);
771 fprintf(fd
, srationalfmt
, sep
,
772 (double)lp
[0] / (double)lp
[1]);
779 float *fp
= (float *)data
;
781 fprintf(fd
, floatfmt
, sep
, *fp
++), sep
= " ";
785 double *dp
= (double *)data
;
787 fprintf(fd
, doublefmt
, sep
, *dp
++), sep
= " ";
791 uint32
*lp
= (uint32
*)data
;
792 while (count
-- > 0) {
793 fprintf(fd
, ifdfmt
, sep
, (unsigned long) *lp
++);
799 uint64
*llp
= (uint64
*)data
;
800 while (count
-- > 0) {
801 #if defined(__WIN32__) && defined(_MSC_VER)
802 fprintf(fd
, ifd8fmt
, sep
, (unsigned __int64
) *llp
++);
804 fprintf(fd
, ifd8fmt
, sep
, (unsigned long long) *llp
++);
814 ReadError(char* what
)
816 Fatal("Error while reading %s", what
);
822 vError(FILE* fd
, const char* fmt
, va_list ap
)
824 fprintf(fd
, "%s: ", curfile
);
825 vfprintf(fd
, fmt
, ap
);
830 Error(const char* fmt
, ...)
834 vError(stderr
, fmt
, ap
);
839 Fatal(const char* fmt
, ...)
843 vError(stderr
, fmt
, ap
);
848 /* vim: set ts=8 sts=8 sw=8 noet: */