void _TIFFSetDefaultCompressionState(TIFF* tif);
static const long typemask[13] = {
- 0L, /* TIFF_NOTYPE */
- 0x000000ffL, /* TIFF_BYTE */
- 0xffffffffL, /* TIFF_ASCII */
- 0x0000ffffL, /* TIFF_SHORT */
- 0xffffffffL, /* TIFF_LONG */
- 0xffffffffL, /* TIFF_RATIONAL */
- 0x000000ffL, /* TIFF_SBYTE */
- 0x000000ffL, /* TIFF_UNDEFINED */
- 0x0000ffffL, /* TIFF_SSHORT */
- 0xffffffffL, /* TIFF_SLONG */
- 0xffffffffL, /* TIFF_SRATIONAL */
- 0xffffffffL, /* TIFF_FLOAT */
- 0xffffffffL, /* TIFF_DOUBLE */
+ (long)0L, /* TIFF_NOTYPE */
+ (long)0x000000ffL, /* TIFF_BYTE */
+ (long)0xffffffffL, /* TIFF_ASCII */
+ (long)0x0000ffffL, /* TIFF_SHORT */
+ (long)0xffffffffL, /* TIFF_LONG */
+ (long)0xffffffffL, /* TIFF_RATIONAL */
+ (long)0x000000ffL, /* TIFF_SBYTE */
+ (long)0x000000ffL, /* TIFF_UNDEFINED */
+ (long)0x0000ffffL, /* TIFF_SSHORT */
+ (long)0xffffffffL, /* TIFF_SLONG */
+ (long)0xffffffffL, /* TIFF_SRATIONAL */
+ (long)0xffffffffL, /* TIFF_FLOAT */
+ (long)0xffffffffL, /* TIFF_DOUBLE */
};
static const int bigTypeshift[13] = {
0, /* TIFF_NOTYPE */
tif->tif_curstrip = (tstrip_t) -1; /* invalid strip */
tif->tif_row = (uint32) -1; /* read/write pre-increment */
tif->tif_clientdata = clientdata;
+ if (!readproc || !writeproc || !seekproc || !closeproc
+ || !sizeproc || !mapproc || !unmapproc) {
+ TIFFError(module, "One of the client procedures are NULL pointer");
+ goto bad3;
+ }
tif->tif_readproc = readproc;
tif->tif_writeproc = writeproc;
tif->tif_seekproc = seekproc;
* a file is opened read-only.
*/
tif->tif_flags = FILLORDER_MSB2LSB;
- if (m == O_RDONLY)
+ if (m == O_RDONLY )
+ tif->tif_flags |= TIFF_MAPPED;
+
#ifdef STRIPCHOP_DEFAULT
- tif->tif_flags |= TIFF_MAPPED|STRIPCHOP_DEFAULT;
-#else
- tif->tif_flags |= TIFF_MAPPED;
+ if (m == O_RDONLY || m == O_RDWR)
+ tif->tif_flags |= STRIPCHOP_DEFAULT;
#endif
{ union { int32 i; char c[4]; } u; u.i = 1; bigendian = u.c[0] == 0; }
* The 'L', 'B', and 'H' flags are intended for applications
* that can optimize operations on data by using a particular
* bit order. By default the library returns data in MSB2LSB
- * bit order for compatibiltiy with older versions of this
+ * bit order for compatibility with older versions of this
* library. Returning data in the bit order of the native cpu
* makes the most sense but also requires applications to check
* the value of the FillOrder tag; something they probabyl do
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabShort(&tif->tif_header.tiff_version);
tif->tif_header.tiff_diroff = 0; /* filled in later */
+
+ /*
+ * This seek shouldn't be necessary, but I have had some
+ * crazy problems with a failed fseek() on Solaris leaving
+ * the current file pointer out of whack when an fwrite()
+ * is done.
+ */
+ TIFFSeekFile( tif, 0, SEEK_SET );
+
if (!WriteOK(tif, &tif->tif_header, sizeof (TIFFHeader))) {
TIFFError(name, "Error writing TIFF header");
goto bad;
if (!TIFFDefaultDirectory(tif))
goto bad;
tif->tif_diroff = 0;
+ tif->tif_dirlist = NULL;
+ tif->tif_dirnumber = 0;
return (tif);
}
/*
return ((TIFF*)0);
bad2:
(void) (*closeproc)(clientdata);
+bad3:
return ((TIFF*)0);
}