]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Support libtiff 4.0
authorAidan Van Dyk <mountie@cherry.home.highrise.ca>
Wed, 4 Apr 2012 00:07:11 +0000 (20:07 -0400)
committerAidan Van Dyk <mountie@cherry.home.highrise.ca>
Wed, 4 Apr 2012 01:18:29 +0000 (21:18 -0400)
libtiff 4.0 changed a few things:
- no more TIFFDirEntry
- Moved to "Classic" vs "Big" tiffs, so renamed some things
- Moved to 64-bit types for bytecounts/offsets

configure
faxd/Class1Send.c++
faxd/Class2Send.c++
faxd/FaxModem.h
faxd/choptest.c++
faxd/cqtest.c++
faxd/faxQueueApp.c++
faxd/tagtest.c++
hfaxd/FileTransfer.c++

index c6976fdb23ecf8ecaeed808f65d2dc745c72dfdf..8f591b554c46ce2fc3e8334225e88ba8851f7f09 100755 (executable)
--- a/configure
+++ b/configure
@@ -2523,13 +2523,18 @@ getConfigTag()
 }
 
 #
-# Check if TIFF library is compatible. If successful,
-# set $tiff_runlen_t on exit to "uint16" or "uint32"
+# Check if TIFF library is compatible, checking:
+#   $tiff_runlen_t: "uint16" or "uint32"
+#   $tiff_offset_t: "uint32" or "uint64"
+#   $tiff_bytecount_t: "uint32" or "uint64"
+#   "Classic" structure names
 #
 CheckLibtiff()
 {
     Note "... checking TIFF library version"
     tiff_runlen_t=""
+    tiff_offset_t=""
+    tiff_bytecount_t=""
     cat>t.c<<EOF
 #include <stdio.h>
 #include "tiffio.h"
@@ -2550,8 +2555,21 @@ EOF
        Note "  Found libtiff version ${lib_ver}"
        if [ ${header_ver} -ge 19960307 ]; then
            case ${lib_ver} in
-               3.4)            tiff_runlen_t="uint16" ;;
-               3.[56789])      tiff_runlen_t="uint32" ;;
+               3.4)            tiff_runlen_t="uint16"
+                               tiff_offset_t="uint32"
+                               tiff_bytecount_t="uint32"
+                               ;;
+               3.[56789])      tiff_runlen_t="uint32"
+                               tiff_offset_t="uint32"
+                               tiff_bytecount_t="uint32"
+                               ;;
+               4.[0])          tiff_runlen_t="uint32"
+                               tiff_offset_t="uint64"
+                               tiff_bytecount_t="uint64"
+                               echo '#define TIFFHeader        TIFFHeaderClassic'
+                               echo '#define TIFF_VERSION      TIFF_VERSION_CLASSIC'
+                               echo '#define NEED_TIFFDIRENTRY'
+                               ;;
            esac
        fi
     else
@@ -2581,6 +2599,8 @@ EOF
     fi
     if [ "${tiff_runlen_t}" != "" ]; then
        export tiff_runlen_t
+       export tiff_offset_t
+       export tiff_bytecount_t
        return 0
     else
        cat 1>&2 <<EOF
@@ -3175,8 +3195,10 @@ BuildPortDotH()
     fi
     CheckTermioFuncDecls termios.h
     if CheckLibtiff; then
-       Note "... add declaration for tiff_runlen_t"
+       Note "... add declaration for tiff compatibility"
        echo "#define tiff_runlen_t ${tiff_runlen_t}"
+       echo "#define tiff_offset_t ${tiff_offset_t}"
+       echo "#define tiff_bytecount_t ${tiff_bytecount_t}"
     fi
     if [ "x$LIBPAM" != "x" ]; then
        CheckPAMType
index ff0019093dd08aa850e700349dd20f342bf37cae..92ba13b42c4ce24bb3a0fee918ce3ab7f264034b 100644 (file)
@@ -1776,7 +1776,7 @@ Class1Modem::sendPage(TIFF* tif, Class2Params& params, u_int pageChop, u_int ppm
         * Calculate total amount of space needed to read
         * the image into memory (in its encoded format).
         */
-       uint32* stripbytecount;
+       tiff_bytecount_t* stripbytecount;
        (void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecount);
        tstrip_t strip;
        u_long totdata = 0;
index 818b1387612b6c20201c65d947bb579f1ced4d34..8379e381380a0d7c061fb8431a9b3248ae89222c 100644 (file)
@@ -473,7 +473,7 @@ Class2Modem::sendPageData(TIFF* tif, u_int pageChop, bool cover)
         * Calculate total amount of space needed to read
         * the image into memory (in its encoded format).
         */
-       uint32* stripbytecount;
+       tiff_bytecount_t* stripbytecount;
        (void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecount);
        tstrip_t strip;
        u_long totdata = 0;
index 0e21ada039ceb5c6dd2a208977ce416a00b1a0c6..4090ebe81bf55870137c238f220859f4040bb730 100644 (file)
@@ -83,7 +83,7 @@ private:
     u_char*    recvRow;        // current receive row raster
     u_char*    recvPageStart;  // pointer to start of page buffer
     u_long*    savedWriteOff;  // file offset at start of page data
-    u_long*    savedStripByteCounts;   // byte counts at start of page data
+    tiff_bytecount_t*  savedStripByteCounts;   // byte counts at start of page data
     int                decodedPixels;  // number of pixels decoded with error
     int                decoderFd[2];   // file descriptors for the decoder pipe
     int                counterFd[2];   // file descriptors for the counter pipe
index b1786cee28e031f73ee7635afc56a65a707a9250..e924b6809e15f5518cf4f80f27e0abb04c185af7 100644 (file)
@@ -120,7 +120,7 @@ main(int argc, char* argv[])
 
            uint16 fillorder;
            TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder);
-           uint32* stripbytecount;
+           tiff_bytecount_t* stripbytecount;
            (void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecount);
 
            u_int totbytes = (u_int) stripbytecount[0];
index 9757a3801a12b872da54c248313434f528e3c35f..94f76bc6b541075329a292ff8231e6efd144077f 100644 (file)
@@ -565,7 +565,7 @@ main(int argc, char* argv[])
 
        cq.recvSetupTIFF(tifout, 0, cq.recvFillOrder, params);
 
-       uint32* stripbytecount;
+       tiff_bytecount_t* stripbytecount;
        (void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecount);
        for (u_int strip = 0; strip < TIFFNumberOfStrips(tif); strip++) {
            u_int totbytes = (u_int) stripbytecount[strip];
index 96a508e4c577bb9b2f23760f0a5ce34af18cced7..279ecc610e979ef06f8fcb51d7fd69ff8e0ed740 100644 (file)
@@ -1046,7 +1046,7 @@ faxQueueApp::preparePageChop(const FaxRequest& req,
     TIFF* tif, const Class2Params& params, fxStr& pagehandling)
 {
     tstrip_t s = TIFFNumberOfStrips(tif)-1;
-    uint32* stripbytecount;
+    tiff_bytecount_t* stripbytecount;
     (void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecount);
     u_int stripSize = (u_int) stripbytecount[s];
     if (stripSize == 0)
index bd1a0216916b01ba782e28bc8566f9445ba5ea16..5dbd23fd70521c9dc0c711da1c88f98e542e74f8 100644 (file)
@@ -522,7 +522,7 @@ main(int argc, char* argv[])
 
        uint16 fillorder;
        TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder);
-       uint32* stripbytecount;
+       tiff_bytecount_t* stripbytecount;
        (void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecount);
 
        bool firstStrip = setupTagLineSlop(params);
index cc855e5c5898d33b93a737dd5a7fc78540d6152d..8cc4cd0cefccf16b56330a151eb6347238397abf 100644 (file)
 #endif /* CHAR_BIT */
 
 
+#ifdef NEED_TIFFDIRENTRY
+/*
+ * we don't pass these to libtiff anywhere, but HylaFAX uses it to keep track
+ * of the info it has read from the TIFFGetField functions when constructin
+ * and writing a single-directory TIFF FILE read from an existing TIFF fax.
+ */
+typedef struct {
+       uint16          tdir_tag;
+       uint16          tdir_type;      /* data type */
+       uint32          tdir_count;     /* number of items; length in spec */
+       uint32          tdir_offset;    /* byte offset to field data */
+} TIFFDirEntry;
+#endif
+
+
 static struct {
     const char*        name;           // protocol token name
     bool       supported;      // true if format is supported
@@ -226,7 +241,7 @@ HylaFAXServer::retrievePageCmd(const char* name)
                 * amount of image data and then adding in
                 * the expected data for the TIFF headers.
                 */
-               uint32* sb;
+               tiff_bytecount_t* sb;
                TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &sb);
                file_size = sizeof (DirTemplate) +
                    sizeof (TIFFHeader) + sizeof (uint16);
@@ -441,7 +456,7 @@ HylaFAXServer::sendTIFFHeader(TIFF* tif, int fdout)
 bool
 HylaFAXServer::sendITIFFData(TIFF* tif, int fdout)
 {
-    uint32* sb;
+    tiff_bytecount_t* sb;
     (void) TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &sb);
     tdata_t buf = _TIFFmalloc(sb[0]);
     tsize_t bsize = sb[0];