diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 266e3fcf..bfcc3b0a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -35,6 +35,7 @@ set(TESTSCRIPTS ppm2tiff_pbm.sh ppm2tiff_pgm.sh ppm2tiff_ppm.sh + fax2tiff.sh tiffcp-g3.sh tiffcp-g3-1d.sh tiffcp-g3-1d-fill.sh @@ -151,6 +152,7 @@ set(UNCOMPRESSEDIMAGES # files which are not currently used by the tests. set(IMAGES_EXTRA_DIST images/README.txt + images/miniswhite-1c-1b.g3 ${BMPIMAGES} ${GIFIMAGES} ${PNMIMAGES} diff --git a/test/Makefile.am b/test/Makefile.am index 8992ef04..cc3fb683 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -71,6 +71,7 @@ TESTSCRIPTS = \ ppm2tiff_pbm.sh \ ppm2tiff_pgm.sh \ ppm2tiff_ppm.sh \ + fax2tiff.sh \ tiffcp-g3.sh \ tiffcp-g3-1d.sh \ tiffcp-g3-1d-fill.sh \ @@ -181,6 +182,7 @@ PNMIMAGES = \ # files which are not currently used by the tests. IMAGES_EXTRA_DIST = \ images/README.txt \ + images/miniswhite-1c-1b.g3 \ $(PNMIMAGES) \ $(TIFFIMAGES) diff --git a/test/fax2tiff.sh b/test/fax2tiff.sh new file mode 100755 index 00000000..fc0a95d7 --- /dev/null +++ b/test/fax2tiff.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Basic sanity check for fax2tiff +# +. ${srcdir:-.}/common.sh +infile="${IMAGES}/miniswhite-1c-1b.g3" +outfile="o-fax2tiff.tiff" +echo "$MEMCHECK ${FAX2TIFF} -M -o $outfile $infile" +eval "$MEMCHECK" "${FAX2TIFF}" "-M" "-o" "$outfile" "$infile" +status=$? +if [ $status != 0 ] ; then + echo "Returned failed status $status!" + echo "Output (if any) is in \"${outfile}\"." + exit $status +fi +f_tiffinfo_validate $outfile diff --git a/test/images/README.txt b/test/images/README.txt index 17f6292e..b6447d8e 100644 --- a/test/images/README.txt +++ b/test/images/README.txt @@ -27,3 +27,6 @@ PNM files: minisblack-1c-8b.pgm miniswhite-1c-1b.pbm rgb-3c-8b.ppm + +G3 Fax files : + miniswhite-1c-1b.g3 diff --git a/test/images/miniswhite-1c-1b.g3 b/test/images/miniswhite-1c-1b.g3 new file mode 100644 index 00000000..9f00ce16 Binary files /dev/null and b/test/images/miniswhite-1c-1b.g3 differ diff --git a/tools/fax2tiff.c b/tools/fax2tiff.c index 2098b2ab..21223131 100644 --- a/tools/fax2tiff.c +++ b/tools/fax2tiff.c @@ -74,14 +74,10 @@ static void usage(void); Struct to carry client data. Note that it does not appear that the client data is actually used in this program. */ -typedef struct _FAX_Client_Data +typedef union _FAX_Client_Data { -#if defined(_WIN32) && defined(USE_WIN32_FILEIO) - intptr_t fh; /* Operating system file handle */ -#else - int fd; /* Integer file descriptor */ -#endif - + thandle_t fh; /* Operating system file handle */ + int fd; /* Integer file descriptor */ } FAX_Client_Data; int @@ -89,7 +85,7 @@ main(int argc, char* argv[]) { FILE *in; TIFF *out = NULL; - FAX_Client_Data client_data; + FAX_Client_Data client_data; TIFFErrorHandler whandler = NULL; int compression_in = COMPRESSION_CCITTFAX3; int compression_out = COMPRESSION_CCITTFAX3; @@ -280,11 +276,11 @@ main(int argc, char* argv[]) continue; } #if defined(_WIN32) && defined(USE_WIN32_FILEIO) - client_data.fh = _get_osfhandle(fileno(in)); + client_data.fh = (thandle_t)_get_osfhandle(fileno(in)); #else - client_data.fd = fileno(in); + client_data.fd = fileno(in); #endif - TIFFSetClientdata(faxTIFF, (thandle_t) &client_data); + TIFFSetClientdata(faxTIFF, client_data.fh); TIFFSetFileName(faxTIFF, (const char*)argv[optind]); TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1);