diff options
Diffstat (limited to 'tiff')
312 files changed, 16747 insertions, 16332 deletions
diff --git a/tiff/CMakeLists.txt b/tiff/CMakeLists.txt index efe857df..dddbaf6a 100644 --- a/tiff/CMakeLists.txt +++ b/tiff/CMakeLists.txt @@ -2,6 +2,7 @@ # Run "cmake" to generate the build files for your platform # # Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> # Written by Roger Leigh <rleigh@codelibre.net> # # Permission to use, copy, modify, distribute, and sell this software and @@ -23,718 +24,115 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -cmake_minimum_required(VERSION 2.8.11) # b/c of use of BUILD_INTERFACE generator expression - -# Default policy is from 2.8.9 -cmake_policy(VERSION 2.8.9) -# Set MacOSX @rpath usage globally. -if (POLICY CMP0020) - cmake_policy(SET CMP0020 NEW) -endif(POLICY CMP0020) -if (POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif(POLICY CMP0042) -# Use new variable expansion policy. -if (POLICY CMP0053) - cmake_policy(SET CMP0053 NEW) -endif(POLICY CMP0053) -if (POLICY CMP0054) - cmake_policy(SET CMP0054 NEW) -endif(POLICY CMP0054) +cmake_minimum_required(VERSION 3.9.0) -# Read version information from configure.ac. -FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure REGEX "^LIBTIFF_.*=") -foreach(line ${configure}) - foreach(var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION - LIBTIFF_CURRENT LIBTIFF_REVISION LIBTIFF_AGE) - if(NOT ${var} AND line MATCHES "^${var}=(.*)") - set(${var} "${CMAKE_MATCH_1}") - break() - endif() - endforeach() -endforeach() - -math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}") -set(SO_MINOR "${LIBTIFF_AGE}") -set(SO_REVISION "${LIBTIFF_REVISION}") - -message(STATUS "Building tiff version ${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}${LIBTIFF_ALPHA_VERSION}") -message(STATUS "libtiff library version ${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}") - -set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries") - -# Project version -project(tiff C) -set(VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}") -set(tiff_VERSION "${VERSION}") -set(tiff_VERSION_MAJOR "${LIBTIFF_MAJOR_VERSION}") -set(tiff_VERSION_MINOR "${LIBTIFF_MINOR_VERSION}") -set(tiff_VERSION_PATCH "${LIBTIFF_MICRO_VERSION}") - -# the other tiff_VERSION_* variables are set automatically -set(tiff_VERSION_ALPHA "${LIBTIFF_ALPHA_VERSION}") -# Library version (unlike libtool's baroque scheme, WYSIWYG here) -set(SO_COMPATVERSION "${SO_MAJOR}") -set(SO_VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}") - -# For autotools header compatibility -set(PACKAGE_NAME "LibTIFF Software") -set(PACKAGE_TARNAME "${PROJECT_NAME}") -set(PACKAGE_VERSION "${PROJECT_VERSION}${tiff_VERSION_ALPHA}") -set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") -set(PACKAGE_BUGREPORT "tiff@lists.maptools.org") - -include(GNUInstallDirs) -include(CheckCCompilerFlag) -include(CheckCSourceCompiles) -include(CheckIncludeFile) -include(CheckLibraryExists) -include(CheckTypeSize) -include(CheckSymbolExists) -enable_testing() - -macro(current_date var) - if(UNIX) - execute_process(COMMAND "date" +"%Y%m%d" OUTPUT_VARIABLE ${var}) - endif() -endmacro() - -current_date(RELEASE_DATE) - -macro(extra_dist) - foreach(file ${ARGV}) - file(RELATIVE_PATH relfile "${PROJECT_SOURCE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/${file}") - list(APPEND EXTRA_DIST "${relfile}") - endforeach() - set(EXTRA_DIST "${EXTRA_DIST}" PARENT_SCOPE) -endmacro() - -set(EXTRA_DIST - HOWTO-RELEASE - Makefile.vc - SConstruct - autogen.sh - configure.com - nmake.opt - libtiff-4.pc.in) - -# These are annoyingly verbose, produce false positives or don't work -# nicely with all supported compiler versions, so are disabled unless -# explicitly enabled. -option(extra-warnings "Enable extra compiler warnings" OFF) - -# This will cause the compiler to fail when an error occurs. -option(fatal-warnings "Compiler warnings are errors" OFF) - -# Check if the compiler supports each of the following additional -# flags, and enable them if supported. This greatly improves the -# quality of the build by checking for a number of common problems, -# some of which are quite serious. -if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR - CMAKE_C_COMPILER_ID MATCHES "Clang") - set(test_flags - -Wall - -Winline - -W - -Wformat-security - -Wpointer-arith - -Wdisabled-optimization - -Wno-unknown-pragmas - -Wdeclaration-after-statement - -fstrict-aliasing) - if(extra-warnings) - list(APPEND test_flags - -Wfloat-equal - -Wmissing-prototypes - -Wunreachable-code) - endif() - if(fatal-warnings) - list(APPEND test_flags - -Werror) - endif() -elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - set(test_flags) - if(extra-warnings) - list(APPEND test_flags - /W4) - else() - list(APPEND test_flags - /W3) - endif() - if (fatal-warnings) - list(APPEND test_flags - /WX) - endif() -endif() - -foreach(flag ${test_flags}) - string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}") - set(test_c_flag "C_FLAG${flag_var}") - CHECK_C_COMPILER_FLAG(${flag} "${test_c_flag}") - if (${test_c_flag}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") - endif (${test_c_flag}) -endforeach(flag ${test_flags}) - -if(MSVC) - set(CMAKE_DEBUG_POSTFIX "d") -endif() - -option(ld-version-script "Enable linker version script" ON) -# Check if LD supports linker scripts. -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { - global: sym; -}; - -VERS_2 { - global: sym; -} VERS_1; -") -set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) -set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map") -check_c_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT) -set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) -file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") -if (ld-version-script AND HAVE_LD_VERSION_SCRIPT) - set(HAVE_LD_VERSION_SCRIPT TRUE) -else() - set(HAVE_LD_VERSION_SCRIPT FALSE) -endif() +# Default policy is from 3.9.0 +cmake_policy(VERSION 3.9.0) -# Find libm, if available -if(NOT MINGW) - find_library(M_LIBRARY m) -endif() +# Find CMake modules in cmake/ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") -check_include_file(assert.h HAVE_ASSERT_H) -check_include_file(dlfcn.h HAVE_DLFCN_H) -check_include_file(fcntl.h HAVE_FCNTL_H) -check_include_file(inttypes.h HAVE_INTTYPES_H) -check_include_file(io.h HAVE_IO_H) -check_include_file(search.h HAVE_SEARCH_H) -check_include_file(stdint.h HAVE_STDINT_H) -check_include_file(string.h HAVE_STRING_H) -check_include_file(strings.h HAVE_STRINGS_H) -check_include_file(sys/time.h HAVE_SYS_TIME_H) -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(unistd.h HAVE_UNISTD_H) - -# Inspired from /usr/share/autoconf/autoconf/c.m4 -foreach(inline_keyword "inline" "__inline__" "__inline") - if(NOT DEFINED C_INLINE) - set(CMAKE_REQUIRED_DEFINITIONS_SAVE ${CMAKE_REQUIRED_DEFINITIONS}) - set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - "-Dinline=${inline_keyword}") - check_c_source_compiles(" - typedef int foo_t; - static inline foo_t static_foo() {return 0;} - foo_t foo(){return 0;} - int main(int argc, char *argv[]) {return 0;}" - C_HAS_${inline_keyword}) - set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_SAVE}) - if(C_HAS_${inline_keyword}) - set(C_INLINE TRUE) - set(INLINE_KEYWORD "${inline_keyword}") - endif() - endif() -endforeach() -if(NOT DEFINED C_INLINE) - set(INLINE_KEYWORD) -endif() +# Read version information from configure.ac. +include(AutotoolsVersion) +message(STATUS "Building tiff version ${LIBTIFF_VERSION_FULL}") +message(STATUS "libtiff library version ${SO_VERSION}") +string(TIMESTAMP BUILD_DATE "%Y%m%d") +message(STATUS "libtiff build date: ${BUILD_DATE}") -# off_t and size_t checks omitted; not clear they are used at all -# Are off_t and size_t checks strictly necessary? - -# Check if sys/time.h and time.h allow use together -check_c_source_compiles(" -#include <sys/time.h> -#include <time.h> -int main(void){return 0;}" - TIME_WITH_SYS_TIME) - -# Check if struct tm is in sys/time.h -check_c_source_compiles(" -#include <sys/types.h> -#include <time.h> - -int main(void){ - struct tm tm; - int *p = &tm.tm_sec; - return !p; -}" - TM_IN_SYS_TIME) - -# Check type sizes -# NOTE: Could be replaced with C99 <stdint.h> -check_type_size("signed int" SIZEOF_SIGNED_INT) -check_type_size("unsigned int" SIZEOF_UNSIGNED_INT) -check_type_size("signed long" SIZEOF_SIGNED_LONG) -check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG) -check_type_size("signed long long" SIZEOF_SIGNED_LONG_LONG) -check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG) -check_type_size("unsigned char *" SIZEOF_UNSIGNED_CHAR_P) - -set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES}) -set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h") -check_type_size("size_t" SIZEOF_SIZE_T) -check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T) -set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE}) - -macro(report_values) - foreach(val ${ARGV}) - message(STATUS "${val} set to ${${val}}") - endforeach() -endmacro() - -set(TIFF_INT8_T "signed char") -set(TIFF_UINT8_T "unsigned char") - -set(TIFF_INT16_T "signed short") -set(TIFF_UINT16_T "unsigned short") - -if(SIZEOF_SIGNED_INT EQUAL 4) - set(TIFF_INT32_T "signed int") - set(TIFF_INT32_FORMAT "%d") -elseif(SIZEOF_SIGNED_LONG EQUAL 4) - set(TIFF_INT32_T "signed long") - set(TIFF_INT32_FORMAT "%ld") -endif() -if(SIZEOF_UNSIGNED_INT EQUAL 4) - set(TIFF_UINT32_T "unsigned int") - set(TIFF_UINT32_FORMAT "%u") -elseif(SIZEOF_UNSIGNED_LONG EQUAL 4) - set(TIFF_UINT32_T "unsigned long") - set(TIFF_UINT32_FORMAT "%lu") -endif() +set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries") -if(SIZEOF_SIGNED_LONG EQUAL 8) - set(TIFF_INT64_T "signed long") - set(TIFF_INT64_FORMAT "%ld") -elseif(SIZEOF_SIGNED_LONG_LONG EQUAL 8) - set(TIFF_INT64_T "signed long long") - if (MINGW) - set(TIFF_INT64_FORMAT "%I64d") - else() - set(TIFF_INT64_FORMAT "%lld") - endif() -endif() -if(SIZEOF_UNSIGNED_LONG EQUAL 8) - set(TIFF_UINT64_T "unsigned long") - set(TIFF_UINT64_FORMAT "%lu") -elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL 8) - set(TIFF_UINT64_T "unsigned long long") - if (MINGW) - set(TIFF_UINT64_FORMAT "%I64u") - else() - set(TIFF_UINT64_FORMAT "%llu") - endif() -endif() +# Disable deprecated features to ensure clean build +add_definitions(-DTIFF_DISABLE_DEPRECATED) -if(SIZEOF_UNSIGNED_INT EQUAL SIZEOF_SIZE_T) - set(TIFF_SIZE_T "unsigned int") - set(TIFF_SIZE_FORMAT "%u") - set(TIFF_SSIZE_T "signed int") - set(TIFF_SSIZE_FORMAT "%d") -elseif(SIZEOF_UNSIGNED_LONG EQUAL SIZEOF_SIZE_T) - set(TIFF_SIZE_T "unsigned long") - set(TIFF_SIZE_FORMAT "%lu") - set(TIFF_SSIZE_T "signed long") - set(TIFF_SSIZE_FORMAT "%ld") -elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL SIZEOF_SIZE_T) - set(TIFF_SIZE_T "unsigned long long") - set(TIFF_SSIZE_T "signed long long") - if (MINGW) - set(TIFF_SIZE_FORMAT "%I64u") - set(TIFF_SSIZE_FORMAT "%I64d") - else() - set(TIFF_SIZE_FORMAT "%llu") - set(TIFF_SSIZE_FORMAT "%lld") - endif() -endif() -if(NOT SIZEOF_PTRDIFF_T) - set(TIFF_PTRDIFF_T "${TIFF_SSIZE_T}") - set(TIFF_PTRDIFF_FORMAT "${SSIZE_FORMAT}") -else() - set(TIFF_PTRDIFF_T "ptrdiff_t") - set(TIFF_PTRDIFF_FORMAT "%ld") -endif() +# Project definition +set(CMAKE_C_STANDARD 99) +project(tiff + VERSION "${LIBTIFF_VERSION}" + LANGUAGES C CXX) -#report_values(TIFF_INT8_T TIFF_INT8_FORMAT -# TIFF_UINT8_T TIFF_UINT8_FORMAT -# TIFF_INT16_T TIFF_INT16_FORMAT -# TIFF_UINT16_T TIFF_UINT16_FORMAT -# TIFF_INT32_T TIFF_INT32_FORMAT -# TIFF_UINT32_T TIFF_UINT32_FORMAT -# TIFF_INT64_T TIFF_INT64_FORMAT -# TIFF_UINT64_T TIFF_UINT64_FORMAT -# TIFF_SSIZE_T TIFF_SSIZE_FORMAT -# TIFF_PTRDIFF_T TIFF_PTRDIFF_FORMAT) - -check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP) -check_symbol_exists(setmode "unistd.h" HAVE_SETMODE) -check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) -check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP) -check_symbol_exists(strtol "stdlib.h" HAVE_STRTOL) -check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL) -check_symbol_exists(strtoul "stdlib.h" HAVE_STRTOUL) -check_symbol_exists(strtoull "stdlib.h" HAVE_STRTOULL) -check_symbol_exists(getopt "unistd.h;stdio.h" HAVE_GETOPT) -check_symbol_exists(lfind "search.h" HAVE_LFIND) - -if(NOT HAVE_SNPRINTF) - add_definitions(-DNEED_LIBPORT) -endif() +# Autotools compatibility +include(AutotoolsCompat) -# CPU bit order -set(HOST_FILLORDER FILLORDER_MSB2LSB) -if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR - CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR - # AMD64 on Windows - CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" OR - CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*") - set(HOST_FILLORDER FILLORDER_LSB2MSB) -endif() +# Compiler checks (warning flags, etc.) +include(CompilerChecks) -# CPU endianness -include(TestBigEndian) -test_big_endian(HOST_BIG_ENDIAN) -if(HOST_BIG_ENDIAN) - add_definitions(-DWORDS_BIGENDIAN) -endif() +# Linker checks (version script, etc.) +include(LinkerChecks) -# IEEE floating point -set(HAVE_IEEEFP 1) +# Processor checks (endianness, fill order, floating point, etc.) +include(ProcessorChecks) -report_values(CMAKE_HOST_SYSTEM_PROCESSOR HOST_FILLORDER - HOST_BIG_ENDIAN HAVE_IEEEFP) +# Checks for headers +include(IncludeChecks) -# Large file support -if (UNIX OR MINGW) - # This might not catch every possibility catered for by - # AC_SYS_LARGEFILE. - add_definitions(-D_FILE_OFFSET_BITS=64) - set(FILE_OFFSET_BITS 64) -endif() +# Checks for functions and other symbols +include(SymbolChecks) +# Standard installation paths +include(GNUInstallDirs) # Documentation install directory (default to cmake project docdir) set(LIBTIFF_DOCDIR "${CMAKE_INSTALL_FULL_DOCDIR}") -# Options to enable and disable internal codecs - -option(ccitt "support for CCITT Group 3 & 4 algorithms" ON) -set(CCITT_SUPPORT ${ccitt}) - -option(packbits "support for Macintosh PackBits algorithm" ON) -set(PACKBITS_SUPPORT ${packbits}) - -option(lzw "support for LZW algorithm" ON) -set(LZW_SUPPORT ${lzw}) +# CTest testing +enable_testing() -option(thunder "support for ThunderScan 4-bit RLE algorithm" ON) -set(THUNDER_SUPPORT ${thunder}) +# Checks for type presence and size +include(TypeSizeChecks) -option(next "support for NeXT 2-bit RLE algorithm" ON) -set(NEXT_SUPPORT ${next}) +# Check for POSIX Large File Support (LFS) +include(LargeFileSupport) -option(logluv "support for LogLuv high dynamic range algorithm" ON) -set(LOGLUV_SUPPORT ${logluv}) +# Options for internal codec support +include(InternalCodecs) -# Option for Microsoft Document Imaging -option(mdi "support for Microsoft Document Imaging" ON) -set(MDI_SUPPORT ${mdi}) +# Check for Deflate codec +include(DeflateCodec) -# ZLIB -option(zlib "use zlib (required for Deflate compression)" ON) -if (zlib) - find_package(ZLIB) -endif() -set(ZLIB_SUPPORT 0) -if(ZLIB_FOUND) - set(ZLIB_SUPPORT 1) -endif() -set(ZIP_SUPPORT ${ZLIB_SUPPORT}) - - -# libdeflate -option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ON) -if (libdeflate) - set(DEFLATE_FOUND 0) - find_path(DEFLATE_INCLUDE_DIR libdeflate.h) - set(DEFLATE_NAMES ${DEFLATE_NAMES} deflate) - find_library(DEFLATE_LIBRARY NAMES ${DEFLATE_NAMES}) - if (DEFLATE_INCLUDE_DIR AND DEFLATE_LIBRARY) - set(DEFLATE_FOUND 1) - set(DEFLATE_LIBRARIES ${DEFLATE_LIBRARY}) - endif() -endif() -set(LIBDEFLATE_SUPPORT FALSE) -if(DEFLATE_FOUND) - set(LIBDEFLATE_SUPPORT TRUE) -endif() +# Check for PixarLog codec +include(PixarLogCodec) -if(LIBDEFLATE_SUPPORT AND NOT ZIP_SUPPORT) - message(WARNING "libdeflate available but zlib is not. libdeflate cannot be used") - set(LIBDEFLATE_SUPPORT FALSE) -endif() +# Check for JPEG codec +include(JPEGCodec) -set(LIBDEFLATE_SUPPORT ${LIBDEFLATE_SUPPORT}) +# Check for JBIG codec +include(JBIGCodec) +# Check for LERC codec +include(LERCCodec) -# Option for Pixar log-format algorithm +# Check for LZMA codec +include(LZMACodec) -# Pixar log format -option(pixarlog "support for Pixar log-format algorithm (requires Zlib)" ON) -set(PIXARLOG_SUPPORT FALSE) -if (ZLIB_SUPPORT) - if(pixarlog) - set(PIXARLOG_SUPPORT TRUE) - endif() -endif() +# Check for ZSTD codec +include(ZSTDCodec) -# JPEG -option(jpeg "use libjpeg (required for JPEG compression)" ON) -if (jpeg) - find_package(JPEG) -endif() -set(JPEG_SUPPORT FALSE) -if(JPEG_FOUND) - set(JPEG_SUPPORT TRUE) -endif() +# Check for WebP codec +include(WebPCodec) -option(old-jpeg "support for Old JPEG compression (read-only)" ON) -set(OJPEG_SUPPORT FALSE) -if (JPEG_SUPPORT) - if (old-jpeg) - set(OJPEG_SUPPORT TRUE) - endif() -endif() +# Option for C++ libtiffxx library +include(CXXLibrary) -# JBIG-KIT -option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ON) -if (jbig) - set(JBIG_FOUND 0) - find_path(JBIG_INCLUDE_DIR jbig.h) - set(JBIG_NAMES ${JBIG_NAMES} jbig libjbig) - find_library(JBIG_LIBRARY NAMES ${JBIG_NAMES}) - if (JBIG_INCLUDE_DIR AND JBIG_LIBRARY) - set(JBIG_FOUND 1) - set(JBIG_LIBRARIES ${JBIG_LIBRARY}) - endif() -endif() -set(JBIG_SUPPORT 0) -if(JBIG_FOUND) - set(JBIG_FOUND TRUE) - set(JBIG_SUPPORT 1) -else() - set(JBIG_FOUND FALSE) -endif() +# Checks for OpenGL support +include(OpenGLChecks) -set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) -set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIR}) -check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) -set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) - -# liblzma2 -option(lzma "use liblzma (required for LZMA2 compression)" ON) -if (lzma) - find_package(LibLZMA) -endif() -set(LZMA_SUPPORT 0) -if(LIBLZMA_FOUND) - set(LZMA_SUPPORT 1) -endif() - -# libzstd -option(zstd "use libzstd (required for ZSTD compression)" ON) -if (zstd) - find_path(ZSTD_INCLUDE_DIR zstd.h) - find_library(ZSTD_LIBRARY NAMES zstd) - if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY) - check_library_exists ("${ZSTD_LIBRARY}" ZSTD_decompressStream "" ZSTD_RECENT_ENOUGH) - if (ZSTD_RECENT_ENOUGH) - set(ZSTD_FOUND TRUE) - set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) - message(STATUS "Found ZSTD library: ${ZSTD_LIBRARY}") - else () - message(WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0") - endif () - endif () -endif() -set(ZSTD_SUPPORT 0) -if(ZSTD_FOUND) - set(ZSTD_SUPPORT 1) -endif() - -# libwebp -option(webp "use libwebp (required for WEBP compression)" ON) -if (webp) - find_path(WEBP_INCLUDE_DIR /webp/decode.h) - find_library(WEBP_LIBRARY NAMES webp) -endif() -set(WEBP_SUPPORT 0) -set(WEBP_FOUND FALSE) -if (WEBP_INCLUDE_DIR AND WEBP_LIBRARY) - set(WEBP_SUPPORT 1) - set(WEBP_FOUND TRUE) - set(WEBP_LIBRARIES ${WEBP_LIBRARY}) - message(STATUS "Found WEBP library: ${WEBP_LIBRARY}") -endif() - -# 8/12-bit jpeg mode -option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate -12-bit libjpeg build)" ON) -set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg") -set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library") -set(JPEG12_FOUND FALSE) -if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY) - set(JPEG12_LIBRARIES ${JPEG12_LIBRARY}) - set(JPEG12_FOUND TRUE) -endif() -if (JPEG12_FOUND) - set(JPEG_DUAL_MODE_8_12 1) - set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h") -endif() - -# C++ support -option(cxx "Enable C++ stream API building (requires C++ compiler)" ON) -set(CXX_SUPPORT FALSE) -if (cxx) - enable_language(CXX) - set(CXX_SUPPORT TRUE) -endif() - -# OpenGL and GLUT -find_package(OpenGL) -find_package(GLUT) -set(HAVE_OPENGL FALSE) -if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) - set(HAVE_OPENGL TRUE) -endif() -# Purely to satisfy the generated headers: -check_include_file(GL/gl.h HAVE_GL_GL_H) -check_include_file(GL/glu.h HAVE_GL_GLU_H) -check_include_file(GL/glut.h HAVE_GL_GLUT_H) -check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) -check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) -check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) - -# Win32 IO -set(win32_io FALSE) -if(WIN32) - set(win32_io TRUE) -endif() - -set(USE_WIN32_FILEIO ${win32_io}) +# Windows support +include(WindowsSupport) # Orthogonal features +include(LibraryFeatures) -# Strip chopping -option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)" ON) -set(TIFF_DEFAULT_STRIP_SIZE 8192 CACHE STRING "default size of the strip in bytes (when strip chopping is enabled)") - -set(STRIPCHOP_DEFAULT) -if(strip-chopping) - set(STRIPCHOP_DEFAULT TRUE) - if(TIFF_DEFAULT_STRIP_SIZE) - set(STRIP_SIZE_DEFAULT "${TIFF_DEFAULT_STRIP_SIZE}") - endif() -endif() - -# Defer loading of strip/tile offsets -option(defer-strile-load "enable deferred strip/tile offset/size loading (also available at runtime with the 'D' flag of TIFFOpen())" OFF) -set(DEFER_STRILE_LOAD ${defer-strile-load}) - -# CHUNKY_STRIP_READ_SUPPORT -option(chunky-strip-read "enable reading large strips in chunks for TIFFReadScanline() (experimental)" OFF) -set(CHUNKY_STRIP_READ_SUPPORT ${chunky-strip-read}) +# pkg-config support +include(PkgConfig) -# SUBIFD support -set(SUBIFD_SUPPORT 1) +# math.h/libm portability +find_package(CMath REQUIRED) -# Default handling of ASSOCALPHA support. -option(extrasample-as-alpha "the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly" ON) -if(extrasample-as-alpha) - set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1) -endif() +# Release support +include(Release) -# Default handling of YCbCr subsampling support. -# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details. -option(check-ycbcr-subsampling "enable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag" ON) -if (check-ycbcr-subsampling) - set(CHECK_JPEG_YCBCR_SUBSAMPLING 1) -endif() - -# Generate pkg-config file -set(prefix "${CMAKE_INSTALL_PREFIX}") -set(exec_prefix "${CMAKE_INSTALL_PREFIX}") -set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") -set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc - DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") - -# Includes used by libtiff (and tests) -if(ZLIB_INCLUDE_DIRS) - list(APPEND TIFF_INCLUDES ${ZLIB_INCLUDE_DIRS}) -endif() -if(DEFLATE_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${DEFLATE_INCLUDE_DIR}) -endif() -if(JPEG_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR}) -endif() -if(JPEG12_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR}) -endif() -if(JBIG_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${JBIG_INCLUDE_DIR}) -endif() -if(LIBLZMA_INCLUDE_DIRS) - list(APPEND TIFF_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) -endif() -if(ZSTD_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${ZSTD_INCLUDE_DIR}) -endif() -if(WEBP_INCLUDE_DIR) - list(APPEND TIFF_INCLUDES ${WEBP_INCLUDE_DIR}) -endif() - -# Libraries required by libtiff -set(TIFF_LIBRARY_DEPS) -if(NOT MINGW AND M_LIBRARY) - list(APPEND TIFF_LIBRARY_DEPS "m") -endif() -if(ZLIB_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES}) -endif() -if(DEFLATE_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${DEFLATE_LIBRARIES}) -endif() -if(JPEG_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) -endif() -if(JPEG12_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) -endif() -if(JBIG_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${JBIG_LIBRARIES}) -endif() -if(LIBLZMA_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES}) -endif() -if(ZSTD_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${ZSTD_LIBRARIES}) -endif() -if(WEBP_LIBRARIES) - list(APPEND TIFF_LIBRARY_DEPS ${WEBP_LIBRARIES}) -endif() - -#report_values(TIFF_INCLUDES TIFF_LIBRARY_DEPS) # Process subdirectories add_subdirectory(port) @@ -746,10 +144,9 @@ add_subdirectory(build) add_subdirectory(man) add_subdirectory(html) -#message(STATUS "EXTRA_DIST: ${EXTRA_DIST}") message(STATUS "") -message(STATUS "Libtiff is now configured for ${host}") +message(STATUS "Libtiff is now configured for ${CMAKE_SYSTEM}") message(STATUS "") message(STATUS " Installation directory: ${prefix}") message(STATUS " Documentation directory: ${LIBTIFF_DOCDIR}") @@ -769,16 +166,29 @@ message(STATUS " NeXT 2-bit RLE algorithm: ${next}") message(STATUS " LogLuv high dynamic range encoding: ${logluv}") message(STATUS "") message(STATUS " Support for external codecs:") -message(STATUS " ZLIB support: ${zlib} (requested) ${ZLIB_FOUND} (availability)") -message(STATUS " libdeflate support: ${libdeflate} (requested) ${LIBDEFLATE_SUPPORT} (availability)") -message(STATUS " Pixar log-format algorithm: ${pixarlog} (requested) ${PIXARLOG_SUPPORT} (availability)") -message(STATUS " JPEG support: ${jpeg} (requested) ${JPEG_FOUND} (availability)") -message(STATUS " Old JPEG support: ${old-jpeg} (requested) ${JPEG_FOUND} (availability)") -message(STATUS " JPEG 8/12 bit dual mode: ${jpeg12} (requested) ${JPEG12_FOUND} (availability)") -message(STATUS " ISO JBIG support: ${jbig} (requested) ${JBIG_FOUND} (availability)") -message(STATUS " LZMA2 support: ${lzma} (requested) ${LIBLZMA_FOUND} (availability)") -message(STATUS " ZSTD support: ${zstd} (requested) ${ZSTD_FOUND} (availability)") -message(STATUS " WEBP support: ${webp} (requested) ${WEBP_FOUND} (availability)") +message(STATUS " ZLIB support: Requested:${zlib} Availability:${ZLIB_FOUND} Support:${ZLIB_SUPPORT}") +if(ZLIB_SUPPORT) + message(STATUS " libdeflate support: Requested:${libdeflate} Availability:${DEFLATE_FOUND} Support:${LIBDEFLATE_SUPPORT}") +else() + message(STATUS " libdeflate support: Requested:${libdeflate} Availability:${DEFLATE_FOUND} Support:${LIBDEFLATE_SUPPORT} (Depends on ZLIB Support)") +endif() +if(ZLIB_SUPPORT) + message(STATUS " Pixar log-format algorithm: Requested:${pixarlog} Availability:${ZLIB_FOUND} Support:${PIXARLOG_SUPPORT}") +else() + message(STATUS " Pixar log-format algorithm: Requested:${pixarlog} Availability:${ZLIB_FOUND} Support:${PIXARLOG_SUPPORT} (Depends on ZLIB Support)") +endif() +message(STATUS " JPEG support: Requested:${jpeg} Availability:${JPEG_FOUND} Support:${JPEG_SUPPORT}") +if(JPEG_SUPPORT) + message(STATUS " Old JPEG support: Requested:${old-jpeg} Availability:${JPEG_SUPPORT} Support:${OJPEG_SUPPORT}") +else() + message(STATUS " Old JPEG support: Requested:${old-jpeg} Availability:${JPEG_SUPPORT} Support:${OJPEG_SUPPORT} (Depends on JPEG Support)") +endif() +message(STATUS " JPEG 8/12 bit dual mode: Requested:${jpeg12} Availability:${JPEG12_FOUND} Support:${JPEG_DUAL_MODE_8_12}") +message(STATUS " ISO JBIG support: Requested:${jbig} Availability:${JBIG_FOUND} Support:${JBIG_SUPPORT}") +message(STATUS " LERC support: Requested:${lerc} Availability:${LERC_FOUND} Support:${LERC_SUPPORT}") +message(STATUS " LZMA2 support: Requested:${lzma} Availability:${LIBLZMA_FOUND} Support:${LZMA_SUPPORT}") +message(STATUS " ZSTD support: Requested:${zstd} Availability:${ZSTD_USABLE} Support:${ZSTD_SUPPORT}") +message(STATUS " WEBP support: Requested:${webp} Availability:${WEBP_FOUND} Support:${WEBP_SUPPORT}") message(STATUS "") message(STATUS " C++ support: ${cxx} (requested) ${CXX_SUPPORT} (availability)") message(STATUS "") diff --git a/tiff/ChangeLog b/tiff/ChangeLog index 452dcb3a..9bda39c3 100644 --- a/tiff/ChangeLog +++ b/tiff/ChangeLog @@ -1,3 +1,899 @@ +2021-04-16 Even Rouault <even.rouault@spatialys.com> + + libtiff v4.3.0 released + +2021-04-15 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'libjpeg12_cmake' into 'master' + libtiff/tif_config.h.cmake.in: surround LIBJPEG_12_PATH by double quotes + + See merge request libtiff/libtiff!237 + +2021-04-15 Even Rouault <even.rouault@spatialys.com> + + libtiff/tif_config.h.cmake.in: surround LIBJPEG_12_PATH by double quotes + +2021-04-14 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'lerc_api_change' into 'master' + tif_lerc.c: cope with API breakage in liblerc master + + See merge request libtiff/libtiff!236 + +2021-04-14 Even Rouault <even.rouault@spatialys.com> + + tif_lerc.c: cope with API breakage in liblerc master. + +2021-04-08 Even Rouault <even.rouault@spatialys.com> + + libtiff: remove remaining #ifdef WIN32 and use PRI formatting. + +2021-03-10 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'kmilos-master-patch-73187' into 'master' + tiffcp: Remove LZW help text, preset not supported + + See merge request libtiff/libtiff!229 + +2021-03-10 Miloš Komarčević <miloskomarcevic@aim.com> + + tiffcp: Remove LZW help text, preset not supported. + +2021-03-10 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'feature/lerc' into 'master' + Add LERC Compression Plugin (closes: #213) + + Closes #213 + + See merge request libtiff/libtiff!228 + +2021-03-10 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'cmake-fixes' into 'master' + CMake fixes + + Closes #246 et #245 + + See merge request libtiff/libtiff!232 + +2021-03-09 Roger Leigh <rleigh@codelibre.net> + + cmake: Correct FindCMath. + + cmake: Correct ZSTD_USABLE typo. + +2021-03-07 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'cmake-find-lib-prefixes' into 'master' + cmake: Correct find lib prefixes for Deflate and JBIG + + See merge request libtiff/libtiff!231 + +2021-03-07 Roger Leigh <rleigh@codelibre.net> + + cmake: FindJBIG uses lib prefix on Windows. + + cmake: FindDeflate uses lib prefix on Windows. + +2021-03-07 Even Rouault <even.rouault@spatialys.com> + + TWebPDecode(): avoid potential overflow on multiplication (CID 1472928) + + TIFFReadDirEntryArrayWithLimit(): avoid false positive from Coverity Scan regarding out-of-bounds access (CID 1472927) + + tif_dirwrite.c: avoid setting a variable that is not read afterwards. + +2021-03-07 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'coverity-fixes' into 'master' + Coverity fixes (high impact) + + See merge request libtiff/libtiff!227 + +2021-03-07 Roger Leigh <rleigh@codelibre.net> + + Fix high-impact Coverity issues (resource leaks). + The issues are in the tests and tiffcrop, not the core library. Real issues, but not high risk. + + Use to test if Coverity integration is performing properly on merge. + +2021-03-07 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'fix_tif_fax3_encoder_regression' into 'master' + tif_fax3.c: fix master regression in encoder + + See merge request libtiff/libtiff!230 + +2021-03-07 Even Rouault <even.rouault@spatialys.com> + + tif_fax3.c: fix master regression in encoder. + Fix issue introduced in 39a74eede0455ec8ee334dcddf71f5354d508d8b + + Spotted by gdal's tiff_write_76 test + +2021-03-07 Antonio Valentino <antonio.valentino@tiscali.it> + + Add LERC support in CMake. + +2021-03-07 Antonio Valentino <Antonio.Valentino@esa.int> + + Add LERC support in configure.ac and Makefile.am. + +2021-03-07 Antonio Valentino <antonio.valentino@tiscali.it> + + Add LERC support to tiffcp. + +2021-03-07 Antonio Valentino <Antonio.Valentino@esa.int> + + Add LERC plugin. + The lerc plugin code has been copyed form GDAL. + +2021-03-06 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'display_tool_purpose' into 'master' + TIFF tools: insert a line of text summarizing each tool's purpose + + See merge request libtiff/libtiff!214 + +2021-03-06 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'cmake-update' into 'master' + CMake updates + + See merge request libtiff/libtiff!224 + +2021-03-06 Even Rouault <even.rouault@spatialys.com> + + tiff.h: typo fix in comment. + +2021-02-15 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'remove-travis' into 'master' + ci: Remove unused Travis-CI support + + See merge request libtiff/libtiff!226 + +2021-02-14 Roger Leigh <rleigh@codelibre.net> + + ci: Remove unused Travis-CI support. + +2021-02-14 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'ci-coverity' into 'master' + Enable Coverity static analysis with CI pipeline + + See merge request libtiff/libtiff!225 + +2021-02-14 Roger Leigh <rleigh@codelibre.net> + + ci: Add Coverity static analysis job. + + ci: Use custom libtiff CI image. + +2021-02-13 Roger Leigh <rleigh@codelibre.net> + + cmake: Add release target. + + cmake: Remove empty contrib files. + + cmake: Tidy toplevel. + + cmake: Move pkg-config support to PkgConfig.cmake. + + cmake: Move library feature options to CXXLibraryFeatures.cmake. + + cmake: Move C++ support to CXXLibrary.cmake. + + cmake: Add FindCMath to handle libm linking portably. + + cmake: Tidy unused includes. + + cmake: Rename release date to build date. + + cmake: Compute timestamp portably. + + cmake: Remove remaining uses of report_values() + + cmake: Move JPEG12 checks to JPEGCodec.cmake. + + cmake: Move OpenGL checks to OpenGLChecks.cmake. + + cmake: Move OpenGL checks to OpenGLChecks.cmake. + + cmake: Move WebP codec support to WebPCodec.cmake. + + cmake: Use imported targets for WebP. + + cmake: Add FindWebP. + + cmake: Move ZSTD codec support to ZSTDCodec.cmake. + + cmake: Use imported targets for ZSTD. + + cmake: Add FindZSTD. + + cmake: Move LZMA codec support to LZMACodec.cmake. + + cmake: Use imported targets for LibLZMA. + + cmake: Move JBIG codec support to JBIGCodec.cmake. + + cmake: Use imported targets for JBIG. + + cmake: Add FindJBIG. + + cmake: Move PixarLog codec support to PixarLogCodec.cmake. + + cmake: Report system name in configuration report. + + cmake: Move JPEG codec support to JPEGCodec.cmake. + + cmake: Use imported targets for JPEG. + + cmake: Move Deflate codec support to DeflateCodec.cmake. + + cmake: Use imported targets for ZLIB and Deflate. + + cmake: Add FindDeflate. + + cmake: Move symbol checks to SymbolChecks.cmake. + + cmake: Move include checks to IncludeChecks.cmake. + + cmake: Move all autotools logic to separate files. + + cmake: Move internal codec options to InternalCodecs.cmake. + + cmake: Move LFS check to LargeFileSupport.cmake. + + cmake: Move Win32 IO feature to WindowsIOFeature.cmake. + + cmake: Move processor capability checks to ProcessorChecks.cmake. + + cmake: Move type size checks to TypeSizeChecks.cmake. + + cmake: Move linker checks to LinkerChecks.cmake. + + cmake: Move warning options to CompilerChecks. + + cmake: Move version introspection to AutotoolsVersion.cmake. + + cmake: Move compiler checks to CompilerChecks.cmake. + + cmake: Split into helper scripts. + +2021-02-08 Roger Leigh <rleigh@codelibre.net> + + cmake: Use target_sources. + + libport: Adjust header and library to only define and link if required. + * Make libport an OBJECT library when in use, otherwise a dummy + INTERFACE library + * libport.h will work if getopt is present or not present. If + present, will fall back to <unistd.h>, else will define + symbols + * Add generated libport_config.h to define HAVE_GETOPT and HAVE_UNISTD_H + * dummy.c no longer needed with CMake + * libtiff/libtiffxx no longer link with libport + + cmake: Remove unnecessary extra_dist usage. + Only makes sense in the context of Automake. Was carried over + for reference while porting, but is not needed. + + cmake: Update minimum version and policy version to 3.9. + +2021-02-08 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'remove-nmake' into 'master' + Remove NMake build support + + See merge request libtiff/libtiff!223 + +2021-02-08 Roger Leigh <rleigh@codelibre.net> + + Remove NMake build support. + The functionality provided by the NMake build is now completely + superseded by the CMake build. + +2021-02-08 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'warning-fixes' into 'master' + Warning fixes + + See merge request libtiff/libtiff!222 + +2021-02-07 Miguel Medalha <medalist@sapo.pt> + + Update tiffsplit.c. + + Reinsert summary line lost after conflicting merge. + + Merge branch 'master' into 'display_tool_purpose' + # Conflicts: + # tools/tiffsplit.c + +2021-02-06 Roger Leigh <rleigh@codelibre.net> + + ci: Enable fatal warnings with -Werror for AppVeyor/GCC. + + ci: Enable fatal warnings with -Werror for GitLab CI. + + tif_zstd.c: Remove unused variable warning. + + custom_dir_EXIF_231: Remove case statement fallthrough. + + custom_dir_EXIF_231: Correct use of strncpy. + + Correct include order. + + Eliminate implict fallthrough usage. + Use simple loops in place of manual loop unrolling. Rely on + the compiler optimiser to unroll loops when appropriate. + + Suppress potential unused variable warning. + + Suppress warnings or avoid case statement fallthrough. + +2021-02-05 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'c99-ssize_t-fixes' into 'master' + C99 ssize_t fixes + + Closes #239 + + See merge request libtiff/libtiff!219 + +2021-02-05 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'tiffsplit-too-many-args' into 'master' + tiffsplit.c: exit with EXIT_FAILURE if there are extra args on the command line + + See merge request libtiff/libtiff!209 + +2021-02-05 Roger Leigh <rleigh@codelibre.net> + + Add additional TIFF_SSIZE_FORMAT uses. + +2021-02-04 Roger Leigh <rleigh@codelibre.net> + + NMake fixes for size type formatting. + + Add TIFF_SIZE_FORMAT for portable use of %z. + MinGW64 does support %z, but it issues a compiler warning. + + Align Autoconf tif_config.h and CMake tif_config.cmake.in. + + Use TIFF_SSIZE_FORMAT for formatting tmsize_t. + +2021-02-04 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'remove-lcc' into 'master' + Remove Makefile.lcc + + See merge request libtiff/libtiff!221 + +2021-02-04 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'remove-scons' into 'master' + Remove SCons build + + See merge request libtiff/libtiff!220 + +2021-02-03 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'c99-snprintf' into 'master' + Use C99 snprintf + + See merge request libtiff/libtiff!217 + +2021-02-03 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'tiff2ps-const' into 'master' + tiff2ps.c: string literals must be const char *, not char * + + See merge request libtiff/libtiff!202 + +2021-02-03 Roger Leigh <rleigh@codelibre.net> + + Remove SCons build. + Unmaintained for 16 years. + +2021-02-03 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'codec_summary' into 'master' + Modify 'CMakeLists.txt' to produce a meaningful summary of external codecs + + See merge request libtiff/libtiff!192 + +2021-02-03 Roger Leigh <rleigh@codelibre.net> + + Remove Makefile.lcc. + Unmaintained for 22 years. + +2021-02-02 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'ci-32-bit' into 'master' + ci: Build 32- and 64-bit MSVC variants + + See merge request libtiff/libtiff!218 + +2021-02-01 Roger Leigh <rleigh@codelibre.net> + + ci: Build 32- and 64-bit MSVC variants. + + Use C99 snprintf. + +2021-02-01 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'c99-strtol' into 'master' + Use C99 strtol, strtoul, strtoll and strtoull + + See merge request libtiff/libtiff!216 + +2021-01-31 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'c99-inline' into 'master' + Use C99 inline + + See merge request libtiff/libtiff!215 + +2021-01-31 Roger Leigh <rleigh@codelibre.net> + + Use C99 strtol, strtoul, strtoll and strtoull. + + tif_fax3: Use C99 inline. + + Remove inline feature tests and defines. + Available as a standard feature with C99. + +2021-01-30 Miguel Medalha <medalist@sapo.pt> + + Update raw2tiff.c (remove duplicate description of tool) + +2021-01-30 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'c99-format-strings' into 'master' + C99 format strings + + See merge request libtiff/libtiff!211 + +2021-01-29 Miguel Medalha <medalist@sapo.pt> + + Update tiffdither.c (2 tabs caused slight misalignment of lines in usage info output) + +2021-01-28 Miguel Medalha <medalist@sapo.pt> + + Update ppm2tiff.c (slight misalignment of lines in usage info output) + + Update tiffset.c (small misalignment of lines in usage info output) + +2021-01-28 Medalha <medalist@sapo.pt> + + Display tool purpose. + +2021-01-28 Thomas Bernard <miniupnp@free.fr> + + tiff2ps.c: string literals must be const char *, not char * + +2021-01-28 Roger Leigh <rleigh@codelibre.net> + + libtiff: Use PRI format flags and remove unnecessary casts. + +2021-01-27 Roger Leigh <rleigh@codelibre.net> + + ascii_tag: Use PRI format flags and remove unnecessary casts. + + check_tag: Use PRI format flags and remove unnecessary casts. + + custom_dir_EXIF_231: Use PRI format flags and remove unnecessary casts. + + short_tag: Use PRI format flags and remove unnecessary casts. + + strip_rw: Use PRI format flags and remove unnecessary casts. + + fax2tiff: Use PRI format flags and remove unnecessary casts. + + ppm2tiff: Correct format strings. + + raw2tiff: Use PRI format flags and remove unnecessary casts. + + rgb2ycbcr: Use PRI format flags and remove unnecessary casts. + + tiff2pdf: Use PRI format flags and remove unnecessary casts. + + tiff2ps: Use PRI format flags and remove unnecessary casts. + + tiff2rgba: Use PRI format flags and remove unnecessary casts. + + tiffcmp: Use PRI format flags and remove unnecessary casts. + + tiffcp: Use PRI format flags and remove unnecessary casts. + + tiffcrop: Use PRI format flags and remove unnecessary casts. + + tiffinfo: Use PRI format flags and remove unnecessary casts. + + tiffdump: Use PRI format flags and remove unnecessary casts. + +2021-01-27 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'c99-require-stdtypes' into 'master' + Use standard C99 integer types + + See merge request libtiff/libtiff!205 + +2021-01-26 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'reserve_COMPRESSION_JXL' into 'master' + tiff.h: reserve COMPRESSION_JXL=50002 for JPEGXL + + See merge request libtiff/libtiff!210 + +2021-01-22 Even Rouault <even.rouault@spatialys.com> + + tiff.h: reserve COMPRESSION_JXL=50002 for JPEGXL. + +2021-01-22 Kurt Schwehr <schwehr@google.com> + + tiffsplit.c: exit with EXIT_FAILURE if there are extra args on the command line + e.g. tiffsplit in.tif a_prefix_ junk + +2021-01-22 Roger Leigh <rleigh@codelibre.net> + + Add and enable TIFF_DISABLE_DEPRECATED for internal use. + + Add typedef deprecations for GCC/Clang and MSVC. + + Use standard C99 integer types. + +2021-01-20 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'ubuntu-zstd-wepb' into 'master' + gitlab-ci : use libzstd-dev and libwebp-dev ubuntu packages + + See merge request libtiff/libtiff!208 + +2021-01-20 Thomas Bernard <miniupnp@free.fr> + + gitlab-ci : use libzstd-dev and libwebp-dev ubuntu packages. + should replace !206 + +2021-01-20 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'issue-232' into 'master' + tiff2ps: exit the loop in case of error + + Closes #232 + + See merge request libtiff/libtiff!201 + +2021-01-20 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'tiffsplit-exit-status' into 'master' + tiffsplit: Exit with EXIT_FAILURE if unable to open the input file. + + See merge request libtiff/libtiff!207 + +2021-01-20 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'config-cleanup' into 'master' + Remove HAVE_INTTYPES_H, HAVE_LFIND & lfind, HAVE_SEARCH_H & include <search.h> + + See merge request libtiff/libtiff!203 + +2021-01-19 Kurt Schwehr <schwehr@google.com> + + tiffsplit: Exit with EXIT_FAILURE if unable to open the input file. + +2021-01-18 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'tiffcmp' into 'master' + tiffcmp: fix comparaison with pixels that are fractional number of bytes + + Closes #53 + + See merge request libtiff/libtiff!141 + +2021-01-15 Kurt Schwehr <schwehr@google.com> + + CMakeLists.txt: Remove search for lfind. + + Remove HAVE_INTTYPES_H, HAVE_LFIND & lfind, HAVE_SEARCH_H & include <search.h> + - HAVE_INTTYPES_H is replaced with TIFF_HAVE_INTTYPES_H + - tif_dirinfo.c has a static td_lfind + +2021-01-15 Thomas Bernard <miniupnp@free.fr> + + tiffcmp: fix comparaison with pixels that are fractional number of bytes + For exemple : 4bits per sample + 3 samples per pixel => 1.5 bytes per pixel + + tiff2ps: exit the loop in case of error. + fixes #232 + +2021-01-15 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'rm-strcasecmp' into 'master' + Remove port/strcasecmp.c as strcasecmp is not currently used in libtiff. + + Closes #235 + + See merge request libtiff/libtiff!199 + +2021-01-15 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'std-int-types' into 'master' + Use standard C99 integer types + + See merge request libtiff/libtiff!185 + +2021-01-13 Kurt Schwehr <schwehr@google.com> + + Remove port/strcasecmp.c as strcasecmp is not currently used in libtiff. + Fixes #235 + +2021-01-10 Miguel Medalha <medalist@sapo.pt> + + Update CMakeLists.txt. Delete unnecessary line from libdeflate codec support section + +2021-01-10 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'include_libport' into 'master' + tiff tools and libtiff/mkg3states: include 'libport.h', remove local definition of 'getopt()' + + See merge request libtiff/libtiff!198 + +2021-01-09 Miguel Medalha <medalist@sapo.pt> + + Update CMakeLists.txt. Cleanup of indentation space. Removal of leading '/' from webp include dir. + +2021-01-09 miguel <medalist@sapo.pt> + + cmake: Use target_include_directories correctly. + +2021-01-09 Roger Leigh <rleigh@codelibre.net> + + cmake: Use target_include_directories correctly. + + cmake: Drop unnecessary TOOL_INCLUDES. + +2021-01-07 Roger Leigh <rleigh@codelibre.net> + + cmake: Use target_include_directories correctly. + +2021-01-07 miguel <medalist@sapo.pt> + + tiff tools and libtiff/mkg3states: include 'libport.h', remove local definition of 'getopt()' + +2021-01-07 Miguel Medalha <medalist@sapo.pt> + + Update CMakeLists.txt. + +2021-01-07 miguel <medalist@sapo.pt> + + tiff tools: include 'libport.h', remove local definition of 'getopt()' + +2021-01-06 Roger Leigh <rleigh@codelibre.net> + + Remove conditional use of <string.h> + + cmake: Drop dlfcn.h check. + + cmake: Remove duplicate line. + + Use stdint.h types when available. + +2021-01-05 Olivier Paquet <olivier.paquet@gmail.com> + + Merge branch 'iptcutil' into 'master' + contrib/iptcutil.c: set '#ifdef _WIN32' (was '#ifdef WIN32', which failed at build time) + + See merge request libtiff/libtiff!197 + +2021-01-05 miguel <medalist@sapo.pt> + + tiff tools: include 'libport.h', remove local definition of 'getopt()' + + contrib/iptcutil.c - set '#ifdef _WIN32' (was '#ifdef WIN32', which failed at build time) + +2021-01-04 Even Rouault <even.rouault@spatialys.com> + + tools/CMakeLists.txt: add comment about rgb2ycbcr and thumbnail not to be installed + +2021-01-04 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'revert-5331ed49' into 'master' + Revert "Merge branch 'install_targets' into 'master'" + + See merge request libtiff/libtiff!196 + +2021-01-04 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'drop-wince' into 'master' + Remove non-functional WinCE support + + See merge request libtiff/libtiff!188 + +2021-01-04 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'drop-vms' into 'master' + Remove non-functional VMS support + + See merge request libtiff/libtiff!187 + +2021-01-03 Even Rouault <even.rouault@spatialys.com> + + Revert "Merge branch 'install_targets' into 'master'" + This reverts merge request !193 + +2021-01-03 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'tiffcp_b_parameter' into 'master' + tiffcp: Remove unnecessary reference to compression from usage info for -b parameter + + See merge request libtiff/libtiff!189 + +2021-01-03 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'cmake-faxtable' into 'master' + cmake: Add faxtable target + + See merge request libtiff/libtiff!186 + +2021-01-03 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'install_targets' into 'master' + Update 'CMakeLists.txt' from 'tools'. + + See merge request libtiff/libtiff!193 + +2021-01-03 Miguel Medalha <medalist@sapo.pt> + + Update 'CMakeLists.txt' from 'tools'. + + Update CMakeLists.txt. + +2021-01-03 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'usage_info' into 'master' + thumbnail: Rename constant variable 'stuff' to 'usage_info' + + See merge request libtiff/libtiff!190 + +2021-01-03 Miguel Medalha <medalist@sapo.pt> + + Modified 'CMakeLists.txt' to produce a meaningful summary of external codecs support. + + Removed unnecessary reference to compression from usage info for -b parameter + + Constant variable 'stuff' renamed to 'usage_info' for consistency with the other tools + +2021-01-02 Roger Leigh <rleigh@codelibre.net> + + Remove non-functional VMS support. + + Remove non-functional WinCE support. + +2021-01-02 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'codespell' into 'master' + Fix spelling mistakes. + + See merge request libtiff/libtiff!183 + +2021-01-02 Kurt Schwehr <schwehr@google.com> + + ChangeLog: Remove extraneous character from prior commit - 00fe7828. + +2021-01-02 Roger Leigh <rleigh@codelibre.net> + + Merge branch 'codespell-custom_dir_EXIF_231' into 'master' + custom_dir_EXIF_231.c: dos2unix and codespell + + See merge request libtiff/libtiff!184 + +2021-01-01 Roger Leigh <rleigh@codelibre.net> + + mkg3states: Sync generator with current generated file content. + + cmake: Add faxtable and mkg3states targets. + +2020-12-31 Kurt Schwehr <schwehr@google.com> + + custom_dir_EXIF_231.c: dos2unix and codespell. + additonal, Varable, greather, alwasy + +2020-12-31 Kurt Schwehr <schwehr@google.com> + + Fix spelling mistakes. + Found with: + + codespell --version + 1.17.1 + +2020-12-29 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'remove-some-vms-ifdef' into 'master' + Remove "ifdef VMS" that are no longer necessary. + + See merge request libtiff/libtiff!181 + +2020-12-29 Kurt Schwehr <schwehr@google.com> + + Remove "ifdef VMS" that are no longer necessary. + Both sides of the if are now the same. + +2020-12-29 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + + _TIFFBuiltinCODECS should be const. + +2020-12-28 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'issue-202' into 'master' + tiff2pdf.c: check that tiff_datasize fits in a signed tsize_t + + Closes #202 + + See merge request libtiff/libtiff!166 + +2020-12-28 Even Rouault <even.rouault@spatialys.com> + + Merge branch 'w_report-when-libdeflate-is-found' into 'master' + CMakeLists.txt: Report when libdeflate is found + + See merge request libtiff/libtiff!175 + +2020-12-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + + Declare gpsFields as static const. + +2020-12-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + + Merge branch 'tools-reduce-initialized-data' into 'master' + Reduce initialized data by making more data const and simplifying usage() implementation. + + See merge request libtiff/libtiff!180 + +2020-12-28 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + + Reduce initialized data by making more data const and simplifying usage() implementation. + +2020-12-27 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + + Merge branch 'master' into 'master' + tiff tools: display of compression methods is now conditional instead of hard-coded + + See merge request libtiff/libtiff!176 + +2020-12-27 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + + Merge branch 'build' into 'master' + Fix wrong URL for fetching config.guess and config.sub + + See merge request libtiff/libtiff!177 + +2020-12-26 Chocobo1 <Chocobo1@users.noreply.github.com> + + Fix wrong URL for fetching config.guess and config.sub. + +2020-12-25 miguel <medalist@sapo.pt> + + tiff tools: made display of compression methods and their parameters conditional on their actual availability + +2020-12-20 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + + autogen.sh now updates config.guess and config.sub from master gnulib version. + +2020-12-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> + + Add a https://libtiff.gitlab.io/libtiff/ link. + + Remove stray character in URL area. + + Changes for 4.2.0 release. + + Changes for 4.2.0 release. + 2020-12-19 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> * libtiff 4.2.0 released. @@ -469,7 +1365,7 @@ see #17 tiffmedian: shopw usage on stdout when -h is used. - aslo use EXIT_SUCCESS/EXIT_FAILURE + also use EXIT_SUCCESS/EXIT_FAILURE see #17 tiffinfo: print usage on stdout when -h is used. @@ -674,7 +1570,7 @@ 2020-03-27 Thomas Bernard <miniupnp@free.fr> tiff2pdf: fix "raw" copy of Deflate streams. - The Predictor parametter was not copied from the source tiff to the PDF. + The Predictor parameter was not copied from the source tiff to the PDF. fixes #48 / http://bugzilla.maptools.org/show_bug.cgi?id=2442 2020-03-26 Thomas Bernard <miniupnp@free.fr> @@ -982,7 +1878,7 @@ - EXIF_GPS_upgrade rebased onto c8c5309b765ef4ff097d2aaffbdb8f403db8967d (Merge branch 'Rational2DoublePrecision_correction' into 'master') and adapted: - tif_dirinfo.c: All rational tags set to TIFF_SETGET_FLOAT but only the GPSTAG_ tags set to TIFF_SETGET_DOUBLE. - - custom_dir_EXIF_231.c: Editorials amended and gcc warnigs fixed. + - custom_dir_EXIF_231.c: Editorials amended and gcc warnings fixed. - CMakeLists.txt: add_test(NAME "custom_dir_EXIF_231" COMMAND "custom_dir_EXIF_231") added. 2020-03-07 Even Rouault <even.rouault@spatialys.com> @@ -1006,7 +1902,7 @@ fix #55 http://bugzilla.maptools.org/show_bug.cgi?id=2505 - Patch originally submited by Ludolf Holzheid <ludolf.holzheid@gmx.de> + Patch originally submitted by Ludolf Holzheid <ludolf.holzheid@gmx.de> 2020-03-06 Even Rouault <even.rouault@spatialys.com> @@ -1129,7 +2025,7 @@ 2020-02-29 Su_Laus <sulau@freenet.de> - tif_dirwrite.c: bugfix DoubleToSrational(), which returns plain signed interger values always as unsigned rationals. Add a test into rational_precision2double.c for "-1.0" and some editorials in tif_dirwrite.c. (code is related to 6df997c786928757caea0dd68d26ea5f098f49df changes). + tif_dirwrite.c: bugfix DoubleToSrational(), which returns plain signed integer values always as unsigned rationals. Add a test into rational_precision2double.c for "-1.0" and some editorials in tif_dirwrite.c. (code is related to 6df997c786928757caea0dd68d26ea5f098f49df changes). 2020-02-29 Even Rouault <even.rouault@spatialys.com> @@ -1174,7 +2070,7 @@ Rational with Double Precision Upgrade. Unfortunately, custom rational tags (TIFF_RATIONAL with field_bit=FIELD_CUSTOM) are defined as TIFF_SETGET_DOUBLE - but for the reading interface and LibTiff internally they are stored ALLWAYS as floating point SINGLE precision. + but for the reading interface and LibTiff internally they are stored ALWAYS as floating point SINGLE precision. Double precision custom rational tags are not supported by LibTiff. For the GPS tags in WGS84 a higher accuracy / precision is needed. @@ -1269,7 +2165,7 @@ raw2tiff: avoid divide by 0. fixes #151 / http://bugzilla.maptools.org/show_bug.cgi?id=2839 - first memcmp() lines before computing corellation + first memcmp() lines before computing correlation and always avoid divide by 0 anyway 2020-02-09 Even Rouault <even.rouault@spatialys.com> @@ -1294,7 +2190,7 @@ tiffcrop.c:4027:20: runtime error: left shift of 190 by 24 places cannot be represented in type 'int' C treats (byte << 24) as an int expression. - casting explicitely to unsigned type uint32 avoids the problem. + casting explicitly to unsigned type uint32 avoids the problem. the same issue has been fixed elsewhere with a24213691616e7cd35aa3e2805493de80c7e4fcf @@ -1523,7 +2419,7 @@ 2019-08-25 Even Rouault <even.rouault@spatialys.com> - JPEG: avoid use of unintialized memory on corrupted files. + JPEG: avoid use of uninitialized memory on corrupted files. Follow-up of cf3ce6fab894414a336546f62adc57f02590a22c Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16602 Credit to OSS Fuzz @@ -1587,7 +2483,7 @@ signed), which was especially easily triggered on 32-bit builds (with recent enough compilers that assume that signed multiplication cannot overflow, since this is undefined behaviour by the C standard). The original issue which lead to - this fix was trigged from tif_fax3.c + this fix was triggered from tif_fax3.c There were also unsafe (implementation defied), and broken in practice on 64bit builds, ways of checking that a uint64 fits of a (signed) tmsize_t by doing @@ -1660,7 +2556,7 @@ - Discussion in https://gitlab.com/libtiff/libtiff/merge_requests/39 - http://bugzilla.maptools.org/show_bug.cgi?id=2540 - Comments and indention adapted. + Comments and indentation adapted. Preparation to rebase onto master @@ -1680,7 +2576,7 @@ [00:02:58] -- CMAKE_HOST_SYSTEM_PROCESSOR set to AMD64 [00:02:58] -- HOST_FILLORDER set to FILLORDER_MSB2LSB - Ther reason is that we match the "amd64.*" lowercase string whereas + The reason is that we match the "amd64.*" lowercase string whereas CMAKE_HOST_SYSTEM_PROCESSOR is set to AMD64 uppercase. 2019-07-09 Even Rouault <even.rouault@spatialys.com> @@ -1690,13 +2586,13 @@ 2019-07-09 Even Rouault <even.rouault@spatialys.com> Merge branch 'fix_chromium_925269' into 'master' - OJPEG: avoid use of unintialized memory on corrupted files + OJPEG: avoid use of uninitialized memory on corrupted files See merge request libtiff/libtiff!86 2019-07-05 Even Rouault <even.rouault@spatialys.com> - OJPEG: avoid use of unintialized memory on corrupted files. + OJPEG: avoid use of uninitialized memory on corrupted files. Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=925269 Patch from Lei Zhang with little adaptations. @@ -1849,12 +2745,12 @@ arrays are only loaded when first accessed. This can speed-up the opening of files stored on the network when just metadata retrieval is needed. This mode has been used for years by the GDAL library when compiled with - its embeded libtiff copy. + its embedded libtiff copy. To avoid potential out-of-tree code (typically codecs) that would use the td_stripbytecount and td_stripoffset array inconditionnaly assuming they have been loaded, those have been suffixed with _p (for protected). The - use of the new functions mentionned below is then recommended. + use of the new functions mentioned below is then recommended. Another addition of this commit is the capability of loading only the values of the offset/bytecount of the strile of interest instead of the @@ -1870,7 +2766,7 @@ if a strile is present or not without decompressing the data, or updating an existing sparse file. They will also be used to enable a future enhancement where client code can entirely - skip bytecount loading in some situtations + skip bytecount loading in some situations A new test/defer_strile_loading.c test has been added to test the above capabilities. @@ -2141,8 +3037,8 @@ Also the values were not properly calculated. It should be 255-x, 15-x, 3-x for bps 8, 4, 2. - But anyway it is easyer to invert all bits as 255-x = ~x, etc. - (substracting from a binary number composed of all 1 is like inverting + But anyway it is easier to invert all bits as 255-x = ~x, etc. + (subtracting from a binary number composed of all 1 is like inverting the bits) 2019-02-11 Thomas Bernard <miniupnp@free.fr> @@ -2670,7 +3566,7 @@ Merge branch 'zstd' - Add warning about COMPRESSION_ZSTD not being officialy registered. + Add warning about COMPRESSION_ZSTD not being officially registered. 2018-02-14 Even Rouault <even.rouault@mines-paris.org> @@ -2900,7 +3796,7 @@ result, we end up writing past the end of the buffer. There are also some related issues that this also fixes. For example, - TIFFGetField can return uninitalized pointer values, and the logic to + TIFFGetField can return uninitialized pointer values, and the logic to detect a N=3 vs N=1 transfer function seemed rather strange. It is also strange that we declare the transfer functions to be of type @@ -3315,7 +4211,7 @@ scans and not interleavedin a single one, needs to allocate memory (or backing store) for the whole strip/tile. See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf - This limitation may be overriden by setting the + This limitation may be overridden by setting the LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompiling libtiff with a custom value of TIFF_LIBJPEG_LARGEST_MEM_ALLOC macro. @@ -3598,7 +4494,7 @@ * libtiff/tif_jpeg.c: only run JPEGFixupTagsSubsampling() if the YCbCrSubsampling tag is not explicitly present. This helps a bit to reduce - the I/O amount when te tag is present (especially on cloud hosted files). + the I/O amount when the tag is present (especially on cloud hosted files). 2017-01-14 Even Rouault <even.rouault at spatialys.com> @@ -3839,7 +4735,7 @@ 2016-12-03 Even Rouault <even.rouault at spatialys.com> * libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to - instanciate compute ntrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip), + instantiate compute ntrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip), instead of a logic based on the total size of data. Which is faulty is the total size of data is not sufficient to fill the whole image, and thus results in reading outside of the StripByCounts/StripOffsets arrays when @@ -3863,7 +4759,7 @@ 2016-12-02 Even Rouault <even.rouault at spatialys.com> - * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that + * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that can cause various issues, such as buffer overflows in the library. Reported by Agostino Sarubbo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2598 @@ -4305,7 +5201,7 @@ * libtiff/tif_write.c: TIFFWriteEncodedStrip() and TIFFWriteEncodedTile() should return -1 in case of failure of tif_encodestrip() as documented * libtiff/tif_dumpmode.c: DumpModeEncode() should return 0 in case of - failure so that the above mentionned functions detect the error. + failure so that the above mentioned functions detect the error. 2015-12-06 Even Rouault <even.rouault at spatialys.com> @@ -4328,7 +5224,7 @@ 2015-11-22 Even Rouault <even.rouault at spatialys.com> * libtiff/*.c: fix typos in comments (patch by Kurt Schwehr) - + 2015-11-22 Even Rouault <even.rouault at spatialys.com> * libtiff/*.c: fix MSVC warnings related to cast shortening and @@ -4896,7 +5792,7 @@ 2014-12-27 Even Rouault <even.rouault@spatialys.com> * libtiff/tif_dir.c: in TIFFDefaultDirectory(), reset any already existing - extented tags installed by user code through the extender mechaninm before + extended tags installed by user code through the extender mechanism before calling the extender callback (GDAL #5054) 2014-12-26 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> @@ -4999,14 +5895,14 @@ cpStripToTile() (called from writeBufferToContigTiles). Note that the resulting TIFF file would be scrambled even if tiffcp wouldn't crash, since the output file would contain - RGB data intepreted as subsampled YCbCr values. + RGB data interpreted as subsampled YCbCr values. This patch fixes the problem by forcing RGB space on the output TIF if the input is JPEG-encoded and output is *not* JPEG-encoded. Author: Tomasz Buchert <tomasz.buchert@inria.fr> 2014-12-21 Even Rouault <even.rouault@spatialys.com> - Fix various crasher bugs on fuzzed images. + Fix various crash bugs on fuzzed images. * libtiff/tif_dir.c: TIFFSetField(): refuse to set negative values for TIFFTAG_XRESOLUTION and TIFFTAG_YRESOLUTION that cause asserts when writing the directory @@ -5343,7 +6239,7 @@ * libtiff 4.0.2 released. - * tools/tif2pdf.c, tools/tifdump.c: avoid unitialized variable + * tools/tif2pdf.c, tools/tifdump.c: avoid uninitialized variable warnings with clang. 2012-06-15 Tom Lane <tgl@sss.pgh.pa.us> @@ -6990,7 +7886,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic Added support for a TIFF_PTRDIFF_T type to use when doing pointer arithmetic. Added support for a TIFF_SSIZE_T in order to return memory sizes but still allow returning -1 for errors. - * libtiff/tiffconf.vc.h: Add porting type defintions for WIN32. + * libtiff/tiffconf.vc.h: Add porting type definitions for WIN32. 2007-06-25 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> @@ -7125,7 +8021,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic * libtiff/tif_config.wince.h: Added configuration header for WinCE. * libtiff/tiffconf.wince.h: Ported old configuration header for WinCE. * libtiff/tif_wince.c: Added WinCE-specific implementation of some - functons from tif_win32.c. + functions from tif_win32.c. * libtiff/tif_win32.c: Disabled some functions already reimplemented in tif_wince.c. * libtiff/tiffiop.h, port/lfind.c: Added conditional include of some standard header files for Windows CE build. @@ -7369,7 +8265,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic * libtiff/tif_jpeg.c: strip size related bugfix in encode raw - * libtiff/tif_strip.c: temporarilly added two new versions of + * libtiff/tif_strip.c: temporarily added two new versions of TIFFScanlineSize - TIFFNewScanlineSize: proposed new version, after all related issues and side-effects are sorted out @@ -7429,7 +8325,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2006-03-16 Andrey Kiselev <dron@ak4719.spb.edu> - * libtiff/tiffiop.h: Added decalration for + * libtiff/tiffiop.h: Added declaration for _TIFFSetDefaultCompressionState(). * libtiff/{tif_jpeg.c, tif_fax3.c, tif_zip.c, tif_pixarlog.c, @@ -7759,7 +8655,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic http://bugzilla.remotesensing.org/show_bug.cgi?id=1003 - * libtiff/tif_dirinfo.c: Correctly yse bsearch() and lfind() + * libtiff/tif_dirinfo.c: Correctly use bsearch() and lfind() functions as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1008 @@ -7804,7 +8700,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic http://bugzilla.remotesensing.org/show_bug.cgi?id=977 - * tools/tiffsplit.c: Copy fax related fields over splitted parts + * tools/tiffsplit.c: Copy fax related fields over split parts as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=983 @@ -7986,12 +8882,12 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2005-06-07 Andrey Kiselev <dron@ak4719.spb.edu> * contrib/addtiffo/tif_ovrcache.c: Properly extract tile/strip size; - use pixel sized shift in contigous case. + use pixel sized shift in contiguous case. 2005-06-06 Andrey Kiselev <dron@ak4719.spb.edu> * contrib/addtiffo/{tif_overview.c, tif_ovrcache.c, tif_ovrcache.h}: - Make overviews working for contiguos images. + Make overviews working for contiguous images. 2005-06-03 Andrey Kiselev <dron@ak4719.spb.edu> @@ -8421,7 +9317,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic http://bugzilla.remotesensing.org/show_bug.cgi?id=697 - * libtiff/tif_config.in.vc: Removed unneded definitions for + * libtiff/tif_config.in.vc: Removed unneeded definitions for read/open/close/lseek functions to fix the http://bugzilla.remotesensing.org/show_bug.cgi?id=680 @@ -9280,7 +10176,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic * man/tiff2pdf.1: Few improvements in page layout. * Makefile.in, /man/Makefile.in, /html/man/tiff2pdf.1.html: - Added support fpr tiff2pdf manual page. + Added support for tiff2pdf manual page. 2003-11-26 Ross Finlayson <libtiff@apexinternetsoftware.com> @@ -9289,7 +10185,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2003-11-26 Andrey Kiselev <dron@ak4719.spb.edu> * Makefile.in, /tools/{Makefile.in, makefile.vc}: - Added support fpr tiff2pdf utility. + Added support for tiff2pdf utility. 2003-11-25 Ross Finlayson <libtiff@apexinternetsoftware.com> @@ -9332,7 +10228,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2003-11-17 Andrey Kiselev <dron@ak4719.spb.edu> * contrib/pds/{tif_pdsdirread.c, tif_pdsdirwrite.c}: Use - TIFFDataWidth() function insted of tiffDataWidth array. + TIFFDataWidth() function instead of tiffDataWidth array. 2003-11-16 Andrey Kiselev <dron@ak4719.spb.edu> @@ -10119,7 +11015,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic TIFFDataType sizes instead of working with tiffDataWidth array directly. Should prevent out-of-borders bugs in case of unknown or broken data types. EstimateStripByteCounts routine modified, so it - won't work when tags with uknown sizes founded. + won't work when tags with unknown sizes founded. Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=109 2002-03-13 Andrey Kiselev <dron@ak4719.spb.edu> @@ -10321,7 +11217,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic * libtiff/tif_getimage.c: relax handling of contig case where there are extra samples that are supposed to be ignored. This - should now work for 8bit greyscale or palletted images. + should now work for 8bit greyscale or paletted images. http://bugzilla.remotesensing.org/show_bug.cgi?id=75 @@ -10551,7 +11447,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2001-02-16 Frank Warmerdam <warmerdam@pobox.com> * libtiff/libtiff.def: Brent Roman submitted new version adding - serveral missing entry points. + several missing entry points. * libtiff/tif_dirinfo.c: don't declare tiffFieldInfo static on VMS. Some sort of weird VMS thing. @@ -10961,7 +11857,7 @@ Tue Nov 30 14:41:43 1999 Frank Warmerdam <warmerda@gdal.velocet.ca> *** 3.5 Tue Nov 30 14:15:32 EST 1999 Mike Welles <mike@onshore.com> - * Added zip creation to relase makefile target + * Added zip creation to release makefile target * Added html for TIFFWriteTile.3t man page. diff --git a/tiff/HOWTO-RELEASE b/tiff/HOWTO-RELEASE index abcdc9ba..dfadd5cd 100644 --- a/tiff/HOWTO-RELEASE +++ b/tiff/HOWTO-RELEASE @@ -25,7 +25,11 @@ Notes on releasing. 1. Commit any unsaved changes. 2. Use gnulib's gitlog-to-changelog script to add new (since the last - release) entries to the traditional ChangeLog file. Take note of + release) entries to the traditional ChangeLog file. + + http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/gitlog-to-changelog + + Take note of the most recent change note time stamp and use that as the starting point. Concatenate the old logs to the new logs. The added logs may be used to help produce the release notes (in next step). For @@ -43,7 +47,8 @@ Notes on releasing. 4. Add vX.X.html file to the list of 'docfiles' files in the html/Makefile.am. -5. Update html/index.html to refer to this new page as the current release. +5. Update html/index.html to refer to this new page as the current release, + and update date at the bottom of the page 6. Increment the release version in configure.ac. Put 'alpha' or 'beta' after the version, if applicable. For example: @@ -140,7 +145,7 @@ Notes on releasing. 17. Copy release packages from the build tree to the ftp.remotesensing.org ftp site. - scp tiff-*.tar.gz tiff-*.zip \ + scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.zip tiff-*.zip.sig \ bfriesen@upload.osgeo.org:/osgeo/download/libtiff 18. Announce to list, tiff@lists.maptools.org diff --git a/tiff/Makefile.am b/tiff/Makefile.am index d19e58ee..f34dac2b 100644 --- a/tiff/Makefile.am +++ b/tiff/Makefile.am @@ -37,14 +37,11 @@ docfiles = \ VERSION EXTRA_DIST = \ + cmake \ CMakeLists.txt \ HOWTO-RELEASE \ - Makefile.vc \ - SConstruct \ autogen.sh \ - configure.com \ - libtiff-4.pc.in \ - nmake.opt + libtiff-4.pc.in dist_doc_DATA = $(docfiles) diff --git a/tiff/Makefile.in b/tiff/Makefile.in index a4a7b80c..e272bd7d 100644 --- a/tiff/Makefile.in +++ b/tiff/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -126,8 +126,9 @@ DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = config.h $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = libtiff-4.pc CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -194,7 +195,8 @@ am__recursive_targets = \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir distdir-am dist dist-all distcheck -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. @@ -215,13 +217,14 @@ ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libtiff-4.pc.in \ - $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \ +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(srcdir)/libtiff-4.pc.in $(top_srcdir)/config/compile \ + $(top_srcdir)/config/config.guess \ $(top_srcdir)/config/config.sub \ $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \ $(top_srcdir)/config/missing ChangeLog TODO config/compile \ - config/config.guess config/config.sub config/depcomp \ - config/install-sh config/ltmain.sh config/missing + config/config.guess config/config.sub config/install-sh \ + config/ltmain.sh config/missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -403,6 +406,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -423,14 +427,11 @@ docfiles = \ VERSION EXTRA_DIST = \ + cmake \ CMakeLists.txt \ HOWTO-RELEASE \ - Makefile.vc \ - SConstruct \ autogen.sh \ - configure.com \ - libtiff-4.pc.in \ - nmake.opt + libtiff-4.pc.in dist_doc_DATA = $(docfiles) SUBDIRS = port libtiff tools build contrib test man html @@ -443,7 +444,8 @@ COVERITY_EMAIL = bfriesen@simple.dallas.tx.us COVERITY_TARBALL = libtiff.xz COVERITY_VERSION = devel-${PACKAGE_CHANGE_DATE} COVERITY_DESCRIPTION = 'libtiff development' -all: all-recursive +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: Makefile @@ -479,6 +481,21 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): + +config.h: stamp-h1 + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 libtiff-4.pc: $(top_builddir)/config.status $(srcdir)/libtiff-4.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ @@ -722,10 +739,6 @@ dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) -dist-zstd: distdir - tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst - $(am__post_remove_distdir) - dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @@ -767,8 +780,6 @@ distcheck: dist eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ - *.tar.zst*) \ - zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) @@ -838,7 +849,7 @@ distcleancheck: distclean exit 1; } >&2 check-am: all-am check: check-recursive -all-am: Makefile $(DATA) +all-am: Makefile $(DATA) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)"; do \ @@ -881,8 +892,8 @@ clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-libtool \ - distclean-tags +distclean-am: clean-am distclean-generic distclean-hdr \ + distclean-libtool distclean-tags dvi: dvi-recursive @@ -944,25 +955,25 @@ ps-am: uninstall-am: uninstall-dist_docDATA uninstall-pkgconfigDATA -.MAKE: $(am__recursive_targets) install-am install-strip +.MAKE: $(am__recursive_targets) all install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ - dist-xz dist-zip dist-zstd distcheck distclean \ - distclean-generic distclean-libtool distclean-tags \ - distcleancheck distdir distuninstallcheck dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dist_docDATA install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-pkgconfigDATA install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-dist_docDATA uninstall-pkgconfigDATA + dist-xz dist-zip distcheck distclean distclean-generic \ + distclean-hdr distclean-libtool distclean-tags distcleancheck \ + distdir distuninstallcheck dvi dvi-am html html-am info \ + info-am install install-am install-data install-data-am \ + install-dist_docDATA install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-pkgconfigDATA install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-dist_docDATA \ + uninstall-pkgconfigDATA .PRECIOUS: Makefile diff --git a/tiff/Makefile.vc b/tiff/Makefile.vc deleted file mode 100644 index eeb5d04d..00000000 --- a/tiff/Makefile.vc +++ /dev/null @@ -1,60 +0,0 @@ -# -# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# -# Makefile for MS Visual C and Watcom C compilers. -# Edit nmake.opt file if you want to ajust building options. -# -# To build: -# C:\libtiff> nmake /f makefile.vc - -!INCLUDE nmake.opt - -all: port lib tools - -port:: - cd libtiff - $(MAKE) /f Makefile.vc tif_config.h - cd.. - cd port - $(MAKE) /f Makefile.vc - cd.. - -lib: port - cd libtiff - $(MAKE) /f Makefile.vc - cd.. - -tools: lib - cd tools - $(MAKE) /f Makefile.vc - cd .. - -clean: - cd port - $(MAKE) /f Makefile.vc clean - cd.. - cd libtiff - $(MAKE) /f Makefile.vc clean - cd.. - cd tools - $(MAKE) /f Makefile.vc clean - cd .. diff --git a/tiff/RELEASE-DATE b/tiff/RELEASE-DATE index 1137155e..e74bf2b4 100644 --- a/tiff/RELEASE-DATE +++ b/tiff/RELEASE-DATE @@ -1 +1 @@ -20201219 +20210416 diff --git a/tiff/SConstruct b/tiff/SConstruct deleted file mode 100644 index ee87fedf..00000000 --- a/tiff/SConstruct +++ /dev/null @@ -1,169 +0,0 @@ -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2005, Andrey Kiselev <dron@ak4719.spb.edu> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# This file contains rules to build software with the SCons tool -# (see the http://www.scons.org/ for details on SCons). - -import os - -env = Environment() - -# Read the user supplied options -opts = Options('libtiff.conf') -opts.Add(PathOption('PREFIX', \ - 'install architecture-independent files in this directory', \ - '/usr/local', PathOption.PathIsDirCreate)) -opts.Add(BoolOption('ccitt', \ - 'enable support for CCITT Group 3 & 4 algorithms', \ - 'yes')) -opts.Add(BoolOption('packbits', \ - 'enable support for Macintosh PackBits algorithm', \ - 'yes')) -opts.Add(BoolOption('lzw', \ - 'enable support for LZW algorithm', \ - 'yes')) -opts.Add(BoolOption('thunder', \ - 'enable support for ThunderScan 4-bit RLE algorithm', \ - 'yes')) -opts.Add(BoolOption('next', \ - 'enable support for NeXT 2-bit RLE algorithm', \ - 'yes')) -opts.Add(BoolOption('logluv', \ - 'enable support for LogLuv high dynamic range encoding', \ - 'yes')) -opts.Add(BoolOption('strip_chopping', \ - 'support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage)', \ - 'yes')) -opts.Add(BoolOption('extrasample_as_alpha', \ - 'the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don\'t mark the alpha properly', \ - 'yes')) -opts.Add(BoolOption('check_ycbcr_subsampling', \ - 'disable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag', \ - 'yes')) -opts.Update(env) -opts.Save('libtiff.conf', env) -Help(opts.GenerateHelpText(env)) - -# Here are our installation paths: -idir_prefix = '$PREFIX' -idir_lib = '$PREFIX/lib' -idir_bin = '$PREFIX/bin' -idir_inc = '$PREFIX/include' -idir_doc = '$PREFIX/doc' -Export([ 'env', 'idir_prefix', 'idir_lib', 'idir_bin', 'idir_inc', 'idir_doc' ]) - -# Now proceed to system feature checks -target_cpu, target_vendor, target_kernel, target_os = \ - os.popen("./config/config.guess").readlines()[0].split("-") - -def Define(context, key, have): - import SCons.Conftest - SCons.Conftest._Have(context, key, have) - -def CheckCustomOption(context, name): - context.Message('Checking is the ' + name + ' option set... ') - ret = env[name] - Define(context, name + '_SUPPORT', ret) - context.Result(ret) - return ret - -def CheckFillorderOption(context): - context.Message('Checking for the native cpu bit order... ') - if target_cpu[0] == 'i' and target_cpu[2:] == '86': - Define(context, 'HOST_FILLORDER', 'FILLORDER_LSB2MSB') - context.Result('lsb2msb') - else: - Define(context, 'HOST_FILLORDER', 'FILLORDER_MSB2LSB') - context.Result('msb2lsb') - return 1 - -def CheckIEEEFPOption(context): - context.Message('Checking for the IEEE floating point format... ') - Define(context, 'HAVE_IEEEFP', 1) - context.Result(1) - return 1 - -def CheckOtherOption(context, name): - context.Message('Checking is the ' + name + ' option set... ') - ret = env[name] - Define(context, 'HAVE_' + name, ret) - context.Result(ret) - return ret - -custom_tests = { \ - 'CheckCustomOption' : CheckCustomOption, \ - 'CheckFillorderOption' : CheckFillorderOption, \ - 'CheckIEEEFPOption' : CheckIEEEFPOption, \ - 'CheckOtherOption' : CheckOtherOption \ - } -conf = Configure(env, custom_tests = custom_tests, \ - config_h = 'libtiff/tif_config.h') - -# Check for standard library -conf.CheckLib('c') -if target_os != 'cygwin' \ - and target_os != 'mingw32' \ - and target_os != 'beos' \ - and target_os != 'darwin': - conf.CheckLib('m') - -# Check for system headers -conf.CheckCHeader('assert.h') -conf.CheckCHeader('fcntl.h') -conf.CheckCHeader('io.h') -conf.CheckCHeader('limits.h') -conf.CheckCHeader('malloc.h') -conf.CheckCHeader('search.h') -conf.CheckCHeader('sys/time.h') -conf.CheckCHeader('unistd.h') - -# Check for standard library functions -conf.CheckFunc('floor') -conf.CheckFunc('isascii') -conf.CheckFunc('memmove') -conf.CheckFunc('memset') -conf.CheckFunc('mmap') -conf.CheckFunc('pow') -conf.CheckFunc('setmode') -conf.CheckFunc('sqrt') -conf.CheckFunc('strchr') -conf.CheckFunc('strrchr') -conf.CheckFunc('strstr') -conf.CheckFunc('strtol') - -conf.CheckFillorderOption() -conf.CheckIEEEFPOption() -conf.CheckCustomOption('ccitt') -conf.CheckCustomOption('packbits') -conf.CheckCustomOption('lzw') -conf.CheckCustomOption('thunder') -conf.CheckCustomOption('next') -conf.CheckCustomOption('logluv') -conf.CheckOtherOption('strip_chopping') -conf.CheckOtherOption('extrasample_as_alpha') -conf.CheckOtherOption('check_ycbcr_subsampling') - -env = conf.Finish() - -# Ok, now go to build files in the subdirectories -SConscript(dirs = [ 'libtiff' ], name = 'SConstruct') diff --git a/tiff/VERSION b/tiff/VERSION index 6aba2b24..80895903 100644 --- a/tiff/VERSION +++ b/tiff/VERSION @@ -1 +1 @@ -4.2.0 +4.3.0 diff --git a/tiff/aclocal.m4 b/tiff/aclocal.m4 index 3ba29cd2..9299d04d 100644 --- a/tiff/aclocal.m4 +++ b/tiff/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.2 -*- Autoconf -*- +# generated automatically by aclocal 1.16.1 -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2020 Free Software Foundation, Inc. +# Copyright (C) 2002-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.2], [], +m4_if([$1], [1.16.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.2])dnl +[AM_AUTOMAKE_VERSION([1.16.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2020 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -332,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2020 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -371,9 +371,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. If GNU make was not used, consider - re-running the configure script with MAKE="gmake" (or whatever is - necessary). You can also try re-running configure with the + for automatic dependency tracking. Try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi @@ -400,7 +398,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -597,7 +595,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -618,7 +616,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2020 Free Software Foundation, Inc. +# Copyright (C) 2003-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -640,7 +638,7 @@ AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -675,7 +673,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -718,7 +716,7 @@ AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2020 Free Software Foundation, Inc. +# Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -757,7 +755,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -786,7 +784,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2020 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -833,7 +831,7 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -852,7 +850,7 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2020 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -933,7 +931,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2020 Free Software Foundation, Inc. +# Copyright (C) 2009-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -993,7 +991,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2020 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1021,7 +1019,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2020 Free Software Foundation, Inc. +# Copyright (C) 2006-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1040,7 +1038,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2020 Free Software Foundation, Inc. +# Copyright (C) 2004-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/tiff/autogen.sh b/tiff/autogen.sh index 56338850..9ef71b53 100755 --- a/tiff/autogen.sh +++ b/tiff/autogen.sh @@ -5,4 +5,16 @@ aclocal -I ./m4 autoheader automake --foreign --add-missing --copy autoconf - +# Get latest config.guess and config.sub from upstream master since +# these are often out of date. +for file in config.guess config.sub +do + echo "$0: getting $file..." + wget -q --timeout=5 -O config/$file.tmp \ + "https://git.savannah.gnu.org/cgit/config.git/plain/${file}" \ + && mv config/$file.tmp config/$file \ + && chmod a+x config/$file + retval=$? + rm -f config/$file.tmp + test $retval -eq 0 || exit $retval +done diff --git a/tiff/build/CMakeLists.txt b/tiff/build/CMakeLists.txt index d44c6eac..756fb716 100644 --- a/tiff/build/CMakeLists.txt +++ b/tiff/build/CMakeLists.txt @@ -21,5 +21,3 @@ # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. - -extra_dist(README) diff --git a/tiff/build/Makefile.in b/tiff/build/Makefile.in index d0893046..148f618f 100644 --- a/tiff/build/Makefile.in +++ b/tiff/build/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -123,8 +123,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -348,6 +350,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/cmake/AutotoolsCompat.cmake b/tiff/cmake/AutotoolsCompat.cmake new file mode 100644 index 00000000..f491a8a1 --- /dev/null +++ b/tiff/cmake/AutotoolsCompat.cmake @@ -0,0 +1,32 @@ +# Autotools compatibility +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +# For autotools header compatibility +set(PACKAGE_NAME "LibTIFF Software") +set(PACKAGE_TARNAME "${PROJECT_NAME}") +set(PACKAGE_VERSION "${PROJECT_VERSION}${LIBTIFF_ALPHA_VERSION}") +set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") +set(PACKAGE_BUGREPORT "tiff@lists.maptools.org") diff --git a/tiff/cmake/AutotoolsVersion.cmake b/tiff/cmake/AutotoolsVersion.cmake new file mode 100644 index 00000000..0f660878 --- /dev/null +++ b/tiff/cmake/AutotoolsVersion.cmake @@ -0,0 +1,50 @@ +# Read version information from configure.ac. +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +# Get version from configure.ac +FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure REGEX "^LIBTIFF_.*=") +foreach(line ${configure}) + foreach(var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION + LIBTIFF_CURRENT LIBTIFF_REVISION LIBTIFF_AGE) + if(NOT ${var} AND line MATCHES "^${var}=(.*)") + set(${var} "${CMAKE_MATCH_1}") + break() + endif() + endforeach() +endforeach() + +# Package version +set(LIBTIFF_VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}") +set(LIBTIFF_VERSION_FULL "${LIBTIFF_VERSION}${LIBTIFF_ALPHA_VERSION}") + +# Convert the libtool version variables to proper major and minor versions +math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}") +set(SO_MINOR "${LIBTIFF_AGE}") +set(SO_REVISION "${LIBTIFF_REVISION}") + +# Library version (unlike libtool's baroque scheme, WYSIWYG here) +set(SO_COMPATVERSION "${SO_MAJOR}") +set(SO_VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}") diff --git a/tiff/contrib/ras/CMakeLists.txt b/tiff/cmake/CXXLibrary.cmake index b19a04fa..3fc15a98 100644 --- a/tiff/contrib/ras/CMakeLists.txt +++ b/tiff/cmake/CXXLibrary.cmake @@ -1,6 +1,7 @@ -# CMake build for libtiff +# C++ library option # # Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> # Written by Roger Leigh <rleigh@codelibre.net> # # Permission to use, copy, modify, distribute, and sell this software and @@ -22,7 +23,10 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -extra_dist( - README - ras2tif.c - tif2ras.c) +# C++ support +option(cxx "Enable C++ stream API building (requires C++ compiler)" ON) +set(CXX_SUPPORT FALSE) +if (cxx) + enable_language(CXX) + set(CXX_SUPPORT TRUE) +endif() diff --git a/tiff/cmake/CompilerChecks.cmake b/tiff/cmake/CompilerChecks.cmake new file mode 100644 index 00000000..8ac5564b --- /dev/null +++ b/tiff/cmake/CompilerChecks.cmake @@ -0,0 +1,124 @@ +# Compiler feature checks +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +include(CheckCCompilerFlag) + + +# These are annoyingly verbose, produce false positives or don't work +# nicely with all supported compiler versions, so are disabled unless +# explicitly enabled. +option(extra-warnings "Enable extra compiler warnings" OFF) + +# This will cause the compiler to fail when an error occurs. +option(fatal-warnings "Compiler warnings are errors" OFF) + +# Check if the compiler supports each of the following additional +# flags, and enable them if supported. This greatly improves the +# quality of the build by checking for a number of common problems, +# some of which are quite serious. +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR + CMAKE_C_COMPILER_ID MATCHES "Clang") + set(test_flags + -Wall + -Winline + -Wformat-security + -Wpointer-arith + -Wdisabled-optimization + -Wno-unknown-pragmas + -fstrict-aliasing) + if(extra-warnings) + list(APPEND test_flags + -pedantic + -Wextra + -Wformat + -Wformat-overflow + -Wformat-nonliteral + -Wformat-signedness + -Wformat-truncation + -Wdeclaration-after-statement + -Wconversion + -Wsign-conversion + -Wnull-dereference + -Wdouble-promotion + -Wmisleading-indentation + -Wmissing-include-dirs + -Wswitch-default + -Wswitch-enum + -Wunused-local-typedefs + -Wunused-parameter + -Wuninitialized + -Warith-conversion + -Wbool-operation + -Wduplicated-branches + -Wduplicated-cond + -Wshadow + -Wunused-macros + -Wc99-c11-compat + -Wcast-qual + -Wcast-align + -Wwrite-strings + -Wdangling-else + -Wsizeof-array-div + -Wsizeof-pointer-div + -Wsizeof-pointer-memaccess + -Wlogical-op + -Wlogical-not-parentheses + -Wstrict-prototypes + -Wmissing-declarations + -Wredundant-decls + -Wno-int-to-pointer-cast + -Wfloat-equal + -Wfloat-conversion + -Wmissing-prototypes + -Wunreachable-code) + endif() + if(fatal-warnings) + list(APPEND test_flags + -Werror) + endif() +elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + set(test_flags) + if(extra-warnings) + list(APPEND test_flags + /W4) + else() + list(APPEND test_flags + /W3) + endif() + if (fatal-warnings) + list(APPEND test_flags + /WX) + endif() +endif() + +foreach(flag ${test_flags}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}") + set(test_c_flag "C_FLAG${flag_var}") + CHECK_C_COMPILER_FLAG(${flag} "${test_c_flag}") + if (${test_c_flag}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif (${test_c_flag}) +endforeach(flag ${test_flags}) diff --git a/tiff/cmake/DeflateCodec.cmake b/tiff/cmake/DeflateCodec.cmake new file mode 100644 index 00000000..76e5673e --- /dev/null +++ b/tiff/cmake/DeflateCodec.cmake @@ -0,0 +1,45 @@ +# Checks for deflate codec support +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +# ZLIB +set(ZLIB_SUPPORT FALSE) +find_package(ZLIB) +option(zlib "use zlib (required for Deflate compression)" ${ZLIB_FOUND}) +if(zlib AND ZLIB_FOUND) + set(ZLIB_SUPPORT TRUE) +endif() +set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + +# libdeflate +set(LIBDEFLATE_SUPPORT FALSE) +find_package(Deflate) +option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) +if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +endif() +if(Deflate_FOUND AND NOT ZIP_SUPPORT) + message(WARNING "libdeflate available but zlib is not. libdeflate cannot be used") +endif() diff --git a/tiff/cmake/FindCMath.cmake b/tiff/cmake/FindCMath.cmake new file mode 100644 index 00000000..2da3b7f1 --- /dev/null +++ b/tiff/cmake/FindCMath.cmake @@ -0,0 +1,72 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindCMath +-------- + +Find the native CMath includes and library. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``CMath::CMath``, if +CMath has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + CMath_INCLUDE_DIRS - Where to find math.h + CMath_LIBRARIES - List of libraries when using CMath. + CMath_FOUND - True if CMath found. + +#]=======================================================================] + + +include(CheckSymbolExists) +include(CheckLibraryExists) + +check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW) +if(NOT CMath_HAVE_LIBC_POW) + find_library(CMath_LIBRARY NAMES m) + + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMath_LIBRARY}) + check_symbol_exists(pow "math.h" CMath_HAVE_LIBM_POW) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) +endif() + +set(CMath_pow FALSE) +if(CMath_HAVE_LIBC_POW OR CMath_HAVE_LIBM_POW) + set(CMath_pow TRUE) +endif() + +set(CMath_INCLUDE_DIRS) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CMath REQUIRED_VARS CMath_pow) + +if(CMath_FOUND) + if(NOT CMath_INCLUDE_DIRS) + set(CMath_INCLUDE_DIRS) + endif() + if(NOT CMath_LIBRARIES) + if (CMath_LIBRARY) + set(CMath_LIBRARIES ${CMath_LIBRARY}) + endif() + endif() + + if(NOT TARGET CMath::CMath) + if(CMath_LIBRARIES) + add_library(CMath::CMath UNKNOWN IMPORTED) + set_target_properties(CMath::CMath PROPERTIES + IMPORTED_LOCATION "${CMath_LIBRARY}") + else() + add_library(CMath::CMath INTERFACE IMPORTED) + endif() + endif() +endif() diff --git a/tiff/cmake/FindDeflate.cmake b/tiff/cmake/FindDeflate.cmake new file mode 100644 index 00000000..ef6a5765 --- /dev/null +++ b/tiff/cmake/FindDeflate.cmake @@ -0,0 +1,116 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindDeflate +-------- + +Find the native Deflate includes and library. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``Deflate::Deflate``, if +Deflate has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + Deflate_INCLUDE_DIRS - where to find deflate.h, etc. + Deflate_LIBRARIES - List of libraries when using deflate. + Deflate_FOUND - True if deflate found. + +:: + + Deflate_VERSION_STRING - The version of deflate found (x.y.z) + Deflate_VERSION_MAJOR - The major version of deflate + Deflate_VERSION_MINOR - The minor version of deflate + + Debug and Release variants are found separately. +#]=======================================================================] + +# Standard names to search for +set(Deflate_NAMES deflate deflatestatic) +set(Deflate_NAMES_DEBUG deflated deflatestaticd) + +find_path(Deflate_INCLUDE_DIR + NAMES libdeflate.h + PATH_SUFFIXES include) + +set(Deflate_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") +# Library has a "lib" prefix even on Windows. +set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") + +# Allow Deflate_LIBRARY to be set manually, as the location of the deflate library +if(NOT Deflate_LIBRARY) + find_library(Deflate_LIBRARY_RELEASE + NAMES ${Deflate_NAMES} + PATH_SUFFIXES lib) + find_library(Deflate_LIBRARY_DEBUG + NAMES ${Deflate_NAMES_DEBUG} + PATH_SUFFIXES lib) + + include(SelectLibraryConfigurations) + select_library_configurations(Deflate) +endif() + +set(CMAKE_FIND_LIBRARY_PREFIXES "${Deflate_OLD_FIND_LIBRARY_PREFIXES}") + +unset(Deflate_NAMES) +unset(Deflate_NAMES_DEBUG) +unset(Deflate_OLD_FIND_LIBRARY_PREFIXES) + +mark_as_advanced(Deflate_INCLUDE_DIR) + +if(Deflate_INCLUDE_DIR AND EXISTS "${Deflate_INCLUDE_DIR}/deflate.h") + file(STRINGS "${Deflate_INCLUDE_DIR}/libdeflate.h" Deflate_H REGEX "^#define LIBDEFLATE_VERSION_STRING\s+\"[^\"]*\"$") + + string(REGEX REPLACE "^.*Deflate_VERSION \"([0-9]+).*$" "\\1" Deflate_MAJOR_VERSION "${Deflate_H}") + string(REGEX REPLACE "^.*Deflate_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" Deflate_MINOR_VERSION "${Deflate_H}") + set(Deflate_VERSION_STRING "${Deflate_MAJOR_VERSION}.${Deflate_MINOR_VERSION}") + + set(Deflate_MAJOR_VERSION "${Deflate_VERSION_MAJOR}") + set(Deflate_MINOR_VERSION "${Deflate_VERSION_MINOR}") +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Deflate + REQUIRED_VARS Deflate_LIBRARY Deflate_INCLUDE_DIR + VERSION_VAR Deflate_VERSION_STRING) + +if(Deflate_FOUND) + set(Deflate_INCLUDE_DIRS ${Deflate_INCLUDE_DIR}) + + if(NOT Deflate_LIBRARIES) + set(Deflate_LIBRARIES ${Deflate_LIBRARY}) + endif() + + if(NOT TARGET Deflate::Deflate) + add_library(Deflate::Deflate UNKNOWN IMPORTED) + set_target_properties(Deflate::Deflate PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Deflate_INCLUDE_DIRS}") + + if(Deflate_LIBRARY_RELEASE) + set_property(TARGET Deflate::Deflate APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(Deflate::Deflate PROPERTIES + IMPORTED_LOCATION_RELEASE "${Deflate_LIBRARY_RELEASE}") + endif() + + if(Deflate_LIBRARY_DEBUG) + set_property(TARGET Deflate::Deflate APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(Deflate::Deflate PROPERTIES + IMPORTED_LOCATION_DEBUG "${Deflate_LIBRARY_DEBUG}") + endif() + + if(NOT Deflate_LIBRARY_RELEASE AND NOT Deflate_LIBRARY_DEBUG) + set_target_properties(Deflate::Deflate PROPERTIES + IMPORTED_LOCATION_RELEASE "${Deflate_LIBRARY}") + endif() + endif() +endif() diff --git a/tiff/cmake/FindJBIG.cmake b/tiff/cmake/FindJBIG.cmake new file mode 100644 index 00000000..f0c232c3 --- /dev/null +++ b/tiff/cmake/FindJBIG.cmake @@ -0,0 +1,116 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindJBIG +-------- + +Find the native JBIG includes and library. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``JBIG::JBIG``, if +JBIG has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + JBIG_INCLUDE_DIRS - where to find jbig.h, etc. + JBIG_LIBRARIES - List of libraries when using jbig. + JBIG_FOUND - True if jbig found. + +:: + + JBIG_VERSION_STRING - The version of jbig found (x.y.z) + JBIG_VERSION_MAJOR - The major version of jbig + JBIG_VERSION_MINOR - The minor version of jbig + + Debug and Release variants are found separately. +#]=======================================================================] + +# Standard names to search for +set(JBIG_NAMES jbig) +set(JBIG_NAMES_DEBUG jbigd) + +find_path(JBIG_INCLUDE_DIR + NAMES jbig.h + PATH_SUFFIXES include) + +set(JBIG_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") +# Library has a "lib" prefix even on Windows. +set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") + +# Allow JBIG_LIBRARY to be set manually, as the location of the jbig library +if(NOT JBIG_LIBRARY) + find_library(JBIG_LIBRARY_RELEASE + NAMES ${JBIG_NAMES} + PATH_SUFFIXES lib) + find_library(JBIG_LIBRARY_DEBUG + NAMES ${JBIG_NAMES_DEBUG} + PATH_SUFFIXES lib) + + include(SelectLibraryConfigurations) + select_library_configurations(JBIG) +endif() + +set(CMAKE_FIND_LIBRARY_PREFIXES "${JBIG_OLD_FIND_LIBRARY_PREFIXES}") + +unset(JBIG_NAMES) +unset(JBIG_NAMES_DEBUG) +unset(JBIG_OLD_FIND_LIBRARY_PREFIXES) + +mark_as_advanced(JBIG_INCLUDE_DIR) + +if(JBIG_INCLUDE_DIR AND EXISTS "${JBIG_INCLUDE_DIR}/jbig.h") + file(STRINGS "${JBIG_INCLUDE_DIR}/jbig.h" JBIG_H REGEX "^#define JBG_VERSION *\"[^\"]*\"$") + + string(REGEX REPLACE "^.*JBG_VERSION *\"([0-9]+).*$" "\\1" JBIG_MAJOR_VERSION "${JBIG_H}") + string(REGEX REPLACE "^.*JBG_VERSION *\"[0-9]+\\.([0-9]+).*$" "\\1" JBIG_MINOR_VERSION "${JBIG_H}") + set(JBIG_VERSION_STRING "${JBIG_MAJOR_VERSION}.${JBIG_MINOR_VERSION}") + + set(JBIG_MAJOR_VERSION "${JBIG_VERSION_MAJOR}") + set(JBIG_MINOR_VERSION "${JBIG_VERSION_MINOR}") +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(JBIG + REQUIRED_VARS JBIG_LIBRARY JBIG_INCLUDE_DIR + VERSION_VAR JBIG_VERSION_STRING) + +if(JBIG_FOUND) + set(JBIG_INCLUDE_DIRS ${JBIG_INCLUDE_DIR}) + + if(NOT JBIG_LIBRARIES) + set(JBIG_LIBRARIES ${JBIG_LIBRARY}) + endif() + + if(NOT TARGET JBIG::JBIG) + add_library(JBIG::JBIG UNKNOWN IMPORTED) + set_target_properties(JBIG::JBIG PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${JBIG_INCLUDE_DIRS}") + + if(JBIG_LIBRARY_RELEASE) + set_property(TARGET JBIG::JBIG APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(JBIG::JBIG PROPERTIES + IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY_RELEASE}") + endif() + + if(JBIG_LIBRARY_DEBUG) + set_property(TARGET JBIG::JBIG APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(JBIG::JBIG PROPERTIES + IMPORTED_LOCATION_DEBUG "${JBIG_LIBRARY_DEBUG}") + endif() + + if(NOT JBIG_LIBRARY_RELEASE AND NOT JBIG_LIBRARY_DEBUG) + set_target_properties(JBIG::JBIG PROPERTIES + IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY}") + endif() + endif() +endif() diff --git a/tiff/cmake/FindJPEG.cmake b/tiff/cmake/FindJPEG.cmake new file mode 100644 index 00000000..12d0844b --- /dev/null +++ b/tiff/cmake/FindJPEG.cmake @@ -0,0 +1,142 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindJPEG +-------- + +Find the Joint Photographic Experts Group (JPEG) library (``libjpeg``) + +Imported targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.12 + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``JPEG::JPEG`` + The JPEG library, if found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``JPEG_FOUND`` + If false, do not try to use JPEG. +``JPEG_INCLUDE_DIRS`` + where to find jpeglib.h, etc. +``JPEG_LIBRARIES`` + the libraries needed to use JPEG. +``JPEG_VERSION`` + .. versionadded:: 3.12 + the version of the JPEG library found + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``JPEG_INCLUDE_DIRS`` + where to find jpeglib.h, etc. +``JPEG_LIBRARY_RELEASE`` + where to find the JPEG library (optimized). +``JPEG_LIBRARY_DEBUG`` + where to find the JPEG library (debug). + +.. versionadded:: 3.12 + Debug and Release variand are found separately. + +Obsolete variables +^^^^^^^^^^^^^^^^^^ + +``JPEG_INCLUDE_DIR`` + where to find jpeglib.h, etc. (same as JPEG_INCLUDE_DIRS) +``JPEG_LIBRARY`` + where to find the JPEG library. +#]=======================================================================] + +find_path(JPEG_INCLUDE_DIR jpeglib.h) + +set(jpeg_names ${JPEG_NAMES} jpeg jpeg-static libjpeg libjpeg-static turbojpeg turbojpeg-static) +foreach(name ${jpeg_names}) + list(APPEND jpeg_names_debug "${name}d") +endforeach() + +if(NOT JPEG_LIBRARY) + find_library(JPEG_LIBRARY_RELEASE NAMES ${jpeg_names} NAMES_PER_DIR) + find_library(JPEG_LIBRARY_DEBUG NAMES ${jpeg_names_debug} NAMES_PER_DIR) + include(SelectLibraryConfigurations) + select_library_configurations(JPEG) + mark_as_advanced(JPEG_LIBRARY_RELEASE JPEG_LIBRARY_DEBUG) +endif() +unset(jpeg_names) +unset(jpeg_names_debug) + +if(JPEG_INCLUDE_DIR) + file(GLOB _JPEG_CONFIG_HEADERS_FEDORA "${JPEG_INCLUDE_DIR}/jconfig*.h") + file(GLOB _JPEG_CONFIG_HEADERS_DEBIAN "${JPEG_INCLUDE_DIR}/*/jconfig.h") + set(_JPEG_CONFIG_HEADERS + "${JPEG_INCLUDE_DIR}/jpeglib.h" + ${_JPEG_CONFIG_HEADERS_FEDORA} + ${_JPEG_CONFIG_HEADERS_DEBIAN}) + foreach (_JPEG_CONFIG_HEADER IN LISTS _JPEG_CONFIG_HEADERS) + if (NOT EXISTS "${_JPEG_CONFIG_HEADER}") + continue () + endif () + file(STRINGS "${_JPEG_CONFIG_HEADER}" + jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*") + + if (NOT jpeg_lib_version) + continue () + endif () + + string(REGEX REPLACE "^#define[\t ]+JPEG_LIB_VERSION[\t ]+([0-9]+).*" + "\\1" JPEG_VERSION "${jpeg_lib_version}") + break () + endforeach () + unset(jpeg_lib_version) + unset(_JPEG_CONFIG_HEADER) + unset(_JPEG_CONFIG_HEADERS) + unset(_JPEG_CONFIG_HEADERS_FEDORA) + unset(_JPEG_CONFIG_HEADERS_DEBIAN) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(JPEG + REQUIRED_VARS JPEG_LIBRARY JPEG_INCLUDE_DIR + VERSION_VAR JPEG_VERSION) + +if(JPEG_FOUND) + set(JPEG_LIBRARIES ${JPEG_LIBRARY}) + set(JPEG_INCLUDE_DIRS "${JPEG_INCLUDE_DIR}") + + if(NOT TARGET JPEG::JPEG) + add_library(JPEG::JPEG UNKNOWN IMPORTED) + if(JPEG_INCLUDE_DIRS) + set_target_properties(JPEG::JPEG PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}") + endif() + if(EXISTS "${JPEG_LIBRARY}") + set_target_properties(JPEG::JPEG PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${JPEG_LIBRARY}") + endif() + if(EXISTS "${JPEG_LIBRARY_RELEASE}") + set_property(TARGET JPEG::JPEG APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(JPEG::JPEG PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" + IMPORTED_LOCATION_RELEASE "${JPEG_LIBRARY_RELEASE}") + endif() + if(EXISTS "${JPEG_LIBRARY_DEBUG}") + set_property(TARGET JPEG::JPEG APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(JPEG::JPEG PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" + IMPORTED_LOCATION_DEBUG "${JPEG_LIBRARY_DEBUG}") + endif() + endif() +endif() + +mark_as_advanced(JPEG_LIBRARY JPEG_INCLUDE_DIR) diff --git a/tiff/cmake/FindLERC.cmake b/tiff/cmake/FindLERC.cmake new file mode 100644 index 00000000..ade742a1 --- /dev/null +++ b/tiff/cmake/FindLERC.cmake @@ -0,0 +1,86 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindLerc +-------- + +Find the native Lerc includes and library. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``LERC::LERC``, if +CMath has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + LERC_INCLUDE_DIRS - where to find Lerc_c_api.h, etc. + LERC_LIBRARIES - List of libraries when using LERC. + LERC_FOUND - True if LERC found. + +#]=======================================================================] + +# Standard names to search for +set(LERC_NAMES LercLib Lerc) + +find_path(LERC_INCLUDE_DIR + NAMES Lerc_c_api.h + PATH_SUFFIXES include) + +# Allow LERC_LIBRARY to be set manually, as the location of the deflate library +if(NOT LERC_LIBRARY) + find_library(LERC_LIBRARY_RELEASE + NAMES ${LERC_NAMES} + PATH_SUFFIXES lib) + + include(SelectLibraryConfigurations) + select_library_configurations(LERC) +endif() + +unset(LERC_NAMES) + +mark_as_advanced(LERC_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LERC + REQUIRED_VARS LERC_LIBRARY LERC_INCLUDE_DIR + VERSION_VAR LERC_VERSION_STRING) + +if(LERC_FOUND) + set(LERC_INCLUDE_DIRS ${LERC_INCLUDE_DIR}) + + if(NOT LERC_LIBRARIES) + set(LERC_LIBRARIES ${LERC_LIBRARY}) + endif() + + if(NOT TARGET LERC::LERC) + add_library(LERC::LERC UNKNOWN IMPORTED) + set_target_properties(LERC::LERC PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${LERC_INCLUDE_DIRS}") + + if(LERC_LIBRARY_RELEASE) + set_property(TARGET LERC::LERC APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(LERC::LERC PROPERTIES + IMPORTED_LOCATION_RELEASE "${LERC_LIBRARY_RELEASE}") + endif() + + if(LERC_LIBRARY_DEBUG) + set_property(TARGET LERC::LERC APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(LERC::LERC PROPERTIES + IMPORTED_LOCATION_DEBUG "${LERC_LIBRARY_DEBUG}") + endif() + + if(NOT LERC_LIBRARY_RELEASE AND NOT LERC_LIBRARY_DEBUG) + set_target_properties(LERC::LERC PROPERTIES + IMPORTED_LOCATION_RELEASE "${LERC_LIBRARY}") + endif() + endif() +endif() diff --git a/tiff/cmake/FindLibLZMA.cmake b/tiff/cmake/FindLibLZMA.cmake new file mode 100644 index 00000000..3042bac9 --- /dev/null +++ b/tiff/cmake/FindLibLZMA.cmake @@ -0,0 +1,126 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindLibLZMA +----------- + +Find LZMA compression algorithm headers and library. + + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.14 + +This module defines :prop_tgt:`IMPORTED` target ``LibLZMA::LibLZMA``, if +liblzma has been found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``LIBLZMA_FOUND`` + True if liblzma headers and library were found. +``LIBLZMA_INCLUDE_DIRS`` + Directory where liblzma headers are located. +``LIBLZMA_LIBRARIES`` + Lzma libraries to link against. +``LIBLZMA_HAS_AUTO_DECODER`` + True if lzma_auto_decoder() is found (required). +``LIBLZMA_HAS_EASY_ENCODER`` + True if lzma_easy_encoder() is found (required). +``LIBLZMA_HAS_LZMA_PRESET`` + True if lzma_lzma_preset() is found (required). +``LIBLZMA_VERSION_MAJOR`` + The major version of lzma +``LIBLZMA_VERSION_MINOR`` + The minor version of lzma +``LIBLZMA_VERSION_PATCH`` + The patch version of lzma +``LIBLZMA_VERSION_STRING`` + version number as a string (ex: "5.0.3") +#]=======================================================================] + +find_path(LIBLZMA_INCLUDE_DIR lzma.h ) +if(NOT LIBLZMA_LIBRARY) + find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma NAMES_PER_DIR PATH_SUFFIXES lib) + find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad NAMES_PER_DIR PATH_SUFFIXES lib) + include(SelectLibraryConfigurations) + select_library_configurations(LIBLZMA) +else() + file(TO_CMAKE_PATH "${LIBLZMA_LIBRARY}" LIBLZMA_LIBRARY) +endif() + +if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h") + file(STRINGS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS REGEX "#define LZMA_VERSION_[A-Z]+ [0-9]+") + + string(REGEX REPLACE ".*#define LZMA_VERSION_MAJOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MAJOR "${LIBLZMA_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define LZMA_VERSION_MINOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MINOR "${LIBLZMA_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define LZMA_VERSION_PATCH ([0-9]+).*" "\\1" LIBLZMA_VERSION_PATCH "${LIBLZMA_HEADER_CONTENTS}") + + set(LIBLZMA_VERSION_STRING "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}") + unset(LIBLZMA_HEADER_CONTENTS) +endif() + +# We're using new code known now as XZ, even library still been called LZMA +# it can be found in http://tukaani.org/xz/ +# Avoid using old codebase +if (LIBLZMA_LIBRARY) + include(CheckLibraryExists) + set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) + set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY}) + if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG) + set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY}) + elseif(LIBLZMA_LIBRARY_RELEASE) + set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_RELEASE}) + elseif(LIBLZMA_LIBRARY_DEBUG) + set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_DEBUG}) + endif() + CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER) + CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER) + CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET) + unset(LIBLZMA_LIBRARY_check) + set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY + LIBLZMA_INCLUDE_DIR + LIBLZMA_HAS_AUTO_DECODER + LIBLZMA_HAS_EASY_ENCODER + LIBLZMA_HAS_LZMA_PRESET + VERSION_VAR LIBLZMA_VERSION_STRING + ) +mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY ) + +if (LIBLZMA_FOUND) + set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY}) + set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR}) + if(NOT TARGET LibLZMA::LibLZMA) + add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR} + IMPORTED_LINK_INTERFACE_LANGUAGES C) + + if(LIBLZMA_LIBRARY_RELEASE) + set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + IMPORTED_LOCATION_RELEASE "${LIBLZMA_LIBRARY_RELEASE}") + endif() + + if(LIBLZMA_LIBRARY_DEBUG) + set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + IMPORTED_LOCATION_DEBUG "${LIBLZMA_LIBRARY_DEBUG}") + endif() + + if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + IMPORTED_LOCATION "${LIBLZMA_LIBRARY}") + endif() + endif() +endif () diff --git a/tiff/cmake/FindWebP.cmake b/tiff/cmake/FindWebP.cmake new file mode 100644 index 00000000..770fd979 --- /dev/null +++ b/tiff/cmake/FindWebP.cmake @@ -0,0 +1,91 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindWebP +-------- + +Find the native WebP includes and library. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``WebP::WebP``, if +WebP has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + WebP_INCLUDE_DIRS - where to find webp/*.h, etc. + WebP_LIBRARIES - List of libraries when using webp. + WebP_FOUND - True if webp found. + + Debug and Release variants are found separately. +#]=======================================================================] + +# Standard names to search for +set(WebP_NAMES webp) +set(WebP_NAMES_DEBUG webpd) + +find_path(WebP_INCLUDE_DIR + NAMES webp/decode.h + PATH_SUFFIXES include) + +# Allow WebP_LIBRARY to be set manually, as the location of the webp library +if(NOT WebP_LIBRARY) + find_library(WebP_LIBRARY_RELEASE + NAMES ${WebP_NAMES} + PATH_SUFFIXES lib) + find_library(WebP_LIBRARY_DEBUG + NAMES ${WebP_NAMES_DEBUG} + PATH_SUFFIXES lib) + + include(SelectLibraryConfigurations) + select_library_configurations(WebP) +endif() + +unset(WebP_NAMES) +unset(WebP_NAMES_DEBUG) + +mark_as_advanced(WebP_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP + REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR) + +if(WebP_FOUND) + set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR}) + + if(NOT WebP_LIBRARIES) + set(WebP_LIBRARIES ${WebP_LIBRARY}) + endif() + + if(NOT TARGET WebP::WebP) + add_library(WebP::WebP UNKNOWN IMPORTED) + set_target_properties(WebP::WebP PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIRS}") + + if(WebP_LIBRARY_RELEASE) + set_property(TARGET WebP::WebP APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(WebP::WebP PROPERTIES + IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}") + endif() + + if(WebP_LIBRARY_DEBUG) + set_property(TARGET WebP::WebP APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(WebP::WebP PROPERTIES + IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}") + endif() + + if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG) + set_target_properties(WebP::WebP PROPERTIES + IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY}") + endif() + endif() +endif() diff --git a/tiff/cmake/FindZSTD.cmake b/tiff/cmake/FindZSTD.cmake new file mode 100644 index 00000000..a4066300 --- /dev/null +++ b/tiff/cmake/FindZSTD.cmake @@ -0,0 +1,107 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindZSTD +-------- + +Find the native ZSTD includes and library. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``ZSTD::ZSTD``, if +ZSTD has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + ZSTD_INCLUDE_DIRS - where to find zstd.h, etc. + ZSTD_LIBRARIES - List of libraries when using zstd. + ZSTD_FOUND - True if zstd found. + +:: + + ZSTD_VERSION_STRING - The version of zstd found (x.y.z) + ZSTD_VERSION_MAJOR - The major version of zstd + ZSTD_VERSION_MINOR - The minor version of zstd + + Debug and Release variants are found separately. +#]=======================================================================] + +# Standard names to search for +set(ZSTD_NAMES zstd zstd_static) +set(ZSTD_NAMES_DEBUG zstdd zstd_staticd) + +find_path(ZSTD_INCLUDE_DIR + NAMES zstd.h + PATH_SUFFIXES include) + +# Allow ZSTD_LIBRARY to be set manually, as the location of the zstd library +if(NOT ZSTD_LIBRARY) + find_library(ZSTD_LIBRARY_RELEASE + NAMES ${ZSTD_NAMES} + PATH_SUFFIXES lib) + find_library(ZSTD_LIBRARY_DEBUG + NAMES ${ZSTD_NAMES_DEBUG} + PATH_SUFFIXES lib) + + include(SelectLibraryConfigurations) + select_library_configurations(ZSTD) +endif() + +unset(ZSTD_NAMES) +unset(ZSTD_NAMES_DEBUG) + +mark_as_advanced(ZSTD_INCLUDE_DIR) + +if(ZSTD_INCLUDE_DIR AND EXISTS "${ZSTD_INCLUDE_DIR}/zstd.h") + file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" ZSTD_H REGEX "^#define ZSTD_VERSION_.*$") + + string(REGEX REPLACE "^.*ZSTD_VERSION_MAJOR *([0-9]+).*$" "\\1" ZSTD_MAJOR_VERSION "${ZSTD_H}") + string(REGEX REPLACE "^.*ZSTD_VERSION_MINOR *([0-9]+).*$" "\\1" ZSTD_MINOR_VERSION "${ZSTD_H}") + string(REGEX REPLACE "^.*ZSTD_VERSION_RELEASE *([0-9]+).*$" "\\1" ZSTD_PATCH_VERSION "${ZSTD_H}") + set(ZSTD_VERSION_STRING "${ZSTD_MAJOR_VERSION}.${ZSTD_MINOR_VERSION}.${ZSTD_PATCH_VERSION}") +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZSTD + REQUIRED_VARS ZSTD_LIBRARY ZSTD_INCLUDE_DIR + VERSION_VAR ZSTD_VERSION_STRING) + +if(ZSTD_FOUND) + set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR}) + + if(NOT ZSTD_LIBRARIES) + set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) + endif() + + if(NOT TARGET ZSTD::ZSTD) + add_library(ZSTD::ZSTD UNKNOWN IMPORTED) + set_target_properties(ZSTD::ZSTD PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}") + + if(ZSTD_LIBRARY_RELEASE) + set_property(TARGET ZSTD::ZSTD APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(ZSTD::ZSTD PROPERTIES + IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}") + endif() + + if(ZSTD_LIBRARY_DEBUG) + set_property(TARGET ZSTD::ZSTD APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(ZSTD::ZSTD PROPERTIES + IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}") + endif() + + if(NOT ZSTD_LIBRARY_RELEASE AND NOT ZSTD_LIBRARY_DEBUG) + set_target_properties(ZSTD::ZSTD PROPERTIES + IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY}") + endif() + endif() +endif() diff --git a/tiff/cmake/IncludeChecks.cmake b/tiff/cmake/IncludeChecks.cmake new file mode 100644 index 00000000..08873598 --- /dev/null +++ b/tiff/cmake/IncludeChecks.cmake @@ -0,0 +1,36 @@ +# Checks for headers +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +include(CheckIncludeFile) + + +check_include_file(assert.h HAVE_ASSERT_H) +check_include_file(fcntl.h HAVE_FCNTL_H) +check_include_file(io.h HAVE_IO_H) +check_include_file(strings.h HAVE_STRINGS_H) +check_include_file(sys/time.h HAVE_SYS_TIME_H) +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(unistd.h HAVE_UNISTD_H) diff --git a/tiff/cmake/InternalCodecs.cmake b/tiff/cmake/InternalCodecs.cmake new file mode 100644 index 00000000..97526e1e --- /dev/null +++ b/tiff/cmake/InternalCodecs.cmake @@ -0,0 +1,46 @@ +# Options to enable and disable internal codecs +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +option(ccitt "support for CCITT Group 3 & 4 algorithms" ON) +set(CCITT_SUPPORT ${ccitt}) + +option(packbits "support for Macintosh PackBits algorithm" ON) +set(PACKBITS_SUPPORT ${packbits}) + +option(lzw "support for LZW algorithm" ON) +set(LZW_SUPPORT ${lzw}) + +option(thunder "support for ThunderScan 4-bit RLE algorithm" ON) +set(THUNDER_SUPPORT ${thunder}) + +option(next "support for NeXT 2-bit RLE algorithm" ON) +set(NEXT_SUPPORT ${next}) + +option(logluv "support for LogLuv high dynamic range algorithm" ON) +set(LOGLUV_SUPPORT ${logluv}) + +option(mdi "support for Microsoft Document Imaging" ON) +set(MDI_SUPPORT ${mdi}) diff --git a/tiff/cmake/JBIGCodec.cmake b/tiff/cmake/JBIGCodec.cmake new file mode 100644 index 00000000..a4350028 --- /dev/null +++ b/tiff/cmake/JBIGCodec.cmake @@ -0,0 +1,47 @@ +# Checks for JBIG codec support +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +# JBIG-KIT +set(JBIG_SUPPORT FALSE) + +find_package(JBIG) + +if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) + check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) +endif() + +option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ${JBIG_FOUND}) + +if (jbig AND JBIG_FOUND) + set(JBIG_SUPPORT TRUE) +endif() + diff --git a/tiff/cmake/JPEGCodec.cmake b/tiff/cmake/JPEGCodec.cmake new file mode 100644 index 00000000..5b295851 --- /dev/null +++ b/tiff/cmake/JPEGCodec.cmake @@ -0,0 +1,56 @@ +# Checks for JPEG codec support +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +# JPEG +set(JPEG_SUPPORT FALSE) +find_package(JPEG) +option(jpeg "use libjpeg (required for JPEG compression)" ${JPEG_FOUND}) +if (jpeg AND JPEG_FOUND) + set(JPEG_SUPPORT TRUE) +endif() + +# Old-jpeg +set(OJPEG_SUPPORT FALSE) +option(old-jpeg "support for Old JPEG compression (read-only)" ${JPEG_SUPPORT}) +if (old-jpeg AND JPEG_SUPPORT) + set(OJPEG_SUPPORT TRUE) +endif() + +# 8/12-bit jpeg mode +set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg") +set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library") +set(JPEG_DUAL_MODE_8_12 FALSE) +if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY) + set(JPEG12_LIBRARIES ${JPEG12_LIBRARY}) + set(JPEG12_FOUND TRUE) +else() + set(JPEG12_FOUND FALSE) +endif() +option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate 12-bit libjpeg build)" ${JPEG12_FOUND}) +if (jpeg12 AND JPEG12_FOUND) + set(JPEG_DUAL_MODE_8_12 TRUE) + set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h") +endif() diff --git a/tiff/cmake/LERCCodec.cmake b/tiff/cmake/LERCCodec.cmake new file mode 100644 index 00000000..7344bfa5 --- /dev/null +++ b/tiff/cmake/LERCCodec.cmake @@ -0,0 +1,32 @@ +# Checks for LERC codec support +# +# Copyright © 2021 Antonio Valentino <antonio.valentino@tiscali.it> +# Written by Antonio Valentino <antonio.valentino@tiscali.it> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +# libLerc +set(LERC_SUPPORT FALSE) +find_package(LERC) +option(lerc "use libLerc (required for LERC compression)" ${LERC_FOUND}) +if (lerc AND LERC_FOUND) + set(LERC_SUPPORT TRUE) +endif() diff --git a/tiff/contrib/mfs/CMakeLists.txt b/tiff/cmake/LZMACodec.cmake index 3f4f3a90..06b14c1e 100644 --- a/tiff/contrib/mfs/CMakeLists.txt +++ b/tiff/cmake/LZMACodec.cmake @@ -1,6 +1,7 @@ -# CMake build for libtiff +# Checks for LZMA codec support # # Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> # Written by Roger Leigh <rleigh@codelibre.net> # # Permission to use, copy, modify, distribute, and sell this software and @@ -22,6 +23,11 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -extra_dist( - README - mfs_file.c) + +# liblzma2 +set(LZMA_SUPPORT FALSE) +find_package(LibLZMA) +option(lzma "use liblzma (required for LZMA2 compression)" ${LZMA_FOUND}) +if (lzma AND LIBLZMA_FOUND) + set(LZMA_SUPPORT TRUE) +endif() diff --git a/tiff/contrib/tags/CMakeLists.txt b/tiff/cmake/LargeFileSupport.cmake index 9945da76..f1819b97 100644 --- a/tiff/contrib/tags/CMakeLists.txt +++ b/tiff/cmake/LargeFileSupport.cmake @@ -1,6 +1,7 @@ -# CMake build for libtiff +# Large file support # # Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> # Written by Roger Leigh <rleigh@codelibre.net> # # Permission to use, copy, modify, distribute, and sell this software and @@ -22,11 +23,10 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -extra_dist( - README - listtif.c - maketif.c - xtif_dir.c - xtiffio.h - xtiffiop.h) +if (UNIX OR MINGW) + # This might not catch every possibility catered for by + # Autoconf AC_SYS_LARGEFILE. + add_definitions(-D_FILE_OFFSET_BITS=64) + set(FILE_OFFSET_BITS 64) +endif() diff --git a/tiff/cmake/LibraryFeatures.cmake b/tiff/cmake/LibraryFeatures.cmake new file mode 100644 index 00000000..929ed241 --- /dev/null +++ b/tiff/cmake/LibraryFeatures.cmake @@ -0,0 +1,60 @@ +# C library features +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# Strip chopping +option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)" ON) +set(TIFF_DEFAULT_STRIP_SIZE 8192 CACHE STRING "default size of the strip in bytes (when strip chopping is enabled)") + +set(STRIPCHOP_DEFAULT) +if(strip-chopping) + set(STRIPCHOP_DEFAULT TRUE) + if(TIFF_DEFAULT_STRIP_SIZE) + set(STRIP_SIZE_DEFAULT "${TIFF_DEFAULT_STRIP_SIZE}") + endif() +endif() + +# Defer loading of strip/tile offsets +option(defer-strile-load "enable deferred strip/tile offset/size loading (also available at runtime with the 'D' flag of TIFFOpen())" OFF) +set(DEFER_STRILE_LOAD ${defer-strile-load}) + +# CHUNKY_STRIP_READ_SUPPORT +option(chunky-strip-read "enable reading large strips in chunks for TIFFReadScanline() (experimental)" OFF) +set(CHUNKY_STRIP_READ_SUPPORT ${chunky-strip-read}) + +# SUBIFD support +set(SUBIFD_SUPPORT 1) + +# Default handling of ASSOCALPHA support. +option(extrasample-as-alpha "the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly" ON) +if(extrasample-as-alpha) + set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1) +endif() + +# Default handling of YCbCr subsampling support. +# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details. +option(check-ycbcr-subsampling "enable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag" ON) +if (check-ycbcr-subsampling) + set(CHECK_JPEG_YCBCR_SUBSAMPLING 1) +endif() diff --git a/tiff/cmake/LinkerChecks.cmake b/tiff/cmake/LinkerChecks.cmake new file mode 100644 index 00000000..ad1f0f9f --- /dev/null +++ b/tiff/cmake/LinkerChecks.cmake @@ -0,0 +1,50 @@ +# Check linker capabilities +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +include(CheckCSourceCompiles) + + +option(ld-version-script "Enable linker version script" ON) + +# Check if LD supports linker scripts. +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { + global: sym; +}; + +VERS_2 { + global: sym; +} VERS_1; +") +set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) +set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map") +check_c_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT) +set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) +file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") +if (ld-version-script AND HAVE_LD_VERSION_SCRIPT) + set(HAVE_LD_VERSION_SCRIPT TRUE) +else() + set(HAVE_LD_VERSION_SCRIPT FALSE) +endif() diff --git a/tiff/cmake/OpenGLChecks.cmake b/tiff/cmake/OpenGLChecks.cmake new file mode 100644 index 00000000..8d4142aa --- /dev/null +++ b/tiff/cmake/OpenGLChecks.cmake @@ -0,0 +1,43 @@ +# Checks for OpenGL and GLUT support +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# OpenGL and GLUT +set(OpenGL_GL_PREFERENCE LEGACY) + +find_package(OpenGL COMPONENTS OpenGL) +find_package(GLUT) + +set(HAVE_OPENGL FALSE) +if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) + set(HAVE_OPENGL TRUE) +endif() + +# Purely to satisfy the generated headers: +check_include_file(GL/gl.h HAVE_GL_GL_H) +check_include_file(GL/glu.h HAVE_GL_GLU_H) +check_include_file(GL/glut.h HAVE_GL_GLUT_H) +check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) +check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) +check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) diff --git a/tiff/cmake/PixarLogCodec.cmake b/tiff/cmake/PixarLogCodec.cmake new file mode 100644 index 00000000..db363050 --- /dev/null +++ b/tiff/cmake/PixarLogCodec.cmake @@ -0,0 +1,33 @@ +# Checks for PixarLog codec support +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +# Option for Pixar log-format algorithm +# Pixar log format +set(PIXARLOG_SUPPORT FALSE) +option(pixarlog "support for Pixar log-format algorithm (requires Zlib)" ${ZLIB_SUPPORT}) +if(pixarlog AND ZLIB_SUPPORT) + set(PIXARLOG_SUPPORT TRUE) +endif() diff --git a/tiff/cmake/PkgConfig.cmake b/tiff/cmake/PkgConfig.cmake new file mode 100644 index 00000000..92674bd7 --- /dev/null +++ b/tiff/cmake/PkgConfig.cmake @@ -0,0 +1,36 @@ +# pkg-config support +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# Generate pkg-config file +set(prefix "${CMAKE_INSTALL_PREFIX}") +set(exec_prefix "${CMAKE_INSTALL_PREFIX}") +set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") +set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc) + +# Install pkg-config file +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc + DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") diff --git a/tiff/cmake/ProcessorChecks.cmake b/tiff/cmake/ProcessorChecks.cmake new file mode 100644 index 00000000..8d8c568a --- /dev/null +++ b/tiff/cmake/ProcessorChecks.cmake @@ -0,0 +1,47 @@ +# Processor capability checks +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +include(TestBigEndian) + + +# CPU bit order +set(HOST_FILLORDER FILLORDER_MSB2LSB) +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR + CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR + # AMD64 on Windows + CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" OR + CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*") + set(HOST_FILLORDER FILLORDER_LSB2MSB) +endif() + +# CPU endianness +test_big_endian(HOST_BIG_ENDIAN) +if(HOST_BIG_ENDIAN) + add_definitions(-DWORDS_BIGENDIAN) +endif() + +# IEEE floating point +set(HAVE_IEEEFP 1) diff --git a/tiff/cmake/Release.cmake b/tiff/cmake/Release.cmake new file mode 100644 index 00000000..fbf34cc6 --- /dev/null +++ b/tiff/cmake/Release.cmake @@ -0,0 +1,31 @@ +# Release support +# +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +add_custom_target(release + COMMAND ${CMAKE_COMMAND} + "-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}" + "-DLIBTIFF_VERSION=${PROJECT_VERSION}" + -P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake" + COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION}") diff --git a/tiff/cmake/ReleaseScript.cmake b/tiff/cmake/ReleaseScript.cmake new file mode 100644 index 00000000..31cdbfe3 --- /dev/null +++ b/tiff/cmake/ReleaseScript.cmake @@ -0,0 +1,32 @@ +# Release support +# +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +string(TIMESTAMP LIBTIFF_RELEASE_DATE "%Y%m%d") + +message(STATUS "Setting release version to ${LIBTIFF_VERSION}") +message(STATUS "Setting release date to ${LIBTIFF_RELEASE_DATE}") + +configure_file("${SOURCE_DIR}/libtiff/tiffvers.h.cmake.in" + "${SOURCE_DIR}/libtiff/tiffvers.h" + @ONLY) diff --git a/tiff/cmake/SymbolChecks.cmake b/tiff/cmake/SymbolChecks.cmake new file mode 100644 index 00000000..210748ed --- /dev/null +++ b/tiff/cmake/SymbolChecks.cmake @@ -0,0 +1,43 @@ +# Checks for symbols +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +include(CheckSymbolExists) + + +# Check for getopt +check_symbol_exists(getopt "unistd.h;stdio.h" HAVE_GETOPT) +check_symbol_exists(optarg "getopt.h" HAVE_DECL_OPTARG) +if (HAVE_DECL_OPTARG) + set(HAVE_DECL_OPTARG 1) +else() + set(HAVE_DECL_OPTARG 0) +endif() + +# Check for mmap +check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP) + +# Check for setmode +check_symbol_exists(setmode "unistd.h" HAVE_SETMODE) diff --git a/tiff/cmake/TypeSizeChecks.cmake b/tiff/cmake/TypeSizeChecks.cmake new file mode 100644 index 00000000..29f23b41 --- /dev/null +++ b/tiff/cmake/TypeSizeChecks.cmake @@ -0,0 +1,52 @@ +# Check type sizes +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES}) +set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h") +check_type_size("size_t" SIZEOF_SIZE_T) +set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE}) + +# C99 fixed-size integer types +set(TIFF_INT8_T "int8_t") +set(TIFF_UINT8_T "uint8_t") + +set(TIFF_INT16_T "int16_t") +set(TIFF_UINT16_T "uint16_t") + +set(TIFF_INT32_T "int32_t") +set(TIFF_UINT32_T "uint32_t") + +set(TIFF_INT64_T "int64_t") +set(TIFF_UINT64_T "uint64_t") + +# size_t and TIFF signed size-type +if(SIZEOF_SIZE_T EQUAL 4) + set(TIFF_SSIZE_T "int32_t") +elseif(SIZEOF_SIZE_T EQUAL 8) + set(TIFF_SSIZE_T "int64_t") +else() + message(FATAL_ERROR "Unsupported size_t size ${SIZEOF_SIZE_T}; please add support") +endif() diff --git a/tiff/contrib/dbs/xtiff/CMakeLists.txt b/tiff/cmake/WebPCodec.cmake index fec4d0d8..1d676a78 100644 --- a/tiff/contrib/dbs/xtiff/CMakeLists.txt +++ b/tiff/cmake/WebPCodec.cmake @@ -1,6 +1,7 @@ -# CMake build for libtiff +# Checks for WebP codec support # # Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> # Written by Roger Leigh <rleigh@codelibre.net> # # Permission to use, copy, modify, distribute, and sell this software and @@ -22,8 +23,13 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -extra_dist( - README - patchlevel.h - xtiff.c - xtifficon.h) +# libwebp +set(WEBP_SUPPORT FALSE) + +find_package(WebP) + +option(webp "use libwebp (required for WEBP compression)" ${WebP_FOUND}) + +if (webp AND WebP_FOUND) + set(WEBP_SUPPORT TRUE) +endif() diff --git a/tiff/contrib/pds/CMakeLists.txt b/tiff/cmake/WindowsSupport.cmake index 53a0e056..93c13094 100644 --- a/tiff/contrib/pds/CMakeLists.txt +++ b/tiff/cmake/WindowsSupport.cmake @@ -1,6 +1,7 @@ -# CMake build for libtiff +# Windows support # # Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> # Written by Roger Leigh <rleigh@codelibre.net> # # Permission to use, copy, modify, distribute, and sell this software and @@ -22,9 +23,17 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -extra_dist( - README - tif_imageiter.c - tif_imageiter.h - tif_pdsdirread.c - tif_pdsdirwrite.c) +# Debug postfix +if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") +endif() + +# Win32 file I/O +set(win32_io_default OFF) +if(WIN32) + set(win32_io_default ON) +endif() + +option(win32-io "Use Win32 I/O" ${win32_io_default}) + +set(USE_WIN32_FILEIO ${win32-io}) diff --git a/tiff/cmake/ZSTDCodec.cmake b/tiff/cmake/ZSTDCodec.cmake new file mode 100644 index 00000000..d3d2de80 --- /dev/null +++ b/tiff/cmake/ZSTDCodec.cmake @@ -0,0 +1,53 @@ +# Checks for LZMA codec support +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Copyright © 2021 Roger Leigh <rleigh@codelibre.net> +# Written by Roger Leigh <rleigh@codelibre.net> +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + + +# libzstd +set(ZSTD_SUPPORT FALSE) +set(ZSTD_USABLE FALSE) + +find_package(ZSTD) + +if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) + check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + + if (ZSTD_RECENT_ENOUGH) + set(ZSTD_USABLE TRUE) + else() + message(WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0") + endif() +endif() + +option(zstd "use libzstd (required for ZSTD compression)" ${ZSTD_USABLE}) + +if (zstd AND ZSTD_USABLE) + set(ZSTD_SUPPORT TRUE) +endif() diff --git a/tiff/config.h.in b/tiff/config.h.in new file mode 100644 index 00000000..4ccb7421 --- /dev/null +++ b/tiff/config.h.in @@ -0,0 +1,275 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + +/* Support CCITT Group 3 & 4 algorithms */ +#undef CCITT_SUPPORT + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#undef CHECK_JPEG_YCBCR_SUBSAMPLING + +/* enable partial strip reading for large strips (experimental) */ +#undef CHUNKY_STRIP_READ_SUPPORT + +/* Support C++ stream API (requires C++ compiler) */ +#undef CXX_SUPPORT + +/* Treat extra sample as alpha (default enabled). The RGBA interface will + treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many + packages produce RGBA files but don't mark the alpha properly. */ +#undef DEFAULT_EXTRASAMPLE_AS_ALPHA + +/* enable deferred strip/tile offset/size loading */ +#undef DEFER_STRILE_LOAD + +/* Define to 1 if you have the <assert.h> header file. */ +#undef HAVE_ASSERT_H + +/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. + */ +#undef HAVE_DECL_OPTARG + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the <fcntl.h> header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#undef HAVE_FSEEKO + +/* Define to 1 if you have the `getopt' function. */ +#undef HAVE_GETOPT + +/* Define to 1 if you have the <GLUT/glut.h> header file. */ +#undef HAVE_GLUT_GLUT_H + +/* Define to 1 if you have the <GL/glut.h> header file. */ +#undef HAVE_GL_GLUT_H + +/* Define to 1 if you have the <GL/glu.h> header file. */ +#undef HAVE_GL_GLU_H + +/* Define to 1 if you have the <GL/gl.h> header file. */ +#undef HAVE_GL_GL_H + +/* Define as 0 or 1 according to the floating point format supported by the + machine */ +#undef HAVE_IEEEFP + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the <io.h> header file. */ +#undef HAVE_IO_H + +/* Define to 1 if you have the `jbg_newlen' function. */ +#undef HAVE_JBG_NEWLEN + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mmap' function. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the <OpenGL/glu.h> header file. */ +#undef HAVE_OPENGL_GLU_H + +/* Define to 1 if you have the <OpenGL/gl.h> header file. */ +#undef HAVE_OPENGL_GL_H + +/* Define if you have POSIX threads libraries and header files. */ +#undef HAVE_PTHREAD + +/* Define to 1 if you have the <search.h> header file. */ +#undef HAVE_SEARCH_H + +/* Define to 1 if you have the `setmode' function. */ +#undef HAVE_SETMODE + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Use nonstandard varargs form for the GLU tesselator callback */ +#undef HAVE_VARARGS_GLU_TESSCB + +/* Define to 1 if you have the <windows.h> header file. */ +#undef HAVE_WINDOWS_H + +/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian + (Intel) */ +#undef HOST_BIGENDIAN + +/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ +#undef HOST_FILLORDER + +/* Support ISO JBIG compression (requires JBIG-KIT library) */ +#undef JBIG_SUPPORT + +/* 8/12 bit libjpeg dual mode enabled */ +#undef JPEG_DUAL_MODE_8_12 + +/* Support JPEG compression (requires IJG JPEG library) */ +#undef JPEG_SUPPORT + +/* Support lerc compression */ +#undef LERC_SUPPORT + +/* Support libdeflate enhanced compression */ +#undef LIBDEFLATE_SUPPORT + +/* 12bit libjpeg primary include file with path */ +#undef LIBJPEG_12_PATH + +/* Support LogLuv high dynamic range encoding */ +#undef LOGLUV_SUPPORT + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* Support LZMA2 compression */ +#undef LZMA_SUPPORT + +/* Support LZW algorithm */ +#undef LZW_SUPPORT + +/* Support Microsoft Document Imaging format */ +#undef MDI_SUPPORT + +/* Support NeXT 2-bit RLE algorithm */ +#undef NEXT_SUPPORT + +/* Support Old JPEG compresson (read-only) */ +#undef OJPEG_SUPPORT + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Support Macintosh PackBits algorithm */ +#undef PACKBITS_SUPPORT + +/* Support Pixar log-format algorithm (requires Zlib) */ +#undef PIXARLOG_SUPPORT + +/* Define to necessary symbol if this constant uses a non-standard name on + your system. */ +#undef PTHREAD_CREATE_JOINABLE + +/* The size of `size_t', as computed by sizeof. */ +#undef SIZEOF_SIZE_T + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Support strip chopping (whether or not to convert single-strip uncompressed + images to multiple strips of specified size to reduce memory usage) */ +#undef STRIPCHOP_DEFAULT + +/* Default size of the strip in bytes (when strip chopping enabled) */ +#undef STRIP_SIZE_DEFAULT + +/* Enable SubIFD tag (330) support */ +#undef SUBIFD_SUPPORT + +/* Support ThunderScan 4-bit RLE algorithm */ +#undef THUNDER_SUPPORT + +/* Signed size type */ +#undef TIFF_SSIZE_T + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your <sys/time.h> declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* define to use win32 IO system */ +#undef USE_WIN32_FILEIO + +/* Version number of package */ +#undef VERSION + +/* Support webp compression */ +#undef WEBP_SUPPORT + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +/* Define to 1 if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* Support Deflate compression */ +#undef ZIP_SUPPORT + +/* Support zstd compression */ +#undef ZSTD_SUPPORT + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +#undef _LARGEFILE_SOURCE + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `long int' if <sys/types.h> does not define. */ +#undef off_t + +/* Define to `unsigned int' if <sys/types.h> does not define. */ +#undef size_t diff --git a/tiff/config/config.guess b/tiff/config/config.guess index 6c32c864..1972fda8 100755 --- a/tiff/config/config.guess +++ b/tiff/config/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2014-11-04' +timestamp='2021-01-25' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2014-11-04' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. +# along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,19 +27,19 @@ timestamp='2014-11-04' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to <config-patches@gnu.org>. -me=`echo "$0" | sed -e 's,.*/,,'` +me=$(echo "$0" | sed -e 's,.*/,,') usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,8 +84,6 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -96,66 +94,89 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { tmp=$( (umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null) && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown -UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +UNAME_MACHINE=$( (uname -m) 2>/dev/null) || UNAME_MACHINE=unknown +UNAME_RELEASE=$( (uname -r) 2>/dev/null) || UNAME_RELEASE=unknown +UNAME_SYSTEM=$( (uname -s) 2>/dev/null) || UNAME_SYSTEM=unknown +UNAME_VERSION=$( (uname -v) 2>/dev/null) || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include <features.h> #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #else + #include <stdarg.h> + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g')" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -167,22 +188,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + echo unknown)) + case "$UNAME_MACHINE_ARCH" in + aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + earmv*) + arch=$(echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,') + endian=$(echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p') + machine="${arch}${endian}"-unknown + ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -197,117 +228,137 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in os=netbsd ;; esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=$(echo "$UNAME_MACHINE_ARCH" | sed -e "$expr") + ;; + esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=$(echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2) ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" + echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + UNAME_MACHINE_ARCH=$(arch | sed 's/Bitrig.//') + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + UNAME_MACHINE_ARCH=$(arch | sed 's/OpenBSD.//') + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=$(arch | sed 's/^.*BSD\.//') + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; + *:OS108:*:*) + echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Twizzler:*:*) + echo "$UNAME_MACHINE"-unknown-twizzler + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $3}') ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $4}') ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + ALPHA_CPU_TYPE=$(/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1) case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo "$UNAME_MACHINE"-dec-osf"$(echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -319,7 +370,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos @@ -329,7 +380,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then + if test "$( (/bin/universe) 2>/dev/null)" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd @@ -342,69 +393,69 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in + case $(/usr/bin/uname -p) in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"$(echo "$UNAME_RELEASE" | sed -e 's/[^.]*//')" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + set_cc_for_build + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" exit ;; sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in + case "$(/usr/bin/arch -k)" in Series*|S4*) - UNAME_RELEASE=`uname -v` + UNAME_RELEASE=$(uname -v) ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/')" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in + UNAME_RELEASE=$( (sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null) + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case "$(/bin/arch)" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -415,44 +466,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include <stdio.h> /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -461,23 +512,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=$(echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p') && + SYSTEM_NAME=$("$dummy" "$dummyarg") && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -502,18 +553,18 @@ EOF exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + UNAME_PROCESSOR=$(/usr/bin/uname -p) + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -530,26 +581,26 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"$(echo "$UNAME_RELEASE"|sed -e 's/-/_/g')" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + exit ;; # Note that: echo "'$(uname -s)'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if test -x /usr/bin/oslevel ; then + IBM_REV=$(/usr/bin/oslevel) else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> main() @@ -560,7 +611,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") then echo "$SYSTEM_NAME" else @@ -573,28 +624,28 @@ EOF fi exit ;; *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_CPU_ID=$(/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }') + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | - awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + if test -x /usr/bin/lslpp ; then + IBM_REV=$(/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/) else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -609,28 +660,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + if test -x /usr/bin/getconf; then + sc_cpu_version=$(/usr/bin/getconf SC_CPU_VERSION 2>/dev/null) + sc_kernel_bits=$(/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null) + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include <stdlib.h> @@ -663,13 +714,13 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=$("$dummy") test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if test "$HP_ARCH" = hppa2.0w then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -680,23 +731,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include <unistd.h> int main () @@ -721,11 +772,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=$("$dummy") && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -734,17 +785,17 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + if test -x /usr/sbin/sysversion ; then + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -769,130 +820,123 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + FUJITSU_PROC=$(uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz) + FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///') + FUJITSU_REL=$(echo "$UNAME_RELEASE" | sed -e 's/ /_/') echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + FUJITSU_SYS=$(uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///') + FUJITSU_REL=$(echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/') echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=$(uname -p) + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabihf + fi exit ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + UNAME_PROCESSOR=$(/usr/bin/uname -p) + case "$UNAME_PROCESSOR" in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin + echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*//')" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "$(echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,')-unknown-$LIBC$(echo "$UNAME_RELEASE"|sed -e 's,/.*$,,')" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-$(echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]")$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')-$LIBC" exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case $(sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null) in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -902,129 +946,182 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "$($CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI')" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + case $(grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2) in + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + set_cc_for_build + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI="$LIBC"x32 + fi + fi + echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1038,51 +1135,51 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=$(echo "$UNAME_RELEASE" | sed 's/\/MP$//') if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in + case $(/bin/uname -X | grep "^Machine") in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then - UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + UNAME_REL=$(sed -n 's/.*Version //p' </usr/options/cb.name) + echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL" elif /bin/uname -X 2>/dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + UNAME_REL=$( (/bin/uname -X|grep Release|sed -e 's/.*= //')) (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 @@ -1090,9 +1187,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1100,7 +1197,7 @@ EOF # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1112,9 +1209,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1132,41 +1229,41 @@ EOF 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + && OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + && OS_REL=.$(sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1176,8 +1273,8 @@ EOF exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + UNAME_MACHINE=$( (uname -p) 2>/dev/null) + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1197,23 +1294,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + if test -d /usr/nec; then + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1232,77 +1329,97 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + exit ;; + arm64:Darwin:*:*) + echo aarch64-apple-darwin"$UNAME_RELEASE" exit ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=$(uname -p) + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=$(uname -p) + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1311,18 +1428,19 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + # shellcheck disable=SC2154 + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1343,14 +1461,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + UNAME_MACHINE=$( (uname -p) 2>/dev/null) + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1359,62 +1477,223 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo "$UNAME_MACHINE"-pc-skyos"$(echo "$UNAME_RELEASE" | sed -e 's/ .*$//')" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + *:AROS:*:*) + echo "$UNAME_MACHINE"-unknown-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" + exit ;; +esac + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" <<EOF +#ifdef _SEQUENT_ +#include <sys/types.h> +#include <sys/utsname.h> +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include <signal.h> +#if defined(_SIZE_T_) || defined(SIGLOST) +#include <sys/utsname.h> +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=$( (hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null); + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include <sys/param.h> +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=$($dummy) && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <<EOF + +NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize +the system type. Please install a C compiler and try again. +EOF + ;; esac cat >&2 <<EOF -$0: unable to guess system type -This script, last modified $timestamp, has failed to recognize -the operating system you are using. It is advised that you -download the most up to date version of the config scripts from +This script (version $timestamp), has failed to recognize the +operating system you are using. If your script is old, overwrite *all* +copies of config.guess and config.sub with the latest versions from: - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + https://git.savannah.gnu.org/cgit/config.git/plain/config.guess and - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + https://git.savannah.gnu.org/cgit/config.git/plain/config.sub +EOF -If the version you run ($0) is already up to date, please -send the following data and any information you think might be -pertinent to <config-patches@gnu.org> in order to provide the needed -information to handle your system. +year=$(echo $timestamp | sed 's,-.*,,') +# shellcheck disable=SC2003 +if test "$(expr "$(date +%Y)" - "$year")" -lt 3 ; then + cat >&2 <<EOF + +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` +uname -m = $( (uname -m) 2>/dev/null || echo unknown) +uname -r = $( (uname -r) 2>/dev/null || echo unknown) +uname -s = $( (uname -s) 2>/dev/null || echo unknown) +uname -v = $( (uname -v) 2>/dev/null || echo unknown) -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` +/usr/bin/uname -p = $( (/usr/bin/uname -p) 2>/dev/null) +/bin/uname -X = $( (/bin/uname -X) 2>/dev/null) -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` +hostinfo = $( (hostinfo) 2>/dev/null) +/bin/universe = $( (/bin/universe) 2>/dev/null) +/usr/bin/arch -k = $( (/usr/bin/arch -k) 2>/dev/null) +/bin/arch = $( (/bin/arch) 2>/dev/null) +/usr/bin/oslevel = $( (/usr/bin/oslevel) 2>/dev/null) +/usr/convex/getsysinfo = $( (/usr/convex/getsysinfo) 2>/dev/null) -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/tiff/config/config.sub b/tiff/config/config.sub index 7ffe3737..7f7d0b05 100755 --- a/tiff/config/config.sub +++ b/tiff/config/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2014-12-03' +timestamp='2021-03-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2014-12-03' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see <http://www.gnu.org/licenses/>. +# along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +33,7 @@ timestamp='2014-12-03' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -50,15 +50,14 @@ timestamp='2014-12-03' # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. -me=`echo "$0" | sed -e 's,.*/,,'` +me=$(echo "$0" | sed -e 's,.*/,,') usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -68,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -90,12 +89,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -111,1228 +110,1169 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +IFS="-" read field1 field2 field3 field4 <<EOF +$1 +EOF -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos +# Separate into logical components for further validation +case $1 in + *-*-*-*-*) + echo Invalid configuration \`"$1"\': more than four components >&2 + exit 1 ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac ;; - -psos*) - os=-psos + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec + cpu=powerpc + vendor=ibm + basic_os=cnk ;; decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 + cpu=pdp10 + vendor=dec + basic_os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 + cpu=pdp10 + vendor=dec + basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp + cpu=m68k + vendor=motorola ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + cpu=$(echo "$1" | sed -e 's/86.*/86/') + vendor=pc + basic_os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + cpu=$(echo "$1" | sed -e 's/86.*/86/') + vendor=pc + basic_os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + cpu=$(echo "$1" | sed -e 's/86.*/86/') + vendor=pc + basic_os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach + cpu=$(echo "$1" | sed -e 's/86.*/86/') + vendor=pc + basic_os=solaris2 ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) + cpu=mips + vendor=sgi + case $basic_os in + irix*) ;; *) - os=-irix4 + basic_os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint + cpu=m68000 + vendor=convergent ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint ;; news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) ;; - -ns2*) - os=-nextstep2 + ns2*) + basic_os=nextstep2 ;; *) - os=-nextstep3 + basic_os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem + cpu=np1 + vendor=gould ;; op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k + cpu=hppa1.1 + vendor=oki + basic_os=proelf ;; pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; pbd) - basic_machine=sparc-tti + cpu=sparc + vendor=tti ;; pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + cpu=m68k + vendor=tti ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + pc532) + cpu=ns32k + vendor=pc532 ;; pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + cpu=pn + vendor=gould ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + power) + cpu=power + vendor=ibm ;; ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff + cpu=i386 + vendor=ibm ;; rm[46]00) - basic_machine=mips-siemens + cpu=mips + vendor=siemens ;; rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi + cpu=romp + vendor=ibm ;; - sb1) - basic_machine=mipsisa64sb1-unknown + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks ;; - sde) - basic_machine=mipsisa32-sde - os=-elf + tower | tower-32) + cpu=m68k + vendor=ncr ;; - sei) - basic_machine=mips-sei - os=-seiux + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu ;; - sequent) - basic_machine=i386-sequent + w65) + cpu=w65 + vendor=wdc ;; - sh) - basic_machine=sh-hitachi - os=-hms + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf ;; - sh5el) - basic_machine=sh5le-unknown + none) + cpu=none + vendor=none ;; - sh64) - basic_machine=sh64-unknown + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks + leon-*|leon[3-9]-*) + cpu=sparc + vendor=$(echo "$basic_machine" | sed 's/-.*//') ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 + + *-*) + # shellcheck disable=SC2162 + IFS="-" read cpu vendor <<EOF +$basic_machine +EOF ;; - spur) - basic_machine=spur-unknown + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + cpu=$basic_machine + vendor=pc ;; - st2000) - basic_machine=m68k-tandem + # These rules are duplicated from below for sake of the special case above; + # i.e. things that normalized to x86 arches should also default to "pc" + pc98) + cpu=i386 + vendor=pc ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 + x64 | amd64) + cpu=x86_64 + vendor=pc ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + # Recognize the basic CPU types without company name. + *) + cpu=$basic_machine + vendor=unknown ;; - sun2) - basic_machine=m68000-sun +esac + +unset -v basic_machine + +# Decode basic machines in the full and proper CPU-Company form. +case $cpu-$vendor in + # Here we handle the default manufacturer of certain CPU types in canonical form. It is in + # some cases the only manufacturer, in others, it is the most popular. + craynv-unknown) + vendor=cray + basic_os=${basic_os:-unicosmp} ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 + c90-unknown | c90-cray) + vendor=cray + basic_os=${Basic_os:-unicos} ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 + fx80-unknown) + vendor=alliant ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 + romp-unknown) + vendor=ibm ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 + mmix-unknown) + vendor=knuth ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 + microblaze-unknown | microblazeel-unknown) + vendor=xilinx ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 + rs6000-unknown) + vendor=ibm ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 + vax-unknown) + vendor=dec ;; - sun3 | sun3-*) - basic_machine=m68k-sun + pdp11-unknown) + vendor=dec ;; - sun4) - basic_machine=sparc-sun + we32k-unknown) + vendor=att ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun + cydra-unknown) + vendor=cydrome ;; - sv1) - basic_machine=sv1-cray - os=-unicos + i370-ibm*) + vendor=ibm ;; - symmetry) - basic_machine=i386-sequent - os=-dynix + orion-unknown) + vendor=highlevel ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos + xps-unknown | xps100-unknown) + cpu=xps100 + vendor=honeywell ;; - t90) - basic_machine=t90-cray - os=-unicos + + # Here we normalize CPU types with a missing or matching vendor + dpx20-unknown | dpx20-bull) + cpu=rs6000 + vendor=bull + basic_os=${basic_os:-bosx} ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu + + # Here we normalize CPU types irrespective of the vendor + amd64-*) + cpu=x86_64 ;; - tx39) - basic_machine=mipstx39-unknown + blackfin-*) + cpu=bfin + basic_os=linux ;; - tx39el) - basic_machine=mipstx39el-unknown + c54x-*) + cpu=tic54x ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 + c55x-*) + cpu=tic55x ;; - tower | tower-32) - basic_machine=m68k-ncr + c6x-*) + cpu=tic6x ;; - tpf) - basic_machine=s390x-ibm - os=-tpf + e500v[12]-*) + cpu=powerpc + basic_os=${basic_os}"spe" ;; - udi29k) - basic_machine=a29k-amd - os=-udi + mips3*-*) + cpu=mips64 ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 + ms1-*) + cpu=mt ;; - v810 | necv810) - basic_machine=v810-nec - os=-none + m68knommu-*) + cpu=m68k + basic_os=linux ;; - vaxv) - basic_machine=vax-dec - os=-sysv + m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) + cpu=s12z ;; - vms) - basic_machine=vax-dec - os=-vms + openrisc-*) + cpu=or32 ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu + parisc-*) + cpu=hppa + basic_os=linux ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + cpu=i586 ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks + pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + cpu=i686 ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + cpu=i686 ;; - w65*) - basic_machine=w65-wdc - os=-none + pentium4-*) + cpu=i786 ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf + pc98-*) + cpu=i386 ;; - xbox) - basic_machine=i686-pc - os=-mingw32 + ppc-* | ppcbe-*) + cpu=powerpc ;; - xps | xps100) - basic_machine=xps100-honeywell + ppcle-* | powerpclittle-*) + cpu=powerpcle ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ppc64-*) + cpu=powerpc64 ;; - ymp) - basic_machine=ymp-cray - os=-unicos + ppc64le-* | powerpc64little-*) + cpu=powerpc64le ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim + sb1-*) + cpu=mipsisa64sb1 ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim + sb1el-*) + cpu=mipsisa64sb1el ;; - none) - basic_machine=none-none - os=-none + sh5e[lb]-*) + cpu=$(echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/') ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond + spur-*) + cpu=spur ;; - op50n) - basic_machine=hppa1.1-oki + strongarm-* | thumb-*) + cpu=arm ;; - op60c) - basic_machine=hppa1.1-oki + tx39-*) + cpu=mipstx39 ;; - romp) - basic_machine=romp-ibm + tx39el-*) + cpu=mipstx39el ;; - mmix) - basic_machine=mmix-knuth + x64-*) + cpu=x86_64 ;; - rs6000) - basic_machine=rs6000-ibm + xscale-* | xscalee[bl]-*) + cpu=$(echo "$cpu" | sed 's/^xscale/arm/') ;; - vax) - basic_machine=vax-dec + arm64-*) + cpu=aarch64 ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. + cr16-*) + basic_os=${basic_os:-elf} ;; - pdp11) - basic_machine=pdp11-dec + crisv32-* | etraxfs*-*) + cpu=crisv32 + vendor=axis ;; - we32k) - basic_machine=we32k-att + cris-* | etrax*-*) + cpu=cris + vendor=axis ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown + crx-*) + basic_os=${basic_os:-elf} ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun + neo-tandem) + cpu=neo + vendor=tandem ;; - cydra) - basic_machine=cydra-cydrome + nse-tandem) + cpu=nse + vendor=tandem ;; - orion) - basic_machine=orion-highlevel + nsr-tandem) + cpu=nsr + vendor=tandem ;; - orion105) - basic_machine=clipper-highlevel + nsv-tandem) + cpu=nsv + vendor=tandem ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple + nsx-tandem) + cpu=nsx + vendor=tandem ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple + mipsallegrexel-sony) + cpu=mipsallegrexel + vendor=sony ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. + tile*-*) + basic_os=${basic_os:-linux-gnu} ;; + *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | loongarch32 | loongarch64 | loongarchx32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1340,200 +1280,213 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if test x$basic_os != x then + +# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=$(echo $basic_os | sed -e 's|gnu/linux|gnu|') + ;; + os2-emx) + kernel=os2 + os=$(echo $basic_os | sed -e 's|os2-emx|emx|') + ;; + nto-qnx*) + kernel=nto + os=$(echo $basic_os | sed -e 's|nto-qnx|qnx|') + ;; + *-*) + # shellcheck disable=SC2162 + IFS="-" read kernel os <<EOF +$basic_os +EOF + ;; + # Default OS when just kernel was specified + nto*) + kernel=nto + os=$(echo $basic_os | sed -e 's|nto|qnx|') + ;; + linux*) + kernel=linux + os=$(echo $basic_os | sed -e 's|linux|gnu|') + ;; + *) + kernel= + os=$basic_os + ;; +esac + +# Now, normalize the OS (knowing we just have one component, it's not a kernel, +# etc.) case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + # First match some system type aliases that might get confused + # with valid system types. + # solaris* is a basic system type, with this one exception. + auroraux) + os=auroraux ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` + bluegene*) + os=cnk ;; - -solaris) - os=-solaris2 + solaris1 | solaris1.*) + os=$(echo $os | sed -e 's|solaris1|sunos4|') ;; - -svr4*) - os=-sysv4 + solaris) + os=solaris2 ;; - -unixware*) - os=-sysv4.2uw + unixware*) + os=sysv4.2uw ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac + # Some version numbers need modification + chorusos*) + os=chorusos ;; - -nto-qnx*) + isc) + os=isc2.2 ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` + sco6) + os=sco5v6 ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + sco5) + os=sco3.2v5 ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + sco4) + os=sco3.2v4 ;; - -linux-dietlibc) - os=-linux-dietlibc + sco3.2.[4-9]*) + os=$(echo $os | sed -e 's/sco3.2./sco3.2v/') ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` + sco*v* | scout) + # Don't match below ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + sco*) + os=sco3.2v2 ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + psos*) + os=psos ;; - -opened*) - os=-openedition + qnx*) + os=qnx ;; - -os400*) - os=-os400 + hiux*) + os=hiuxwe2 ;; - -wince*) - os=-wince + lynx*178) + os=lynxos178 ;; - -osfrose*) - os=-osfrose + lynx*5) + os=lynxos5 ;; - -osf*) - os=-osf + lynxos*) + # don't get caught up in next wildcard ;; - -utek*) - os=-bsd + lynx*) + os=lynxos ;; - -dynix*) - os=-bsd + mac[0-9]*) + os=$(echo "$os" | sed -e 's|mac|macos|') ;; - -acis*) - os=-aos + opened*) + os=openedition ;; - -atheos*) - os=-atheos + os400*) + os=os400 ;; - -syllable*) - os=-syllable + sunos5*) + os=$(echo "$os" | sed -e 's|sunos5|solaris2|') ;; - -386bsd) - os=-bsd + sunos6*) + os=$(echo "$os" | sed -e 's|sunos6|solaris3|') ;; - -ctix* | -uts*) - os=-sysv + wince*) + os=wince ;; - -nova*) - os=-rtmk-nova + utek*) + os=bsd ;; - -ns2 ) - os=-nextstep2 + dynix*) + os=bsd ;; - -nsk*) - os=-nsk + acis*) + os=aos ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` + atheos*) + os=atheos ;; - -sinix*) - os=-sysv4 + syllable*) + os=syllable ;; - -tpf*) - os=-tpf + 386bsd) + os=bsd ;; - -triton*) - os=-sysv3 + ctix* | uts*) + os=sysv ;; - -oss*) - os=-sysv3 + nova*) + os=rtmk-nova ;; - -svr4) - os=-sysv4 + ns2) + os=nextstep2 ;; - -svr3) - os=-sysv3 + # Preserve the version number of sinix5. + sinix5.*) + os=$(echo $os | sed -e 's|sinix|sysv|') ;; - -sysvr4) - os=-sysv4 + sinix*) + os=sysv4 ;; - # This must come after -sysvr4. - -sysv*) + tpf*) + os=tpf ;; - -ose*) - os=-ose + triton*) + os=sysv3 ;; - -es1800*) - os=-ose + oss*) + os=sysv3 ;; - -xenix) - os=-xenix + svr4*) + os=sysv4 ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + svr3) + os=sysv3 ;; - -aros*) - os=-aros + sysvr4) + os=sysv4 ;; - -zvmoe) - os=-zvmoe + ose*) + os=ose ;; - -dicos*) - os=-dicos + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint ;; - -nacl*) + dicos*) + os=dicos ;; - -none) + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $cpu in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac ;; *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1546,261 +1499,361 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + kernel=linux + os=gnu ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; - *-be) - os=-beos + pru-*) + os=elf ;; - *-haiku) - os=-haiku + *-be) + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + musl* | newlib* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* | serenity* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) + ;; + uclinux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - -sunos*) + *-sunos*) vendor=sun ;; - -cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - -beos*) + *-beos*) vendor=be ;; - -hpux*) + *-hpux*) vendor=hp ;; - -mpeix*) + *-mpeix*) vendor=hp ;; - -hiux*) + *-hiux*) vendor=hitachi ;; - -unos*) + *-unos*) vendor=crds ;; - -dgux*) + *-dgux*) vendor=dg ;; - -luna*) + *-luna*) vendor=omron ;; - -genix*) + *-genix*) vendor=ns ;; - -mvs* | -opened*) + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - -os400*) + s390-* | s390x-*) vendor=ibm ;; - -ptx*) + *-ptx*) vendor=sequent ;; - -tpf*) + *-tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - -aux*) + *-aux*) vendor=apple ;; - -hms*) + *-hms*) vendor=hitachi ;; - -mpw* | -macos*) + *-mpw* | *-macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - -vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/tiff/config/install-sh b/tiff/config/install-sh index 0b0fdcbb..8175c640 100755 --- a/tiff/config/install-sh +++ b/tiff/config/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2013-12-25.23; # UTC +scriptversion=2018-03-11.20; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -271,15 +271,18 @@ do fi dst=$dst_arg - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. + # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst - dst=$dstdir/`basename "$src"` + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac dstdir_status=0 else dstdir=`dirname "$dst"` @@ -288,6 +291,11 @@ do fi fi + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + obsolete_mkdir_used=false if test $dstdir_status != 0; then @@ -324,34 +332,43 @@ do # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) + # Note that $RANDOM variable is not portable (e.g. dash); Use it + # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p' feature. if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi - rmdir "$tmpdir/d" "$tmpdir" + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac;; @@ -427,8 +444,8 @@ do else # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 @@ -493,9 +510,9 @@ do done # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/tiff/config/ltmain.sh b/tiff/config/ltmain.sh index 0f0a2da3..0cb7f90d 100644 --- a/tiff/config/ltmain.sh +++ b/tiff/config/ltmain.sh @@ -31,7 +31,7 @@ PROGRAM=libtool PACKAGE=libtool -VERSION=2.4.6 +VERSION="2.4.6 Debian-2.4.6-14" package_revision=2.4.6 @@ -387,7 +387,7 @@ EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. # putting '$debug_cmd' at the start of all your functions, you can get # bash to show function call trace with: # -# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name +# debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name debug_cmd=${debug_cmd-":"} exit_cmd=: @@ -1370,7 +1370,7 @@ func_lt_ver () #! /bin/sh # Set a version string for this script. -scriptversion=2014-01-07.03; # UTC +scriptversion=2015-10-07.11; # UTC # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 @@ -1530,6 +1530,8 @@ func_run_hooks () { $debug_cmd + _G_rc_run_hooks=false + case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not support hook funcions.n" ;; @@ -1538,16 +1540,16 @@ func_run_hooks () eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do - eval $_G_hook '"$@"' - - # store returned options list back into positional - # parameters for next 'cmd' execution. - eval _G_hook_result=\$${_G_hook}_result - eval set dummy "$_G_hook_result"; shift + if eval $_G_hook '"$@"'; then + # store returned options list back into positional + # parameters for next 'cmd' execution. + eval _G_hook_result=\$${_G_hook}_result + eval set dummy "$_G_hook_result"; shift + _G_rc_run_hooks=: + fi done - func_quote_for_eval ${1+"$@"} - func_run_hooks_result=$func_quote_for_eval_result + $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result } @@ -1557,10 +1559,16 @@ func_run_hooks () ## --------------- ## # In order to add your own option parsing hooks, you must accept the -# full positional parameter list in your hook function, remove any -# options that you action, and then pass back the remaining unprocessed +# full positional parameter list in your hook function, you may remove/edit +# any options that you action, and then pass back the remaining unprocessed # options in '<hooked_function_name>_result', escaped suitably for -# 'eval'. Like this: +# 'eval'. In this case you also must return $EXIT_SUCCESS to let the +# hook's caller know that it should pay attention to +# '<hooked_function_name>_result'. Returning $EXIT_FAILURE signalizes that +# arguments are left untouched by the hook and therefore caller will ignore the +# result variable. +# +# Like this: # # my_options_prep () # { @@ -1570,9 +1578,11 @@ func_run_hooks () # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' -# -# func_quote_for_eval ${1+"$@"} -# my_options_prep_result=$func_quote_for_eval_result +# # No change in '$@' (ignored completely by this hook). There is +# # no need to do the equivalent (but slower) action: +# # func_quote_for_eval ${1+"$@"} +# # my_options_prep_result=$func_quote_for_eval_result +# false # } # func_add_hook func_options_prep my_options_prep # @@ -1581,25 +1591,37 @@ func_run_hooks () # { # $debug_cmd # +# args_changed=false +# # # Note that for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in -# --silent|-s) opt_silent=: ;; +# --silent|-s) opt_silent=: +# args_changed=: +# ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift +# args_changed=: # ;; -# *) set dummy "$_G_opt" "$*"; shift; break ;; +# *) # Make sure the first unrecognised option "$_G_opt" +# # is added back to "$@", we could need that later +# # if $args_changed is true. +# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; # esac # done # -# func_quote_for_eval ${1+"$@"} -# my_silent_option_result=$func_quote_for_eval_result +# if $args_changed; then +# func_quote_for_eval ${1+"$@"} +# my_silent_option_result=$func_quote_for_eval_result +# fi +# +# $args_changed # } # func_add_hook func_parse_options my_silent_option # @@ -1611,16 +1633,32 @@ func_run_hooks () # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." # -# func_quote_for_eval ${1+"$@"} -# my_option_validation_result=$func_quote_for_eval_result +# false # } # func_add_hook func_validate_options my_option_validation # -# You'll alse need to manually amend $usage_message to reflect the extra +# You'll also need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. +# func_options_finish [ARG]... +# ---------------------------- +# Finishing the option parse loop (call 'func_options' hooks ATM). +func_options_finish () +{ + $debug_cmd + + _G_func_options_finish_exit=false + if func_run_hooks func_options ${1+"$@"}; then + func_options_finish_result=$func_run_hooks_result + _G_func_options_finish_exit=: + fi + + $_G_func_options_finish_exit +} + + # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the @@ -1630,17 +1668,28 @@ func_options () { $debug_cmd - func_options_prep ${1+"$@"} - eval func_parse_options \ - ${func_options_prep_result+"$func_options_prep_result"} - eval func_validate_options \ - ${func_parse_options_result+"$func_parse_options_result"} + _G_rc_options=false + + for my_func in options_prep parse_options validate_options options_finish + do + if eval func_$my_func '${1+"$@"}'; then + eval _G_res_var='$'"func_${my_func}_result" + eval set dummy "$_G_res_var" ; shift + _G_rc_options=: + fi + done - eval func_run_hooks func_options \ - ${func_validate_options_result+"$func_validate_options_result"} + # Save modified positional parameters for caller. As a top-level + # options-parser function we always need to set the 'func_options_result' + # variable (regardless the $_G_rc_options value). + if $_G_rc_options; then + func_options_result=$_G_res_var + else + func_quote_for_eval ${1+"$@"} + func_options_result=$func_quote_for_eval_result + fi - # save modified positional parameters for caller - func_options_result=$func_run_hooks_result + $_G_rc_options } @@ -1649,9 +1698,9 @@ func_options () # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and -# needs to propogate that back to rest of this script, then the complete +# needs to propagate that back to rest of this script, then the complete # modified list must be put in 'func_run_hooks_result' before -# returning. +# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned). func_hookable func_options_prep func_options_prep () { @@ -1661,10 +1710,14 @@ func_options_prep () opt_verbose=false opt_warning_types= - func_run_hooks func_options_prep ${1+"$@"} + _G_rc_options_prep=false + if func_run_hooks func_options_prep ${1+"$@"}; then + _G_rc_options_prep=: + # save modified positional parameters for caller + func_options_prep_result=$func_run_hooks_result + fi - # save modified positional parameters for caller - func_options_prep_result=$func_run_hooks_result + $_G_rc_options_prep } @@ -1678,18 +1731,20 @@ func_parse_options () func_parse_options_result= + _G_rc_parse_options=false # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. - func_run_hooks func_parse_options ${1+"$@"} - - # Adjust func_parse_options positional parameters to match - eval set dummy "$func_run_hooks_result"; shift + if func_run_hooks func_parse_options ${1+"$@"}; then + eval set dummy "$func_run_hooks_result"; shift + _G_rc_parse_options=: + fi # Break out of the loop if we already parsed every option. test $# -gt 0 || break + _G_match_parse_options=: _G_opt=$1 shift case $_G_opt in @@ -1704,7 +1759,10 @@ func_parse_options () ;; --warnings|--warning|-W) - test $# = 0 && func_missing_arg $_G_opt && break + if test $# = 0 && func_missing_arg $_G_opt; then + _G_rc_parse_options=: + break + fi case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above @@ -1757,15 +1815,25 @@ func_parse_options () shift ;; - --) break ;; + --) _G_rc_parse_options=: ; break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; - *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift + _G_match_parse_options=false + break + ;; esac + + $_G_match_parse_options && _G_rc_parse_options=: done - # save modified positional parameters for caller - func_quote_for_eval ${1+"$@"} - func_parse_options_result=$func_quote_for_eval_result + + if $_G_rc_parse_options; then + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + func_parse_options_result=$func_quote_for_eval_result + fi + + $_G_rc_parse_options } @@ -1778,16 +1846,21 @@ func_validate_options () { $debug_cmd + _G_rc_validate_options=false + # Display all warnings if -W was not given. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" - func_run_hooks func_validate_options ${1+"$@"} + if func_run_hooks func_validate_options ${1+"$@"}; then + # save modified positional parameters for caller + func_validate_options_result=$func_run_hooks_result + _G_rc_validate_options=: + fi # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE - # save modified positional parameters for caller - func_validate_options_result=$func_run_hooks_result + $_G_rc_validate_options } @@ -2068,12 +2141,12 @@ include the following information: compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) - version: $progname (GNU libtool) 2.4.6 + version: $progname $scriptversion Debian-2.4.6-14 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to <bug-libtool@gnu.org>. -GNU libtool home page: <http://www.gnu.org/software/libtool/>. +GNU libtool home page: <http://www.gnu.org/s/libtool/>. General help using GNU software: <http://www.gnu.org/gethelp/>." exit 0 } @@ -2270,6 +2343,8 @@ libtool_options_prep () nonopt= preserve_args= + _G_rc_lt_options_prep=: + # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) @@ -2293,11 +2368,18 @@ libtool_options_prep () uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; + *) + _G_rc_lt_options_prep=false + ;; esac - # Pass back the list of options. - func_quote_for_eval ${1+"$@"} - libtool_options_prep_result=$func_quote_for_eval_result + if $_G_rc_lt_options_prep; then + # Pass back the list of options. + func_quote_for_eval ${1+"$@"} + libtool_options_prep_result=$func_quote_for_eval_result + fi + + $_G_rc_lt_options_prep } func_add_hook func_options_prep libtool_options_prep @@ -2309,9 +2391,12 @@ libtool_parse_options () { $debug_cmd + _G_rc_lt_parse_options=false + # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do + _G_match_lt_parse_options=: _G_opt=$1 shift case $_G_opt in @@ -2386,15 +2471,22 @@ libtool_parse_options () func_append preserve_args " $_G_opt" ;; - # An option not handled by this hook function: - *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"} ; shift + _G_match_lt_parse_options=false + break + ;; esac + $_G_match_lt_parse_options && _G_rc_lt_parse_options=: done + if $_G_rc_lt_parse_options; then + # save modified positional parameters for caller + func_quote_for_eval ${1+"$@"} + libtool_parse_options_result=$func_quote_for_eval_result + fi - # save modified positional parameters for caller - func_quote_for_eval ${1+"$@"} - libtool_parse_options_result=$func_quote_for_eval_result + $_G_rc_lt_parse_options } func_add_hook func_parse_options libtool_parse_options @@ -7272,10 +7364,16 @@ func_mode_link () # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -specs=* GCC specs files # -stdlib=* select c++ std lib with clang + # -fsanitize=* Clang/GCC memory and address sanitizer + # -fuse-ld=* Linker select flags for GCC + # -static-* direct GCC to link specific libraries statically + # -fcilkplus Cilk Plus language extension features for C/C++ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ + -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result func_append compile_command " $arg" @@ -7568,7 +7666,10 @@ func_mode_link () case $pass in dlopen) libs=$dlfiles ;; dlpreopen) libs=$dlprefiles ;; - link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + link) + libs="$deplibs %DEPLIBS%" + test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" + ;; esac fi if test lib,dlpreopen = "$linkmode,$pass"; then @@ -7887,19 +7988,19 @@ func_mode_link () # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_preserve_dup_deps; then + case "$tmp_libs " in + *" $deplib "*) func_append specialdeplibs " $deplib" ;; + esac + fi + func_append tmp_libs " $deplib" + done elif test prog != "$linkmode" && test lib != "$linkmode"; then func_fatal_error "'$lib' is not a convenience library" fi - tmp_libs= - for deplib in $dependency_libs; do - deplibs="$deplib $deplibs" - if $opt_preserve_dup_deps; then - case "$tmp_libs " in - *" $deplib "*) func_append specialdeplibs " $deplib" ;; - esac - fi - func_append tmp_libs " $deplib" - done continue fi # $pass = conv @@ -8823,6 +8924,9 @@ func_mode_link () revision=$number_minor lt_irix_increment=no ;; + *) + func_fatal_configuration "$modename: unknown library version type '$version_type'" + ;; esac ;; no) diff --git a/tiff/config/test-driver b/tiff/config/test-driver index 8e575b01..b8521a48 100755 --- a/tiff/config/test-driver +++ b/tiff/config/test-driver @@ -1,9 +1,9 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2013-07-13.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-2018 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ scriptversion=2013-07-13.22; # UTC # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -140,9 +140,9 @@ echo ":copy-in-global-log: $gcopy" >> $trs_file # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/tiff/configure b/tiff/configure index 96362dad..1d9918f7 100755 --- a/tiff/configure +++ b/tiff/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for LibTIFF Software 4.2.0. +# Generated by GNU Autoconf 2.69 for LibTIFF Software 4.3.0. # # Report bugs to <tiff@lists.maptools.org>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='LibTIFF Software' PACKAGE_TARNAME='tiff' -PACKAGE_VERSION='4.2.0' -PACKAGE_STRING='LibTIFF Software 4.2.0' +PACKAGE_VERSION='4.3.0' +PACKAGE_STRING='LibTIFF Software 4.3.0' PACKAGE_BUGREPORT='tiff@lists.maptools.org' PACKAGE_URL='' @@ -662,6 +662,8 @@ HAVE_ZSTD_FALSE HAVE_ZSTD_TRUE HAVE_LZMA_FALSE HAVE_LZMA_TRUE +HAVE_LERC_FALSE +HAVE_LERC_TRUE HAVE_JBIG_FALSE HAVE_JBIG_TRUE HAVE_JPEG_FALSE @@ -785,6 +787,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -844,6 +847,9 @@ enable_old_jpeg enable_jbig with_jbig_include_dir with_jbig_lib_dir +enable_lerc +with_lerc_include_dir +with_lerc_lib_dir enable_lzma with_lzma_include_dir with_lzma_lib_dir @@ -919,6 +925,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1171,6 +1178,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1308,7 +1324,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1421,7 +1437,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures LibTIFF Software 4.2.0 to adapt to many kinds of systems. +\`configure' configures LibTIFF Software 4.3.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1461,6 +1477,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1495,7 +1512,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of LibTIFF Software 4.2.0:";; + short | recursive ) echo "Configuration of LibTIFF Software 4.3.0:";; esac cat <<\_ACEOF @@ -1542,6 +1559,8 @@ Optional Features: enabled by default) --disable-jbig disable JBIG-KIT usage (required for ISO JBIG compression, enabled by default) + --disable-lerc disable liblerc usage (required for lerc + compression, enabled by default) --disable-lzma disable liblzma usage (required for LZMA2 compression, enabled by default) --disable-zstd disable libzstd usage (required for zstd @@ -1556,7 +1575,7 @@ Optional Features: --disable-strip-chopping disable support for strip chopping (whether or not to convert single-strip uncompressed images to - mutiple strips of specified size to reduce memory + multiple strips of specified size to reduce memory usage) --enable-defer-strile-load enable deferred strip/tile offset/size loading (also @@ -1598,6 +1617,9 @@ Optional Packages: --with-jbig-include-dir=DIR location of JBIG-KIT headers --with-jbig-lib-dir=DIR location of JBIG-KIT library binary + --with-lerc-include-dir=DIR + location of liblerc headers + --with-lerc-lib-dir=DIR location of liblerc library binary --with-lzma-include-dir=DIR location of liblzma headers --with-lzma-lib-dir=DIR location of liblzma library binary @@ -1698,7 +1720,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -LibTIFF Software configure 4.2.0 +LibTIFF Software configure 4.3.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2471,7 +2493,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by LibTIFF Software $as_me 4.2.0, which was +It was created by LibTIFF Software $as_me 4.3.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3414,7 +3436,7 @@ fi # Define the identity of the package. PACKAGE='tiff' - VERSION='4.2.0' + VERSION='4.3.0' cat >>confdefs.h <<_ACEOF @@ -3648,15 +3670,15 @@ fi LIBTIFF_MAJOR_VERSION=4 -LIBTIFF_MINOR_VERSION=2 +LIBTIFF_MINOR_VERSION=3 LIBTIFF_MICRO_VERSION=0 LIBTIFF_ALPHA_VERSION= LIBTIFF_VERSION=$LIBTIFF_MAJOR_VERSION.$LIBTIFF_MINOR_VERSION.$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION LIBTIFF_RELEASE_DATE=`date +"%Y%m%d"` -LIBTIFF_CURRENT=11 +LIBTIFF_CURRENT=12 LIBTIFF_REVISION=0 -LIBTIFF_AGE=6 +LIBTIFF_AGE=7 LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE # This is a special hack for OpenBSD and MirOS systems. The dynamic linker @@ -3680,6 +3702,69 @@ LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 +$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } +cat > confinc.mk << 'END' +am__doit: + @echo this is the am__doit target >confinc.out +.PHONY: am__doit +END +am__include="#" +am__quote= +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 + (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + case $?:`cat confinc.out 2>/dev/null` in #( + '0:this is the am__doit target') : + case $s in #( + BSD) : + am__include='.include' am__quote='"' ;; #( + *) : + am__include='include' am__quote='' ;; +esac ;; #( + *) : + ;; +esac + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 +$as_echo "${_am_result}" >&6; } + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' + am__nodep='_no' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4527,69 +4612,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 -$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } -cat > confinc.mk << 'END' -am__doit: - @echo this is the am__doit target >confinc.out -.PHONY: am__doit -END -am__include="#" -am__quote= -# BSD make does it like this. -echo '.include "confinc.mk" # ignored' > confmf.BSD -# Other make implementations (GNU, Solaris 10, AIX) do it like this. -echo 'include confinc.mk # ignored' > confmf.GNU -_am_result=no -for s in GNU BSD; do - { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 - (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } - case $?:`cat confinc.out 2>/dev/null` in #( - '0:this is the am__doit target') : - case $s in #( - BSD) : - am__include='.include' am__quote='"' ;; #( - *) : - am__include='include' am__quote='' ;; -esac ;; #( - *) : - ;; -esac - if test "$am__include" != "#"; then - _am_result="yes ($s style)" - break - fi -done -rm -f confinc.* confmf.* -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 -$as_echo "${_am_result}" >&6; } - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' - am__nodep='_no' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - depcc="$CC" am_compiler_list= @@ -4719,6 +4741,183 @@ else fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 +$as_echo_n "checking for $CC option to accept ISO C99... " >&6; } +if ${ac_cv_prog_cc_c99+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c99=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdbool.h> +#include <stdlib.h> +#include <wchar.h> +#include <stdio.h> + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +#define debug(...) fprintf (stderr, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + your preprocessor is broken; +#endif +#if BIG_OK +#else + your preprocessor is broken; +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\0'; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static void +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str; + int number; + float fnumber; + + while (*format) + { + switch (*format++) + { + case 's': // string + str = va_arg (args_copy, const char *); + break; + case 'd': // int + number = va_arg (args_copy, int); + break; + case 'f': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); +} + +int +main () +{ + + // Check bool. + _Bool success = false; + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + test_varargs ("s, d' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' + || dynamic_array[ni.number - 1] != 543); + + ; + return 0; +} +_ACEOF +for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c99=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c99" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c99" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c99" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +$as_echo "$ac_cv_prog_cc_c99" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c99" != xno; then : + +fi + + @@ -6165,7 +6364,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; -netbsd*) +netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else @@ -6524,7 +6723,7 @@ esac fi : ${AR=ar} -: ${AR_FLAGS=cru} +: ${AR_FLAGS=cr} @@ -7025,11 +7224,8 @@ _LT_EOF test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s "$nlist"; then + $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 + if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -8248,8 +8444,8 @@ int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 + echo "$AR cr libconftest.a conftest.o" >&5 + $AR cr libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF @@ -9676,6 +9872,12 @@ lt_prog_compiler_static= lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; + # flang / f18. f95 an alias for gfortran or flang on Debian + flang* | f18* | f95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) @@ -10152,6 +10354,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie openbsd* | bitrig*) with_gnu_ld=no ;; + linux* | k*bsd*-gnu | gnu*) + link_all_deplibs=no + ;; esac ld_shlibs=yes @@ -10406,7 +10611,7 @@ _LT_EOF fi ;; - netbsd*) + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= @@ -11076,6 +11281,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi + link_all_deplibs=no else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' @@ -11097,7 +11303,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } esac ;; - netbsd*) + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else @@ -12212,6 +12418,18 @@ fi dynamic_linker='GNU/Linux ld.so' ;; +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + netbsd*) version_type=sunos need_lib_prefix=no @@ -14020,7 +14238,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else GXX=no @@ -14512,7 +14730,7 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -14577,7 +14795,7 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -14916,7 +15134,7 @@ fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # FIXME: insert proper C++ library support @@ -15000,7 +15218,7 @@ fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. @@ -15011,7 +15229,7 @@ fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' fi hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir' @@ -15524,7 +15742,7 @@ lt_prog_compiler_static_CXX= ;; esac ;; - netbsd*) + netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise @@ -15899,6 +16117,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie ;; esac ;; + linux* | k*bsd*-gnu | gnu*) + link_all_deplibs_CXX=no + ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; @@ -16592,6 +16813,18 @@ fi dynamic_linker='GNU/Linux ld.so' ;; +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + netbsd*) version_type=sunos need_lib_prefix=no @@ -17113,48 +17346,6 @@ $as_echo "#define const /**/" >>confdefs.h fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } -if ${ac_cv_c_inline+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_inline=$ac_kw -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } - -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : @@ -17554,254 +17745,8 @@ _ACEOF -# Obtain size of an 'signed int' and define as SIZEOF_SIGNED_INT -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of signed int" >&5 -$as_echo_n "checking size of signed int... " >&6; } -if ${ac_cv_sizeof_signed_int+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (signed int))" "ac_cv_sizeof_signed_int" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_signed_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (signed int) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_signed_int=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_signed_int" >&5 -$as_echo "$ac_cv_sizeof_signed_int" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SIGNED_INT $ac_cv_sizeof_signed_int -_ACEOF - - - -# Obtain size of an 'unsigned int' and define as SIZEOF_UNSIGNED_INT -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned int" >&5 -$as_echo_n "checking size of unsigned int... " >&6; } -if ${ac_cv_sizeof_unsigned_int+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned int))" "ac_cv_sizeof_unsigned_int" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_unsigned_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (unsigned int) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_unsigned_int=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_int" >&5 -$as_echo "$ac_cv_sizeof_unsigned_int" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int -_ACEOF - - - -# Obtain size of a 'signed long' and define as SIZEOF_SIGNED_LONG -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of signed long" >&5 -$as_echo_n "checking size of signed long... " >&6; } -if ${ac_cv_sizeof_signed_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (signed long))" "ac_cv_sizeof_signed_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_signed_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (signed long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_signed_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_signed_long" >&5 -$as_echo "$ac_cv_sizeof_signed_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SIGNED_LONG $ac_cv_sizeof_signed_long -_ACEOF - - - -# Obtain size of a 'unsigned long' and define as SIZEOF_UNSIGNED_LONG -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned long" >&5 -$as_echo_n "checking size of unsigned long... " >&6; } -if ${ac_cv_sizeof_unsigned_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned long))" "ac_cv_sizeof_unsigned_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_unsigned_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (unsigned long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_unsigned_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_long" >&5 -$as_echo "$ac_cv_sizeof_unsigned_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_UNSIGNED_LONG $ac_cv_sizeof_unsigned_long -_ACEOF - - - -# Obtain size of a 'long long' and define as SIZEOF_SIGNED_LONG_LONG. -# If 'long long' is not supported then the value defined is zero. -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of signed long long" >&5 -$as_echo_n "checking size of signed long long... " >&6; } -if ${ac_cv_sizeof_signed_long_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (signed long long))" "ac_cv_sizeof_signed_long_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_signed_long_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (signed long long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_signed_long_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_signed_long_long" >&5 -$as_echo "$ac_cv_sizeof_signed_long_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SIGNED_LONG_LONG $ac_cv_sizeof_signed_long_long -_ACEOF - - - -# Obtain size of a 'unsigned long long' and define as -# SIZEOF_UNSIGNED_LONG_LONG. If 'unsigned long long' is not -# supported then the value defined is zero. -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned long long" >&5 -$as_echo_n "checking size of unsigned long long... " >&6; } -if ${ac_cv_sizeof_unsigned_long_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned long long))" "ac_cv_sizeof_unsigned_long_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_unsigned_long_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (unsigned long long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_unsigned_long_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_long_long" >&5 -$as_echo "$ac_cv_sizeof_unsigned_long_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_UNSIGNED_LONG_LONG $ac_cv_sizeof_unsigned_long_long -_ACEOF - - - -# Obtain the size of an 'unsigned char *' and define as -# SIZEOF_UNSIGNED_CHAR_P. Result is available in -# ac_cv_sizeof_unsigned_char_p. -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned char *" >&5 -$as_echo_n "checking size of unsigned char *... " >&6; } -if ${ac_cv_sizeof_unsigned_char_p+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned char *))" "ac_cv_sizeof_unsigned_char_p" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_unsigned_char_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (unsigned char *) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_unsigned_char_p=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_char_p" >&5 -$as_echo "$ac_cv_sizeof_unsigned_char_p" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_UNSIGNED_CHAR_P $ac_cv_sizeof_unsigned_char_p -_ACEOF - +# Disable deprecated features to ensure clean build +CPPFLAGS="-DTIFF_DISABLE_DEPRECATED $CPPFLAGS" # Obtain the size of 'size_t' and define as SIZEOF_SIZE_T. Result is @@ -17840,241 +17785,34 @@ _ACEOF -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed 8-bit type" >&5 -$as_echo_n "checking for signed 8-bit type... " >&6; } -INT8_T='signed char' -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INT8_T" >&5 -$as_echo "$INT8_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_INT8_T $INT8_T -_ACEOF - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned 8-bit type" >&5 -$as_echo_n "checking for unsigned 8-bit type... " >&6; } -UINT8_T='unsigned char' -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $UINT8_T" >&5 -$as_echo "$UINT8_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_UINT8_T $UINT8_T -_ACEOF - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed 16-bit type" >&5 -$as_echo_n "checking for signed 16-bit type... " >&6; } -INT16_T='signed short' -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INT16_T" >&5 -$as_echo "$INT16_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_INT16_T $INT16_T -_ACEOF - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned 16-bit type" >&5 -$as_echo_n "checking for unsigned 16-bit type... " >&6; } -UINT16_T='unsigned short' -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $UINT16_T" >&5 -$as_echo "$UINT16_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_UINT16_T $UINT16_T -_ACEOF - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed 32-bit type" >&5 -$as_echo_n "checking for signed 32-bit type... " >&6; } -INT32_T='none' -INT32_FORMAT='none' -if test $ac_cv_sizeof_signed_int -eq 4 -then - INT32_T='signed int' - INT32_FORMAT='"%d"' -elif test $ac_cv_sizeof_signed_long -eq 4 -then - INT32_T='signed long' - INT32_FORMAT='"%ld"' -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INT32_T" >&5 -$as_echo "$INT32_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_INT32_T $INT32_T -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define TIFF_INT32_FORMAT $INT32_FORMAT -_ACEOF - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned 32-bit type" >&5 -$as_echo_n "checking for unsigned 32-bit type... " >&6; } -UINT32_T='none' -UINT32_FORMAT='none' -if test $ac_cv_sizeof_unsigned_int -eq 4 -then - UINT32_T='unsigned int' - UINT32_FORMAT='"%u"' -elif test $ac_cv_sizeof_unsigned_long -eq 4 -then - UINT32_T='unsigned long' - UINT32_FORMAT='"%lu"' -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $UINT32_T" >&5 -$as_echo "$UINT32_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_UINT32_T $UINT32_T -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define TIFF_UINT32_FORMAT $UINT32_FORMAT -_ACEOF - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed 64-bit type" >&5 -$as_echo_n "checking for signed 64-bit type... " >&6; } -INT64_T='none' -INT64_FORMAT='none' -if test $ac_cv_sizeof_signed_long -eq 8 -then - INT64_T='signed long' - INT64_FORMAT='"%ld"' -elif test $ac_cv_sizeof_signed_long_long -eq 8 -then - INT64_T='signed long long' - case "${host_os}" in - mingw32*) - # MinGW32 understands 'long long', but uses printf from WIN32 CRT - INT64_FORMAT='"%I64d"' - ;; - *) - INT64_FORMAT='"%lld"' - ;; - esac -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INT64_T" >&5 -$as_echo "$INT64_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_INT64_T $INT64_T -_ACEOF +# C99 fixed-size integer types +INT8_T='int8_t' +UINT8_T='uint8_t' +INT16_T='int16_t' +UINT16_T='uint16_t' -cat >>confdefs.h <<_ACEOF -#define TIFF_INT64_FORMAT $INT64_FORMAT -_ACEOF +INT32_T='int32_t' +UINT32_T='uint32_t' +INT64_T='int64_t' +UINT64_T='uint64_t' -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned 64-bit type" >&5 -$as_echo_n "checking for unsigned 64-bit type... " >&6; } -UINT64_T='none' -UINT64_FORMAT='none' -if test $ac_cv_sizeof_unsigned_long -eq 8 +if test $ac_cv_sizeof_size_t -eq 4 then - UINT64_T='unsigned long' - UINT64_FORMAT='"%lu"' -elif test $ac_cv_sizeof_unsigned_long_long -eq 8 + SSIZE_T='int32_t' +elif test $ac_cv_sizeof_size_t -eq 8 then - UINT64_T='unsigned long long' - case "${host_os}" in - mingw32*) - # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT - UINT64_FORMAT='"%I64u"' - ;; - *) - UINT64_FORMAT='"%llu"' - ;; - esac -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $UINT64_T" >&5 -$as_echo "$UINT64_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_UINT64_T $UINT64_T -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define TIFF_UINT64_FORMAT $UINT64_FORMAT -_ACEOF - - -# Determine formatting specifier for 'size_t'. While the size should -# be precise, the type determined may not match the system definition. -# A named type is provided to allow casting to the type we determined -# without changing the actual size. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for 'size_t' format specifier" >&5 -$as_echo_n "checking for 'size_t' format specifier... " >&6; } -SIZE_T='unknown' -SIZE_FORMAT='unknown' -if test $ac_cv_sizeof_unsigned_int -eq $ac_cv_sizeof_size_t -then - SIZE_T='unsigned int' - SIZE_FORMAT='"%u"' -elif test $ac_cv_sizeof_unsigned_long -eq $ac_cv_sizeof_size_t -then - SIZE_T='unsigned long' - SIZE_FORMAT='"%lu"' -elif test $ac_cv_sizeof_unsigned_long_long -eq $ac_cv_sizeof_size_t -then - SIZE_T='unsigned long long' - case "${host_os}" in - mingw32*) - # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT - SIZE_FORMAT='"%I64u"' - ;; - *) - SIZE_FORMAT='"%llu"' - ;; - esac + SSIZE_T='int64_t' +else + as_fn_error $? "Unsupported size_t size ${ac_cv_sizeof_size_t}; please add support" "$LINENO" 5 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SIZE_FORMAT" >&5 -$as_echo "$SIZE_FORMAT" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_SIZE_T $SIZE_T -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define TIFF_SIZE_FORMAT $SIZE_FORMAT -_ACEOF # Determine TIFF equivalent of ssize_t { $as_echo "$as_me:${as_lineno-$LINENO}: checking for signed size type" >&5 $as_echo_n "checking for signed size type... " >&6; } -SSIZE_T='unknown' -SSIZE_FORMAT='unknown' -if test $ac_cv_sizeof_signed_int -eq $ac_cv_sizeof_size_t -then - SSIZE_T='signed int' - SSIZE_FORMAT='"%d"' -elif test $ac_cv_sizeof_signed_long -eq $ac_cv_sizeof_size_t -then - SSIZE_T='signed long' - SSIZE_FORMAT='"%ld"' -elif test $ac_cv_sizeof_signed_long_long -eq $ac_cv_sizeof_size_t -then - SSIZE_T='signed long long' - case "${host_os}" in - mingw32*) - # MinGW32 understands 'long long', but uses printf from WIN32 CRT - SSIZE_FORMAT='"%I64d"' - ;; - *) - SSIZE_FORMAT='"%lld"' - ;; - esac -fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SSIZE_T" >&5 $as_echo "$SSIZE_T" >&6; } @@ -18083,42 +17821,7 @@ cat >>confdefs.h <<_ACEOF _ACEOF -cat >>confdefs.h <<_ACEOF -#define TIFF_SSIZE_FORMAT $SSIZE_FORMAT -_ACEOF - - -# Determine the type to use for the difference between two pointers. -# We will default to the POSIX ptrdiff_t if it is available, but will -# be prepared for the case when it is not. -PTRDIFF_T='unknown' -PTRDIFF_FORMAT='"%ld"' -ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" -if test "x$ac_cv_type_ptrdiff_t" = xyes; then : - PTRDIFF_T=ptrdiff_t -fi - -if test $PTRDIFF_T = unknown -then - PTRDIFF_T=$SSIZE_T - PTRDIFF_FORMAT=$SSIZE_FORMAT -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pointer difference type" >&5 -$as_echo_n "checking for pointer difference type... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTRDIFF_T" >&5 -$as_echo "$PTRDIFF_T" >&6; } - -cat >>confdefs.h <<_ACEOF -#define TIFF_PTRDIFF_T $PTRDIFF_T -_ACEOF - - -cat >>confdefs.h <<_ACEOF -#define TIFF_PTRDIFF_FORMAT $PTRDIFF_FORMAT -_ACEOF - - -for ac_func in mmap setmode snprintf +for ac_func in mmap setmode do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -18145,104 +17848,6 @@ esac fi -ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf" -if test "x$ac_cv_func_snprintf" = xyes; then : - $as_echo "#define HAVE_SNPRINTF 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" snprintf.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS snprintf.$ac_objext" - ;; -esac - -fi - - -ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" -if test "x$ac_cv_func_strcasecmp" = xyes; then : - $as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" strcasecmp.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strcasecmp.$ac_objext" - ;; -esac - -fi - - -ac_fn_c_check_func "$LINENO" "strtol" "ac_cv_func_strtol" -if test "x$ac_cv_func_strtol" = xyes; then : - $as_echo "#define HAVE_STRTOL 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" strtol.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtol.$ac_objext" - ;; -esac - -fi - - -ac_fn_c_check_func "$LINENO" "strtoll" "ac_cv_func_strtoll" -if test "x$ac_cv_func_strtoll" = xyes; then : - $as_echo "#define HAVE_STRTOLL 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" strtoll.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtoll.$ac_objext" - ;; -esac - -fi - - -ac_fn_c_check_func "$LINENO" "strtoul" "ac_cv_func_strtoul" -if test "x$ac_cv_func_strtoul" = xyes; then : - $as_echo "#define HAVE_STRTOUL 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" strtoul.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtoul.$ac_objext" - ;; -esac - -fi - - -ac_fn_c_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull" -if test "x$ac_cv_func_strtoull" = xyes; then : - $as_echo "#define HAVE_STRTOULL 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" strtoull.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtoull.$ac_objext" - ;; -esac - -fi - - -ac_fn_c_check_func "$LINENO" "lfind" "ac_cv_func_lfind" -if test "x$ac_cv_func_lfind" = xyes; then : - $as_echo "#define HAVE_LFIND 1" >>confdefs.h - -else - case " $LIBOBJS " in - *" lfind.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS lfind.$ac_objext" - ;; -esac - -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking native cpu bit order" >&5 $as_echo_n "checking native cpu bit order... " >&6; } @@ -18328,7 +17933,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -18374,7 +17979,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -18398,7 +18003,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -18443,7 +18048,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -18467,7 +18072,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -18520,6 +18125,8 @@ fi + + # Check whether --enable-ccitt was given. if test "${enable_ccitt+set}" = set; then : enableval=$enable_ccitt; HAVE_CCITT=$enableval @@ -19123,6 +18730,172 @@ fi +HAVE_LERC=no + +# Check whether --enable-lerc was given. +if test "${enable_lerc+set}" = set; then : + enableval=$enable_lerc; +fi + + +# Check whether --with-lerc-include-dir was given. +if test "${with_lerc_include_dir+set}" = set; then : + withval=$with_lerc_include_dir; +fi + + +# Check whether --with-lerc-lib-dir was given. +if test "${with_lerc_lib_dir+set}" = set; then : + withval=$with_lerc_lib_dir; +fi + + +if test "x$enable_lerc" != "xno" ; then + + if test "x$with_lerc_lib_dir" != "x" ; then + LDFLAGS="-L$with_lerc_lib_dir $LDFLAGS" + fi + + lerc_lib_name="LercLib" + as_ac_Lib=`$as_echo "ac_cv_lib_"$lerc_lib_name"''_lerc_decode" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lerc_decode in -l\"$lerc_lib_name\"" >&5 +$as_echo_n "checking for lerc_decode in -l\"$lerc_lib_name\"... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-l"$lerc_lib_name" $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char lerc_decode (); +int +main () +{ +return lerc_decode (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + lerc_lib=yes +else + lerc_lib=no +fi + + if test "$lerc_lib" = "no" ; then + lerc_lib_name="Lerc" + as_ac_Lib=`$as_echo "ac_cv_lib_"$lerc_lib_name"''_lerc_decode" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lerc_decode in -l\"$lerc_lib_name\"" >&5 +$as_echo_n "checking for lerc_decode in -l\"$lerc_lib_name\"... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-l"$lerc_lib_name" $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char lerc_decode (); +int +main () +{ +return lerc_decode (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" +else + eval "$as_ac_Lib=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + lerc_lib=yes +else + lerc_lib=no +fi + + fi + if test "$lerc_lib" = "no" -a "x$with_lerc_lib_dir" != "x"; then + as_fn_error $? "lerc library not found at $with_lerc_lib_dir" "$LINENO" 5 + fi + + if test "x$with_lerc_include_dir" != "x" ; then + CPPFLAGS="-I$with_lerc_include_dir $CPPFLAGS" + fi + ac_fn_c_check_header_mongrel "$LINENO" "Lerc_c_api.h" "ac_cv_header_Lerc_c_api_h" "$ac_includes_default" +if test "x$ac_cv_header_Lerc_c_api_h" = xyes; then : + lerc_c_api_h=yes +else + lerc_c_api_h=no +fi + + + if test "$lerc_c_api_h" = "no" -a "x$with_lerc_include_dir" != "x" ; then + as_fn_error $? "Liblerc headers not found at $with_lerc_include_dir" "$LINENO" 5 + fi + + if test "$lerc_lib" = "yes" -a "$lerc_c_api_h" = "yes" ; then + HAVE_LERC=yes + fi + +fi + +if test "$HAVE_LERC" = "yes" ; then + +$as_echo "#define LERC_SUPPORT 1" >>confdefs.h + + LIBS="-l${lerc_lib_name} $LIBS" + tiff_libs_private="-l${lerc_lib_name} ${tiff_libs_private}" + + if test "$HAVE_RPATH" = "yes" -a "x$with_lerc_lib_dir" != "x" ; then + LIBDIR="-R $with_lerc_lib_dir $LIBDIR" + fi + +fi + + if test "$HAVE_LERC" = 'yes'; then + HAVE_LERC_TRUE= + HAVE_LERC_FALSE='#' +else + HAVE_LERC_TRUE='#' + HAVE_LERC_FALSE= +fi + + + HAVE_LZMA=no # Check whether --enable-lzma was given. @@ -21243,7 +21016,7 @@ fi -ac_config_headers="$ac_config_headers libtiff/tif_config.h libtiff/tiffconf.h" +ac_config_headers="$ac_config_headers config.h libtiff/tif_config.h libtiff/tiffconf.h port/libport_config.h" ac_config_files="$ac_config_files Makefile build/Makefile contrib/Makefile contrib/addtiffo/Makefile contrib/dbs/Makefile contrib/dbs/xtiff/Makefile contrib/iptcutil/Makefile contrib/mfs/Makefile contrib/pds/Makefile contrib/ras/Makefile contrib/stream/Makefile contrib/tags/Makefile contrib/win_dib/Makefile html/Makefile html/images/Makefile html/man/Makefile libtiff-4.pc libtiff/Makefile man/Makefile port/Makefile test/Makefile tools/Makefile" @@ -21406,6 +21179,10 @@ if test -z "${HAVE_JBIG_TRUE}" && test -z "${HAVE_JBIG_FALSE}"; then as_fn_error $? "conditional \"HAVE_JBIG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_LERC_TRUE}" && test -z "${HAVE_LERC_FALSE}"; then + as_fn_error $? "conditional \"HAVE_LERC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${HAVE_LZMA_TRUE}" && test -z "${HAVE_LZMA_FALSE}"; then as_fn_error $? "conditional \"HAVE_LZMA\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -21827,7 +21604,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by LibTIFF Software $as_me 4.2.0, which was +This file was extended by LibTIFF Software $as_me 4.3.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21893,7 +21670,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -LibTIFF Software config.status 4.2.0 +LibTIFF Software config.status 4.3.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -22407,8 +22184,10 @@ do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "libtiff/tif_config.h") CONFIG_HEADERS="$CONFIG_HEADERS libtiff/tif_config.h" ;; "libtiff/tiffconf.h") CONFIG_HEADERS="$CONFIG_HEADERS libtiff/tiffconf.h" ;; + "port/libport_config.h") CONFIG_HEADERS="$CONFIG_HEADERS port/libport_config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "build/Makefile") CONFIG_FILES="$CONFIG_FILES build/Makefile" ;; "contrib/Makefile") CONFIG_FILES="$CONFIG_FILES contrib/Makefile" ;; @@ -23108,9 +22887,7 @@ $as_echo X/"$am_mf" | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. If GNU make was not used, consider - re-running the configure script with MAKE=\"gmake\" (or whatever is - necessary). You can also try re-running configure with the + for automatic dependency tracking. Try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } @@ -23137,7 +22914,6 @@ See \`config.log' for more details" "$LINENO" 5; } cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. @@ -23885,7 +23661,7 @@ echo " C++ compiler: ${CXX} ${CXXFLAGS}" echo " Enable runtime linker paths: ${HAVE_RPATH}" echo " Enable linker symbol versioning: ${have_ld_version_script}" echo " Support Microsoft Document Imaging: ${HAVE_MDI}" -echo " Use win32 IO: ${win32_io_ok}" +echo " Use Win32 IO: ${win32_io_ok}" echo "" echo " Support for internal codecs:" echo " CCITT Group 3 & 4 algorithms: ${HAVE_CCITT}" @@ -23903,6 +23679,7 @@ echo " JPEG support: ${HAVE_JPEG}" echo " Old JPEG support: ${HAVE_OJPEG}" echo " JPEG 8/12 bit dual mode: ${HAVE_JPEG12}" echo " ISO JBIG support: ${HAVE_JBIG}" +echo " LERC support: ${HAVE_LERC}" echo " LZMA2 support: ${HAVE_LZMA}" echo " ZSTD support: ${HAVE_ZSTD}" echo " WEBP support: ${HAVE_WEBP}" diff --git a/tiff/configure.ac b/tiff/configure.ac index a2242330..acde12bf 100644 --- a/tiff/configure.ac +++ b/tiff/configure.ac @@ -25,7 +25,7 @@ dnl OF THIS SOFTWARE. dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.64) -AC_INIT([LibTIFF Software],[4.2.0],[tiff@lists.maptools.org],[tiff]) +AC_INIT([LibTIFF Software],[4.3.0],[tiff@lists.maptools.org],[tiff]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(m4) AC_LANG(C) @@ -40,7 +40,7 @@ AM_MAINTAINER_MODE dnl Versioning. dnl Don't fill the ALPHA_VERSION field, if not applicable. LIBTIFF_MAJOR_VERSION=4 -LIBTIFF_MINOR_VERSION=2 +LIBTIFF_MINOR_VERSION=3 LIBTIFF_MICRO_VERSION=0 LIBTIFF_ALPHA_VERSION= LIBTIFF_VERSION=$LIBTIFF_MAJOR_VERSION.$LIBTIFF_MINOR_VERSION.$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION @@ -76,9 +76,9 @@ dnl 5. If any interfaces have been added since the last public release, then dnl increment age. dnl 6. If any interfaces have been removed since the last public release, dnl then set age to 0. -LIBTIFF_CURRENT=11 +LIBTIFF_CURRENT=12 LIBTIFF_REVISION=0 -LIBTIFF_AGE=6 +LIBTIFF_AGE=7 LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE # This is a special hack for OpenBSD and MirOS systems. The dynamic linker @@ -103,7 +103,7 @@ AC_SUBST(LIBTIFF_VERSION_INFO) AC_SUBST(LIBTIFF_RELEASE_DATE) dnl Checks for programs. -AC_PROG_CC +AC_PROG_CC_C99 AM_PROG_CC_C_O dnl We want warnings. As many warnings as possible. @@ -178,7 +178,6 @@ AC_CHECK_HEADERS([assert.h fcntl.h io.h search.h unistd.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST -AC_C_INLINE AC_C_BIGENDIAN AC_TYPE_OFF_T AC_TYPE_SIZE_T @@ -193,231 +192,55 @@ dnl Check if optarg (and presumably related externs) already declared in headers AC_CHECK_DECLS([optarg]) dnl --------------------------------------------------------------------------- -dnl Compute sized types for current CPU and compiler options +dnl Deprecated features and backward compatibilty dnl --------------------------------------------------------------------------- -# Obtain size of an 'signed int' and define as SIZEOF_SIGNED_INT -AC_CHECK_SIZEOF(signed int) - -# Obtain size of an 'unsigned int' and define as SIZEOF_UNSIGNED_INT -AC_CHECK_SIZEOF(unsigned int) - -# Obtain size of a 'signed long' and define as SIZEOF_SIGNED_LONG -AC_CHECK_SIZEOF(signed long) - -# Obtain size of a 'unsigned long' and define as SIZEOF_UNSIGNED_LONG -AC_CHECK_SIZEOF(unsigned long) +# Disable deprecated features to ensure clean build +CPPFLAGS="-DTIFF_DISABLE_DEPRECATED $CPPFLAGS" -# Obtain size of a 'long long' and define as SIZEOF_SIGNED_LONG_LONG. -# If 'long long' is not supported then the value defined is zero. -AC_CHECK_SIZEOF(signed long long) - -# Obtain size of a 'unsigned long long' and define as -# SIZEOF_UNSIGNED_LONG_LONG. If 'unsigned long long' is not -# supported then the value defined is zero. -AC_CHECK_SIZEOF(unsigned long long) - -# Obtain the size of an 'unsigned char *' and define as -# SIZEOF_UNSIGNED_CHAR_P. Result is available in -# ac_cv_sizeof_unsigned_char_p. -AC_CHECK_SIZEOF(unsigned char *) +dnl --------------------------------------------------------------------------- +dnl Compute sized types for current CPU and compiler options +dnl --------------------------------------------------------------------------- # Obtain the size of 'size_t' and define as SIZEOF_SIZE_T. Result is # available in ac_cv_sizeof_size_t AC_CHECK_SIZEOF([size_t]) -AC_MSG_CHECKING(for signed 8-bit type) -INT8_T='signed char' -AC_MSG_RESULT($INT8_T) -AC_DEFINE_UNQUOTED(TIFF_INT8_T,$INT8_T,[Signed 8-bit type]) -AC_MSG_CHECKING(for unsigned 8-bit type) -UINT8_T='unsigned char' -AC_MSG_RESULT($UINT8_T) -AC_DEFINE_UNQUOTED(TIFF_UINT8_T,$UINT8_T,[Unsigned 8-bit type]) +# C99 fixed-size integer types +INT8_T='int8_t' +UINT8_T='uint8_t' -AC_MSG_CHECKING(for signed 16-bit type) -INT16_T='signed short' -AC_MSG_RESULT($INT16_T) -AC_DEFINE_UNQUOTED(TIFF_INT16_T,$INT16_T,[Signed 16-bit type]) +INT16_T='int16_t' +UINT16_T='uint16_t' +INT32_T='int32_t' +UINT32_T='uint32_t' -AC_MSG_CHECKING(for unsigned 16-bit type) -UINT16_T='unsigned short' -AC_MSG_RESULT($UINT16_T) -AC_DEFINE_UNQUOTED(TIFF_UINT16_T,$UINT16_T,[Unsigned 16-bit type]) +INT64_T='int64_t' +UINT64_T='uint64_t' -AC_MSG_CHECKING(for signed 32-bit type) -INT32_T='none' -INT32_FORMAT='none' -if test $ac_cv_sizeof_signed_int -eq 4 -then - INT32_T='signed int' - INT32_FORMAT='"%d"' -elif test $ac_cv_sizeof_signed_long -eq 4 -then - INT32_T='signed long' - INT32_FORMAT='"%ld"' -fi -AC_MSG_RESULT($INT32_T) -AC_DEFINE_UNQUOTED(TIFF_INT32_T,$INT32_T,[Signed 32-bit type]) -AC_DEFINE_UNQUOTED(TIFF_INT32_FORMAT,$INT32_FORMAT,[Signed 32-bit type formatter]) - -AC_MSG_CHECKING(for unsigned 32-bit type) -UINT32_T='none' -UINT32_FORMAT='none' -if test $ac_cv_sizeof_unsigned_int -eq 4 +if test $ac_cv_sizeof_size_t -eq 4 then - UINT32_T='unsigned int' - UINT32_FORMAT='"%u"' -elif test $ac_cv_sizeof_unsigned_long -eq 4 + SSIZE_T='int32_t' +elif test $ac_cv_sizeof_size_t -eq 8 then - UINT32_T='unsigned long' - UINT32_FORMAT='"%lu"' -fi -AC_MSG_RESULT($UINT32_T) -AC_DEFINE_UNQUOTED(TIFF_UINT32_T,$UINT32_T,[Unsigned 32-bit type]) -AC_DEFINE_UNQUOTED(TIFF_UINT32_FORMAT,$UINT32_FORMAT,[Unsigned 32-bit type formatter]) - -AC_MSG_CHECKING(for signed 64-bit type) -INT64_T='none' -INT64_FORMAT='none' -if test $ac_cv_sizeof_signed_long -eq 8 -then - INT64_T='signed long' - INT64_FORMAT='"%ld"' -elif test $ac_cv_sizeof_signed_long_long -eq 8 -then - INT64_T='signed long long' - case "${host_os}" in - mingw32*) - # MinGW32 understands 'long long', but uses printf from WIN32 CRT - INT64_FORMAT='"%I64d"' - ;; - *) - INT64_FORMAT='"%lld"' - ;; - esac + SSIZE_T='int64_t' +else + AC_MSG_ERROR([Unsupported size_t size ${ac_cv_sizeof_size_t}; please add support]) fi -AC_MSG_RESULT($INT64_T) -AC_DEFINE_UNQUOTED(TIFF_INT64_T,$INT64_T,[Signed 64-bit type]) -AC_DEFINE_UNQUOTED(TIFF_INT64_FORMAT,$INT64_FORMAT,[Signed 64-bit type formatter]) - -AC_MSG_CHECKING(for unsigned 64-bit type) -UINT64_T='none' -UINT64_FORMAT='none' -if test $ac_cv_sizeof_unsigned_long -eq 8 -then - UINT64_T='unsigned long' - UINT64_FORMAT='"%lu"' -elif test $ac_cv_sizeof_unsigned_long_long -eq 8 -then - UINT64_T='unsigned long long' - case "${host_os}" in - mingw32*) - # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT - UINT64_FORMAT='"%I64u"' - ;; - *) - UINT64_FORMAT='"%llu"' - ;; - esac -fi -AC_MSG_RESULT($UINT64_T) -AC_DEFINE_UNQUOTED(TIFF_UINT64_T,$UINT64_T,[Unsigned 64-bit type]) -AC_DEFINE_UNQUOTED(TIFF_UINT64_FORMAT,$UINT64_FORMAT,[Unsigned 64-bit type formatter]) - -# Determine formatting specifier for 'size_t'. While the size should -# be precise, the type determined may not match the system definition. -# A named type is provided to allow casting to the type we determined -# without changing the actual size. -AC_MSG_CHECKING([for 'size_t' format specifier]) -SIZE_T='unknown' -SIZE_FORMAT='unknown' -if test $ac_cv_sizeof_unsigned_int -eq $ac_cv_sizeof_size_t -then - SIZE_T='unsigned int' - SIZE_FORMAT='"%u"' -elif test $ac_cv_sizeof_unsigned_long -eq $ac_cv_sizeof_size_t -then - SIZE_T='unsigned long' - SIZE_FORMAT='"%lu"' -elif test $ac_cv_sizeof_unsigned_long_long -eq $ac_cv_sizeof_size_t -then - SIZE_T='unsigned long long' - case "${host_os}" in - mingw32*) - # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT - SIZE_FORMAT='"%I64u"' - ;; - *) - SIZE_FORMAT='"%llu"' - ;; - esac -fi -AC_MSG_RESULT([$SIZE_FORMAT]) -AC_DEFINE_UNQUOTED([TIFF_SIZE_T],[$SIZE_T],[Unsigned size type]) -AC_DEFINE_UNQUOTED([TIFF_SIZE_FORMAT],[$SIZE_FORMAT],[Size type formatter]) - # Determine TIFF equivalent of ssize_t AC_MSG_CHECKING(for signed size type) -SSIZE_T='unknown' -SSIZE_FORMAT='unknown' -if test $ac_cv_sizeof_signed_int -eq $ac_cv_sizeof_size_t -then - SSIZE_T='signed int' - SSIZE_FORMAT='"%d"' -elif test $ac_cv_sizeof_signed_long -eq $ac_cv_sizeof_size_t -then - SSIZE_T='signed long' - SSIZE_FORMAT='"%ld"' -elif test $ac_cv_sizeof_signed_long_long -eq $ac_cv_sizeof_size_t -then - SSIZE_T='signed long long' - case "${host_os}" in - mingw32*) - # MinGW32 understands 'long long', but uses printf from WIN32 CRT - SSIZE_FORMAT='"%I64d"' - ;; - *) - SSIZE_FORMAT='"%lld"' - ;; - esac -fi AC_MSG_RESULT($SSIZE_T) AC_DEFINE_UNQUOTED(TIFF_SSIZE_T,$SSIZE_T,[Signed size type]) -AC_DEFINE_UNQUOTED(TIFF_SSIZE_FORMAT,$SSIZE_FORMAT,[Signed size type formatter]) - -# Determine the type to use for the difference between two pointers. -# We will default to the POSIX ptrdiff_t if it is available, but will -# be prepared for the case when it is not. -PTRDIFF_T='unknown' -PTRDIFF_FORMAT='"%ld"' -AC_CHECK_TYPE(ptrdiff_t,[PTRDIFF_T=ptrdiff_t]) -if test $PTRDIFF_T = unknown -then - PTRDIFF_T=$SSIZE_T - PTRDIFF_FORMAT=$SSIZE_FORMAT -fi -AC_MSG_CHECKING(for pointer difference type) -AC_MSG_RESULT($PTRDIFF_T) -AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_T,$PTRDIFF_T,[Pointer difference type]) -AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_FORMAT,$PTRDIFF_FORMAT,[Pointer difference type formatter]) dnl Checks for library functions. -AC_CHECK_FUNCS([mmap setmode snprintf]) +AC_CHECK_FUNCS([mmap setmode]) dnl Will use local replacements for unavailable functions AC_REPLACE_FUNCS(getopt) -AC_REPLACE_FUNCS(snprintf) -AC_REPLACE_FUNCS(strcasecmp) -AC_REPLACE_FUNCS(strtol) -AC_REPLACE_FUNCS(strtoll) -AC_REPLACE_FUNCS(strtoul) -AC_REPLACE_FUNCS(strtoull) -AC_REPLACE_FUNCS(lfind) dnl --------------------------------------------------------------------------- dnl Check the native cpu bit order. @@ -456,7 +279,7 @@ dnl Set the floating point format. dnl FIXME: write appropriate test. dnl --------------------------------------------------------------------------- HAVE_IEEEFP=1 -AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format suported by the machine]) +AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format supported by the machine]) dnl --------------------------------------------------------------------------- dnl Enable run-time paths to libraries usage. @@ -489,6 +312,8 @@ fi AC_SUBST(LIBTIFF_DOCDIR) + + dnl --------------------------------------------------------------------------- dnl Switch on/off internal codecs. dnl --------------------------------------------------------------------------- @@ -817,6 +642,65 @@ fi AM_CONDITIONAL(HAVE_JBIG, test "$HAVE_JBIG" = 'yes') dnl --------------------------------------------------------------------------- +dnl Check for liblerc. +dnl --------------------------------------------------------------------------- + +HAVE_LERC=no + +AC_ARG_ENABLE(lerc, + AS_HELP_STRING([--disable-lerc], + [disable liblerc usage (required for lerc compression, enabled by default)]),,) +AC_ARG_WITH(lerc-include-dir, + AS_HELP_STRING([--with-lerc-include-dir=DIR], + [location of liblerc headers]),,) +AC_ARG_WITH(lerc-lib-dir, + AS_HELP_STRING([--with-lerc-lib-dir=DIR], + [location of liblerc library binary]),,) + +if test "x$enable_lerc" != "xno" ; then + + if test "x$with_lerc_lib_dir" != "x" ; then + LDFLAGS="-L$with_lerc_lib_dir $LDFLAGS" + fi + + lerc_lib_name="LercLib" + AC_CHECK_LIB("$lerc_lib_name", lerc_decode, [lerc_lib=yes], [lerc_lib=no],) + if test "$lerc_lib" = "no" ; then + lerc_lib_name="Lerc" + AC_CHECK_LIB("$lerc_lib_name", lerc_decode, [lerc_lib=yes], [lerc_lib=no],) + fi + if test "$lerc_lib" = "no" -a "x$with_lerc_lib_dir" != "x"; then + AC_MSG_ERROR([lerc library not found at $with_lerc_lib_dir]) + fi + + if test "x$with_lerc_include_dir" != "x" ; then + CPPFLAGS="-I$with_lerc_include_dir $CPPFLAGS" + fi + AC_CHECK_HEADER(Lerc_c_api.h, [lerc_c_api_h=yes], [lerc_c_api_h=no]) + if test "$lerc_c_api_h" = "no" -a "x$with_lerc_include_dir" != "x" ; then + AC_MSG_ERROR([Liblerc headers not found at $with_lerc_include_dir]) + fi + + if test "$lerc_lib" = "yes" -a "$lerc_c_api_h" = "yes" ; then + HAVE_LERC=yes + fi + +fi + +if test "$HAVE_LERC" = "yes" ; then + AC_DEFINE(LERC_SUPPORT,1,[Support lerc compression]) + LIBS="-l${lerc_lib_name} $LIBS" + tiff_libs_private="-l${lerc_lib_name} ${tiff_libs_private}" + + if test "$HAVE_RPATH" = "yes" -a "x$with_lerc_lib_dir" != "x" ; then + LIBDIR="-R $with_lerc_lib_dir $LIBDIR" + fi + +fi + +AM_CONDITIONAL(HAVE_LERC, test "$HAVE_LERC" = 'yes') + +dnl --------------------------------------------------------------------------- dnl Check for liblzma2. dnl --------------------------------------------------------------------------- @@ -1106,7 +990,7 @@ dnl --------------------------------------------------------------------------- AC_ARG_ENABLE(strip-chopping, AS_HELP_STRING([--disable-strip-chopping], - [disable support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)]), + [disable support for strip chopping (whether or not to convert single-strip uncompressed images to multiple strips of specified size to reduce memory usage)]), [HAVE_STRIPCHOP=$enableval], [HAVE_STRIPCHOP=yes]) AC_ARG_WITH(default-strip-size, AS_HELP_STRING([--with-default-strip-size=SIZE], @@ -1114,7 +998,7 @@ AC_ARG_WITH(default-strip-size, if test "$HAVE_STRIPCHOP" = "yes" \ -a "x$with_default_strip_size" != "xno"; then - AC_DEFINE(STRIPCHOP_DEFAULT,TIFF_STRIPCHOP,[Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)]) + AC_DEFINE(STRIPCHOP_DEFAULT,TIFF_STRIPCHOP,[Support strip chopping (whether or not to convert single-strip uncompressed images to multiple strips of specified size to reduce memory usage)]) if test "x$with_default_strip_size" = "x" \ -o "x$with_default_strip_size" = "xyes"; then @@ -1196,7 +1080,7 @@ dnl --------------------------------------------------------------------------- AC_SUBST(LIBDIR) -AC_CONFIG_HEADERS([libtiff/tif_config.h libtiff/tiffconf.h]) +AC_CONFIG_HEADERS([config.h libtiff/tif_config.h libtiff/tiffconf.h port/libport_config.h]) AC_CONFIG_FILES([Makefile \ build/Makefile \ @@ -1236,7 +1120,7 @@ LOC_MSG([ C++ compiler: ${CXX} ${CXXFLAGS}]) LOC_MSG([ Enable runtime linker paths: ${HAVE_RPATH}]) LOC_MSG([ Enable linker symbol versioning: ${have_ld_version_script}]) LOC_MSG([ Support Microsoft Document Imaging: ${HAVE_MDI}]) -LOC_MSG([ Use win32 IO: ${win32_io_ok}]) +LOC_MSG([ Use Win32 IO: ${win32_io_ok}]) LOC_MSG() LOC_MSG([ Support for internal codecs:]) LOC_MSG([ CCITT Group 3 & 4 algorithms: ${HAVE_CCITT}]) @@ -1254,6 +1138,7 @@ LOC_MSG([ JPEG support: ${HAVE_JPEG}]) LOC_MSG([ Old JPEG support: ${HAVE_OJPEG}]) LOC_MSG([ JPEG 8/12 bit dual mode: ${HAVE_JPEG12}]) LOC_MSG([ ISO JBIG support: ${HAVE_JBIG}]) +LOC_MSG([ LERC support: ${HAVE_LERC}]) LOC_MSG([ LZMA2 support: ${HAVE_LZMA}]) LOC_MSG([ ZSTD support: ${HAVE_ZSTD}]) LOC_MSG([ WEBP support: ${HAVE_WEBP}]) diff --git a/tiff/configure.com b/tiff/configure.com deleted file mode 100644 index a3064425..00000000 --- a/tiff/configure.com +++ /dev/null @@ -1,1356 +0,0 @@ -$! -$! OpenVMS configure procedure for libtiff -$! (c) Alexey Chupahin 22-NOV-2007 -$! elvis_75@mail.ru -$! -$! Permission to use, copy, modify, distribute, and sell this software and -$! its documentation for any purpose is hereby granted without fee, provided -$! that (i) the above copyright notices and this permission notice appear in -$! all copies of the software and related documentation, and (ii) the names of -$! Sam Leffler and Silicon Graphics may not be used in any advertising or -$! publicity relating to the software without the specific, prior written -$! permission of Sam Leffler and Silicon Graphics. -$! -$! THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -$! EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -$! WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -$! -$! IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -$! ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -$! OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -$! WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -$! LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -$! OF THIS SOFTWARE. -$! -$! -$ SET NOON -$WRITE SYS$OUTPUT " " -$WRITE SYS$OUTPUT "Configuring libTIFF library" -$WRITE SYS$OUTPUT " " -$! Checking architecture -$DECC = F$SEARCH("SYS$SYSTEM:DECC$COMPILER.EXE") .NES. "" -$IF (.NOT. DECC) THEN $WRITE SYS$OUTPUT "BAD compiler" GOTO EXIT -$ IF F$GETSYI("ARCH_TYPE").EQ.1 THEN CPU = "VAX" -$ IF F$GETSYI("ARCH_TYPE").EQ.2 THEN CPU = "Alpha" -$ IF F$GETSYI("ARCH_TYPE").EQ.3 THEN CPU = "I64" -$ OS = F$GETSYI("VERSION") -$WRITE SYS$OUTPUT "Checking architecture ... ", CPU -$WRITE SYS$OUTPUT "Checking OS ... OpenVMS ",OS -$SHARED=0 -$IF ( (CPU.EQS."Alpha").OR.(CPU.EQS."I64") ) -$ THEN -$ SHARED=64 -$ ELSE -$ SHARED=32 -$ENDIF -$MMS = F$SEARCH("SYS$SYSTEM:MMS.EXE") .NES. "" -$MMK = F$TYPE(MMK) -$IF (MMS .OR. MMK.NES."") THEN GOTO TEST_LIBRARIES -$! I cant find any make tool -$GOTO EXIT -$! -$! -$TEST_LIBRARIES: -$! Setting as MAKE utility one of MMS or MMK. I prefer MMS. -$IF (MMK.NES."") THEN MAKE="MMK" -$IF (MMS) THEN MAKE="MMS" -$WRITE SYS$OUTPUT "Checking build utility ... ''MAKE'" -$WRITE SYS$OUTPUT " " -$! -$! -$IF (P1.EQS."STATIC").OR.(P1.EQS."static") THEN SHARED=0 -$! -$! -$!"Checking for strcasecmp " -$ DEFINE SYS$ERROR _NLA0: -$ DEFINE SYS$OUTPUT _NLA0: -$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT - #include <strings.h> - #include <stdlib.h> - - int main() - { - if (strcasecmp("bla", "Bla")==0) exit(0); - else exit(2); - } -$! -$TMP = $STATUS -$DEASS SYS$ERROR -$DEAS SYS$OUTPUT -$IF (TMP .NE. %X10B90001) -$ THEN -$ HAVE_STRCASECMP=0 -$ GOTO NEXT1 -$ENDIF -$DEFINE SYS$ERROR _NLA0: -$DEFINE SYS$OUTPUT _NLA0: -$LINK/EXE=TEST TEST -$TMP = $STATUS -$DEAS SYS$ERROR -$DEAS SYS$OUTPUT -$!WRITE SYS$OUTPUT TMP -$IF (TMP .NE. %X10000001) -$ THEN -$ HAVE_STRCASECMP=0 -$ GOTO NEXT1 -$ENDIF -$! -$DEFINE SYS$ERROR _NLA0: -$DEFINE SYS$OUTPUT _NLA0: -$RUN TEST -$IF ($STATUS .NE. %X00000001) -$ THEN -$ HAVE_STRCASECMP=0 -$ ELSE -$ HAVE_STRCASECMP=1 -$ENDIF -$DEAS SYS$ERROR -$DEAS SYS$OUTPUT -$NEXT1: -$IF (HAVE_STRCASECMP.EQ.1) -$ THEN -$ WRITE SYS$OUTPUT "Checking for strcasecmp ... Yes" -$ ELSE -$ WRITE SYS$OUTPUT "Checking for strcasecmp ... No" -$ENDIF -$! -$! - -$!"Checking for lfind " -$ DEFINE SYS$ERROR _NLA0: -$ DEFINE SYS$OUTPUT _NLA0: -$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT - #include <search.h> - - int main() - { - lfind((const void *)key, (const void *)NULL, (size_t *)NULL, - (size_t) 0, NULL); - } -$! -$TMP = $STATUS -$DEASS SYS$ERROR -$DEAS SYS$OUTPUT -$IF (TMP .NE. %X10B90001) -$ THEN -$ HAVE_LFIND=0 -$ GOTO NEXT2 -$ENDIF -$DEFINE SYS$ERROR _NLA0: -$DEFINE SYS$OUTPUT _NLA0: -$LINK/EXE=TEST TEST -$TMP = $STATUS -$DEAS SYS$ERROR -$DEAS SYS$OUTPUT -$!WRITE SYS$OUTPUT TMP -$IF (TMP .NE. %X10000001) -$ THEN -$ HAVE_LFIND=0 -$ GOTO NEXT2 -$ ELSE -$ HAVE_LFIND=1 -$ENDIF -$! -$NEXT2: -$IF (HAVE_LFIND.EQ.1) -$ THEN -$ WRITE SYS$OUTPUT "Checking for lfind ... Yes" -$ ELSE -$ WRITE SYS$OUTPUT "Checking for lfind ... No" -$ENDIF -$! -$! -$!"Checking for correct zlib library " -$ DEFINE SYS$ERROR _NLA0: -$ DEFINE SYS$OUTPUT _NLA0: -$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT - #include <stdlib.h> - #include <stdio.h> - #include <zlib.h> - int main() - { - printf("checking version zlib: %s\n",zlibVersion()); - } -$TMP = $STATUS -$DEASS SYS$ERROR -$DEAS SYS$OUTPUT -$!WRITE SYS$OUTPUT TMP -$IF (TMP .NE. %X10B90001) -$ THEN -$ HAVE_ZLIB=0 -$ GOTO EXIT -$ENDIF -$DEFINE SYS$ERROR _NLA0: -$DEFINE SYS$OUTPUT _NLA0: -$LINK/EXE=TEST TEST,ZLIB:LIBZ/LIB -$TMP = $STATUS -$DEAS SYS$ERROR -$DEAS SYS$OUTPUT -$!WRITE SYS$OUTPUT TMP -$IF (TMP .NE. %X10000001) -$ THEN -$ HAVE_ZLIB=0 -$ GOTO EXIT -$ ELSE -$ HAVE_ZLIB=1 -$ENDIF -$IF (HAVE_ZLIB.EQ.1) -$ THEN -$ WRITE SYS$OUTPUT "Checking for correct zlib library ... Yes" -$ ELSE -$ WRITE SYS$OUTPUT "Checking for correct zlib library ... No" -$ WRITE SYS$OUTPUT "This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html" -$ENDIF -$RUN TEST -$! - -$DEL TEST.OBJ;* -$! Checking for JPEG ... -$ DEFINE SYS$ERROR _NLA0: -$ DEFINE SYS$OUTPUT _NLA0: -$ CC/OBJECT=TEST.OBJ/INCLUDE=(JPEG) SYS$INPUT - #include <stdlib.h> - #include <stdio.h> - #include <jpeglib.h> - #include <jversion.h> - int main() - { - printf("checking version jpeg: %s\n",JVERSION); - jpeg_quality_scaling(0); - return 0; - } -$TMP = $STATUS -$DEASS SYS$ERROR -$DEAS SYS$OUTPUT -$!WRITE SYS$OUTPUT TMP -$IF (TMP .NE. %X10B90001) -$ THEN -$ WRITE SYS$OUTPUT "Checking for static jpeg library ... No" -$ HAVE_JPEG=0 -$ENDIF -$DEFINE SYS$ERROR _NLA0: -$DEFINE SYS$OUTPUT _NLA0: -$LINK/EXE=TEST TEST,JPEG:LIBJPEG/LIB -$TMP = $STATUS -$DEAS SYS$ERROR -$DEAS SYS$OUTPUT -$!WRITE SYS$OUTPUT TMP -$IF (TMP .NE. %X10000001) -$ THEN -$ HAVE_JPEG=0 -$ ELSE -$ HAVE_JPEG=1 -$ENDIF -$IF (HAVE_JPEG.EQ.1) -$ THEN -$ WRITE SYS$OUTPUT "Checking for static jpeg library ... Yes" -$ JPEG_LIBRARY_PATH="JPEG:LIBJPEG/LIB" -$ RUN TEST -$ ELSE -$ WRITE SYS$OUTPUT "Checking for static jpeg library ... No" -$ENDIF -$! -$!"Checking for SHARED JPEG library " -$OPEN/WRITE OUT TEST.OPT -$WRITE OUT "SYS$SHARE:LIBJPEG$SHR/SHARE" -$WRITE OUT "ZLIB:LIBZ/LIB" -$CLOSE OUT -$DEFINE SYS$ERROR _NLA0: -$DEFINE SYS$OUTPUT _NLA0: -$LINK/EXE=TEST TEST,TEST/OPT -$TMP = $STATUS -$DEAS SYS$ERROR -$DEAS SYS$OUTPUT -$!WRITE SYS$OUTPUT TMP -$IF (TMP .NE. %X10000001) -$ THEN -$ HAVE_JPEG_SHARED=0 -$ ELSE -$ HAVE_JPEG_SHARED=1 -$ENDIF -$IF (HAVE_JPEG_SHARED.EQ.1) -$ THEN -$ WRITE SYS$OUTPUT "Checking for shared jpeg library ... Yes" -$ JPEG_LIBRARY_PATH="SYS$SHARE:LIBJPEG$SHR/SHARE" -$ ELSE -$ WRITE SYS$OUTPUT "Checking for shared jpeg library ... No" -$ENDIF -$! -$ IF ( (HAVE_JPEG_SHARED.EQ.0).AND.(HAVE_JPEG.EQ.0) ) -$ THEN -$ WRITE SYS$OUTPUT "No JPEG library installed. This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html" -$ GOTO EXIT -$ ENDIF -$! -$! -$! -$! Checking for X11 ... -$IF F$TRNLNM("DECW$INCLUDE") .NES. "" -$ THEN -$ WRITE SYS$OUTPUT "Checking for X11 ... Yes" -$ ELSE -$ WRITE SYS$OUTPUT "Checking for X11 ... No" -$ WRITE SYS$OUTPUT "This is fatal. Please install X11 software" -$ GOTO EXIT -$ENDIF -$! -$!WRITING BUILD FILES -$OPEN/WRITE OUT BUILD.COM -$ WRITE OUT "$set def [.port]" -$ WRITE OUT "$",MAKE -$ WRITE OUT "$set def [-.libtiff]" -$ WRITE OUT "$",MAKE -$ WRITE OUT "$set def [-.tools]" -$ WRITE OUT "$",MAKE -$ WRITE OUT "$set def [-]" -$ WRITE OUT "$cop [.PORT]LIBPORT.OLB [.LIBTIFF]LIBPORT.OLB" -$ WRITE OUT "$ CURRENT = F$ENVIRONMENT (""DEFAULT"") " -$ WRITE OUT "$TIFF=CURRENT" -$ WRITE OUT "$OPEN/WRITE OUTT LIBTIFF$STARTUP.COM" -$ WRITE OUT "$TIFF[F$LOCATE(""]"",TIFF),9]:="".LIBTIFF]""" -$ WRITE OUT "$WRITE OUTT ""DEFINE TIFF ","'","'","TIFF'"" " -$ WRITE OUT "$TIFF=CURRENT" -$ WRITE OUT "$TIFF[F$LOCATE(""]"",TIFF),7]:="".TOOLS]""" -$ WRITE OUT "$WRITE OUTT ""BMP2TIFF:==$", "'","'","TIFF'BMP2TIFF""" -$ WRITE OUT "$WRITE OUTT ""FAX2PS:==$", "'","'","TIFF'FAX2PS""" -$ WRITE OUT "$WRITE OUTT ""FAX2TIFF:==$", "'","'","TIFF'FAX2TIFF""" -$ WRITE OUT "$WRITE OUTT ""GIF2TIFF:==$", "'","'","TIFF'GIF2TIFF""" -$ WRITE OUT "$WRITE OUTT ""PAL2RGB:==$", "'","'","TIFF'PAL2RGB""" -$ WRITE OUT "$WRITE OUTT ""PPM2TIFF:==$", "'","'","TIFF'PPM2TIFF""" -$ WRITE OUT "$WRITE OUTT ""RAS2TIFF:==$", "'","'","TIFF'RAS2TIFF""" -$ WRITE OUT "$WRITE OUTT ""RAW2TIFF:==$", "'","'","TIFF'RAW2TIFF""" -$ WRITE OUT "$WRITE OUTT ""RGB2YCBCR:==$", "'","'","TIFF'RGB2YCBCR""" -$ WRITE OUT "$WRITE OUTT ""THUMBNAIL:==$", "'","'","TIFF'THUMBNAIL""" -$ WRITE OUT "$WRITE OUTT ""TIFF2BW:==$", "'","'","TIFF'TIFF2BW""" -$ WRITE OUT "$WRITE OUTT ""TIFF2PDF:==$", "'","'","TIFF'TIFF2PDF""" -$ WRITE OUT "$WRITE OUTT ""TIFF2PS:==$", "'","'","TIFF'TIFF2PS""" -$ WRITE OUT "$WRITE OUTT ""TIFF2RGBA:==$", "'","'","TIFF'TIFF2RGBA""" -$ WRITE OUT "$WRITE OUTT ""TIFFCMP:==$", "'","'","TIFF'TIFFCMP""" -$ WRITE OUT "$WRITE OUTT ""TIFFCP:==$", "'","'","TIFF'TIFFCP""" -$ WRITE OUT "$WRITE OUTT ""TIFFDITHER:==$", "'","'","TIFF'TIFFDITHER""" -$ WRITE OUT "$WRITE OUTT ""TIFFDUMP:==$", "'","'","TIFF'TIFFDUMP""" -$ WRITE OUT "$WRITE OUTT ""TIFFINFO:==$", "'","'","TIFF'TIFFINFO""" -$ WRITE OUT "$WRITE OUTT ""TIFFMEDIAN:==$", "'","'","TIFF'TIFFMEDIAN""" -$ WRITE OUT "$WRITE OUTT ""TIFFCROP:==$", "'","'","TIFF'TIFFCROP""" -$ WRITE OUT "$WRITE OUTT ""TIFFSET:==$", "'","'","TIFF'TIFFSET""" -$ WRITE OUT "$CLOSE OUTT" -$ WRITE OUT "$OPEN/WRITE OUTT [.LIBTIFF]LIBTIFF.OPT" -$ WRITE OUT "$WRITE OUTT ""TIFF:TIFF/LIB"" -$ WRITE OUT "$WRITE OUTT ""TIFF:LIBPORT/LIB"" -$ WRITE OUT "$WRITE OUTT ""JPEG:LIBJPEG/LIB"" -$ WRITE OUT "$WRITE OUTT ""ZLIB:LIBZ/LIB"" -$ WRITE OUT "$CLOSE OUTT" -$! -$ WRITE OUT "$WRITE SYS$OUTPUT "" "" " -$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" " -$ WRITE OUT "$WRITE SYS$OUTPUT ""LIBTIFF$STARTUP.COM has been created. "" " -$ WRITE OUT "$WRITE SYS$OUTPUT ""This file setups all logicals needed. It should be execute before using LibTIFF "" " -$ WRITE OUT "$WRITE SYS$OUTPUT ""Nice place to call it - LOGIN.COM "" " -$ WRITE OUT "$WRITE SYS$OUTPUT """" " -$ WRITE OUT "$WRITE SYS$OUTPUT ""Using the library:"" " -$ WRITE OUT "$WRITE SYS$OUTPUT ""CC/INC=TIFF ASCII_TAG.C"" " -$ WRITE OUT "$WRITE SYS$OUTPUT ""LINK ASCII_TAG,TIFF:LIBTIFF/OPT"" " -$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" " -$CLOSE OUT -$! -$! DESCRIP.MMS in [.PORT] -$OBJ="dummy.obj" -$IF HAVE_STRCASECMP.NE.1 -$ THEN -$ OBJ=OBJ+",strcasecmp.obj" -$ENDIF -$IF HAVE_LFIND.NE.1 -$ THEN -$ OBJ=OBJ+",lfind.obj" -$ENDIF -$OPEN/WRITE OUT [.PORT]DESCRIP.MMS -$WRITE OUT "OBJ=",OBJ -$WRITE OUT "" -$WRITE OUT "LIBPORT.OLB : $(OBJ)" -$WRITE OUT " LIB/CREA LIBPORT $(OBJ)" -$WRITE OUT "" -$WRITE OUT "" -$WRITE OUT "dummy.obj : dummy.c" -$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" -$WRITE OUT "" -$WRITE OUT "" -$WRITE OUT "strcasecmp.obj : strcasecmp.c" -$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" -$WRITE OUT "" -$WRITE OUT "" -$WRITE OUT "lfind.obj : lfind.c" -$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" -$WRITE OUT "" -$WRITE OUT "" -$CLOSE OUT -$! -$! -$WRITE SYS$OUTPUT "Creating LIBTIFF$DEF.OPT" -$IF (SHARED.EQ.64) -$ THEN -$ COPY SYS$INPUT TIFF$DEF.OPT -SYMBOL_VECTOR= (- -TIFFOpen=PROCEDURE,- -TIFFGetVersion=PROCEDURE,- -TIFFCleanup=PROCEDURE,- -TIFFClose=PROCEDURE,- -TIFFFlush=PROCEDURE,- -TIFFFlushData=PROCEDURE,- -TIFFGetField=PROCEDURE,- -TIFFVGetField=PROCEDURE,- -TIFFGetFieldDefaulted=PROCEDURE,- -TIFFVGetFieldDefaulted=PROCEDURE,- -TIFFGetTagListEntry=PROCEDURE,- -TIFFGetTagListCount=PROCEDURE,- -TIFFReadDirectory=PROCEDURE,- -TIFFScanlineSize=PROCEDURE,- -TIFFStripSize=PROCEDURE,- -TIFFVStripSize=PROCEDURE,- -TIFFRawStripSize=PROCEDURE,- -TIFFTileRowSize=PROCEDURE,- -TIFFTileSize=PROCEDURE,- -TIFFVTileSize=PROCEDURE,- -TIFFFileno=PROCEDURE,- -TIFFSetFileno=PROCEDURE,- -TIFFGetMode=PROCEDURE,- -TIFFIsTiled=PROCEDURE,- -TIFFIsByteSwapped=PROCEDURE,- -TIFFIsBigEndian=PROCEDURE,- -TIFFIsMSB2LSB=PROCEDURE,- -TIFFIsUpSampled=PROCEDURE,- -TIFFCIELabToRGBInit=PROCEDURE,- -TIFFCIELabToXYZ=PROCEDURE,- -TIFFXYZToRGB=PROCEDURE,- -TIFFYCbCrToRGBInit=PROCEDURE,- -TIFFYCbCrtoRGB=PROCEDURE,- -TIFFCurrentRow=PROCEDURE,- -TIFFCurrentDirectory=PROCEDURE,- -TIFFCurrentStrip=PROCEDURE,- -TIFFCurrentTile=PROCEDURE,- -TIFFDataWidth=PROCEDURE,- -TIFFReadBufferSetup=PROCEDURE,- -TIFFWriteBufferSetup=PROCEDURE,- -TIFFSetupStrips=PROCEDURE,- -TIFFLastDirectory=PROCEDURE,- -TIFFSetDirectory=PROCEDURE,- -TIFFSetSubDirectory=PROCEDURE,- -TIFFUnlinkDirectory=PROCEDURE,- -TIFFSetField=PROCEDURE,- -TIFFVSetField=PROCEDURE,- -TIFFCheckpointDirectory=PROCEDURE,- -TIFFWriteDirectory=PROCEDURE,- -TIFFRewriteDirectory=PROCEDURE,- -TIFFPrintDirectory=PROCEDURE,- -TIFFReadScanline=PROCEDURE,- -TIFFWriteScanline=PROCEDURE,- -TIFFReadRGBAImage=PROCEDURE,- -TIFFReadRGBAImageOriented=PROCEDURE,- -TIFFFdOpen=PROCEDURE,- -TIFFClientOpen=PROCEDURE,- -TIFFFileName=PROCEDURE,- -TIFFError=PROCEDURE,- -TIFFErrorExt=PROCEDURE,- -TIFFWarning=PROCEDURE,- -TIFFWarningExt=PROCEDURE,- -TIFFSetErrorHandler=PROCEDURE,- -TIFFSetErrorHandlerExt=PROCEDURE,- -TIFFSetWarningHandler=PROCEDURE,- -TIFFSetWarningHandlerExt=PROCEDURE,- -TIFFComputeTile=PROCEDURE,- -TIFFCheckTile=PROCEDURE,- -TIFFNumberOfTiles=PROCEDURE,- -TIFFReadTile=PROCEDURE,- -TIFFWriteTile=PROCEDURE,- -TIFFComputeStrip=PROCEDURE,- -TIFFNumberOfStrips=PROCEDURE,- -TIFFRGBAImageBegin=PROCEDURE,- -TIFFRGBAImageGet=PROCEDURE,- -TIFFRGBAImageEnd=PROCEDURE,- -TIFFReadEncodedStrip=PROCEDURE,- -TIFFReadRawStrip=PROCEDURE,- -TIFFReadEncodedTile=PROCEDURE,- -TIFFReadRawTile=PROCEDURE,- -TIFFReadRGBATile=PROCEDURE,- -TIFFReadRGBAStrip=PROCEDURE,- -TIFFWriteEncodedStrip=PROCEDURE,- -TIFFWriteRawStrip=PROCEDURE,- -TIFFWriteEncodedTile=PROCEDURE,- -TIFFWriteRawTile=PROCEDURE,- -TIFFSetWriteOffset=PROCEDURE,- -TIFFSwabDouble=PROCEDURE,- -TIFFSwabShort=PROCEDURE,- -TIFFSwabLong=PROCEDURE,- -TIFFSwabArrayOfShort=PROCEDURE,- -TIFFSwabArrayOfLong=PROCEDURE,- -TIFFSwabArrayOfDouble=PROCEDURE,- -TIFFSwabArrayOfTriples=PROCEDURE,- -TIFFReverseBits=PROCEDURE,- -TIFFGetBitRevTable=PROCEDURE,- -TIFFDefaultStripSize=PROCEDURE,- -TIFFDefaultTileSize=PROCEDURE,- -TIFFRasterScanlineSize=PROCEDURE,- -_TIFFmalloc=PROCEDURE,- -_TIFFrealloc=PROCEDURE,- -_TIFFfree=PROCEDURE,- -_TIFFmemset=PROCEDURE,- -_TIFFmemcpy=PROCEDURE,- -_TIFFmemcmp=PROCEDURE,- -TIFFCreateDirectory=PROCEDURE,- -TIFFSetTagExtender=PROCEDURE,- -TIFFMergeFieldInfo=PROCEDURE,- -TIFFFindFieldInfo=PROCEDURE,- -TIFFFindFieldInfoByName=PROCEDURE,- -TIFFFieldWithName=PROCEDURE,- -TIFFFieldWithTag=PROCEDURE,- -TIFFFieldTag=PROCEDURE,- -TIFFFieldName=PROCEDURE,- -TIFFFieldDataType=PROCEDURE,- -TIFFFieldPassCount=PROCEDURE,- -TIFFFieldReadCount=PROCEDURE,- -TIFFFieldWriteCount=PROCEDURE,- -TIFFCurrentDirOffset=PROCEDURE,- -TIFFWriteCheck=PROCEDURE,- -TIFFRGBAImageOK=PROCEDURE,- -TIFFNumberOfDirectories=PROCEDURE,- -TIFFSetFileName=PROCEDURE,- -TIFFSetClientdata=PROCEDURE,- -TIFFSetMode=PROCEDURE,- -TIFFClientdata=PROCEDURE,- -TIFFGetReadProc=PROCEDURE,- -TIFFGetWriteProc=PROCEDURE,- -TIFFGetSeekProc=PROCEDURE,- -TIFFGetCloseProc=PROCEDURE,- -TIFFGetSizeProc=PROCEDURE,- -TIFFGetMapFileProc=PROCEDURE,- -TIFFGetUnmapFileProc=PROCEDURE,- -TIFFIsCODECConfigured=PROCEDURE,- -TIFFGetConfiguredCODECs=PROCEDURE,- -TIFFFindCODEC=PROCEDURE,- -TIFFRegisterCODEC=PROCEDURE,- -TIFFUnRegisterCODEC=PROCEDURE,- -TIFFFreeDirectory=PROCEDURE,- -TIFFReadCustomDirectory=PROCEDURE,- -TIFFReadEXIFDirectory=PROCEDURE,- -TIFFAccessTagMethods=PROCEDURE,- -TIFFGetClientInfo=PROCEDURE,- -TIFFSetClientInfo=PROCEDURE,- -TIFFReassignTagToIgnore=PROCEDURE- -) - -$ENDIF -$IF (SHARED.EQ.32) -$ THEN -$ COPY SYS$INPUT TIFF$DEF.OPT -UNIVERSAL=TIFFOpen -UNIVERSAL=TIFFGetVersion -UNIVERSAL=TIFFCleanup -UNIVERSAL=TIFFClose -UNIVERSAL=TIFFFlush -UNIVERSAL=TIFFFlushData -UNIVERSAL=TIFFGetField -UNIVERSAL=TIFFVGetField -UNIVERSAL=TIFFGetFieldDefaulted -UNIVERSAL=TIFFVGetFieldDefaulted -UNIVERSAL=TIFFGetTagListEntry -UNIVERSAL=TIFFGetTagListCount -UNIVERSAL=TIFFReadDirectory -UNIVERSAL=TIFFScanlineSize -UNIVERSAL=TIFFStripSize -UNIVERSAL=TIFFVStripSize -UNIVERSAL=TIFFRawStripSize -UNIVERSAL=TIFFTileRowSize -UNIVERSAL=TIFFTileSize -UNIVERSAL=TIFFVTileSize -UNIVERSAL=TIFFFileno -UNIVERSAL=TIFFSetFileno -UNIVERSAL=TIFFGetMode -UNIVERSAL=TIFFIsTiled -UNIVERSAL=TIFFIsByteSwapped -UNIVERSAL=TIFFIsBigEndian -UNIVERSAL=TIFFIsMSB2LSB -UNIVERSAL=TIFFIsUpSampled -UNIVERSAL=TIFFCIELabToRGBInit -UNIVERSAL=TIFFCIELabToXYZ -UNIVERSAL=TIFFXYZToRGB -UNIVERSAL=TIFFYCbCrToRGBInit -UNIVERSAL=TIFFYCbCrtoRGB -UNIVERSAL=TIFFCurrentRow -UNIVERSAL=TIFFCurrentDirectory -UNIVERSAL=TIFFCurrentStrip -UNIVERSAL=TIFFCurrentTile -UNIVERSAL=TIFFDataWidth -UNIVERSAL=TIFFReadBufferSetup -UNIVERSAL=TIFFWriteBufferSetup -UNIVERSAL=TIFFSetupStrips -UNIVERSAL=TIFFLastDirectory -UNIVERSAL=TIFFSetDirectory -UNIVERSAL=TIFFSetSubDirectory -UNIVERSAL=TIFFUnlinkDirectory -UNIVERSAL=TIFFSetField -UNIVERSAL=TIFFVSetField -UNIVERSAL=TIFFCheckpointDirectory -UNIVERSAL=TIFFWriteDirectory -UNIVERSAL=TIFFRewriteDirectory -UNIVERSAL=TIFFPrintDirectory -UNIVERSAL=TIFFReadScanline -UNIVERSAL=TIFFWriteScanline -UNIVERSAL=TIFFReadRGBAImage -UNIVERSAL=TIFFReadRGBAImageOriented -UNIVERSAL=TIFFFdOpen -UNIVERSAL=TIFFClientOpen -UNIVERSAL=TIFFFileName -UNIVERSAL=TIFFError -UNIVERSAL=TIFFErrorExt -UNIVERSAL=TIFFWarning -UNIVERSAL=TIFFWarningExt -UNIVERSAL=TIFFSetErrorHandler -UNIVERSAL=TIFFSetErrorHandlerExt -UNIVERSAL=TIFFSetWarningHandler -UNIVERSAL=TIFFSetWarningHandlerExt -UNIVERSAL=TIFFComputeTile -UNIVERSAL=TIFFCheckTile -UNIVERSAL=TIFFNumberOfTiles -UNIVERSAL=TIFFReadTile -UNIVERSAL=TIFFWriteTile -UNIVERSAL=TIFFComputeStrip -UNIVERSAL=TIFFNumberOfStrips -UNIVERSAL=TIFFRGBAImageBegin -UNIVERSAL=TIFFRGBAImageGet -UNIVERSAL=TIFFRGBAImageEnd -UNIVERSAL=TIFFReadEncodedStrip -UNIVERSAL=TIFFReadRawStrip -UNIVERSAL=TIFFReadEncodedTile -UNIVERSAL=TIFFReadRawTile -UNIVERSAL=TIFFReadRGBATile -UNIVERSAL=TIFFReadRGBAStrip -UNIVERSAL=TIFFWriteEncodedStrip -UNIVERSAL=TIFFWriteRawStrip -UNIVERSAL=TIFFWriteEncodedTile -UNIVERSAL=TIFFWriteRawTile -UNIVERSAL=TIFFSetWriteOffset -UNIVERSAL=TIFFSwabDouble -UNIVERSAL=TIFFSwabShort -UNIVERSAL=TIFFSwabLong -UNIVERSAL=TIFFSwabArrayOfShort -UNIVERSAL=TIFFSwabArrayOfLong -UNIVERSAL=TIFFSwabArrayOfDouble -UNIVERSAL=TIFFSwabArrayOfTriples -UNIVERSAL=TIFFReverseBits -UNIVERSAL=TIFFGetBitRevTable -UNIVERSAL=TIFFDefaultStripSize -UNIVERSAL=TIFFDefaultTileSize -UNIVERSAL=TIFFRasterScanlineSize -UNIVERSAL=_TIFFmalloc -UNIVERSAL=_TIFFrealloc -UNIVERSAL=_TIFFfree -UNIVERSAL=_TIFFmemset -UNIVERSAL=_TIFFmemcpy -UNIVERSAL=_TIFFmemcmp -UNIVERSAL=TIFFCreateDirectory -UNIVERSAL=TIFFSetTagExtender -UNIVERSAL=TIFFMergeFieldInfo -UNIVERSAL=TIFFFindFieldInfo -UNIVERSAL=TIFFFindFieldInfoByName -UNIVERSAL=TIFFFieldWithName -UNIVERSAL=TIFFFieldWithTag -UNIVERSAL=TIFFFieldTag -UNIVERSAL=TIFFFieldName -UNIVERSAL=TIFFFieldDataType -UNIVERSAL=TIFFFieldPassCount -UNIVERSAL=TIFFFieldReadCount -UNIVERSAL=TIFFFieldWriteCount -UNIVERSAL=TIFFCurrentDirOffset -UNIVERSAL=TIFFWriteCheck -UNIVERSAL=TIFFRGBAImageOK -UNIVERSAL=TIFFNumberOfDirectories -UNIVERSAL=TIFFSetFileName -UNIVERSAL=TIFFSetClientdata -UNIVERSAL=TIFFSetMode -UNIVERSAL=TIFFClientdata -UNIVERSAL=TIFFGetReadProc -UNIVERSAL=TIFFGetWriteProc -UNIVERSAL=TIFFGetSeekProc -UNIVERSAL=TIFFGetCloseProc -UNIVERSAL=TIFFGetSizeProc -UNIVERSAL=TIFFGetMapFileProc -UNIVERSAL=TIFFGetUnmapFileProc -UNIVERSAL=TIFFIsCODECConfigured -UNIVERSAL=TIFFGetConfiguredCODECs -UNIVERSAL=TIFFFindCODEC -UNIVERSAL=TIFFRegisterCODEC -UNIVERSAL=TIFFUnRegisterCODEC -UNIVERSAL=TIFFFreeDirectory -UNIVERSAL=TIFFReadCustomDirectory -UNIVERSAL=TIFFReadEXIFDirectory -UNIVERSAL=TIFFAccessTagMethods -UNIVERSAL=TIFFGetClientInfo -UNIVERSAL=TIFFSetClientInfo -UNIVERSAL=TIFFReassignTagToIgnore - -$ENDIF -$! -$! -$! Writing TIFF$SHR.OPT file to build TOOLS -$ IF (SHARED.GT.0) -$ THEN -$ OPEN/WRITE OUT TIFF$SHR.OPT -$ WRITE OUT "[]TIFF/LIB" -$ WRITE OUT "[-.PORT]LIBPORT/LIB" -$ WRITE OUT JPEG_LIBRARY_PATH -$ WRITE OUT "ZLIB:LIBZ/LIB" -$ CLOSE OUT -$ ENDIF -$! -$! -$! Writing OPT.OPT file to build TOOLS -$OPEN/WRITE OUT OPT.OPT -$ IF (SHARED.GT.0) -$ THEN -$ WRITE OUT "[-.LIBTIFF]TIFF$SHR/SHARE" -$ WRITE OUT JPEG_LIBRARY_PATH -$ ELSE -$ WRITE OUT "[-.LIBTIFF]TIFF/LIB" -$ WRITE OUT "[-.PORT]LIBPORT/LIB" -$ WRITE OUT JPEG_LIBRARY_PATH -$ ENDIF -$ WRITE OUT "ZLIB:LIBZ/LIB" -$CLOSE OUT -$! -$! -$COPY SYS$INPUT [.LIBTIFF]DESCRIP.MMS -# (c) Alexey Chupahin 22-NOV-2007 -# OpenVMS 7.3-1, DEC 2000 mod.300 -# OpenVMS 8.3, HP rx1620 -# Makefile for DEC C compilers. -# - -INCL = /INCLUDE=(JPEG,ZLIB,[]) - -CFLAGS = $(INCL) - -OBJ_SYSDEP_MODULE = tif_vms.obj - -OBJ = \ -tif_aux.obj,\ -tif_close.obj,\ -tif_codec.obj,\ -tif_color.obj,\ -tif_compress.obj,\ -tif_dir.obj,\ -tif_dirinfo.obj,\ -tif_dirread.obj,\ -tif_dirwrite.obj,\ -tif_dumpmode.obj,\ -tif_error.obj,\ -tif_extension.obj,\ -tif_fax3.obj,\ -tif_fax3sm.obj,\ -tif_flush.obj,\ -tif_getimage.obj,\ -tif_jbig.obj,\ -tif_jpeg.obj,\ -tif_luv.obj,\ -tif_lzw.obj,\ -tif_next.obj,\ -tif_ojpeg.obj,\ -tif_open.obj,\ -tif_packbits.obj,\ -tif_pixarlog.obj,\ -tif_predict.obj,\ -tif_print.obj,\ -tif_read.obj,\ -tif_strip.obj,\ -tif_swab.obj,\ -tif_thunder.obj,\ -tif_tile.obj,\ -tif_version.obj,\ -tif_warning.obj,\ -tif_write.obj,\ -tif_zip.obj, $(OBJ_SYSDEP_MODULE) - -$IF (SHARED.GT.0) -$ THEN -$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS -ALL : tiff.olb, tiff$shr.exe - $WRITE SYS$OUTPUT "Done" - -tiff$shr.exe : tiff.olb - LINK/SHARE=TIFF$SHR.EXE TIF_AUX,[-]TIFF$DEF/OPT, [-]TIFF$SHR/OPT - COPY TIFF$SHR.EXE SYS$SHARE - PURGE SYS$SHARE:TIFF$SHR.EXE - -$ ELSE -$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS -ALL : tiff.olb - $WRITE SYS$OUTPUT "Done" - -$ENDIF -$! -$! -$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS - -tiff.olb : $(OBJ) - lib/crea tiff.olb $(OBJ) - -#tif_config.h : tif_config.h-vms -# copy tif_config.h-vms tif_config.h -# -#tiffconf.h : tiffconf.h-vms -# copy tiffconf.h-vms tiffconf.h - -tif_aux.obj : tif_aux.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_close.obj : tif_close.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_codec.obj : tif_codec.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_color.obj : tif_color.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_compress.obj : tif_compress.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_dir.obj : tif_dir.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_dirinfo.obj : tif_dirinfo.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_dirread.obj : tif_dirread.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_dirwrite.obj : tif_dirwrite.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_dumpmode.obj : tif_dumpmode.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_error.obj : tif_error.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_extension.obj : tif_extension.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_fax3.obj : tif_fax3.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_fax3sm.obj : tif_fax3sm.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_flush.obj : tif_flush.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_getimage.obj : tif_getimage.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_jbig.obj : tif_jbig.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_jpeg.obj : tif_jpeg.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_luv.obj : tif_luv.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_lzw.obj : tif_lzw.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_next.obj : tif_next.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_ojpeg.obj : tif_ojpeg.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_open.obj : tif_open.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_packbits.obj : tif_packbits.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_pixarlog.obj : tif_pixarlog.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_predict.obj : tif_predict.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_print.obj : tif_print.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_read.obj : tif_read.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_strip.obj : tif_strip.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_swab.obj : tif_swab.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_thunder.obj : tif_thunder.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_tile.obj : tif_tile.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_unix.obj : tif_unix.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_version.obj : tif_version.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_warning.obj : tif_warning.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_write.obj : tif_write.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tif_zip.obj : tif_zip.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - - -clean : - del *.obj;* - del *.olb;* -$! -$! -$! -$COPY SYS$INPUT [.TOOLS]DESCRIP.MMS -# (c) Alexey Chupahin 22-NOV-2007 -# OpenVMS 7.3-1, DEC 2000 mod.300 -# OpenVMS 8.3, HP rx1620 - -INCL = /INCL=([],[-.LIBTIFF]) -CFLAGS = $(INCL) -LIBS = [-]OPT/OPT - -OBJ=\ -bmp2tiff.exe,\ -fax2ps.exe,\ -fax2tiff.exe,\ -gif2tiff.exe,\ -pal2rgb.exe,\ -ppm2tiff.exe,\ -ras2tiff.exe,\ -raw2tiff.exe,\ -rgb2ycbcr.exe,\ -thumbnail.exe,\ -tiff2bw.exe,\ -tiff2pdf.exe,\ -tiff2ps.exe,\ -tiff2rgba.exe,\ -tiffcmp.exe,\ -tiffcp.exe,\ -tiffcrop.exe,\ -tiffdither.exe,\ -tiffdump.exe,\ -tiffinfo.exe,\ -tiffmedian.exe,\ -tiffset.exe,\ -tiffsplit.exe,\ -ycbcr.exe - - -all : $(OBJ) - $! - -bmp2tiff.obj : bmp2tiff.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -bmp2tiff.exe : bmp2tiff.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -fax2ps.obj : fax2ps.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -fax2ps.exe : fax2ps.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -fax2tiff.obj : fax2tiff.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -fax2tiff.exe : fax2tiff.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -gif2tiff.obj : gif2tiff.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -gif2tiff.exe : gif2tiff.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -pal2rgb.obj : pal2rgb.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -pal2rgb.exe : pal2rgb.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -ppm2tiff.obj : ppm2tiff.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -ppm2tiff.exe : ppm2tiff.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -ras2tiff.obj : ras2tiff.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -ras2tiff.exe : ras2tiff.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -raw2tiff.obj : raw2tiff.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -raw2tiff.exe : raw2tiff.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -rgb2ycbcr.obj : rgb2ycbcr.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -rgb2ycbcr.exe : rgb2ycbcr.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -sgi2tiff.obj : sgi2tiff.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -sgi2tiff.exe : sgi2tiff.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -sgisv.obj : sgisv.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -sgisv.exe : sgisv.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -thumbnail.obj : thumbnail.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -thumbnail.exe : thumbnail.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiff2bw.obj : tiff2bw.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiff2bw.exe : tiff2bw.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiff2pdf.obj : tiff2pdf.c - $(CC) $(CFLAGS) /NOWARN $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiff2pdf.exe : tiff2pdf.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiff2ps.obj : tiff2ps.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiff2ps.exe : tiff2ps.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiff2rgba.obj : tiff2rgba.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiff2rgba.exe : tiff2rgba.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffcmp.obj : tiffcmp.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffcmp.exe : tiffcmp.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffcp.obj : tiffcp.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffcp.exe : tiffcp.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffcrop.obj : tiffcrop.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffcrop.exe : tiffcrop.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffdither.obj : tiffdither.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffdither.exe : tiffdither.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffdump.obj : tiffdump.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffdump.exe : tiffdump.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffgt.obj : tiffgt.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffgt.exe : tiffgt.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffinfo.obj : tiffinfo.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffinfo.exe : tiffinfo.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffmedian.obj : tiffmedian.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffmedian.exe : tiffmedian.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffset.obj : tiffset.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffset.exe : tiffset.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -tiffsplit.obj : tiffsplit.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -tiffsplit.exe : tiffsplit.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - -ycbcr.obj : ycbcr.c - $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) - -ycbcr.exe : ycbcr.obj - LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) - - -CLEAN : - DEL ALL.;* - DEL *.OBJ;* - DEL *.EXE;* - -$! -$! -$! -$!copiing and patching TIFF_CONF.H, TIF_CONFIG.H -$! -$CURRENT = F$ENVIRONMENT (""DEFAULT"") -$CURRENT[F$LOCATE("]",CURRENT),9]:=".LIBTIFF]" -$WRITE SYS$OUTPUT "Creating TIFFCONF.H and TIF_CONFIG.H" -$COPY SYS$INPUT 'CURRENT'TIFFCONF.H -/* - Configuration defines for installed libtiff. - This file maintained for backward compatibility. Do not use definitions - from this file in your programs. -*/ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ - -/* Define to 1 if the system has the type `int16'. */ -//#define HAVE_INT16 - -/* Define to 1 if the system has the type `int32'. */ -//#define HAVE_INT32 - -/* Define to 1 if the system has the type `int8'. */ -//#define HAVE_INT8 - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Compatibility stuff. */ - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ - -#ifdef __IEEE_FLOAT -#define HAVE_IEEEFP 1 -#endif - -#define HAVE_GETOPT 1 - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#define HOST_BIGENDIAN 0 - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Support LogLuv high dynamic range encoding */ -#define LOGLUV_SUPPORT 1 - -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 - -/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation - fails with unpatched IJG JPEG library) */ - -/* Support Macintosh PackBits algorithm */ -#define PACKBITS_SUPPORT 1 - -/* Support Pixar log-format algorithm (requires Zlib) */ -#define PIXARLOG_SUPPORT 1 - -/* Support ThunderScan 4-bit RLE algorithm */ -#define THUNDER_SUPPORT 1 - -/* Support Deflate compression */ -/* #undef ZIP_SUPPORT */ - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP - -/* Enable SubIFD tag (330) support */ -#define SUBIFD_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 - -/* - * Feature support definitions. - * XXX: These macros are obsoleted. Don't use them in your apps! - * Macros stays here for backward compatibility and should be always defined. - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT - -#endif /* _TIFFCONF_ */ - - -$COPY SYS$INPUT 'CURRENT'TIF_CONFIG.H -/* Define to 1 if you have the <assert.h> header file. */ - -#ifndef HAVE_GETOPT -# define HAVE_GETOPT 1 -#endif - -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ - -#ifdef __IEEE_FLOAT -#define HAVE_IEEEFP 1 -#endif - -#define HAVE_UNISTD_H 1 - -#define HAVE_STRING_H 1 -/* Define to 1 if you have the <sys/types.h> header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the <io.h> header file. */ -//#define HAVE_IO_H 1 - -/* Define to 1 if you have the <search.h> header file. */ -//#define HAVE_SEARCH_H 1 - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Set the native cpu bit order */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -/* -#ifndef __cplusplus -# ifndef inline -# define inline __inline -# endif -#endif -*/ - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 -/* Support C++ stream API (requires C++ compiler) */ -#define CXX_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* little Endian */ -#define HOST_BIGENDIAN 0 -#define JPEG_SUPPORT 1 -#define LOGLUV_SUPPORT 1 -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support Microsoft Document Imaging format */ -#define MDI_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 -#define OJPEG_SUPPORT 1 - -/* Name of package */ -#define PACKAGE "tiff" - - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "tiff@lists.maptools.org" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "LibTIFF Software" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "LibTIFF Software 3.9.0beta for VMS" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "tiff" - -$PURGE 'CURRENT'TIFFCONF.H -$PURGE 'CURRENT'TIF_CONFIG.H -$OPEN/APPEND OUT 'CURRENT'TIF_CONFIG.H -$IF HAVE_LFIND.EQ.1 -$ THEN -$ WRITE OUT "#define HAVE_SEARCH_H 1" -$ ELSE -$ WRITE OUT "#undef HAVE_SEARCH_H" -$ENDIF -$CLOSE OUT -$! -$! -$WRITE SYS$OUTPUT " " -$WRITE SYS$OUTPUT " " -$WRITE SYS$OUTPUT "Now you can type @BUILD " -$! -$EXIT: -$DEFINE SYS$ERROR _NLA0: -$DEFINE SYS$OUTPUT _NLA0: -$DEL TEST.OBJ;* -$DEL TEST.C;* -$DEL TEST.EXE;* -$DEAS SYS$ERROR -$DEAS SYS$OUTPUT diff --git a/tiff/contrib/CMakeLists.txt b/tiff/contrib/CMakeLists.txt index 6bb124f4..8c8310b6 100644 --- a/tiff/contrib/CMakeLists.txt +++ b/tiff/contrib/CMakeLists.txt @@ -25,11 +25,3 @@ add_subdirectory(addtiffo) add_subdirectory(dbs) add_subdirectory(iptcutil) -add_subdirectory(mfs) -add_subdirectory(pds) -add_subdirectory(ras) -add_subdirectory(stream) -add_subdirectory(tags) -add_subdirectory(win_dib) - -extra_dist(README) diff --git a/tiff/contrib/Makefile.in b/tiff/contrib/Makefile.in index c0f998b3..ec34d8de 100644 --- a/tiff/contrib/Makefile.in +++ b/tiff/contrib/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -122,8 +122,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -347,6 +349,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/contrib/addtiffo/CMakeLists.txt b/tiff/contrib/addtiffo/CMakeLists.txt index 45e733cd..2f3959bc 100644 --- a/tiff/contrib/addtiffo/CMakeLists.txt +++ b/tiff/contrib/addtiffo/CMakeLists.txt @@ -22,14 +22,6 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -extra_dist( - README - Makefile.vc) - -include_directories(${PROJECT_SOURCE_DIR}/libtiff - ${PROJECT_BINARY_DIR}/libtiff - ${CMAKE_CURRENT_BINARY_DIR}) - add_executable(addtiffo addtiffo.c tif_overview.c tif_ovrcache.c tif_ovrcache.h) target_link_libraries(addtiffo tiff port) diff --git a/tiff/contrib/addtiffo/Makefile.am b/tiff/contrib/addtiffo/Makefile.am index 87342bde..3f817c6f 100644 --- a/tiff/contrib/addtiffo/Makefile.am +++ b/tiff/contrib/addtiffo/Makefile.am @@ -27,7 +27,6 @@ LIBTIFF = $(top_builddir)/libtiff/libtiff.la EXTRA_DIST = \ CMakeLists.txt \ - Makefile.vc \ README noinst_PROGRAMS = addtiffo diff --git a/tiff/contrib/addtiffo/Makefile.in b/tiff/contrib/addtiffo/Makefile.in index 31dc815c..49a90cbc 100644 --- a/tiff/contrib/addtiffo/Makefile.in +++ b/tiff/contrib/addtiffo/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -124,8 +124,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) @@ -149,7 +151,7 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/libtiff -I$(top_builddir)/port depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/addtiffo.Po \ @@ -341,6 +343,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -353,7 +356,6 @@ top_srcdir = @top_srcdir@ LIBTIFF = $(top_builddir)/libtiff/libtiff.la EXTRA_DIST = \ CMakeLists.txt \ - Makefile.vc \ README addtiffo_SOURCES = addtiffo.c tif_overview.c tif_ovrcache.c tif_ovrcache.h diff --git a/tiff/contrib/addtiffo/Makefile.vc b/tiff/contrib/addtiffo/Makefile.vc deleted file mode 100755 index 2777dc2a..00000000 --- a/tiff/contrib/addtiffo/Makefile.vc +++ /dev/null @@ -1,28 +0,0 @@ -# -# If libtiff.a is installed in /usr/lib or /usr/local/lib just point -# LIBTIFF_DIR there. It doesn't need a full libtiff tree. -# -!INCLUDE ..\..\nmake.opt - -LIBTIFF_DIR = ..\..\libtiff -# -INCL = -I..\..\libtiff -LIBS = $(LIBTIFF_DIR)\libtiff.lib - -addtiffo: addtiffo.obj tif_overview.obj tif_ovrcache.obj - $(CC) $(CFLAGS) addtiffo.obj tif_overview.obj tif_ovrcache.obj \ - $(LIBS) /Feaddtiffo.exe - - -addtiffo.obj: addtiffo.c - $(CC) -c $(CFLAGS) addtiffo.c - -tif_overview.obj: tif_overview.c - $(CC) -c $(CFLAGS) tif_overview.c - -tif_ovrcache.obj: tif_ovrcache.c - $(CC) -c $(CFLAGS) tif_ovrcache.c - -clean: - -del *.obj - -del addtiffo.exe diff --git a/tiff/contrib/addtiffo/tif_overview.c b/tiff/contrib/addtiffo/tif_overview.c index 03b35733..6e837d10 100644 --- a/tiff/contrib/addtiffo/tif_overview.c +++ b/tiff/contrib/addtiffo/tif_overview.c @@ -79,16 +79,16 @@ void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, /* function is called. */ /************************************************************************/ -uint32 TIFF_WriteOverview( TIFF *hTIFF, uint32 nXSize, uint32 nYSize, - int nBitsPerPixel, int nPlanarConfig, int nSamples, - int nBlockXSize, int nBlockYSize, - int bTiled, int nCompressFlag, int nPhotometric, - int nSampleFormat, - unsigned short *panRed, - unsigned short *panGreen, - unsigned short *panBlue, - int bUseSubIFDs, - int nHorSubsampling, int nVerSubsampling ) +uint32_t TIFF_WriteOverview( TIFF *hTIFF, uint32_t nXSize, uint32_t nYSize, + int nBitsPerPixel, int nPlanarConfig, int nSamples, + int nBlockXSize, int nBlockYSize, + int bTiled, int nCompressFlag, int nPhotometric, + int nSampleFormat, + unsigned short *panRed, + unsigned short *panGreen, + unsigned short *panBlue, + int bUseSubIFDs, + int nHorSubsampling, int nVerSubsampling ) { toff_t nBaseDirOffset; @@ -173,13 +173,13 @@ uint32 TIFF_WriteOverview( TIFF *hTIFF, uint32 nXSize, uint32 nYSize, /************************************************************************/ static void -TIFF_GetSourceSamples( double * padfSamples, unsigned char *pabySrc, - int nPixelBytes, int nSampleFormat, - uint32 nXSize, uint32 nYSize, +TIFF_GetSourceSamples( double * padfSamples, unsigned char *pabySrc, + int nPixelBytes, int nSampleFormat, + uint32_t nXSize, uint32_t nYSize, int nPixelOffset, int nLineOffset ) { - uint32 iXOff, iYOff; - int iSample; + uint32_t iXOff, iYOff; + int iSample; iSample = 0; @@ -197,19 +197,19 @@ TIFF_GetSourceSamples( double * padfSamples, unsigned char *pabySrc, } else if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 2 ) { - padfSamples[iSample++] = ((uint16 *) pabyData)[0]; + padfSamples[iSample++] = ((uint16_t *) pabyData)[0]; } else if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 4 ) { - padfSamples[iSample++] = ((uint32 *) pabyData)[0]; + padfSamples[iSample++] = ((uint32_t *) pabyData)[0]; } else if( nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 2 ) { - padfSamples[iSample++] = ((int16 *) pabyData)[0]; + padfSamples[iSample++] = ((int16_t *) pabyData)[0]; } else if( nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 32 ) { - padfSamples[iSample++] = ((int32 *) pabyData)[0]; + padfSamples[iSample++] = ((int32_t *) pabyData)[0]; } else if( nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 4 ) { @@ -238,19 +238,19 @@ TIFF_SetSample( unsigned char * pabyData, int nPixelBytes, int nSampleFormat, } else if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 2 ) { - *((uint16 *)pabyData) = (uint16) MAX(0,MIN(65535,dfValue)); + *((uint16_t *)pabyData) = (uint16_t) MAX(0, MIN(65535, dfValue)); } else if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 4 ) { - *((uint32 *)pabyData) = (uint32) dfValue; + *((uint32_t *)pabyData) = (uint32_t) dfValue; } else if( nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 2 ) { - *((int16 *)pabyData) = (int16) MAX(-32768,MIN(32767,dfValue)); + *((int16_t *)pabyData) = (int16_t) MAX(-32768, MIN(32767, dfValue)); } else if( nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 32 ) { - *((int32 *)pabyData) = (int32) dfValue; + *((int32_t *)pabyData) = (int32_t) dfValue; } else if( nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 4 ) { @@ -271,15 +271,15 @@ TIFF_SetSample( unsigned char * pabyData, int nPixelBytes, int nSampleFormat, static void TIFF_DownSample( unsigned char *pabySrcTile, - uint32 nBlockXSize, uint32 nBlockYSize, + uint32_t nBlockXSize, uint32_t nBlockYSize, int nPixelSkewBits, int nBitsPerPixel, unsigned char * pabyOTile, - uint32 nOBlockXSize, uint32 nOBlockYSize, - uint32 nTXOff, uint32 nTYOff, int nOMult, + uint32_t nOBlockXSize, uint32_t nOBlockYSize, + uint32_t nTXOff, uint32_t nTYOff, int nOMult, int nSampleFormat, const char * pszResampling ) { - uint32 i, j; + uint32_t i, j; int k, nPixelBytes = (nBitsPerPixel) / 8; int nPixelGroupBytes = (nBitsPerPixel+nPixelSkewBits)/8; unsigned char *pabySrc, *pabyDst; @@ -357,13 +357,13 @@ void TIFF_DownSample( unsigned char *pabySrcTile, for( i = 0; i*nOMult < nBlockXSize; i++ ) { double dfTotal; - uint32 nXSize, nYSize, iSample; + uint32_t nXSize, nYSize, iSample; if( i + nTXOff >= nOBlockXSize ) break; - nXSize = MIN((uint32)nOMult,nBlockXSize-i); - nYSize = MIN((uint32)nOMult,nBlockYSize-j); + nXSize = MIN((uint32_t)nOMult, nBlockXSize - i); + nYSize = MIN((uint32_t)nOMult, nBlockYSize - j); TIFF_GetSourceSamples( padfSamples, pabySrc, nPixelBytes, nSampleFormat, @@ -394,10 +394,10 @@ void TIFF_DownSample( unsigned char *pabySrcTile, /************************************************************************/ static void TIFF_DownSample_Subsampled( unsigned char *pabySrcTile, int nSample, - uint32 nBlockXSize, uint32 nBlockYSize, + uint32_t nBlockXSize, uint32_t nBlockYSize, unsigned char * pabyOTile, - uint32 nOBlockXSize, uint32 nOBlockYSize, - uint32 nTXOff, uint32 nTYOff, int nOMult, + uint32_t nOBlockXSize, uint32_t nOBlockYSize, + uint32_t nTXOff, uint32_t nTYOff, int nOMult, const char *pszResampling, int nHorSubsampling, int nVerSubsampling ) { @@ -405,10 +405,10 @@ void TIFF_DownSample_Subsampled( unsigned char *pabySrcTile, int nSample, int nSampleBlockSize; int nSourceSampleRowSize; int nDestSampleRowSize; - uint32 nSourceX, nSourceY; - uint32 nSourceXSec, nSourceYSec; - uint32 nSourceXSecEnd, nSourceYSecEnd; - uint32 nDestX, nDestY; + uint32_t nSourceX, nSourceY; + uint32_t nSourceXSec, nSourceYSec; + uint32_t nSourceXSecEnd, nSourceYSecEnd; + uint32_t nDestX, nDestY; int nSampleOffsetInSampleBlock; unsigned int nCummulator; unsigned int nCummulatorCount; @@ -572,9 +572,9 @@ void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig, int nOverviews, int * panOvList, int nBitsPerPixel, int nSamples, TIFFOvrCache ** papoRawBIs, - uint32 nSXOff, uint32 nSYOff, + uint32_t nSXOff, uint32_t nSYOff, unsigned char *pabySrcTile, - uint32 nBlockXSize, uint32 nBlockYSize, + uint32_t nBlockXSize, uint32_t nBlockYSize, int nSampleFormat, const char * pszResampling ) { @@ -614,10 +614,10 @@ void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig, { TIFFOvrCache *poRBI = papoRawBIs[iOverview]; unsigned char *pabyOTile; - uint32 nTXOff, nTYOff, nOXOff, nOYOff, nOMult; - uint32 nOBlockXSize = poRBI->nBlockXSize; - uint32 nOBlockYSize = poRBI->nBlockYSize; - int nSkewBits, nSampleByteOffset; + uint32_t nTXOff, nTYOff, nOXOff, nOYOff, nOMult; + uint32_t nOBlockXSize = poRBI->nBlockXSize; + uint32_t nOBlockYSize = poRBI->nBlockYSize; + int nSkewBits, nSampleByteOffset; /* * Fetch the destination overview tile @@ -718,14 +718,14 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, { TIFFOvrCache **papoRawBIs; - uint32 nXSize, nYSize, nBlockXSize, nBlockYSize; - uint16 nBitsPerPixel, nPhotometric, nCompressFlag, nSamples, + uint32_t nXSize, nYSize, nBlockXSize, nBlockYSize; + uint16_t nBitsPerPixel, nPhotometric, nCompressFlag, nSamples, nPlanarConfig, nSampleFormat; int bSubsampled; - uint16 nHorSubsampling, nVerSubsampling; + uint16_t nHorSubsampling, nVerSubsampling; int bTiled, nSXOff, nSYOff, i; unsigned char *pabySrcTile; - uint16 *panRedMap, *panGreenMap, *panBlueMap; + uint16_t *panRedMap, *panGreenMap, *panBlueMap; TIFFErrorHandler pfnWarning; (void) pfnProgress; @@ -782,7 +782,7 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, } /* -------------------------------------------------------------------- */ -/* Turn off warnings to avoid alot of repeated warnings while */ +/* Turn off warnings to avoid a lot of repeated warnings while */ /* rereading directories. */ /* -------------------------------------------------------------------- */ pfnWarning = TIFFSetWarningHandler( NULL ); @@ -803,17 +803,17 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, } /* -------------------------------------------------------------------- */ -/* Capture the pallette if there is one. */ +/* Capture the palette if there is one. */ /* -------------------------------------------------------------------- */ if( TIFFGetField( hTIFF, TIFFTAG_COLORMAP, &panRedMap, &panGreenMap, &panBlueMap ) ) { - uint16 *panRed2, *panGreen2, *panBlue2; + uint16_t *panRed2, *panGreen2, *panBlue2; int nColorCount = 1 << nBitsPerPixel; - panRed2 = (uint16 *) _TIFFmalloc(2*nColorCount); - panGreen2 = (uint16 *) _TIFFmalloc(2*nColorCount); - panBlue2 = (uint16 *) _TIFFmalloc(2*nColorCount); + panRed2 = (uint16_t *) _TIFFmalloc(2 * nColorCount); + panGreen2 = (uint16_t *) _TIFFmalloc(2 * nColorCount); + panBlue2 = (uint16_t *) _TIFFmalloc(2 * nColorCount); memcpy( panRed2, panRedMap, 2 * nColorCount ); memcpy( panGreen2, panGreenMap, 2 * nColorCount ); @@ -835,7 +835,7 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, for( i = 0; i < nOverviews; i++ ) { - uint32 nOXSize, nOYSize, nOBlockXSize, nOBlockYSize; + uint32_t nOXSize, nOYSize, nOBlockXSize, nOBlockYSize; toff_t nDirOffset; nOXSize = (nXSize + panOvList[i] - 1) / panOvList[i]; diff --git a/tiff/contrib/addtiffo/tif_ovrcache.c b/tiff/contrib/addtiffo/tif_ovrcache.c index ac500ab4..75b6436a 100644 --- a/tiff/contrib/addtiffo/tif_ovrcache.c +++ b/tiff/contrib/addtiffo/tif_ovrcache.c @@ -138,7 +138,7 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) int nRet, iTileX, iTileY = psCache->nBlockOffset; unsigned char *pabyData; toff_t nBaseDirOffset; - uint32 RowsInStrip; + uint32_t RowsInStrip; /* -------------------------------------------------------------------- */ /* If the output cache is multi-byte per sample, and the file */ @@ -148,11 +148,11 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) if( TIFFIsByteSwapped(psCache->hTIFF) ) { if( psCache->nBitsPerPixel == 16 ) - TIFFSwabArrayOfShort( (uint16 *) psCache->pabyRow1Blocks, + TIFFSwabArrayOfShort( (uint16_t *) psCache->pabyRow1Blocks, (psCache->nBytesPerBlock * psCache->nSamples) / 2 ); else if( psCache->nBitsPerPixel == 32 ) - TIFFSwabArrayOfLong( (uint32 *) psCache->pabyRow1Blocks, + TIFFSwabArrayOfLong( (uint32_t *) psCache->pabyRow1Blocks, (psCache->nBytesPerBlock * psCache->nSamples) / 4 ); else if( psCache->nBitsPerPixel == 64 ) diff --git a/tiff/contrib/addtiffo/tif_ovrcache.h b/tiff/contrib/addtiffo/tif_ovrcache.h index 0ad10829..83c97bf0 100644 --- a/tiff/contrib/addtiffo/tif_ovrcache.h +++ b/tiff/contrib/addtiffo/tif_ovrcache.h @@ -43,14 +43,14 @@ extern "C" { typedef struct { - uint32 nXSize; - uint32 nYSize; + uint32_t nXSize; + uint32_t nYSize; - uint16 nBitsPerPixel; - uint16 nSamples; - uint16 nPlanarConfig; - uint32 nBlockXSize; - uint32 nBlockYSize; + uint16_t nBitsPerPixel; + uint16_t nSamples; + uint16_t nPlanarConfig; + uint32_t nBlockXSize; + uint32_t nBlockYSize; toff_t nBytesPerBlock; toff_t nBytesPerRow; @@ -76,15 +76,15 @@ void TIFFDestroyOvrCache( TIFFOvrCache * ); void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, int (*)(double,void*), void * ); -void TIFF_ProcessFullResBlock( TIFF *, int, int, int, int, int, int *, int, - int, TIFFOvrCache **, uint32, uint32, - unsigned char *, uint32, uint32, +void TIFF_ProcessFullResBlock( TIFF *, int, int, int, int, int, int *, int, + int, TIFFOvrCache **, uint32_t, uint32_t, + unsigned char *, uint32_t, uint32_t, int, const char * ); -uint32 TIFF_WriteOverview( TIFF *, uint32, uint32, int, int, int, int, int, - int, int, int, int, unsigned short *, - unsigned short *, unsigned short *, int, - int, int); +uint32_t TIFF_WriteOverview( TIFF *, uint32_t, uint32_t, int, int, int, int, int, + int, int, int, int, unsigned short *, + unsigned short *, unsigned short *, int, + int, int); diff --git a/tiff/contrib/dbs/CMakeLists.txt b/tiff/contrib/dbs/CMakeLists.txt index ff3ce20c..b5681777 100644 --- a/tiff/contrib/dbs/CMakeLists.txt +++ b/tiff/contrib/dbs/CMakeLists.txt @@ -22,25 +22,17 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -include_directories(${PROJECT_SOURCE_DIR}/libtiff - ${PROJECT_BINARY_DIR}/libtiff - ${CMAKE_CURRENT_BINARY_DIR}) - add_executable(tiff-bi tiff-bi.c) target_link_libraries(tiff-bi tiff port) add_executable(tiff-grayscale tiff-grayscale.c) -target_link_libraries(tiff-grayscale tiff port) +target_link_libraries(tiff-grayscale tiff port CMath::CMath) add_executable(tiff-palette tiff-palette.c) target_link_libraries(tiff-palette tiff port) add_executable(tiff-rgb tiff-rgb.c) -target_link_libraries(tiff-rgb tiff port) - -add_subdirectory(xtiff) - -extra_dist(README) +target_link_libraries(tiff-rgb tiff port CMath::CMath) if(WEBP_SUPPORT AND EMSCRIPTEN) # Emscripten is pretty finnicky about linker flags. diff --git a/tiff/contrib/dbs/Makefile.in b/tiff/contrib/dbs/Makefile.in index 0f44fdd1..eb6a255d 100644 --- a/tiff/contrib/dbs/Makefile.in +++ b/tiff/contrib/dbs/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -125,8 +125,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) @@ -158,7 +160,7 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/libtiff -I$(top_builddir)/port depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/tiff-bi.Po \ @@ -395,6 +397,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/contrib/dbs/tiff-grayscale.c b/tiff/contrib/dbs/tiff-grayscale.c index 92c7b904..644eb9ee 100644 --- a/tiff/contrib/dbs/tiff-grayscale.c +++ b/tiff/contrib/dbs/tiff-grayscale.c @@ -41,7 +41,7 @@ int main(int argc, char **argv) int bits_per_pixel = 8, cmsize, i, j, k, gray_index, chunk_size = 32, nchunks = 16; unsigned char * scan_line; - uint16 * gray; + uint16_t * gray; float refblackwhite[2*1]; TIFF * tif; @@ -73,11 +73,11 @@ int main(int argc, char **argv) } cmsize = nchunks * nchunks; - gray = (uint16 *) malloc(cmsize * sizeof(uint16)); + gray = (uint16_t *) malloc(cmsize * sizeof(uint16_t)); gray[0] = 3000; for (i = 1; i < cmsize; i++) - gray[i] = (uint16) (-log10((double) i / (cmsize - 1)) * 1000); + gray[i] = (uint16_t) (-log10((double) i / (cmsize - 1)) * 1000); refblackwhite[0] = 0.0; refblackwhite[1] = (float)((1L<<bits_per_pixel) - 1); diff --git a/tiff/contrib/dbs/tiff-palette.c b/tiff/contrib/dbs/tiff-palette.c index 7b3d433f..9f8ea105 100644 --- a/tiff/contrib/dbs/tiff-palette.c +++ b/tiff/contrib/dbs/tiff-palette.c @@ -40,7 +40,7 @@ int main(int argc, char **argv) int bits_per_pixel = 8, cmsize, i, j, k, cmap_index, chunk_size = 32, nchunks = 16; unsigned char * scan_line; - uint16 *red, *green, *blue; + uint16_t *red, *green, *blue; TIFF * tif; programName = argv[0]; @@ -79,9 +79,9 @@ int main(int argc, char **argv) } else { cmsize = 2; } - red = (uint16 *) malloc(cmsize * sizeof(uint16)); - green = (uint16 *) malloc(cmsize * sizeof(uint16)); - blue = (uint16 *) malloc(cmsize * sizeof(uint16)); + red = (uint16_t *) malloc(cmsize * sizeof(uint16_t)); + green = (uint16_t *) malloc(cmsize * sizeof(uint16_t)); + blue = (uint16_t *) malloc(cmsize * sizeof(uint16_t)); switch (bits_per_pixel) { case 8: diff --git a/tiff/contrib/dbs/tiff-rgb.c b/tiff/contrib/dbs/tiff-rgb.c index d14ed005..f912cb99 100644 --- a/tiff/contrib/dbs/tiff-rgb.c +++ b/tiff/contrib/dbs/tiff-rgb.c @@ -29,7 +29,7 @@ #include "tiffio.h" -#define ROUND(x) (uint16) ((x) + 0.5) +#define ROUND(x) (uint16_t) ((x) + 0.5) #define CMSIZE 256 #define WIDTH 525 #define HEIGHT 512 @@ -45,7 +45,7 @@ int main(int argc, char **argv) int i, j; TIFF * tif; unsigned char * scan_line; - uint16 red[CMSIZE], green[CMSIZE], blue[CMSIZE]; + uint16_t red[CMSIZE], green[CMSIZE], blue[CMSIZE]; float refblackwhite[2*3]; programName = argv[0]; diff --git a/tiff/contrib/dbs/xtiff/Makefile.am b/tiff/contrib/dbs/xtiff/Makefile.am index a138c90a..cd810472 100644 --- a/tiff/contrib/dbs/xtiff/Makefile.am +++ b/tiff/contrib/dbs/xtiff/Makefile.am @@ -27,7 +27,6 @@ #LIBTIFF = $(top_builddir)/libtiff/libtiff.la EXTRA_DIST = \ - CMakeLists.txt \ README \ patchlevel.h \ xtiff.c \ diff --git a/tiff/contrib/dbs/xtiff/Makefile.in b/tiff/contrib/dbs/xtiff/Makefile.in index 4be51fd8..50b6bf09 100644 --- a/tiff/contrib/dbs/xtiff/Makefile.in +++ b/tiff/contrib/dbs/xtiff/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -125,8 +125,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -290,6 +292,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -300,7 +303,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ - CMakeLists.txt \ README \ patchlevel.h \ xtiff.c \ diff --git a/tiff/contrib/dbs/xtiff/xtiff.c b/tiff/contrib/dbs/xtiff/xtiff.c index bc10b670..a9518f83 100644 --- a/tiff/contrib/dbs/xtiff/xtiff.c +++ b/tiff/contrib/dbs/xtiff/xtiff.c @@ -70,7 +70,7 @@ #include "xtifficon.h" #define TIFF_GAMMA "2.2" /* default gamma from the TIFF 5.0 spec */ -#define ROUND(x) (uint16) ((x) + 0.5) +#define ROUND(x) (uint16_t) ((x) + 0.5) #define SCALE(x, s) (((x) * 65535L) / (s)) #define MCHECK(m) if (!m) { fprintf(stderr, "malloc failed\n"); exit(0); } #define MIN(a, b) (((a) < (b)) ? (a) : (b)) @@ -131,8 +131,8 @@ typedef struct { Boolean help; float gamma; Boolean usePixmap; - uint32 viewportWidth; - uint32 viewportHeight; + uint32_t viewportWidth; + uint32_t viewportHeight; int translate; Boolean verbose; } AppData, *AppDataPtr; @@ -236,8 +236,8 @@ unsigned char basePixel = 0; * TIFF data structures */ TIFF * tfFile = NULL; -uint32 tfImageWidth, tfImageHeight; -uint16 tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration, +uint32_t tfImageWidth, tfImageHeight; +uint16_t tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration, tfPhotometricInterpretation, tfGrayResponseUnit, tfImageDepth, tfBytesPerRow; int tfDirectory = 0, tfMultiPage = False; @@ -253,7 +253,7 @@ double *dRed, *dGreen, *dBlue; /* * shared data structures */ -uint16 * redMap = NULL, *greenMap = NULL, *blueMap = NULL, +uint16_t * redMap = NULL, *greenMap = NULL, *blueMap = NULL, *grayMap = NULL, colormapSize; char * imageMemory; char * fileName; @@ -451,9 +451,9 @@ GetTIFFHeader() */ switch (tfPhotometricInterpretation) { case PHOTOMETRIC_RGB: - redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); - greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); - blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + redMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); + greenMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); + blueMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] @@ -462,9 +462,9 @@ GetTIFFHeader() case PHOTOMETRIC_PALETTE: if (!TIFFGetField(tfFile, TIFFTAG_COLORMAP, &redMap, &greenMap, &blueMap)) { - redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); - greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); - blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + redMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); + greenMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); + blueMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] @@ -479,18 +479,18 @@ GetTIFFHeader() } break; case PHOTOMETRIC_MINISWHITE: - redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); - greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); - blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + redMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); + greenMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); + blueMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(colormapSize-1-i, colormapSize-1); break; case PHOTOMETRIC_MINISBLACK: - redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); - greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); - blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + redMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); + greenMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); + blueMap = (uint16_t *) malloc(colormapSize * sizeof(uint16_t)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(i, colormapSize-1); @@ -736,8 +736,8 @@ GetTIFFImage() { int pixel_map[3], red_shift, green_shift, blue_shift; char *scan_line, *output_p, *input_p; - uint32 i, j; - uint16 s; + uint32_t i, j; + uint16_t s; scan_line = (char *) malloc(tfBytesPerRow = TIFFScanlineSize(tfFile)); MCHECK(scan_line); diff --git a/tiff/contrib/iptcutil/CMakeLists.txt b/tiff/contrib/iptcutil/CMakeLists.txt index 35cc2612..39d908c6 100644 --- a/tiff/contrib/iptcutil/CMakeLists.txt +++ b/tiff/contrib/iptcutil/CMakeLists.txt @@ -22,14 +22,5 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -extra_dist( - README - test.iptc - test.txt) - -include_directories(${PROJECT_SOURCE_DIR}/libtiff - ${PROJECT_BINARY_DIR}/libtiff - ${CMAKE_CURRENT_BINARY_DIR}) - add_executable(iptcutil iptcutil.c) target_link_libraries(iptcutil tiff port) diff --git a/tiff/contrib/iptcutil/Makefile.in b/tiff/contrib/iptcutil/Makefile.in index c0cc3959..ec2f2457 100644 --- a/tiff/contrib/iptcutil/Makefile.in +++ b/tiff/contrib/iptcutil/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -124,8 +124,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) @@ -148,7 +150,7 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/libtiff -I$(top_builddir)/port depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/iptcutil.Po @@ -339,6 +341,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/contrib/iptcutil/iptcutil.c b/tiff/contrib/iptcutil/iptcutil.c index 621716df..e002eee1 100644 --- a/tiff/contrib/iptcutil/iptcutil.c +++ b/tiff/contrib/iptcutil/iptcutil.c @@ -17,7 +17,7 @@ # include <fcntl.h> #endif -#ifdef WIN32 +#ifdef _WIN32 #define STRNICMP strnicmp #else #define STRNICMP strncasecmp @@ -414,14 +414,14 @@ int main(int argc, char *argv[]) { case 't': mode = 1; -#ifdef WIN32 +#ifdef _WIN32 /* Set "stdout" to binary mode: */ _setmode( _fileno( ofile ), _O_BINARY ); #endif break; case 'b': mode = 0; -#ifdef WIN32 +#ifdef _WIN32 /* Set "stdin" to binary mode: */ _setmode( _fileno( ifile ), _O_BINARY ); #endif diff --git a/tiff/contrib/mfs/Makefile.am b/tiff/contrib/mfs/Makefile.am index b0bad60a..62ae5d57 100644 --- a/tiff/contrib/mfs/Makefile.am +++ b/tiff/contrib/mfs/Makefile.am @@ -24,6 +24,5 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ - CMakeLists.txt \ README \ mfs_file.c diff --git a/tiff/contrib/mfs/Makefile.in b/tiff/contrib/mfs/Makefile.in index 0ed2019c..b558e081 100644 --- a/tiff/contrib/mfs/Makefile.in +++ b/tiff/contrib/mfs/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -122,8 +122,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -287,6 +289,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -297,7 +300,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ - CMakeLists.txt \ README \ mfs_file.c diff --git a/tiff/contrib/pds/Makefile.am b/tiff/contrib/pds/Makefile.am index 435e2b33..c4e6bafe 100644 --- a/tiff/contrib/pds/Makefile.am +++ b/tiff/contrib/pds/Makefile.am @@ -24,7 +24,6 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ - CMakeLists.txt \ README \ tif_imageiter.c \ tif_imageiter.h \ diff --git a/tiff/contrib/pds/Makefile.in b/tiff/contrib/pds/Makefile.in index 77b02179..f3f79a82 100644 --- a/tiff/contrib/pds/Makefile.in +++ b/tiff/contrib/pds/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -122,8 +122,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -287,6 +289,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -297,7 +300,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ - CMakeLists.txt \ README \ tif_imageiter.c \ tif_imageiter.h \ diff --git a/tiff/contrib/pds/tif_imageiter.c b/tiff/contrib/pds/tif_imageiter.c index 243cfd65..7ecf61a0 100644 --- a/tiff/contrib/pds/tif_imageiter.c +++ b/tiff/contrib/pds/tif_imageiter.c @@ -49,17 +49,17 @@ #include <assert.h> #include <stdio.h> -static int gtTileContig(TIFFImageIter*, void *udata, uint32, uint32); -static int gtTileSeparate(TIFFImageIter*, void *udata, uint32, uint32); -static int gtStripContig(TIFFImageIter*, void *udata, uint32, uint32); -static int gtStripSeparate(TIFFImageIter*, void *udata, uint32, uint32); +static int gtTileContig(TIFFImageIter*, void *udata, uint32_t, uint32_t); +static int gtTileSeparate(TIFFImageIter*, void *udata, uint32_t, uint32_t); +static int gtStripContig(TIFFImageIter*, void *udata, uint32_t, uint32_t); +static int gtStripSeparate(TIFFImageIter*, void *udata, uint32_t, uint32_t); static const char photoTag[] = "PhotometricInterpretation"; static int isCCITTCompression(TIFF* tif) { - uint16 compress; + uint16_t compress; TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); return (compress == COMPRESSION_CCITTFAX3 || compress == COMPRESSION_CCITTFAX4 || @@ -70,9 +70,9 @@ isCCITTCompression(TIFF* tif) int TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024]) { - uint16* sampleinfo; - uint16 extrasamples; - uint16 planarconfig; + uint16_t* sampleinfo; + uint16_t extrasamples; + uint16_t planarconfig; int colorchannels; img->tif = tif; @@ -134,7 +134,7 @@ TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024]) return (0); } /* It would probably be nice to have a reality check here. */ - { uint16 compress; + { uint16_t compress; TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) { /* can rely on libjpeg to convert to RGB */ @@ -152,7 +152,7 @@ TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024]) } break; case PHOTOMETRIC_SEPARATED: { - uint16 inkset; + uint16_t inkset; TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); if (inkset != INKSET_CMYK) { sprintf(emsg, "Sorry, can not handle separated image with %s=%d", @@ -206,7 +206,7 @@ TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024]) } int -TIFFImageIterGet(TIFFImageIter* img, void *udata, uint32 w, uint32 h) +TIFFImageIterGet(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h) { if (img->get == NULL) { TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No \"get\" routine setup"); @@ -230,7 +230,7 @@ TIFFImageIterEnd(TIFFImageIter* img) */ int TIFFReadImageIter(TIFF* tif, - uint32 rwidth, uint32 rheight, uint8* raster, int stop) + uint32_t rwidth, uint32_t rheight, uint8_t* raster, int stop) { char emsg[1024]; TIFFImageIter img; @@ -255,16 +255,16 @@ TIFFReadImageIter(TIFF* tif, * SamplesPerPixel == 1 */ static int -gtTileContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h) +gtTileContig(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h) { TIFF* tif = img->tif; ImageIterTileContigRoutine callback = img->callback.contig; - uint16 orientation; - uint32 col, row; - uint32 tw, th; + uint16_t orientation; + uint32_t col, row; + uint32_t tw, th; u_char* buf; - int32 fromskew; - uint32 nrow; + int32_t fromskew; + uint32_t nrow; buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif)); if (buf == 0) { @@ -284,7 +284,7 @@ gtTileContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h) * Tile is clipped horizontally. Calculate * visible portion and skewing factors. */ - uint32 npix = w - col; + uint32_t npix = w - col; fromskew = tw - npix; (*callback)(img, udata, col, row, npix, nrow, fromskew, buf); } else { @@ -303,22 +303,22 @@ gtTileContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h) * We assume that all such images are RGB. */ static int -gtTileSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h) +gtTileSeparate(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h) { TIFF* tif = img->tif; ImageIterTileSeparateRoutine callback = img->callback.separate; - uint16 orientation; - uint32 col, row; - uint32 tw, th; + uint16_t orientation; + uint32_t col, row; + uint32_t tw, th; u_char* buf; u_char* r; u_char* g; u_char* b; u_char* a; tsize_t tilesize; - int32 fromskew; + int32_t fromskew; int alpha = img->alpha; - uint32 nrow; + uint32_t nrow; tilesize = TIFFTileSize(tif); buf = (u_char*) _TIFFmalloc(4*tilesize); @@ -351,7 +351,7 @@ gtTileSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h) * Tile is clipped horizontally. Calculate * visible portion and skewing factors. */ - uint32 npix = w - col; + uint32_t npix = w - col; fromskew = tw - npix; (*callback)(img, udata, col, row, npix, nrow, fromskew, r, g, b, a); } else { @@ -370,17 +370,17 @@ gtTileSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h) * SamplesPerPixel == 1 */ static int -gtStripContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h) +gtStripContig(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h) { TIFF* tif = img->tif; ImageIterTileContigRoutine callback = img->callback.contig; - uint16 orientation; - uint32 row, nrow; + uint16_t orientation; + uint32_t row, nrow; u_char* buf; - uint32 rowsperstrip; - uint32 imagewidth = img->width; + uint32_t rowsperstrip; + uint32_t imagewidth = img->width; tsize_t scanline; - int32 fromskew; + int32_t fromskew; buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif)); if (buf == 0) { @@ -409,19 +409,19 @@ gtStripContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h) * We assume that all such images are RGB. */ static int -gtStripSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h) +gtStripSeparate(TIFFImageIter* img, void *udata, uint32_t w, uint32_t h) { TIFF* tif = img->tif; ImageIterTileSeparateRoutine callback = img->callback.separate; - uint16 orientation; + uint16_t orientation; u_char *buf; u_char *r, *g, *b, *a; - uint32 row, nrow; + uint32_t row, nrow; tsize_t scanline; - uint32 rowsperstrip; - uint32 imagewidth = img->width; + uint32_t rowsperstrip; + uint32_t imagewidth = img->width; tsize_t stripsize; - int32 fromskew; + int32_t fromskew; int alpha = img->alpha; stripsize = TIFFStripSize(tif); diff --git a/tiff/contrib/pds/tif_imageiter.h b/tiff/contrib/pds/tif_imageiter.h index 4f4fd279..4f09c1d2 100644 --- a/tiff/contrib/pds/tif_imageiter.h +++ b/tiff/contrib/pds/tif_imageiter.h @@ -8,28 +8,28 @@ typedef struct _TIFFImageIter TIFFImageIter; bits of data. The array pp is ordered in h consecutive rows of w+fromskew pixels each. */ typedef void (*ImageIterTileContigRoutine) - (TIFFImageIter*, void *, uint32, uint32, uint32, uint32, int32, + (TIFFImageIter*, void *, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, unsigned char*); #define DECLAREContigCallbackFunc(name) \ static void name(\ TIFFImageIter* img, \ void* user_data, \ - uint32 x, uint32 y, \ - uint32 w, uint32 h, \ - int32 fromskew, \ + uint32_t x, uint32_t y, \ + uint32_t w, uint32_t h, \ + int32_t fromskew, \ u_char* pp \ ) typedef void (*ImageIterTileSeparateRoutine) - (TIFFImageIter*, void *, uint32, uint32, uint32, uint32, int32, + (TIFFImageIter*, void *, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, unsigned char*, unsigned char*, unsigned char*, unsigned char*); #define DECLARESepCallbackFunc(name) \ static void name(\ TIFFImageIter* img, \ void* user_data, \ - uint32 x, uint32 y, \ - uint32 w, uint32 h,\ - int32 fromskew, \ + uint32_t x, uint32_t y, \ + uint32_t w, uint32_t h,\ + int32_t fromskew, \ u_char* r, u_char* g, u_char* b, u_char* a\ ) @@ -38,17 +38,17 @@ struct _TIFFImageIter { int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap palette */ - uint16* greencmap; - uint16* bluecmap; + uint32_t width; /* image width */ + uint32_t height; /* image height */ + uint16_t bitspersample; /* image bits/sample */ + uint16_t samplesperpixel; /* image samples/pixel */ + uint16_t orientation; /* image orientation */ + uint16_t photometric; /* image photometric interp */ + uint16_t* redcmap; /* colormap palette */ + uint16_t* greencmap; + uint16_t* bluecmap; /* get image data routine */ - int (*get)(TIFFImageIter*, void *udata, uint32, uint32); + int (*get)(TIFFImageIter*, void *udata, uint32_t, uint32_t); union { void (*any)(TIFFImageIter*); ImageIterTileContigRoutine contig; diff --git a/tiff/contrib/pds/tif_pdsdirread.c b/tiff/contrib/pds/tif_pdsdirread.c index cc6231da..19fccb38 100644 --- a/tiff/contrib/pds/tif_pdsdirread.c +++ b/tiff/contrib/pds/tif_pdsdirread.c @@ -55,13 +55,13 @@ #define TIFFCvtIEEEFloatToNative(tif, n, fp) #define TIFFCvtIEEEDoubleToNative(tif, n, dp) #else -extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); -extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); +extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32_t, float*); +extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32_t, double*); #endif -static void EstimateStripByteCounts(TIFF*, TIFFDirEntry*, uint16); +static void EstimateStripByteCounts(TIFF*, TIFFDirEntry*, uint16_t); static void MissingRequired(TIFF*, const char*); -static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); +static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32_t); static tsize_t TIFFFetchData(TIFF*, TIFFDirEntry*, char*); static tsize_t TIFFFetchString(TIFF*, TIFFDirEntry*, char*); static float TIFFFetchRational(TIFF*, TIFFDirEntry*); @@ -69,8 +69,8 @@ static int TIFFFetchNormalSubTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*, int (*getFieldFn)(TIFF *tif,ttag_t tag,...)); static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, int*); static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*); -static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**); +static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16_t*); +static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32_t**); static int TIFFFetchExtraSamples(TIFF*, TIFFDirEntry*); static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*); static float TIFFFetchFloat(TIFF*, TIFFDirEntry*); @@ -126,8 +126,8 @@ TIFFReadPrivateDataSubDirectory(TIFF* tif, toff_t pdir_offset, double dv; const TIFFFieldInfo* fip; int fix; - uint16 dircount; - uint32 nextdiroff; + uint16_t dircount; + uint32_t nextdiroff; char* cp; int diroutoforderwarning = 0; @@ -139,7 +139,7 @@ TIFFReadPrivateDataSubDirectory(TIFF* tif, toff_t pdir_offset, "Seek error accessing TIFF private subdirectory"); return (0); } - if (!ReadOK(tif, &dircount, sizeof (uint16))) { + if (!ReadOK(tif, &dircount, sizeof (uint16_t))) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Can not read TIFF private subdirectory count"); return (0); @@ -157,7 +157,7 @@ TIFFReadPrivateDataSubDirectory(TIFF* tif, toff_t pdir_offset, /* * Read offset to next directory for sequential scans. */ - (void) ReadOK(tif, &nextdiroff, sizeof (uint32)); + (void) ReadOK(tif, &nextdiroff, sizeof (uint32_t)); } else { toff_t off = pdir_offset; @@ -166,8 +166,8 @@ TIFFReadPrivateDataSubDirectory(TIFF* tif, toff_t pdir_offset, "Can not read TIFF private subdirectory count"); return (0); } else - _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof (uint16)); - off += sizeof (uint16); + _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof (uint16_t)); + off += sizeof (uint16_t); if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); dir = (TIFFDirEntry *)CheckMalloc(tif, @@ -181,8 +181,8 @@ TIFFReadPrivateDataSubDirectory(TIFF* tif, toff_t pdir_offset, _TIFFmemcpy(dir, tif->tif_base + off, dircount*sizeof (TIFFDirEntry)); off += dircount* sizeof (TIFFDirEntry); - if (off + sizeof (uint32) < tif->tif_size) - _TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof (uint32)); + if (off + sizeof (uint32_t) < tif->tif_size) + _TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof (uint32_t)); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&nextdiroff); @@ -260,9 +260,9 @@ TIFFReadPrivateDataSubDirectory(TIFF* tif, toff_t pdir_offset, * Check count if known in advance. */ if (fip->field_readcount != TIFF_VARIABLE) { - uint32 expected = (fip->field_readcount == TIFF_SPP) ? - (uint32) td->td_samplesperpixel : - (uint32) fip->field_readcount; + uint32_t expected = (fip->field_readcount == TIFF_SPP) ? + (uint32_t) td->td_samplesperpixel : + (uint32_t) fip->field_readcount; if (!CheckDirCount(tif, dp, expected)) goto ignore; } @@ -283,29 +283,29 @@ bad: } static void -EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) +EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount) { register TIFFDirEntry *dp; register TIFFDirectory *td = &tif->tif_dir; - uint16 i; + uint16_t i; if (td->td_stripbytecount) _TIFFfree(td->td_stripbytecount); - td->td_stripbytecount = (uint32*) - CheckMalloc(tif, td->td_nstrips * sizeof (uint32), + td->td_stripbytecount = (uint32_t*) + CheckMalloc(tif, td->td_nstrips * sizeof (uint32_t), "for \"StripByteCounts\" array"); if (td->td_compression != COMPRESSION_NONE) { - uint32 space = (uint32)(sizeof (TIFFHeader) - + sizeof (uint16) + uint32_t space = (uint32_t)(sizeof (TIFFHeader) + + sizeof (uint16_t) + (dircount * sizeof (TIFFDirEntry)) - + sizeof (uint32)); + + sizeof (uint32_t)); toff_t filesize = TIFFGetFileSize(tif); - uint16 n; + uint16_t n; /* calculate amount of space used by indirect values */ for (dp = dir, n = dircount; n > 0; n--, dp++) { - uint32 cc = dp->tdir_count*TIFFDataWidth(dp->tdir_type); - if (cc > sizeof (uint32)) + uint32_t cc = dp->tdir_count*TIFFDataWidth(dp->tdir_type); + if (cc > sizeof (uint32_t)) space += cc; } space = (filesize - space) / td->td_samplesperpixel; @@ -323,8 +323,8 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) td->td_stripbytecount[i] = filesize - td->td_stripoffset[i]; } else { - uint32 rowbytes = TIFFScanlineSize(tif); - uint32 rowsperstrip = td->td_imagelength / td->td_nstrips; + uint32_t rowbytes = TIFFScanlineSize(tif); + uint32_t rowsperstrip = td->td_imagelength / td->td_nstrips; for (i = 0; i < td->td_nstrips; i++) td->td_stripbytecount[i] = rowbytes*rowsperstrip; } @@ -347,7 +347,7 @@ MissingRequired(TIFF* tif, const char* tagname) * there is a mismatch. */ static int -CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) +CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32_t count) { if (count != dir->tdir_count) { TIFFWarning(tif->tif_name, @@ -382,16 +382,16 @@ TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp) switch (dir->tdir_type) { case TIFF_SHORT: case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); + TIFFSwabArrayOfShort((uint16_t*) cp, dir->tdir_count); break; case TIFF_LONG: case TIFF_SLONG: case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); + TIFFSwabArrayOfLong((uint32_t*) cp, dir->tdir_count); break; case TIFF_RATIONAL: case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); + TIFFSwabArrayOfLong((uint32_t*) cp, 2*dir->tdir_count); break; case TIFF_DOUBLE: TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); @@ -412,7 +412,7 @@ static tsize_t TIFFFetchString(TIFF* tif, TIFFDirEntry* dir, char* cp) { if (dir->tdir_count <= 4) { - uint32 l = dir->tdir_offset; + uint32_t l = dir->tdir_offset; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&l); _TIFFmemcpy(cp, &l, dir->tdir_count); @@ -425,7 +425,7 @@ TIFFFetchString(TIFF* tif, TIFFDirEntry* dir, char* cp) * Convert numerator+denominator to float. */ static int -cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv) +cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32_t num, uint32_t denom, float* rv) { if (denom == 0) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, @@ -436,7 +436,7 @@ cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv) if (dir->tdir_type == TIFF_RATIONAL) *rv = ((float)num / (float)denom); else - *rv = ((float)(int32)num / (float)(int32)denom); + *rv = ((float)(int32_t)num / (float)(int32_t)denom); return (1); } } @@ -449,7 +449,7 @@ cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv) static float TIFFFetchRational(TIFF* tif, TIFFDirEntry* dir) { - uint32 l[2]; + uint32_t l[2]; float v; return (!TIFFFetchData(tif, dir, (char *)l) || @@ -473,12 +473,12 @@ TIFFFetchFloat(TIFF* tif, TIFFDirEntry* dir) TIFFCvtIEEEFloatToNative(tif, 1, &v); #else float v; - /* This is a little bit tricky - if we just cast the uint32 to a float, + /* This is a little bit tricky - if we just cast the uint32_t to a float, C will perform a numerical conversion, which is not what we want. - We want to take the actual bit pattern in the uint32 and interpret - it as a float. Thus we cast a uint32 * into a float * and then + We want to take the actual bit pattern in the uint32_t and interpret + it as a float. Thus we cast a uint32_t * into a float * and then dereference to get v. */ - uint32 l = (uint32) + uint32_t l = (uint32_t) TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); v = * (float *) &l; TIFFCvtIEEEFloatToNative(tif, 1, &v); @@ -491,7 +491,7 @@ TIFFFetchFloat(TIFF* tif, TIFFDirEntry* dir) * Fetch an array of BYTE or SBYTE values. */ static int -TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) +TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16_t* v) { if (dir->tdir_count <= 4) { /* @@ -521,7 +521,7 @@ TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) * Fetch an array of SHORT or SSHORT values. */ static int -TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) +TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16_t* v) { if (dir->tdir_count <= 2) { if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { @@ -546,7 +546,7 @@ TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) static int TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir) { - uint16 v[2]; + uint16_t v[2]; int ok = 0; switch (dir->tdir_type) { @@ -568,7 +568,7 @@ TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir) * Fetch an array of LONG or SLONG values. */ static int -TIFFFetchLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v) +TIFFFetchLongArray(TIFF* tif, TIFFDirEntry* dir, uint32_t* v) { if (dir->tdir_count == 1) { v[0] = dir->tdir_offset; @@ -584,14 +584,14 @@ static int TIFFFetchRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v) { int ok = 0; - uint32* l; + uint32_t* l; - l = (uint32*)CheckMalloc(tif, + l = (uint32_t*)CheckMalloc(tif, dir->tdir_count*TIFFDataWidth(dir->tdir_type), "to fetch array of rationals"); if (l) { if (TIFFFetchData(tif, dir, (char *)l)) { - uint32 i; + uint32_t i; for (i = 0; i < dir->tdir_count; i++) { ok = cvtRational(tif, dir, l[2*i+0], l[2*i+1], &v[i]); @@ -654,42 +654,42 @@ TIFFFetchAnyArray(TIFF* tif, TIFFDirEntry* dir, double* v) switch (dir->tdir_type) { case TIFF_BYTE: case TIFF_SBYTE: - if (!TIFFFetchByteArray(tif, dir, (uint16*) v)) + if (!TIFFFetchByteArray(tif, dir, (uint16_t*) v)) return (0); if (dir->tdir_type == TIFF_BYTE) { - uint16* vp = (uint16*) v; + uint16_t* vp = (uint16_t*) v; for (i = dir->tdir_count-1; i >= 0; i--) v[i] = vp[i]; } else { - int16* vp = (int16*) v; + int16_t* vp = (int16_t*) v; for (i = dir->tdir_count-1; i >= 0; i--) v[i] = vp[i]; } break; case TIFF_SHORT: case TIFF_SSHORT: - if (!TIFFFetchShortArray(tif, dir, (uint16*) v)) + if (!TIFFFetchShortArray(tif, dir, (uint16_t*) v)) return (0); if (dir->tdir_type == TIFF_SHORT) { - uint16* vp = (uint16*) v; + uint16_t* vp = (uint16_t*) v; for (i = dir->tdir_count-1; i >= 0; i--) v[i] = vp[i]; } else { - int16* vp = (int16*) v; + int16_t* vp = (int16_t*) v; for (i = dir->tdir_count-1; i >= 0; i--) v[i] = vp[i]; } break; case TIFF_LONG: case TIFF_SLONG: - if (!TIFFFetchLongArray(tif, dir, (uint32*) v)) + if (!TIFFFetchLongArray(tif, dir, (uint32_t*) v)) return (0); if (dir->tdir_type == TIFF_LONG) { - uint32* vp = (uint32*) v; + uint32_t* vp = (uint32_t*) v; for (i = dir->tdir_count-1; i >= 0; i--) v[i] = vp[i]; } else { - int32* vp = (int32*) v; + int32_t* vp = (int32_t*) v; for (i = dir->tdir_count-1; i >= 0; i--) v[i] = vp[i]; } @@ -747,20 +747,20 @@ TIFFFetchNormalSubTag(TIFF* tif, TIFFDirEntry* dp, const TIFFFieldInfo* fip, case TIFF_SBYTE: /* NB: always expand BYTE values to shorts */ cp = CheckMalloc(tif, - dp->tdir_count * sizeof (uint16), mesg); - ok = cp && TIFFFetchByteArray(tif, dp, (uint16*) cp); + dp->tdir_count * sizeof (uint16_t), mesg); + ok = cp && TIFFFetchByteArray(tif, dp, (uint16_t*) cp); break; case TIFF_SHORT: case TIFF_SSHORT: cp = CheckMalloc(tif, - dp->tdir_count * sizeof (uint16), mesg); - ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp); + dp->tdir_count * sizeof (uint16_t), mesg); + ok = cp && TIFFFetchShortArray(tif, dp, (uint16_t*) cp); break; case TIFF_LONG: case TIFF_SLONG: cp = CheckMalloc(tif, - dp->tdir_count * sizeof (uint32), mesg); - ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp); + dp->tdir_count * sizeof (uint32_t), mesg); + ok = cp && TIFFFetchLongArray(tif, dp, (uint32_t*) cp); break; case TIFF_RATIONAL: case TIFF_SRATIONAL: @@ -804,9 +804,9 @@ TIFFFetchNormalSubTag(TIFF* tif, TIFFDirEntry* dp, const TIFFFieldInfo* fip, case TIFF_SSHORT: /* * If the tag is also acceptable as a LONG or SLONG - * then (*setFieldFn) will expect an uint32 parameter + * then (*setFieldFn) will expect an uint32_t parameter * passed to it (through varargs). Thus, for machines - * where sizeof (int) != sizeof (uint32) we must do + * where sizeof (int) != sizeof (uint32_t) we must do * a careful check here. It's hard to say if this * is worth optimizing. * @@ -817,7 +817,7 @@ TIFFFetchNormalSubTag(TIFF* tif, TIFFDirEntry* dp, const TIFFFieldInfo* fip, */ { TIFFDataType type = fip->field_type; if (type != TIFF_LONG && type != TIFF_SLONG) { - uint16 v = (uint16) + uint16_t v = (uint16_t) TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); ok = (fip->field_passcount ? (*setFieldFn)(tif, dp->tdir_tag, 1, &v) @@ -828,7 +828,7 @@ TIFFFetchNormalSubTag(TIFF* tif, TIFFDirEntry* dp, const TIFFFieldInfo* fip, /* fall through... */ case TIFF_LONG: case TIFF_SLONG: - { uint32 v32 = + { uint32_t v32 = TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); ok = (fip->field_passcount ? (*setFieldFn)(tif, dp->tdir_tag, 1, &v32) @@ -885,12 +885,12 @@ TIFFFetchPerSampleShorts(TIFF* tif, TIFFDirEntry* dir, int* pl) int samples = tif->tif_dir.td_samplesperpixel; int status = 0; - if (CheckDirCount(tif, dir, (uint32) samples)) { - uint16 buf[10]; - uint16* v = buf; + if (CheckDirCount(tif, dir, (uint32_t) samples)) { + uint16_t buf[10]; + uint16_t* v = buf; if (samples > NITEMS(buf)) - v = (uint16*) _TIFFmalloc(samples * sizeof (uint16)); + v = (uint16_t*) _TIFFmalloc(samples * sizeof (uint16_t)); if (TIFFFetchShortArray(tif, dir, v)) { int i; for (i = 1; i < samples; i++) @@ -921,7 +921,7 @@ TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl) int samples = (int) tif->tif_dir.td_samplesperpixel; int status = 0; - if (CheckDirCount(tif, dir, (uint32) samples)) { + if (CheckDirCount(tif, dir, (uint32_t) samples)) { double buf[10]; double* v = buf; @@ -953,31 +953,31 @@ TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl) * in fact it's also used for tiles. */ static int -TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp) +TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32_t** lpp) { - register uint32* lp; + register uint32_t* lp; int status; - if (!CheckDirCount(tif, dir, (uint32) nstrips)) + if (!CheckDirCount(tif, dir, (uint32_t) nstrips)) return (0); /* * Allocate space for strip information. */ if (*lpp == NULL && - (*lpp = (uint32 *)CheckMalloc(tif, - nstrips * sizeof (uint32), "for strip array")) == NULL) + (*lpp = (uint32_t *)CheckMalloc(tif, + nstrips * sizeof (uint32_t), "for strip array")) == NULL) return (0); lp = *lpp; if (dir->tdir_type == (int)TIFF_SHORT) { /* - * Handle uint16->uint32 expansion. + * Handle uint16_t->uint32_t expansion. */ - uint16* dp = (uint16*) CheckMalloc(tif, - dir->tdir_count* sizeof (uint16), "to fetch strip tag"); + uint16_t* dp = (uint16_t*) CheckMalloc(tif, + dir->tdir_count* sizeof (uint16_t), "to fetch strip tag"); if (dp == NULL) return (0); if (status = TIFFFetchShortArray(tif, dir, dp)) { - register uint16* wp = dp; + register uint16_t* wp = dp; while (nstrips-- > 0) *lp++ = *wp++; } @@ -994,12 +994,12 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp) static int TIFFFetchExtraSamples(TIFF* tif, TIFFDirEntry* dir) { - uint16 buf[10]; - uint16* v = buf; + uint16_t buf[10]; + uint16_t* v = buf; int status; if (dir->tdir_count > NITEMS(buf)) - v = (uint16*) _TIFFmalloc(dir->tdir_count * sizeof (uint16)); + v = (uint16_t*) _TIFFmalloc(dir->tdir_count * sizeof (uint16_t)); if (dir->tdir_type == TIFF_BYTE) status = TIFFFetchByteArray(tif, dir, v); else @@ -1028,14 +1028,14 @@ TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir) /* * Handle LONG's for backward compatibility. */ - cp = CheckMalloc(tif, dir->tdir_count * sizeof (uint32), mesg); - if (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) { + cp = CheckMalloc(tif, dir->tdir_count * sizeof (uint32_t), mesg); + if (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32_t*) cp))) { float* fp = (float*) CheckMalloc(tif, dir->tdir_count * sizeof (float), mesg); if (ok = (fp != NULL)) { - uint32 i; + uint32_t i; for (i = 0; i < dir->tdir_count; i++) - fp[i] = (float)((uint32*) cp)[i]; + fp[i] = (float)((uint32_t*) cp)[i]; ok = TIFFSetField(tif, dir->tdir_tag, fp); _TIFFfree((char*) fp); } @@ -1058,12 +1058,12 @@ static void ChopUpSingleUncompressedStrip(TIFF* tif) { register TIFFDirectory *td = &tif->tif_dir; - uint32 bytecount = td->td_stripbytecount[0]; - uint32 offset = td->td_stripoffset[0]; + uint32_t bytecount = td->td_stripbytecount[0]; + uint32_t offset = td->td_stripoffset[0]; tsize_t rowbytes = TIFFVTileSize(tif, 1), stripbytes; tstrip_t strip, nstrips, rowsperstrip; - uint32* newcounts; - uint32* newoffsets; + uint32_t* newcounts; + uint32_t* newoffsets; /* * Make the rows hold at least one @@ -1080,9 +1080,9 @@ ChopUpSingleUncompressedStrip(TIFF* tif) if (rowsperstrip >= td->td_rowsperstrip) return; nstrips = (tstrip_t) TIFFhowmany(bytecount, stripbytes); - newcounts = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32), + newcounts = (uint32_t*) CheckMalloc(tif, nstrips * sizeof (uint32_t), "for chopped \"StripByteCounts\" array"); - newoffsets = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32), + newoffsets = (uint32_t*) CheckMalloc(tif, nstrips * sizeof (uint32_t), "for chopped \"StripOffsets\" array"); if (newcounts == NULL || newoffsets == NULL) { /* diff --git a/tiff/contrib/pds/tif_pdsdirwrite.c b/tiff/contrib/pds/tif_pdsdirwrite.c index a670bda1..9e51bfbd 100644 --- a/tiff/contrib/pds/tif_pdsdirwrite.c +++ b/tiff/contrib/pds/tif_pdsdirwrite.c @@ -63,31 +63,31 @@ #define TIFFCvtNativeToIEEEFloat(tif, n, fp) #define TIFFCvtNativeToIEEEDouble(tif, n, dp) #else -extern void TIFFCvtNativeToIEEEFloat(TIFF*, uint32, float*); -extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*); +extern void TIFFCvtNativeToIEEEFloat(TIFF*, uint32_t, float*); +extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32_t, double*); #endif static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*); static int TIFFWriteNormalSubTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*, int (*getFieldFn)(TIFF *tif,ttag_t tag,...)); -static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32); +static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32_t); static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*); static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*); static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*); -static int TIFFWriteShortTable(TIFF*, ttag_t, TIFFDirEntry*, uint32, uint16**); +static int TIFFWriteShortTable(TIFF*, ttag_t, TIFFDirEntry*, uint32_t, uint16_t**); static int TIFFWriteShortArray(TIFF*, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint16*); + TIFFDataType, ttag_t, TIFFDirEntry*, uint32_t, uint16_t*); static int TIFFWriteLongArray(TIFF *, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint32*); + TIFFDataType, ttag_t, TIFFDirEntry*, uint32_t, uint32_t*); static int TIFFWriteRationalArray(TIFF *, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*); + TIFFDataType, ttag_t, TIFFDirEntry*, uint32_t, float*); static int TIFFWriteFloatArray(TIFF *, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*); + TIFFDataType, ttag_t, TIFFDirEntry*, uint32_t, float*); static int TIFFWriteDoubleArray(TIFF *, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*); + TIFFDataType, ttag_t, TIFFDirEntry*, uint32_t, double*); static int TIFFWriteByteArray(TIFF*, TIFFDirEntry*, char*); static int TIFFWriteAnyArray(TIFF*, - TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*); + TIFFDataType, ttag_t, TIFFDirEntry*, uint32_t, double*); #ifdef COLORIMETRY_SUPPORT static int TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*); #endif @@ -124,7 +124,7 @@ static int TIFFWriteRational(TIFF*, the main, standard TIFF directories that does not apply to special private subdirectories, so such a reimplementation for the sake of eliminating redundant or duplicate code is probably not possible, - unless we also pass in a Main flag to indiciate which type of handling + unless we also pass in a Main flag to indicate which type of handling to do, which would be kind of a hack. I've marked those places where I changed or ripped out code which would have to be re-inserted to generalize this function. If it can be done in a clean and graceful way, @@ -138,14 +138,14 @@ static int TIFFWriteRational(TIFF*, */ toff_t TIFFWritePrivateDataSubDirectory(TIFF* tif, - uint32 pdir_fieldsset[], int pdir_fields_last, + uint32_t pdir_fieldsset[], int pdir_fields_last, TIFFFieldInfo *field_info, int (*getFieldFn)(TIFF *tif, ttag_t tag, ...)) { - uint16 dircount; - uint32 diroff, nextdiroff; + uint16_t dircount; + uint32_t diroff, nextdiroff; ttag_t tag; - uint32 nfields; + uint32_t nfields; tsize_t dirsize; char* data; TIFFDirEntry* dir; @@ -188,7 +188,7 @@ TIFFWritePrivateDataSubDirectory(TIFF* tif, tif->tif_dataoff =(TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1; diroff = tif->tif_dataoff; tif->tif_dataoff = (toff_t)( - diroff + sizeof (uint16) + dirsize + sizeof (toff_t)); + diroff + sizeof (uint16_t) + dirsize + sizeof (toff_t)); if (tif->tif_dataoff & 1) tif->tif_dataoff++; (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); @@ -204,9 +204,9 @@ TIFFWritePrivateDataSubDirectory(TIFF* tif, * why the original code calls ResetFieldBit(), since we're already * going through the fields in order... * - * fields_size is the number of uint32's we will need to hold the + * fields_size is the number of uint32_t's we will need to hold the * bit-mask for all of the fields. If our highest field number is - * 100, then we'll need 100 / (8*4)+1 == 4 uint32's to hold the + * 100, then we'll need 100 / (8*4)+1 == 4 uint32_t's to hold the * fieldset. * * Unlike the original code, we allocate fields dynamically based @@ -214,9 +214,9 @@ TIFFWritePrivateDataSubDirectory(TIFF* tif, * data subdirectories to contain more than the built-in code's limit * of 95 tags in a directory. */ - fields_size = pdir_fields_last / (8*sizeof(uint32)) + 1; - fields = _TIFFmalloc(fields_size*sizeof(uint32)); - _TIFFmemcpy(fields, pdir_fieldsset, fields_size * sizeof(uint32)); + fields_size = pdir_fields_last / (8*sizeof(uint32_t)) + 1; + fields = _TIFFmalloc(fields_size*sizeof(uint32_t)); + _TIFFmemcpy(fields, pdir_fieldsset, fields_size * sizeof(uint32_t)); /* Deleted "write out extra samples tag" code here. */ @@ -243,7 +243,7 @@ TIFFWritePrivateDataSubDirectory(TIFF* tif, /* * Write directory. */ - dircount = (uint16) nfields; + dircount = (uint16_t) nfields; /* Deleted code to link to the next directory - we set it to zero! */ nextdiroff = 0; if (tif->tif_flags & TIFF_SWAB) { @@ -261,7 +261,7 @@ TIFFWritePrivateDataSubDirectory(TIFF* tif, TIFFSwabArrayOfShort(&dir->tdir_tag, 2); TIFFSwabArrayOfLong(&dir->tdir_count, 2); } - dircount = (uint16) nfields; + dircount = (uint16_t) nfields; TIFFSwabShort(&dircount); TIFFSwabLong(&nextdiroff); } @@ -296,7 +296,7 @@ TIFFWritePrivateDataSubDirectory(TIFF* tif, */ TIFFDefaultDirectory(tif); tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; + tif->tif_row = (uint32_t) -1; tif->tif_curstrip = (tstrip_t) -1; #endif @@ -328,7 +328,7 @@ TIFFWriteNormalSubTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip, case TIFF_SHORT: case TIFF_SSHORT: if (wc > 1) { - uint16* wp; + uint16_t* wp; if (wc == (u_short) TIFF_VARIABLE) { (*getFieldFn)(tif, fip->field_tag, &wc, &wp); dir->tdir_count = wc; @@ -337,7 +337,7 @@ TIFFWriteNormalSubTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip, if (!WRITEF(TIFFWriteShortArray, wp)) return (0); } else { - uint16 sv; + uint16_t sv; (*getFieldFn)(tif, fip->field_tag, &sv); dir->tdir_offset = TIFFInsertData(tif, dir->tdir_type, sv); @@ -346,7 +346,7 @@ TIFFWriteNormalSubTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip, case TIFF_LONG: case TIFF_SLONG: if (wc > 1) { - uint32* lp; + uint32_t* lp; if (wc == (u_short) TIFF_VARIABLE) { (*getFieldFn)(tif, fip->field_tag, &wc, &lp); dir->tdir_count = wc; @@ -445,7 +445,7 @@ TIFFWriteNormalSubTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip, case TIFF_ASCII: { char* cp; (*getFieldFn)(tif, fip->field_tag, &cp); - dir->tdir_count = (uint32) (strlen(cp) + 1); + dir->tdir_count = (uint32_t) (strlen(cp) + 1); if (!TIFFWriteByteArray(tif, dir, cp)) return (0); } @@ -475,7 +475,7 @@ TIFFWriteNormalSubTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip, * or LONG type according to the value. */ static void -TIFFSetupShortLong(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint32 v) +TIFFSetupShortLong(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint32_t v) { dir->tdir_tag = tag; dir->tdir_count = 1; @@ -512,12 +512,12 @@ TIFFWriteRational(TIFF* tif, static int TIFFWritePerSampleShorts(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) { - uint16 buf[10], v; - uint16* w = buf; + uint16_t buf[10], v; + uint16_t* w = buf; int i, status, samples = tif->tif_dir.td_samplesperpixel; if (samples > NITEMS(buf)) - w = (uint16*) _TIFFmalloc(samples * sizeof (uint16)); + w = (uint16_t*) _TIFFmalloc(samples * sizeof (uint16_t)); TIFFGetField(tif, tag, &v); for (i = 0; i < samples; i++) w[i] = v; @@ -560,7 +560,7 @@ TIFFWritePerSampleAnys(TIFF* tif, static int TIFFSetupShortPair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) { - uint16 v[2]; + uint16_t v[2]; TIFFGetField(tif, tag, &v[0], &v[1]); return (TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, 2, v)); @@ -573,14 +573,14 @@ TIFFSetupShortPair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) */ static int TIFFWriteShortTable(TIFF* tif, - ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16** table) + ttag_t tag, TIFFDirEntry* dir, uint32_t n, uint16_t** table) { - uint32 i, off; + uint32_t i, off; dir->tdir_tag = tag; dir->tdir_type = (short) TIFF_SHORT; /* XXX -- yech, fool TIFFWriteData */ - dir->tdir_count = (uint32) (1L<<tif->tif_dir.td_bitspersample); + dir->tdir_count = (uint32_t) (1L<<tif->tif_dir.td_bitspersample); off = tif->tif_dataoff; for (i = 0; i < n; i++) if (!TIFFWriteData(tif, dir, (char *)table[i])) @@ -610,14 +610,14 @@ TIFFWriteByteArray(TIFF* tif, TIFFDirEntry* dir, char* cp) */ static int TIFFWriteShortArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16* v) + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32_t n, uint16_t* v) { dir->tdir_tag = tag; dir->tdir_type = (short) type; dir->tdir_count = n; if (n <= 2) { if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - dir->tdir_offset = (uint32) ((long) v[0] << 16); + dir->tdir_offset = (uint32_t) ((long) v[0] << 16); if (n == 2) dir->tdir_offset |= v[1] & 0xffff; } else { @@ -636,7 +636,7 @@ TIFFWriteShortArray(TIFF* tif, */ static int TIFFWriteLongArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint32* v) + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32_t n, uint32_t* v) { dir->tdir_tag = tag; dir->tdir_type = (short) type; @@ -654,20 +654,20 @@ TIFFWriteLongArray(TIFF* tif, */ static int TIFFWriteRationalArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v) + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32_t n, float* v) { - uint32 i; - uint32* t; + uint32_t i; + uint32_t* t; int status; dir->tdir_tag = tag; dir->tdir_type = (short) type; dir->tdir_count = n; - t = (uint32*) _TIFFmalloc(2*n * sizeof (uint32)); + t = (uint32_t*) _TIFFmalloc(2*n * sizeof (uint32_t)); for (i = 0; i < n; i++) { float fv = v[i]; int sign = 1; - uint32 den; + uint32_t den; if (fv < 0) { if (type == TIFF_RATIONAL) { @@ -693,14 +693,14 @@ TIFFWriteRationalArray(TIFF* tif, static int TIFFWriteFloatArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v) + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32_t n, float* v) { dir->tdir_tag = tag; dir->tdir_type = (short) type; dir->tdir_count = n; TIFFCvtNativeToIEEEFloat(tif, n, v); if (n == 1) { - dir->tdir_offset = *(uint32*) &v[0]; + dir->tdir_offset = *(uint32_t*) &v[0]; return (1); } else return (TIFFWriteData(tif, dir, (char*) v)); @@ -708,7 +708,7 @@ TIFFWriteFloatArray(TIFF* tif, static int TIFFWriteDoubleArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v) + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32_t n, double* v) { dir->tdir_tag = tag; dir->tdir_type = (short) type; @@ -728,7 +728,7 @@ TIFFWriteDoubleArray(TIFF* tif, */ static int TIFFWriteAnyArray(TIFF* tif, - TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v) + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32_t n, double* v) { char buf[10 * sizeof(double)]; char* w = buf; @@ -760,34 +760,34 @@ TIFFWriteAnyArray(TIFF* tif, } break; case TIFF_SHORT: - { uint16* bp = (uint16*) w; + { uint16_t* bp = (uint16_t*) w; for (i = 0; i < n; i++) - bp[i] = (uint16) v[i]; - if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp)) + bp[i] = (uint16_t) v[i]; + if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16_t*)bp)) goto out; } break; case TIFF_SSHORT: - { int16* bp = (int16*) w; + { int16_t* bp = (int16_t*) w; for (i = 0; i < n; i++) - bp[i] = (int16) v[i]; - if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp)) + bp[i] = (int16_t) v[i]; + if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16_t*)bp)) goto out; } break; case TIFF_LONG: - { uint32* bp = (uint32*) w; + { uint32_t* bp = (uint32_t*) w; for (i = 0; i < n; i++) - bp[i] = (uint32) v[i]; + bp[i] = (uint32_t) v[i]; if (!TIFFWriteLongArray(tif, type, tag, dir, n, bp)) goto out; } break; case TIFF_SLONG: - { int32* bp = (int32*) w; + { int32_t* bp = (int32_t*) w; for (i = 0; i < n; i++) - bp[i] = (int32) v[i]; - if (!TIFFWriteLongArray(tif, type, tag, dir, n, (uint32*) bp)) + bp[i] = (int32_t) v[i]; + if (!TIFFWriteLongArray(tif, type, tag, dir, n, (uint32_t*) bp)) goto out; } break; @@ -821,8 +821,8 @@ static int TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir) { TIFFDirectory* td = &tif->tif_dir; - tsize_t n = (1L<<td->td_bitspersample) * sizeof (uint16); - uint16** tf = td->td_transferfunction; + tsize_t n = (1L<<td->td_bitspersample) * sizeof (uint16_t); + uint16_t** tf = td->td_transferfunction; int ncols; /* @@ -853,16 +853,16 @@ TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp) switch (dir->tdir_type) { case TIFF_SHORT: case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); + TIFFSwabArrayOfShort((uint16_t*) cp, dir->tdir_count); break; case TIFF_LONG: case TIFF_SLONG: case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); + TIFFSwabArrayOfLong((uint32_t*) cp, dir->tdir_count); break; case TIFF_RATIONAL: case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); + TIFFSwabArrayOfLong((uint32_t*) cp, 2*dir->tdir_count); break; case TIFF_DOUBLE: TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); @@ -889,11 +889,11 @@ static int TIFFLinkDirectory(TIFF* tif) { static const char module[] = "TIFFLinkDirectory"; - uint32 nextdir; - uint32 diroff; + uint32_t nextdir; + uint32_t diroff; tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1; - diroff = (uint32) tif->tif_diroff; + diroff = (uint32_t) tif->tif_diroff; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&diroff); #if SUBIFD_SUPPORT @@ -921,7 +921,7 @@ TIFFLinkDirectory(TIFF* tif) /* * First directory, overwrite offset in header. */ - tif->tif_header.tiff_diroff = (uint32) tif->tif_diroff; + tif->tif_header.tiff_diroff = (uint32_t) tif->tif_diroff; #define HDROFF(f) ((toff_t) &(((TIFFHeader*) 0)->f)) (void) TIFFSeekFile(tif, HDROFF(tiff_diroff), SEEK_SET); if (!WriteOK(tif, &diroff, sizeof (diroff))) { @@ -935,7 +935,7 @@ TIFFLinkDirectory(TIFF* tif) */ nextdir = tif->tif_header.tiff_diroff; do { - uint16 dircount; + uint16_t dircount; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, sizeof (dircount))) { diff --git a/tiff/contrib/ras/Makefile.am b/tiff/contrib/ras/Makefile.am index 26617edf..92e124bf 100644 --- a/tiff/contrib/ras/Makefile.am +++ b/tiff/contrib/ras/Makefile.am @@ -24,7 +24,6 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ - CMakeLists.txt \ README \ ras2tif.c \ tif2ras.c diff --git a/tiff/contrib/ras/Makefile.in b/tiff/contrib/ras/Makefile.in index dac37b63..f891cb05 100644 --- a/tiff/contrib/ras/Makefile.in +++ b/tiff/contrib/ras/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -122,8 +122,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -287,6 +289,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -297,7 +300,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ - CMakeLists.txt \ README \ ras2tif.c \ tif2ras.c diff --git a/tiff/contrib/stream/CMakeLists.txt b/tiff/contrib/stream/CMakeLists.txt deleted file mode 100644 index c874ff64..00000000 --- a/tiff/contrib/stream/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# CMake build for libtiff -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Written by Roger Leigh <rleigh@codelibre.net> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -extra_dist( - README - tiffstream.cpp - tiffstream.h) diff --git a/tiff/contrib/stream/Makefile.am b/tiff/contrib/stream/Makefile.am index 0324e865..cd882b32 100644 --- a/tiff/contrib/stream/Makefile.am +++ b/tiff/contrib/stream/Makefile.am @@ -24,7 +24,6 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ - CMakeLists.txt \ README \ tiffstream.cpp \ tiffstream.h diff --git a/tiff/contrib/stream/Makefile.in b/tiff/contrib/stream/Makefile.in index 5f7f1eba..b8bfc6aa 100644 --- a/tiff/contrib/stream/Makefile.in +++ b/tiff/contrib/stream/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -122,8 +122,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -287,6 +289,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -297,7 +300,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ - CMakeLists.txt \ README \ tiffstream.cpp \ tiffstream.h diff --git a/tiff/contrib/tags/Makefile.am b/tiff/contrib/tags/Makefile.am index 67d99679..0bdec678 100644 --- a/tiff/contrib/tags/Makefile.am +++ b/tiff/contrib/tags/Makefile.am @@ -24,7 +24,6 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ - CMakeLists.txt \ README \ listtif.c \ maketif.c \ diff --git a/tiff/contrib/tags/Makefile.in b/tiff/contrib/tags/Makefile.in index 502d8f05..7448a154 100644 --- a/tiff/contrib/tags/Makefile.in +++ b/tiff/contrib/tags/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -122,8 +122,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -287,6 +289,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -297,7 +300,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ - CMakeLists.txt \ README \ listtif.c \ maketif.c \ diff --git a/tiff/contrib/tags/README b/tiff/contrib/tags/README index 3220b7b1..d58a5641 100644 --- a/tiff/contrib/tags/README +++ b/tiff/contrib/tags/README @@ -56,7 +56,7 @@ so that multiple clients may be installed. The TIFFExtendProc method that you define should be used to override the TIFF file's "vsetfield" and "vgetfield" methods, so that you can trap your new, private tags, and install their values into -a private directory structure. For your convienience, a new pointer +a private directory structure. For your convenience, a new pointer has also been added to the "TIFF" file structure: tidata_t tif_clientdir; /* client TIFF directory */ diff --git a/tiff/contrib/tags/maketif.c b/tiff/contrib/tags/maketif.c index e965201a..41ca8859 100644 --- a/tiff/contrib/tags/maketif.c +++ b/tiff/contrib/tags/maketif.c @@ -36,7 +36,7 @@ failure: void SetUpTIFFDirectory(TIFF *tif) { double mymulti[6]={0.0,1.0,2.0, 3.1415926, 5.0,1.0}; - uint32 mysingle=3456; + uint32_t mysingle=3456; char *ascii="This file was produced by Steven Spielberg. NOT"; TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,WIDTH); diff --git a/tiff/contrib/tags/xtif_dir.c b/tiff/contrib/tags/xtif_dir.c index 35295526..628bc415 100644 --- a/tiff/contrib/tags/xtif_dir.c +++ b/tiff/contrib/tags/xtif_dir.c @@ -91,7 +91,7 @@ _XTIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) xtiff *xt = XTIFFDIR(tif); XTIFFDirectory* xd = &xt->xtif_dir; int status = 1; - uint32 v32=0; + uint32_t v32=0; int i=0, v=0; va_list ap1 = ap; @@ -104,12 +104,12 @@ _XTIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) */ case TIFFTAG_EXAMPLE_MULTI: /* multi-valued tags need to store the count as well */ - xd->xd_num_multi = (uint16) va_arg(ap, int); + xd->xd_num_multi = (uint16_t) va_arg(ap, int); _TIFFsetDoubleArray(&xd->xd_example_multi, va_arg(ap, double*), (long) xd->xd_num_multi); break; case TIFFTAG_EXAMPLE_SINGLE: - xd->xd_example_single = va_arg(ap, uint32); + xd->xd_example_single = va_arg(ap, uint32_t); break; case TIFFTAG_EXAMPLE_ASCII: _TIFFsetString(&xd->xd_example_ascii, va_arg(ap, char*)); @@ -162,14 +162,14 @@ _XTIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) * example tags with your own. */ case TIFFTAG_EXAMPLE_MULTI: - *va_arg(ap, uint16*) = xd->xd_num_multi; + *va_arg(ap, uint16_t*) = xd->xd_num_multi; *va_arg(ap, double**) = xd->xd_example_multi; break; case TIFFTAG_EXAMPLE_ASCII: *va_arg(ap, char**) = xd->xd_example_ascii; break; case TIFFTAG_EXAMPLE_SINGLE: - *va_arg(ap, uint32*) = xd->xd_example_single; + *va_arg(ap, uint32_t*) = xd->xd_example_single; break; default: /* return inherited method */ diff --git a/tiff/contrib/tags/xtiffiop.h b/tiff/contrib/tags/xtiffiop.h index 9d534a83..5220e20d 100644 --- a/tiff/contrib/tags/xtiffiop.h +++ b/tiff/contrib/tags/xtiffiop.h @@ -32,9 +32,9 @@ /* XXX - Define Private directory tag structure here */ struct XTIFFDirectory { - uint16 xd_num_multi; /* dir-count for the multi tag */ + uint16_t xd_num_multi; /* dir-count for the multi tag */ double* xd_example_multi; - uint32 xd_example_single; + uint32_t xd_example_single; char* xd_example_ascii; }; typedef struct XTIFFDirectory XTIFFDirectory; @@ -45,7 +45,7 @@ typedef struct XTIFFDirectory XTIFFDirectory; struct xtiff { TIFF *xtif_tif; /* parent TIFF pointer */ - uint32 xtif_flags; + uint32_t xtif_flags; #define XTIFFP_PRINT 0x00000001 XTIFFDirectory xtif_dir; /* internal rep of current directory */ TIFFVSetMethod xtif_vsetfield; /* inherited tag set routine */ diff --git a/tiff/contrib/win_dib/CMakeLists.txt b/tiff/contrib/win_dib/CMakeLists.txt deleted file mode 100644 index 11d124f5..00000000 --- a/tiff/contrib/win_dib/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# CMake build for libtiff -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Written by Roger Leigh <rleigh@codelibre.net> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -extra_dist( - Makefile.w95 - README.Tiffile - README.tiff2dib - Tiffile.cpp - tiff2dib.c) diff --git a/tiff/contrib/win_dib/Makefile.am b/tiff/contrib/win_dib/Makefile.am index 50a1dab0..53ededb1 100644 --- a/tiff/contrib/win_dib/Makefile.am +++ b/tiff/contrib/win_dib/Makefile.am @@ -24,7 +24,6 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ - CMakeLists.txt \ Makefile.w95 \ README.Tiffile \ README.tiff2dib \ diff --git a/tiff/contrib/win_dib/Makefile.in b/tiff/contrib/win_dib/Makefile.in index fa3b2237..d9f40b8e 100644 --- a/tiff/contrib/win_dib/Makefile.in +++ b/tiff/contrib/win_dib/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -122,8 +122,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -287,6 +289,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -297,7 +300,6 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ - CMakeLists.txt \ Makefile.w95 \ README.Tiffile \ README.tiff2dib \ diff --git a/tiff/contrib/win_dib/README.Tiffile b/tiff/contrib/win_dib/README.Tiffile index 82c6e5c4..8645f05c 100644 --- a/tiff/contrib/win_dib/README.Tiffile +++ b/tiff/contrib/win_dib/README.Tiffile @@ -2,7 +2,7 @@ Frank, I attached a file that uses RGBA interface (tif_getimage.c) to read a tiff file and convert to a DIB. It's advantage is that it is easy to read *any* -tiff file suported by libtiff and easily convert it to a DIB. The disadvantage +tiff file supported by libtiff and easily convert it to a DIB. The disadvantage is that bilevel (B&W) bitmaps (and all other non-rgba images) are also converted to RGBA, thus taking up 32x as much memory as needed (4 bytes per pixel, rather than 1 bit). I read tiff files, but don't need to diff --git a/tiff/contrib/win_dib/README.tiff2dib b/tiff/contrib/win_dib/README.tiff2dib index ff70ca1a..75e1254b 100644 --- a/tiff/contrib/win_dib/README.tiff2dib +++ b/tiff/contrib/win_dib/README.tiff2dib @@ -14,7 +14,7 @@ Here is some information that may help someone. I build the library under Windows 95 as a 32-bit library. The contribution of Scott Wagner (tif_win32.c) worked fine, but -the makefile "makefile.msc" was unsable because it was +the makefile "makefile.msc" was unusable because it was written for DOS or Windows 3.1 and all the files names are limited to 8 characters. @@ -38,7 +38,7 @@ I had to : I also join the source file "tif2dib.c" that I created, it contain the function LoadTIFFinDIB that load a TIFF file and build a memory DIB with it and return the -HANDLE (HDIB) of the memory bloc containing this DIB. +HANDLE (HDIB) of the memory block containing this DIB. Since DIB is the "natural" bitmap format for Windows 3.1, 95 and NT, this function should be useful for some Windows 95 (or NT) developer. diff --git a/tiff/contrib/win_dib/Tiffile.cpp b/tiff/contrib/win_dib/Tiffile.cpp index 2f7965d6..27e29b5f 100644 --- a/tiff/contrib/win_dib/Tiffile.cpp +++ b/tiff/contrib/win_dib/Tiffile.cpp @@ -40,7 +40,7 @@ struct TIFFDibImage { HANDLE LoadTIFFinDIB(LPCTSTR lpFileName); -HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32* raster) ; +HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster) ; static void MyWarningHandler(const char* module, const char* fmt, va_list ap) @@ -99,12 +99,12 @@ PVOID ReadTIFF ( LPCTSTR lpszPath ) if (TIFFRGBAImageBegin(&img.tif, tif, -1, emsg)) { size_t npixels; - uint32* raster; + uint32_t* raster; DibInstallHack(&img); npixels = img.tif.width * img.tif.height; - raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); + raster = (uint32_t*) _TIFFmalloc(npixels * sizeof (uint32_t)); if (raster != NULL) { if (TIFFRGBAImageGet(&img.tif, raster, img.tif.width, img.tif.height)) { pDIB = TIFFRGBA2DIB(&img, raster); @@ -128,17 +128,17 @@ PVOID ReadTIFF ( LPCTSTR lpszPath ) -HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32* raster) +HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32_t* raster) { void* pDIB = 0; TIFFRGBAImage* img = &dib->tif; - uint32 imageLength; - uint32 imageWidth; - uint16 BitsPerSample; - uint16 SamplePerPixel; - uint32 RowsPerStrip; - uint16 PhotometricInterpretation; + uint32_t imageLength; + uint32_t imageWidth; + uint16_t BitsPerSample; + uint16_t SamplePerPixel; + uint32_t RowsPerStrip; + uint16_t PhotometricInterpretation; BITMAPINFOHEADER bi; int dwDIBSize ; @@ -273,25 +273,25 @@ typedef unsigned char u_char; #define DECLAREContigPutFunc(name) \ static void name(\ TIFFRGBAImage* img, \ - uint32* cp, \ - uint32 x, uint32 y, \ - uint32 w, uint32 h, \ - int32 fromskew, int32 toskew, \ + uint32_t* cp, \ + uint32_t x, uint32_t y, \ + uint32_t w, uint32_t h, \ + int32_t fromskew, int32_t toskew, \ u_char* pp \ ) #define DECLARESepPutFunc(name) \ static void name(\ TIFFRGBAImage* img,\ - uint32* cp,\ - uint32 x, uint32 y, \ - uint32 w, uint32 h,\ - int32 fromskew, int32 toskew,\ + uint32_t* cp,\ + uint32_t x, uint32_t y, \ + uint32_t w, uint32_t h,\ + int32_t fromskew, int32_t toskew,\ u_char* r, u_char* g, u_char* b, u_char* a\ ) DECLAREContigPutFunc(putContig1bitTile); -static int getStripContig1Bit(TIFFRGBAImage* img, uint32* uraster, uint32 w, uint32 h); +static int getStripContig1Bit(TIFFRGBAImage* img, uint32_t* uraster, uint32_t w, uint32_t h); //typdef struct TIFFDibImage { // TIFFRGBAImage tif; @@ -329,7 +329,7 @@ DECLAREContigPutFunc(putContig1bitTile) int wb = WIDTHBYTES(w); u_char* ucp = (u_char*)cp; - /* Conver 'w' to bytes from pixels (rounded up) */ + /* Convert 'w' to bytes from pixels (rounded up) */ w = (w+7)/8; while (h-- > 0) { @@ -348,11 +348,11 @@ DECLAREContigPutFunc(putContig1bitTile) /* * Hacked from the tif_getimage.c file. */ -static uint32 -setorientation(TIFFRGBAImage* img, uint32 h) +static uint32_t +setorientation(TIFFRGBAImage* img, uint32_t h) { TIFF* tif = img->tif; - uint32 y; + uint32_t y; switch (img->orientation) { case ORIENTATION_BOTRIGHT: @@ -390,22 +390,22 @@ setorientation(TIFFRGBAImage* img, uint32 h) * for 1-bit bitmaps */ static int -getStripContig1Bit(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +getStripContig1Bit(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; - uint16 orientation; - uint32 row, y, nrow, rowstoread; - uint32 pos; + uint16_t orientation; + uint32_t row, y, nrow, rowstoread; + uint32_t pos; u_char* buf; - uint32 rowsperstrip; - uint32 imagewidth = img->width; + uint32_t rowsperstrip; + uint32_t imagewidth = img->width; tsize_t scanline; - int32 fromskew, toskew; + int32_t fromskew, toskew; tstrip_t strip; tsize_t stripsize; u_char* braster = (u_char*)raster; // byte wide raster - uint32 wb = WIDTHBYTES(w); + uint32_t wb = WIDTHBYTES(w); int ret = 1; buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif)); @@ -415,7 +415,7 @@ getStripContig1Bit(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) } y = setorientation(img, h); orientation = img->orientation; - toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? wb+wb : wb-wb); + toskew = -(int32_t) (orientation == ORIENTATION_TOPLEFT ? wb+wb : wb-wb); TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); scanline = TIFFScanlineSize(tif); fromskew = (w < imagewidth ? imagewidth - w : 0)/8; @@ -433,8 +433,8 @@ getStripContig1Bit(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) } pos = ((row + img->row_offset) % rowsperstrip) * scanline; - (*put)(img, (uint32*)(braster+y*wb), 0, y, w, nrow, fromskew, toskew, buf + pos); - y += (orientation == ORIENTATION_TOPLEFT ?-(int32) nrow : (int32) nrow); + (*put)(img, (uint32_t*)(braster+y*wb), 0, y, w, nrow, fromskew, toskew, buf + pos); + y += (orientation == ORIENTATION_TOPLEFT ?-(int32_t) nrow : (int32_t) nrow); } _TIFFfree(buf); return (ret); diff --git a/tiff/contrib/win_dib/tiff2dib.c b/tiff/contrib/win_dib/tiff2dib.c index 2fa2de69..5b9e1747 100644 --- a/tiff/contrib/win_dib/tiff2dib.c +++ b/tiff/contrib/win_dib/tiff2dib.c @@ -4,7 +4,7 @@ * * The function LoadTIFFinDIB in this source file let you load * a TIFF file and build a memory DIB with it and return the - * HANDLE (HDIB) of the memory bloc containing the DIB. + * HANDLE (HDIB) of the memory block containing the DIB. * * Example : * @@ -30,7 +30,7 @@ static HDIB CreateDIB(DWORD dwWidth, DWORD dwHeight, WORD wBitCount); static LPSTR FindDIBBits(LPSTR lpDIB); static WORD PaletteSize(LPSTR lpDIB); static WORD DIBNumColors(LPSTR lpDIB); -static int checkcmap(int n, uint16* r, uint16* g, uint16* b); +static int checkcmap(int n, uint16_t* r, uint16_t* g, uint16_t* b); @@ -49,7 +49,7 @@ static int checkcmap(int n, uint16* r, uint16* g, uint16* b); * Description: * * This function load a TIFF file and build a memory DIB with it - * and return the HANDLE (HDIB) of the memory bloc containing + * and return the HANDLE (HDIB) of the memory block containing * the DIB. * * 4/12/95 Philippe Tenenhaus 100423.3705@compuserve.com @@ -127,10 +127,10 @@ HDIB LoadTIFFinDIB(LPSTR lpFileName) //PhotometricInterpretation = 3 image have a color palette if (PhotometricInterpretation == 3) { - uint16* red; - uint16* green; - uint16* blue; - int16 i; + uint16_t* red; + uint16_t* green; + uint16_t* blue; + int16_t i; LPBITMAPINFO lpbmi; int Palette16Bits; @@ -220,7 +220,7 @@ imageWidth*SamplePerPixel); } -static int checkcmap(int n, uint16* r, uint16* g, uint16* b) +static int checkcmap(int n, uint16_t* r, uint16_t* g, uint16_t* b) { while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) diff --git a/tiff/html/CMakeLists.txt b/tiff/html/CMakeLists.txt index 5f34e1e5..b3317d32 100644 --- a/tiff/html/CMakeLists.txt +++ b/tiff/html/CMakeLists.txt @@ -83,5 +83,3 @@ install(FILES ${docfiles} add_subdirectory(images) add_subdirectory(man) - -extra_dist(${docfiles}) diff --git a/tiff/html/Makefile.am b/tiff/html/Makefile.am index 2929b8ed..2b41f03c 100644 --- a/tiff/html/Makefile.am +++ b/tiff/html/Makefile.am @@ -89,7 +89,8 @@ docfiles = \ v4.0.9.html \ v4.0.10.html \ v4.1.0.html \ - v4.2.0.html + v4.2.0.html \ + v4.3.0.html dist_doc_DATA = $(docfiles) diff --git a/tiff/html/Makefile.in b/tiff/html/Makefile.in index b60e5cfa..b80fdc5b 100644 --- a/tiff/html/Makefile.in +++ b/tiff/html/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -125,8 +125,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ DIST_COMMON = $(srcdir)/Makefile.am $(dist_doc_DATA) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -379,6 +381,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -451,7 +454,8 @@ docfiles = \ v4.0.9.html \ v4.0.10.html \ v4.1.0.html \ - v4.2.0.html + v4.2.0.html \ + v4.3.0.html dist_doc_DATA = $(docfiles) SUBDIRS = images man diff --git a/tiff/html/addingtags.html b/tiff/html/addingtags.html index bd4b972a..7e197e25 100644 --- a/tiff/html/addingtags.html +++ b/tiff/html/addingtags.html @@ -239,7 +239,7 @@ add appropriate handling as follows: <P> If you want to maintain portability, beware of making assumptions -about data types. Use the typedefs (<TT>uint16</TT>, etc. when dealing with +about data types. Use the typedefs (<TT>uint16_t</TT>, etc. when dealing with data on disk and <TT>t*_t</TT> when stuff is in memory) and be careful about passing items through printf or similar vararg interfaces. diff --git a/tiff/html/build.html b/tiff/html/build.html index 4186645b..72a43f22 100644 --- a/tiff/html/build.html +++ b/tiff/html/build.html @@ -14,8 +14,6 @@ Building the Software Distribution</h1> <ul> <li><a href="#CMAKE">Building on all systems with CMake</a>.</li> <li><a href="#UNIX">Building on a UNIX system with Autoconf</a>.</li> -<li><a href="#PC">Building on an MS-DOS or Windows system with nmake</a>.</li> -<li><a href="#VMS">Building on a VMS system</a>.</li> <li><a href="#Other">Building the Software on Other Systems.</a></li> </ul> @@ -424,179 +422,6 @@ configured.</dd> </dl> <hr width="65%" align="right"> <a name="PC" id="PC"></a> -<h2>Building the Software under Windows 2000/XP/7/8/10 with nmake</h2> -With Microsoft Visual C++ installed, and properly configured for -commandline use (you will likely need to source VCVARS32.BAT in -AUTOEXEC.bAT or somewhere similar) you should be able to use the -provided <tt>makefile.vc</tt>. -<p>The source package is delivered using Unix line termination -conventions, which work with MSVC but do not work with Windows -'notepad'. If you use unzip from the <a href= -"http://www.info-zip.org/pub/infozip/">Info-Zip</a> package, you -can extract the files using Windows normal line termination -conventions with a command similar to:</p> -<pre> - unzip -aa -a tiff-4.0.5.zip -</pre> -<p>By default the nmake-based libtiff build does not depend on any -additional libraries. Normally libtiff should be built with at least -JPEG and ZIP support so that it can open JPEG and ZIP-compressed TIFF -files. In order to add additional libraries (e.g. libjpeg, zlib, -jbigkit), build those libraries according to their own particular -build instructions, and then edit 'nmake.opt' (using a capable -plain-text editor) to enable use of the libraries, including -specifying where the libraries are installed. It is also necessary to -edit libtiff/tiffconf.vc.h to enable the related configuration defines -(<em>JPEG_SUPPORT</em>, <em>OJPEG_SUPPORT</em>, <em>PIXARLOG_SUPPORT</em>, -<em>ZIP_SUPPORT</em>), or to disable features which are normally -included by default. Ignore the comment at the top of the -libtiff/tiffconf.vc.h file which says that it has no influence on the -build, because the statement is not true for Windows. Please note that -the nmake build copies tiffconf.vc.h to tiffconf.h, and copies -tif_config.vc.h to tif_config.h, overwriting any files which may be -present. Likewise, the 'nmake clean' step removes those files.</p> -<p>To build using the provided makefile.vc you may use:</p> -<pre> - C:\tiff-4.0.5> nmake /f makefile.vc clean - C:\tiff-4.0.5> nmake /f makefile.vc - - or (the hard way) - - C:\tiff-4.0.5> cd port - C:\tiff-4.0.5\port> nmake /f makefile.vc clean - C:\tiff-4.0.5\port> nmake /f makefile.vc - C:\tiff-4.0.5> cd ../libtiff - C:\tiff-4.0.5\libtiff> nmake /f makefile.vc clean - C:\tiff-4.0.5\libtiff> nmake /f makefile.vc - C:\tiff-4.0.5\libtiff> cd ..\tools - C:\tiff-4.0.5\tools> nmake /f makefile.vc clean - C:\tiff-4.0.5\tools> nmake /f makefile.vc -</pre> -<p>This will build the library -file <tt>libtiff\libtiff\libtiff.lib</tt>.</p> -<p>The makefile also builds a DLL (libtiff.dll) with an associated -import library (libtiff_i.lib). Any builds using libtiff will need to -include the LIBTIFF\LIBTIFF directory in the include path.</p> -<p>The <tt>libtiff\tools\makefile.vc</tt> should build .exe's for -all the standard TIFF tool programs.</p> -<hr> -<a name="VMS" id="VMS"></a> -<h2>Building the Software on a VMS System</h2> -The VMS port was done by Karsten Spang (<a href= -"mailto:krs@kampsax.dk">krs@kampsax.dk</a>), who also "sort of" -maintains it. The VMS specific files are not in the main -directories. Instead they are placed under -<tt>[.CONTRIB.VMS...]</tt> in the distribution tree. Installation: -It is assumed that you have unpacked the tar file into a VMS -directory tree, in this text called DISK:[TIFF]. -<ol> -<li>Move the VMS specific files to their proper directories. -<pre> -$ SET DEFAULT DISK:[TIFF.CONTRIB.VMS] -$ RENAME [.LIBTIFF]*.* [-.-.LIBTIFF] -$ RENAME [.TOOLS]*.* [-.-.TOOLS] -</pre></li> -<li>Compile the library. -<pre> -$ SET DEFAULT DISK:[TIFF.LIBTIFF] -$ @MAKEVMS -</pre></li> -<li>Compile the tools. -<pre> -$ SET DEFAULT DISK:[TIFF.TOOLS] -$ @MAKEVMS -</pre></li> -<li>Define the programs. -<pre> -$ DEFINE TIFFSHR DISK:[TIFF.LIBTIFF]TIFFSHR -$ FAX2PS :==$DISK:[TIFF.TOOLS]FAX2PS -$ FAX2TIFF :==$DISK:[TIFF.TOOLS]FAX2TIFF -$ GIF2TIFF :==$DISK:[TIFF.TOOLS]GIF2TIFF -$ PAL2RGB :==$DISK:[TIFF.TOOLS]PAL2RGB -$ PPM2TIFF :==$DISK:[TIFF.TOOLS]PPM2TIFF -$ RAS2TIFF :==$DISK:[TIFF.TOOLS]RAS2TIFF -$ RGB2YCBCR :==$DISK:[TIFF.TOOLS]RGB2YCBCR -$ THUMBNAIL :==$DISK:[TIFF.TOOLS]THUMBNAIL -$ TIFF2BW :==$DISK:[TIFF.TOOLS]TIFF2BW -$ TIFF2PS :==$DISK:[TIFF.TOOLS]TIFF2PS -$ TIFFCMP :==$DISK:[TIFF.TOOLS]TIFFCMP -$ TIFFCP :==$DISK:[TIFF.TOOLS]TIFFCP -$ TIFFDITHER:==$DISK:[TIFF.TOOLS]TIFFDITHER -$ TIFFDUMP :==$DISK:[TIFF.TOOLS]TIFFDUMP -$ TIFFINFO :==$DISK:[TIFF.TOOLS]TIFFINFO -$ TIFFMEDIAN:==$DISK:[TIFF.TOOLS]TIFFMEDIAN -$ TIFFSPLIT :==$DISK:[TIFF.TOOLS]TIFFSPLIT -$ YCBCR :==$DISK:[TIFF.TOOLS]YCBCR -</pre></li> -</ol> -You will want to add these lines to your <tt>LOGIN.COM</tt> file, -after changing the name of the directory that you have used on your -machine. -<p>This release has been tested on OpenVMS/VAX 5.5-2, using VAX C -3.2. A previous release was tested under OpenVMS/AXP ?.? using DEC -C ?.?, it is believed that this release as well works on AXP. The -code contains some GNU C specific things. This does *not* imply, -however, that the VAX/GCC configuration has been tested, *it has -not*.</p> -<p>The command procedures (<tt>MAKEVMS.COM</tt>) for building the -library and tools, is believed to choose the correct options for -the VAX and AXP cases automatically.</p> -<p>On the AXP, IEEE floating point is used by default. If you want -VAX floating point, remove the <tt>/FLOAT=IEEE_FLOAT</tt> -qualifier, and change <tt>HAVE_IEEEFP=1</tt> to -<tt>HAVE_IEEEFP=0</tt> in the <tt>MAKEVMS.COM</tt> files in both -the <b>libtiff</b> and <b>tools</b> directories.</p> -<h3>Compiling your own program on a VMS system:</h3> -When compiling a source file in which you <tt>"#include -<tiffio.h>"</tt>, use the following command -<pre> - $ CC/INCLUDE=DISK:[TIFF.LIBTIFF] -</pre> -This ensures that the header file is found. On the AXP, also add -<tt>/FLOAT=IEEE_FLOAT</tt> (if used when building the library). -<h3>Linking your own program to the TIFF library on a VMS -system:</h3> -You can link to the library in two ways: Either using the shareable -library, or using the object library. On the VAX these -possibilities are: -<ol> -<li>Using the shareable TIFF library. -<pre> -$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS,SYS$INPUT:/OPTIONS - SYS$SHARE:VAXCRTL/SHAREABLE -</pre></li> -<li>Using the TIFF object library. -<pre> -$ LINK MY_PROGRAM, - - DISK:[TIFF.LIBTIFF]TIFF/LIBRARY/INCLUDE=(TIF_FAX3SM,TIF_CODEC), - - SYS$INPUT:/OPTIONS - SYS$SHARE:VAXCRTL/SHAREABLE -</pre></li> -</ol> -On AXP (and possibly also using DEC C on VAX) the corresponding -commands are -<ol> -<li>Using the shareable TIFF library. -<pre> -$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS -</pre></li> -<li>Using the TIFF object library. -<pre> -$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/LIBRARY -</pre></li> -</ol> -Method 1 uses the shortest link time and smallest <tt>.EXE</tt> -files, but it requires that <tt>TIFFSHR</tt> is defined as above at -link time and <strong>at run time</strong>. Using the compilation -procedure above, the tools are linked in this way. -<p>Method 2 gives somewhat longer link time and larger -<tt>.EXE</tt> files, but does not require <tt>TIFFSHR</tt> to be -defined. This method is recommended if you want to run your program -on another machine, and for some reason don't want to have the -library on that machine. If you plan to have more than one program -(including the tools) on the machine, it is recommended that you -copy the library to the other machine and use method 1.</p> -<hr> <a name="Other" id="Other"></a> <h2>Building the Software on Other Systems</h2> This section contains information that might be useful if you are @@ -720,7 +545,6 @@ libtiff/tif_thunder.c Thunderscan codec (decoding only) libtiff/tif_tile.c some tile-related code libtiff/tif_unix.c UNIX-related OS support libtiff/tif_version.c library version support -libtiff/tif_vms.c VMS-related OS support libtiff/tif_warning.c library warning handler libtiff/tif_win3.c Windows-3.1-related OS support libtiff/tif_win32.c Win32 (95/98/NT) related OS support diff --git a/tiff/html/contrib.html b/tiff/html/contrib.html index 9a670658..16d3d744 100644 --- a/tiff/html/contrib.html +++ b/tiff/html/contrib.html @@ -30,16 +30,6 @@ aren't directly TIFF related). <TR> <TD VALIGN=top> -<B>contrib/vms</B> -</TD> -<TD> -scripts and files from Karsten Spang for building - the library and tools under VMS -</TD> -</TR> - -<TR> -<TD VALIGN=top> <B>contrib/dbs</B> </TD> <TD> diff --git a/tiff/html/images/CMakeLists.txt b/tiff/html/images/CMakeLists.txt index e25f9f62..8c810575 100644 --- a/tiff/html/images/CMakeLists.txt +++ b/tiff/html/images/CMakeLists.txt @@ -42,5 +42,3 @@ set(docfiles install(FILES ${docfiles} DESTINATION "${LIBTIFF_DOCDIR}/html/images") - -extra_dist(${docfiles}) diff --git a/tiff/html/images/Makefile.in b/tiff/html/images/Makefile.in index 64f473d1..f9065cf5 100644 --- a/tiff/html/images/Makefile.in +++ b/tiff/html/images/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -124,8 +124,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ DIST_COMMON = $(srcdir)/Makefile.am $(dist_doc_DATA) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -318,6 +320,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/html/index.html b/tiff/html/index.html index fd7b5f77..3173ca72 100644 --- a/tiff/html/index.html +++ b/tiff/html/index.html @@ -28,7 +28,7 @@ </tr> <tr> <th>Latest Stable Release</th> - <td><a href="v4.2.0.html">v4.2.0</a></td> + <td><a href="v4.3.0.html">v4.3.0</a></td> </tr> <tr> <th>Master Download Site</th> @@ -114,7 +114,7 @@ </ul> <hr> <p> - Last updated 2019-11-03 + Last updated 2021-04-16 </p> </body> </html> diff --git a/tiff/html/internals.html b/tiff/html/internals.html index 20061ef0..da2998ae 100644 --- a/tiff/html/internals.html +++ b/tiff/html/internals.html @@ -253,18 +253,7 @@ operating system-dependencies as possible in two files: <B>tiffcomp.h</B> and <B>libtiff/tif_<os>.c</B>. The latter file contains operating system-specific routines to do I/O and I/O-related operations. -The UNIX (<B>tif_unix.c</B>), -Macintosh (<B>tif_apple.c</B>), -and VMS (<B>tif_vms.c</B>) -code has had the most use; -the MS/DOS support (<B>tif_msdos.c</B>) assumes -some level of UNIX system call emulation (i.e. -<TT>open</TT>, -<TT>read</TT>, -<TT>write</TT>, -<TT>fstat</TT>, -<TT>malloc</TT>, -<TT>free</TT>). +The UNIX (<B>tif_unix.c</B>) code has had the most use. <P> Native CPU byte order is determined on the fly by @@ -289,7 +278,7 @@ The following defines control general portability: <TR> <TD VALIGN=top><TT>HAVE_IEEEFP</TT></TD> <TD>Define this as 0 or 1 according to the floating point - format suported by the machine. If your machine does + format supported by the machine. If your machine does not support IEEE floating point then you will need to add support to tif_machdep.c to convert between the native format and IEEE format.</TD> @@ -338,37 +327,37 @@ purely by fiddling with the following machine-dependent typedefs: <TABLE BORDER CELLPADDING=3 WIDTH="100%"> <TR> -<TD>uint8</TD> +<TD>uint8_t</TD> <TD>8-bit unsigned integer</TD> <TD>tiff.h</TD> </TR> <TR> -<TD>int8</TD> +<TD>int8_t</TD> <TD>8-bit signed integer</TD> <TD>tiff.h</TD> </TR> <TR> -<TD>uint16</TD> +<TD>uint16_t</TD> <TD>16-bit unsigned integer</TD> <TD>tiff.h</TD> </TR> <TR> -<TD>int16</TD> +<TD>int16_t</TD> <TD>16-bit signed integer</TD> <TD>tiff.h</TD> </TR> <TR> -<TD>uint32</TD> +<TD>uint32_t</TD> <TD>32-bit unsigned integer</TD> <TD>tiff.h</TD> </TR> <TR> -<TD>int32</TD> +<TD>int32_t</TD> <TD>32-bit signed integer</TD> <TD>tiff.h</TD> </TR> @@ -399,23 +388,23 @@ structure: </TR> <TR> -<TD>typedef uint16 tdir_t;</TD> <TD>directory index</TD> +<TD>typedef uint16_t tdir_t;</TD> <TD>directory index</TD> </TR> <TR> -<TD>typedef uint16 tsample_t;</TD> <TD>sample number</TD> +<TD>typedef uint16_t tsample_t;</TD> <TD>sample number</TD> </TR> <TR> -<TD>typedef uint32 tstrip_t;</TD> <TD>strip number</TD> +<TD>typedef uint32_t tstrip_t;</TD> <TD>strip number</TD> </TR> <TR> -<TD>typedef uint32 ttile_t;</TD> <TD>tile number</TD> +<TD>typedef uint32_t ttile_t;</TD> <TD>tile number</TD> </TR> <TR> -<TD>typedef int32 tsize_t;</TD> <TD>i/o size in bytes</TD> +<TD>typedef int32_t tsize_t;</TD> <TD>i/o size in bytes</TD> </TR> <TR> @@ -427,7 +416,7 @@ structure: </TR> <TR> -<TD>typedef int32 toff_t;</TD> <TD>file offset (should be off_t)</TD> +<TD>typedef int32_t toff_t;</TD> <TD>file offset (should be off_t)</TD> </TR> <TR> @@ -449,7 +438,7 @@ be an arbitrary size (without penalty). <TT>ttag_t</TT> must be either because the library uses a varargs interface and ANSI C restricts the type of the parameter before an ellipsis to be a promoted type. <TT>toff_t</TT> is defined as -<TT>int32</TT> because +<TT>int32_t</TT> because TIFF file offsets are (unsigned) 32-bit quantities. A signed value is used because some interfaces return -1 on error (sigh). Finally, note that <TT>tidata_t</TT> is used internally to the library to diff --git a/tiff/html/libtiff.html b/tiff/html/libtiff.html index cda66b5a..7698ef54 100644 --- a/tiff/html/libtiff.html +++ b/tiff/html/libtiff.html @@ -296,7 +296,7 @@ the <tt>TIFFGetFieldDefaulted</tt> interface may be used. </p> <p> - The manual pages for the tag get and set routines specifiy the exact data types + The manual pages for the tag get and set routines specify the exact data types and calling conventions required for each tag supported by the library. </p> <hr> @@ -375,14 +375,14 @@ {<br> TIFF* tif = TIFFOpen(argv[1], "r");<br> if (tif) {<br> - uint32 w, h;<br> + uint32_t w, h;<br> size_t npixels;<br> - uint32* raster;<br> + uint32_t* raster;<br> <br> TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);<br> TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);<br> npixels = w * h;<br> - raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));<br> + raster = (uint32_t*) _TIFFmalloc(npixels * sizeof (uint32_t));<br> if (raster != NULL) {<br> if (TIFFReadRGBAImage(tif, w, h, raster, 0)) {<br> ...process raster data...<br> @@ -417,10 +417,10 @@ <br> if (TIFFRGBAImageBegin(&img, tif, 0, emsg)) {<br> size_t npixels;<br> - uint32* raster;<br> + uint32_t* raster;<br> <br> npixels = img.width * img.height;<br> - raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));<br> + raster = (uint32_t*) _TIFFmalloc(npixels * sizeof (uint32_t));<br> if (raster != NULL) {<br> if (TIFFRGBAImageGet(&img, raster, img.width, img.height)) {<br> ...process raster data...<br> @@ -511,9 +511,9 @@ {<br> TIFF* tif = TIFFOpen("myfile.tif", "r");<br> if (tif) {<br> - uint32 imagelength;<br> + uint32_t imagelength;<br> tdata_t buf;<br> - uint32 row;<br> + uint32_t row;<br> <br> TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);<br> buf = _TIFFmalloc(TIFFScanlineSize(tif));<br> @@ -538,9 +538,9 @@ {<br> TIFF* tif = TIFFOpen("myfile.tif", "r");<br> if (tif) {<br> - uint32 imagelength;<br> + uint32_t imagelength;<br> tdata_t buf;<br> - uint32 row;<br> + uint32_t row;<br> <br> TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);<br> TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config);<br> @@ -549,7 +549,7 @@ for (row = 0; row < imagelength; row++)<br> TIFFReadScanline(tif, buf, row, 0);<br> } else if (config == planarconfig_separate) {<br> - uint16 s, nsamples;<br> + uint16_t s, nsamples;<br> <br> tiffgetfield(tif, tifftag_samplesperpixel, &nsamples);<br> for (s = 0; s < nsamples; s++)<br> @@ -635,8 +635,8 @@ if (tif) {<br> tdata_t buf;<br> tstrip_t strip;<br> - uint32* bc;<br> - uint32 stripsize;<br> + uint32_t* bc;<br> + uint32_t stripsize;<br> <br> TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc);<br> stripsize = bc[0];<br> @@ -689,9 +689,9 @@ {<br> TIFF* tif = TIFFOpen("myfile.tif", "r");<br> if (tif) {<br> - uint32 imageWidth, imageLength;<br> - uint32 tileWidth, tileLength;<br> - uint32 x, y;<br> + uint32_t imageWidth, imageLength;<br> + uint32_t tileWidth, tileLength;<br> + uint32_t x, y;<br> tdata_t buf;<br> <br> TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth);<br> diff --git a/tiff/html/man/CMakeLists.txt b/tiff/html/man/CMakeLists.txt index 897a0e73..97aeaf63 100644 --- a/tiff/html/man/CMakeLists.txt +++ b/tiff/html/man/CMakeLists.txt @@ -91,8 +91,6 @@ set(docfiles set(doc_DATA ${indexfile} ${docfiles}) -extra_dist(${doc_DATA}) - install(FILES ${doc_DATA} DESTINATION "${LIBTIFF_DOCDIR}/html/man") diff --git a/tiff/html/man/Makefile.in b/tiff/html/man/Makefile.in index f6d6cef2..4c5802de 100644 --- a/tiff/html/man/Makefile.in +++ b/tiff/html/man/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -124,8 +124,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ DIST_COMMON = $(srcdir)/Makefile.am $(dist_doc_DATA) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -318,6 +320,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/html/man/TIFFDataWidth.3tiff.html b/tiff/html/man/TIFFDataWidth.3tiff.html index 9eede060..c8318ded 100644 --- a/tiff/html/man/TIFFDataWidth.3tiff.html +++ b/tiff/html/man/TIFFDataWidth.3tiff.html @@ -75,7 +75,7 @@ TIFF_DOUBLE</i></p> <td width="8%"></td> <td width="91%"> <p><i>TIFFDataWidth</i> returns a number of bytes occupied -by the item of given type. 0 returned when uknown data type +by the item of given type. 0 returned when unknown data type supplied.</p> </td> </table> diff --git a/tiff/html/man/TIFFFieldPassCount.3tiff.html b/tiff/html/man/TIFFFieldPassCount.3tiff.html index 5dc31262..4f6c6ad3 100644 --- a/tiff/html/man/TIFFFieldPassCount.3tiff.html +++ b/tiff/html/man/TIFFFieldPassCount.3tiff.html @@ -67,9 +67,9 @@ field information pointer previously returned by <b>TIFFFieldWithName</b>.</p> <p style="margin-left:11%; margin-top: 1em">When a -<i>count</i> is required, it will be of type <b>uint32</b> +<i>count</i> is required, it will be of type <b>uint32_t</b> when <b>TIFFFieldReadCount</b> reports -<b>TIFF_VARIABLE2</b>, and of type <b>uint16</b> otherwise. +<b>TIFF_VARIABLE2</b>, and of type <b>uint16_t</b> otherwise. (This distinction is critical for use of <b>TIFFGetField</b>, but normally not so for use of <b>TIFFSetField</b>.)</p> diff --git a/tiff/html/man/TIFFFieldReadCount.3tiff.html b/tiff/html/man/TIFFFieldReadCount.3tiff.html index d800a861..6a0b1359 100644 --- a/tiff/html/man/TIFFFieldReadCount.3tiff.html +++ b/tiff/html/man/TIFFFieldReadCount.3tiff.html @@ -63,12 +63,12 @@ should be supplied to <b>TIFFGetField</b>. For most field types this is a small positive integer, typically 1 or 2, but there are some special values: <b><br> TIFF_VARIABLE</b> indicates that a variable number of values -is possible; then, a <b>uint16</b> <i>count</i> argument and +is possible; then, a <b>uint16_t</b> <i>count</i> argument and a pointer <i>data</i> argument must be supplied to <b>TIFFGetField</b>. <b><br> TIFF_VARIABLE2</b> is the same as <b>TIFF_VARIABLE</b> except that the <i>count</i> argument must have type -<b>uint32</b>. <b><br> +<b>uint32_t</b>. <b><br> TIFF_SPP</b> indicates that the number of arguments is equal to the image’s number of samples per pixel.</p> diff --git a/tiff/html/man/TIFFFieldTag.3tiff.html b/tiff/html/man/TIFFFieldTag.3tiff.html index b1fdea0f..05a13a71 100644 --- a/tiff/html/man/TIFFFieldTag.3tiff.html +++ b/tiff/html/man/TIFFFieldTag.3tiff.html @@ -45,7 +45,7 @@ <p style="margin-left:11%; margin-top: 1em"><b>#include <tiffio.h></b></p> -<p style="margin-left:11%; margin-top: 1em"><b>uint32 +<p style="margin-left:11%; margin-top: 1em"><b>uint32_t TIFFFieldTag(const TIFFField*</b> <i>fip</i><b>)</b></p> <h2>DESCRIPTION diff --git a/tiff/html/man/TIFFFieldWriteCount.3tiff.html b/tiff/html/man/TIFFFieldWriteCount.3tiff.html index 0d446bc7..31f27f51 100644 --- a/tiff/html/man/TIFFFieldWriteCount.3tiff.html +++ b/tiff/html/man/TIFFFieldWriteCount.3tiff.html @@ -63,12 +63,12 @@ should be supplied to <b>TIFFSetField</b>. For most field types this is a small positive integer, typically 1 or 2, but there are some special values: <b><br> TIFF_VARIABLE</b> indicates that a variable number of values -is possible; then, a <b>uint16</b> <i>count</i> argument and +is possible; then, a <b>uint16_t</b> <i>count</i> argument and a pointer <i>data</i> argument must be supplied to <b>TIFFSetField</b>. <b><br> TIFF_VARIABLE2</b> is the same as <b>TIFF_VARIABLE</b> except that the <i>count</i> argument must have type -<b>uint32</b>. (On most modern machines, this makes no +<b>uint32_t</b>. (On most modern machines, this makes no practical difference, and the <i>count</i> argument can simply be an <b>int</b> in either case.) <b><br> TIFF_SPP</b> indicates that the number of arguments must be diff --git a/tiff/html/man/TIFFGetField.3tiff.html b/tiff/html/man/TIFFGetField.3tiff.html index cbbb8be7..ac2ca912 100644 --- a/tiff/html/man/TIFFGetField.3tiff.html +++ b/tiff/html/man/TIFFGetField.3tiff.html @@ -183,7 +183,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -206,7 +206,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -229,7 +229,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -252,7 +252,7 @@ values.</p> <td width="28%"> -<p>uint16**</p></td> +<p>uint16_t**</p></td> <td width="12%"> @@ -277,7 +277,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -300,7 +300,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -346,7 +346,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -415,7 +415,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -438,7 +438,7 @@ values.</p> <td width="28%"> -<p>uint16*,uint16**</p></td> +<p>uint16_t*,uint16_t**</p></td> <td width="12%"> @@ -513,7 +513,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -536,7 +536,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -559,7 +559,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -582,7 +582,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -628,7 +628,7 @@ values.</p> <td width="28%"> -<p>uint32*,void**</p></td> +<p>uint32_t*,void**</p></td> <td width="12%"> @@ -653,7 +653,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -699,7 +699,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -722,7 +722,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -768,7 +768,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -841,7 +841,7 @@ values.</p> <td width="28%"> -<p>uint32*,void**</p></td> +<p>uint32_t*,void**</p></td> <td width="12%"> @@ -914,7 +914,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -937,7 +937,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -960,7 +960,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1006,7 +1006,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1052,7 +1052,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1075,7 +1075,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1098,7 +1098,7 @@ values.</p> <td width="28%"> -<p>uint32*,void**</p></td> +<p>uint32_t*,void**</p></td> <td width="12%"> @@ -1123,7 +1123,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1146,7 +1146,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1219,7 +1219,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1242,7 +1242,7 @@ values.</p> <td width="28%"> -<p>uint32*,void**</p></td> +<p>uint32_t*,void**</p></td> <td width="12%"> @@ -1267,7 +1267,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1290,7 +1290,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1313,7 +1313,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1428,7 +1428,7 @@ values.</p> <td width="28%"> -<p>uint32**</p></td> +<p>uint32_t**</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1451,7 +1451,7 @@ values.</p> <td width="28%"> -<p>uint32**</p></td> +<p>uint32_t**</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1474,7 +1474,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1497,7 +1497,7 @@ values.</p> <td width="28%"> -<p>uint16*,uint32**</p></td> +<p>uint16_t*,uint32_t**</p></td> <td width="12%"> @@ -1545,7 +1545,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1568,7 +1568,7 @@ values.</p> <td width="28%"> -<p>uint32**</p></td> +<p>uint32_t**</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1591,7 +1591,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1614,7 +1614,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1637,7 +1637,7 @@ values.</p> <td width="28%"> -<p>uint32**</p></td> +<p>uint32_t**</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1660,7 +1660,7 @@ values.</p> <td width="28%"> -<p>uint32*</p></td> +<p>uint32_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1677,7 +1677,7 @@ values.</p> <td width="12%"> -<p>uint16**1<<BitsPerSample entry arrays</p></td></tr> +<p>uint16_t**1<<BitsPerSample entry arrays</p></td></tr> <tr valign="top" align="left"> <td width="11%"></td> <td width="38%"> @@ -1723,7 +1723,7 @@ values.</p> <td width="28%"> -<p>uint32*,void**</p></td> +<p>uint32_t*,void**</p></td> <td width="12%"> @@ -1819,7 +1819,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1842,7 +1842,7 @@ values.</p> <td width="28%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="12%"> </td></tr> <tr valign="top" align="left"> @@ -1914,14 +1914,14 @@ you want to read the LONG value from the tag 33424 and ASCII string from the tag 36867 you can use the following code:</p> -<p style="margin-left:22%; margin-top: 1em">uint16 count; +<p style="margin-left:22%; margin-top: 1em">uint16_t count; <br> void *data;</p> <p style="margin-left:22%; margin-top: 1em">TIFFGetField(tiff, 33424, &count, &data); <br> -printf("Tag %d: %d, count %d0, 33424, *(uint32 *)data, +printf("Tag %d: %d, count %d0, 33424, *(uint32_t *)data, count); <br> TIFFGetField(tiff, 36867, &count, &data); <br> printf("Tag %d: %s, count %d0, 36867, (char *)data, diff --git a/tiff/html/man/TIFFRGBAImage.3tiff.html b/tiff/html/man/TIFFRGBAImage.3tiff.html index 83581f11..1d97e53e 100644 --- a/tiff/html/man/TIFFRGBAImage.3tiff.html +++ b/tiff/html/man/TIFFRGBAImage.3tiff.html @@ -53,8 +53,8 @@ int TIFFRGBAImageBegin(TIFFRGBAImage *</b><i>img</i><b>, TIFF*</b> <i>tif</i><b>, int</b> <i>stopOnError</i><b>, char</b> <i>emsg[1024]</i><b>)<br> int TIFFRGBAImageGet(TIFFRGBAImage *</b><i>img</i><b>, -uint32*</b> <i>raster</i><b>, uint32</b> <i>width</i> <b>, -uint32</b> <i>height</i><b>)<br> +uint32_t*</b> <i>raster</i><b>, uint32_t</b> <i>width</i> <b>, +uint32_t</b> <i>height</i><b>)<br> void TIFFRGBAImageEnd(TIFFRGBAImage *</b><i>img</i><b>)</b></p> </td> @@ -169,9 +169,9 @@ after each display operation. For example, the update the display as the raster is being filled:</p> <!-- INDENTATION --> <pre>static void -putContigAndDraw(TIFFRGBAImage* img, uint32* raster, - uint32 x, uint32 y, uint32 w, uint32 h, - int32 fromskew, int32 toskew, +putContigAndDraw(TIFFRGBAImage* img, uint32_t* raster, + uint32_t x, uint32_t y, uint32_t w, uint32_t h, + int32_t fromskew, int32_t toskew, unsigned char* cp) { (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp); diff --git a/tiff/html/man/TIFFReadRGBAImage.3tiff.html b/tiff/html/man/TIFFReadRGBAImage.3tiff.html index f648f099..37578bc5 100644 --- a/tiff/html/man/TIFFReadRGBAImage.3tiff.html +++ b/tiff/html/man/TIFFReadRGBAImage.3tiff.html @@ -47,12 +47,12 @@ and decode an image into a fixed-format raster</p> 0xff)</b></p> <!-- INDENTATION --> <p><b>int TIFFReadRGBAImage(TIFF *</b><i>tif</i><b>, -uint32</b> <i>width</i><b>, uint32</b> <i>height</i><b>, -uint32 *</b><i>raster</i><b>, int</b> +uint32_t</b> <i>width</i><b>, uint32_t</b> <i>height</i><b>, +uint32_t *</b><i>raster</i><b>, int</b> <i>stopOnError</i><b>)<br> int TIFFReadRGBAImageOriented(TIFF *</b><i>tif</i><b>, -uint32</b> <i>width</i><b>, uint32</b> <i>height</i><b>, -uint32 *</b><i>raster</i><b>, int</b> <i>orientation</i><b>, +uint32_t</b> <i>width</i><b>, uint32_t</b> <i>height</i><b>, +uint32_t *</b><i>raster</i><b>, int</b> <i>orientation</i><b>, int</b> <i>stopOnError</i><b>)</b></p> </td> </table> @@ -176,7 +176,7 @@ scaling sample values. Palette, grayscale, bilevel, uncorrected by any colorimetry information present in the directory.</p> <!-- INDENTATION --> -<p>The paramater <i>stopOnError</i> specifies how to act if +<p>The parameter <i>stopOnError</i> specifies how to act if an error is encountered while reading the image. If <i>stopOnError</i> is non-zero, then an error will terminate the operation; otherwise <i>TIFFReadRGBAImage</i> will diff --git a/tiff/html/man/TIFFReadRGBAStrip.3tiff.html b/tiff/html/man/TIFFReadRGBAStrip.3tiff.html index 3358df7d..2d6caeb7 100644 --- a/tiff/html/man/TIFFReadRGBAStrip.3tiff.html +++ b/tiff/html/man/TIFFReadRGBAStrip.3tiff.html @@ -47,7 +47,7 @@ into a fixed-format raster</p> 0xff)</b></p> <!-- INDENTATION --> <p><b>int TIFFReadRGBAStrip(TIFF *</b><i>tif</i><b>, -uint32</b> <i>row</i><b>, uint32 +uint32_t</b> <i>row</i><b>, uint32_t *</b><i>raster</i><b>)</b></p> </td> </table> diff --git a/tiff/html/man/TIFFReadRGBATile.3tiff.html b/tiff/html/man/TIFFReadRGBATile.3tiff.html index bdbb43cc..ea37f7e1 100644 --- a/tiff/html/man/TIFFReadRGBATile.3tiff.html +++ b/tiff/html/man/TIFFReadRGBATile.3tiff.html @@ -100,7 +100,7 @@ into a fixed-format raster</p> <td width="8%"></td> <td width="91%"> <p><b>int TIFFReadRGBATile(TIFF *</b><i>tif</i><b>, -uint32</b> <i>x</i><b>, uint32</b> <i>y</i><b>, uint32 +uint32_t</b> <i>x</i><b>, uint32_t</b> <i>y</i><b>, uint32_t *</b><i>raster</i><b>)</b></p> </td> </table> diff --git a/tiff/html/man/TIFFReadScanline.3tiff.html b/tiff/html/man/TIFFReadScanline.3tiff.html index 79f17fcd..11d60c45 100644 --- a/tiff/html/man/TIFFReadScanline.3tiff.html +++ b/tiff/html/man/TIFFReadScanline.3tiff.html @@ -42,7 +42,7 @@ data from an open <small>TIFF</small> file</p> <p><b>#include <tiffio.h></b></p> <!-- INDENTATION --> <p><b>int TIFFReadScanline(TIFF *</b><i>tif</i><b>, -tdata_t</b> <i>buf</i><b>, uint32</b> <i>row</i><b>, +tdata_t</b> <i>buf</i><b>, uint32_t</b> <i>row</i><b>, tsample_t</b> <i>sample</i><b>)</b></p> </td> </table> diff --git a/tiff/html/man/TIFFReadTile.3tiff.html b/tiff/html/man/TIFFReadTile.3tiff.html index 26054803..11db5ed6 100644 --- a/tiff/html/man/TIFFReadTile.3tiff.html +++ b/tiff/html/man/TIFFReadTile.3tiff.html @@ -41,8 +41,8 @@ an open <small>TIFF</small> file</p> <p><b>#include <tiffio.h></b></p> <!-- INDENTATION --> <p><b>tsize_t TIFFReadTile(TIFF *</b><i>tif</i><b>, -tdata_t</b> <i>buf</i><b>, uint32</b> <i>x</i><b>, -uint32</b> <i>y</i><b>, uint32</b> <i>z</i><b>, +tdata_t</b> <i>buf</i><b>, uint32_t</b> <i>x</i><b>, +uint32_t</b> <i>y</i><b>, uint32_t</b> <i>z</i><b>, tsample_t</b> <i>sample</i><b>)</b></p> </td> </table> diff --git a/tiff/html/man/TIFFSetDirectory.3tiff.html b/tiff/html/man/TIFFSetDirectory.3tiff.html index c3434056..be90c933 100644 --- a/tiff/html/man/TIFFSetDirectory.3tiff.html +++ b/tiff/html/man/TIFFSetDirectory.3tiff.html @@ -41,7 +41,7 @@ current directory for an open <small>TIFF</small> file</p> <!-- INDENTATION --> <p><b>int TIFFSetDirectory(TIFF *</b><i>tif</i><b>, tdir_t</b> <i>dirnum</i><b>)<br> -int TIFFSetSubDirectory(TIFF *</b><i>tif</i><b>, uint32</b> +int TIFFSetSubDirectory(TIFF *</b><i>tif</i><b>, uint32_t</b> <i>diroff</i><b>)</b></p> </td> </table> diff --git a/tiff/html/man/TIFFSetField.3tiff.html b/tiff/html/man/TIFFSetField.3tiff.html index ce6a88b0..be4de304 100644 --- a/tiff/html/man/TIFFSetField.3tiff.html +++ b/tiff/html/man/TIFFSetField.3tiff.html @@ -93,9 +93,9 @@ understood by <i>libtiff</i>, the number of parameter values, and the expected types for the parameter values are shown below. The data types are: <i>char*</i> is null-terminated string and corresponds to the -<small>ASCII</small> data type; <i>uint16</i> is an unsigned -16-bit value; <i>uint32</i> is an unsigned 32-bit value; -<i>uint16*</i> is an array of unsigned 16-bit values. +<small>ASCII</small> data type; <i>uint16_t</i> is an unsigned +16-bit value; <i>uint32_t</i> is an unsigned 32-bit value; +<i>uint16_t*</i> is an array of unsigned 16-bit values. <i>void*</i> is an array of data values of unspecified type.</p> @@ -173,7 +173,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -196,7 +196,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -221,7 +221,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -244,7 +244,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16*</p></td> +<p>uint16_t*</p></td> <td width="11%"> @@ -269,7 +269,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -294,7 +294,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -386,7 +386,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -409,7 +409,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16,uint16*</p></td> +<p>uint16_t,uint16_t*</p></td> <td width="11%"> @@ -484,7 +484,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -509,7 +509,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> @@ -534,7 +534,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> @@ -559,7 +559,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -605,7 +605,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32,void*</p></td> +<p>uint32_t,void*</p></td> <td width="11%"> @@ -630,7 +630,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> @@ -678,7 +678,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -701,7 +701,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> @@ -726,7 +726,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16, char*</p></td> +<p>uint16_t, char*</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -749,7 +749,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -824,7 +824,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32*,void*</p></td> +<p>uint32_t*,void*</p></td> <td width="11%"> @@ -897,7 +897,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -922,7 +922,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -945,7 +945,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -991,7 +991,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -1037,7 +1037,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -1060,7 +1060,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -1083,7 +1083,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32,void*</p></td> +<p>uint32_t,void*</p></td> <td width="11%"> @@ -1108,7 +1108,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -1133,7 +1133,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -1208,7 +1208,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -1231,7 +1231,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32,void*</p></td> +<p>uint32_t,void*</p></td> <td width="11%"> @@ -1256,7 +1256,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> @@ -1281,7 +1281,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -1306,7 +1306,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -1425,7 +1425,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -1448,7 +1448,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16,uint32*</p></td> +<p>uint16_t,uint32_t*</p></td> <td width="11%"> @@ -1496,7 +1496,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> </td></tr> <tr valign="top" align="left"> @@ -1519,7 +1519,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> @@ -1544,7 +1544,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> @@ -1569,7 +1569,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32</p></td> +<p>uint32_t</p></td> <td width="11%"> @@ -1584,7 +1584,7 @@ meaning of each tag.</p> <td width="29%"> -<p>1 or 3‡ uint16*</p></td> +<p>1 or 3‡ uint16_t*</p></td> <td width="11%"> @@ -1634,7 +1634,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint32,void*</p></td> +<p>uint32_t,void*</p></td> <td width="11%"> @@ -1730,7 +1730,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> @@ -1755,7 +1755,7 @@ meaning of each tag.</p> <td width="29%"> -<p>uint16</p></td> +<p>uint16_t</p></td> <td width="11%"> diff --git a/tiff/html/man/TIFFWriteScanline.3tiff.html b/tiff/html/man/TIFFWriteScanline.3tiff.html index 8f300217..7b5dfea7 100644 --- a/tiff/html/man/TIFFWriteScanline.3tiff.html +++ b/tiff/html/man/TIFFWriteScanline.3tiff.html @@ -42,7 +42,7 @@ <p><b>#include <tiffio.h></b></p> <!-- INDENTATION --> <p><b>int TIFFWriteScanline(TIFF *</b><i>tif</i><b>, -tdata_t</b> <i>buf</i><b>, uint32</b> <i>row</i><b>, +tdata_t</b> <i>buf</i><b>, uint32_t</b> <i>row</i><b>, tsample_t</b> <i>sample</i><b>)</b></p> </td> </table> diff --git a/tiff/html/man/TIFFWriteTile.3tiff.html b/tiff/html/man/TIFFWriteTile.3tiff.html index d450ee12..d4f520b6 100644 --- a/tiff/html/man/TIFFWriteTile.3tiff.html +++ b/tiff/html/man/TIFFWriteTile.3tiff.html @@ -40,8 +40,8 @@ an open <small>TIFF</small> file</p> <p><b>#include <tiffio.h></b></p> <!-- INDENTATION --> <p><b>tsize_t TIFFWriteTile(TIFF *</b><i>tif</i><b>, -tdata_t</b> <i>buf</i><b>, uint32</b> <i>x</i><b>, -uint32</b> <i>y</i><b>, uint32</b> <i>z</i><b>, +tdata_t</b> <i>buf</i><b>, uint32_t</b> <i>x</i><b>, +uint32_t</b> <i>y</i><b>, uint32_t</b> <i>z</i><b>, tsample_t</b> <i>sample</i><b>)</b></p> </td> </table> diff --git a/tiff/html/man/TIFFcodec.3tiff.html b/tiff/html/man/TIFFcodec.3tiff.html index e18c0ed4..e7a52460 100644 --- a/tiff/html/man/TIFFcodec.3tiff.html +++ b/tiff/html/man/TIFFcodec.3tiff.html @@ -39,14 +39,14 @@ routines</p> <td width="91%"> <p><b>#include <tiffio.h></b></p> <!-- INDENTATION --> -<p><b>const TIFFCodec* TIFFFindCODEC(uint16</b> +<p><b>const TIFFCodec* TIFFFindCODEC(uint16_t</b> <i>scheme</i><b>);<br> -TIFFCodec* TIFFRegisterCODEC(uint16</b> <i>scheme</i><b>, +TIFFCodec* TIFFRegisterCODEC(uint16_t</b> <i>scheme</i><b>, const char *</b><i>method</i><b>, TIFFInitMethod</b> <i>init</i><b>);<br> void TIFFUnRegisterCODEC(TIFFCodec *</b><i>codec</i><b>);<br> -int TIFFIsCODECConfigured(uint16</b> +int TIFFIsCODECConfigured(uint16_t</b> <i>scheme</i><b>);</b></p> </td> </table> diff --git a/tiff/html/man/TIFFcolor.3tiff.html b/tiff/html/man/TIFFcolor.3tiff.html index e598ae6e..d4c5a58a 100644 --- a/tiff/html/man/TIFFcolor.3tiff.html +++ b/tiff/html/man/TIFFcolor.3tiff.html @@ -42,21 +42,21 @@ routines.</p> *</b><i>ycbcr</i><b>, float *</b><i>luma</i><b>, float *</b><i>refBlackWhite"</i><b>);"<br> void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *</b><i>ycbcr</i><b>, -uint32</b> <i>Y</i><b>, int32</b> <i>Cb</i><b>, int32</b> -<i>Cr</i><b>, uint32 *</b><i>R</i><b>, uint32 -*</b><i>G</i><b>, uint32 *</b><i>B</i> <b>);</b></p> +uint32_t</b> <i>Y</i><b>, int32_t</b> <i>Cb</i><b>, int32_t</b> +<i>Cr</i><b>, uint32_t *</b><i>R</i><b>, uint32_t +*</b><i>G</i><b>, uint32_t *</b><i>B</i> <b>);</b></p> <!-- INDENTATION --> <p><b>int TIFFCIELabToRGBInit(TIFFCIELabToRGB *</b><i>cielab</i><b>, TIFFDisplay *</b><i>display</i><b>, float *</b><i>refWhite</i><b>);<br> void TIFFCIELabToXYZ(TIFFCIELabToRGB *</b><i>cielab</i><b>, -uint32</b> <i>L</i><b>, int32</b> <i>a</i><b>, int32</b> +uint32_t</b> <i>L</i><b>, int32_t</b> <i>a</i><b>, int32_t</b> <i>b</i><b>, float *</b><i>X</i><b>, float *</b><i>Y</i><b>, float *</b><i>Z</i><b>);<br> void TIFFXYZToRGB(TIFFCIELabToRGB *</b><i>cielab</i><b>, float</b> <i>X</i><b>, float</b> <i>Y</i><b>, float</b> -<i>Z"</i><b>,</b><i>uint32</i><b>*"</b><i>R</i><b>, -uint32 *</b><i>G</i><b>, uint32 *</b><i>B</i><b>);</b></p> +<i>Z"</i><b>,</b><i>uint32_t</i><b>*"</b><i>R</i><b>, +uint32_t *</b><i>G</i><b>, uint32_t *</b><i>B</i><b>);</b></p> </td> </table> <a name="DESCRIPTION"></a> @@ -116,7 +116,7 @@ int*</p> <td width="6%"> <p>Cb_b_tab;<br> -int32*</p> +int32_t*</p> </td> <td width="56%"> </td> @@ -127,7 +127,7 @@ int32*</p> <td width="6%"> <p>Cr_g_tab;<br> -int32*</p> +int32_t*</p> </td> <td width="56%"> </td> @@ -148,7 +148,7 @@ int32*</p> <tr valign="top" align="left"> <td width="17%"></td> <td width="82%"> -<p>int32* Y_tab;<br> +<p>int32_t* Y_tab;<br> } TIFFYCbCrToRGB;</p></td> </table> <!-- INDENTATION --> @@ -178,7 +178,7 @@ should helps to understand the the technique:</p> <td width="17%"></td> <td width="82%"> <pre>float *luma, *refBlackWhite; -uint16 hs, vs; +uint16_t hs, vs; /* Initialize structures */ ycbcr = (TIFFYCbCrToRGB*) @@ -212,7 +212,7 @@ sizeof(long))</p> <td width="24%"></td> <td width="75%"> -<p>+ 3*256*sizeof(int32));</p> +<p>+ 3*256*sizeof(int32_t));</p> </td> </table> <!-- INDENTATION --> @@ -272,9 +272,9 @@ if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) < <td width="17%"></td> <td width="82%"> <p>/* Start conversion */<br> -uint32 r, g, b;<br> -uint32 Y;<br> -int32 Cb, Cr;</p> +uint32_t r, g, b;<br> +uint32_t Y;<br> +int32_t Cb, Cr;</p> <!-- INDENTATION --> <p>for each pixel in image</p></td> </table> @@ -535,19 +535,19 @@ as</p> <td width="24%"></td> <td width="75%"> -<p>uint32 d_Vrwr; /* Pixel values for ref. white */</p> +<p>uint32_t d_Vrwr; /* Pixel values for ref. white */</p> </td> <tr valign="top" align="left"> <td width="24%"></td> <td width="75%"> -<p>uint32 d_Vrwg;</p> +<p>uint32_t d_Vrwg;</p> </td> <tr valign="top" align="left"> <td width="24%"></td> <td width="75%"> -<p>uint32 d_Vrwb;</p> +<p>uint32_t d_Vrwb;</p> </td> <tr valign="top" align="left"> <td width="24%"></td> @@ -922,9 +922,9 @@ state.");</p> <p>}</p> <!-- INDENTATION --> <p>/* Now we can start to convert */<br> -uint32 r, g, b;<br> -uint32 L;<br> -int32 a, b;<br> +uint32_t r, g, b;<br> +uint32_t L;<br> +int32_t a, b;<br> float X, Y, Z;</p> <!-- INDENTATION --> <p>for each pixel in image</p></td> diff --git a/tiff/html/man/TIFFquery.3tiff.html b/tiff/html/man/TIFFquery.3tiff.html index 2b47fc3d..9fabecca 100644 --- a/tiff/html/man/TIFFquery.3tiff.html +++ b/tiff/html/man/TIFFquery.3tiff.html @@ -41,7 +41,7 @@ routines</p> <td width="91%"> <p><b>#include <tiffio.h></b></p> <!-- INDENTATION --> -<p><b>uint32 TIFFCurrentRow(TIFF*</b> <i>tif</i><b>)<br> +<p><b>uint32_t TIFFCurrentRow(TIFF*</b> <i>tif</i><b>)<br> tstrip_t TIFFCurrentStrip(TIFF*</b> <i>tif</i><b>)<br> ttile_t TIFFCurrentTile(TIFF*</b> <i>tif</i><b>)<br> tdir_t TIFFCurrentDirectory(TIFF*</b> <i>tif</i><b>)<br> diff --git a/tiff/html/man/TIFFstrip.3tiff.html b/tiff/html/man/TIFFstrip.3tiff.html index ae6b7903..80cdc748 100644 --- a/tiff/html/man/TIFFstrip.3tiff.html +++ b/tiff/html/man/TIFFstrip.3tiff.html @@ -39,15 +39,15 @@ TIFFRawStripSize, TIFFComputeStrip, TIFFNumberOfStrips <td width="91%"> <p><b>#include <tiffio.h></b></p> <!-- INDENTATION --> -<p><b>uint32 TIFFDefaultStripSize(TIFF *</b><i>tif</i><b>, -uint32</b> <i>estimate</i><b>)<br> +<p><b>uint32_t TIFFDefaultStripSize(TIFF *</b><i>tif</i><b>, +uint32_t</b> <i>estimate</i><b>)<br> tsize_t TIFFStripSize(TIFF *</b><i>tif</i><b>)<br> -tsize_t TIFFVStripSize(TIFF *</b><i>tif</i><b>, uint32</b> +tsize_t TIFFVStripSize(TIFF *</b><i>tif</i><b>, uint32_t</b> <i>nrows</i><b>)<br> tsize_t TIFFRawStripSize(TIFF *</b><i>tif</i><b>, tstrip_t</b> <i>strip</i><b>)<br> tstrip_t TIFFComputeStrip(TIFF *</b><i>tif</i><b>, -uint32</b> <i>row</i><b>, tsample_t</b> +uint32_t</b> <i>row</i><b>, tsample_t</b> <i>sample</i><b>)<br> tstrip_t TIFFNumberOfStrips(TIFF *</b><i>tif</i><b>)</b></p> </td> diff --git a/tiff/html/man/TIFFswab.3tiff.html b/tiff/html/man/TIFFswab.3tiff.html index 3f7ebfef..dcbf6012 100644 --- a/tiff/html/man/TIFFswab.3tiff.html +++ b/tiff/html/man/TIFFswab.3tiff.html @@ -43,11 +43,11 @@ TIFFSwabLong, TIFFSwabArrayOfShort, TIFFSwabArrayOfLong <i>reversed</i><b>)<br> void TIFFReverseBits(u_char *</b><i>data</i><b>, unsigned long</b> <i>nbytes</i><b>)<br> -void TIFFSwabShort(uint16 *</b><i>data</i><b>)<br> -void TIFFSwabLong(uint32 *</b><i>data</i><b>)<br> -void TIFFSwabArrayOfShort(uint16 *</b><i>data</i><b>, +void TIFFSwabShort(uint16_t *</b><i>data</i><b>)<br> +void TIFFSwabLong(uint32_t *</b><i>data</i><b>)<br> +void TIFFSwabArrayOfShort(uint16_t *</b><i>data</i><b>, unsigned long</b> <i>nshorts</i><b>)<br> -void TIFFSwabArrayOfLong(uint32 *</b><i>data</i><b>, +void TIFFSwabArrayOfLong(uint32_t *</b><i>data</i><b>, unsigned long</b> <i>nlongs</i><b>)</b></p> </td> </table> diff --git a/tiff/html/man/TIFFtile.3tiff.html b/tiff/html/man/TIFFtile.3tiff.html index b69cc919..2d1bb576 100644 --- a/tiff/html/man/TIFFtile.3tiff.html +++ b/tiff/html/man/TIFFtile.3tiff.html @@ -40,16 +40,16 @@ TIFFNumberOfTiles − tile-related utility routines</p> <p><b>#include <tiffio.h></b></p> <!-- INDENTATION --> <p><b>void TIFFDefaultTileSize(TIFF *</b><i>tif</i><b>, -uint32 *</b><i>tw</i><b>, uint32 *</b><i>th</i><b>)<br> +uint32_t *</b><i>tw</i><b>, uint32_t *</b><i>th</i><b>)<br> tsize_t TIFFTileSize(TIFF *</b><i>tif</i><b>)<br> tsize_t TIFFTileRowSize(TIFF *</b><i>tif</i><b>)<br> -tsize_t TIFFVTileSize(TIFF *</b><i>tif</i><b>, uint32</b> +tsize_t TIFFVTileSize(TIFF *</b><i>tif</i><b>, uint32_t</b> <i>nrows</i><b>)<br> -ttile_t TIFFComputeTile(TIFF *</b><i>tif</i><b>, uint32</b> -<i>x</i><b>, uint32</b> <i>y</i><b>, uint32</b> <i>z</i><b>, +ttile_t TIFFComputeTile(TIFF *</b><i>tif</i><b>, uint32_t</b> +<i>x</i><b>, uint32_t</b> <i>y</i><b>, uint32_t</b> <i>z</i><b>, tsample_t</b> <i>sample</i><b>)<br> -int TIFFCheckTile(TIFF *</b><i>tif</i><b>, uint32</b> -<i>x</i><b>, uint32</b> <i>y</i><b>, uint32</b> <i>z</i><b>, +int TIFFCheckTile(TIFF *</b><i>tif</i><b>, uint32_t</b> +<i>x</i><b>, uint32_t</b> <i>y</i><b>, uint32_t</b> <i>z</i><b>, tsample_t</b> <i>sample</i><b>)<br> ttile_t TIFFNumberOfTiles(TIFF *</b><i>tif</i><b>)</b></p> </td> diff --git a/tiff/html/man/libtiff.3tiff.html b/tiff/html/man/libtiff.3tiff.html index 931ae94b..5ca38dfe 100644 --- a/tiff/html/man/libtiff.3tiff.html +++ b/tiff/html/man/libtiff.3tiff.html @@ -113,7 +113,7 @@ passed through the varargs interfaces.</big></p></td> <td width="15%"></td> <td width="46%"> -<p><big>typedef unsigned short uint16;</big></p> +<p><big>typedef unsigned short uint16_t;</big></p> </td> <td width="38%"> @@ -124,7 +124,7 @@ passed through the varargs interfaces.</big></p></td> <td width="46%"> <p><big>typedef unsigned <<i>thing</i>> -uint32;</big></p> +uint32_t;</big></p> </td> <td width="38%"> @@ -144,7 +144,7 @@ uint32;</big></p> <td width="15%"></td> <td width="46%"> -<p><big>typedef uint16 tdir_t;</big></p> +<p><big>typedef uint16_t tdir_t;</big></p> </td> <td width="38%"> @@ -154,7 +154,7 @@ uint32;</big></p> <td width="15%"></td> <td width="46%"> -<p><big>typedef uint16 tsample_t;</big></p> +<p><big>typedef uint16_t tsample_t;</big></p> </td> <td width="38%"> @@ -164,7 +164,7 @@ uint32;</big></p> <td width="15%"></td> <td width="46%"> -<p><big>typedef uint32 tstrip_t;</big></p> +<p><big>typedef uint32_t tstrip_t;</big></p> </td> <td width="38%"> @@ -174,7 +174,7 @@ uint32;</big></p> <td width="15%"></td> <td width="46%"> -<p><big>typedef uint32 ttile_t;</big></p> +<p><big>typedef uint32_t ttile_t;</big></p> </td> <td width="38%"> @@ -184,7 +184,7 @@ uint32;</big></p> <td width="15%"></td> <td width="46%"> -<p><big>typedef int32 tsize_t;</big></p> +<p><big>typedef int32_t tsize_t;</big></p> </td> <td width="38%"> @@ -214,7 +214,7 @@ uint32;</big></p> <td width="15%"></td> <td width="46%"> -<p><big>typedef int32 toff_t;</big></p> +<p><big>typedef int32_t toff_t;</big></p> </td> <td width="38%"> @@ -238,7 +238,7 @@ size (w/o penalty). <i>ttag_t</i> must be either int, unsigned int, pointer, or double because the library uses a varargs interface and</big> ANSI C <big>restricts the type of the parameter before an ellipsis to be a promoted type. -<i>toff_t</i> is defined as int32 because TIFF file offsets +<i>toff_t</i> is defined as int32_t because TIFF file offsets are (unsigned) 32-bit quantities. A signed value is used because some interfaces return −1 on error. Finally, note that user-specified data references are passed as diff --git a/tiff/html/v3.4beta007.html b/tiff/html/v3.4beta007.html index c2b51f0a..77c6ac8d 100644 --- a/tiff/html/v3.4beta007.html +++ b/tiff/html/v3.4beta007.html @@ -54,7 +54,7 @@ The following information is located here: <LI>Niles Ritter's client tag extension hooks were added <LI>a new routine <TT>TIFFCurrentDirOffset</TT> was added for applications that want to find out the file offset of a TIFF directory -<LI>the calculation of the number of strips in an image was corected +<LI>the calculation of the number of strips in an image was corrected for images with certain esoteric configurations <LI>a potential memory leak (very unlikely) was plugged <LI>the <TT>TIFFReadRGBAImage</TT> support was completely rewritten diff --git a/tiff/html/v3.4beta016.html b/tiff/html/v3.4beta016.html index 11035384..e959af8e 100644 --- a/tiff/html/v3.4beta016.html +++ b/tiff/html/v3.4beta016.html @@ -55,7 +55,7 @@ The following information is located here: <LI>support was added for registering new codecs external to the library and for overriding the codecs that are builtin to the library <LI>emulation support for the old <TT>DataType</TT> tag was improved -<LI>suppport was added for the <TT>SMinSampleValue</TT> +<LI>support was added for the <TT>SMinSampleValue</TT> and <TT>SMaxSampleValue</TT> tags <LI>the library no longer ignores <TT>TileWidth</TT> and <TT>TileLength</TT> tags whose values are not a multiple of 16 (per the spec); this diff --git a/tiff/html/v3.4beta028.html b/tiff/html/v3.4beta028.html index 5ae0e490..1d54afe1 100644 --- a/tiff/html/v3.4beta028.html +++ b/tiff/html/v3.4beta028.html @@ -84,7 +84,7 @@ The following information is located here: order, and ``H'' for the bit order of the native CPU) <LI>the byte order of image and tag data written to newly-created files can now be controlled on a per-file basis through a mode parameter - supplied when openening a file (``b'' to force Big-Endian byte order + supplied when opening a file (``b'' to force Big-Endian byte order and ``l'' to force Little-Endian byte order) <LI>the use memory-mapped files for images opened read-only can now be controlled on a per-file basis through a mode parameter supplied diff --git a/tiff/html/v3.5.7.html b/tiff/html/v3.5.7.html index a58b7e5a..5ae2d26c 100644 --- a/tiff/html/v3.5.7.html +++ b/tiff/html/v3.5.7.html @@ -44,7 +44,7 @@ The following information is located here: <UL> <li> libtiff/libtiff.def: Brent Roman submitted new version adding -serveral missing entry points. Also add a few other entry points +several missing entry points. Also add a few other entry points later. <li> configure, Makefile.in, etc: added support for OPTIMIZER being @@ -152,7 +152,7 @@ later. <li> libtiff/tif_getimage.c: relax handling of contig case where there are extra samples that are supposed to be ignored as per bug 75. This -should now work for 8bit greyscale or palletted images. +should now work for 8bit greyscale or paletted images. <li> libtiff/tif_packbits.c: fixed memory overrun error as per bug 77. diff --git a/tiff/html/v3.6.0.html b/tiff/html/v3.6.0.html index 1a3ba4a9..57613867 100644 --- a/tiff/html/v3.6.0.html +++ b/tiff/html/v3.6.0.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> @@ -108,7 +108,7 @@ with externally defined tags is the primary reason for the shift to the <UL> <li> configure, config.site: Fix for large files (>2GiB) support. New -option in the config.site: LARGEFILE="yes". Should be enougth for the large +option in the config.site: LARGEFILE="yes". Should be enough for the large files I/O. <li> configure: Set -DPIXARLOG_SUPPORT option along with -DZIP_SUPPORT. diff --git a/tiff/html/v3.6.1.html b/tiff/html/v3.6.1.html index 6a357f4c..e7036c0f 100644 --- a/tiff/html/v3.6.1.html +++ b/tiff/html/v3.6.1.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> @@ -125,7 +125,7 @@ interface. YCbCr to RGB conversion code also moved there and now has <a href="./man/TIFFcolor.3t.html">publicly available interface</a>. These routines currently used in TIFFRGBAImage interface only and not supported in other libtiff tools yet. So if you want, for example, to convert CIE Lab image -into PostScript file you should do it in two steps: chnge colorspace to RGB +into PostScript file you should do it in two steps: change colorspace to RGB using <a href="./man/tiff2rgba.1.html">tiff2rgba</a> utility abd then process it with the <a href="./man/tiff2ps.1.html">tiff2ps</a>. @@ -176,7 +176,7 @@ lines. <UL> <li> contrib/pds/{tif_pdsdirread.c, tif_pdsdirwrite.c}: Use TIFFDataWidth() -function insted of tiffDataWidth array. +function instead of tiffDataWidth array. </UL> diff --git a/tiff/html/v3.7.0.html b/tiff/html/v3.7.0.html index 9c0819a4..c08fb3b6 100644 --- a/tiff/html/v3.7.0.html +++ b/tiff/html/v3.7.0.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.7.0alpha.html b/tiff/html/v3.7.0alpha.html index 39b63238..70b11177 100644 --- a/tiff/html/v3.7.0alpha.html +++ b/tiff/html/v3.7.0alpha.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.7.0beta.html b/tiff/html/v3.7.0beta.html index f646480f..8ed682ca 100644 --- a/tiff/html/v3.7.0beta.html +++ b/tiff/html/v3.7.0beta.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.7.0beta2.html b/tiff/html/v3.7.0beta2.html index 41ba6c3a..0b0b9a82 100644 --- a/tiff/html/v3.7.0beta2.html +++ b/tiff/html/v3.7.0beta2.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.7.1.html b/tiff/html/v3.7.1.html index 164b4059..66263cd5 100644 --- a/tiff/html/v3.7.1.html +++ b/tiff/html/v3.7.1.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.7.2.html b/tiff/html/v3.7.2.html index d396021e..ac1ae85d 100644 --- a/tiff/html/v3.7.2.html +++ b/tiff/html/v3.7.2.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.7.3.html b/tiff/html/v3.7.3.html index 54978c8f..bc1dc26d 100644 --- a/tiff/html/v3.7.3.html +++ b/tiff/html/v3.7.3.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.7.4.html b/tiff/html/v3.7.4.html index eeb0f3ca..a811a173 100644 --- a/tiff/html/v3.7.4.html +++ b/tiff/html/v3.7.4.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.8.0.html b/tiff/html/v3.8.0.html index 81a8b0c6..be1529ba 100644 --- a/tiff/html/v3.8.0.html +++ b/tiff/html/v3.8.0.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> @@ -110,7 +110,7 @@ The following information is located here: <a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=1003"> http://bugzilla.remotesensing.org/show_bug.cgi?id=1003</a> - <li> tif_dirinfo.c: Correctly yse bsearch() and lfind() + <li> tif_dirinfo.c: Correctly use bsearch() and lfind() functions as per bug <a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=1008"> http://bugzilla.remotesensing.org/show_bug.cgi?id=1008</a> @@ -170,7 +170,7 @@ The following information is located here: <a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=965"> http://bugzilla.remotesensing.org/show_bug.cgi?id=965</a> - <li> tiffsplit.c: Copy fax related fields over splitted parts + <li> tiffsplit.c: Copy fax related fields over split parts as per bug <a href="http://bugzilla.remotesensing.org/show_bug.cgi?id=983"> http://bugzilla.remotesensing.org/show_bug.cgi?id=983</a> diff --git a/tiff/html/v3.8.1.html b/tiff/html/v3.8.1.html index 0fe7d9c0..d53bb1fb 100644 --- a/tiff/html/v3.8.1.html +++ b/tiff/html/v3.8.1.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.8.2.html b/tiff/html/v3.8.2.html index 41bb2e55..7a33181b 100644 --- a/tiff/html/v3.8.2.html +++ b/tiff/html/v3.8.2.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.9.0beta.html b/tiff/html/v3.9.0beta.html index 56f32ed3..ef6214ad 100644 --- a/tiff/html/v3.9.0beta.html +++ b/tiff/html/v3.9.0beta.html @@ -32,7 +32,7 @@ If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> @@ -74,7 +74,7 @@ The following information is located here: tif_config.vc.h for easier identification by folks using an IDE. <li> configure, configure.ac: OJPEG support enabled by default (i.e., - whe the conformant JPEG support enabled). + when conformant JPEG support is enabled). <li> README.vms, Makefile.am, configure.com, libtiff/{Makefile.am, tif_config.h-vms, tif_stream.cxx, tif_vms.c, tiffconf.h-vms}: diff --git a/tiff/html/v3.9.1.html b/tiff/html/v3.9.1.html index 1f369a83..2f5a7afa 100644 --- a/tiff/html/v3.9.1.html +++ b/tiff/html/v3.9.1.html @@ -32,7 +32,7 @@ find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v3.9.2.html b/tiff/html/v3.9.2.html index a190a301..8bd9dc85 100644 --- a/tiff/html/v3.9.2.html +++ b/tiff/html/v3.9.2.html @@ -32,7 +32,7 @@ find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v4.0.0.html b/tiff/html/v4.0.0.html index a7e9bb63..d9b4c2bd 100644 --- a/tiff/html/v4.0.0.html +++ b/tiff/html/v4.0.0.html @@ -33,7 +33,7 @@ it was not considered important enough to be mentioned. Please consult the ChangeLog file in the source package for full change details. The following information is located here: <UL> -<LI><A HREF="#hightlights">Major Changes</A> +<LI><A HREF="#highlights">Major Changes</A> <LI><A HREF="#configure">Changes in the software configuration</A> <LI><A HREF="#libtiff">Changes in libtiff</A> <LI><A HREF="#tools">Changes in the tools</A> diff --git a/tiff/html/v4.0.4beta.html b/tiff/html/v4.0.4beta.html index e9e70a55..66e451a8 100644 --- a/tiff/html/v4.0.4beta.html +++ b/tiff/html/v4.0.4beta.html @@ -112,7 +112,7 @@ information is located here: putcontig8bitYCbCr21tile cases. <li> in TIFFDefaultDirectory(), reset any already existing - extented tags installed by user code through the extender mechaninm before + extended tags installed by user code through the extender mechaninm before calling the extender callback (GDAL #5054) <li> Fix warnings about unused parameters. diff --git a/tiff/html/v4.0.7.html b/tiff/html/v4.0.7.html index 4f92c129..dab75df8 100644 --- a/tiff/html/v4.0.7.html +++ b/tiff/html/v4.0.7.html @@ -252,7 +252,7 @@ information is located here: tif_encodestrip() as documented <LI> libtiff/tif_dumpmode.c: DumpModeEncode() should return 0 in - case of failure so that the above mentionned functions detect + case of failure so that the above mentioned functions detect the error. <LI> libtiff/*.c: fix MSVC warnings related to cast shortening and diff --git a/tiff/html/v4.0.8.html b/tiff/html/v4.0.8.html index bd3f751c..456f2bdb 100644 --- a/tiff/html/v4.0.8.html +++ b/tiff/html/v4.0.8.html @@ -98,7 +98,7 @@ information is located here: makes it unnecessary. <LI> libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() - to instanciate compute ntrips as + to instantiate compute ntrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip), instead of a logic based on the total size of data. Which is faulty is the total size of data is not sufficient to fill the whole image, diff --git a/tiff/html/v4.0.9.html b/tiff/html/v4.0.9.html index 19b370a4..6ab33510 100644 --- a/tiff/html/v4.0.9.html +++ b/tiff/html/v4.0.9.html @@ -170,7 +170,7 @@ information is located here: scans and not interleavedin a single one, needs to allocate memory (or backing store) for the whole strip/tile. See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf - This limitation may be overriden by setting the + This limitation may be overridden by setting the LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompiling libtiff with a custom value of TIFF_LIBJPEG_LARGEST_MEM_ALLOC macro. <LI> libtiff/tif_jbig.c: fix memory leak in error code path of JBIGDecode() diff --git a/tiff/html/v4.1.0.html b/tiff/html/v4.1.0.html index 80dac5bf..4828bcc0 100644 --- a/tiff/html/v4.1.0.html +++ b/tiff/html/v4.1.0.html @@ -59,12 +59,12 @@ hr { <div style="margin-left: 3em"> <HR SIZE=4 ALIGN=left> <B>Current Version</B>: v4.1.0<BR> -<B>Previous Version</B>: <A HREF=v4.0.10.html>v4.0.10</a><BR> -<B>Master Download Site</B>: <A HREF="https://download.osgeo.org/libtiff"> -download.osgeo.org</a>, directory pub/libtiff<<BR> -<B>Master HTTP Site #1</B>: <A HREF="http://www.simplesystems.org/libtiff/"> +<B>Previous Version</B>: <A HREF=v4.0.10.html>v4.0.10</A><BR> +<B>Master Download Site</B>: <A HREF="https://download.osgeo.org/libtiff"</A> +download.osgeo.org</a>, directory pub/libtiff<BR> +<B>Master HTTP Site #1</B>: <A HREF="http://www.simplesystems.org/libtiff/"</A> http://www.simplesystems.org/libtiff/</a><BR> -<B>Master HTTP Site #2</B>: <A HREF="http://libtiff.maptools.org/"> +<B>Master HTTP Site #2</B>: <A HREF="http://libtiff.maptools.org/"</A> http://libtiff.maptools.org/</a> <HR SIZE=4 ALIGN=left> </div> diff --git a/tiff/html/v4.2.0.html b/tiff/html/v4.2.0.html index c81ecdd2..58d0bfc3 100644 --- a/tiff/html/v4.2.0.html +++ b/tiff/html/v4.2.0.html @@ -59,12 +59,14 @@ hr { <div style="margin-left: 3em"> <HR SIZE=4 ALIGN=left> <B>Current Version</B>: v4.2.0<BR> -<B>Previous Version</B>: <A HREF=v4.1.0.html>v4.1.0</a><BR> +<B>Previous Version</B>: <A HREF="v4.1.0.html">v4.1.0</A><BR> <B>Master Download Site</B>: <A HREF="https://download.osgeo.org/libtiff"> -download.osgeo.org</a>, directory pub/libtiff<<BR> +download.osgeo.org</a>, directory pub/libtiff<BR> <B>Master HTTP Site #1</B>: <A HREF="http://www.simplesystems.org/libtiff/"> -http://www.simplesystems.org/libtiff/</a><BR> -<B>Master HTTP Site #2</B>: <A HREF="http://libtiff.maptools.org/"> + http://www.simplesystems.org/libtiff/</A><BR> +<B>Master HTTP Site #2</B>: <A HREF="https://libtiff.gitlab.io/libtiff/"> + https://libtiff.gitlab.io/libtiff/</A><BR> +<B>Master HTTP Site #3</B>: <A HREF="http://libtiff.maptools.org/"> http://libtiff.maptools.org/</a> <HR SIZE=4 ALIGN=left> </div> diff --git a/tiff/html/v4.3.0.html b/tiff/html/v4.3.0.html new file mode 100644 index 00000000..64f9fa7f --- /dev/null +++ b/tiff/html/v4.3.0.html @@ -0,0 +1,186 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<HTML> +<HEAD> +<TITLE> + Changes in TIFF v4.3.0 +</TITLE> +<STYLE TYPE="text/css"> +body { + font-family: Helvetica, Arial, Sans; +} +table, th, td { + border: 1px solid black; + border-collapse: collapse; +} +th, td { + padding: 8pt; + text-align: center; +} +th { + text-align: center; +} +td { + text-align: center; +} + +ul li { + padding: 3pt; +} + +ul.a { + list-style-type: circle; +} + +ul.b { + list-style-type: square; +} + +ol.c { + list-style-type: upper-roman; +} + +ol.d { + list-style-type: lower-alpha; +} + +hr { + width: 65%; +} + +</STYLE> +</HEAD> + +<BODY BGCOLOR=white> + +<BASEFONT SIZE=4> +<B><FONT SIZE="+3">T</FONT>IFF <FONT SIZE="+2">C</FONT>HANGE <FONT SIZE="+2">I</FONT>NFORMATION</B> +<BASEFONT SIZE=3> + +<div style="margin-left: 3em"> +<HR SIZE=4 ALIGN=left> +<B>Current Version</B>: v4.3.0<BR> +<B>Previous Version</B>: <A HREF="v4.2.0.html">v4.2.0</A><BR> +<B>Master Download Site</B>: <A HREF="https://download.osgeo.org/libtiff"> +download.osgeo.org</a>, directory pub/libtiff<BR> +<B>Master HTTP Site #1</B>: <A HREF="http://www.simplesystems.org/libtiff/"> + http://www.simplesystems.org/libtiff/</A><BR> +<B>Master HTTP Site #2</B>: <A HREF="https://libtiff.gitlab.io/libtiff/"> + https://libtiff.gitlab.io/libtiff/</A><BR> +<B>Master HTTP Site #3</B>: <A HREF="http://libtiff.maptools.org/"> +http://libtiff.maptools.org/</a> +<HR SIZE=4 ALIGN=left> +</div> + +<P> +This document provides a summary of significant changes made to the +software between the <I>previous</I> and <I>current</I> versions (see +above). A fully-detailed change summary is provided by the ChangeLog file +included in the release package and by the Git commit history: +<UL> +<LI><A HREF="#highlights">Major Changes</A> +<LI><A HREF="#configure">Changes in the software configuration</A> +<LI><A HREF="#libtiff">Changes in libtiff</A> +<LI><A HREF="#tools">Changes in the tools</A> +<LI><A HREF="#contrib">Changes in the contrib area</A> +</UL> +<p> +<P><HR ALIGN=left> + +<!-- ============================================================= --> + +<A NAME="highlights"><B><FONT SIZE="+3">M</FONT>AJOR CHANGES:</B></A> + +<UL> + + <LI>Build and usage of the library and its utilities requires a C99 capable + compiler.</LI> + + <LI>New optional codec for the LERC (Limited Error Raster Compression) compression scheme. + To have it available, configure libtiff against the SDK available at + https://github.com/esri/lerc</LI> + + <LI>CMake build: revamp of build scripts</LI> +</UL> + + +<P><HR ALIGN=left> +<!-- ============================================================= --> + +<A NAME="configure"><B><FONT SIZE="+3">C</FONT>HANGES IN THE SOFTWARE CONFIGURATION:</B></A> + +<UL> + + <LI>cmake: revamp of the cmake build scripts. There are impacts on the case of + some options.</LI> + + <LI>cmake: update minimum version and policy version to 3.9.</LI> + + <LI>Remove NMake build support. The functionality provided by the NMake build + is now completely superseded by the CMake build.</LI> + + <LI>Remove antiquated Scons and makefile.lcc build support.</LI> + + <LI>Remove non-functional VMS and WinCE support.</LI> + + <LI>autogen.sh now updates config.guess and config.sub from master gnulib version.</LI> + +</UL> + +<P><HR ALIGN=left> + +<!-- ============================================================= --> + +<A NAME="libtiff"><B><FONT SIZE="+3">C</FONT>HANGES IN LIBTIFF:</B></A> + +<UL> + + <LI>Use of "int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64" + typedefs is now deprecated. libtiff code and headers no longer use them, + and use their C99 standard equivalents (with "_t" suffix). Those typedefs + are still available, with deprecation warnings, but external code is strongly + encouraged to use the corresponding C99 stdint.h types. The deprecated + types might be removed in a future release.</LI> + + <LI>Removal of unused, or now useless due to C99 availability, functions in port/</LI> + + <LI>A few issues spotted by static code analysis tools fixed. Compiler + warnings addressed.</LI> +</UL> + +<P><HR ALIGN=left> + +<!-- ============================================================= --> + +<A NAME="tools"><B><FONT SIZE="+3">C</FONT>HANGES IN THE TOOLS:</B></A> + +<UL> + + <LI>In usage text, insert a line of text summarizing each tool's purpose </LI> + + <LI>tiff tools: made display of compression methods and their parameters + conditional on their actual availability</LI> + + <LI>tiff2ps: exit the loop in case of error (#232)</LI> + + <LI>tiff2pdf: check that tiff_datasize fits in a signed tsize_t (#202)</LI> + + <LI>tiffsplit: exit with EXIT_FAILURE if there are extra args on the command line</LI> + + <LI>tiffcmp: fix comparaison with pixels that are fractional number of bytes (#53)</LI> + +</UL> + +<P><HR ALIGN=left> + +<!-- ============================================================= --> + +<A NAME="contrib"><B><FONT SIZE="+3">C</FONT>HANGES IN THE CONTRIB AREA:</B></A> + +<UL> + + <LI>iptcutil.c - set '#ifdef _WIN32' (was '#ifdef WIN32', which failed at build time)</LI> + +</UL> + +</BODY> +</HTML> diff --git a/tiff/libtiff/CMakeLists.txt b/tiff/libtiff/CMakeLists.txt index 080685db..90105b28 100644..100755 --- a/tiff/libtiff/CMakeLists.txt +++ b/tiff/libtiff/CMakeLists.txt @@ -30,97 +30,112 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h @ONLY) -extra_dist( - SConstruct - tif_config.h-vms - tif_config.vc.h - tif_config.wince.h - tiffconf.vc.h - tiffconf.wince.h - libtiff.def - libtiff.map - libtiffxx.map) - -set(tiff_HEADERS - tiff.h - tiffio.h - tiffvers.h) - -set(tiff_noinst_HEADERS - t4.h - tif_dir.h - tif_predict.h - tiffiop.h - uvcode.h) - -set(nodist_tiff_HEADERS - ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h) - -set(tiff_SOURCES - tif_aux.c - tif_close.c - tif_codec.c - tif_color.c - tif_compress.c - tif_dir.c - tif_dirinfo.c - tif_dirread.c - tif_dirwrite.c - tif_dumpmode.c - tif_error.c - tif_extension.c - tif_fax3.c - tif_fax3sm.c - tif_flush.c - tif_getimage.c - tif_jbig.c - tif_jpeg.c - tif_jpeg_12.c - tif_luv.c - tif_lzma.c - tif_lzw.c - tif_next.c - tif_ojpeg.c - tif_open.c - tif_packbits.c - tif_pixarlog.c - tif_predict.c - tif_print.c - tif_read.c - tif_strip.c - tif_swab.c - tif_thunder.c - tif_tile.c - tif_version.c - tif_warning.c - tif_webp.c - tif_write.c - tif_zip.c - tif_zstd.c) - -set(tiffxx_HEADERS - tiffio.hxx) - -set(tiffxx_SOURCES - tif_stream.cxx) +set(tiff_public_HEADERS + tiff.h + tiffio.h + tiffvers.h + ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h) + +set(tiff_private_HEADERS + t4.h + tif_dir.h + tif_predict.h + tiffiop.h + uvcode.h + ${CMAKE_CURRENT_BINARY_DIR}/tif_config.h) + + +add_library(tiff libtiff.def) + +target_sources(tiff PRIVATE + ${tiff_public_HEADERS} + ${tiff_private_HEADERS} + tif_aux.c + tif_close.c + tif_codec.c + tif_color.c + tif_compress.c + tif_dir.c + tif_dirinfo.c + tif_dirread.c + tif_dirwrite.c + tif_dumpmode.c + tif_error.c + tif_extension.c + tif_fax3.c + tif_fax3sm.c + tif_flush.c + tif_getimage.c + tif_jbig.c + tif_jpeg.c + tif_jpeg_12.c + tif_lerc.c + tif_luv.c + tif_lzma.c + tif_lzw.c + tif_next.c + tif_ojpeg.c + tif_open.c + tif_packbits.c + tif_pixarlog.c + tif_predict.c + tif_print.c + tif_read.c + tif_strip.c + tif_swab.c + tif_thunder.c + tif_tile.c + tif_version.c + tif_warning.c + tif_webp.c + tif_write.c + tif_zip.c + tif_zstd.c) if(USE_WIN32_FILEIO) - extra_dist(tif_unix.c) - list(APPEND tiff_SOURCES tif_win32.c) + target_sources(tiff PRIVATE tif_win32.c) else() - extra_dist(tif_win32.c) - list(APPEND tiff_SOURCES tif_unix.c) + target_sources(tiff PRIVATE tif_unix.c) endif() -add_library(tiff ${tiff_SOURCES} ${tiff_HEADERS} ${nodist_tiff_HEADERS} - ${tiff_port_SOURCES} libtiff.def) target_include_directories(tiff PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> + PRIVATE ${TIFF_INCLUDES} ) -target_link_libraries(tiff ${TIFF_LIBRARY_DEPS}) + +if(ZIP_SUPPORT) + target_link_libraries(tiff PRIVATE ZLIB::ZLIB) +endif() +if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) + target_link_libraries(tiff PRIVATE Deflate::Deflate) +endif() +if(JPEG_SUPPORT) + target_link_libraries(tiff PRIVATE JPEG::JPEG) + if(JPEG_DUAL_MODE_8_12) + target_include_directories(tiff PRIVATE ${JPEG12_INCLUDE_DIR}) + target_link_libraries(tiff PRIVATE ${JPEG12_LIBRARIES}) + endif() +endif() +if(JBIG_SUPPORT) + target_link_libraries(tiff PRIVATE JBIG::JBIG) +endif() +if(LERC_SUPPORT) + target_link_libraries(tiff PRIVATE LERC::LERC) +endif() +if(LZMA_SUPPORT) + target_link_libraries(tiff PRIVATE LibLZMA::LibLZMA) +endif() +if(ZSTD_SUPPORT) + target_link_libraries(tiff PRIVATE ZSTD::ZSTD) +endif() +if(WEBP_SUPPORT) + target_link_libraries(tiff PRIVATE WebP::WebP) +endif() +target_link_libraries(tiff PRIVATE CMath::CMath) + set_target_properties(tiff PROPERTIES SOVERSION ${SO_COMPATVERSION}) if(NOT CYGWIN) # This property causes shared libraries on Linux to have the full version @@ -139,11 +154,17 @@ install(TARGETS tiff LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) -install(FILES ${tiff_HEADERS} ${nodist_tiff_HEADERS} +install(FILES ${tiff_public_HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") if(CXX_SUPPORT) - add_library(tiffxx ${tiffxx_SOURCES} ${tiffxx_HEADERS}) + set(tiffxx_HEADERS + tiffio.hxx) + + add_library(tiffxx) + target_sources(tiffxx PRIVATE + ${tiffxx_HEADERS} + tif_stream.cxx) target_link_libraries(tiffxx tiff) set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION}) if(NOT CYGWIN) @@ -167,3 +188,13 @@ if(CXX_SUPPORT) DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") endif() + +add_executable(mkg3states) +target_sources(mkg3states PRIVATE mkg3states.c tif_fax3.h) +target_link_libraries(mkg3states tiff port) + +add_custom_target(faxtable + DEPENDS mkg3states + COMMAND ${CMAKE_COMMAND} -E rm "tif_fax3sm.c" + COMMAND mkg3states -b -c const "tif_fax3sm.c" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/tiff/libtiff/Makefile.am b/tiff/libtiff/Makefile.am index 14a250a5..44522b62 100644 --- a/tiff/libtiff/Makefile.am +++ b/tiff/libtiff/Makefile.am @@ -29,18 +29,11 @@ libtiffincludedir = $(includedir) EXTRA_DIST = \ CMakeLists.txt \ - Makefile.vc \ - SConstruct \ libtiff.def \ libtiff.map \ libtiffxx.map \ - tif_config.h-vms \ tif_config.h.cmake.in \ - tif_config.vc.h \ - tif_config.wince.h \ - tiffconf.h.cmake.in \ - tiffconf.vc.h \ - tiffconf.wince.h + tiffconf.h.cmake.in libtiffinclude_HEADERS = \ tiff.h \ @@ -81,6 +74,7 @@ libtiff_la_SOURCES = \ tif_jbig.c \ tif_jpeg.c \ tif_jpeg_12.c \ + tif_lerc.c \ tif_luv.c \ tif_lzma.c \ tif_lzw.c \ @@ -128,7 +122,6 @@ endif if HAVE_LD_VERSION_SCRIPT libtiff_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiff.map endif -libtiff_la_LIBADD = $(LIBPORT) libtiffxx_la_LDFLAGS = \ -no-undefined \ @@ -139,7 +132,7 @@ endif if HAVE_LD_VERSION_SCRIPT libtiffxx_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiffxx.map endif -libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT) +libtiffxx_la_LIBADD = $(LIBTIFF) libtiffxx_la_DEPENDENCIES = libtiff.la # @@ -154,3 +147,4 @@ mkg3states_LDADD = $(LIBPORT) faxtable: mkg3states (rm -f tif_fax3sm.c && ./mkg3states -b -c const tif_fax3sm.c) +AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port diff --git a/tiff/libtiff/Makefile.in b/tiff/libtiff/Makefile.in index 2f853ea5..40b78797 100644 --- a/tiff/libtiff/Makefile.in +++ b/tiff/libtiff/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -137,7 +137,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ DIST_COMMON = $(srcdir)/Makefile.am $(am__libtiffinclude_HEADERS_DIST) \ $(noinst_HEADERS) $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = tif_config.h tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h tif_config.h tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) @@ -172,17 +173,17 @@ am__installdirs = "$(DESTDIR)$(libdir)" \ "$(DESTDIR)$(libtiffincludedir)" \ "$(DESTDIR)$(libtiffincludedir)" LTLIBRARIES = $(lib_LTLIBRARIES) -libtiff_la_DEPENDENCIES = $(LIBPORT) +libtiff_la_LIBADD = am__libtiff_la_SOURCES_DIST = tif_aux.c tif_close.c tif_codec.c \ tif_color.c tif_compress.c tif_dir.c tif_dirinfo.c \ tif_dirread.c tif_dirwrite.c tif_dumpmode.c tif_error.c \ tif_extension.c tif_fax3.c tif_fax3sm.c tif_flush.c \ - tif_getimage.c tif_jbig.c tif_jpeg.c tif_jpeg_12.c tif_luv.c \ - tif_lzma.c tif_lzw.c tif_next.c tif_ojpeg.c tif_open.c \ - tif_packbits.c tif_pixarlog.c tif_predict.c tif_print.c \ - tif_read.c tif_strip.c tif_swab.c tif_thunder.c tif_tile.c \ - tif_version.c tif_warning.c tif_webp.c tif_write.c tif_zip.c \ - tif_zstd.c tif_win32.c tif_unix.c + tif_getimage.c tif_jbig.c tif_jpeg.c tif_jpeg_12.c tif_lerc.c \ + tif_luv.c tif_lzma.c tif_lzw.c tif_next.c tif_ojpeg.c \ + tif_open.c tif_packbits.c tif_pixarlog.c tif_predict.c \ + tif_print.c tif_read.c tif_strip.c tif_swab.c tif_thunder.c \ + tif_tile.c tif_version.c tif_warning.c tif_webp.c tif_write.c \ + tif_zip.c tif_zstd.c tif_win32.c tif_unix.c @WIN32_IO_TRUE@am__objects_1 = tif_win32.lo @WIN32_IO_FALSE@am__objects_2 = tif_unix.lo am_libtiff_la_OBJECTS = tif_aux.lo tif_close.lo tif_codec.lo \ @@ -190,11 +191,11 @@ am_libtiff_la_OBJECTS = tif_aux.lo tif_close.lo tif_codec.lo \ tif_dirread.lo tif_dirwrite.lo tif_dumpmode.lo tif_error.lo \ tif_extension.lo tif_fax3.lo tif_fax3sm.lo tif_flush.lo \ tif_getimage.lo tif_jbig.lo tif_jpeg.lo tif_jpeg_12.lo \ - tif_luv.lo tif_lzma.lo tif_lzw.lo tif_next.lo tif_ojpeg.lo \ - tif_open.lo tif_packbits.lo tif_pixarlog.lo tif_predict.lo \ - tif_print.lo tif_read.lo tif_strip.lo tif_swab.lo \ - tif_thunder.lo tif_tile.lo tif_version.lo tif_warning.lo \ - tif_webp.lo tif_write.lo tif_zip.lo tif_zstd.lo \ + tif_lerc.lo tif_luv.lo tif_lzma.lo tif_lzw.lo tif_next.lo \ + tif_ojpeg.lo tif_open.lo tif_packbits.lo tif_pixarlog.lo \ + tif_predict.lo tif_print.lo tif_read.lo tif_strip.lo \ + tif_swab.lo tif_thunder.lo tif_tile.lo tif_version.lo \ + tif_warning.lo tif_webp.lo tif_write.lo tif_zip.lo tif_zstd.lo \ $(am__objects_1) $(am__objects_2) libtiff_la_OBJECTS = $(am_libtiff_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -225,7 +226,7 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/port depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/mkg3states.Po \ @@ -238,19 +239,19 @@ am__depfiles_remade = ./$(DEPDIR)/mkg3states.Po \ ./$(DEPDIR)/tif_fax3.Plo ./$(DEPDIR)/tif_fax3sm.Plo \ ./$(DEPDIR)/tif_flush.Plo ./$(DEPDIR)/tif_getimage.Plo \ ./$(DEPDIR)/tif_jbig.Plo ./$(DEPDIR)/tif_jpeg.Plo \ - ./$(DEPDIR)/tif_jpeg_12.Plo ./$(DEPDIR)/tif_luv.Plo \ - ./$(DEPDIR)/tif_lzma.Plo ./$(DEPDIR)/tif_lzw.Plo \ - ./$(DEPDIR)/tif_next.Plo ./$(DEPDIR)/tif_ojpeg.Plo \ - ./$(DEPDIR)/tif_open.Plo ./$(DEPDIR)/tif_packbits.Plo \ - ./$(DEPDIR)/tif_pixarlog.Plo ./$(DEPDIR)/tif_predict.Plo \ - ./$(DEPDIR)/tif_print.Plo ./$(DEPDIR)/tif_read.Plo \ - ./$(DEPDIR)/tif_stream.Plo ./$(DEPDIR)/tif_strip.Plo \ - ./$(DEPDIR)/tif_swab.Plo ./$(DEPDIR)/tif_thunder.Plo \ - ./$(DEPDIR)/tif_tile.Plo ./$(DEPDIR)/tif_unix.Plo \ - ./$(DEPDIR)/tif_version.Plo ./$(DEPDIR)/tif_warning.Plo \ - ./$(DEPDIR)/tif_webp.Plo ./$(DEPDIR)/tif_win32.Plo \ - ./$(DEPDIR)/tif_write.Plo ./$(DEPDIR)/tif_zip.Plo \ - ./$(DEPDIR)/tif_zstd.Plo + ./$(DEPDIR)/tif_jpeg_12.Plo ./$(DEPDIR)/tif_lerc.Plo \ + ./$(DEPDIR)/tif_luv.Plo ./$(DEPDIR)/tif_lzma.Plo \ + ./$(DEPDIR)/tif_lzw.Plo ./$(DEPDIR)/tif_next.Plo \ + ./$(DEPDIR)/tif_ojpeg.Plo ./$(DEPDIR)/tif_open.Plo \ + ./$(DEPDIR)/tif_packbits.Plo ./$(DEPDIR)/tif_pixarlog.Plo \ + ./$(DEPDIR)/tif_predict.Plo ./$(DEPDIR)/tif_print.Plo \ + ./$(DEPDIR)/tif_read.Plo ./$(DEPDIR)/tif_stream.Plo \ + ./$(DEPDIR)/tif_strip.Plo ./$(DEPDIR)/tif_swab.Plo \ + ./$(DEPDIR)/tif_thunder.Plo ./$(DEPDIR)/tif_tile.Plo \ + ./$(DEPDIR)/tif_unix.Plo ./$(DEPDIR)/tif_version.Plo \ + ./$(DEPDIR)/tif_warning.Plo ./$(DEPDIR)/tif_webp.Plo \ + ./$(DEPDIR)/tif_win32.Plo ./$(DEPDIR)/tif_write.Plo \ + ./$(DEPDIR)/tif_zip.Plo ./$(DEPDIR)/tif_zstd.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -301,8 +302,8 @@ am__libtiffinclude_HEADERS_DIST = tiff.h tiffio.h tiffvers.h \ tiffio.hxx HEADERS = $(libtiffinclude_HEADERS) $(nodist_libtiffinclude_HEADERS) \ $(noinst_HEADERS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ - tif_config.h.in tiffconf.h.in +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)tif_config.h.in tiffconf.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. @@ -463,6 +464,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -475,11 +477,9 @@ top_srcdir = @top_srcdir@ LIBPORT = $(top_builddir)/port/libport.la LIBTIFF = $(top_builddir)/libtiff/libtiff.la libtiffincludedir = $(includedir) -EXTRA_DIST = CMakeLists.txt Makefile.vc SConstruct libtiff.def \ - libtiff.map libtiffxx.map tif_config.h-vms \ - tif_config.h.cmake.in tif_config.vc.h tif_config.wince.h \ - tiffconf.h.cmake.in tiffconf.vc.h tiffconf.wince.h \ - $(am__append_2) $(am__append_4) +EXTRA_DIST = CMakeLists.txt libtiff.def libtiff.map libtiffxx.map \ + tif_config.h.cmake.in tiffconf.h.cmake.in $(am__append_2) \ + $(am__append_4) libtiffinclude_HEADERS = tiff.h tiffio.h tiffvers.h $(am__append_1) noinst_HEADERS = \ t4.h \ @@ -495,8 +495,8 @@ libtiff_la_SOURCES = tif_aux.c tif_close.c tif_codec.c tif_color.c \ tif_compress.c tif_dir.c tif_dirinfo.c tif_dirread.c \ tif_dirwrite.c tif_dumpmode.c tif_error.c tif_extension.c \ tif_fax3.c tif_fax3sm.c tif_flush.c tif_getimage.c tif_jbig.c \ - tif_jpeg.c tif_jpeg_12.c tif_luv.c tif_lzma.c tif_lzw.c \ - tif_next.c tif_ojpeg.c tif_open.c tif_packbits.c \ + tif_jpeg.c tif_jpeg_12.c tif_lerc.c tif_luv.c tif_lzma.c \ + tif_lzw.c tif_next.c tif_ojpeg.c tif_open.c tif_packbits.c \ tif_pixarlog.c tif_predict.c tif_print.c tif_read.c \ tif_strip.c tif_swab.c tif_thunder.c tif_tile.c tif_version.c \ tif_warning.c tif_webp.c tif_write.c tif_zip.c tif_zstd.c \ @@ -507,13 +507,13 @@ libtiffxx_la_SOURCES = \ lib_LTLIBRARIES = libtiff.la $(am__append_6) libtiff_la_LDFLAGS = -no-undefined -version-info \ $(LIBTIFF_VERSION_INFO) $(am__append_7) $(am__append_8) -libtiff_la_LIBADD = $(LIBPORT) libtiffxx_la_LDFLAGS = -no-undefined -version-info \ $(LIBTIFF_VERSION_INFO) $(am__append_9) $(am__append_10) -libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT) +libtiffxx_la_LIBADD = $(LIBTIFF) libtiffxx_la_DEPENDENCIES = libtiff.la mkg3states_SOURCES = mkg3states.c tif_fax3.h mkg3states_LDADD = $(LIBPORT) +AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port all: tif_config.h tiffconf.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -549,28 +549,24 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -tif_config.h: stamp-h1 - @test -f $@ || rm -f stamp-h1 - @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 - -stamp-h1: $(srcdir)/tif_config.h.in $(top_builddir)/config.status - @rm -f stamp-h1 - cd $(top_builddir) && $(SHELL) ./config.status libtiff/tif_config.h -$(srcdir)/tif_config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) - rm -f stamp-h1 - touch $@ - -tiffconf.h: stamp-h2 +tif_config.h: stamp-h2 @test -f $@ || rm -f stamp-h2 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h2 -stamp-h2: $(srcdir)/tiffconf.h.in $(top_builddir)/config.status +stamp-h2: $(srcdir)/tif_config.h.in $(top_builddir)/config.status @rm -f stamp-h2 + cd $(top_builddir) && $(SHELL) ./config.status libtiff/tif_config.h + +tiffconf.h: stamp-h3 + @test -f $@ || rm -f stamp-h3 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h3 + +stamp-h3: $(srcdir)/tiffconf.h.in $(top_builddir)/config.status + @rm -f stamp-h3 cd $(top_builddir) && $(SHELL) ./config.status libtiff/tiffconf.h distclean-hdr: - -rm -f tif_config.h stamp-h1 tiffconf.h stamp-h2 + -rm -f tif_config.h stamp-h2 tiffconf.h stamp-h3 clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ @@ -652,6 +648,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_jbig.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_jpeg.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_jpeg_12.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_lerc.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_luv.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_lzma.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_lzw.Plo@am__quote@ # am--include-marker @@ -922,6 +919,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/tif_jbig.Plo -rm -f ./$(DEPDIR)/tif_jpeg.Plo -rm -f ./$(DEPDIR)/tif_jpeg_12.Plo + -rm -f ./$(DEPDIR)/tif_lerc.Plo -rm -f ./$(DEPDIR)/tif_luv.Plo -rm -f ./$(DEPDIR)/tif_lzma.Plo -rm -f ./$(DEPDIR)/tif_lzw.Plo @@ -1012,6 +1010,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/tif_jbig.Plo -rm -f ./$(DEPDIR)/tif_jpeg.Plo -rm -f ./$(DEPDIR)/tif_jpeg_12.Plo + -rm -f ./$(DEPDIR)/tif_lerc.Plo -rm -f ./$(DEPDIR)/tif_luv.Plo -rm -f ./$(DEPDIR)/tif_lzma.Plo -rm -f ./$(DEPDIR)/tif_lzw.Plo diff --git a/tiff/libtiff/Makefile.vc b/tiff/libtiff/Makefile.vc deleted file mode 100644 index 5aac3310..00000000 --- a/tiff/libtiff/Makefile.vc +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# -# Makefile for MS Visual C and Watcom C compilers. -# -# To build: -# C:\libtiff\libtiff> nmake /f makefile.vc all -# - -!INCLUDE ..\nmake.opt - -INCL = -I. $(JPEG_INCLUDE) $(ZLIB_INCLUDE) $(JBIG_INCLUDE) - -!IFDEF USE_WIN_CRT_LIB -OBJ_SYSDEP_MODULE = tif_unix.obj -!ELSE -OBJ_SYSDEP_MODULE = tif_win32.obj -!ENDIF - -OBJ = \ - tif_aux.obj \ - tif_close.obj \ - tif_codec.obj \ - tif_color.obj \ - tif_compress.obj \ - tif_dir.obj \ - tif_dirinfo.obj \ - tif_dirread.obj \ - tif_dirwrite.obj \ - tif_dumpmode.obj \ - tif_error.obj \ - tif_extension.obj \ - tif_fax3.obj \ - tif_fax3sm.obj \ - tif_getimage.obj \ - tif_jbig.obj \ - tif_jpeg.obj \ - tif_jpeg_12.obj \ - tif_ojpeg.obj \ - tif_flush.obj \ - tif_luv.obj \ - tif_lzw.obj \ - tif_next.obj \ - tif_open.obj \ - tif_packbits.obj \ - tif_pixarlog.obj \ - tif_predict.obj \ - tif_print.obj \ - tif_read.obj \ - tif_stream.obj \ - tif_swab.obj \ - tif_strip.obj \ - tif_thunder.obj \ - tif_tile.obj \ - tif_version.obj \ - tif_warning.obj \ - tif_write.obj \ - tif_zip.obj \ - $(OBJ_SYSDEP_MODULE) - -all: libtiff.lib $(DLLNAME) - -tif_config.h: tif_config.vc.h - copy tif_config.vc.h tif_config.h - -tiffconf.h: tiffconf.vc.h - copy tiffconf.vc.h tiffconf.h - -libtiff.lib: tif_config.h tiffconf.h $(OBJ) - $(AR) /out:libtiff.lib ..\port\libport.lib $(OBJ) $(LIBS) - -$(DLLNAME): tif_config.h tiffconf.h libtiff.def $(OBJ) - $(LD) /debug /dll /def:libtiff.def /out:$(DLLNAME) \ - /implib:libtiff_i.lib ..\port\libport.lib $(OBJ) $(LIBS) - -clean: - -del tif_config.h tiffconf.h - -del *.obj - -del *.lib - -del *.dll - -del *.dll.manifest - -del *.pdb diff --git a/tiff/libtiff/SConstruct b/tiff/libtiff/SConstruct deleted file mode 100644 index af3daace..00000000 --- a/tiff/libtiff/SConstruct +++ /dev/null @@ -1,71 +0,0 @@ -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2005, Andrey Kiselev <dron@ak4719.spb.edu> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# This file contains rules to build software with the SCons tool -# (see the http://www.scons.org/ for details on SCons). - -# Import globally defined options -Import([ 'env', 'idir_lib' ]) - -SRCS = [ \ - 'tif_aux.c', \ - 'tif_close.c', \ - 'tif_codec.c', \ - 'tif_color.c', \ - 'tif_compress.c', \ - 'tif_dir.c', \ - 'tif_dirinfo.c', \ - 'tif_dirread.c', \ - 'tif_dirwrite.c', \ - 'tif_dumpmode.c', \ - 'tif_error.c', \ - 'tif_extension.c', \ - 'tif_fax3.c', \ - 'tif_fax3sm.c', \ - 'tif_flush.c', \ - 'tif_getimage.c', \ - 'tif_jbig.c', \ - 'tif_jpeg.c', \ - 'tif_luv.c', \ - 'tif_lzw.c', \ - 'tif_next.c', \ - 'tif_ojpeg.c', \ - 'tif_open.c', \ - 'tif_packbits.c', \ - 'tif_pixarlog.c', \ - 'tif_predict.c', \ - 'tif_print.c', \ - 'tif_read.c', \ - 'tif_strip.c', \ - 'tif_swab.c', \ - 'tif_thunder.c', \ - 'tif_tile.c', \ - 'tif_unix.c', \ - 'tif_version.c', \ - 'tif_warning.c', \ - 'tif_write.c', \ - 'tif_zip.c' ] - -StaticLibrary('tiff', SRCS) -SharedLibrary('tiff', SRCS) - diff --git a/tiff/libtiff/mkg3states.c b/tiff/libtiff/mkg3states.c index 2cb9174c..44653255 100644 --- a/tiff/libtiff/mkg3states.c +++ b/tiff/libtiff/mkg3states.c @@ -28,6 +28,7 @@ * Copyright (C) 1990, 1995 Frank D. Cringle. */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -39,10 +40,6 @@ #include "tif_fax3.h" -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - #define streq(a,b) (strcmp(a,b) == 0) /* NB: can't use names in tif_fax3.h 'cuz they are declared const */ @@ -51,8 +48,8 @@ TIFFFaxTabEnt WhiteTable[4096]; TIFFFaxTabEnt BlackTable[8192]; struct proto { - uint16 code; /* right justified, lsb-first, zero filled */ - uint16 val; /* (pixel count)<<4 + code width */ + uint16_t code; /* right justified, lsb-first, zero filled */ + uint16_t val; /* (pixel count)<<4 + code width */ }; static struct proto Pass[] = { @@ -433,11 +430,19 @@ main(int argc, char* argv[]) fprintf(fd, "/* WARNING, this file was automatically generated by the\n"); fprintf(fd, " mkg3states program */\n"); + fprintf(fd, "#include <stdint.h>\n"); fprintf(fd, "#include \"tiff.h\"\n"); fprintf(fd, "#include \"tif_fax3.h\"\n"); WriteTable(fd, MainTable, 128, "TIFFFaxMainTable"); WriteTable(fd, WhiteTable, 4096, "TIFFFaxWhiteTable"); WriteTable(fd, BlackTable, 8192, "TIFFFaxBlackTable"); + fprintf(fd, "/*\n" + " * Local Variables:\n" + " * mode: c\n" + " * c-basic-offset: 8\n" + " * fill-column: 78\n" + " * End:\n" + " */\n"); fclose(fd); return (0); } diff --git a/tiff/libtiff/tif_aux.c b/tiff/libtiff/tif_aux.c index c9f19054..140f26c7 100644 --- a/tiff/libtiff/tif_aux.c +++ b/tiff/libtiff/tif_aux.c @@ -32,10 +32,10 @@ #include <math.h> #include <float.h> -uint32 -_TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where) +uint32_t +_TIFFMultiply32(TIFF* tif, uint32_t first, uint32_t second, const char* where) { - if (second && first > TIFF_UINT32_MAX / second) { + if (second && first > UINT32_MAX / second) { TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); return 0; } @@ -43,10 +43,10 @@ _TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where) return first * second; } -uint64 -_TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where) +uint64_t +_TIFFMultiply64(TIFF* tif, uint64_t first, uint64_t second, const char* where) { - if (second && first > TIFF_UINT64_MAX / second) { + if (second && first > UINT64_MAX / second) { TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); return 0; } @@ -79,9 +79,9 @@ _TIFFMultiplySSize(TIFF* tif, tmsize_t first, tmsize_t second, const char* where return first * second; } -tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64 val, const char* module) +tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64_t val, const char* module) { - if( val > (uint64)TIFF_TMSIZE_T_MAX ) + if( val > (uint64_t)TIFF_TMSIZE_T_MAX ) { if( tif != NULL && module != NULL ) { @@ -109,8 +109,8 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer, if (cp == NULL) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%ld elements of %ld bytes each)", - what,(long) nmemb, (long) elem_size); + "(%"TIFF_SSIZE_FORMAT" elements of %"TIFF_SSIZE_FORMAT" bytes each)", + what, nmemb, elem_size); } return cp; @@ -125,7 +125,7 @@ _TIFFCheckMalloc(TIFF* tif, tmsize_t nmemb, tmsize_t elem_size, const char* what static int TIFFDefaultTransferFunction(TIFFDirectory* td) { - uint16 **tf = td->td_transferfunction; + uint16_t **tf = td->td_transferfunction; tmsize_t i, n, nbytes; tf[0] = tf[1] = tf[2] = 0; @@ -133,22 +133,22 @@ TIFFDefaultTransferFunction(TIFFDirectory* td) return 0; n = ((tmsize_t)1)<<td->td_bitspersample; - nbytes = n * sizeof (uint16); - tf[0] = (uint16 *)_TIFFmalloc(nbytes); + nbytes = n * sizeof (uint16_t); + tf[0] = (uint16_t *)_TIFFmalloc(nbytes); if (tf[0] == NULL) return 0; tf[0][0] = 0; for (i = 1; i < n; i++) { double t = (double)i/((double) n-1.); - tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5); + tf[0][i] = (uint16_t)floor(65535. * pow(t, 2.2) + .5); } if (td->td_samplesperpixel - td->td_extrasamples > 1) { - tf[1] = (uint16 *)_TIFFmalloc(nbytes); + tf[1] = (uint16_t *)_TIFFmalloc(nbytes); if(tf[1] == NULL) goto bad; _TIFFmemcpy(tf[1], tf[0], nbytes); - tf[2] = (uint16 *)_TIFFmalloc(nbytes); + tf[2] = (uint16_t *)_TIFFmalloc(nbytes); if (tf[2] == NULL) goto bad; _TIFFmemcpy(tf[2], tf[0], nbytes); @@ -205,7 +205,7 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td) * place in the library -- in TIFFDefaultDirectory. */ int -TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) +TIFFVGetFieldDefaulted(TIFF* tif, uint32_t tag, va_list ap) { TIFFDirectory *td = &tif->tif_dir; @@ -213,37 +213,37 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) return (1); switch (tag) { case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32 *) = td->td_subfiletype; + *va_arg(ap, uint32_t *) = td->td_subfiletype; return (1); case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16 *) = td->td_bitspersample; + *va_arg(ap, uint16_t *) = td->td_bitspersample; return (1); case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16 *) = td->td_threshholding; + *va_arg(ap, uint16_t *) = td->td_threshholding; return (1); case TIFFTAG_FILLORDER: - *va_arg(ap, uint16 *) = td->td_fillorder; + *va_arg(ap, uint16_t *) = td->td_fillorder; return (1); case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16 *) = td->td_orientation; + *va_arg(ap, uint16_t *) = td->td_orientation; return (1); case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16 *) = td->td_samplesperpixel; + *va_arg(ap, uint16_t *) = td->td_samplesperpixel; return (1); case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32 *) = td->td_rowsperstrip; + *va_arg(ap, uint32_t *) = td->td_rowsperstrip; return (1); case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_minsamplevalue; + *va_arg(ap, uint16_t *) = td->td_minsamplevalue; return (1); case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_maxsamplevalue; + *va_arg(ap, uint16_t *) = td->td_maxsamplevalue; return (1); case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16 *) = td->td_planarconfig; + *va_arg(ap, uint16_t *) = td->td_planarconfig; return (1); case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16 *) = td->td_resolutionunit; + *va_arg(ap, uint16_t *) = td->td_resolutionunit; return (1); case TIFFTAG_PREDICTOR: { @@ -252,42 +252,42 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Cannot get \"Predictor\" tag as plugin is not configured"); - *va_arg(ap, uint16*) = 0; + *va_arg(ap, uint16_t*) = 0; return 0; } - *va_arg(ap, uint16*) = (uint16) sp->predictor; + *va_arg(ap, uint16_t*) = (uint16_t) sp->predictor; return 1; } case TIFFTAG_DOTRANGE: - *va_arg(ap, uint16 *) = 0; - *va_arg(ap, uint16 *) = (1<<td->td_bitspersample)-1; + *va_arg(ap, uint16_t *) = 0; + *va_arg(ap, uint16_t *) = (1 << td->td_bitspersample) - 1; return (1); case TIFFTAG_INKSET: - *va_arg(ap, uint16 *) = INKSET_CMYK; + *va_arg(ap, uint16_t *) = INKSET_CMYK; return 1; case TIFFTAG_NUMBEROFINKS: - *va_arg(ap, uint16 *) = 4; + *va_arg(ap, uint16_t *) = 4; return (1); case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16 *) = td->td_extrasamples; - *va_arg(ap, const uint16 **) = td->td_sampleinfo; + *va_arg(ap, uint16_t *) = td->td_extrasamples; + *va_arg(ap, const uint16_t **) = td->td_sampleinfo; return (1); case TIFFTAG_MATTEING: - *va_arg(ap, uint16 *) = + *va_arg(ap, uint16_t *) = (td->td_extrasamples == 1 && td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); return (1); case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32 *) = td->td_tiledepth; + *va_arg(ap, uint32_t *) = td->td_tiledepth; return (1); case TIFFTAG_DATATYPE: - *va_arg(ap, uint16 *) = td->td_sampleformat-1; + *va_arg(ap, uint16_t *) = td->td_sampleformat - 1; return (1); case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16 *) = td->td_sampleformat; + *va_arg(ap, uint16_t *) = td->td_sampleformat; return(1); case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32 *) = td->td_imagedepth; + *va_arg(ap, uint32_t *) = td->td_imagedepth; return (1); case TIFFTAG_YCBCRCOEFFICIENTS: { @@ -297,11 +297,11 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) return 1; } case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1]; + *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1]; return (1); case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16 *) = td->td_ycbcrpositioning; + *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning; return (1); case TIFFTAG_WHITEPOINT: { @@ -321,10 +321,10 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag"); return (0); } - *va_arg(ap, const uint16 **) = td->td_transferfunction[0]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[0]; if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, const uint16 **) = td->td_transferfunction[1]; - *va_arg(ap, const uint16 **) = td->td_transferfunction[2]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[1]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[2]; } return (1); case TIFFTAG_REFERENCEBLACKWHITE: @@ -341,7 +341,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) * value if the tag is not present in the directory. */ int -TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...) +TIFFGetFieldDefaulted(TIFF* tif, uint32_t tag, ...) { int ok; va_list ap; @@ -353,16 +353,16 @@ TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...) } struct _Int64Parts { - int32 low, high; + int32_t low, high; }; typedef union { struct _Int64Parts part; - int64 value; + int64_t value; } _Int64; float -_TIFFUInt64ToFloat(uint64 ui64) +_TIFFUInt64ToFloat(uint64_t ui64) { _Int64 i; @@ -378,7 +378,7 @@ _TIFFUInt64ToFloat(uint64 ui64) } double -_TIFFUInt64ToDouble(uint64 ui64) +_TIFFUInt64ToDouble(uint64_t ui64) { _Int64 i; @@ -406,7 +406,7 @@ int _TIFFSeekOK(TIFF* tif, toff_t off) { /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */ /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */ - return off <= (~(uint64)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off; + return off <= (~(uint64_t)0) / 2 && TIFFSeekFile(tif, off, SEEK_SET) == off; } /* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/tiff/libtiff/tif_close.c b/tiff/libtiff/tif_close.c index e4228df9..674518a1 100644 --- a/tiff/libtiff/tif_close.c +++ b/tiff/libtiff/tif_close.c @@ -76,7 +76,7 @@ TIFFCleanup(TIFF* tif) * Clean up custom fields. */ if (tif->tif_fields && tif->tif_nfields > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfields; i++) { TIFFField *fld = tif->tif_fields[i]; @@ -91,7 +91,7 @@ TIFFCleanup(TIFF* tif) } if (tif->tif_nfieldscompat > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfieldscompat; i++) { if (tif->tif_fieldscompat[i].allocated_size) diff --git a/tiff/libtiff/tif_codec.c b/tiff/libtiff/tif_codec.c index b6c04f01..931eb093 100644 --- a/tiff/libtiff/tif_codec.c +++ b/tiff/libtiff/tif_codec.c @@ -67,6 +67,9 @@ static int NotConfigured(TIFF*, int); #ifndef LOGLUV_SUPPORT #define TIFFInitSGILog NotConfigured #endif +#ifndef LERC_SUPPORT +#define TIFFInitLERC NotConfigured +#endif #ifndef LZMA_SUPPORT #define TIFFInitLZMA NotConfigured #endif @@ -80,11 +83,7 @@ static int NotConfigured(TIFF*, int); /* * Compression schemes statically built into the library. */ -#ifdef VMS const TIFFCodec _TIFFBuiltinCODECS[] = { -#else -TIFFCodec _TIFFBuiltinCODECS[] = { -#endif { "None", COMPRESSION_NONE, TIFFInitDumpMode }, { "LZW", COMPRESSION_LZW, TIFFInitLZW }, { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, @@ -105,6 +104,7 @@ TIFFCodec _TIFFBuiltinCODECS[] = { { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA }, { "ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD }, { "WEBP", COMPRESSION_WEBP, TIFFInitWebP }, + { "LERC", COMPRESSION_LERC, TIFFInitLERC }, { NULL, 0, NULL } }; @@ -114,7 +114,7 @@ _notConfigured(TIFF* tif) const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); char compression_code[20]; - sprintf(compression_code, "%d",tif->tif_dir.td_compression ); + sprintf(compression_code, "%"PRIu16, tif->tif_dir.td_compression ); TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%s compression support is not configured", c ? c->name : compression_code ); @@ -146,7 +146,7 @@ NotConfigured(TIFF* tif, int scheme) */ int -TIFFIsCODECConfigured(uint16 scheme) +TIFFIsCODECConfigured(uint16_t scheme) { const TIFFCodec* codec = TIFFFindCODEC(scheme); diff --git a/tiff/libtiff/tif_color.c b/tiff/libtiff/tif_color.c index 8fae40ea..2b962af9 100644 --- a/tiff/libtiff/tif_color.c +++ b/tiff/libtiff/tif_color.c @@ -41,8 +41,8 @@ * Convert color value from the CIE L*a*b* 1976 space to CIE XYZ. */ void -TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b, - float *X, float *Y, float *Z) +TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, int32_t b, + float *X, float *Y, float *Z) { float L = (float)l * 100.0F / 255.0F; float cby, tmp; @@ -68,13 +68,13 @@ TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b, *Z = cielab->Z0 * tmp * tmp * tmp; } -#define RINT(R) ((uint32)((R)>0?((R)+0.5):((R)-0.5))) +#define RINT(R) ((uint32_t)((R)>0?((R)+0.5):((R)-0.5))) /* * Convert color value from the XYZ space to RGB. */ void TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z, - uint32 *r, uint32 *g, uint32 *b) + uint32_t *r, uint32_t *g, uint32_t *b) { int i; float Yr, Yg, Yb; @@ -171,17 +171,17 @@ TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab, * see below for more information on how it works. */ #define SHIFT 16 -#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5)) -#define ONE_HALF ((int32)(1<<(SHIFT-1))) -#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)(((RW)-(RB)!=0) ? ((RW)-(RB)) : 1)) +#define FIX(x) ((int32_t)((x) * (1L<<SHIFT) + 0.5)) +#define ONE_HALF ((int32_t)(1<<(SHIFT-1))) +#define Code2V(c, RB, RW, CR) ((((c)-(int32_t)(RB))*(float)(CR))/(float)(((RW)-(RB)!=0) ? ((RW)-(RB)) : 1)) #define CLAMP(f,min,max) ((f)<(min)?(min):(f)>(max)?(max):(f)) #define HICLAMP(f,max) ((f)>(max)?(max):(f)) void -TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr, - uint32 *r, uint32 *g, uint32 *b) +TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32_t Y, int32_t Cb, int32_t Cr, + uint32_t *r, uint32_t *g, uint32_t *b) { - int32 i; + int32_t i; /* XXX: Only 8-bit YCbCr input supported for now */ Y = HICLAMP(Y, 255); @@ -241,7 +241,7 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) #define LumaBlue luma[2] clamptab = (TIFFRGBValue*)( - (uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long))); + (uint8_t*) ycbcr + TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long))); _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ ycbcr->clamptab = (clamptab += 256); for (i = 0; i < 256; i++) @@ -249,14 +249,14 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; - ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256); + ycbcr->Cr_g_tab = (int32_t*) (ycbcr->Cb_b_tab + 256); ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256; ycbcr->Y_tab = ycbcr->Cb_g_tab + 256; - { float f1 = 2-2*LumaRed; int32 D1 = FIX(CLAMP(f1,0.0F,2.0F)); - float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(CLAMP(f2,0.0F,2.0F)); - float f3 = 2-2*LumaBlue; int32 D3 = FIX(CLAMP(f3,0.0F,2.0F)); - float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(CLAMP(f4,0.0F,2.0F)); + { float f1 = 2-2*LumaRed; int32_t D1 = FIX(CLAMP(f1, 0.0F, 2.0F)); + float f2 = LumaRed*f1/LumaGreen; int32_t D2 = -FIX(CLAMP(f2, 0.0F, 2.0F)); + float f3 = 2-2*LumaBlue; int32_t D3 = FIX(CLAMP(f3, 0.0F, 2.0F)); + float f4 = LumaBlue*f3/LumaGreen; int32_t D4 = -FIX(CLAMP(f4, 0.0F, 2.0F)); int x; #undef LumaBlue @@ -271,19 +271,19 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) * constructing tables indexed by the raw pixel data. */ for (i = 0, x = -128; i < 256; i++, x++) { - int32 Cr = (int32)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F, + int32_t Cr = (int32_t)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F, refBlackWhite[5] - 128.0F, 127), -128.0F * 32, 128.0F * 32); - int32 Cb = (int32)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F, + int32_t Cb = (int32_t)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F, refBlackWhite[3] - 128.0F, 127), -128.0F * 32, 128.0F * 32); - ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT); - ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT); + ycbcr->Cr_r_tab[i] = (int32_t)((D1 * Cr + ONE_HALF) >> SHIFT); + ycbcr->Cb_b_tab[i] = (int32_t)((D3 * Cb + ONE_HALF) >> SHIFT); ycbcr->Cr_g_tab[i] = D2*Cr; ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF; ycbcr->Y_tab[i] = - (int32)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255), + (int32_t)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255), -128.0F * 32, 128.0F * 32); } } diff --git a/tiff/libtiff/tif_compress.c b/tiff/libtiff/tif_compress.c index 915478f5..8fcedf45 100644 --- a/tiff/libtiff/tif_compress.c +++ b/tiff/libtiff/tif_compress.c @@ -40,28 +40,28 @@ TIFFNoEncode(TIFF* tif, const char* method) c->name, method); } else { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s encoding is not implemented", + "Compression scheme %"PRIu16" %s encoding is not implemented", tif->tif_dir.td_compression, method); } return (-1); } int -_TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoRowEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "scanline")); } int -_TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoStripEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "strip")); } int -_TIFFNoTileEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoTileEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "tile")); @@ -78,7 +78,7 @@ TIFFNoDecode(TIFF* tif, const char* method) c->name, method); else TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s decoding is not implemented", + "Compression scheme %"PRIu16" %s decoding is not implemented", tif->tif_dir.td_compression, method); return (0); } @@ -91,28 +91,28 @@ _TIFFNoFixupTags(TIFF* tif) } int -_TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoRowDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "scanline")); } int -_TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoStripDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "strip")); } int -_TIFFNoTileDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoTileDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "tile")); } int -_TIFFNoSeek(TIFF* tif, uint32 off) +_TIFFNoSeek(TIFF* tif, uint32_t off) { (void) off; TIFFErrorExt(tif->tif_clientdata, tif->tif_name, @@ -121,7 +121,7 @@ _TIFFNoSeek(TIFF* tif, uint32 off) } int -_TIFFNoPreCode(TIFF* tif, uint16 s) +_TIFFNoPreCode(TIFF* tif, uint16_t s) { (void) tif; (void) s; return (1); @@ -158,7 +158,7 @@ _TIFFSetDefaultCompressionState(TIFF* tif) int TIFFSetCompressionScheme(TIFF* tif, int scheme) { - const TIFFCodec *c = TIFFFindCODEC((uint16) scheme); + const TIFFCodec *c = TIFFFindCODEC((uint16_t) scheme); _TIFFSetDefaultCompressionState(tif); /* @@ -182,7 +182,7 @@ typedef struct _codec { static codec_t* registeredCODECS = NULL; const TIFFCodec* -TIFFFindCODEC(uint16 scheme) +TIFFFindCODEC(uint16_t scheme) { const TIFFCodec* c; codec_t* cd; @@ -197,15 +197,15 @@ TIFFFindCODEC(uint16 scheme) } TIFFCodec* -TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) +TIFFRegisterCODEC(uint16_t scheme, const char* name, TIFFInitMethod init) { codec_t* cd = (codec_t*) _TIFFmalloc((tmsize_t)(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1)); if (cd != NULL) { - cd->info = (TIFFCodec*) ((uint8*) cd + sizeof (codec_t)); + cd->info = (TIFFCodec*) ((uint8_t*) cd + sizeof (codec_t)); cd->info->name = (char*) - ((uint8*) cd->info + sizeof (TIFFCodec)); + ((uint8_t*) cd->info + sizeof (TIFFCodec)); strcpy(cd->info->name, name); cd->info->scheme = scheme; cd->info->init = init; diff --git a/tiff/libtiff/tif_config.h-vms b/tiff/libtiff/tif_config.h-vms deleted file mode 100644 index d653bd82..00000000 --- a/tiff/libtiff/tif_config.h-vms +++ /dev/null @@ -1,46 +0,0 @@ -/* Define to 1 if you have the <assert.h> header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -#define HAVE_UNISTD_H 1 - -#define HAVE_STRING_H 1 -/* Define to 1 if you have the <sys/types.h> header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the <io.h> header file. */ -//#define HAVE_IO_H 1 - -/* Define to 1 if you have the <search.h> header file. */ -//#define HAVE_SEARCH_H 1 - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of a `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* Set the native cpu bit order */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -/* -#ifndef __cplusplus -# ifndef inline -# define inline __inline -# endif -#endif -*/ - -// #define lfind _lfind diff --git a/tiff/libtiff/tif_config.h.cmake.in b/tiff/libtiff/tif_config.h.cmake.in index 24144603..20e44630 100644 --- a/tiff/libtiff/tif_config.h.cmake.in +++ b/tiff/libtiff/tif_config.h.cmake.in @@ -1,6 +1,8 @@ /* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */ /* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */ +#include "tiffconf.h" + /* Support CCITT Group 3 & 4 algorithms */ #cmakedefine CCITT_SUPPORT 1 @@ -20,12 +22,15 @@ /* Define to 1 if you have the <assert.h> header file. */ #cmakedefine HAVE_ASSERT_H 1 -/* Define to 1 if you have the <dlfcn.h> header file. */ -#cmakedefine HAVE_DLFCN_H 1 +/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */ +#cmakedefine HAVE_DECL_OPTARG 1 /* Define to 1 if you have the <fcntl.h> header file. */ #cmakedefine HAVE_FCNTL_H 1 +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#cmakedefine HAVE_FSEEKO 1 + /* Define to 1 if you have the `getopt' function. */ #cmakedefine HAVE_GETOPT 1 @@ -41,18 +46,12 @@ /* Define to 1 if you have the <GL/gl.h> header file. */ #cmakedefine HAVE_GL_GL_H 1 -/* Define to 1 if you have the <inttypes.h> header file. */ -#cmakedefine HAVE_INTTYPES_H 1 - /* Define to 1 if you have the <io.h> header file. */ #cmakedefine HAVE_IO_H 1 /* Define to 1 if you have the `jbg_newlen' function. */ #cmakedefine HAVE_JBG_NEWLEN 1 -/* Define to 1 if you have the `lfind' function. */ -#cmakedefine HAVE_LFIND 1 - /* Define to 1 if you have the `mmap' function. */ #cmakedefine HAVE_MMAP 1 @@ -62,42 +61,12 @@ /* Define to 1 if you have the <OpenGL/gl.h> header file. */ #cmakedefine HAVE_OPENGL_GL_H 1 -/* Define to 1 if you have the <search.h> header file. */ -#cmakedefine HAVE_SEARCH_H 1 - /* Define to 1 if you have the `setmode' function. */ #cmakedefine HAVE_SETMODE 1 -/* Define to 1 if you have the `snprintf' function. */ -#cmakedefine HAVE_SNPRINTF 1 - -/* Define to 1 if you have the <stdint.h> header file. */ -#cmakedefine HAVE_STDINT_H 1 - -/* Define to 1 if you have the `strcasecmp' function. */ -#cmakedefine HAVE_STRCASECMP 1 - /* Define to 1 if you have the <strings.h> header file. */ #cmakedefine HAVE_STRINGS_H 1 -/* Define to 1 if you have the <string.h> header file. */ -#cmakedefine HAVE_STRING_H 1 - -/* Define to 1 if you have the `strtol' function. */ -#cmakedefine HAVE_STRTOL 1 - -/* Define to 1 if you have the `strtoll' function. */ -#cmakedefine HAVE_STRTOLL 1 - -/* Define to 1 if you have the `strtoul' function. */ -#cmakedefine HAVE_STRTOUL 1 - -/* Define to 1 if you have the `strtoull' function. */ -#cmakedefine HAVE_STRTOULL 1 - -/* Define to 1 if you have the <sys/time.h> header file. */ -#cmakedefine HAVE_SYS_TIME_H 1 - /* Define to 1 if you have the <sys/types.h> header file. */ #cmakedefine HAVE_SYS_TYPES_H 1 @@ -105,20 +74,17 @@ #cmakedefine HAVE_UNISTD_H 1 /* 8/12 bit libjpeg dual mode enabled */ -#cmakedefine JPEG_DUAL_MODE_8_12 1 +#cmakedefine JPEG_DUAL_MODE_8_12 1 1 + +/* Support LERC compression */ +#cmakedefine LERC_SUPPORT 1 /* 12bit libjpeg primary include file with path */ -#define LIBJPEG_12_PATH @LIBJPEG_12_PATH@ +#define LIBJPEG_12_PATH "@LIBJPEG_12_PATH@" /* Support LZMA2 compression */ #cmakedefine LZMA_SUPPORT 1 -/* Support ZSTD compression */ -#cmakedefine ZSTD_SUPPORT 1 - -/* Support WEBP compression */ -#cmakedefine WEBP_SUPPORT 1 - /* Name of package */ #define PACKAGE "@PACKAGE_NAME@" @@ -140,69 +106,25 @@ /* Define to the version of this package. */ #define PACKAGE_VERSION "@PACKAGE_VERSION@" -/* The size of `signed int', as computed by sizeof. */ -#define SIZEOF_SIGNED_INT @SIZEOF_SIGNED_INT@ - -/* The size of `signed long', as computed by sizeof. */ -#define SIZEOF_SIGNED_LONG @SIZEOF_SIGNED_LONG@ - -/* The size of `signed long long', as computed by sizeof. */ -#define SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@ - -/* The size of `unsigned char *', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@ - -/* The size of `unsigned int', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@ - -/* The size of `unsigned long', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@ - -/* The size of `unsigned long long', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@ - -/* The size of `unsigned short', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@ +/* Size of size_t */ +#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@ /* Default size of the strip in bytes (when strip chopping enabled) */ #define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@ -/* Signed 32-bit type formatter */ -#define TIFF_INT32_FORMAT "@TIFF_INT32_FORMAT@" - -/* Signed 64-bit type formatter */ -#define TIFF_INT64_FORMAT "@TIFF_INT64_FORMAT@" - -/* Pointer difference type formatter */ -#define TIFF_PTRDIFF_FORMAT "@TIFF_PTRDIFF_FORMAT@" - -/* Unsigned size type formatter */ -#define TIFF_SIZE_FORMAT "@TIFF_SIZE_FORMAT@" - -/* Signed size type formatter */ -#define TIFF_SSIZE_FORMAT "@TIFF_SSIZE_FORMAT@" - -/* Unsigned 32-bit type formatter */ -#define TIFF_UINT32_FORMAT "@TIFF_UINT32_FORMAT@" - -/* Unsigned 64-bit type formatter */ -#define TIFF_UINT64_FORMAT "@TIFF_UINT64_FORMAT@" - -/* Unsigned 8-bit type */ -#define TIFF_UINT8_T @TIFF_UINT8_T@ - -/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ -#undef TIME_WITH_SYS_TIME - -/* Define to 1 if your <sys/time.h> declares `struct tm'. */ -#cmakedefine TM_IN_SYS_TIME 1 - /* define to use win32 IO system */ #cmakedefine USE_WIN32_FILEIO 1 /* Version number of package */ #define VERSION "@PACKAGE_VERSION@" +/* Support WEBP compression */ +#cmakedefine WEBP_SUPPORT 1 + +/* Support ZSTD compression */ +#cmakedefine ZSTD_SUPPORT 1 + + /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD @@ -215,17 +137,19 @@ # endif #endif -/* Number of bits in a file offset, on hosts where this is settable. */ -#define _FILE_OFFSET_BITS @FILE_OFFSET_BITS@ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#define inline @INLINE_KEYWORD@ +#if !defined(__MINGW32__) +# define TIFF_SIZE_FORMAT "zu" +#endif +#if SIZEOF_SIZE_T == 8 +# define TIFF_SSIZE_FORMAT PRId64 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu64 +# endif +#elif SIZEOF_SIZE_T == 4 +# define TIFF_SSIZE_FORMAT PRId32 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu32 +# endif +#else +# error "Unsupported size_t size; please submit a bug report" #endif - -/* Define to `long int' if <sys/types.h> does not define. */ -#undef off_t - -/* Define to `unsigned int' if <sys/types.h> does not define. */ -#undef size_t diff --git a/tiff/libtiff/tif_config.h.in b/tiff/libtiff/tif_config.h.in index 30afd7a1..66eef23b 100644 --- a/tiff/libtiff/tif_config.h.in +++ b/tiff/libtiff/tif_config.h.in @@ -1,7 +1,6 @@ -/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */ +/* libtiff/tif_config.h.in. Not generated, but originated from autoheader. */ -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD +#include "tiffconf.h" /* Support CCITT Group 3 & 4 algorithms */ #undef CCITT_SUPPORT @@ -16,11 +15,6 @@ /* Support C++ stream API (requires C++ compiler) */ #undef CXX_SUPPORT -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#undef DEFAULT_EXTRASAMPLE_AS_ALPHA - /* enable deferred strip/tile offset/size loading */ #undef DEFER_STRILE_LOAD @@ -31,9 +25,6 @@ */ #undef HAVE_DECL_OPTARG -/* Define to 1 if you have the <dlfcn.h> header file. */ -#undef HAVE_DLFCN_H - /* Define to 1 if you have the <fcntl.h> header file. */ #undef HAVE_FCNTL_H @@ -55,25 +46,12 @@ /* Define to 1 if you have the <GL/gl.h> header file. */ #undef HAVE_GL_GL_H -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#undef HAVE_IEEEFP - -/* Define to 1 if you have the <inttypes.h> header file. */ -#undef HAVE_INTTYPES_H - /* Define to 1 if you have the <io.h> header file. */ #undef HAVE_IO_H /* Define to 1 if you have the `jbg_newlen' function. */ #undef HAVE_JBG_NEWLEN -/* Define to 1 if you have the `lfind' function. */ -#undef HAVE_LFIND - -/* Define to 1 if you have the <memory.h> header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP @@ -83,103 +61,33 @@ /* Define to 1 if you have the <OpenGL/gl.h> header file. */ #undef HAVE_OPENGL_GL_H -/* Define if you have POSIX threads libraries and header files. */ -#undef HAVE_PTHREAD - -/* Define to 1 if you have the <search.h> header file. */ -#undef HAVE_SEARCH_H - /* Define to 1 if you have the `setmode' function. */ #undef HAVE_SETMODE /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF -/* Define to 1 if you have the <stdint.h> header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the <stdlib.h> header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - /* Define to 1 if you have the <strings.h> header file. */ #undef HAVE_STRINGS_H -/* Define to 1 if you have the <string.h> header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - -/* Define to 1 if you have the `strtoll' function. */ -#undef HAVE_STRTOLL - -/* Define to 1 if you have the `strtoul' function. */ -#undef HAVE_STRTOUL - -/* Define to 1 if you have the `strtoull' function. */ -#undef HAVE_STRTOULL - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#undef HAVE_SYS_STAT_H - /* Define to 1 if you have the <sys/types.h> header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H -/* Use nonstandard varargs form for the GLU tesselator callback */ -#undef HAVE_VARARGS_GLU_TESSCB - -/* Define to 1 if you have the <windows.h> header file. */ -#undef HAVE_WINDOWS_H - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#undef HOST_BIGENDIAN - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#undef HOST_FILLORDER - -/* Support ISO JBIG compression (requires JBIG-KIT library) */ -#undef JBIG_SUPPORT - /* 8/12 bit libjpeg dual mode enabled */ #undef JPEG_DUAL_MODE_8_12 -/* Support JPEG compression (requires IJG JPEG library) */ -#undef JPEG_SUPPORT - -/* Support libdeflate enhanced compression */ -#undef LIBDEFLATE_SUPPORT +/* Support LERC compression */ +#undef LERC_SUPPORT /* 12bit libjpeg primary include file with path */ #undef LIBJPEG_12_PATH -/* Support LogLuv high dynamic range encoding */ -#undef LOGLUV_SUPPORT - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#undef LT_OBJDIR - /* Support LZMA2 compression */ #undef LZMA_SUPPORT -/* Support LZW algorithm */ -#undef LZW_SUPPORT - -/* Support Microsoft Document Imaging format */ -#undef MDI_SUPPORT - -/* Support NeXT 2-bit RLE algorithm */ -#undef NEXT_SUPPORT - -/* Support Old JPEG compresson (read-only) */ -#undef OJPEG_SUPPORT - /* Name of package */ #undef PACKAGE @@ -201,116 +109,12 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Support Macintosh PackBits algorithm */ -#undef PACKBITS_SUPPORT - -/* Support Pixar log-format algorithm (requires Zlib) */ -#undef PIXARLOG_SUPPORT - -/* Define to necessary symbol if this constant uses a non-standard name on - your system. */ -#undef PTHREAD_CREATE_JOINABLE - -/* The size of `signed int', as computed by sizeof. */ -#undef SIZEOF_SIGNED_INT - -/* The size of `signed long', as computed by sizeof. */ -#undef SIZEOF_SIGNED_LONG - -/* The size of `signed long long', as computed by sizeof. */ -#undef SIZEOF_SIGNED_LONG_LONG - /* The size of `size_t', as computed by sizeof. */ #undef SIZEOF_SIZE_T -/* The size of `unsigned char *', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_CHAR_P - -/* The size of `unsigned int', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_INT - -/* The size of `unsigned long', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_LONG - -/* The size of `unsigned long long', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_LONG_LONG - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of specified size to reduce memory usage) */ -#undef STRIPCHOP_DEFAULT - /* Default size of the strip in bytes (when strip chopping enabled) */ #undef STRIP_SIZE_DEFAULT -/* Enable SubIFD tag (330) support */ -#undef SUBIFD_SUPPORT - -/* Support ThunderScan 4-bit RLE algorithm */ -#undef THUNDER_SUPPORT - -/* Signed 16-bit type */ -#undef TIFF_INT16_T - -/* Signed 32-bit type formatter */ -#undef TIFF_INT32_FORMAT - -/* Signed 32-bit type */ -#undef TIFF_INT32_T - -/* Signed 64-bit type formatter */ -#undef TIFF_INT64_FORMAT - -/* Signed 64-bit type */ -#undef TIFF_INT64_T - -/* Signed 8-bit type */ -#undef TIFF_INT8_T - -/* Pointer difference type formatter */ -#undef TIFF_PTRDIFF_FORMAT - -/* Pointer difference type */ -#undef TIFF_PTRDIFF_T - -/* Size type formatter */ -#undef TIFF_SIZE_FORMAT - -/* Unsigned size type */ -#undef TIFF_SIZE_T - -/* Signed size type formatter */ -#undef TIFF_SSIZE_FORMAT - -/* Signed size type */ -#undef TIFF_SSIZE_T - -/* Unsigned 16-bit type */ -#undef TIFF_UINT16_T - -/* Unsigned 32-bit type formatter */ -#undef TIFF_UINT32_FORMAT - -/* Unsigned 32-bit type */ -#undef TIFF_UINT32_T - -/* Unsigned 64-bit type formatter */ -#undef TIFF_UINT64_FORMAT - -/* Unsigned 64-bit type */ -#undef TIFF_UINT64_T - -/* Unsigned 8-bit type */ -#undef TIFF_UINT8_T - -/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ -#undef TIME_WITH_SYS_TIME - -/* Define to 1 if your <sys/time.h> declares `struct tm'. */ -#undef TM_IN_SYS_TIME - /* define to use win32 IO system */ #undef USE_WIN32_FILEIO @@ -332,12 +136,6 @@ # endif #endif -/* Define to 1 if the X Window System is missing or not being used. */ -#undef X_DISPLAY_MISSING - -/* Support Deflate compression */ -#undef ZIP_SUPPORT - /* Support zstd compression */ #undef ZSTD_SUPPORT @@ -355,17 +153,19 @@ /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline +#if !defined(__MINGW32__) +# define TIFF_SIZE_FORMAT "zu" +#endif +#if SIZEOF_SIZE_T == 8 +# define TIFF_SSIZE_FORMAT PRId64 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu64 +# endif +#elif SIZEOF_SIZE_T == 4 +# define TIFF_SSIZE_FORMAT PRId32 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu32 +# endif +#else +# error "Unsupported size_t size; please submit a bug report" #endif - -/* Define to `long int' if <sys/types.h> does not define. */ -#undef off_t - -/* Define to `unsigned int' if <sys/types.h> does not define. */ -#undef size_t diff --git a/tiff/libtiff/tif_config.vc.h b/tiff/libtiff/tif_config.vc.h index 939594f8..5cebfa02 100644 --- a/tiff/libtiff/tif_config.vc.h +++ b/tiff/libtiff/tif_config.vc.h @@ -104,24 +104,11 @@ /* Set the native cpu bit order */ #define HOST_FILLORDER FILLORDER_LSB2MSB -/* - Please see associated settings in "nmake.opt" which configure porting - settings. It should not be necessary to edit the following pre-processor - logic. -*/ -#if defined(_MSC_VER) /* Visual Studio 2015 / VC 14 / MSVC 19.00 finally has snprintf() */ -# if _MSC_VER < 1900 /* Visual C++ 2015 */ -# define snprintf _snprintf -# else -# define HAVE_SNPRINTF 1 -# endif -# define HAVE_STRTOL 1 -# define HAVE_STRTOUL 1 -# if _MSC_VER >= 1900 /* Visual Studio 2015 added strtoll/strtoull */ -# define HAVE_STRTOLL 1 -# define HAVE_STRTOULL 1 -# endif +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define snprintf _snprintf +#else +#define HAVE_SNPRINTF 1 #endif /* Define to 1 if your processor stores words with the most significant byte diff --git a/tiff/libtiff/tif_config.wince.h b/tiff/libtiff/tif_config.wince.h deleted file mode 100644 index e85e2e62..00000000 --- a/tiff/libtiff/tif_config.wince.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * TIFF library configuration header for Windows CE platform. - */ -#ifndef _WIN32_WCE -# error This version of tif_config.h header is dedicated for Windows CE platform! -#endif - -/* Define to 1 if you have the <assert.h> header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* Define to 1 if you have the `jbg_newlen' function. */ -#define HAVE_JBG_NEWLEN 1 - -/* Define to 1 if you have the <string.h> header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the <sys/types.h> header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the <io.h> header file. */ -#define HAVE_IO_H 1 - -/* Define to 1 if you have the <search.h> header file. */ -#define HAVE_SEARCH_H 1 - -/* Define to 1 if you have the `setmode' function. */ -#define HAVE_SETMODE 1 - -/* Define to 1 if you have the `bsearch' function. */ -#define HAVE_BSEARCH 1 -#define bsearch wceex_bsearch - -/* Define to 1 if you have the `lfind' function. */ -#define HAVE_LFIND 1 -#define lfind wceex_lfind - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* Set the native cpu bit order */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef WORDS_BIGENDIAN */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -# ifndef inline -# define inline __inline -# endif -#endif - - -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/tiff/libtiff/tif_dir.c b/tiff/libtiff/tif_dir.c index 347b7115..a6c254fc 100644 --- a/tiff/libtiff/tif_dir.c +++ b/tiff/libtiff/tif_dir.c @@ -54,21 +54,21 @@ setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size) _TIFFmemcpy(*vpp, vp, bytes); } } -void _TIFFsetByteArray(void** vpp, void* vp, uint32 n) +void _TIFFsetByteArray(void** vpp, void* vp, uint32_t n) { setByteArray(vpp, vp, n, 1); } void _TIFFsetString(char** cpp, char* cp) { setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); } -static void _TIFFsetNString(char** cpp, char* cp, uint32 n) +static void _TIFFsetNString(char** cpp, char* cp, uint32_t n) { setByteArray((void**) cpp, (void*) cp, n, 1); } -void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n) - { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); } -void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n) - { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); } -static void _TIFFsetLong8Array(uint64** lpp, uint64* lp, uint32 n) - { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64)); } -void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n) +void _TIFFsetShortArray(uint16_t** wpp, uint16_t* wp, uint32_t n) + { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16_t)); } +void _TIFFsetLongArray(uint32_t** lpp, uint32_t* lp, uint32_t n) + { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32_t)); } +static void _TIFFsetLong8Array(uint64_t** lpp, uint64_t* lp, uint32_t n) + { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64_t)); } +void _TIFFsetFloatArray(float** fpp, float* fp, uint32_t n) { setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); } -void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n) +void _TIFFsetDoubleArray(double** dpp, double* dp, uint32_t n) { setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); } static void @@ -88,20 +88,20 @@ setDoubleArrayOneValue(double** vpp, double value, size_t nmemb) * Install extra samples information. */ static int -setExtraSamples(TIFF* tif, va_list ap, uint32* v) +setExtraSamples(TIFF* tif, va_list ap, uint32_t* v) { /* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */ #define EXTRASAMPLE_COREL_UNASSALPHA 999 - uint16* va; - uint32 i; + uint16_t* va; + uint32_t i; TIFFDirectory* td = &tif->tif_dir; static const char module[] = "setExtraSamples"; - *v = (uint16) va_arg(ap, uint16_vap); - if ((uint16) *v > td->td_samplesperpixel) + *v = (uint16_t) va_arg(ap, uint16_vap); + if ((uint16_t) *v > td->td_samplesperpixel) return 0; - va = va_arg(ap, uint16*); + va = va_arg(ap, uint16_t*); if (*v > 0 && va == NULL) /* typically missing param */ return 0; for (i = 0; i < *v; i++) { @@ -130,7 +130,7 @@ setExtraSamples(TIFF* tif, va_list ap, uint32* v) td->td_transferfunction[0] = NULL; } - td->td_extrasamples = (uint16) *v; + td->td_extrasamples = (uint16_t) *v; _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples); return 1; @@ -141,11 +141,11 @@ setExtraSamples(TIFF* tif, va_list ap, uint32* v) * Confirm we have "samplesperpixel" ink names separated by \0. Returns * zero if the ink names are not as expected. */ -static uint32 -checkInkNamesString(TIFF* tif, uint32 slen, const char* s) +static uint32_t +checkInkNamesString(TIFF* tif, uint32_t slen, const char* s) { TIFFDirectory* td = &tif->tif_dir; - uint16 i = td->td_samplesperpixel; + uint16_t i = td->td_samplesperpixel; if (slen > 0) { const char* ep = s+slen; @@ -156,29 +156,29 @@ checkInkNamesString(TIFF* tif, uint32 slen, const char* s) goto bad; cp++; /* skip \0 */ } - return ((uint32)(cp-s)); + return ((uint32_t)(cp - s)); } bad: TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", - "%s: Invalid InkNames value; expecting %d names, found %d", + "%s: Invalid InkNames value; expecting %"PRIu16" names, found %"PRIu16, tif->tif_name, td->td_samplesperpixel, - td->td_samplesperpixel-i); + (uint16_t)(td->td_samplesperpixel-i)); return (0); } static int -_TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) +_TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "_TIFFVSetField"; TIFFDirectory* td = &tif->tif_dir; int status = 1; - uint32 v32, i, v; + uint32_t v32, i, v; double dblval; char* s; const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); - uint32 standard_tag = tag; + uint32_t standard_tag = tag; if( fip == NULL ) /* cannot happen since OkToChangeTag() already checks it */ return 0; /* @@ -193,16 +193,16 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) switch (standard_tag) { case TIFFTAG_SUBFILETYPE: - td->td_subfiletype = (uint32) va_arg(ap, uint32); + td->td_subfiletype = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_IMAGEWIDTH: - td->td_imagewidth = (uint32) va_arg(ap, uint32); + td->td_imagewidth = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_IMAGELENGTH: - td->td_imagelength = (uint32) va_arg(ap, uint32); + td->td_imagelength = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_BITSPERSAMPLE: - td->td_bitspersample = (uint16) va_arg(ap, uint16_vap); + td->td_bitspersample = (uint16_t) va_arg(ap, uint16_vap); /* * If the data require post-decoding processing to byte-swap * samples, set it up here. Note that since tags are required @@ -226,14 +226,14 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) } break; case TIFFTAG_COMPRESSION: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); /* * If we're changing the compression scheme, the notify the * previous module so that it can cleanup any state it's * setup. */ if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { - if ((uint32)td->td_compression == v) + if ((uint32_t)td->td_compression == v) break; (*tif->tif_cleanup)(tif); tif->tif_flags &= ~TIFF_CODERSETUP; @@ -242,31 +242,31 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) * Setup new compression routine state. */ if( (status = TIFFSetCompressionScheme(tif, v)) != 0 ) - td->td_compression = (uint16) v; + td->td_compression = (uint16_t) v; else status = 0; break; case TIFFTAG_PHOTOMETRIC: - td->td_photometric = (uint16) va_arg(ap, uint16_vap); + td->td_photometric = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_THRESHHOLDING: - td->td_threshholding = (uint16) va_arg(ap, uint16_vap); + td->td_threshholding = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_FILLORDER: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) goto badvalue; - td->td_fillorder = (uint16) v; + td->td_fillorder = (uint16_t) v; break; case TIFFTAG_ORIENTATION: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) goto badvalue; else - td->td_orientation = (uint16) v; + td->td_orientation = (uint16_t) v; break; case TIFFTAG_SAMPLESPERPIXEL: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v == 0) goto badvalue; if( v != td->td_samplesperpixel ) @@ -303,10 +303,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) td->td_transferfunction[0] = NULL; } } - td->td_samplesperpixel = (uint16) v; + td->td_samplesperpixel = (uint16_t) v; break; case TIFFTAG_ROWSPERSTRIP: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 == 0) goto badvalue32; td->td_rowsperstrip = v32; @@ -316,10 +316,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) } break; case TIFFTAG_MINSAMPLEVALUE: - td->td_minsamplevalue = (uint16) va_arg(ap, uint16_vap); + td->td_minsamplevalue = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_MAXSAMPLEVALUE: - td->td_maxsamplevalue = (uint16) va_arg(ap, uint16_vap); + td->td_maxsamplevalue = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_SMINSAMPLEVALUE: if (tif->tif_flags & TIFF_PERSAMPLE) @@ -346,10 +346,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) td->td_yresolution = _TIFFClampDoubleToFloat( dblval ); break; case TIFFTAG_PLANARCONFIG: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) goto badvalue; - td->td_planarconfig = (uint16) v; + td->td_planarconfig = (uint16_t) v; break; case TIFFTAG_XPOSITION: td->td_xposition = _TIFFClampDoubleToFloat( va_arg(ap, double) ); @@ -358,66 +358,66 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) td->td_yposition = _TIFFClampDoubleToFloat( va_arg(ap, double) ); break; case TIFFTAG_RESOLUTIONUNIT: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) goto badvalue; - td->td_resolutionunit = (uint16) v; + td->td_resolutionunit = (uint16_t) v; break; case TIFFTAG_PAGENUMBER: - td->td_pagenumber[0] = (uint16) va_arg(ap, uint16_vap); - td->td_pagenumber[1] = (uint16) va_arg(ap, uint16_vap); + td->td_pagenumber[0] = (uint16_t) va_arg(ap, uint16_vap); + td->td_pagenumber[1] = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_HALFTONEHINTS: - td->td_halftonehints[0] = (uint16) va_arg(ap, uint16_vap); - td->td_halftonehints[1] = (uint16) va_arg(ap, uint16_vap); + td->td_halftonehints[0] = (uint16_t) va_arg(ap, uint16_vap); + td->td_halftonehints[1] = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_COLORMAP: - v32 = (uint32)(1L<<td->td_bitspersample); - _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32); + v32 = (uint32_t)(1L << td->td_bitspersample); + _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16_t*), v32); + _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16_t*), v32); + _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16_t*), v32); break; case TIFFTAG_EXTRASAMPLES: if (!setExtraSamples(tif, ap, &v)) goto badvalue; break; case TIFFTAG_MATTEING: - td->td_extrasamples = (((uint16) va_arg(ap, uint16_vap)) != 0); + td->td_extrasamples = (((uint16_t) va_arg(ap, uint16_vap)) != 0); if (td->td_extrasamples) { - uint16 sv = EXTRASAMPLE_ASSOCALPHA; + uint16_t sv = EXTRASAMPLE_ASSOCALPHA; _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1); } break; case TIFFTAG_TILEWIDTH: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 % 16) { if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile width %u, convert file", v32); + "Nonstandard tile width %"PRIu32", convert file", v32); } td->td_tilewidth = v32; tif->tif_flags |= TIFF_ISTILED; break; case TIFFTAG_TILELENGTH: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 % 16) { if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile length %u, convert file", v32); + "Nonstandard tile length %"PRIu32", convert file", v32); } td->td_tilelength = v32; tif->tif_flags |= TIFF_ISTILED; break; case TIFFTAG_TILEDEPTH: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 == 0) goto badvalue32; td->td_tiledepth = v32; break; case TIFFTAG_DATATYPE: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); switch (v) { case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; @@ -425,13 +425,13 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; default: goto badvalue; } - td->td_sampleformat = (uint16) v; + td->td_sampleformat = (uint16_t) v; break; case TIFFTAG_SAMPLEFORMAT: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) goto badvalue; - td->td_sampleformat = (uint16) v; + td->td_sampleformat = (uint16_t) v; /* Try to fix up the SWAB function for complex data. */ if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT @@ -445,13 +445,13 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) tif->tif_postdecode = _TIFFSwab32BitData; break; case TIFFTAG_IMAGEDEPTH: - td->td_imagedepth = (uint32) va_arg(ap, uint32); + td->td_imagedepth = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_SUBIFD: if ((tif->tif_flags & TIFF_INSUBIFD) == 0) { - td->td_nsubifd = (uint16) va_arg(ap, uint16_vap); - _TIFFsetLong8Array(&td->td_subifd, (uint64*) va_arg(ap, uint64*), - (uint32) td->td_nsubifd); + td->td_nsubifd = (uint16_t) va_arg(ap, uint16_vap); + _TIFFsetLong8Array(&td->td_subifd, (uint64_t*) va_arg(ap, uint64_t*), + (uint32_t) td->td_nsubifd); } else { TIFFErrorExt(tif->tif_clientdata, module, "%s: Sorry, cannot nest SubIFDs", @@ -460,24 +460,24 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) } break; case TIFFTAG_YCBCRPOSITIONING: - td->td_ycbcrpositioning = (uint16) va_arg(ap, uint16_vap); + td->td_ycbcrpositioning = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_YCBCRSUBSAMPLING: - td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, uint16_vap); - td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, uint16_vap); + td->td_ycbcrsubsampling[0] = (uint16_t) va_arg(ap, uint16_vap); + td->td_ycbcrsubsampling[1] = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_TRANSFERFUNCTION: v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; for (i = 0; i < v; i++) _TIFFsetShortArray(&td->td_transferfunction[i], - va_arg(ap, uint16*), 1U<<td->td_bitspersample); + va_arg(ap, uint16_t*), 1U << td->td_bitspersample); break; case TIFFTAG_REFERENCEBLACKWHITE: /* XXX should check for null range */ _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6); break; case TIFFTAG_INKNAMES: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); s = va_arg(ap, char*); v = checkInkNamesString(tif, v, s); status = v > 0; @@ -487,7 +487,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) } break; case TIFFTAG_PERSAMPLE: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if( v == PERSAMPLE_MULTI ) tif->tif_flags |= TIFF_PERSAMPLE; else @@ -575,18 +575,18 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) if (fip->field_type == TIFF_ASCII) { - uint32 ma; + uint32_t ma; char* mb; if (fip->field_passcount) { assert(fip->field_writecount==TIFF_VARIABLE2); - ma=(uint32)va_arg(ap,uint32); + ma=(uint32_t)va_arg(ap, uint32_t); mb=(char*)va_arg(ap,char*); } else { mb=(char*)va_arg(ap,char*); - ma=(uint32)(strlen(mb)+1); + ma=(uint32_t)(strlen(mb) + 1); } tv->count=ma; setByteArray(&tv->value,mb,ma,1); @@ -595,7 +595,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) { if (fip->field_passcount) { if (fip->field_writecount == TIFF_VARIABLE2) - tv->count = (uint32) va_arg(ap, uint32); + tv->count = (uint32_t) va_arg(ap, uint32_t); else tv->count = (int) va_arg(ap, int); } else if (fip->field_writecount == TIFF_VARIABLE @@ -632,9 +632,9 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) handled this way ... likely best if we move it into the directory structure with an explicit field in libtiff 4.1 and assign it a FIELD_ value */ - uint16 v2[2]; - v2[0] = (uint16)va_arg(ap, int); - v2[1] = (uint16)va_arg(ap, int); + uint16_t v2[2]; + v2[0] = (uint16_t)va_arg(ap, int); + v2[1] = (uint16_t)va_arg(ap, int); _TIFFmemcpy(tv->value, &v2, 4); } @@ -654,51 +654,51 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) case TIFF_BYTE: case TIFF_UNDEFINED: { - uint8 v2 = (uint8)va_arg(ap, int); + uint8_t v2 = (uint8_t)va_arg(ap, int); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SBYTE: { - int8 v2 = (int8)va_arg(ap, int); + int8_t v2 = (int8_t)va_arg(ap, int); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SHORT: { - uint16 v2 = (uint16)va_arg(ap, int); + uint16_t v2 = (uint16_t)va_arg(ap, int); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SSHORT: { - int16 v2 = (int16)va_arg(ap, int); + int16_t v2 = (int16_t)va_arg(ap, int); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_LONG: case TIFF_IFD: { - uint32 v2 = va_arg(ap, uint32); + uint32_t v2 = va_arg(ap, uint32_t); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SLONG: { - int32 v2 = va_arg(ap, int32); + int32_t v2 = va_arg(ap, int32_t); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_LONG8: case TIFF_IFD8: { - uint64 v2 = va_arg(ap, uint64); + uint64_t v2 = va_arg(ap, uint64_t); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SLONG8: { - int64 v2 = va_arg(ap, int64); + int64_t v2 = va_arg(ap, int64_t); _TIFFmemcpy(val, &v2, tv_size); } break; @@ -755,7 +755,7 @@ badvalue: { const TIFFField* fip2=TIFFFieldWithTag(tif,tag); TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad value %u for \"%s\" tag", + "%s: Bad value %"PRIu32" for \"%s\" tag", tif->tif_name, v, fip2 ? fip2->field_name : "Unknown"); va_end(ap); @@ -765,7 +765,7 @@ badvalue32: { const TIFFField* fip2=TIFFFieldWithTag(tif,tag); TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad value %u for \"%s\" tag", + "%s: Bad value %"PRIu32" for \"%s\" tag", tif->tif_name, v32, fip2 ? fip2->field_name : "Unknown"); va_end(ap); @@ -793,11 +793,11 @@ badvaluedouble: * on the format of the data that is written. */ static int -OkToChangeTag(TIFF* tif, uint32 tag) +OkToChangeTag(TIFF* tif, uint32_t tag) { const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); if (!fip) { /* unknown tag */ - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u", + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %"PRIu32, tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); return (0); } @@ -825,7 +825,7 @@ OkToChangeTag(TIFF* tif, uint32 tag) * updated. */ int -TIFFSetField(TIFF* tif, uint32 tag, ...) +TIFFSetField(TIFF* tif, uint32_t tag, ...) { va_list ap; int status; @@ -840,7 +840,7 @@ TIFFSetField(TIFF* tif, uint32 tag, ...) * Clear the contents of the field in the internal structure. */ int -TIFFUnsetField(TIFF* tif, uint32 tag) +TIFFUnsetField(TIFF* tif, uint32_t tag) { const TIFFField *fip = TIFFFieldWithTag(tif, tag); TIFFDirectory* td = &tif->tif_dir; @@ -884,18 +884,18 @@ TIFFUnsetField(TIFF* tif, uint32 tag) * top of the library. */ int -TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) +TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap) { return OkToChangeTag(tif, tag) ? (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0; } static int -_TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) +_TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap) { TIFFDirectory* td = &tif->tif_dir; int ret_val = 1; - uint32 standard_tag = tag; + uint32_t standard_tag = tag; const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */ return 0; @@ -914,13 +914,13 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) { int i; for (i = 0; i < td->td_customValueCount; i++) { - uint16 val; + uint16_t val; TIFFTagValue *tv = td->td_customValues + i; if (tv->info->field_tag != standard_tag) continue; if( tv->value == NULL ) return 0; - val = *(uint16 *)tv->value; + val = *(uint16_t *)tv->value; /* Truncate to SamplesPerPixel, since the */ /* setting code for INKNAMES assume that there are SamplesPerPixel */ /* inknames. */ @@ -928,11 +928,11 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) if( val > td->td_samplesperpixel ) { TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField", - "Truncating NumberOfInks from %u to %u", + "Truncating NumberOfInks from %u to %"PRIu16, val, td->td_samplesperpixel); val = td->td_samplesperpixel; } - *va_arg(ap, uint16*) = val; + *va_arg(ap, uint16_t*) = val; return 1; } return 0; @@ -940,43 +940,43 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) switch (standard_tag) { case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32*) = td->td_subfiletype; + *va_arg(ap, uint32_t*) = td->td_subfiletype; break; case TIFFTAG_IMAGEWIDTH: - *va_arg(ap, uint32*) = td->td_imagewidth; + *va_arg(ap, uint32_t*) = td->td_imagewidth; break; case TIFFTAG_IMAGELENGTH: - *va_arg(ap, uint32*) = td->td_imagelength; + *va_arg(ap, uint32_t*) = td->td_imagelength; break; case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16*) = td->td_bitspersample; + *va_arg(ap, uint16_t*) = td->td_bitspersample; break; case TIFFTAG_COMPRESSION: - *va_arg(ap, uint16*) = td->td_compression; + *va_arg(ap, uint16_t*) = td->td_compression; break; case TIFFTAG_PHOTOMETRIC: - *va_arg(ap, uint16*) = td->td_photometric; + *va_arg(ap, uint16_t*) = td->td_photometric; break; case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16*) = td->td_threshholding; + *va_arg(ap, uint16_t*) = td->td_threshholding; break; case TIFFTAG_FILLORDER: - *va_arg(ap, uint16*) = td->td_fillorder; + *va_arg(ap, uint16_t*) = td->td_fillorder; break; case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16*) = td->td_orientation; + *va_arg(ap, uint16_t*) = td->td_orientation; break; case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16*) = td->td_samplesperpixel; + *va_arg(ap, uint16_t*) = td->td_samplesperpixel; break; case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32*) = td->td_rowsperstrip; + *va_arg(ap, uint32_t*) = td->td_rowsperstrip; break; case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_minsamplevalue; + *va_arg(ap, uint16_t*) = td->td_minsamplevalue; break; case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_maxsamplevalue; + *va_arg(ap, uint16_t*) = td->td_maxsamplevalue; break; case TIFFTAG_SMINSAMPLEVALUE: if (tif->tif_flags & TIFF_PERSAMPLE) @@ -984,7 +984,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) else { /* libtiff historically treats this as a single value. */ - uint16 i; + uint16_t i; double v = td->td_sminsamplevalue[0]; for (i=1; i < td->td_samplesperpixel; ++i) if( td->td_sminsamplevalue[i] < v ) @@ -998,7 +998,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) else { /* libtiff historically treats this as a single value. */ - uint16 i; + uint16_t i; double v = td->td_smaxsamplevalue[0]; for (i=1; i < td->td_samplesperpixel; ++i) if( td->td_smaxsamplevalue[i] > v ) @@ -1013,7 +1013,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) *va_arg(ap, float*) = td->td_yresolution; break; case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16*) = td->td_planarconfig; + *va_arg(ap, uint16_t*) = td->td_planarconfig; break; case TIFFTAG_XPOSITION: *va_arg(ap, float*) = td->td_xposition; @@ -1022,90 +1022,90 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) *va_arg(ap, float*) = td->td_yposition; break; case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16*) = td->td_resolutionunit; + *va_arg(ap, uint16_t*) = td->td_resolutionunit; break; case TIFFTAG_PAGENUMBER: - *va_arg(ap, uint16*) = td->td_pagenumber[0]; - *va_arg(ap, uint16*) = td->td_pagenumber[1]; + *va_arg(ap, uint16_t*) = td->td_pagenumber[0]; + *va_arg(ap, uint16_t*) = td->td_pagenumber[1]; break; case TIFFTAG_HALFTONEHINTS: - *va_arg(ap, uint16*) = td->td_halftonehints[0]; - *va_arg(ap, uint16*) = td->td_halftonehints[1]; + *va_arg(ap, uint16_t*) = td->td_halftonehints[0]; + *va_arg(ap, uint16_t*) = td->td_halftonehints[1]; break; case TIFFTAG_COLORMAP: - *va_arg(ap, const uint16**) = td->td_colormap[0]; - *va_arg(ap, const uint16**) = td->td_colormap[1]; - *va_arg(ap, const uint16**) = td->td_colormap[2]; + *va_arg(ap, const uint16_t**) = td->td_colormap[0]; + *va_arg(ap, const uint16_t**) = td->td_colormap[1]; + *va_arg(ap, const uint16_t**) = td->td_colormap[2]; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: _TIFFFillStriles( tif ); - *va_arg(ap, const uint64**) = td->td_stripoffset_p; + *va_arg(ap, const uint64_t**) = td->td_stripoffset_p; break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: _TIFFFillStriles( tif ); - *va_arg(ap, const uint64**) = td->td_stripbytecount_p; + *va_arg(ap, const uint64_t**) = td->td_stripbytecount_p; break; case TIFFTAG_MATTEING: - *va_arg(ap, uint16*) = + *va_arg(ap, uint16_t*) = (td->td_extrasamples == 1 && td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); break; case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16*) = td->td_extrasamples; - *va_arg(ap, const uint16**) = td->td_sampleinfo; + *va_arg(ap, uint16_t*) = td->td_extrasamples; + *va_arg(ap, const uint16_t**) = td->td_sampleinfo; break; case TIFFTAG_TILEWIDTH: - *va_arg(ap, uint32*) = td->td_tilewidth; + *va_arg(ap, uint32_t*) = td->td_tilewidth; break; case TIFFTAG_TILELENGTH: - *va_arg(ap, uint32*) = td->td_tilelength; + *va_arg(ap, uint32_t*) = td->td_tilelength; break; case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32*) = td->td_tiledepth; + *va_arg(ap, uint32_t*) = td->td_tiledepth; break; case TIFFTAG_DATATYPE: switch (td->td_sampleformat) { case SAMPLEFORMAT_UINT: - *va_arg(ap, uint16*) = DATATYPE_UINT; + *va_arg(ap, uint16_t*) = DATATYPE_UINT; break; case SAMPLEFORMAT_INT: - *va_arg(ap, uint16*) = DATATYPE_INT; + *va_arg(ap, uint16_t*) = DATATYPE_INT; break; case SAMPLEFORMAT_IEEEFP: - *va_arg(ap, uint16*) = DATATYPE_IEEEFP; + *va_arg(ap, uint16_t*) = DATATYPE_IEEEFP; break; case SAMPLEFORMAT_VOID: - *va_arg(ap, uint16*) = DATATYPE_VOID; + *va_arg(ap, uint16_t*) = DATATYPE_VOID; break; } break; case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16*) = td->td_sampleformat; + *va_arg(ap, uint16_t*) = td->td_sampleformat; break; case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32*) = td->td_imagedepth; + *va_arg(ap, uint32_t*) = td->td_imagedepth; break; case TIFFTAG_SUBIFD: - *va_arg(ap, uint16*) = td->td_nsubifd; - *va_arg(ap, const uint64**) = td->td_subifd; + *va_arg(ap, uint16_t*) = td->td_nsubifd; + *va_arg(ap, const uint64_t**) = td->td_subifd; break; case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16*) = td->td_ycbcrpositioning; + *va_arg(ap, uint16_t*) = td->td_ycbcrpositioning; break; case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; + *va_arg(ap, uint16_t*) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16_t*) = td->td_ycbcrsubsampling[1]; break; case TIFFTAG_TRANSFERFUNCTION: - *va_arg(ap, const uint16**) = td->td_transferfunction[0]; + *va_arg(ap, const uint16_t**) = td->td_transferfunction[0]; if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, const uint16**) = td->td_transferfunction[1]; - *va_arg(ap, const uint16**) = td->td_transferfunction[2]; + *va_arg(ap, const uint16_t**) = td->td_transferfunction[1]; + *va_arg(ap, const uint16_t**) = td->td_transferfunction[2]; } else { - *va_arg(ap, const uint16**) = NULL; - *va_arg(ap, const uint16**) = NULL; + *va_arg(ap, const uint16_t**) = NULL; + *va_arg(ap, const uint16_t**) = NULL; } break; case TIFFTAG_REFERENCEBLACKWHITE: @@ -1151,9 +1151,9 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) if (fip->field_passcount) { if (fip->field_readcount == TIFF_VARIABLE2) - *va_arg(ap, uint32*) = (uint32)tv->count; + *va_arg(ap, uint32_t*) = (uint32_t)tv->count; else /* Assume TIFF_VARIABLE */ - *va_arg(ap, uint16*) = (uint16)tv->count; + *va_arg(ap, uint16_t*) = (uint16_t)tv->count; *va_arg(ap, const void **) = tv->value; ret_val = 1; } else if (fip->field_tag == TIFFTAG_DOTRANGE @@ -1162,8 +1162,8 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) handled this way ... likely best if we move it into the directory structure with an explicit field in libtiff 4.1 and assign it a FIELD_ value */ - *va_arg(ap, uint16*) = ((uint16 *)tv->value)[0]; - *va_arg(ap, uint16*) = ((uint16 *)tv->value)[1]; + *va_arg(ap, uint16_t*) = ((uint16_t *)tv->value)[0]; + *va_arg(ap, uint16_t*) = ((uint16_t *)tv->value)[1]; ret_val = 1; } else { if (fip->field_type == TIFF_ASCII @@ -1179,45 +1179,45 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) switch (fip->field_type) { case TIFF_BYTE: case TIFF_UNDEFINED: - *va_arg(ap, uint8*) = - *(uint8 *)val; + *va_arg(ap, uint8_t*) = + *(uint8_t *)val; ret_val = 1; break; case TIFF_SBYTE: - *va_arg(ap, int8*) = - *(int8 *)val; + *va_arg(ap, int8_t*) = + *(int8_t *)val; ret_val = 1; break; case TIFF_SHORT: - *va_arg(ap, uint16*) = - *(uint16 *)val; + *va_arg(ap, uint16_t*) = + *(uint16_t *)val; ret_val = 1; break; case TIFF_SSHORT: - *va_arg(ap, int16*) = - *(int16 *)val; + *va_arg(ap, int16_t*) = + *(int16_t *)val; ret_val = 1; break; case TIFF_LONG: case TIFF_IFD: - *va_arg(ap, uint32*) = - *(uint32 *)val; + *va_arg(ap, uint32_t*) = + *(uint32_t *)val; ret_val = 1; break; case TIFF_SLONG: - *va_arg(ap, int32*) = - *(int32 *)val; + *va_arg(ap, int32_t*) = + *(int32_t *)val; ret_val = 1; break; case TIFF_LONG8: case TIFF_IFD8: - *va_arg(ap, uint64*) = - *(uint64 *)val; + *va_arg(ap, uint64_t*) = + *(uint64_t *)val; ret_val = 1; break; case TIFF_SLONG8: - *va_arg(ap, int64*) = - *(int64 *)val; + *va_arg(ap, int64_t*) = + *(int64_t *)val; ret_val = 1; break; case TIFF_RATIONAL: @@ -1267,7 +1267,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) * internal directory structure. */ int -TIFFGetField(TIFF* tif, uint32 tag, ...) +TIFFGetField(TIFF* tif, uint32_t tag, ...) { int status; va_list ap; @@ -1285,7 +1285,7 @@ TIFFGetField(TIFF* tif, uint32 tag, ...) * top of the library. */ int -TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) +TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap) { const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ? @@ -1368,8 +1368,8 @@ TIFFCreateDirectory(TIFF* tif) tif->tif_diroff = 0; tif->tif_nextdiroff = 0; tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (uint32) -1; + tif->tif_row = (uint32_t) -1; + tif->tif_curstrip = (uint32_t) -1; return 0; } @@ -1381,7 +1381,7 @@ TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray) /* * Reset the field definitions to match the application provided list. - * Hopefully TIFFDefaultDirectory() won't have done anything irreversable + * Hopefully TIFFDefaultDirectory() won't have done anything irreversible * based on it's assumption this is an image directory. */ _TIFFSetupFields(tif, infoarray); @@ -1389,8 +1389,8 @@ TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray) tif->tif_diroff = 0; tif->tif_nextdiroff = 0; tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (uint32) -1; + tif->tif_row = (uint32_t) -1; + tif->tif_curstrip = (uint32_t) -1; return 0; } @@ -1432,7 +1432,7 @@ TIFFDefaultDirectory(TIFF* tif) td->td_threshholding = THRESHHOLD_BILEVEL; td->td_orientation = ORIENTATION_TOPLEFT; td->td_samplesperpixel = 1; - td->td_rowsperstrip = (uint32) -1; + td->td_rowsperstrip = (uint32_t) -1; td->td_tilewidth = 0; td->td_tilelength = 0; td->td_tiledepth = 1; @@ -1456,7 +1456,7 @@ TIFFDefaultDirectory(TIFF* tif) * but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054) */ if (tif->tif_nfieldscompat > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfieldscompat; i++) { if (tif->tif_fieldscompat[i].allocated_size) @@ -1490,38 +1490,38 @@ TIFFDefaultDirectory(TIFF* tif) } static int -TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) +TIFFAdvanceDirectory(TIFF* tif, uint64_t* nextdir, uint64_t* off) { static const char module[] = "TIFFAdvanceDirectory"; if (isMapped(tif)) { - uint64 poff=*nextdir; + uint64_t poff=*nextdir; if (!(tif->tif_flags&TIFF_BIGTIFF)) { tmsize_t poffa,poffb,poffc,poffd; - uint16 dircount; - uint32 nextdir32; + uint16_t dircount; + uint32_t nextdir32; poffa=(tmsize_t)poff; - poffb=poffa+sizeof(uint16); - if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint16))||(poffb>tif->tif_size)) + poffb=poffa+sizeof(uint16_t); + if (((uint64_t)poffa != poff) || (poffb < poffa) || (poffb < (tmsize_t)sizeof(uint16_t)) || (poffb > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count"); *nextdir=0; return(0); } - _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16)); + _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(&dircount); poffc=poffb+dircount*12; - poffd=poffc+sizeof(uint32); - if ((poffc<poffb)||(poffc<dircount*12)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint32))||(poffd>tif->tif_size)) + poffd=poffc+sizeof(uint32_t); + if ((poffc<poffb) || (poffc<dircount*12) || (poffd<poffc) || (poffd<(tmsize_t)sizeof(uint32_t)) || (poffd > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link"); return(0); } if (off!=NULL) - *off=(uint64)poffc; - _TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32)); + *off=(uint64_t)poffc; + _TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&nextdir32); *nextdir=nextdir32; @@ -1529,16 +1529,16 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) else { tmsize_t poffa,poffb,poffc,poffd; - uint64 dircount64; - uint16 dircount16; + uint64_t dircount64; + uint16_t dircount16; poffa=(tmsize_t)poff; - poffb=poffa+sizeof(uint64); - if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint64))||(poffb>tif->tif_size)) + poffb=poffa+sizeof(uint64_t); + if (((uint64_t)poffa != poff) || (poffb < poffa) || (poffb < (tmsize_t)sizeof(uint64_t)) || (poffb > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count"); return(0); } - _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64)); + _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(&dircount64); if (dircount64>0xFFFF) @@ -1546,17 +1546,17 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) TIFFErrorExt(tif->tif_clientdata,module,"Sanity check on directory count failed"); return(0); } - dircount16=(uint16)dircount64; + dircount16=(uint16_t)dircount64; poffc=poffb+dircount16*20; - poffd=poffc+sizeof(uint64); - if ((poffc<poffb)||(poffc<dircount16*20)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint64))||(poffd>tif->tif_size)) + poffd=poffc+sizeof(uint64_t); + if ((poffc<poffb) || (poffc<dircount16*20) || (poffd<poffc) || (poffd<(tmsize_t)sizeof(uint64_t)) || (poffd > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link"); return(0); } if (off!=NULL) - *off=(uint64)poffc; - _TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64)); + *off=(uint64_t)poffc; + _TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(nextdir); } @@ -1566,10 +1566,10 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint16 dircount; - uint32 nextdir32; + uint16_t dircount; + uint32_t nextdir32; if (!SeekOK(tif, *nextdir) || - !ReadOK(tif, &dircount, sizeof (uint16))) { + !ReadOK(tif, &dircount, sizeof (uint16_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", tif->tif_name); return (0); @@ -1582,7 +1582,7 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) else (void) TIFFSeekFile(tif, dircount*12, SEEK_CUR); - if (!ReadOK(tif, &nextdir32, sizeof (uint32))) { + if (!ReadOK(tif, &nextdir32, sizeof (uint32_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", tif->tif_name); return (0); @@ -1593,10 +1593,10 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) } else { - uint64 dircount64; - uint16 dircount16; + uint64_t dircount64; + uint16_t dircount16; if (!SeekOK(tif, *nextdir) || - !ReadOK(tif, &dircount64, sizeof (uint64))) { + !ReadOK(tif, &dircount64, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", tif->tif_name); return (0); @@ -1608,14 +1608,14 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count"); return(0); } - dircount16 = (uint16)dircount64; + dircount16 = (uint16_t)dircount64; if (off != NULL) *off = TIFFSeekFile(tif, dircount16*20, SEEK_CUR); else (void) TIFFSeekFile(tif, dircount16*20, SEEK_CUR); - if (!ReadOK(tif, nextdir, sizeof (uint64))) { + if (!ReadOK(tif, nextdir, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", tif->tif_name); @@ -1631,12 +1631,12 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) /* * Count the number of directories in a file. */ -uint16 +uint16_t TIFFNumberOfDirectories(TIFF* tif) { static const char module[] = "TIFFNumberOfDirectories"; - uint64 nextdir; - uint16 n; + uint64_t nextdir; + uint16_t n; if (!(tif->tif_flags&TIFF_BIGTIFF)) nextdir = tif->tif_header.classic.tiff_diroff; else @@ -1663,10 +1663,10 @@ TIFFNumberOfDirectories(TIFF* tif) * NB: Directories are numbered starting at 0. */ int -TIFFSetDirectory(TIFF* tif, uint16 dirn) +TIFFSetDirectory(TIFF* tif, uint16_t dirn) { - uint64 nextdir; - uint16 n; + uint64_t nextdir; + uint16_t n; if (!(tif->tif_flags&TIFF_BIGTIFF)) nextdir = tif->tif_header.classic.tiff_diroff; @@ -1697,7 +1697,7 @@ TIFFSetDirectory(TIFF* tif, uint16 dirn) * the SubIFD tag (e.g. thumbnail images). */ int -TIFFSetSubDirectory(TIFF* tif, uint64 diroff) +TIFFSetSubDirectory(TIFF* tif, uint64_t diroff) { tif->tif_nextdiroff = diroff; /* @@ -1711,7 +1711,7 @@ TIFFSetSubDirectory(TIFF* tif, uint64 diroff) /* * Return file offset of the current directory. */ -uint64 +uint64_t TIFFCurrentDirOffset(TIFF* tif) { return (tif->tif_diroff); @@ -1731,12 +1731,12 @@ TIFFLastDirectory(TIFF* tif) * Unlink the specified directory from the directory chain. */ int -TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) +TIFFUnlinkDirectory(TIFF* tif, uint16_t dirn) { static const char module[] = "TIFFUnlinkDirectory"; - uint64 nextdir; - uint64 off; - uint16 n; + uint64_t nextdir; + uint64_t off; + uint16_t n; if (tif->tif_mode == O_RDONLY) { TIFFErrorExt(tif->tif_clientdata, module, @@ -1760,7 +1760,7 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) } for (n = dirn-1; n > 0; n--) { if (nextdir == 0) { - TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn); + TIFFErrorExt(tif->tif_clientdata, module, "Directory %"PRIu16" does not exist", dirn); return (0); } if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) @@ -1780,12 +1780,12 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) (void) TIFFSeekFile(tif, off, SEEK_SET); if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 nextdir32; - nextdir32=(uint32)nextdir; - assert((uint64)nextdir32==nextdir); + uint32_t nextdir32; + nextdir32=(uint32_t)nextdir; + assert((uint64_t)nextdir32 == nextdir); if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&nextdir32); - if (!WriteOK(tif, &nextdir32, sizeof (uint32))) { + if (!WriteOK(tif, &nextdir32, sizeof (uint32_t))) { TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); return (0); } @@ -1794,7 +1794,7 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) { if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&nextdir); - if (!WriteOK(tif, &nextdir, sizeof (uint64))) { + if (!WriteOK(tif, &nextdir, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); return (0); } @@ -1820,8 +1820,8 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) tif->tif_diroff = 0; /* force link on next write */ tif->tif_nextdiroff = 0; /* next write must be at end */ tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (uint32) -1; + tif->tif_row = (uint32_t) -1; + tif->tif_curstrip = (uint32_t) -1; return (1); } diff --git a/tiff/libtiff/tif_dir.h b/tiff/libtiff/tif_dir.h index f608dd71..1782b35d 100644 --- a/tiff/libtiff/tif_dir.h +++ b/tiff/libtiff/tif_dir.h @@ -50,15 +50,15 @@ typedef struct { * it is left-justified in the offset field. */ typedef struct { - uint16 tdir_tag; /* see below */ - uint16 tdir_type; /* data type; see below */ - uint64 tdir_count; /* number of items; length in spec */ + uint16_t tdir_tag; /* see below */ + uint16_t tdir_type; /* data type; see below */ + uint64_t tdir_count; /* number of items; length in spec */ union { - uint16 toff_short; - uint32 toff_long; - uint64 toff_long8; + uint16_t toff_short; + uint32_t toff_long; + uint64_t toff_long8; } tdir_offset; /* either offset or the data itself if fits */ - uint8 tdir_ignore; /* flag status to ignore tag when parsing tags in tif_dirread.c */ + uint8_t tdir_ignore; /* flag status to ignore tag when parsing tags in tif_dirread.c */ } TIFFDirEntry; /* @@ -69,50 +69,50 @@ typedef struct { /* bit vector of fields that are set */ unsigned long td_fieldsset[FIELD_SETLONGS]; - uint32 td_imagewidth, td_imagelength, td_imagedepth; - uint32 td_tilewidth, td_tilelength, td_tiledepth; - uint32 td_subfiletype; - uint16 td_bitspersample; - uint16 td_sampleformat; - uint16 td_compression; - uint16 td_photometric; - uint16 td_threshholding; - uint16 td_fillorder; - uint16 td_orientation; - uint16 td_samplesperpixel; - uint32 td_rowsperstrip; - uint16 td_minsamplevalue, td_maxsamplevalue; + uint32_t td_imagewidth, td_imagelength, td_imagedepth; + uint32_t td_tilewidth, td_tilelength, td_tiledepth; + uint32_t td_subfiletype; + uint16_t td_bitspersample; + uint16_t td_sampleformat; + uint16_t td_compression; + uint16_t td_photometric; + uint16_t td_threshholding; + uint16_t td_fillorder; + uint16_t td_orientation; + uint16_t td_samplesperpixel; + uint32_t td_rowsperstrip; + uint16_t td_minsamplevalue, td_maxsamplevalue; double* td_sminsamplevalue; double* td_smaxsamplevalue; float td_xresolution, td_yresolution; - uint16 td_resolutionunit; - uint16 td_planarconfig; + uint16_t td_resolutionunit; + uint16_t td_planarconfig; float td_xposition, td_yposition; - uint16 td_pagenumber[2]; - uint16* td_colormap[3]; - uint16 td_halftonehints[2]; - uint16 td_extrasamples; - uint16* td_sampleinfo; + uint16_t td_pagenumber[2]; + uint16_t* td_colormap[3]; + uint16_t td_halftonehints[2]; + uint16_t td_extrasamples; + uint16_t* td_sampleinfo; /* even though the name is misleading, td_stripsperimage is the number * of striles (=strips or tiles) per plane, and td_nstrips the total * number of striles */ - uint32 td_stripsperimage; - uint32 td_nstrips; /* size of offset & bytecount arrays */ - uint64* td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */ - uint64* td_stripbytecount_p; /* should be accessed with TIFFGetStrileByteCount */ - uint32 td_stripoffsetbyteallocsize; /* number of elements currently allocated for td_stripoffset/td_stripbytecount. Only used if TIFF_LAZYSTRILELOAD is set */ + uint32_t td_stripsperimage; + uint32_t td_nstrips; /* size of offset & bytecount arrays */ + uint64_t* td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */ + uint64_t* td_stripbytecount_p; /* should be accessed with TIFFGetStrileByteCount */ + uint32_t td_stripoffsetbyteallocsize; /* number of elements currently allocated for td_stripoffset/td_stripbytecount. Only used if TIFF_LAZYSTRILELOAD is set */ #ifdef STRIPBYTECOUNTSORTED_UNUSED int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ #endif TIFFDirEntry td_stripoffset_entry; /* for deferred loading */ TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */ - uint16 td_nsubifd; - uint64* td_subifd; + uint16_t td_nsubifd; + uint64_t* td_subifd; /* YCbCr parameters */ - uint16 td_ycbcrsubsampling[2]; - uint16 td_ycbcrpositioning; + uint16_t td_ycbcrsubsampling[2]; + uint16_t td_ycbcrpositioning; /* Colorimetry parameters */ - uint16* td_transferfunction[3]; + uint16_t* td_transferfunction[3]; float* td_refblackwhite; /* CMYK parameters */ int td_inknameslen; @@ -276,17 +276,17 @@ typedef enum { struct _TIFFFieldArray { TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */ - uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */ - uint32 count; /* number of elements in fields array */ + uint32_t allocated_size; /* 0 if array is constant, other if modified by future definition extension support */ + uint32_t count; /* number of elements in fields array */ TIFFField* fields; /* actual field info */ }; struct _TIFFField { - uint32 field_tag; /* field's tag */ + uint32_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ short field_writecount; /* write count/TIFF_VARIABLE */ TIFFDataType field_type; /* type of associated data */ - uint32 reserved; /* reserved for future extension */ + uint32_t reserved; /* reserved for future extension */ TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */ TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */ unsigned short field_bit; /* bit in fieldsset bit vector */ @@ -296,9 +296,9 @@ struct _TIFFField { TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */ }; -extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32); -extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType); -extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType); +extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32_t); +extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32_t, TIFFDataType); +extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32_t, TIFFDataType); extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag); #if defined(__cplusplus) diff --git a/tiff/libtiff/tif_dirinfo.c b/tiff/libtiff/tif_dirinfo.c index 7217042c..8565dfbc 100644 --- a/tiff/libtiff/tif_dirinfo.c +++ b/tiff/libtiff/tif_dirinfo.c @@ -325,7 +325,7 @@ exifFields[] = { * EXIF-GPS tags (Version 2.31, July 2016; nothing changed for version 2.32 May 2019) */ -static TIFFField +static const TIFFField gpsFields[] = { /* For the GPS tag definitions in gpsFields[] the standard definition for Rationals is TIFF_SETGET_DOUBLE and TIFF_SETGET_C0_FLOAT. *-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values can now be written and also read in double precision! @@ -415,7 +415,7 @@ void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* fieldarray) { if (tif->tif_fields && tif->tif_nfields > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfields; i++) { TIFFField *fld = tif->tif_fields[i]; @@ -464,12 +464,12 @@ tagNameCompare(const void* a, const void* b) } int -_TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n) +_TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32_t n) { static const char module[] = "_TIFFMergeFields"; static const char reason[] = "for fields array"; /* TIFFField** tp; */ - uint32 i; + uint32_t i; tif->tif_foundfield = NULL; @@ -511,7 +511,7 @@ _TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n) void _TIFFPrintFieldInfo(TIFF* tif, FILE* fd) { - uint32 i; + uint32_t i; fprintf(fd, "%s: \n", tif->tif_name); for (i = 0; i < tif->tif_nfields; i++) { @@ -677,7 +677,7 @@ _TIFFSetGetFieldSize(TIFFSetGetFieldType setgettype) const TIFFField* -TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt) +TIFFFindField(TIFF* tif, uint32_t tag, TIFFDataType dt) { TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; TIFFField* pkey = &key; @@ -729,7 +729,7 @@ _TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt) } const TIFFField* -TIFFFieldWithTag(TIFF* tif, uint32 tag) +TIFFFieldWithTag(TIFF* tif, uint32_t tag) { const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); if (!fip) { @@ -752,7 +752,7 @@ TIFFFieldWithName(TIFF* tif, const char *field_name) return (fip); } -uint32 +uint32_t TIFFFieldTag(const TIFFField* fip) { return fip->field_tag; @@ -789,7 +789,7 @@ TIFFFieldWriteCount(const TIFFField* fip) } const TIFFField* -_TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt) +_TIFFFindOrRegisterField(TIFF *tif, uint32_t tag, TIFFDataType dt) { const TIFFField *fld; @@ -805,7 +805,7 @@ _TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt) } TIFFField* -_TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type) +_TIFFCreateAnonField(TIFF *tif, uint32_t tag, TIFFDataType field_type) { TIFFField *fld; (void) tif; @@ -1059,13 +1059,13 @@ _TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount) } int -TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) +TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32_t n) { static const char module[] = "TIFFMergeFieldInfo"; static const char reason[] = "for fields array"; TIFFField *tp; size_t nfields; - uint32 i; + uint32_t i; if (tif->tif_nfieldscompat > 0) { tif->tif_fieldscompat = (TIFFFieldArray *) diff --git a/tiff/libtiff/tif_dirread.c b/tiff/libtiff/tif_dirread.c index ba127ca9..d84147a0 100644 --- a/tiff/libtiff/tif_dirread.c +++ b/tiff/libtiff/tif_dirread.c @@ -34,23 +34,19 @@ * TIFFReadDirectory, so as to eliminate current possibly repetitive lookup. */ +#include "tiffconf.h" #include "tiffiop.h" #include <float.h> #include <stdlib.h> -#define FAILED_FII ((uint32) -1) - -/* - * Largest 64-bit signed integer value. - */ -#define TIFF_INT64_MAX ((int64)(TIFF_UINT64_MAX >> 1)) +#define FAILED_FII ((uint32_t) -1) #ifdef HAVE_IEEEFP # define TIFFCvtIEEEFloatToNative(tif, n, fp) # define TIFFCvtIEEEDoubleToNative(tif, n, dp) #else -extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); -extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); +extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32_t, float*); +extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32_t, double*); #endif enum TIFFReadDirEntryErr { @@ -64,126 +60,126 @@ enum TIFFReadDirEntryErr { TIFFReadDirEntryErrAlloc = 7, }; -static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* direntry, float* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32_t* count, uint32_t desttypesize, void** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64_t** value); static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEntry* direntry, float** value); static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64_t** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value); #if 0 static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); #endif -static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value); -static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8* value); -static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); -static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16* value); -static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value); -static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64* value); +static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8_t* value); +static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8_t* value); +static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value); +static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16_t* value); +static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32_t* value); +static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64_t* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFDirEntry* direntry, double* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFFDirEntry* direntry, double* value); static void TIFFReadDirEntryCheckedFloat(TIFF* tif, TIFFDirEntry* direntry, float* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte(int8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF* tif, uint64_t offset, tmsize_t size, void* dest); static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, const char* module, const char* tagname, int recover); -static void TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount); -static TIFFDirEntry* TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 tagid); -static void TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii); +static void TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount); +static TIFFDirEntry* TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount, uint16_t tagid); +static void TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16_t tagid, uint32_t* fii); -static int EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount); +static int EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount); static void MissingRequired(TIFF*, const char*); -static int TIFFCheckDirOffset(TIFF* tif, uint64 diroff); -static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); -static uint16 TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, uint64* nextdiroff); +static int TIFFCheckDirOffset(TIFF* tif, uint64_t diroff); +static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32_t); +static uint16_t TIFFFetchDirectory(TIFF* tif, uint64_t diroff, TIFFDirEntry** pdir, uint64_t* nextdiroff); static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*, int recover); -static int TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp); +static int TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32_t nstrips, uint64_t** lpp); static int TIFFFetchSubjectDistance(TIFF*, TIFFDirEntry*); static void ChopUpSingleUncompressedStrip(TIFF*); static void TryChopUpUncompressedBigTiff(TIFF*); -static uint64 TIFFReadUInt64(const uint8 *value); -static int _TIFFGetMaxColorChannels(uint16 photometric); +static uint64_t TIFFReadUInt64(const uint8_t *value); +static int _TIFFGetMaxColorChannels(uint16_t photometric); static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount ); typedef union _UInt64Aligned_t { double d; - uint64 l; - uint32 i[2]; - uint16 s[4]; - uint8 c[8]; + uint64_t l; + uint32_t i[2]; + uint16_t s[4]; + uint8_t c[8]; } UInt64Aligned_t; /* - Unaligned safe copy of a uint64 value from an octet array. + Unaligned safe copy of a uint64_t value from an octet array. */ -static uint64 TIFFReadUInt64(const uint8 *value) +static uint64_t TIFFReadUInt64(const uint8_t *value) { UInt64Aligned_t result; @@ -199,7 +195,7 @@ static uint64 TIFFReadUInt64(const uint8 *value) return result.l; } -static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -212,76 +208,76 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* di return(TIFFReadDirEntryErrOk); case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteSbyte(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteShort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteSshort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteLong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteSlong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeByteLong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeByteSlong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } default: @@ -289,7 +285,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* di } } -static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -298,19 +294,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* d { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeShortSbyte(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: @@ -318,56 +314,56 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* d return(TIFFReadDirEntryErrOk); case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeShortSshort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeShortLong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeShortSlong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeShortLong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeShortSlong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } default: @@ -375,7 +371,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* d } } -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -384,36 +380,36 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* di { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLongSbyte(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLongSshort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: @@ -421,36 +417,36 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* di return(TIFFReadDirEntryErrOk); case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLongSlong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeLongLong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeLongSlong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } default: @@ -458,7 +454,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* di } } -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -467,53 +463,53 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* d { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLong8Sbyte(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLong8Sshort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLong8Slong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: @@ -521,14 +517,14 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* d return(err); case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeLong8Slong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } default: @@ -545,49 +541,49 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* d { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); @@ -605,7 +601,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* d } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); @@ -658,49 +654,49 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); @@ -718,7 +714,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); @@ -746,7 +742,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* } } -static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -756,9 +752,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* di case TIFF_LONG: case TIFF_IFD: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: @@ -776,7 +772,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* di #define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD) static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( - TIFF* tif, uint64 offset, tmsize_t size, void** pdest) + TIFF* tif, uint64_t offset, tmsize_t size, void** pdest) { #if SIZEOF_SIZE_T == 8 tmsize_t threshold = INITIAL_THRESHOLD; @@ -807,15 +803,15 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( } #endif - new_dest = (uint8*) _TIFFrealloc( + new_dest = (uint8_t*) _TIFFrealloc( *pdest, already_read + to_read); if( new_dest == NULL ) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%ld elements of %ld bytes each)", + "(%"TIFF_SSIZE_FORMAT" elements of %"TIFF_SSIZE_FORMAT" bytes each)", "TIFFReadDirEntryArray", - (long) 1, (long) (already_read + to_read)); + (tmsize_t) 1, already_read + to_read); return TIFFReadDirEntryErrAlloc; } *pdest = new_dest; @@ -831,13 +827,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( } static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( - TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, - void** value, uint64 maxcount) + TIFF* tif, TIFFDirEntry* direntry, uint32_t* count, uint32_t desttypesize, + void** value, uint64_t maxcount) { int typesize; - uint32 datasize; + uint32_t datasize; void* data; - uint64 target_count64; + uint64_t target_count64; int original_datasize_clamped; typesize=TIFFDataWidth(direntry->tdir_type); @@ -862,16 +858,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( * in either the current data type or the dest data type. This also * avoids problems with overflow of tmsize_t on 32bit systems. */ - if ((uint64)(2147483647/typesize)<target_count64) + if ((uint64_t)(2147483647 / typesize) < target_count64) return(TIFFReadDirEntryErrSizesan); - if ((uint64)(2147483647/desttypesize)<target_count64) + if ((uint64_t)(2147483647 / desttypesize) < target_count64) return(TIFFReadDirEntryErrSizesan); - *count=(uint32)target_count64; + *count=(uint32_t)target_count64; datasize=(*count)*typesize; assert((tmsize_t)datasize>0); - if( isMapped(tif) && datasize > (uint64)tif->tif_size ) + if( isMapped(tif) && datasize > (uint64_t)tif->tif_size ) return TIFFReadDirEntryErrIo; if( !isMapped(tif) && @@ -888,18 +884,20 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( } if (!(tif->tif_flags&TIFF_BIGTIFF)) { - if (original_datasize_clamped<=4) + /* Only the condition on original_datasize_clamped. The second + * one is implied, but Coverity Scan cannot see it. */ + if (original_datasize_clamped<=4 && datasize <= 4 ) _TIFFmemcpy(data,&direntry->tdir_offset,datasize); else { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); if( isMapped(tif) ) - err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data); + err=TIFFReadDirEntryData(tif, (uint64_t)offset, (tmsize_t)datasize, data); else - err=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data); + err=TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset, (tmsize_t)datasize, &data); if (err!=TIFFReadDirEntryErrOk) { _TIFFfree(data); @@ -909,18 +907,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( } else { - if (original_datasize_clamped<=8) + /* See above comment for the Classic TIFF case */ + if (original_datasize_clamped<=8 && datasize <= 8 ) _TIFFmemcpy(data,&direntry->tdir_offset,datasize); else { enum TIFFReadDirEntryErr err; - uint64 offset = direntry->tdir_offset.toff_long8; + uint64_t offset = direntry->tdir_offset.toff_long8; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(&offset); if( isMapped(tif) ) - err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data); + err=TIFFReadDirEntryData(tif, (uint64_t)offset, (tmsize_t)datasize, data); else - err=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data); + err=TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset, (tmsize_t)datasize, &data); if (err!=TIFFReadDirEntryErrOk) { _TIFFfree(data); @@ -932,18 +931,18 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32_t* count, uint32_t desttypesize, void** value) { return TIFFReadDirEntryArrayWithLimit(tif, direntry, count, - desttypesize, value, ~((uint64)0)); + desttypesize, value, ~((uint64_t)0)); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint8* data; + uint8_t* data; switch (direntry->tdir_type) { case TIFF_ASCII: @@ -971,13 +970,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr case TIFF_ASCII: case TIFF_UNDEFINED: case TIFF_BYTE: - *value=(uint8*)origdata; + *value=(uint8_t*)origdata; return(TIFFReadDirEntryErrOk); case TIFF_SBYTE: { - int8* m; - uint32 n; - m=(int8*)origdata; + int8_t* m; + uint32_t n; + m=(int8_t*)origdata; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeByteSbyte(*m); @@ -988,11 +987,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr } m++; } - *value=(uint8*)origdata; + *value=(uint8_t*)origdata; return(TIFFReadDirEntryErrOk); } } - data=(uint8*)_TIFFmalloc(count); + data=(uint8_t*)_TIFFmalloc(count); if (data==0) { _TIFFfree(origdata); @@ -1002,10 +1001,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr { case TIFF_SHORT: { - uint16* ma; - uint8* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + uint8_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1014,34 +1013,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr err=TIFFReadDirEntryCheckRangeByteShort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - uint8* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + uint8_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); err=TIFFReadDirEntryCheckRangeByteSshort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - uint8* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + uint8_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1050,34 +1049,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr err=TIFFReadDirEntryCheckRangeByteLong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - uint8* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + uint8_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeByteSlong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - uint8* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + uint8_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1086,25 +1085,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr err=TIFFReadDirEntryCheckRangeByteLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - uint8* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + uint8_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeByteSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; @@ -1119,12 +1118,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - int8* data; + int8_t* data; switch (direntry->tdir_type) { case TIFF_UNDEFINED: @@ -1151,9 +1150,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt case TIFF_UNDEFINED: case TIFF_BYTE: { - uint8* m; - uint32 n; - m=(uint8*)origdata; + uint8_t* m; + uint32_t n; + m=(uint8_t*)origdata; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeSbyteByte(*m); @@ -1164,14 +1163,14 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt } m++; } - *value=(int8*)origdata; + *value=(int8_t*)origdata; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: - *value=(int8*)origdata; + *value=(int8_t*)origdata; return(TIFFReadDirEntryErrOk); } - data=(int8*)_TIFFmalloc(count); + data=(int8_t*)_TIFFmalloc(count); if (data==0) { _TIFFfree(origdata); @@ -1181,10 +1180,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt { case TIFF_SHORT: { - uint16* ma; - int8* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + int8_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1193,34 +1192,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeSbyteShort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - int8* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + int8_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); err=TIFFReadDirEntryCheckRangeSbyteSshort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - int8* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + int8_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1229,34 +1228,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeSbyteLong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - int8* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + int8_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeSbyteSlong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - int8* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + int8_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1265,25 +1264,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeSbyteLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - int8* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + int8_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeSbyteSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; @@ -1298,12 +1297,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint16* data; + uint16_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1327,19 +1326,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt switch (direntry->tdir_type) { case TIFF_SHORT: - *value=(uint16*)origdata; + *value=(uint16_t*)origdata; if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfShort(*value,count); return(TIFFReadDirEntryErrOk); case TIFF_SSHORT: { - int16* m; - uint32 n; - m=(int16*)origdata; + int16_t* m; + uint32_t n; + m=(int16_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)m); + TIFFSwabShort((uint16_t*)m); err=TIFFReadDirEntryCheckRangeShortSshort(*m); if (err!=TIFFReadDirEntryErrOk) { @@ -1348,11 +1347,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt } m++; } - *value=(uint16*)origdata; + *value=(uint16_t*)origdata; return(TIFFReadDirEntryErrOk); } } - data=(uint16*)_TIFFmalloc(count*2); + data=(uint16_t*)_TIFFmalloc(count * 2); if (data==0) { _TIFFfree(origdata); @@ -1362,37 +1361,37 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt { case TIFF_BYTE: { - uint8* ma; - uint16* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + uint16_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - uint16* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + uint16_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeShortSbyte(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - uint16* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + uint16_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1401,34 +1400,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeShortLong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - uint16* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + uint16_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeShortSlong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - uint16* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + uint16_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1437,25 +1436,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeShortLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - uint16* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + uint16_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeShortSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; @@ -1470,12 +1469,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - int16* data; + int16_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1500,9 +1499,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn { case TIFF_SHORT: { - uint16* m; - uint32 n; - m=(uint16*)origdata; + uint16_t* m; + uint32_t n; + m=(uint16_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) @@ -1515,16 +1514,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn } m++; } - *value=(int16*)origdata; + *value=(int16_t*)origdata; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: - *value=(int16*)origdata; + *value=(int16_t*)origdata; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfShort((uint16*)(*value),count); + TIFFSwabArrayOfShort((uint16_t*)(*value), count); return(TIFFReadDirEntryErrOk); } - data=(int16*)_TIFFmalloc(count*2); + data=(int16_t*)_TIFFmalloc(count * 2); if (data==0) { _TIFFfree(origdata); @@ -1534,32 +1533,32 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn { case TIFF_BYTE: { - uint8* ma; - int16* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + int16_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - int16* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + int16_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } break; case TIFF_LONG: { - uint32* ma; - int16* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + int16_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1568,34 +1567,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn err=TIFFReadDirEntryCheckRangeSshortLong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - int16* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + int16_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeSshortSlong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - int16* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + int16_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1604,25 +1603,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn err=TIFFReadDirEntryCheckRangeSshortLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - int16* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + int16_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeSshortSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } } break; @@ -1637,12 +1636,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint32* data; + uint32_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1666,19 +1665,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr switch (direntry->tdir_type) { case TIFF_LONG: - *value=(uint32*)origdata; + *value=(uint32_t*)origdata; if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong(*value,count); return(TIFFReadDirEntryErrOk); case TIFF_SLONG: { - int32* m; - uint32 n; - m=(int32*)origdata; + int32_t* m; + uint32_t n; + m=(int32_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)m); + TIFFSwabLong((uint32_t*)m); err=TIFFReadDirEntryCheckRangeLongSlong(*m); if (err!=TIFFReadDirEntryErrOk) { @@ -1687,11 +1686,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr } m++; } - *value=(uint32*)origdata; + *value=(uint32_t*)origdata; return(TIFFReadDirEntryErrOk); } } - data=(uint32*)_TIFFmalloc(count*4); + data=(uint32_t*)_TIFFmalloc(count * 4); if (data==0) { _TIFFfree(origdata); @@ -1701,70 +1700,70 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr { case TIFF_BYTE: { - uint8* ma; - uint32* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + uint32_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - uint32* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + uint32_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeLongSbyte(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; case TIFF_SHORT: { - uint16* ma; - uint32* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + uint32_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(ma); - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - uint32* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + uint32_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); err=TIFFReadDirEntryCheckRangeLongSshort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - uint32* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + uint32_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1773,25 +1772,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr err=TIFFReadDirEntryCheckRangeLongLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - uint32* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + uint32_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeLongSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; @@ -1806,12 +1805,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - int32* data; + int32_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1836,13 +1835,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt { case TIFF_LONG: { - uint32* m; - uint32 n; - m=(uint32*)origdata; + uint32_t* m; + uint32_t n; + m=(uint32_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)m); + TIFFSwabLong((uint32_t*)m); err=TIFFReadDirEntryCheckRangeSlongLong(*m); if (err!=TIFFReadDirEntryErrOk) { @@ -1851,16 +1850,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt } m++; } - *value=(int32*)origdata; + *value=(int32_t*)origdata; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: - *value=(int32*)origdata; + *value=(int32_t*)origdata; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)(*value),count); + TIFFSwabArrayOfLong((uint32_t*)(*value), count); return(TIFFReadDirEntryErrOk); } - data=(int32*)_TIFFmalloc(count*4); + data=(int32_t*)_TIFFmalloc(count * 4); if (data==0) { _TIFFfree(origdata); @@ -1870,62 +1869,62 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt { case TIFF_BYTE: { - uint8* ma; - int32* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + int32_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - int32* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + int32_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } break; case TIFF_SHORT: { - uint16* ma; - int32* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + int32_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(ma); - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - int32* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + int32_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); - *mb++=(int32)(*ma++); + TIFFSwabShort((uint16_t*)ma); + *mb++=(int32_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - int32* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + int32_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1934,25 +1933,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeSlongLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - int32* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + int32_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeSlongSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } } break; @@ -1968,12 +1967,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt } static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( - TIFF* tif, TIFFDirEntry* direntry, uint64** value, uint64 maxcount) + TIFF* tif, TIFFDirEntry* direntry, uint64_t** value, uint64_t maxcount) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint64* data; + uint64_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1997,19 +1996,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( switch (direntry->tdir_type) { case TIFF_LONG8: - *value=(uint64*)origdata; + *value=(uint64_t*)origdata; if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong8(*value,count); return(TIFFReadDirEntryErrOk); case TIFF_SLONG8: { - int64* m; - uint32 n; - m=(int64*)origdata; + int64_t* m; + uint32_t n; + m=(int64_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)m); + TIFFSwabLong8((uint64_t*)m); err=TIFFReadDirEntryCheckRangeLong8Slong8(*m); if (err!=TIFFReadDirEntryErrOk) { @@ -2018,11 +2017,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( } m++; } - *value=(uint64*)origdata; + *value=(uint64_t*)origdata; return(TIFFReadDirEntryErrOk); } } - data=(uint64*)_TIFFmalloc(count*8); + data=(uint64_t*)_TIFFmalloc(count * 8); if (data==0) { _TIFFfree(origdata); @@ -2032,94 +2031,94 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( { case TIFF_BYTE: { - uint8* ma; - uint64* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + uint64_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - uint64* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + uint64_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeLong8Sbyte(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; case TIFF_SHORT: { - uint16* ma; - uint64* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + uint64_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(ma); - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - uint64* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + uint64_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); err=TIFFReadDirEntryCheckRangeLong8Sshort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - uint64* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + uint64_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - uint64* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + uint64_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeLong8Slong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; @@ -2134,17 +2133,17 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64_t** value) { - return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value, ~((uint64)0)); + return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value, ~((uint64_t)0)); } -static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - int64* data; + int64_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -2169,9 +2168,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn { case TIFF_LONG8: { - uint64* m; - uint32 n; - m=(uint64*)origdata; + uint64_t* m; + uint32_t n; + m=(uint64_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) @@ -2184,16 +2183,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn } m++; } - *value=(int64*)origdata; + *value=(int64_t*)origdata; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG8: - *value=(int64*)origdata; + *value=(int64_t*)origdata; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64*)(*value),count); + TIFFSwabArrayOfLong8((uint64_t*)(*value), count); return(TIFFReadDirEntryErrOk); } - data=(int64*)_TIFFmalloc(count*8); + data=(int64_t*)_TIFFmalloc(count * 8); if (data==0) { _TIFFfree(origdata); @@ -2203,83 +2202,83 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn { case TIFF_BYTE: { - uint8* ma; - int64* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + int64_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int64)(*ma++); + *mb++=(int64_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - int64* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + int64_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int64)(*ma++); + *mb++=(int64_t)(*ma++); } break; case TIFF_SHORT: { - uint16* ma; - int64* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + int64_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(ma); - *mb++=(int64)(*ma++); + *mb++=(int64_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - int64* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + int64_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); - *mb++=(int64)(*ma++); + TIFFSwabShort((uint16_t*)ma); + *mb++=(int64_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - int64* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + int64_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - *mb++=(int64)(*ma++); + *mb++=(int64_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - int64* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + int64_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); - *mb++=(int64)(*ma++); + TIFFSwabLong((uint32_t*)ma); + *mb++=(int64_t)(*ma++); } } break; @@ -2292,7 +2291,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEntry* direntry, float** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; float* data; switch (direntry->tdir_type) @@ -2323,7 +2322,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt { case TIFF_FLOAT: if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFSwabArrayOfLong((uint32_t*)origdata, count); TIFFCvtIEEEDoubleToNative(tif,count,(float*)origdata); *value=(float*)origdata; return(TIFFReadDirEntryErrOk); @@ -2338,10 +2337,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt { case TIFF_BYTE: { - uint8* ma; + uint8_t* ma; float* mb; - uint32 n; - ma=(uint8*)origdata; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) *mb++=(float)(*ma++); @@ -2349,10 +2348,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SBYTE: { - int8* ma; + int8_t* ma; float* mb; - uint32 n; - ma=(int8*)origdata; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) *mb++=(float)(*ma++); @@ -2360,10 +2359,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SHORT: { - uint16* ma; + uint16_t* ma; float* mb; - uint32 n; - ma=(uint16*)origdata; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2375,25 +2374,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SSHORT: { - int16* ma; + int16_t* ma; float* mb; - uint32 n; - ma=(int16*)origdata; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); *mb++=(float)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; + uint32_t* ma; float* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2405,25 +2404,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SLONG: { - int32* ma; + int32_t* ma; float* mb; - uint32 n; - ma=(int32*)origdata; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); *mb++=(float)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; + uint64_t* ma; float* mb; - uint32 n; - ma=(uint64*)origdata; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2444,27 +2443,27 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SLONG8: { - int64* ma; + int64_t* ma; float* mb; - uint32 n; - ma=(int64*)origdata; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); *mb++=(float)(*ma++); } } break; case TIFF_RATIONAL: { - uint32* ma; - uint32 maa; - uint32 mab; + uint32_t* ma; + uint32_t maa; + uint32_t mab; float* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2483,18 +2482,18 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SRATIONAL: { - uint32* ma; - int32 maa; - uint32 mab; + uint32_t* ma; + int32_t maa; + uint32_t mab; float* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - maa=*(int32*)ma; + maa=*(int32_t*)ma; ma++; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); @@ -2510,9 +2509,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt { double* ma; float* mb; - uint32 n; + uint32_t n; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64*)origdata,count); + TIFFSwabArrayOfLong8((uint64_t*)origdata, count); TIFFCvtIEEEDoubleToNative(tif,count,(double*)origdata); ma=(double*)origdata; mb=data; @@ -2537,7 +2536,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; double* data; switch (direntry->tdir_type) @@ -2568,7 +2567,7 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { case TIFF_DOUBLE: if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64*)origdata,count); + TIFFSwabArrayOfLong8((uint64_t*)origdata, count); TIFFCvtIEEEDoubleToNative(tif,count,(double*)origdata); *value=(double*)origdata; return(TIFFReadDirEntryErrOk); @@ -2583,10 +2582,10 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { case TIFF_BYTE: { - uint8* ma; + uint8_t* ma; double* mb; - uint32 n; - ma=(uint8*)origdata; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) *mb++=(double)(*ma++); @@ -2594,10 +2593,10 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SBYTE: { - int8* ma; + int8_t* ma; double* mb; - uint32 n; - ma=(int8*)origdata; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) *mb++=(double)(*ma++); @@ -2605,10 +2604,10 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SHORT: { - uint16* ma; + uint16_t* ma; double* mb; - uint32 n; - ma=(uint16*)origdata; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2620,25 +2619,25 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SSHORT: { - int16* ma; + int16_t* ma; double* mb; - uint32 n; - ma=(int16*)origdata; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); *mb++=(double)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; + uint32_t* ma; double* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2650,25 +2649,25 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SLONG: { - int32* ma; + int32_t* ma; double* mb; - uint32 n; - ma=(int32*)origdata; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); *mb++=(double)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; + uint64_t* ma; double* mb; - uint32 n; - ma=(uint64*)origdata; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2689,27 +2688,27 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SLONG8: { - int64* ma; + int64_t* ma; double* mb; - uint32 n; - ma=(int64*)origdata; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); *mb++=(double)(*ma++); } } break; case TIFF_RATIONAL: { - uint32* ma; - uint32 maa; - uint32 mab; + uint32_t* ma; + uint32_t maa; + uint32_t mab; double* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2728,18 +2727,18 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SRATIONAL: { - uint32* ma; - int32 maa; - uint32 mab; + uint32_t* ma; + int32_t maa; + uint32_t mab; double* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - maa=*(int32*)ma; + maa=*(int32_t*)ma; ma++; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); @@ -2755,9 +2754,9 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { float* ma; double* mb; - uint32 n; + uint32_t n; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFSwabArrayOfLong((uint32_t*)origdata, count); TIFFCvtIEEEFloatToNative(tif,count,(float*)origdata); ma=(float*)origdata; mb=data; @@ -2771,12 +2770,12 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint64* data; + uint64_t* data; switch (direntry->tdir_type) { case TIFF_LONG: @@ -2797,12 +2796,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntr { case TIFF_LONG8: case TIFF_IFD8: - *value=(uint64*)origdata; + *value=(uint64_t*)origdata; if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong8(*value,count); return(TIFFReadDirEntryErrOk); } - data=(uint64*)_TIFFmalloc(count*8); + data=(uint64_t*)_TIFFmalloc(count * 8); if (data==0) { _TIFFfree(origdata); @@ -2813,16 +2812,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntr case TIFF_LONG: case TIFF_IFD: { - uint32* ma; - uint64* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + uint64_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; @@ -2832,13 +2831,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntr return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value) { enum TIFFReadDirEntryErr err; - uint16* m; - uint16* na; - uint16 nb; - if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel) + uint16_t* m; + uint16_t* na; + uint16_t nb; + if (direntry->tdir_count<(uint64_t)tif->tif_dir.td_samplesperpixel) return(TIFFReadDirEntryErrCount); err=TIFFReadDirEntryShortArray(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk || m == NULL) @@ -2866,8 +2865,8 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFD enum TIFFReadDirEntryErr err; double* m; double* na; - uint16 nb; - if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel) + uint16_t nb; + if (direntry->tdir_count<(uint64_t)tif->tif_dir.td_samplesperpixel) return(TIFFReadDirEntryErrCount); err=TIFFReadDirEntryDoubleArray(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) @@ -2890,53 +2889,53 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFD } #endif -static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value) +static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8_t* value) { (void) tif; - *value=*(uint8*)(&direntry->tdir_offset); + *value=*(uint8_t*)(&direntry->tdir_offset); } -static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8* value) +static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8_t* value) { (void) tif; - *value=*(int8*)(&direntry->tdir_offset); + *value=*(int8_t*)(&direntry->tdir_offset); } -static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value) { *value = direntry->tdir_offset.toff_short; - /* *value=*(uint16*)(&direntry->tdir_offset); */ + /* *value=*(uint16_t*)(&direntry->tdir_offset); */ if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(value); } -static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16* value) +static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16_t* value) { - *value=*(int16*)(&direntry->tdir_offset); + *value=*(int16_t*)(&direntry->tdir_offset); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)value); + TIFFSwabShort((uint16_t*)value); } -static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value) +static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32_t* value) { - *value=*(uint32*)(&direntry->tdir_offset); + *value=*(uint32_t*)(&direntry->tdir_offset); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(value); } -static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32* value) +static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32_t* value) { - *value=*(int32*)(&direntry->tdir_offset); + *value=*(int32_t*)(&direntry->tdir_offset); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)value); + TIFFSwabLong((uint32_t*)value); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,value); @@ -2950,12 +2949,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirE return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64_t* value) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,value); @@ -2963,9 +2962,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDir return(err); } else - *value=*(int64*)(&direntry->tdir_offset); + *value=*(int64_t*)(&direntry->tdir_offset); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)value); + TIFFSwabLong8((uint64_t*)value); return(TIFFReadDirEntryErrOk); } @@ -2974,12 +2973,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFD UInt64Aligned_t m; assert(sizeof(double)==8); - assert(sizeof(uint64)==8); - assert(sizeof(uint32)==4); + assert(sizeof(uint64_t) == 8); + assert(sizeof(uint32_t) == 4); if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,m.i); @@ -3004,13 +3003,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF { UInt64Aligned_t m; assert(sizeof(double)==8); - assert(sizeof(uint64)==8); - assert(sizeof(int32)==4); - assert(sizeof(uint32)==4); + assert(sizeof(uint64_t) == 8); + assert(sizeof(int32_t) == 4); + assert(sizeof(uint32_t) == 4); if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,m.i); @@ -3024,10 +3023,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF /* Not completely sure what we should do when m.i[1]==0, but some */ /* sanitizers do not like division by 0.0: */ /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */ - if ((int32)m.i[0]==0 || m.i[1]==0) + if ((int32_t)m.i[0] == 0 || m.i[1] == 0) *value=0.0; else - *value=(double)((int32)m.i[0])/(double)m.i[1]; + *value= (double)((int32_t)m.i[0]) / (double)m.i[1]; return(TIFFReadDirEntryErrOk); } @@ -3036,26 +3035,26 @@ static void TIFFReadDirEntryCheckedFloat(TIFF* tif, TIFFDirEntry* direntry, floa union { float f; - uint32 i; + uint32_t i; } float_union; assert(sizeof(float)==4); - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); assert(sizeof(float_union)==4); - float_union.i=*(uint32*)(&direntry->tdir_offset); + float_union.i=*(uint32_t*)(&direntry->tdir_offset); *value=float_union.f; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)value); + TIFFSwabLong((uint32_t*)value); } static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDirEntry* direntry, double* value) { assert(sizeof(double)==8); - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); assert(sizeof(UInt64Aligned_t)==8); if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,value); @@ -3069,11 +3068,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDir *value=uint64_union.d; } if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)value); + TIFFSwabLong8((uint64_t*)value); return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3081,7 +3080,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16_t value) { if (value>0xFF) return(TIFFReadDirEntryErrRange); @@ -3089,7 +3088,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16_t value) { if ((value<0)||(value>0xFF)) return(TIFFReadDirEntryErrRange); @@ -3097,7 +3096,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32_t value) { if (value>0xFF) return(TIFFReadDirEntryErrRange); @@ -3105,7 +3104,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32_t value) { if ((value<0)||(value>0xFF)) return(TIFFReadDirEntryErrRange); @@ -3113,7 +3112,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64_t value) { if (value>0xFF) return(TIFFReadDirEntryErrRange); @@ -3121,7 +3120,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64_t value) { if ((value<0)||(value>0xFF)) return(TIFFReadDirEntryErrRange); @@ -3129,7 +3128,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8_t value) { if (value>0x7F) return(TIFFReadDirEntryErrRange); @@ -3137,7 +3136,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16_t value) { if (value>0x7F) return(TIFFReadDirEntryErrRange); @@ -3145,7 +3144,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16_t value) { if ((value<-0x80)||(value>0x7F)) return(TIFFReadDirEntryErrRange); @@ -3153,7 +3152,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32_t value) { if (value>0x7F) return(TIFFReadDirEntryErrRange); @@ -3161,7 +3160,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32_t value) { if ((value<-0x80)||(value>0x7F)) return(TIFFReadDirEntryErrRange); @@ -3169,7 +3168,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64_t value) { if (value>0x7F) return(TIFFReadDirEntryErrRange); @@ -3177,7 +3176,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64_t value) { if ((value<-0x80)||(value>0x7F)) return(TIFFReadDirEntryErrRange); @@ -3185,7 +3184,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3193,7 +3192,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3201,7 +3200,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32_t value) { if (value>0xFFFF) return(TIFFReadDirEntryErrRange); @@ -3209,7 +3208,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32_t value) { if ((value<0)||(value>0xFFFF)) return(TIFFReadDirEntryErrRange); @@ -3217,7 +3216,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64_t value) { if (value>0xFFFF) return(TIFFReadDirEntryErrRange); @@ -3225,7 +3224,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64_t value) { if ((value<0)||(value>0xFFFF)) return(TIFFReadDirEntryErrRange); @@ -3233,7 +3232,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16_t value) { if (value>0x7FFF) return(TIFFReadDirEntryErrRange); @@ -3241,7 +3240,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 val return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32_t value) { if (value>0x7FFF) return(TIFFReadDirEntryErrRange); @@ -3249,7 +3248,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32_t value) { if ((value<-0x8000)||(value>0x7FFF)) return(TIFFReadDirEntryErrRange); @@ -3257,7 +3256,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64_t value) { if (value>0x7FFF) return(TIFFReadDirEntryErrRange); @@ -3265,7 +3264,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 val return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64_t value) { if ((value<-0x8000)||(value>0x7FFF)) return(TIFFReadDirEntryErrRange); @@ -3273,7 +3272,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 val return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3281,7 +3280,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3289,7 +3288,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3298,25 +3297,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongLong8(uint64 value) +TIFFReadDirEntryCheckRangeLongLong8(uint64_t value) { - if (value > TIFF_UINT32_MAX) + if (value > UINT32_MAX) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongSlong8(int64 value) +TIFFReadDirEntryCheckRangeLongSlong8(int64_t value) { - if ((value < 0) || (value > (int64) TIFF_UINT32_MAX)) + if ((value < 0) || (value > (int64_t) UINT32_MAX)) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongLong(uint32 value) +TIFFReadDirEntryCheckRangeSlongLong(uint32_t value) { if (value > 0x7FFFFFFFUL) return(TIFFReadDirEntryErrRange); @@ -3326,7 +3325,7 @@ TIFFReadDirEntryCheckRangeSlongLong(uint32 value) /* Check that the 8-byte unsigned value can fit in a 4-byte unsigned range */ static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongLong8(uint64 value) +TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value) { if (value > 0x7FFFFFFF) return(TIFFReadDirEntryErrRange); @@ -3336,16 +3335,16 @@ TIFFReadDirEntryCheckRangeSlongLong8(uint64 value) /* Check that the 8-byte signed value can fit in a 4-byte signed range */ static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongSlong8(int64 value) +TIFFReadDirEntryCheckRangeSlongSlong8(int64_t value) { - if ((value < 0-((int64) 0x7FFFFFFF+1)) || (value > 0x7FFFFFFF)) + if ((value < 0-((int64_t) 0x7FFFFFFF + 1)) || (value > 0x7FFFFFFF)) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value) +TIFFReadDirEntryCheckRangeLong8Sbyte(int8_t value) { if (value < 0) return(TIFFReadDirEntryErrRange); @@ -3354,7 +3353,7 @@ TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Sshort(int16 value) +TIFFReadDirEntryCheckRangeLong8Sshort(int16_t value) { if (value < 0) return(TIFFReadDirEntryErrRange); @@ -3363,7 +3362,7 @@ TIFFReadDirEntryCheckRangeLong8Sshort(int16 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Slong(int32 value) +TIFFReadDirEntryCheckRangeLong8Slong(int32_t value) { if (value < 0) return(TIFFReadDirEntryErrRange); @@ -3372,7 +3371,7 @@ TIFFReadDirEntryCheckRangeLong8Slong(int32 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Slong8(int64 value) +TIFFReadDirEntryCheckRangeLong8Slong8(int64_t value) { if (value < 0) return(TIFFReadDirEntryErrRange); @@ -3381,16 +3380,16 @@ TIFFReadDirEntryCheckRangeLong8Slong8(int64 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value) +TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value) { - if (value > TIFF_INT64_MAX) + if (value > INT64_MAX) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest) +TIFFReadDirEntryData(TIFF* tif, uint64_t offset, tmsize_t size, void* dest) { assert(size>0); if (!isMapped(tif)) { @@ -3401,13 +3400,13 @@ TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest) } else { size_t ma,mb; ma=(size_t)offset; - if( (uint64)ma!=offset || + if((uint64_t)ma != offset || ma > (~(size_t)0) - (size_t)size ) { return TIFFReadDirEntryErrIo; } mb=ma+size; - if (mb > (uint64)tif->tif_size) + if (mb > (uint64_t)tif->tif_size) return(TIFFReadDirEntryErrIo); _TIFFmemcpy(dest,tif->tif_base+ma,size); } @@ -3506,7 +3505,7 @@ static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, c * type. 0 is returned if photometric type isn't supported or no default value * is defined by the specification. */ -static int _TIFFGetMaxColorChannels( uint16 photometric ) +static int _TIFFGetMaxColorChannels(uint16_t photometric ) { switch (photometric) { case PHOTOMETRIC_PALETTE: @@ -3545,9 +3544,9 @@ static int ByteCountLooksBad(TIFF* tif) * until the whole image will be written and directory * dumped out. */ - uint64 bytecount = TIFFGetStrileByteCount(tif, 0); - uint64 offset = TIFFGetStrileOffset(tif, 0); - uint64 filesize; + uint64_t bytecount = TIFFGetStrileByteCount(tif, 0); + uint64_t offset = TIFFGetStrileOffset(tif, 0); + uint64_t filesize; if( offset == 0 ) return 0; @@ -3560,9 +3559,9 @@ static int ByteCountLooksBad(TIFF* tif) return 1; if( tif->tif_mode == O_RDONLY ) { - uint64 scanlinesize = TIFFScanlineSize64(tif); + uint64_t scanlinesize = TIFFScanlineSize64(tif); if( tif->tif_dir.td_imagelength > 0 && - scanlinesize > TIFF_UINT64_MAX / tif->tif_dir.td_imagelength ) + scanlinesize > UINT64_MAX / tif->tif_dir.td_imagelength ) { return 1; } @@ -3582,11 +3581,11 @@ TIFFReadDirectory(TIFF* tif) { static const char module[] = "TIFFReadDirectory"; TIFFDirEntry* dir; - uint16 dircount; + uint16_t dircount; TIFFDirEntry* dp; - uint16 di; + uint16_t di; const TIFFField* fip; - uint32 fii=FAILED_FII; + uint32_t fii=FAILED_FII; toff_t nextdiroff; int bitspersample_read = FALSE; int color_channels; @@ -3601,7 +3600,7 @@ TIFFReadDirectory(TIFF* tif) if (!dircount) { TIFFErrorExt(tif->tif_clientdata,module, - "Failed to read directory at offset " TIFF_UINT64_FORMAT,nextdiroff); + "Failed to read directory at offset %" PRIu64, nextdiroff); return 0; } TIFFReadDirectoryCheckOrder(tif,dir,dircount); @@ -3612,11 +3611,11 @@ TIFFReadDirectory(TIFF* tif) */ { TIFFDirEntry* ma; - uint16 mb; + uint16_t mb; for (ma=dir, mb=0; mb<dircount; ma++, mb++) { TIFFDirEntry* na; - uint16 nb; + uint16_t nb; for (na=ma+1, nb=mb+1; nb<dircount; na++, nb++) { if (ma->tdir_tag == na->tdir_tag) { @@ -3673,7 +3672,7 @@ TIFFReadDirectory(TIFF* tif) * this, we accept the tag if one value is supplied with either * count. */ - uint16 value; + uint16_t value; enum TIFFReadDirEntryErr err; err=TIFFReadDirEntryShort(tif,dp,&value); if (err==TIFFReadDirEntryErrCount) @@ -3703,7 +3702,7 @@ TIFFReadDirectory(TIFF* tif) if (fii == FAILED_FII) { TIFFWarningExt(tif->tif_clientdata, module, - "Unknown field with tag %d (0x%x) encountered", + "Unknown field with tag %"PRIu16" (0x%"PRIx16") encountered", dp->tdir_tag,dp->tdir_tag); /* the following knowingly leaks the anonymous field structure */ @@ -3714,7 +3713,7 @@ TIFFReadDirectory(TIFF* tif) 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Registering anonymous field with tag %d (0x%x) failed", + "Registering anonymous field with tag %"PRIu16" (0x%"PRIx16") failed", dp->tdir_tag, dp->tdir_tag); dp->tdir_ignore = TRUE; @@ -3863,7 +3862,7 @@ TIFFReadDirectory(TIFF* tif) * too. */ { - uint16 value; + uint16_t value; enum TIFFReadDirEntryErr err; err=TIFFReadDirEntryShort(tif,dp,&value); if (err==TIFFReadDirEntryErrCount) @@ -3886,9 +3885,9 @@ TIFFReadDirectory(TIFF* tif) double *data = NULL; enum TIFFReadDirEntryErr err; - uint32 saved_flags; + uint32_t saved_flags; int m; - if (dp->tdir_count != (uint64)tif->tif_dir.td_samplesperpixel) + if (dp->tdir_count != (uint64_t)tif->tif_dir.td_samplesperpixel) err = TIFFReadDirEntryErrCount; else err = TIFFReadDirEntryDoubleArray(tif, dp, &data); @@ -3961,10 +3960,10 @@ TIFFReadDirectory(TIFF* tif) case TIFFTAG_TRANSFERFUNCTION: { enum TIFFReadDirEntryErr err; - uint32 countpersample; - uint32 countrequired; - uint32 incrementpersample; - uint16* value=NULL; + uint32_t countpersample; + uint32_t countrequired; + uint32_t incrementpersample; + uint16_t* value=NULL; /* It would be dangerous to instantiate those tag values */ /* since if td_bitspersample has not yet been read (due to */ /* unordered tags), it could be read afterwards with a */ @@ -3985,13 +3984,13 @@ TIFFReadDirectory(TIFF* tif) { fip = TIFFFieldWithTag(tif,dp->tdir_tag); TIFFWarningExt(tif->tif_clientdata,module, - "Ignoring %s because BitsPerSample=%d>24", + "Ignoring %s because BitsPerSample=%"PRIu16">24", fip ? fip->field_name : "unknown tagname", tif->tif_dir.td_bitspersample); continue; } countpersample=(1U<<tif->tif_dir.td_bitspersample); - if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample)) + if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64_t)countpersample)) { countrequired=countpersample; incrementpersample=0; @@ -4001,7 +4000,7 @@ TIFFReadDirectory(TIFF* tif) countrequired=3*countpersample; incrementpersample=countpersample; } - if (dp->tdir_count!=(uint64)countrequired) + if (dp->tdir_count!=(uint64_t)countrequired) err=TIFFReadDirEntryErrCount; else err=TIFFReadDirEntryShortArray(tif,dp,&value); @@ -4020,8 +4019,8 @@ TIFFReadDirectory(TIFF* tif) /* BEGIN REV 4.0 COMPATIBILITY */ case TIFFTAG_OSUBFILETYPE: { - uint16 valueo; - uint32 value; + uint16_t valueo; + uint32_t value; if (TIFFReadDirEntryShort(tif,dp,&valueo)==TIFFReadDirEntryErrOk) { switch (valueo) @@ -4154,26 +4153,27 @@ TIFFReadDirectory(TIFF* tif) */ color_channels = _TIFFGetMaxColorChannels(tif->tif_dir.td_photometric); if (color_channels && tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples > color_channels) { - uint16 old_extrasamples; - uint16 *new_sampleinfo; + uint16_t old_extrasamples; + uint16_t *new_sampleinfo; TIFFWarningExt(tif->tif_clientdata,module, "Sum of Photometric type-related " "color channels and ExtraSamples doesn't match SamplesPerPixel. " "Defining non-color channels as ExtraSamples."); old_extrasamples = tif->tif_dir.td_extrasamples; - tif->tif_dir.td_extrasamples = (uint16) (tif->tif_dir.td_samplesperpixel - color_channels); + tif->tif_dir.td_extrasamples = (uint16_t) (tif->tif_dir.td_samplesperpixel - color_channels); // sampleinfo should contain information relative to these new extra samples - new_sampleinfo = (uint16*) _TIFFcalloc(tif->tif_dir.td_extrasamples, sizeof(uint16)); + new_sampleinfo = (uint16_t*) _TIFFcalloc(tif->tif_dir.td_extrasamples, sizeof(uint16_t)); if (!new_sampleinfo) { TIFFErrorExt(tif->tif_clientdata, module, "Failed to allocate memory for " - "temporary new sampleinfo array (%d 16 bit elements)", + "temporary new sampleinfo array " + "(%"PRIu16" 16 bit elements)", tif->tif_dir.td_extrasamples); goto bad; } - memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo, old_extrasamples * sizeof(uint16)); + memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo, old_extrasamples * sizeof(uint16_t)); _TIFFsetShortArray(&tif->tif_dir.td_sampleinfo, new_sampleinfo, tif->tif_dir.td_extrasamples); _TIFFfree(new_sampleinfo); } @@ -4211,7 +4211,7 @@ TIFFReadDirectory(TIFF* tif) if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && tif->tif_dir.td_nstrips > 1) || (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE && - tif->tif_dir.td_nstrips != (uint32)tif->tif_dir.td_samplesperpixel)) { + tif->tif_dir.td_nstrips != (uint32_t)tif->tif_dir.td_samplesperpixel)) { MissingRequired(tif, "StripByteCounts"); goto bad; } @@ -4268,7 +4268,7 @@ TIFFReadDirectory(TIFF* tif) if (tif->tif_dir.td_bitspersample>=16) tif->tif_dir.td_maxsamplevalue=0xFFFF; else - tif->tif_dir.td_maxsamplevalue = (uint16)((1L<<tif->tif_dir.td_bitspersample)-1); + tif->tif_dir.td_maxsamplevalue = (uint16_t)((1L << tif->tif_dir.td_bitspersample) - 1); } #ifdef STRIPBYTECOUNTSORTED_UNUSED @@ -4278,7 +4278,7 @@ TIFFReadDirectory(TIFF* tif) * function in tif_write.c. */ if (!(tif->tif_flags&TIFF_DEFERSTRILELOAD) && tif->tif_dir.td_nstrips > 1) { - uint32 strip; + uint32_t strip; tif->tif_dir.td_stripbytecountsorted = 1; for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { @@ -4333,10 +4333,10 @@ TIFFReadDirectory(TIFF* tif) /* * Reinitialize i/o since we are starting on a new directory. */ - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (uint32) -1; - tif->tif_col = (uint32) -1; - tif->tif_curtile = (uint32) -1; + tif->tif_row = (uint32_t) -1; + tif->tif_curstrip = (uint32_t) -1; + tif->tif_col = (uint32_t) -1; + tif->tif_curtile = (uint32_t) -1; tif->tif_tilesize = (tmsize_t) -1; tif->tif_scanlinesize = TIFFScanlineSize(tif); @@ -4368,11 +4368,11 @@ bad: } static void -TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) +TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount) { static const char module[] = "TIFFReadDirectoryCheckOrder"; - uint16 m; - uint16 n; + uint16_t m; + uint16_t n; TIFFDirEntry* o; m=0; for (n=0, o=dir; n<dircount; n++, o++) @@ -4388,10 +4388,10 @@ TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) } static TIFFDirEntry* -TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 tagid) +TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount, uint16_t tagid) { TIFFDirEntry* m; - uint16 n; + uint16_t n; (void) tif; for (m=dir, n=0; n<dircount; m++, n++) { @@ -4402,11 +4402,11 @@ TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 } static void -TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii) +TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16_t tagid, uint32_t* fii) { - int32 ma,mb,mc; + int32_t ma,mb,mc; ma=-1; - mc=(int32)tif->tif_nfields; + mc=(int32_t)tif->tif_nfields; while (1) { if (ma+1==mc) @@ -4415,9 +4415,9 @@ TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii) return; } mb=(ma+mc)/2; - if (tif->tif_fields[mb]->field_tag==(uint32)tagid) + if (tif->tif_fields[mb]->field_tag==(uint32_t)tagid) break; - if (tif->tif_fields[mb]->field_tag<(uint32)tagid) + if (tif->tif_fields[mb]->field_tag<(uint32_t)tagid) ma=mb; else mc=mb; @@ -4426,7 +4426,7 @@ TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii) { if (mb==0) break; - if (tif->tif_fields[mb-1]->field_tag!=(uint32)tagid) + if (tif->tif_fields[mb-1]->field_tag!=(uint32_t)tagid) break; mb--; } @@ -4443,18 +4443,18 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, { static const char module[] = "TIFFReadCustomDirectory"; TIFFDirEntry* dir; - uint16 dircount; + uint16_t dircount; TIFFDirEntry* dp; - uint16 di; + uint16_t di; const TIFFField* fip; - uint32 fii; + uint32_t fii; (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */ _TIFFSetupFields(tif, infoarray); dircount=TIFFFetchDirectory(tif,diroff,&dir,NULL); if (!dircount) { TIFFErrorExt(tif->tif_clientdata,module, - "Failed to read custom directory at offset " TIFF_UINT64_FORMAT,diroff); + "Failed to read custom directory at offset %" PRIu64,diroff); return 0; } TIFFFreeDirectory(tif); @@ -4466,14 +4466,14 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, if (fii == FAILED_FII) { TIFFWarningExt(tif->tif_clientdata, module, - "Unknown field with tag %d (0x%x) encountered", + "Unknown field with tag %"PRIu16" (0x%"PRIx16") encountered", dp->tdir_tag, dp->tdir_tag); if (!_TIFFMergeFields(tif, _TIFFCreateAnonField(tif, dp->tdir_tag, (TIFFDataType) dp->tdir_type), 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Registering anonymous field with tag %d (0x%x) failed", + "Registering anonymous field with tag %"PRIu16" (0x%"PRIx16") failed", dp->tdir_tag, dp->tdir_tag); dp->tdir_ignore = TRUE; } else { @@ -4493,7 +4493,7 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, { fii++; if ((fii==tif->tif_nfields)|| - (tif->tif_fields[fii]->field_tag!=(uint32)dp->tdir_tag)) + (tif->tif_fields[fii]->field_tag!=(uint32_t)dp->tdir_tag)) { fii=0xFFFF; break; @@ -4503,7 +4503,7 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, if (fii==0xFFFF) { TIFFWarningExt(tif->tif_clientdata, module, - "Wrong data type %d for \"%s\"; tag ignored", + "Wrong data type %"PRIu16" for \"%s\"; tag ignored", dp->tdir_type,fip->field_name); dp->tdir_ignore = TRUE; } @@ -4513,11 +4513,11 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, if ((fip->field_readcount!=TIFF_VARIABLE)&& (fip->field_readcount!=TIFF_VARIABLE2)) { - uint32 expected; + uint32_t expected; if (fip->field_readcount==TIFF_SPP) - expected=(uint32)tif->tif_dir.td_samplesperpixel; + expected=(uint32_t)tif->tif_dir.td_samplesperpixel; else - expected=(uint32)fip->field_readcount; + expected=(uint32_t)fip->field_readcount; if (!CheckDirCount(tif,dp,expected)) dp->tdir_ignore = TRUE; } @@ -4565,13 +4565,13 @@ TIFFReadGPSDirectory(TIFF* tif, toff_t diroff) } static int -EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) +EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount) { static const char module[] = "EstimateStripByteCounts"; TIFFDirEntry *dp; TIFFDirectory *td = &tif->tif_dir; - uint32 strip; + uint32_t strip; /* Do not try to load stripbytecount as we will compute it */ if( !_TIFFFillStrilesInternal( tif, 0 ) ) @@ -4579,16 +4579,16 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) if (td->td_stripbytecount_p) _TIFFfree(td->td_stripbytecount_p); - td->td_stripbytecount_p = (uint64*) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + td->td_stripbytecount_p = (uint64_t*) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64_t), "for \"StripByteCounts\" array"); if( td->td_stripbytecount_p == NULL ) return -1; if (td->td_compression != COMPRESSION_NONE) { - uint64 space; - uint64 filesize; - uint16 n; + uint64_t space; + uint64_t filesize; + uint16_t n; filesize = TIFFGetFileSize(tif); if (!(tif->tif_flags&TIFF_BIGTIFF)) space=sizeof(TIFFHeaderClassic)+2+dircount*12+4; @@ -4597,18 +4597,18 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) /* calculate amount of space used by indirect values */ for (dp = dir, n = dircount; n > 0; n--, dp++) { - uint32 typewidth; - uint64 datasize; + uint32_t typewidth; + uint64_t datasize; typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type); if (typewidth == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Cannot determine size of unknown tag type %d", + "Cannot determine size of unknown tag type %"PRIu16, dp->tdir_type); return -1; } - if( dp->tdir_count > TIFF_UINT64_MAX / typewidth ) + if( dp->tdir_count > UINT64_MAX / typewidth ) return -1; - datasize=(uint64)typewidth*dp->tdir_count; + datasize= (uint64_t)typewidth * dp->tdir_count; if (!(tif->tif_flags&TIFF_BIGTIFF)) { if (datasize<=4) @@ -4619,7 +4619,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) if (datasize<=8) datasize=0; } - if( space > TIFF_UINT64_MAX - datasize ) + if( space > UINT64_MAX - datasize ) return -1; space+=datasize; } @@ -4640,7 +4640,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) * of data in the strip and trim this number back accordingly. */ strip--; - if (td->td_stripoffset_p[strip] > TIFF_UINT64_MAX - td->td_stripbytecount_p[strip]) + if (td->td_stripoffset_p[strip] > UINT64_MAX - td->td_stripbytecount_p[strip]) return -1; if (td->td_stripoffset_p[strip]+td->td_stripbytecount_p[strip] > filesize) { if( td->td_stripoffset_p[strip] >= filesize ) { @@ -4651,16 +4651,16 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) } } } else if (isTiled(tif)) { - uint64 bytespertile = TIFFTileSize64(tif); + uint64_t bytespertile = TIFFTileSize64(tif); for (strip = 0; strip < td->td_nstrips; strip++) td->td_stripbytecount_p[strip] = bytespertile; } else { - uint64 rowbytes = TIFFScanlineSize64(tif); - uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; + uint64_t rowbytes = TIFFScanlineSize64(tif); + uint32_t rowsperstrip = td->td_imagelength / td->td_stripsperimage; for (strip = 0; strip < td->td_nstrips; strip++) { - if( rowbytes > 0 && rowsperstrip > TIFF_UINT64_MAX / rowbytes ) + if( rowbytes > 0 && rowsperstrip > UINT64_MAX / rowbytes ) return -1; td->td_stripbytecount_p[strip] = rowbytes * rowsperstrip; } @@ -4688,9 +4688,9 @@ MissingRequired(TIFF* tif, const char* tagname) * seen directories and check every IFD offset against that list. */ static int -TIFFCheckDirOffset(TIFF* tif, uint64 diroff) +TIFFCheckDirOffset(TIFF* tif, uint64_t diroff) { - uint16 n; + uint16_t n; if (diroff == 0) /* no more directories */ return 0; @@ -4708,14 +4708,14 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff) tif->tif_dirnumber++; if (tif->tif_dirlist == NULL || tif->tif_dirnumber > tif->tif_dirlistsize) { - uint64* new_dirlist; + uint64_t* new_dirlist; /* * XXX: Reduce memory allocation granularity of the dirlist * array. */ - new_dirlist = (uint64*)_TIFFCheckRealloc(tif, tif->tif_dirlist, - tif->tif_dirnumber, 2 * sizeof(uint64), "for IFD list"); + new_dirlist = (uint64_t*)_TIFFCheckRealloc(tif, tif->tif_dirlist, + tif->tif_dirnumber, 2 * sizeof(uint64_t), "for IFD list"); if (!new_dirlist) return 0; if( tif->tif_dirnumber >= 32768 ) @@ -4735,19 +4735,19 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff) * caller is expected to skip/ignore the tag if there is a mismatch. */ static int -CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) +CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32_t count) { - if ((uint64)count > dir->tdir_count) { + if ((uint64_t)count > dir->tdir_count) { const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (" TIFF_UINT64_FORMAT ", expecting %u); tag ignored", + "incorrect count for field \"%s\" (%" PRIu64 ", expecting %"PRIu32"); tag ignored", fip ? fip->field_name : "unknown tagname", dir->tdir_count, count); return (0); - } else if ((uint64)count < dir->tdir_count) { + } else if ((uint64_t)count < dir->tdir_count) { const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (" TIFF_UINT64_FORMAT ", expecting %u); tag trimmed", + "incorrect count for field \"%s\" (%" PRIu64 ", expecting %"PRIu32"); tag trimmed", fip ? fip->field_name : "unknown tagname", dir->tdir_count, count); dir->tdir_count = count; @@ -4761,19 +4761,19 @@ CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) * nextdiroff variable has been specified, read it too. Function returns a * number of fields in the directory or 0 if failed. */ -static uint16 -TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, - uint64 *nextdiroff) +static uint16_t +TIFFFetchDirectory(TIFF* tif, uint64_t diroff, TIFFDirEntry** pdir, + uint64_t *nextdiroff) { static const char module[] = "TIFFFetchDirectory"; void* origdir; - uint16 dircount16; - uint32 dirsize; + uint16_t dircount16; + uint32_t dirsize; TIFFDirEntry* dir; - uint8* ma; + uint8_t* ma; TIFFDirEntry* mb; - uint16 n; + uint16_t n; assert(pdir); @@ -4789,7 +4789,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, } if (!(tif->tif_flags&TIFF_BIGTIFF)) { - if (!ReadOK(tif, &dircount16, sizeof (uint16))) { + if (!ReadOK(tif, &dircount16, sizeof (uint16_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Can not read TIFF directory count", tif->tif_name); @@ -4805,8 +4805,8 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, } dirsize = 12; } else { - uint64 dircount64; - if (!ReadOK(tif, &dircount64, sizeof (uint64))) { + uint64_t dircount64; + if (!ReadOK(tif, &dircount64, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Can not read TIFF directory count", tif->tif_name); @@ -4820,7 +4820,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, "Sanity check on directory count failed, this is probably not a valid IFD offset"); return 0; } - dircount16 = (uint16)dircount64; + dircount16 = (uint16_t)dircount64; dirsize = 20; } origdir = _TIFFCheckMalloc(tif, dircount16, @@ -4842,14 +4842,14 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, { if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 nextdiroff32; - if (!ReadOK(tif, &nextdiroff32, sizeof(uint32))) + uint32_t nextdiroff32; + if (!ReadOK(tif, &nextdiroff32, sizeof(uint32_t))) nextdiroff32 = 0; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&nextdiroff32); *nextdiroff=nextdiroff32; } else { - if (!ReadOK(tif, nextdiroff, sizeof(uint64))) + if (!ReadOK(tif, nextdiroff, sizeof(uint64_t))) *nextdiroff = 0; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(nextdiroff); @@ -4858,7 +4858,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, } else { tmsize_t m; tmsize_t off; - if (tif->tif_diroff > (uint64)TIFF_INT64_MAX) + if (tif->tif_diroff > (uint64_t)INT64_MAX) { TIFFErrorExt(tif->tif_clientdata,module,"Can not read TIFF directory count"); return(0); @@ -4870,22 +4870,22 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, * otherwise a very high offset may cause an OOB read and * crash the client. Make two comparisons instead of * - * off + sizeof(uint16) > tif->tif_size + * off + sizeof(uint16_t) > tif->tif_size * * to avoid overflow. */ if (!(tif->tif_flags&TIFF_BIGTIFF)) { - m=off+sizeof(uint16); - if ((m<off)||(m<(tmsize_t)sizeof(uint16))||(m>tif->tif_size)) { + m=off+sizeof(uint16_t); + if ((m<off) || (m<(tmsize_t)sizeof(uint16_t)) || (m > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata, module, "Can not read TIFF directory count"); return 0; } else { _TIFFmemcpy(&dircount16, tif->tif_base + off, - sizeof(uint16)); + sizeof(uint16_t)); } - off += sizeof (uint16); + off += sizeof (uint16_t); if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount16); if (dircount16>4096) @@ -4898,17 +4898,17 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, } else { - uint64 dircount64; - m=off+sizeof(uint64); - if ((m<off)||(m<(tmsize_t)sizeof(uint64))||(m>tif->tif_size)) { + uint64_t dircount64; + m=off+sizeof(uint64_t); + if ((m<off) || (m<(tmsize_t)sizeof(uint64_t)) || (m > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata, module, "Can not read TIFF directory count"); return 0; } else { _TIFFmemcpy(&dircount64, tif->tif_base + off, - sizeof(uint64)); + sizeof(uint64_t)); } - off += sizeof (uint64); + off += sizeof (uint64_t); if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&dircount64); if (dircount64>4096) @@ -4917,7 +4917,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, "Sanity check on directory count failed, this is probably not a valid IFD offset"); return 0; } - dircount16 = (uint16)dircount64; + dircount16 = (uint16_t)dircount64; dirsize = 20; } if (dircount16 == 0 ) @@ -4945,25 +4945,25 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, off += dircount16 * dirsize; if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 nextdiroff32; - m=off+sizeof(uint32); - if ((m<off)||(m<(tmsize_t)sizeof(uint32))||(m>tif->tif_size)) + uint32_t nextdiroff32; + m=off+sizeof(uint32_t); + if ((m<off) || (m<(tmsize_t)sizeof(uint32_t)) || (m > tif->tif_size)) nextdiroff32 = 0; else _TIFFmemcpy(&nextdiroff32, tif->tif_base + off, - sizeof (uint32)); + sizeof (uint32_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&nextdiroff32); *nextdiroff = nextdiroff32; } else { - m=off+sizeof(uint64); - if ((m<off)||(m<(tmsize_t)sizeof(uint64))||(m>tif->tif_size)) + m=off+sizeof(uint64_t); + if ((m<off) || (m<(tmsize_t)sizeof(uint64_t)) || (m > tif->tif_size)) *nextdiroff = 0; else _TIFFmemcpy(nextdiroff, tif->tif_base + off, - sizeof (uint64)); + sizeof (uint64_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(nextdiroff); } @@ -4977,37 +4977,37 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, _TIFFfree(origdir); return 0; } - ma=(uint8*)origdir; + ma=(uint8_t*)origdir; mb=dir; for (n=0; n<dircount16; n++) { mb->tdir_ignore = FALSE; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); - mb->tdir_tag=*(uint16*)ma; - ma+=sizeof(uint16); + TIFFSwabShort((uint16_t*)ma); + mb->tdir_tag=*(uint16_t*)ma; + ma+=sizeof(uint16_t); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); - mb->tdir_type=*(uint16*)ma; - ma+=sizeof(uint16); + TIFFSwabShort((uint16_t*)ma); + mb->tdir_type=*(uint16_t*)ma; + ma+=sizeof(uint16_t); if (!(tif->tif_flags&TIFF_BIGTIFF)) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); - mb->tdir_count=(uint64)(*(uint32*)ma); - ma+=sizeof(uint32); + TIFFSwabLong((uint32_t*)ma); + mb->tdir_count=(uint64_t)(*(uint32_t*)ma); + ma+=sizeof(uint32_t); mb->tdir_offset.toff_long8=0; - *(uint32*)(&mb->tdir_offset)=*(uint32*)ma; - ma+=sizeof(uint32); + *(uint32_t*)(&mb->tdir_offset)=*(uint32_t*)ma; + ma+=sizeof(uint32_t); } else { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); mb->tdir_count=TIFFReadUInt64(ma); - ma+=sizeof(uint64); + ma+=sizeof(uint64_t); mb->tdir_offset.toff_long8=TIFFReadUInt64(ma); - ma+=sizeof(uint64); + ma+=sizeof(uint64_t); } mb++; } @@ -5024,13 +5024,13 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) { static const char module[] = "TIFFFetchNormalTag"; enum TIFFReadDirEntryErr err; - uint32 fii; + uint32_t fii; const TIFFField* fip = NULL; TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); if( fii == FAILED_FII ) { TIFFErrorExt(tif->tif_clientdata, "TIFFFetchNormalTag", - "No definition found for tag %d", + "No definition found for tag %"PRIu16, dp->tdir_tag); return 0; } @@ -5045,17 +5045,17 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_ASCII: { - uint8* data; + uint8_t* data; assert(fip->field_passcount==0); err=TIFFReadDirEntryByteArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { - uint32 mb = 0; + uint32_t mb = 0; int n; if (data != NULL) { - uint8* ma = data; - while (mb<(uint32)dp->tdir_count) + uint8_t* ma = data; + while (mb<(uint32_t)dp->tdir_count) { if (*ma==0) break; @@ -5063,24 +5063,24 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) mb++; } } - if (mb+1<(uint32)dp->tdir_count) + if (mb+1<(uint32_t)dp->tdir_count) TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" contains null byte in value; value incorrectly truncated during reading due to implementation limitations",fip->field_name); - else if (mb+1>(uint32)dp->tdir_count) + else if (mb+1>(uint32_t)dp->tdir_count) { - uint8* o; + uint8_t* o; TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte",fip->field_name); - if ((uint32)dp->tdir_count+1!=dp->tdir_count+1) + if ((uint32_t)dp->tdir_count + 1 != dp->tdir_count + 1) o=NULL; else - o=_TIFFmalloc((uint32)dp->tdir_count+1); + o=_TIFFmalloc((uint32_t)dp->tdir_count + 1); if (o==NULL) { if (data!=NULL) _TIFFfree(data); return(0); } - _TIFFmemcpy(o,data,(uint32)dp->tdir_count); - o[(uint32)dp->tdir_count]=0; + _TIFFmemcpy(o,data,(uint32_t)dp->tdir_count); + o[(uint32_t)dp->tdir_count]=0; if (data!=0) _TIFFfree(data); data=o; @@ -5095,7 +5095,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT8: { - uint8 data=0; + uint8_t data=0; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryByte(tif,dp,&data); @@ -5108,7 +5108,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT16: { - uint16 data; + uint16_t data; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryShort(tif,dp,&data); @@ -5121,7 +5121,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT32: { - uint32 data; + uint32_t data; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryLong(tif,dp,&data); @@ -5134,7 +5134,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT64: { - uint64 data; + uint64_t data; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryLong8(tif,dp,&data); @@ -5173,7 +5173,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_IFD8: { - uint64 data; + uint64_t data; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryIfd8(tif,dp,&data); @@ -5186,13 +5186,13 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT16_PAIR: { - uint16* data; + uint16_t* data; assert(fip->field_readcount==2); assert(fip->field_passcount==0); if (dp->tdir_count!=2) { TIFFWarningExt(tif->tif_clientdata,module, - "incorrect count for field \"%s\", expected 2, got %d", - fip->field_name,(int)dp->tdir_count); + "incorrect count for field \"%s\", expected 2, got %"PRIu64, + fip->field_name, dp->tdir_count); return(0); } err=TIFFReadDirEntryShortArray(tif,dp,&data); @@ -5209,13 +5209,13 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C0_UINT8: { - uint8* data; + uint8_t* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) { + if (dp->tdir_count!=(uint64_t)fip->field_readcount) { TIFFWarningExt(tif->tif_clientdata,module, - "incorrect count for field \"%s\", expected %d, got %d", - fip->field_name,(int) fip->field_readcount, (int)dp->tdir_count); + "incorrect count for field \"%s\", expected %d, got %"PRIu64, + fip->field_name,(int) fip->field_readcount, dp->tdir_count); return 0; } else @@ -5235,10 +5235,10 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C0_UINT16: { - uint16* data; + uint16_t* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) + if (dp->tdir_count!=(uint64_t)fip->field_readcount) /* corrupt file */; else { @@ -5257,10 +5257,10 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C0_UINT32: { - uint32* data; + uint32_t* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) + if (dp->tdir_count!=(uint64_t)fip->field_readcount) /* corrupt file */; else { @@ -5282,7 +5282,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) float* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) + if (dp->tdir_count!=(uint64_t)fip->field_readcount) /* corrupt file */; else { @@ -5305,7 +5305,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) double* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) + if (dp->tdir_count!=(uint64_t)fip->field_readcount) /* corrupt file */; else { @@ -5324,7 +5324,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_ASCII: { - uint8* data; + uint8_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5340,7 +5340,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte. Forcing it to be null",fip->field_name); data[dp->tdir_count-1] = '\0'; } - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5351,7 +5351,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_UINT8: { - uint8* data; + uint8_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5362,7 +5362,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5373,7 +5373,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_UINT16: { - uint16* data; + uint16_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5384,7 +5384,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5395,7 +5395,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_UINT32: { - uint32* data; + uint32_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5406,7 +5406,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5417,7 +5417,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_UINT64: { - uint64* data; + uint64_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5428,7 +5428,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5450,7 +5450,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5472,7 +5472,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5483,7 +5483,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_IFD8: { - uint64* data; + uint64_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5494,7 +5494,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5505,7 +5505,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_ASCII: { - uint8* data; + uint8_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryByteArray(tif,dp,&data); @@ -5517,7 +5517,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte. Forcing it to be null",fip->field_name); data[dp->tdir_count-1] = '\0'; } - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5527,14 +5527,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_UINT8: { - uint8* data; + uint8_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryByteArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5544,14 +5544,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_SINT8: { - int8* data = NULL; + int8_t* data = NULL; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntrySbyteArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5561,14 +5561,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_UINT16: { - uint16* data; + uint16_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryShortArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5578,14 +5578,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_SINT16: { - int16* data = NULL; + int16_t* data = NULL; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntrySshortArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5595,14 +5595,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_UINT32: { - uint32* data; + uint32_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryLongArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5612,14 +5612,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_SINT32: { - int32* data = NULL; + int32_t* data = NULL; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntrySlongArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5629,14 +5629,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_UINT64: { - uint64* data; + uint64_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryLong8Array(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5646,14 +5646,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_SINT64: { - int64* data = NULL; + int64_t* data = NULL; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntrySlong8Array(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5670,7 +5670,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5687,7 +5687,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5697,14 +5697,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_IFD8: { - uint64* data; + uint64_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryIfd8Array(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5729,11 +5729,11 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) * While this routine says "strips", in fact it's also used for tiles. */ static int -TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) +TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32_t nstrips, uint64_t** lpp) { static const char module[] = "TIFFFetchStripThing"; enum TIFFReadDirEntryErr err; - uint64* data; + uint64_t* data; err=TIFFReadDirEntryLong8ArrayWithLimit(tif,dir,&data,nstrips); if (err!=TIFFReadDirEntryErrOk) { @@ -5741,14 +5741,14 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); return(0); } - if (dir->tdir_count<(uint64)nstrips) + if (dir->tdir_count<(uint64_t)nstrips) { - uint64* resizeddata; + uint64_t* resizeddata; const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag); const char* pszMax = getenv("LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT"); - uint32 max_nstrips = 1000000; + uint32_t max_nstrips = 1000000; if( pszMax ) - max_nstrips = (uint32) atoi(pszMax); + max_nstrips = (uint32_t) atoi(pszMax); TIFFReadDirEntryOutputErr(tif,TIFFReadDirEntryErrCount, module, fip ? fip->field_name : "unknown tagname", @@ -5760,13 +5760,13 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) return(0); } - resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for strip array"); + resizeddata=(uint64_t*)_TIFFCheckMalloc(tif, nstrips, sizeof(uint64_t), "for strip array"); if (resizeddata==0) { _TIFFfree(data); return(0); } - _TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64)); - _TIFFmemset(resizeddata+(uint32)dir->tdir_count,0,(nstrips-(uint32)dir->tdir_count)*sizeof(uint64)); + _TIFFmemcpy(resizeddata,data, (uint32_t)dir->tdir_count * sizeof(uint64_t)); + _TIFFmemset(resizeddata+(uint32_t)dir->tdir_count, 0, (nstrips - (uint32_t)dir->tdir_count) * sizeof(uint64_t)); _TIFFfree(data); data=resizeddata; } @@ -5785,8 +5785,8 @@ TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) UInt64Aligned_t m; m.l=0; assert(sizeof(double)==8); - assert(sizeof(uint64)==8); - assert(sizeof(uint32)==4); + assert(sizeof(uint64_t) == 8); + assert(sizeof(uint32_t) == 4); if (dir->tdir_count!=1) err=TIFFReadDirEntryErrCount; else if (dir->tdir_type!=TIFF_RATIONAL) @@ -5795,8 +5795,8 @@ TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 offset; - offset=*(uint32*)(&dir->tdir_offset); + uint32_t offset; + offset=*(uint32_t*)(&dir->tdir_offset); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,m.i); @@ -5832,32 +5832,32 @@ TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) } } -static void allocChoppedUpStripArrays(TIFF* tif, uint32 nstrips, - uint64 stripbytes, uint32 rowsperstrip) +static void allocChoppedUpStripArrays(TIFF* tif, uint32_t nstrips, + uint64_t stripbytes, uint32_t rowsperstrip) { TIFFDirectory *td = &tif->tif_dir; - uint64 bytecount; - uint64 offset; - uint64 last_offset; - uint64 last_bytecount; - uint32 i; - uint64 *newcounts; - uint64 *newoffsets; + uint64_t bytecount; + uint64_t offset; + uint64_t last_offset; + uint64_t last_bytecount; + uint32_t i; + uint64_t *newcounts; + uint64_t *newoffsets; offset = TIFFGetStrileOffset(tif, 0); last_offset = TIFFGetStrileOffset(tif, td->td_nstrips-1); last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips-1); - if( last_offset > TIFF_UINT64_MAX - last_bytecount || + if( last_offset > UINT64_MAX - last_bytecount || last_offset + last_bytecount < offset ) { return; } bytecount = last_offset + last_bytecount - offset; - newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), - "for chopped \"StripByteCounts\" array"); - newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), - "for chopped \"StripOffsets\" array"); + newcounts = (uint64_t*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64_t), + "for chopped \"StripByteCounts\" array"); + newoffsets = (uint64_t*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64_t), + "for chopped \"StripOffsets\" array"); if (newcounts == NULL || newoffsets == NULL) { /* * Unable to allocate new strip information, give up and use @@ -5911,13 +5911,13 @@ static void ChopUpSingleUncompressedStrip(TIFF* tif) { register TIFFDirectory *td = &tif->tif_dir; - uint64 bytecount; - uint64 offset; - uint32 rowblock; - uint64 rowblockbytes; - uint64 stripbytes; - uint32 nstrips; - uint32 rowsperstrip; + uint64_t bytecount; + uint64_t offset; + uint32_t rowblock; + uint64_t rowblockbytes; + uint64_t stripbytes; + uint32_t nstrips; + uint32_t rowsperstrip; bytecount = TIFFGetStrileByteCount(tif, 0); /* On a newly created file, just re-opened to be filled, we */ @@ -5941,8 +5941,8 @@ ChopUpSingleUncompressedStrip(TIFF* tif) stripbytes = rowblockbytes; rowsperstrip = rowblock; } else if (rowblockbytes > 0 ) { - uint32 rowblocksperstrip; - rowblocksperstrip = (uint32) (STRIP_SIZE_DEFAULT / rowblockbytes); + uint32_t rowblocksperstrip; + rowblocksperstrip = (uint32_t) (STRIP_SIZE_DEFAULT / rowblockbytes); rowsperstrip = rowblocksperstrip * rowblock; stripbytes = rowblocksperstrip * rowblockbytes; } @@ -5981,14 +5981,14 @@ ChopUpSingleUncompressedStrip(TIFF* tif) static void TryChopUpUncompressedBigTiff( TIFF* tif ) { TIFFDirectory *td = &tif->tif_dir; - uint32 rowblock; - uint64 rowblockbytes; - uint32 i; - uint64 stripsize; - uint32 rowblocksperstrip; - uint32 rowsperstrip; - uint64 stripbytes; - uint32 nstrips; + uint32_t rowblock; + uint64_t rowblockbytes; + uint32_t i; + uint64_t stripsize; + uint32_t rowblocksperstrip; + uint32_t rowsperstrip; + uint64_t stripbytes; + uint32_t nstrips; stripsize = TIFFStripSize64(tif); @@ -6041,7 +6041,7 @@ static void TryChopUpUncompressedBigTiff( TIFF* tif ) } /* Aim for 512 MB strips (that will still be manageable by 32 bit builds */ - rowblocksperstrip = (uint32) (512 * 1024 * 1024 / rowblockbytes); + rowblocksperstrip = (uint32_t) (512 * 1024 * 1024 / rowblockbytes); if( rowblocksperstrip == 0 ) rowblocksperstrip = 1; rowsperstrip = rowblocksperstrip * rowblock; @@ -6057,9 +6057,9 @@ static void TryChopUpUncompressedBigTiff( TIFF* tif ) if( tif->tif_mode == O_RDONLY && nstrips > 1000000 ) { - uint64 last_offset = TIFFGetStrileOffset(tif, td->td_nstrips-1); - uint64 filesize = TIFFGetFileSize(tif); - uint64 last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips-1); + uint64_t last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1); + uint64_t filesize = TIFFGetFileSize(tif); + uint64_t last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips - 1); if( last_offset > filesize || last_bytecount > filesize - last_offset ) { @@ -6072,7 +6072,7 @@ static void TryChopUpUncompressedBigTiff( TIFF* tif ) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static uint64 _TIFFUnsanitizedAddUInt64AndInt(uint64 a, int b) +static uint64_t _TIFFUnsanitizedAddUInt64AndInt(uint64_t a, int b) { return a + b; } @@ -6082,8 +6082,8 @@ static uint64 _TIFFUnsanitizedAddUInt64AndInt(uint64 a, int b) * 4096 byte page size. */ static -int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, - int strile, uint64* panVals ) +int _TIFFPartialReadStripArray(TIFF* tif, TIFFDirEntry* dirent, + int strile, uint64_t* panVals ) { static const char module[] = "_TIFFPartialReadStripArray"; #define IO_CACHE_PAGE_SIZE 4096 @@ -6091,37 +6091,37 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, size_t sizeofval; const int bSwab = (tif->tif_flags & TIFF_SWAB) != 0; int sizeofvalint; - uint64 nBaseOffset; - uint64 nOffset; - uint64 nOffsetStartPage; - uint64 nOffsetEndPage; + uint64_t nBaseOffset; + uint64_t nOffset; + uint64_t nOffsetStartPage; + uint64_t nOffsetEndPage; tmsize_t nToRead; tmsize_t nRead; - uint64 nLastStripOffset; + uint64_t nLastStripOffset; int iStartBefore; int i; - const uint32 arraySize = tif->tif_dir.td_stripoffsetbyteallocsize; + const uint32_t arraySize = tif->tif_dir.td_stripoffsetbyteallocsize; unsigned char buffer[2 * IO_CACHE_PAGE_SIZE]; assert( dirent->tdir_count > 4 ); if( dirent->tdir_type == TIFF_SHORT ) { - sizeofval = sizeof(uint16); + sizeofval = sizeof(uint16_t); } else if( dirent->tdir_type == TIFF_LONG ) { - sizeofval = sizeof(uint32); + sizeofval = sizeof(uint32_t); } else if( dirent->tdir_type == TIFF_LONG8 ) { - sizeofval = sizeof(uint64); + sizeofval = sizeof(uint64_t); } else if( dirent->tdir_type == TIFF_SLONG8 ) { /* Non conformant but used by some images as in */ /* https://github.com/OSGeo/gdal/issues/2165 */ - sizeofval = sizeof(int64); + sizeofval = sizeof(int64_t); } else { @@ -6134,20 +6134,20 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, if( tif->tif_flags&TIFF_BIGTIFF ) { - uint64 offset = dirent->tdir_offset.toff_long8; + uint64_t offset = dirent->tdir_offset.toff_long8; if( bSwab ) TIFFSwabLong8(&offset); nBaseOffset = offset; } else { - uint32 offset = dirent->tdir_offset.toff_long; + uint32_t offset = dirent->tdir_offset.toff_long; if( bSwab ) TIFFSwabLong(&offset); nBaseOffset = offset; } /* To avoid later unsigned integer overflows */ - if( nBaseOffset > (uint64)TIFF_INT64_MAX ) + if( nBaseOffset > (uint64_t)INT64_MAX ) { TIFFErrorExt(tif->tif_clientdata, module, "Cannot read offset/size for strile %d", strile); @@ -6191,13 +6191,13 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, if( strile + iStartBefore < 0 ) iStartBefore = -strile; for( i = iStartBefore; - (uint32)(strile + i) < arraySize && + (uint32_t)(strile + i) < arraySize && _TIFFUnsanitizedAddUInt64AndInt(nOffset, (i + 1) * sizeofvalint) <= nOffsetEndPage; ++i ) { if( dirent->tdir_type == TIFF_SHORT ) { - uint16 val; + uint16_t val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); @@ -6207,7 +6207,7 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, } else if( dirent->tdir_type == TIFF_LONG ) { - uint32 val; + uint32_t val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); @@ -6217,7 +6217,7 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, } else if( dirent->tdir_type == TIFF_LONG8 ) { - uint64 val; + uint64_t val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); @@ -6228,22 +6228,22 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, else /* if( dirent->tdir_type == TIFF_SLONG8 ) */ { /* Non conformant data type */ - int64 val; + int64_t val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); if( bSwab ) - TIFFSwabLong8((uint64*) &val); - panVals[strile + i] = (uint64) val; + TIFFSwabLong8((uint64_t*) &val); + panVals[strile + i] = (uint64_t) val; } } return 1; } static int _TIFFFetchStrileValue(TIFF* tif, - uint32 strile, + uint32_t strile, TIFFDirEntry* dirent, - uint64** parray) + uint64_t** parray) { static const char module[] = "_TIFFFetchStrileValue"; TIFFDirectory *td = &tif->tif_dir; @@ -6253,20 +6253,20 @@ static int _TIFFFetchStrileValue(TIFF* tif, } if( strile >= td->td_stripoffsetbyteallocsize ) { - uint32 nStripArrayAllocBefore = td->td_stripoffsetbyteallocsize; - uint32 nStripArrayAllocNew; - uint64 nArraySize64; + uint32_t nStripArrayAllocBefore = td->td_stripoffsetbyteallocsize; + uint32_t nStripArrayAllocNew; + uint64_t nArraySize64; size_t nArraySize; - uint64* offsetArray; - uint64* bytecountArray; + uint64_t* offsetArray; + uint64_t* bytecountArray; if( strile > 1000000 ) { - uint64 filesize = TIFFGetFileSize(tif); + uint64_t filesize = TIFFGetFileSize(tif); /* Avoid excessive memory allocation attempt */ /* For such a big blockid we need at least a TIFF_LONG per strile */ /* for the offset array. */ - if( strile > filesize / sizeof(uint32) ) + if( strile > filesize / sizeof(uint32_t) ) { TIFFErrorExt(tif->tif_clientdata, module, "File too short"); return 0; @@ -6288,7 +6288,7 @@ static int _TIFFFetchStrileValue(TIFF* tif, nStripArrayAllocNew = TIFF_MIN(nStripArrayAllocNew, td->td_nstrips); } assert( strile < nStripArrayAllocNew ); - nArraySize64 = (uint64)sizeof(uint64) * nStripArrayAllocNew; + nArraySize64 = (uint64_t)sizeof(uint64_t) * nStripArrayAllocNew; nArraySize = (size_t)(nArraySize64); #if SIZEOF_SIZE_T == 4 if( nArraySize != nArraySize64 ) @@ -6298,9 +6298,9 @@ static int _TIFFFetchStrileValue(TIFF* tif, return 0; } #endif - offsetArray = (uint64*)( + offsetArray = (uint64_t*)( _TIFFrealloc( td->td_stripoffset_p, nArraySize ) ); - bytecountArray = (uint64*)( + bytecountArray = (uint64_t*)( _TIFFrealloc( td->td_stripbytecount_p, nArraySize ) ); if( offsetArray ) td->td_stripoffset_p = offsetArray; @@ -6312,10 +6312,10 @@ static int _TIFFFetchStrileValue(TIFF* tif, /* Initialize new entries to ~0 / -1 */ memset(td->td_stripoffset_p + nStripArrayAllocBefore, 0xFF, - (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64) ); + (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64_t) ); memset(td->td_stripbytecount_p + nStripArrayAllocBefore, 0xFF, - (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64) ); + (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64_t) ); } else { @@ -6343,10 +6343,10 @@ static int _TIFFFetchStrileValue(TIFF* tif, return 1; } -static uint64 _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32 strile, - TIFFDirEntry* dirent, - uint64** parray, - int *pbErr) +static uint64_t _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32_t strile, + TIFFDirEntry* dirent, + uint64_t** parray, + int *pbErr) { TIFFDirectory *td = &tif->tif_dir; if( pbErr ) @@ -6387,13 +6387,13 @@ static uint64 _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32 strile, } /* Return the value of the TileOffsets/StripOffsets array for the specified tile/strile */ -uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile) +uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile) { return TIFFGetStrileOffsetWithErr(tif, strile, NULL); } /* Return the value of the TileOffsets/StripOffsets array for the specified tile/strile */ -uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr) +uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile, int *pbErr) { TIFFDirectory *td = &tif->tif_dir; return _TIFFGetStrileOffsetOrByteCountValue(tif, strile, @@ -6402,13 +6402,13 @@ uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr) } /* Return the value of the TileByteCounts/StripByteCounts array for the specified tile/strile */ -uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile) +uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile) { return TIFFGetStrileByteCountWithErr(tif, strile, NULL); } /* Return the value of the TileByteCounts/StripByteCounts array for the specified tile/strile */ -uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr) +uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile, int *pbErr) { TIFFDirectory *td = &tif->tif_dir; return _TIFFGetStrileOffsetOrByteCountValue(tif, strile, @@ -6468,7 +6468,7 @@ static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount ) #ifdef STRIPBYTECOUNTSORTED_UNUSED if (tif->tif_dir.td_nstrips > 1 && return_value == 1 ) { - uint32 strip; + uint32_t strip; tif->tif_dir.td_stripbytecountsorted = 1; for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { diff --git a/tiff/libtiff/tif_dirwrite.c b/tiff/libtiff/tif_dirwrite.c index f481250e..12d67be6 100644 --- a/tiff/libtiff/tif_dirwrite.c +++ b/tiff/libtiff/tif_dirwrite.c @@ -35,152 +35,152 @@ #define TIFFCvtNativeToIEEEFloat(tif, n, fp) #define TIFFCvtNativeToIEEEDouble(tif, n, dp) #else -extern void TIFFCvtNativeToIEEEFloat(TIFF* tif, uint32 n, float* fp); -extern void TIFFCvtNativeToIEEEDouble(TIFF* tif, uint32 n, double* dp); +extern void TIFFCvtNativeToIEEEFloat(TIFF* tif, uint32_t n, float* fp); +extern void TIFFCvtNativeToIEEEDouble(TIFF* tif, uint32_t n, double* dp); #endif -static int TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff); +static int TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64_t* pdiroff); -static int TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +static int TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); #if 0 -static int TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); #endif -static int TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); -static int TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +static int TIFFWriteDirectoryTagAscii(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, char* value); +static int TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +static int TIFFWriteDirectoryTagByte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value); #endif -static int TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +static int TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value); #if 0 -static int TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +static int TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value); #endif #ifdef notdef -static int TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +static int TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value); #endif -static int TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); +static int TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int8_t* value); #if 0 -static int TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +static int TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value); #endif -static int TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); -static int TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); -static int TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); +static int TIFFWriteDirectoryTagShort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value); +static int TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint16_t* value); +static int TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value); #ifdef notdef -static int TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +static int TIFFWriteDirectoryTagSshort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value); #endif -static int TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); +static int TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int16_t* value); #if 0 -static int TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +static int TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value); #endif -static int TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); -static int TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +static int TIFFWriteDirectoryTagLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value); +static int TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value); #if 0 -static int TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); +static int TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value); #endif #ifdef notdef -static int TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +static int TIFFWriteDirectoryTagSlong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value); #endif -static int TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); +static int TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int32_t* value); #if 0 -static int TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +static int TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value); #endif #ifdef notdef -static int TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); +static int TIFFWriteDirectoryTagLong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint64_t value); #endif -static int TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); +static int TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int64_t value); #endif -static int TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); -static int TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); -static int TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); -static int TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int64_t* value); +static int TIFFWriteDirectoryTagRational(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); +static int TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); +static int TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); #ifdef notdef -static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value); #endif -static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); #if 0 -static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value); #endif #ifdef notdef -static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); #endif -static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); #if 0 -static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); #endif -static int TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +static int TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #endif -static int TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); -static int TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); -static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value); +static int TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); +static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #endif -static int TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); -static int TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); -static int TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); +static int TIFFWriteDirectoryTagColormap(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir); +static int TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir); +static int TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir); -static int TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); -static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +static int TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, char* value); +static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +static int TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value); #endif -static int TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +static int TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +static int TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value); #endif -static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); -static int TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); -static int TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); +static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int8_t* value); +static int TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value); +static int TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint16_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +static int TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value); #endif -static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); -static int TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); -static int TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int16_t* value); +static int TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value); +static int TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +static int TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value); #endif -static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); +static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int32_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); +static int TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint64_t value); #endif -static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); +static int TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int64_t value); #endif -static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); -static int TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); -static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); -static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int64_t* value); +static int TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); +static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); +static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); /*--: Rational2Double: New functions to support true double-precision for custom rational tag types. */ -static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static int TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static void DoubleToRational(double value, uint32 *num, uint32 *denom); -static void DoubleToSrational(double value, int32 *num, int32 *denom); +static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static int TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static void DoubleToRational(double value, uint32_t *num, uint32_t *denom); +static void DoubleToSrational(double value, int32_t *num, int32_t *denom); #if 0 static void DoubleToRational_direct(double value, unsigned long *num, unsigned long *denom); static void DoubleToSrational_direct(double value, long *num, long *denom); #endif #ifdef notdef -static int TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +static int TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value); #endif -static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); #endif -static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); -static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value); +static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); -static int TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void* data); +static int TIFFWriteDirectoryTagData(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t datatype, uint32_t count, uint32_t datalength, void* data); static int TIFFLinkDirectory(TIFF*); @@ -260,7 +260,7 @@ TIFFCheckpointDirectory(TIFF* tif) } int -TIFFWriteCustomDirectory(TIFF* tif, uint64* pdiroff) +TIFFWriteCustomDirectory(TIFF* tif, uint64_t* pdiroff) { return TIFFWriteDirectorySec(tif,FALSE,FALSE,pdiroff); } @@ -302,11 +302,11 @@ TIFFRewriteDirectory( TIFF *tif ) } else { - uint32 nextdir; + uint32_t nextdir; nextdir = tif->tif_header.classic.tiff_diroff; while(1) { - uint16 dircount; - uint32 nextnextdir; + uint16_t dircount; + uint32_t nextnextdir; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, 2)) { @@ -327,7 +327,7 @@ TIFFRewriteDirectory( TIFF *tif ) TIFFSwabLong(&nextnextdir); if (nextnextdir==tif->tif_diroff) { - uint32 m; + uint32_t m; m=0; (void) TIFFSeekFile(tif, nextdir+2+dircount*12, SEEK_SET); @@ -360,12 +360,12 @@ TIFFRewriteDirectory( TIFF *tif ) } else { - uint64 nextdir; + uint64_t nextdir; nextdir = tif->tif_header.big.tiff_diroff; while(1) { - uint64 dircount64; - uint16 dircount; - uint64 nextnextdir; + uint64_t dircount64; + uint16_t dircount; + uint64_t nextnextdir; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount64, 8)) { @@ -381,7 +381,7 @@ TIFFRewriteDirectory( TIFF *tif ) "Sanity check on tag count failed, likely corrupt TIFF"); return (0); } - dircount=(uint16)dircount64; + dircount=(uint16_t)dircount64; (void) TIFFSeekFile(tif, nextdir+8+dircount*20, SEEK_SET); if (!ReadOK(tif, &nextnextdir, 8)) { @@ -393,7 +393,7 @@ TIFFRewriteDirectory( TIFF *tif ) TIFFSwabLong8(&nextnextdir); if (nextnextdir==tif->tif_diroff) { - uint64 m; + uint64_t m; m=0; (void) TIFFSeekFile(tif, nextdir+8+dircount*20, SEEK_SET); @@ -418,14 +418,14 @@ TIFFRewriteDirectory( TIFF *tif ) } static int -TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) +TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64_t* pdiroff) { static const char module[] = "TIFFWriteDirectorySec"; - uint32 ndir; + uint32_t ndir; TIFFDirEntry* dir; - uint32 dirsize; + uint32_t dirsize; void* dirmem; - uint32 m; + uint32_t m; if (tif->tif_mode == O_RDONLY) return (1); @@ -630,8 +630,8 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) { if (tif->tif_dir.td_extrasamples) { - uint16 na; - uint16* nb; + uint16_t na; + uint16_t* nb; TIFFGetFieldDefaulted(tif,TIFFTAG_EXTRASAMPLES,&na,&nb); if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_EXTRASAMPLES,na,nb)) goto bad; @@ -698,7 +698,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) goto bad; } { - uint32 n; + uint32_t n; for (n=0; n<tif->tif_nfields; n++) { const TIFFField* o; o = tif->tif_fields[n]; @@ -708,54 +708,54 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) { case TIFF_SETGET_ASCII: { - uint32 pa; + uint32_t pa; char* pb; assert(o->field_type==TIFF_ASCII); assert(o->field_readcount==TIFF_VARIABLE); assert(o->field_passcount==0); TIFFGetField(tif,o->field_tag,&pb); - pa=(uint32)(strlen(pb)); - if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,(uint16)o->field_tag,pa,pb)) + pa=(uint32_t)(strlen(pb)); + if (!TIFFWriteDirectoryTagAscii(tif, &ndir, dir, (uint16_t)o->field_tag, pa, pb)) goto bad; } break; case TIFF_SETGET_UINT16: { - uint16 p; + uint16_t p; assert(o->field_type==TIFF_SHORT); assert(o->field_readcount==1); assert(o->field_passcount==0); TIFFGetField(tif,o->field_tag,&p); - if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,(uint16)o->field_tag,p)) + if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, (uint16_t)o->field_tag, p)) goto bad; } break; case TIFF_SETGET_UINT32: { - uint32 p; + uint32_t p; assert(o->field_type==TIFF_LONG); assert(o->field_readcount==1); assert(o->field_passcount==0); TIFFGetField(tif,o->field_tag,&p); - if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,(uint16)o->field_tag,p)) + if (!TIFFWriteDirectoryTagLong(tif, &ndir, dir, (uint16_t)o->field_tag, p)) goto bad; } break; case TIFF_SETGET_C32_UINT8: { - uint32 pa; + uint32_t pa; void* pb; assert(o->field_type==TIFF_UNDEFINED); assert(o->field_readcount==TIFF_VARIABLE2); assert(o->field_passcount==1); TIFFGetField(tif,o->field_tag,&pa,&pb); - if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,(uint16)o->field_tag,pa,pb)) + if (!TIFFWriteDirectoryTagUndefinedArray(tif, &ndir, dir, (uint16_t)o->field_tag, pa, pb)) goto bad; } break; default: TIFFErrorExt(tif->tif_clientdata,module, - "Cannot write tag %d (%s)", + "Cannot write tag %"PRIu32" (%s)", TIFFFieldTag(o), o->field_name ? o->field_name : "unknown"); goto bad; @@ -764,10 +764,10 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) } } } - for (m=0; m<(uint32)(tif->tif_dir.td_customValueCount); m++) + for (m=0; m<(uint32_t)(tif->tif_dir.td_customValueCount); m++) { - uint16 tag = (uint16)tif->tif_dir.td_customValues[m].info->field_tag; - uint32 count = tif->tif_dir.td_customValues[m].count; + uint16_t tag = (uint16_t)tif->tif_dir.td_customValues[m].info->field_tag; + uint32_t count = tif->tif_dir.td_customValues[m].count; switch (tif->tif_dir.td_customValues[m].info->field_type) { case TIFF_ASCII: @@ -892,8 +892,8 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) dirsize=8+ndir*20+8; tif->tif_dataoff=tif->tif_diroff+dirsize; if (!(tif->tif_flags&TIFF_BIGTIFF)) - tif->tif_dataoff=(uint32)tif->tif_dataoff; - if ((tif->tif_dataoff<tif->tif_diroff)||(tif->tif_dataoff<(uint64)dirsize)) + tif->tif_dataoff=(uint32_t)tif->tif_dataoff; + if ((tif->tif_dataoff<tif->tif_diroff)||(tif->tif_dataoff<(uint64_t)dirsize)) { TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded"); goto bad; @@ -907,7 +907,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) { if (TIFFFieldSet(tif,FIELD_SUBIFD)&&(tif->tif_subifdoff==0)) { - uint32 na; + uint32_t na; TIFFDirEntry* nb; for (na=0, nb=dir; ; na++, nb++) { @@ -934,29 +934,29 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) } if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint8* n; - uint32 nTmp; + uint8_t* n; + uint32_t nTmp; TIFFDirEntry* o; n=dirmem; - *(uint16*)n=(uint16)ndir; + *(uint16_t*)n=(uint16_t)ndir; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; o=dir; for (m=0; m<ndir; m++) { - *(uint16*)n=o->tdir_tag; + *(uint16_t*)n=o->tdir_tag; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; - *(uint16*)n=o->tdir_type; + *(uint16_t*)n=o->tdir_type; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; - nTmp = (uint32)o->tdir_count; + nTmp = (uint32_t)o->tdir_count; _TIFFmemcpy(n,&nTmp,4); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)n); + TIFFSwabLong((uint32_t*)n); n+=4; /* This is correct. The data has been */ /* swabbed previously in TIFFWriteDirectoryTagData */ @@ -964,34 +964,34 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) n+=4; o++; } - nTmp = (uint32)tif->tif_nextdiroff; + nTmp = (uint32_t)tif->tif_nextdiroff; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&nTmp); _TIFFmemcpy(n,&nTmp,4); } else { - uint8* n; + uint8_t* n; TIFFDirEntry* o; n=dirmem; - *(uint64*)n=ndir; + *(uint64_t*)n=ndir; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)n); + TIFFSwabLong8((uint64_t*)n); n+=8; o=dir; for (m=0; m<ndir; m++) { - *(uint16*)n=o->tdir_tag; + *(uint16_t*)n=o->tdir_tag; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; - *(uint16*)n=o->tdir_type; + *(uint16_t*)n=o->tdir_type; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; _TIFFmemcpy(n,&o->tdir_count,8); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)n); + TIFFSwabLong8((uint64_t*)n); n+=8; _TIFFmemcpy(n,&o->tdir_offset,8); n+=8; @@ -999,7 +999,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) } _TIFFmemcpy(n,&tif->tif_nextdiroff,8); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)n); + TIFFSwabLong8((uint64_t*)n); } _TIFFfree(dir); dir=NULL; @@ -1035,66 +1035,66 @@ bad: return(0); } -static int8 TIFFClampDoubleToInt8( double val ) +static int8_t TIFFClampDoubleToInt8(double val ) { if( val > 127 ) return 127; if( val < -128 || val != val ) return -128; - return (int8)val; + return (int8_t)val; } -static int16 TIFFClampDoubleToInt16( double val ) +static int16_t TIFFClampDoubleToInt16(double val ) { if( val > 32767 ) return 32767; if( val < -32768 || val != val ) return -32768; - return (int16)val; + return (int16_t)val; } -static int32 TIFFClampDoubleToInt32( double val ) +static int32_t TIFFClampDoubleToInt32(double val ) { if( val > 0x7FFFFFFF ) return 0x7FFFFFFF; if( val < -0x7FFFFFFF-1 || val != val ) return -0x7FFFFFFF-1; - return (int32)val; + return (int32_t)val; } -static uint8 TIFFClampDoubleToUInt8( double val ) +static uint8_t TIFFClampDoubleToUInt8(double val ) { if( val < 0 ) return 0; if( val > 255 || val != val ) return 255; - return (uint8)val; + return (uint8_t)val; } -static uint16 TIFFClampDoubleToUInt16( double val ) +static uint16_t TIFFClampDoubleToUInt16(double val ) { if( val < 0 ) return 0; if( val > 65535 || val != val ) return 65535; - return (uint16)val; + return (uint16_t)val; } -static uint32 TIFFClampDoubleToUInt32( double val ) +static uint32_t TIFFClampDoubleToUInt32(double val ) { if( val < 0 ) return 0; if( val > 0xFFFFFFFFU || val != val ) return 0xFFFFFFFFU; - return (uint32)val; + return (uint32_t)val; } static int -TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { static const char module[] = "TIFFWriteDirectoryTagSampleformatArray"; void* conv; - uint32 i; + uint32_t i; int ok; conv = _TIFFmalloc(count*sizeof(double)); if (conv == NULL) @@ -1121,40 +1121,40 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di if (tif->tif_dir.td_bitspersample<=8) { for (i = 0; i < count; ++i) - ((int8*)conv)[i] = TIFFClampDoubleToInt8(value[i]); - ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8*)conv); + ((int8_t*)conv)[i] = TIFFClampDoubleToInt8(value[i]); + ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8_t*)conv); } else if (tif->tif_dir.td_bitspersample<=16) { for (i = 0; i < count; ++i) - ((int16*)conv)[i] = TIFFClampDoubleToInt16(value[i]); - ok = TIFFWriteDirectoryTagSshortArray(tif,ndir,dir,tag,count,(int16*)conv); + ((int16_t*)conv)[i] = TIFFClampDoubleToInt16(value[i]); + ok = TIFFWriteDirectoryTagSshortArray(tif,ndir,dir,tag,count,(int16_t*)conv); } else { for (i = 0; i < count; ++i) - ((int32*)conv)[i] = TIFFClampDoubleToInt32(value[i]); - ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)conv); + ((int32_t*)conv)[i] = TIFFClampDoubleToInt32(value[i]); + ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32_t*)conv); } break; case SAMPLEFORMAT_UINT: if (tif->tif_dir.td_bitspersample<=8) { for (i = 0; i < count; ++i) - ((uint8*)conv)[i] = TIFFClampDoubleToUInt8(value[i]); - ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8*)conv); + ((uint8_t*)conv)[i] = TIFFClampDoubleToUInt8(value[i]); + ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8_t*)conv); } else if (tif->tif_dir.td_bitspersample<=16) { for (i = 0; i < count; ++i) - ((uint16*)conv)[i] = TIFFClampDoubleToUInt16(value[i]); - ok = TIFFWriteDirectoryTagShortArray(tif,ndir,dir,tag,count,(uint16*)conv); + ((uint16_t*)conv)[i] = TIFFClampDoubleToUInt16(value[i]); + ok = TIFFWriteDirectoryTagShortArray(tif,ndir,dir,tag,count,(uint16_t*)conv); } else { for (i = 0; i < count; ++i) - ((uint32*)conv)[i] = TIFFClampDoubleToUInt32(value[i]); - ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv); + ((uint32_t*)conv)[i] = TIFFClampDoubleToUInt32(value[i]); + ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32_t*)conv); } break; default: @@ -1167,7 +1167,7 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di #if 0 static int -TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { switch (tif->tif_dir.td_sampleformat) { @@ -1178,18 +1178,18 @@ TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry return(TIFFWriteDirectoryTagDoublePerSample(tif,ndir,dir,tag,value)); case SAMPLEFORMAT_INT: if (tif->tif_dir.td_bitspersample<=8) - return(TIFFWriteDirectoryTagSbytePerSample(tif,ndir,dir,tag,(int8)value)); + return(TIFFWriteDirectoryTagSbytePerSample(tif,ndir,dir,tag,(int8_t)value)); else if (tif->tif_dir.td_bitspersample<=16) - return(TIFFWriteDirectoryTagSshortPerSample(tif,ndir,dir,tag,(int16)value)); + return(TIFFWriteDirectoryTagSshortPerSample(tif,ndir,dir,tag,(int16_t)value)); else - return(TIFFWriteDirectoryTagSlongPerSample(tif,ndir,dir,tag,(int32)value)); + return(TIFFWriteDirectoryTagSlongPerSample(tif,ndir,dir,tag,(int32_t)value)); case SAMPLEFORMAT_UINT: if (tif->tif_dir.td_bitspersample<=8) - return(TIFFWriteDirectoryTagBytePerSample(tif,ndir,dir,tag,(uint8)value)); + return(TIFFWriteDirectoryTagBytePerSample(tif,ndir,dir,tag,(uint8_t)value)); else if (tif->tif_dir.td_bitspersample<=16) - return(TIFFWriteDirectoryTagShortPerSample(tif,ndir,dir,tag,(uint16)value)); + return(TIFFWriteDirectoryTagShortPerSample(tif,ndir,dir,tag,(uint16_t)value)); else - return(TIFFWriteDirectoryTagLongPerSample(tif,ndir,dir,tag,(uint32)value)); + return(TIFFWriteDirectoryTagLongPerSample(tif,ndir,dir,tag,(uint32_t)value)); default: return(1); } @@ -1197,7 +1197,7 @@ TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry #endif static int -TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value) +TIFFWriteDirectoryTagAscii(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, char* value) { if (dir==NULL) { @@ -1208,7 +1208,7 @@ TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta } static int -TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value) { if (dir==NULL) { @@ -1220,7 +1220,7 @@ TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #ifdef notdef static int -TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +TIFFWriteDirectoryTagByte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value) { if (dir==NULL) { @@ -1232,7 +1232,7 @@ TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag #endif static int -TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value) { if (dir==NULL) { @@ -1244,19 +1244,19 @@ TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint1 #if 0 static int -TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value) { static const char module[] = "TIFFWriteDirectoryTagBytePerSample"; - uint8* m; - uint8* na; - uint16 nb; + uint8_t* m; + uint8_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint8)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint8_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1272,7 +1272,7 @@ TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u #ifdef notdef static int -TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value) { if (dir==NULL) { @@ -1284,7 +1284,7 @@ TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta #endif static int -TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value) +TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int8_t* value) { if (dir==NULL) { @@ -1296,19 +1296,19 @@ TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint #if 0 static int -TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value) { static const char module[] = "TIFFWriteDirectoryTagSbytePerSample"; - int8* m; - int8* na; - uint16 nb; + int8_t* m; + int8_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int8)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int8_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1323,7 +1323,7 @@ TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #endif static int -TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +TIFFWriteDirectoryTagShort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value) { if (dir==NULL) { @@ -1334,7 +1334,7 @@ TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta } static int -TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value) +TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint16_t* value) { if (dir==NULL) { @@ -1345,19 +1345,19 @@ TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint } static int -TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value) { static const char module[] = "TIFFWriteDirectoryTagShortPerSample"; - uint16* m; - uint16* na; - uint16 nb; + uint16_t* m; + uint16_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint16)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint16_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1372,7 +1372,7 @@ TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #ifdef notdef static int -TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +TIFFWriteDirectoryTagSshort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value) { if (dir==NULL) { @@ -1384,7 +1384,7 @@ TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 t #endif static int -TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value) +TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int16_t* value) { if (dir==NULL) { @@ -1396,19 +1396,19 @@ TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uin #if 0 static int -TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value) { static const char module[] = "TIFFWriteDirectoryTagSshortPerSample"; - int16* m; - int16* na; - uint16 nb; + int16_t* m; + int16_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int16)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int16_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1423,7 +1423,7 @@ TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #endif static int -TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +TIFFWriteDirectoryTagLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value) { if (dir==NULL) { @@ -1434,7 +1434,7 @@ TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag } static int -TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value) { if (dir==NULL) { @@ -1446,19 +1446,19 @@ TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint1 #if 0 static int -TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value) { static const char module[] = "TIFFWriteDirectoryTagLongPerSample"; - uint32* m; - uint32* na; - uint16 nb; + uint32_t* m; + uint32_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint32)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1474,7 +1474,7 @@ TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u #ifdef notdef static int -TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +TIFFWriteDirectoryTagSlong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value) { if (dir==NULL) { @@ -1486,7 +1486,7 @@ TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta #endif static int -TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value) +TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int32_t* value) { if (dir==NULL) { @@ -1498,19 +1498,19 @@ TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint #if 0 static int -TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value) { static const char module[] = "TIFFWriteDirectoryTagSlongPerSample"; - int32* m; - int32* na; - uint16 nb; + int32_t* m; + int32_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int32)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1526,7 +1526,7 @@ TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #ifdef notdef static int -TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) +TIFFWriteDirectoryTagLong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint64_t value) { if (dir==NULL) { @@ -1538,7 +1538,7 @@ TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta #endif static int -TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { if (dir==NULL) { @@ -1550,7 +1550,7 @@ TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint #ifdef notdef static int -TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) +TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int64_t value) { if (dir==NULL) { @@ -1562,7 +1562,7 @@ TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 t #endif static int -TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value) +TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int64_t* value) { if (dir==NULL) { @@ -1573,7 +1573,7 @@ TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uin } static int -TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +TIFFWriteDirectoryTagRational(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { if (dir==NULL) { @@ -1584,7 +1584,7 @@ TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 } static int -TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { if (dir==NULL) { @@ -1595,7 +1595,7 @@ TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u } static int -TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { if (dir==NULL) { @@ -1607,7 +1607,7 @@ TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, /*-- Rational2Double: additional write functions */ static int -TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { if (dir==NULL) { @@ -1618,7 +1618,7 @@ TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* } static int -TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { if (dir==NULL) { @@ -1629,7 +1629,7 @@ TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* } #ifdef notdef -static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value) { if (dir==NULL) { @@ -1640,7 +1640,7 @@ static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir } #endif -static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { if (dir==NULL) { @@ -1651,12 +1651,12 @@ static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry } #if 0 -static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value) { static const char module[] = "TIFFWriteDirectoryTagFloatPerSample"; float* m; float* na; - uint16 nb; + uint16_t nb; int o; if (dir==NULL) { @@ -1678,7 +1678,7 @@ static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirE #endif #ifdef notdef -static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { if (dir==NULL) { @@ -1689,7 +1689,7 @@ static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* di } #endif -static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { if (dir==NULL) { @@ -1700,12 +1700,12 @@ static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntr } #if 0 -static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { static const char module[] = "TIFFWriteDirectoryTagDoublePerSample"; double* m; double* na; - uint16 nb; + uint16_t nb; int o; if (dir==NULL) { @@ -1727,7 +1727,7 @@ static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDir #endif static int -TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value) { if (dir==NULL) { @@ -1739,7 +1739,7 @@ TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 #ifdef notdef static int -TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { if (dir==NULL) { @@ -1751,7 +1751,7 @@ TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint1 #endif static int -TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value) { if (dir==NULL) { @@ -1759,14 +1759,14 @@ TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint1 return(1); } if (value<=0xFFFF) - return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,(uint16)value)); + return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,(uint16_t)value)); else return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value)); } -static int _WriteAsType(TIFF* tif, uint64 strile_size, uint64 uncompressed_threshold) +static int _WriteAsType(TIFF* tif, uint64_t strile_size, uint64_t uncompressed_threshold) { - const uint16 compression = tif->tif_dir.td_compression; + const uint16_t compression = tif->tif_dir.td_compression; if ( compression == COMPRESSION_NONE ) { return strile_size > uncompressed_threshold; @@ -1787,12 +1787,12 @@ static int _WriteAsType(TIFF* tif, uint64 strile_size, uint64 uncompressed_thres return 1; } -static int WriteAsLong8(TIFF* tif, uint64 strile_size) +static int WriteAsLong8(TIFF* tif, uint64_t strile_size) { return _WriteAsType(tif, strile_size, 0xFFFFFFFFU); } -static int WriteAsLong4(TIFF* tif, uint64 strile_size) +static int WriteAsLong4(TIFF* tif, uint64_t strile_size) { return _WriteAsType(tif, strile_size, 0xFFFFU); } @@ -1805,7 +1805,7 @@ static int WriteAsLong4(TIFF* tif, uint64 strile_size) /************************************************************************/ static int -TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { static const char module[] = "TIFFWriteDirectoryTagLongLong8Array"; int o; @@ -1862,10 +1862,10 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ** and convert to long format. */ - uint32* p = _TIFFmalloc(count*sizeof(uint32)); - uint32* q; - uint64* ma; - uint32 mb; + uint32_t* p = _TIFFmalloc(count * sizeof(uint32_t)); + uint32_t* q; + uint64_t* ma; + uint32_t mb; if (p==NULL) { @@ -1882,7 +1882,7 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, _TIFFfree(p); return(0); } - *q= (uint32)(*ma); + *q= (uint32_t)(*ma); } o=TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,count,p); @@ -1890,10 +1890,10 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, } else { - uint16* p = _TIFFmalloc(count*sizeof(uint16)); - uint16* q; - uint64* ma; - uint32 mb; + uint16_t* p = _TIFFmalloc(count * sizeof(uint16_t)); + uint16_t* q; + uint64_t* ma; + uint32_t mb; if (p==NULL) { @@ -1911,7 +1911,7 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, _TIFFfree(p); return(0); } - *q= (uint16)(*ma); + *q= (uint16_t)(*ma); } o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,count,p); @@ -1928,13 +1928,13 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, /************************************************************************/ static int -TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { static const char module[] = "TIFFWriteDirectoryTagIfdIfd8Array"; - uint64* ma; - uint32 mb; - uint32* p; - uint32* q; + uint64_t* ma; + uint32_t mb; + uint32_t* p; + uint32_t* q; int o; /* is this just a counting pass? */ @@ -1954,7 +1954,7 @@ TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui ** and convert to long format. */ - p = _TIFFmalloc(count*sizeof(uint32)); + p = _TIFFmalloc(count*sizeof(uint32_t)); if (p==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1970,7 +1970,7 @@ TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui _TIFFfree(p); return(0); } - *q= (uint32)(*ma); + *q= (uint32_t)(*ma); } o=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,tag,count,p); @@ -1981,12 +1981,12 @@ TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui #ifdef notdef static int -TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { static const char module[] = "TIFFWriteDirectoryTagShortLongLong8Array"; - uint64* ma; - uint32 mb; - uint8 n; + uint64_t* ma; + uint32_t mb; + uint8_t n; int o; if (dir==NULL) { @@ -2006,31 +2006,31 @@ TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* } if (n==0) { - uint16* p; - uint16* q; - p=_TIFFmalloc(count*sizeof(uint16)); + uint16_t* p; + uint16_t* q; + p=_TIFFmalloc(count*sizeof(uint16_t)); if (p==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } for (ma=value, mb=0, q=p; mb<count; ma++, mb++, q++) - *q=(uint16)(*ma); + *q=(uint16_t)(*ma); o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,count,p); _TIFFfree(p); } else if (n==1) { - uint32* p; - uint32* q; - p=_TIFFmalloc(count*sizeof(uint32)); + uint32_t* p; + uint32_t* q; + p=_TIFFmalloc(count*sizeof(uint32_t)); if (p==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } for (ma=value, mb=0, q=p; mb<count; ma++, mb++, q++) - *q=(uint32)(*ma); + *q=(uint32_t)(*ma); o=TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,count,p); _TIFFfree(p); } @@ -2043,11 +2043,11 @@ TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* } #endif static int -TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) +TIFFWriteDirectoryTagColormap(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir) { static const char module[] = "TIFFWriteDirectoryTagColormap"; - uint32 m; - uint16* n; + uint32_t m; + uint16_t* n; int o; if (dir==NULL) { @@ -2055,27 +2055,27 @@ TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) return(1); } m=(1<<tif->tif_dir.td_bitspersample); - n=_TIFFmalloc(3*m*sizeof(uint16)); + n=_TIFFmalloc(3*m*sizeof(uint16_t)); if (n==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - _TIFFmemcpy(&n[0],tif->tif_dir.td_colormap[0],m*sizeof(uint16)); - _TIFFmemcpy(&n[m],tif->tif_dir.td_colormap[1],m*sizeof(uint16)); - _TIFFmemcpy(&n[2*m],tif->tif_dir.td_colormap[2],m*sizeof(uint16)); + _TIFFmemcpy(&n[0],tif->tif_dir.td_colormap[0],m*sizeof(uint16_t)); + _TIFFmemcpy(&n[m],tif->tif_dir.td_colormap[1],m*sizeof(uint16_t)); + _TIFFmemcpy(&n[2*m],tif->tif_dir.td_colormap[2],m*sizeof(uint16_t)); o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_COLORMAP,3*m,n); _TIFFfree(n); return(o); } static int -TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) +TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir) { static const char module[] = "TIFFWriteDirectoryTagTransferfunction"; - uint32 m; - uint16 n; - uint16* o; + uint32_t m; + uint16_t n; + uint16_t* o; int p; if (dir==NULL) { @@ -2095,38 +2095,38 @@ TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir if (n==3) { if (tif->tif_dir.td_transferfunction[2] == NULL || - !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16))) + !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16_t))) n=2; } if (n==2) { if (tif->tif_dir.td_transferfunction[1] == NULL || - !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16))) + !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16_t))) n=1; } if (n==0) n=1; - o=_TIFFmalloc(n*m*sizeof(uint16)); + o=_TIFFmalloc(n*m*sizeof(uint16_t)); if (o==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - _TIFFmemcpy(&o[0],tif->tif_dir.td_transferfunction[0],m*sizeof(uint16)); + _TIFFmemcpy(&o[0],tif->tif_dir.td_transferfunction[0],m*sizeof(uint16_t)); if (n>1) - _TIFFmemcpy(&o[m],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16)); + _TIFFmemcpy(&o[m],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16_t)); if (n>2) - _TIFFmemcpy(&o[2*m],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16)); + _TIFFmemcpy(&o[2*m],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16_t)); p=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_TRANSFERFUNCTION,n*m,o); _TIFFfree(o); return(p); } static int -TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) +TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir) { static const char module[] = "TIFFWriteDirectoryTagSubifd"; - uint64 m; + uint64_t m; int n; if (tif->tif_dir.td_nsubifd==0) return(1); @@ -2138,11 +2138,11 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) m=tif->tif_dataoff; if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32* o; - uint64* pa; - uint32* pb; - uint16 p; - o=_TIFFmalloc(tif->tif_dir.td_nsubifd*sizeof(uint32)); + uint32_t* o; + uint64_t* pa; + uint32_t* pb; + uint16_t p; + o=_TIFFmalloc(tif->tif_dir.td_nsubifd*sizeof(uint32_t)); if (o==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2161,7 +2161,7 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) _TIFFfree(o); return(0); } - *pb++=(uint32)(*pa++); + *pb++=(uint32_t)(*pa++); } n=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,o); _TIFFfree(o); @@ -2188,56 +2188,56 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) } static int -TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value) +TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, char* value) { assert(sizeof(char)==1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_ASCII,count,count,value)); } static int -TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value) { - assert(sizeof(uint8)==1); + assert(sizeof(uint8_t) == 1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_UNDEFINED,count,count,value)); } #ifdef notdef static int -TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value) { - assert(sizeof(uint8)==1); + assert(sizeof(uint8_t)==1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,1,1,&value)); } #endif static int -TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value) { - assert(sizeof(uint8)==1); + assert(sizeof(uint8_t) == 1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,count,count,value)); } #ifdef notdef static int -TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value) { - assert(sizeof(int8)==1); + assert(sizeof(int8_t)==1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,1,1,&value)); } #endif static int -TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value) +TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int8_t* value) { - assert(sizeof(int8)==1); + assert(sizeof(int8_t) == 1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,count,count,value)); } static int -TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value) { - uint16 m; - assert(sizeof(uint16)==2); + uint16_t m; + assert(sizeof(uint16_t) == 2); m=value; if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(&m); @@ -2245,10 +2245,10 @@ TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui } static int -TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value) +TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint16_t* value) { assert(count<0x80000000); - assert(sizeof(uint16)==2); + assert(sizeof(uint16_t) == 2); if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfShort(value,count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,count,count*2,value)); @@ -2256,32 +2256,32 @@ TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di #ifdef notdef static int -TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value) { - int16 m; - assert(sizeof(int16)==2); + int16_t m; + assert(sizeof(int16_t)==2); m=value; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)(&m)); + TIFFSwabShort((uint16_t*)(&m)); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,1,2,&m)); } #endif static int -TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value) +TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int16_t* value) { assert(count<0x80000000); - assert(sizeof(int16)==2); + assert(sizeof(int16_t) == 2); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfShort((uint16*)value,count); + TIFFSwabArrayOfShort((uint16_t*)value, count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,count,count*2,value)); } static int -TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value) { - uint32 m; - assert(sizeof(uint32)==4); + uint32_t m; + assert(sizeof(uint32_t) == 4); m=value; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&m); @@ -2289,10 +2289,10 @@ TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uin } static int -TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value) { assert(count<0x40000000); - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong(value,count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG,count,count*4,value)); @@ -2300,33 +2300,33 @@ TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir #ifdef notdef static int -TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value) { - int32 m; - assert(sizeof(int32)==4); + int32_t m; + assert(sizeof(int32_t)==4); m=value; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)(&m)); + TIFFSwabLong((uint32_t*)(&m)); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,1,4,&m)); } #endif static int -TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value) +TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int32_t* value) { assert(count<0x40000000); - assert(sizeof(int32)==4); + assert(sizeof(int32_t) == 4); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)value,count); + TIFFSwabArrayOfLong((uint32_t*)value, count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,count,count*4,value)); } #ifdef notdef static int -TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) +TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint64_t value) { - uint64 m; - assert(sizeof(uint64)==8); + uint64_t m; + assert(sizeof(uint64_t)==8); if( !(tif->tif_flags&TIFF_BIGTIFF) ) { TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","LONG8 not allowed for ClassicTIFF"); return(0); @@ -2339,10 +2339,10 @@ TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui #endif static int -TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { assert(count<0x20000000); - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); if( !(tif->tif_flags&TIFF_BIGTIFF) ) { TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8Array","LONG8 not allowed for ClassicTIFF"); return(0); @@ -2354,41 +2354,41 @@ TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* di #ifdef notdef static int -TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) +TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int64_t value) { - int64 m; - assert(sizeof(int64)==8); + int64_t m; + assert(sizeof(int64_t)==8); if( !(tif->tif_flags&TIFF_BIGTIFF) ) { TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedSlong8","SLONG8 not allowed for ClassicTIFF"); return(0); } m=value; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)(&m)); + TIFFSwabLong8((uint64_t*)(&m)); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,1,8,&m)); } #endif static int -TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value) +TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int64_t* value) { assert(count<0x20000000); - assert(sizeof(int64)==8); + assert(sizeof(int64_t) == 8); if( !(tif->tif_flags&TIFF_BIGTIFF) ) { TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedSlong8Array","SLONG8 not allowed for ClassicTIFF"); return(0); } if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64*)value,count); + TIFFSwabArrayOfLong8((uint64_t*)value, count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value)); } static int -TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { static const char module[] = "TIFFWriteDirectoryTagCheckedRational"; - uint32 m[2]; - assert(sizeof(uint32)==4); + uint32_t m[2]; + assert(sizeof(uint32_t) == 4); if (value < 0) { TIFFErrorExt(tif->tif_clientdata, module, "Negative value is illegal"); @@ -2405,20 +2405,20 @@ TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, m[0]=0; m[1]=1; } - else if (value <= 0xFFFFFFFFU && value==(double)(uint32)value) + else if (value <= 0xFFFFFFFFU && value==(double)(uint32_t)value) { - m[0]=(uint32)value; + m[0]=(uint32_t)value; m[1]=1; } else if (value<1.0) { - m[0]=(uint32)(value*0xFFFFFFFF); + m[0]=(uint32_t)(value*0xFFFFFFFF); m[1]=0xFFFFFFFF; } else { m[0]=0xFFFFFFFF; - m[1]=(uint32)(0xFFFFFFFF/value); + m[1]=(uint32_t)(0xFFFFFFFF/value); } #else /*--Rational2Double: New function also used for non-custom rational tags. @@ -2438,16 +2438,16 @@ TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, } static int -TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { static const char module[] = "TIFFWriteDirectoryTagCheckedRationalArray"; - uint32* m; + uint32_t* m; float* na; - uint32* nb; - uint32 nc; + uint32_t* nb; + uint32_t nc; int o; - assert(sizeof(uint32)==4); - m=_TIFFmalloc(count*2*sizeof(uint32)); + assert(sizeof(uint32_t) == 4); + m=_TIFFmalloc(count*2*sizeof(uint32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2462,20 +2462,20 @@ TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* nb[1]=1; } else if (*na >= 0 && *na <= (float)0xFFFFFFFFU && - *na==(float)(uint32)(*na)) + *na==(float)(uint32_t)(*na)) { - nb[0]=(uint32)(*na); + nb[0]=(uint32_t)(*na); nb[1]=1; } else if (*na<1.0) { - nb[0]=(uint32)((double)(*na)*0xFFFFFFFF); + nb[0]=(uint32_t)((double)(*na)*0xFFFFFFFF); nb[1]=0xFFFFFFFF; } else { nb[0]=0xFFFFFFFF; - nb[1]=(uint32)((double)0xFFFFFFFF/(*na)); + nb[1]=(uint32_t)((double)0xFFFFFFFF/(*na)); } #else /*-- Rational2Double: Also for float precision accuracy is sometimes enhanced --*/ @@ -2490,16 +2490,16 @@ TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* } static int -TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalArray"; - int32* m; + int32_t* m; float* na; - int32* nb; - uint32 nc; + int32_t* nb; + uint32_t nc; int o; - assert(sizeof(int32)==4); - m=_TIFFmalloc(count*2*sizeof(int32)); + assert(sizeof(int32_t) == 4); + m=_TIFFmalloc(count*2*sizeof(int32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2510,38 +2510,38 @@ TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry #ifdef not_def if (*na<0.0) { - if (*na==(int32)(*na)) + if (*na==(int32_t)(*na)) { - nb[0]=(int32)(*na); + nb[0]=(int32_t)(*na); nb[1]=1; } else if (*na>-1.0) { - nb[0]=-(int32)((double)(-*na)*0x7FFFFFFF); + nb[0]=-(int32_t)((double)(-*na)*0x7FFFFFFF); nb[1]=0x7FFFFFFF; } else { nb[0]=-0x7FFFFFFF; - nb[1]=(int32)((double)0x7FFFFFFF/(-*na)); + nb[1]=(int32_t)((double)0x7FFFFFFF/(-*na)); } } else { - if (*na==(int32)(*na)) + if (*na==(int32_t)(*na)) { - nb[0]=(int32)(*na); + nb[0]=(int32_t)(*na); nb[1]=1; } else if (*na<1.0) { - nb[0]=(int32)((double)(*na)*0x7FFFFFFF); + nb[0]=(int32_t)((double)(*na)*0x7FFFFFFF); nb[1]=0x7FFFFFFF; } else { nb[0]=0x7FFFFFFF; - nb[1]=(int32)((double)0x7FFFFFFF/(*na)); + nb[1]=(int32_t)((double)0x7FFFFFFF/(*na)); } } #else @@ -2550,7 +2550,7 @@ TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry #endif } if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)m,count*2); + TIFFSwabArrayOfLong((uint32_t*)m, count * 2); o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SRATIONAL,count,count*8,&m[0]); _TIFFfree(m); return(o); @@ -2558,16 +2558,16 @@ TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry /*-- Rational2Double: additional write functions for double arrays */ static int -TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { static const char module[] = "TIFFWriteDirectoryTagCheckedRationalDoubleArray"; - uint32* m; + uint32_t* m; double* na; - uint32* nb; - uint32 nc; + uint32_t* nb; + uint32_t nc; int o; - assert(sizeof(uint32)==4); - m=_TIFFmalloc(count*2*sizeof(uint32)); + assert(sizeof(uint32_t) == 4); + m=_TIFFmalloc(count*2*sizeof(uint32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2585,16 +2585,16 @@ TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDir } /*-- TIFFWriteDirectoryTagCheckedRationalDoubleArray() ------- */ static int -TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalDoubleArray"; - int32* m; + int32_t* m; double* na; - int32* nb; - uint32 nc; + int32_t* nb; + uint32_t nc; int o; - assert(sizeof(int32)==4); - m=_TIFFmalloc(count*2*sizeof(int32)); + assert(sizeof(int32_t) == 4); + m=_TIFFmalloc(count*2*sizeof(int32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2605,7 +2605,7 @@ TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDi DoubleToSrational(*na, &nb[0], &nb[1]); } if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)m,count*2); + TIFFSwabArrayOfLong((uint32_t*)m, count * 2); o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SRATIONAL,count,count*8,&m[0]); _TIFFfree(m); return(o); @@ -2626,20 +2626,20 @@ void DoubleToRational_direct(double value, unsigned long *num, unsigned long *de *num=0; *denom=1; } - else if (value <= 0xFFFFFFFFU && (value==(double)(uint32)(value))) /* check for integer values */ + else if (value <= 0xFFFFFFFFU && (value==(double)(uint32_t)(value))) /* check for integer values */ { - *num=(uint32)(value); + *num=(uint32_t)(value); *denom=1; } else if (value<1.0) { - *num = (uint32)((value) * (double)0xFFFFFFFFU); + *num = (uint32_t)((value) * (double)0xFFFFFFFFU); *denom=0xFFFFFFFFU; } else { *num=0xFFFFFFFFU; - *denom=(uint32)((double)0xFFFFFFFFU/(value)); + *denom=(uint32_t)((double)0xFFFFFFFFU/(value)); } } /*-- DoubleToRational_direct() -------------- */ #endif @@ -2656,38 +2656,38 @@ void DoubleToSrational_direct(double value, long *num, long *denom) */ if (value<0.0) { - if (value==(int32)(value)) + if (value==(int32_t)(value)) { - *num=(int32)(value); + *num=(int32_t)(value); *denom=1; } else if (value>-1.0) { - *num=-(int32)((-value) * (double)0x7FFFFFFF); + *num=-(int32_t)((-value) * (double)0x7FFFFFFF); *denom=0x7FFFFFFF; } else { *num=-0x7FFFFFFF; - *denom=(int32)((double)0x7FFFFFFF / (-value)); + *denom=(int32_t)((double)0x7FFFFFFF / (-value)); } } else { - if (value==(int32)(value)) + if (value==(int32_t)(value)) { - *num=(int32)(value); + *num=(int32_t)(value); *denom=1; } else if (value<1.0) { - *num=(int32)((value) *(double)0x7FFFFFFF); + *num=(int32_t)((value) *(double)0x7FFFFFFF); *denom=0x7FFFFFFF; } else { *num=0x7FFFFFFF; - *denom=(int32)((double)0x7FFFFFFF / (value)); + *denom=(int32_t)((double)0x7FFFFFFF / (value)); } } } /*-- DoubleToSrational_direct() --------------*/ @@ -2710,16 +2710,16 @@ void DoubleToSrational_direct(double value, long *num, long *denom) * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ static -void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, unsigned long long *ullNum, unsigned long long *ullDenom) +void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, uint64_t *ullNum, uint64_t *ullDenom) { /* Internally, the integer variables can be bigger than the external ones, * as long as the result will fit into the external variable size. */ - unsigned long long val, numSum[3] = { 0, 1, 0 }, denomSum[3] = { 1, 0, 0 }; - unsigned long long aux, bigNum, bigDenom; - unsigned long long returnLimit; + uint64_t numSum[3] = { 0, 1, 0 }, denomSum[3] = { 1, 0, 0 }; + uint64_t aux, bigNum, bigDenom; + uint64_t returnLimit; int i; - unsigned long long nMax; + uint64_t nMax; double fMax; unsigned long maxDenom; /*-- nMax and fMax defines the initial accuracy of the starting fractional, @@ -2729,7 +2729,7 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall * For long long nMax = ((9223372036854775807-1)/2); for long nMax = ((2147483647-1)/2); */ if (blnUseSmallRange) { - nMax = (unsigned long long)((2147483647 - 1) / 2); /* for ULONG range */ + nMax = (uint64_t)((2147483647 - 1) / 2); /* for ULONG range */ } else { nMax = ((9223372036854775807 - 1) / 2); /* for ULLONG range */ @@ -2750,11 +2750,11 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall } /*-- First generate a rational fraction (bigNum/bigDenom) which represents the value - * as a rational number with the highest accuracy. Therefore, unsigned long long (uint64) is needed. + * as a rational number with the highest accuracy. Therefore, uint64_t (uint64_t) is needed. * This rational fraction is then reduced using the Euclidean algorithm to find the greatest common divisor (GCD). * bigNum = big numinator of value without fraction (or cut residual fraction) * bigDenom = big denominator of value - *-- Break-criteria so that uint64 cast to "bigNum" introduces no error and bigDenom has no overflow, + *-- Break-criteria so that uint64_t cast to "bigNum" introduces no error and bigDenom has no overflow, * and stop with enlargement of fraction when the double-value of it reaches an integer number without fractional part. */ bigDenom = 1; @@ -2762,19 +2762,17 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall bigDenom <<= 1; value *= 2; } - bigNum = (unsigned long long)value; + bigNum = (uint64_t)value; /*-- Start Euclidean algorithm to find the greatest common divisor (GCD) -- */ #define MAX_ITERATIONS 64 for (i = 0; i < MAX_ITERATIONS; i++) { + uint64_t val; /* if bigDenom is not zero, calculate integer part of fraction. */ if (bigDenom == 0) { - val = 0; break; } - else { - val = bigNum / bigDenom; - } + val = bigNum / bigDenom; /* Set bigDenom to reminder of bigNum/bigDenom and bigNum to previous denominator bigDenom. */ aux = bigNum; @@ -2819,11 +2817,11 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ static -void DoubleToRational(double value, uint32 *num, uint32 *denom) +void DoubleToRational(double value, uint32_t *num, uint32_t *denom) { /*---- UN-SIGNED RATIONAL ---- */ double dblDiff, dblDiff2; - unsigned long long ullNum, ullDenom, ullNum2, ullDenom2; + uint64_t ullNum, ullDenom, ullNum2, ullDenom2; /*-- Check for negative values. If so it is an error. */ /* Test written that way to catch NaN */ @@ -2840,8 +2838,8 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom) return; } /*-- Check for easy integer numbers -- */ - if (value == (uint32)(value)) { - *num = (uint32)value; + if (value == (uint32_t)(value)) { + *num = (uint32_t)value; *denom = 1; return; } @@ -2860,11 +2858,7 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom) ToRationalEuclideanGCD(value, FALSE, TRUE, &ullNum2, &ullDenom2); /*-- Double-Check, that returned values fit into ULONG :*/ if (ullNum > 0xFFFFFFFFUL || ullDenom > 0xFFFFFFFFUL || ullNum2 > 0xFFFFFFFFUL || ullDenom2 > 0xFFFFFFFFUL) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%I64u, denom=%I64u | num2=%I64u, denom2=%I64u", value, ullNum, ullDenom, ullNum2, ullDenom2); -#else - TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%12llu, denom=%12llu | num2=%12llu, denom2=%12llu", value, ullNum, ullDenom, ullNum2, ullDenom2); -#endif + TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%12"PRIu64", denom=%12"PRIu64" | num2=%12"PRIu64", denom2=%12"PRIu64"", value, ullNum, ullDenom, ullNum2, ullDenom2); assert(0); } @@ -2872,12 +2866,12 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom) dblDiff = fabs(value - ((double)ullNum / (double)ullDenom)); dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2)); if (dblDiff < dblDiff2) { - *num = (uint32)ullNum; - *denom = (uint32)ullDenom; + *num = (uint32_t)ullNum; + *denom = (uint32_t)ullDenom; } else { - *num = (uint32)ullNum2; - *denom = (uint32)ullDenom2; + *num = (uint32_t)ullNum2; + *denom = (uint32_t)ullDenom2; } } /*-- DoubleToRational() -------------- */ @@ -2887,12 +2881,12 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom) * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ static -void DoubleToSrational(double value, int32 *num, int32 *denom) +void DoubleToSrational(double value, int32_t *num, int32_t *denom) { /*---- SIGNED RATIONAL ----*/ int neg = 1; double dblDiff, dblDiff2; - unsigned long long ullNum, ullDenom, ullNum2, ullDenom2; + uint64_t ullNum, ullDenom, ullNum2, ullDenom2; /*-- Check for negative values and use then the positive one for internal calculations, but take the sign into account before returning. */ if (value < 0) { neg = -1; value = -value; } @@ -2904,8 +2898,8 @@ void DoubleToSrational(double value, int32 *num, int32 *denom) return; } /*-- Check for easy numbers -- */ - if (value == (int32)(value)) { - *num = (int32)(neg * value); + if (value == (int32_t)(value)) { + *num = (int32_t)(neg * value); *denom = 1; return; } @@ -2925,11 +2919,7 @@ void DoubleToSrational(double value, int32 *num, int32 *denom) ToRationalEuclideanGCD(value, TRUE, TRUE, &ullNum2, &ullDenom2); /*-- Double-Check, that returned values fit into LONG :*/ if (ullNum > 0x7FFFFFFFL || ullDenom > 0x7FFFFFFFL || ullNum2 > 0x7FFFFFFFL || ullDenom2 > 0x7FFFFFFFL) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%I64u, denom=%I64u | num2=%I64u, denom2=%I64u", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); -#else - TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%12llu, denom=%12llu | num2=%12llu, denom2=%12llu", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); -#endif + TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%12"PRIu64", denom=%12"PRIu64" | num2=%12"PRIu64", denom2=%12"PRIu64"", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); assert(0); } @@ -2937,12 +2927,12 @@ void DoubleToSrational(double value, int32 *num, int32 *denom) dblDiff = fabs(value - ((double)ullNum / (double)ullDenom)); dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2)); if (dblDiff < dblDiff2) { - *num = (int32)(neg * (long)ullNum); - *denom = (int32)ullDenom; + *num = (int32_t)(neg * (long)ullNum); + *denom = (int32_t)ullDenom; } else { - *num = (int32)(neg * (long)ullNum2); - *denom = (int32)ullDenom2; + *num = (int32_t)(neg * (long)ullNum2); + *denom = (int32_t)ullDenom2; } } /*-- DoubleToSrational() --------------*/ @@ -2952,7 +2942,7 @@ void DoubleToSrational(double value, int32 *num, int32 *denom) #ifdef notdef static int -TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value) { float m; assert(sizeof(float)==4); @@ -2965,7 +2955,7 @@ TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui #endif static int -TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { assert(count<0x40000000); assert(sizeof(float)==4); @@ -2977,7 +2967,7 @@ TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di #ifdef notdef static int -TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { double m; assert(sizeof(double)==8); @@ -2990,7 +2980,7 @@ TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u #endif static int -TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { assert(count<0x20000000); assert(sizeof(double)==8); @@ -3001,20 +2991,20 @@ TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* d } static int -TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value) { assert(count<0x40000000); - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong(value,count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_IFD,count,count*4,value)); } static int -TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { assert(count<0x20000000); - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); assert(tif->tif_flags&TIFF_BIGTIFF); if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong8(value,count); @@ -3022,10 +3012,10 @@ TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir } static int -TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void* data) +TIFFWriteDirectoryTagData(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t datatype, uint32_t count, uint32_t datalength, void* data) { static const char module[] = "TIFFWriteDirectoryTagData"; - uint32 m; + uint32_t m; m=0; while (m<(*ndir)) { @@ -3036,7 +3026,7 @@ TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag } if (m<(*ndir)) { - uint32 n; + uint32_t n; for (n=*ndir; n>m; n--) dir[n]=dir[n-1]; } @@ -3053,11 +3043,11 @@ TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag } else { - uint64 na,nb; + uint64_t na,nb; na=tif->tif_dataoff; nb=na+datalength; if (!(tif->tif_flags&TIFF_BIGTIFF)) - nb=(uint32)nb; + nb=(uint32_t)nb; if ((nb<na)||(nb<datalength)) { TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded"); @@ -3079,8 +3069,8 @@ TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag tif->tif_dataoff++; if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 o; - o=(uint32)na; + uint32_t o; + o=(uint32_t)na; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&o); _TIFFmemcpy(&dir[m].tdir_offset,&o,4); @@ -3113,8 +3103,8 @@ TIFFLinkDirectory(TIFF* tif) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 m; - m = (uint32)tif->tif_diroff; + uint32_t m; + m = (uint32_t)tif->tif_diroff; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&m); (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); @@ -3136,7 +3126,7 @@ TIFFLinkDirectory(TIFF* tif) } else { - uint64 m; + uint64_t m; m = tif->tif_diroff; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&m); @@ -3161,16 +3151,16 @@ TIFFLinkDirectory(TIFF* tif) if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 m; - uint32 nextdir; - m = (uint32)(tif->tif_diroff); + uint32_t m; + uint32_t nextdir; + m = (uint32_t)(tif->tif_diroff); if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&m); if (tif->tif_header.classic.tiff_diroff == 0) { /* * First directory, overwrite offset in header. */ - tif->tif_header.classic.tiff_diroff = (uint32) tif->tif_diroff; + tif->tif_header.classic.tiff_diroff = (uint32_t) tif->tif_diroff; (void) TIFFSeekFile(tif,4, SEEK_SET); if (!WriteOK(tif, &m, 4)) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, @@ -3184,8 +3174,8 @@ TIFFLinkDirectory(TIFF* tif) */ nextdir = tif->tif_header.classic.tiff_diroff; while(1) { - uint16 dircount; - uint32 nextnextdir; + uint16_t dircount; + uint32_t nextnextdir; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, 2)) { @@ -3220,8 +3210,8 @@ TIFFLinkDirectory(TIFF* tif) } else { - uint64 m; - uint64 nextdir; + uint64_t m; + uint64_t nextdir; m = tif->tif_diroff; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&m); @@ -3243,9 +3233,9 @@ TIFFLinkDirectory(TIFF* tif) */ nextdir = tif->tif_header.big.tiff_diroff; while(1) { - uint64 dircount64; - uint16 dircount; - uint64 nextnextdir; + uint64_t dircount64; + uint16_t dircount; + uint64_t nextnextdir; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount64, 8)) { @@ -3261,7 +3251,7 @@ TIFFLinkDirectory(TIFF* tif) "Sanity check on tag count failed, likely corrupt TIFF"); return (0); } - dircount=(uint16)dircount64; + dircount=(uint16_t)dircount64; (void) TIFFSeekFile(tif, nextdir+8+dircount*20, SEEK_SET); if (!ReadOK(tif, &nextnextdir, 8)) { @@ -3302,21 +3292,21 @@ TIFFLinkDirectory(TIFF* tif) /************************************************************************/ int -_TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, +_TIFFRewriteField(TIFF* tif, uint16_t tag, TIFFDataType in_datatype, tmsize_t count, void* data) { static const char module[] = "TIFFResetField"; /* const TIFFField* fip = NULL; */ - uint16 dircount; + uint16_t dircount; tmsize_t dirsize; - uint8 direntry_raw[20]; - uint16 entry_tag = 0; - uint16 entry_type = 0; - uint64 entry_count = 0; - uint64 entry_offset = 0; + uint8_t direntry_raw[20]; + uint16_t entry_tag = 0; + uint16_t entry_type = 0; + uint64_t entry_count = 0; + uint64_t entry_offset = 0; int value_in_entry = 0; - uint64 read_offset; - uint8 *buf_to_write = NULL; + uint64_t read_offset; + uint8_t *buf_to_write = NULL; TIFFDataType datatype; /* -------------------------------------------------------------------- */ @@ -3355,7 +3345,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, if (!(tif->tif_flags&TIFF_BIGTIFF)) { - if (!ReadOK(tif, &dircount, sizeof (uint16))) { + if (!ReadOK(tif, &dircount, sizeof (uint16_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Can not read TIFF directory count", tif->tif_name); @@ -3366,8 +3356,8 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, dirsize = 12; read_offset += 2; } else { - uint64 dircount64; - if (!ReadOK(tif, &dircount64, sizeof (uint64))) { + uint64_t dircount64; + if (!ReadOK(tif, &dircount64, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Can not read TIFF directory count", tif->tif_name); @@ -3375,7 +3365,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&dircount64); - dircount = (uint16)dircount64; + dircount = (uint16_t)dircount64; dirsize = 20; read_offset += 8; } @@ -3392,7 +3382,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, return 0; } - memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16) ); + memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort( &entry_tag ); @@ -3405,7 +3395,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, if( entry_tag != tag ) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Could not find tag %d.", + "%s: Could not find tag %"PRIu16".", tif->tif_name, tag ); return 0; } @@ -3413,31 +3403,31 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* -------------------------------------------------------------------- */ /* Extract the type, count and offset for this entry. */ /* -------------------------------------------------------------------- */ - memcpy( &entry_type, direntry_raw + 2, sizeof(uint16) ); + memcpy( &entry_type, direntry_raw + 2, sizeof(uint16_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort( &entry_type ); if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 value; + uint32_t value; - memcpy( &value, direntry_raw + 4, sizeof(uint32) ); + memcpy( &value, direntry_raw + 4, sizeof(uint32_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong( &value ); entry_count = value; - memcpy( &value, direntry_raw + 8, sizeof(uint32) ); + memcpy( &value, direntry_raw + 8, sizeof(uint32_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong( &value ); entry_offset = value; } else { - memcpy( &entry_count, direntry_raw + 4, sizeof(uint64) ); + memcpy( &entry_count, direntry_raw + 4, sizeof(uint64_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8( &entry_count ); - memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64) ); + memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8( &entry_offset ); } @@ -3524,8 +3514,8 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* swabbing as needed. */ /* -------------------------------------------------------------------- */ buf_to_write = - (uint8 *)_TIFFCheckMalloc(tif, count, TIFFDataWidth(datatype), - "for field buffer."); + (uint8_t *)_TIFFCheckMalloc(tif, count, TIFFDataWidth(datatype), + "for field buffer."); if (!buf_to_write) return 0; @@ -3537,9 +3527,9 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, for( i = 0; i < count; i++ ) { - ((int32 *) buf_to_write)[i] = - (int32) ((int64 *) data)[i]; - if( (int64) ((int32 *) buf_to_write)[i] != ((int64 *) data)[i] ) + ((int32_t *) buf_to_write)[i] = + (int32_t) ((int64_t *) data)[i]; + if((int64_t) ((int32_t *) buf_to_write)[i] != ((int64_t *) data)[i] ) { _TIFFfree( buf_to_write ); TIFFErrorExt( tif->tif_clientdata, module, @@ -3555,9 +3545,9 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, for( i = 0; i < count; i++ ) { - ((uint32 *) buf_to_write)[i] = - (uint32) ((uint64 *) data)[i]; - if( (uint64) ((uint32 *) buf_to_write)[i] != ((uint64 *) data)[i] ) + ((uint32_t *) buf_to_write)[i] = + (uint32_t) ((uint64_t *) data)[i]; + if((uint64_t) ((uint32_t *) buf_to_write)[i] != ((uint64_t *) data)[i] ) { _TIFFfree( buf_to_write ); TIFFErrorExt( tif->tif_clientdata, module, @@ -3572,9 +3562,9 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, for( i = 0; i < count; i++ ) { - ((uint16 *) buf_to_write)[i] = - (uint16) ((uint64 *) data)[i]; - if( (uint64) ((uint16 *) buf_to_write)[i] != ((uint64 *) data)[i] ) + ((uint16_t *) buf_to_write)[i] = + (uint16_t) ((uint64_t *) data)[i]; + if((uint64_t) ((uint16_t *) buf_to_write)[i] != ((uint64_t *) data)[i] ) { _TIFFfree( buf_to_write ); TIFFErrorExt( tif->tif_clientdata, module, @@ -3593,11 +3583,11 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, if( TIFFDataWidth(datatype) > 1 && (tif->tif_flags&TIFF_SWAB) ) { if( TIFFDataWidth(datatype) == 2 ) - TIFFSwabArrayOfShort( (uint16 *) buf_to_write, count ); + TIFFSwabArrayOfShort((uint16_t *) buf_to_write, count ); else if( TIFFDataWidth(datatype) == 4 ) - TIFFSwabArrayOfLong( (uint32 *) buf_to_write, count ); + TIFFSwabArrayOfLong((uint32_t *) buf_to_write, count ); else if( TIFFDataWidth(datatype) == 8 ) - TIFFSwabArrayOfLong8( (uint64 *) buf_to_write, count ); + TIFFSwabArrayOfLong8((uint64_t *) buf_to_write, count ); } /* -------------------------------------------------------------------- */ @@ -3642,7 +3632,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* over the old values without altering the directory entry at */ /* all. */ /* -------------------------------------------------------------------- */ - if( entry_count == (uint64)count && entry_type == (uint16) datatype ) + if( entry_count == (uint64_t)count && entry_type == (uint16_t) datatype ) { if (!SeekOK(tif, entry_offset)) { _TIFFfree( buf_to_write ); @@ -3688,34 +3678,34 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* Adjust the directory entry. */ /* -------------------------------------------------------------------- */ entry_type = datatype; - entry_count = (uint64)count; - memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) ); + entry_count = (uint64_t)count; + memcpy( direntry_raw + 2, &entry_type, sizeof(uint16_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort( (uint16 *) (direntry_raw + 2) ); + TIFFSwabShort( (uint16_t *) (direntry_raw + 2) ); if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 value; + uint32_t value; - value = (uint32) entry_count; - memcpy( direntry_raw + 4, &value, sizeof(uint32) ); + value = (uint32_t) entry_count; + memcpy( direntry_raw + 4, &value, sizeof(uint32_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong( (uint32 *) (direntry_raw + 4) ); + TIFFSwabLong( (uint32_t *) (direntry_raw + 4) ); - value = (uint32) entry_offset; - memcpy( direntry_raw + 8, &value, sizeof(uint32) ); + value = (uint32_t) entry_offset; + memcpy( direntry_raw + 8, &value, sizeof(uint32_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong( (uint32 *) (direntry_raw + 8) ); + TIFFSwabLong( (uint32_t *) (direntry_raw + 8) ); } else { - memcpy( direntry_raw + 4, &entry_count, sizeof(uint64) ); + memcpy( direntry_raw + 4, &entry_count, sizeof(uint64_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8( (uint64 *) (direntry_raw + 4) ); + TIFFSwabLong8( (uint64_t *) (direntry_raw + 4) ); - memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64) ); + memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8( (uint64 *) (direntry_raw + 12) ); + TIFFSwabLong8( (uint64_t *) (direntry_raw + 12) ); } /* -------------------------------------------------------------------- */ diff --git a/tiff/libtiff/tif_dumpmode.c b/tiff/libtiff/tif_dumpmode.c index 4a0b07f5..f1d3c4ad 100644 --- a/tiff/libtiff/tif_dumpmode.c +++ b/tiff/libtiff/tif_dumpmode.c @@ -40,7 +40,7 @@ DumpFixupTags(TIFF* tif) * Encode a hunk of pixels. */ static int -DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +DumpModeEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) s; while (cc > 0) { @@ -73,24 +73,16 @@ DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) * Decode a hunk of pixels. */ static int -DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +DumpModeDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { static const char module[] = "DumpModeDecode"; (void) s; if (tif->tif_rawcc < cc) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, -"Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes", - (unsigned long) tif->tif_row, - (signed __int64) tif->tif_rawcc, - (signed __int64) cc); -#else - TIFFErrorExt(tif->tif_clientdata, module, -"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes", - (unsigned long) tif->tif_row, - (signed long long) tif->tif_rawcc, - (signed long long) cc); -#endif +"Not enough data for scanline %"PRIu32", expected a request for at most %"TIFF_SSIZE_FORMAT" bytes, got a request for %"TIFF_SSIZE_FORMAT" bytes", + tif->tif_row, + tif->tif_rawcc, + cc); return (0); } /* @@ -108,7 +100,7 @@ DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * Seek forwards nrows in the current strip. */ static int -DumpModeSeek(TIFF* tif, uint32 nrows) +DumpModeSeek(TIFF* tif, uint32_t nrows) { tif->tif_rawcp += nrows * tif->tif_scanlinesize; tif->tif_rawcc -= nrows * tif->tif_scanlinesize; diff --git a/tiff/libtiff/tif_extension.c b/tiff/libtiff/tif_extension.c index 87d3cfcb..9d46d3ea 100644 --- a/tiff/libtiff/tif_extension.c +++ b/tiff/libtiff/tif_extension.c @@ -39,13 +39,13 @@ int TIFFGetTagListCount( TIFF *tif ) return td->td_customValueCount; } -uint32 TIFFGetTagListEntry( TIFF *tif, int tag_index ) +uint32_t TIFFGetTagListEntry(TIFF *tif, int tag_index ) { TIFFDirectory* td = &tif->tif_dir; if( tag_index < 0 || tag_index >= td->td_customValueCount ) - return (uint32)(-1); + return (uint32_t)(-1); else return td->td_customValues[tag_index].info->field_tag; } diff --git a/tiff/libtiff/tif_fax3.c b/tiff/libtiff/tif_fax3.c index 9ab5b26a..f68e83a2 100644 --- a/tiff/libtiff/tif_fax3.c +++ b/tiff/libtiff/tif_fax3.c @@ -49,12 +49,12 @@ typedef struct { int rw_mode; /* O_RDONLY for decode, else encode */ int mode; /* operating mode */ tmsize_t rowbytes; /* bytes in a decoded scanline */ - uint32 rowpixels; /* pixels in a scanline */ + uint32_t rowpixels; /* pixels in a scanline */ - uint16 cleanfaxdata; /* CleanFaxData tag */ - uint32 badfaxrun; /* BadFaxRun tag */ - uint32 badfaxlines; /* BadFaxLines tag */ - uint32 groupoptions; /* Group 3/4 options tag */ + uint16_t cleanfaxdata; /* CleanFaxData tag */ + uint32_t badfaxrun; /* BadFaxRun tag */ + uint32_t badfaxlines; /* BadFaxLines tag */ + uint32_t groupoptions; /* Group 3/4 options tag */ TIFFVGetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ @@ -68,14 +68,14 @@ typedef struct { /* Decoder state info */ const unsigned char* bitmap; /* bit reversal table */ - uint32 data; /* current i/o byte/word */ + uint32_t data; /* current i/o byte/word */ int bit; /* current i/o bit in byte */ int EOLcnt; /* count of EOL codes recognized */ TIFFFaxFillFunc fill; /* fill routine */ - uint32* runs; /* b&w runs for current/previous row */ - uint32 nruns; /* size of the refruns / curruns arrays */ - uint32* refruns; /* runs for reference line */ - uint32* curruns; /* runs for current line */ + uint32_t* runs; /* b&w runs for current/previous row */ + uint32_t nruns; /* size of the refruns / curruns arrays */ + uint32_t* refruns; /* runs for reference line */ + uint32_t* curruns; /* runs for current line */ /* Encoder state info */ Ttag tag; /* encoding state */ @@ -104,20 +104,20 @@ typedef struct { Fax3CodecState* sp = DecoderState(tif); \ int a0; /* reference element */ \ int lastx = sp->b.rowpixels; /* last element in row */ \ - uint32 BitAcc; /* bit accumulator */ \ + uint32_t BitAcc; /* bit accumulator */ \ int BitsAvail; /* # valid bits in BitAcc */ \ int RunLength; /* length of current run */ \ unsigned char* cp; /* next byte of input data */ \ unsigned char* ep; /* end of input data */ \ - uint32* pa; /* place to stuff next run */ \ - uint32* thisrun; /* current row's run array */ \ + uint32_t* pa; /* place to stuff next run */ \ + uint32_t* thisrun; /* current row's run array */ \ int EOLcnt; /* # EOL codes recognized */ \ const unsigned char* bitmap = sp->bitmap; /* input data bit reverser */ \ const TIFFFaxTabEnt* TabEnt #define DECLARE_STATE_2D(tif, sp, mod) \ DECLARE_STATE(tif, sp, mod); \ int b1; /* next change on prev line */ \ - uint32* pb /* next run in reference line */\ + uint32_t* pb /* next run in reference line */\ /* * Load any state that may be changed during decoding. */ @@ -135,15 +135,15 @@ typedef struct { sp->bit = BitsAvail; \ sp->data = BitAcc; \ sp->EOLcnt = EOLcnt; \ - tif->tif_rawcc -= (tmsize_t)((uint8*) cp - tif->tif_rawcp); \ - tif->tif_rawcp = (uint8*) cp; \ + tif->tif_rawcc -= (tmsize_t)((uint8_t*) cp - tif->tif_rawcp); \ + tif->tif_rawcp = (uint8_t*) cp; \ } while (0) /* * Setup state for decoding a strip. */ static int -Fax3PreDecode(TIFF* tif, uint16 s) +Fax3PreDecode(TIFF* tif, uint16_t s) { Fax3CodecState* sp = DecoderState(tif); @@ -164,7 +164,7 @@ Fax3PreDecode(TIFF* tif, uint16 s) sp->curruns = sp->runs; if (sp->refruns) { /* init reference line to white */ sp->refruns = sp->runs + sp->nruns; - sp->refruns[0] = (uint32) sp->b.rowpixels; + sp->refruns[0] = (uint32_t) sp->b.rowpixels; sp->refruns[1] = 0; } sp->line = 0; @@ -178,9 +178,9 @@ Fax3PreDecode(TIFF* tif, uint16 s) */ static void -Fax3Unexpected(const char* module, TIFF* tif, uint32 line, uint32 a0) +Fax3Unexpected(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { - TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %u of %s %u (x %u)", + TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -188,10 +188,10 @@ Fax3Unexpected(const char* module, TIFF* tif, uint32 line, uint32 a0) #define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0) static void -Fax3Extension(const char* module, TIFF* tif, uint32 line, uint32 a0) +Fax3Extension(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { TIFFErrorExt(tif->tif_clientdata, module, - "Uncompressed data (not supported) at line %u of %s %u (x %u)", + "Uncompressed data (not supported) at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -199,9 +199,9 @@ Fax3Extension(const char* module, TIFF* tif, uint32 line, uint32 a0) #define extension(a0) Fax3Extension(module, tif, sp->line, a0) static void -Fax3BadLength(const char* module, TIFF* tif, uint32 line, uint32 a0, uint32 lastx) +Fax3BadLength(const char* module, TIFF* tif, uint32_t line, uint32_t a0, uint32_t lastx) { - TIFFWarningExt(tif->tif_clientdata, module, "%s at line %u of %s %u (got %u, expected %u)", + TIFFWarningExt(tif->tif_clientdata, module, "%s at line %"PRIu32" of %s %"PRIu32" (got %"PRIu32", expected %"PRIu32")", a0 < lastx ? "Premature EOL" : "Line length mismatch", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), @@ -210,9 +210,9 @@ Fax3BadLength(const char* module, TIFF* tif, uint32 line, uint32 a0, uint32 last #define badlength(a0,lastx) Fax3BadLength(module, tif, sp->line, a0, lastx) static void -Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) +Fax3PrematureEOF(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { - TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %u of %s %u (x %u)", + TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -229,7 +229,7 @@ Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) * @returns 1 for success, -1 in case of error */ static int -Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +Fax3Decode1D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { DECLARE_STATE(tif, sp, "Fax3Decode1D"); (void) s; @@ -245,8 +245,8 @@ Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) RunLength = 0; pa = thisrun; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %"PRIu32"\n", tif->tif_row); fflush(stdout); #endif SYNC_EOL(EOF1D); @@ -272,7 +272,7 @@ Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) * Decode the requested amount of G3 2D-encoded data. */ static int -Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +Fax3Decode2D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); int is1D; /* current line is 1d/2d-encoded */ @@ -288,7 +288,7 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) RunLength = 0; pa = thisrun = sp->curruns; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d", + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d EOLcnt = %d", BitAcc, BitsAvail, EOLcnt); #endif SYNC_EOL(EOF2D); @@ -296,7 +296,7 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) is1D = GetBits(1); /* 1D/2D-encoding tag bit */ ClrBits(1); #ifdef FAX3_DEBUG - printf(" %s\n-------------------- %d\n", + printf(" %s\n-------------------- %"PRIu32"\n", is1D ? "1D" : "2D", tif->tif_row); fflush(stdout); #endif @@ -310,7 +310,7 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) if (pa < thisrun + sp->nruns) { SETVALUE(0); /* imaginary change for reference */ } - SWAP(uint32*, sp->curruns, sp->refruns); + SWAP(uint32_t*, sp->curruns, sp->refruns); buf += sp->b.rowbytes; occ -= sp->b.rowbytes; sp->line++; @@ -327,89 +327,38 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) } #undef SWAP -/* - * The ZERO & FILL macros must handle spans < 2*sizeof(long) bytes. - * For machines with 64-bit longs this is <16 bytes; otherwise - * this is <8 bytes. We optimize the code here to reflect the - * machine characteristics. - */ -#if SIZEOF_UNSIGNED_LONG == 8 -# define FILL(n, cp) \ - switch (n) { \ - case 15:(cp)[14] = 0xff; /*-fallthrough*/ \ - case 14:(cp)[13] = 0xff; /*-fallthrough*/ \ - case 13:(cp)[12] = 0xff; /*-fallthrough*/ \ - case 12:(cp)[11] = 0xff; /*-fallthrough*/ \ - case 11:(cp)[10] = 0xff; /*-fallthrough*/ \ - case 10: (cp)[9] = 0xff; /*-fallthrough*/ \ - case 9: (cp)[8] = 0xff; /*-fallthrough*/ \ - case 8: (cp)[7] = 0xff; /*-fallthrough*/ \ - case 7: (cp)[6] = 0xff; /*-fallthrough*/ \ - case 6: (cp)[5] = 0xff; /*-fallthrough*/ \ - case 5: (cp)[4] = 0xff; /*-fallthrough*/ \ - case 4: (cp)[3] = 0xff; /*-fallthrough*/ \ - case 3: (cp)[2] = 0xff; /*-fallthrough*/ \ - case 2: (cp)[1] = 0xff; /*-fallthrough*/ \ - case 1: (cp)[0] = 0xff; (cp) += (n); /*-fallthrough*/ \ - case 0: ; \ - } -# define ZERO(n, cp) \ - switch (n) { \ - case 15:(cp)[14] = 0; /*-fallthrough*/ \ - case 14:(cp)[13] = 0; /*-fallthrough*/ \ - case 13:(cp)[12] = 0; /*-fallthrough*/ \ - case 12:(cp)[11] = 0; /*-fallthrough*/ \ - case 11:(cp)[10] = 0; /*-fallthrough*/ \ - case 10: (cp)[9] = 0; /*-fallthrough*/ \ - case 9: (cp)[8] = 0; /*-fallthrough*/ \ - case 8: (cp)[7] = 0; /*-fallthrough*/ \ - case 7: (cp)[6] = 0; /*-fallthrough*/ \ - case 6: (cp)[5] = 0; /*-fallthrough*/ \ - case 5: (cp)[4] = 0; /*-fallthrough*/ \ - case 4: (cp)[3] = 0; /*-fallthrough*/ \ - case 3: (cp)[2] = 0; /*-fallthrough*/ \ - case 2: (cp)[1] = 0; /*-fallthrough*/ \ - case 1: (cp)[0] = 0; (cp) += (n); /*-fallthrough*/ \ - case 0: ; \ +# define FILL(n, cp) \ + { \ + int32_t ifill;\ + for (ifill = 0; ifill < (n); ++ifill) \ + { \ + (cp)[ifill] = 0xff; \ + } \ + (cp) += (n);\ } -#else -# define FILL(n, cp) \ - switch (n) { \ - case 7: (cp)[6] = 0xff; /*-fallthrough*/ \ - case 6: (cp)[5] = 0xff; /*-fallthrough*/ \ - case 5: (cp)[4] = 0xff; /*-fallthrough*/ \ - case 4: (cp)[3] = 0xff; /*-fallthrough*/ \ - case 3: (cp)[2] = 0xff; /*-fallthrough*/ \ - case 2: (cp)[1] = 0xff; /*-fallthrough*/ \ - case 1: (cp)[0] = 0xff; (cp) += (n); /*-fallthrough*/ \ - case 0: ; \ - } -# define ZERO(n, cp) \ - switch (n) { \ - case 7: (cp)[6] = 0; /*-fallthrough*/ \ - case 6: (cp)[5] = 0; /*-fallthrough*/ \ - case 5: (cp)[4] = 0; /*-fallthrough*/ \ - case 4: (cp)[3] = 0; /*-fallthrough*/ \ - case 3: (cp)[2] = 0; /*-fallthrough*/ \ - case 2: (cp)[1] = 0; /*-fallthrough*/ \ - case 1: (cp)[0] = 0; (cp) += (n); /*-fallthrough*/ \ - case 0: ; \ - } -#endif +# define ZERO(n, cp) \ + {\ + int32_t izero; \ + for (izero = 0; izero < (n); ++izero) \ + { \ + (cp)[izero] = 0; \ + } \ + (cp) += (n);\ + } /* * Bit-fill a row according to the white/black * runs generated during G3/G4 decoding. */ void -_TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) +_TIFFFax3fillruns(unsigned char* buf, uint32_t* runs, uint32_t* erun, uint32_t lastx) { static const unsigned char _fillmasks[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; unsigned char* cp; - uint32 x, bx, run; - int32 n, nw; - long* lp; + uint32_t x, bx, run; + int32_t n, nw; + int64_t* lp; if ((erun-runs)&1) *erun++ = 0; @@ -417,7 +366,7 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) for (; runs < erun; runs += 2) { run = runs[0]; if (x+run > lastx || run > lastx ) - run = runs[0] = (uint32) (lastx - x); + run = runs[0] = (uint32_t) (lastx - x); if (run) { cp = buf + (x>>3); bx = x&7; @@ -427,15 +376,15 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) run -= 8-bx; } if( (n = run >> 3) != 0 ) { /* multiple bytes to fill */ - if ((n/sizeof (long)) > 1) { + if ((n/sizeof (int64_t)) > 1) { /* - * Align to longword boundary and fill. + * Align to int64_tword boundary and fill. */ - for (; n && !isAligned(cp, long); n--) + for (; n && !isAligned(cp, int64_t); n--) *cp++ = 0x00; - lp = (long*) cp; - nw = (int32)(n / sizeof (long)); - n -= nw * sizeof (long); + lp = (int64_t*) cp; + nw = (int32_t)(n / sizeof (int64_t)); + n -= nw * sizeof (int64_t); do { *lp++ = 0L; } while (--nw); @@ -462,15 +411,15 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) run -= 8-bx; } if( (n = run>>3) != 0 ) { /* multiple bytes to fill */ - if ((n/sizeof (long)) > 1) { + if ((n/sizeof (int64_t)) > 1) { /* - * Align to longword boundary and fill. + * Align to int64_t boundary and fill. */ - for (; n && !isAligned(cp, long); n--) + for (; n && !isAligned(cp, int64_t); n--) *cp++ = 0xff; - lp = (long*) cp; - nw = (int32)(n / sizeof (long)); - n -= nw * sizeof (long); + lp = (int64_t*) cp; + nw = (int32_t)(n / sizeof (int64_t)); + n -= nw * sizeof (int64_t); do { *lp++ = -1L; } while (--nw); @@ -515,7 +464,7 @@ Fax3SetupState(TIFF* tif) int needsRefLine; Fax3CodecState* dsp = (Fax3CodecState*) Fax3State(tif); tmsize_t rowbytes; - uint32 rowpixels; + uint32_t rowpixels; if (td->td_bitspersample != 1) { TIFFErrorExt(tif->tif_clientdata, module, @@ -532,11 +481,11 @@ Fax3SetupState(TIFF* tif) rowbytes = TIFFScanlineSize(tif); rowpixels = td->td_imagewidth; } - if ((uint64)rowbytes < ((uint64)rowpixels + 7) / 8) + if ((int64_t)rowbytes < ((int64_t)rowpixels + 7) / 8) { TIFFErrorExt(tif->tif_clientdata, module, - "Inconsistent number of bytes per row : rowbytes=%lu rowpixels=%lu", - (unsigned long)(rowbytes), (unsigned long)(rowpixels)); + "Inconsistent number of bytes per row : rowbytes=%" PRId64 " rowpixels=%" PRIu32, + (int64_t) rowbytes, rowpixels); return (0); } sp->rowbytes = rowbytes; @@ -554,24 +503,24 @@ Fax3SetupState(TIFF* tif) TIFFroundup and TIFFSafeMultiply return zero on integer overflow */ - dsp->runs=(uint32*) NULL; + dsp->runs=(uint32_t*) NULL; dsp->nruns = TIFFroundup_32(rowpixels,32); if (needsRefLine) { - dsp->nruns = TIFFSafeMultiply(uint32,dsp->nruns,2); + dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2); } - if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32,dsp->nruns,2) == 0)) { + if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32_t, dsp->nruns, 2) == 0)) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Row pixels integer overflow (rowpixels %u)", + "Row pixels integer overflow (rowpixels %"PRIu32")", rowpixels); return (0); } - dsp->runs = (uint32*) _TIFFCheckMalloc(tif, - TIFFSafeMultiply(uint32,dsp->nruns,2), - sizeof (uint32), - "for Group 3/4 run arrays"); + dsp->runs = (uint32_t*) _TIFFCheckMalloc(tif, + TIFFSafeMultiply(uint32_t, dsp->nruns, 2), + sizeof (uint32_t), + "for Group 3/4 run arrays"); if (dsp->runs == NULL) return (0); - memset( dsp->runs, 0, TIFFSafeMultiply(uint32,dsp->nruns,2)*sizeof(uint32)); + memset( dsp->runs, 0, TIFFSafeMultiply(uint32_t,dsp->nruns,2)*sizeof(uint32_t)); dsp->curruns = dsp->runs; if (needsRefLine) dsp->refruns = dsp->runs + dsp->nruns; @@ -614,7 +563,7 @@ Fax3SetupState(TIFF* tif) if( !TIFFFlushData1(tif) ) \ return 0; \ } \ - *(tif)->tif_rawcp++ = (uint8) (sp)->data; \ + *(tif)->tif_rawcp++ = (uint8_t) (sp)->data; \ (tif)->tif_rawcc++; \ (sp)->data = 0, (sp)->bit = 8; \ } @@ -623,7 +572,7 @@ Fax3SetupState(TIFF* tif) if( !TIFFFlushData1(tif) ) \ return 0; \ } \ - *(tif)->tif_rawcp++ = (uint8) data; \ + *(tif)->tif_rawcp++ = (uint8_t) data; \ (tif)->tif_rawcc++; \ data = 0, bit = 8; \ } @@ -670,7 +619,7 @@ Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length) #define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B") #define DEBUG_PRINT(what,len) { \ int t; \ - printf("%08X/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ + printf("%08"PRIX32"/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ for (t = length-1; t >= 0; t--) \ putchar(code & (1<<t) ? '1' : '0'); \ putchar('\n'); \ @@ -684,7 +633,7 @@ Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length) * terminating codes is supplied. */ static int -putspan(TIFF* tif, int32 span, const tableentry* tab) +putspan(TIFF* tif, int32_t span, const tableentry* tab) { Fax3CodecState* sp = EncoderState(tif); unsigned int bit = sp->bit; @@ -773,7 +722,7 @@ Fax3PutEOL(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -Fax3PreEncode(TIFF* tif, uint16 s) +Fax3PreEncode(TIFF* tif, uint16_t s) { Fax3CodecState* sp = EncoderState(tif); @@ -849,25 +798,15 @@ static const unsigned char oneruns[256] = { }; /* - * On certain systems it pays to inline - * the routines that find pixel spans. - */ -#ifdef VAXC -static int32 find0span(unsigned char*, int32, int32); -static int32 find1span(unsigned char*, int32, int32); -#pragma inline(find0span,find1span) -#endif - -/* * Find a span of ones or zeros using the supplied * table. The ``base'' of the bit string is supplied * along with the start+end bit indices. */ -inline static int32 -find0span(unsigned char* bp, int32 bs, int32 be) +static inline int32_t +find0span(unsigned char* bp, int32_t bs, int32_t be) { - int32 bits = be - bs; - int32 n, span; + int32_t bits = be - bs; + int32_t n, span; bp += bs>>3; /* @@ -885,22 +824,22 @@ find0span(unsigned char* bp, int32 bs, int32 be) bp++; } else span = 0; - if (bits >= (int32)(2 * 8 * sizeof(long))) { - long* lp; + if (bits >= (int32_t)(2 * 8 * sizeof(int64_t))) { + int64_t* lp; /* - * Align to longword boundary and check longwords. + * Align to int64_t boundary and check int64_t words. */ - while (!isAligned(bp, long)) { + while (!isAligned(bp, int64_t)) { if (*bp != 0x00) return (span + zeroruns[*bp]); span += 8; bits -= 8; bp++; } - lp = (long*) bp; - while ((bits >= (int32)(8 * sizeof(long))) && (0 == *lp)) { - span += 8*sizeof (long); - bits -= 8*sizeof (long); + lp = (int64_t*) bp; + while ((bits >= (int32_t)(8 * sizeof(int64_t))) && (0 == *lp)) { + span += 8*sizeof (int64_t); + bits -= 8*sizeof (int64_t); lp++; } bp = (unsigned char*) lp; @@ -925,11 +864,11 @@ find0span(unsigned char* bp, int32 bs, int32 be) return (span); } -inline static int32 -find1span(unsigned char* bp, int32 bs, int32 be) +static inline int32_t +find1span(unsigned char* bp, int32_t bs, int32_t be) { - int32 bits = be - bs; - int32 n, span; + int32_t bits = be - bs; + int32_t n, span; bp += bs>>3; /* @@ -947,22 +886,22 @@ find1span(unsigned char* bp, int32 bs, int32 be) bp++; } else span = 0; - if (bits >= (int32)(2 * 8 * sizeof(long))) { - long* lp; + if (bits >= (int32_t)(2 * 8 * sizeof(int64_t))) { + int64_t* lp; /* - * Align to longword boundary and check longwords. + * Align to int64_t boundary and check int64_t words. */ - while (!isAligned(bp, long)) { + while (!isAligned(bp, int64_t)) { if (*bp != 0xff) return (span + oneruns[*bp]); span += 8; bits -= 8; bp++; } - lp = (long*) bp; - while ((bits >= (int32)(8 * sizeof(long))) && (~0 == *lp)) { - span += 8*sizeof (long); - bits -= 8*sizeof (long); + lp = (int64_t*) bp; + while ((bits >= (int32_t)(8 * sizeof(int64_t))) && (~((uint64_t)0) == (uint64_t)*lp)) { + span += 8*sizeof (int64_t); + bits -= 8*sizeof (int64_t); lp++; } bp = (unsigned char*) lp; @@ -1008,11 +947,11 @@ find1span(unsigned char* bp, int32 bs, int32 be) * of pixels encoded with Huffman codes. */ static int -Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32 bits) +Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32_t bits) { Fax3CodecState* sp = EncoderState(tif); - int32 span; - uint32 bs = 0; + int32_t span; + uint32_t bs = 0; for (;;) { span = find0span(bp, bs, bits); /* white span */ @@ -1032,7 +971,7 @@ Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32 bits) if (sp->bit != 8) /* byte-align */ Fax3FlushBits(tif, sp); if ((sp->b.mode&FAXMODE_WORDALIGN) && - !isAligned(tif->tif_rawcp, uint16)) + !isAligned(tif->tif_rawcp, uint16_t)) Fax3FlushBits(tif, sp); } return (1); @@ -1057,22 +996,22 @@ static const tableentry vcodes[7] = { * documentation for the algorithm. */ static int -Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits) +Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32_t bits) { #define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1) - uint32 a0 = 0; - uint32 a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0)); - uint32 b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0)); - uint32 a2, b2; + uint32_t a0 = 0; + uint32_t a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0)); + uint32_t b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0)); + uint32_t a2, b2; for (;;) { b2 = finddiff2(rp, b1, bits, PIXEL(rp,b1)); if (b2 >= a1) { /* Naive computation triggers -fsanitize=undefined,unsigned-integer-overflow */ /* although it is correct unless the difference between both is < 31 bit */ - /* int32 d = b1 - a1; */ - int32 d = (b1 >= a1 && b1 - a1 <= 3U) ? (int32)(b1 - a1): - (b1 < a1 && a1 - b1 <= 3U) ? -(int32)(a1 - b1) : 0x7FFFFFFF; + /* int32_t d = b1 - a1; */ + int32_t d = (b1 >= a1 && b1 - a1 <= 3U) ? (int32_t)(b1 - a1) : + (b1 < a1 && a1 - b1 <= 3U) ? -(int32_t)(a1 - b1) : 0x7FFFFFFF; if (!(-3 <= d && d <= 3)) { /* horizontal mode */ a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1)); if( !putcode(tif, &horizcode) ) @@ -1113,7 +1052,7 @@ Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits) * Encode a buffer of pixels. */ static int -Fax3Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +Fax3Encode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "Fax3Encode"; Fax3CodecState* sp = EncoderState(tif); @@ -1233,7 +1172,7 @@ static const TIFFField fax4Fields[] = { }; static int -Fax3VSetField(TIFF* tif, uint32 tag, va_list ap) +Fax3VSetField(TIFF* tif, uint32_t tag, va_list ap) { Fax3BaseState* sp = Fax3State(tif); const TIFFField* fip; @@ -1251,21 +1190,21 @@ Fax3VSetField(TIFF* tif, uint32 tag, va_list ap) case TIFFTAG_GROUP3OPTIONS: /* XXX: avoid reading options if compression mismatches. */ if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3) - sp->groupoptions = (uint32) va_arg(ap, uint32); + sp->groupoptions = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_GROUP4OPTIONS: /* XXX: avoid reading options if compression mismatches. */ if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) - sp->groupoptions = (uint32) va_arg(ap, uint32); + sp->groupoptions = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_BADFAXLINES: - sp->badfaxlines = (uint32) va_arg(ap, uint32); + sp->badfaxlines = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_CLEANFAXDATA: - sp->cleanfaxdata = (uint16) va_arg(ap, uint16_vap); + sp->cleanfaxdata = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_CONSECUTIVEBADFAXLINES: - sp->badfaxrun = (uint32) va_arg(ap, uint32); + sp->badfaxrun = (uint32_t) va_arg(ap, uint32_t); break; default: return (*sp->vsetparent)(tif, tag, ap); @@ -1281,7 +1220,7 @@ Fax3VSetField(TIFF* tif, uint32 tag, va_list ap) } static int -Fax3VGetField(TIFF* tif, uint32 tag, va_list ap) +Fax3VGetField(TIFF* tif, uint32_t tag, va_list ap) { Fax3BaseState* sp = Fax3State(tif); @@ -1296,16 +1235,16 @@ Fax3VGetField(TIFF* tif, uint32 tag, va_list ap) break; case TIFFTAG_GROUP3OPTIONS: case TIFFTAG_GROUP4OPTIONS: - *va_arg(ap, uint32*) = sp->groupoptions; + *va_arg(ap, uint32_t*) = sp->groupoptions; break; case TIFFTAG_BADFAXLINES: - *va_arg(ap, uint32*) = sp->badfaxlines; + *va_arg(ap, uint32_t*) = sp->badfaxlines; break; case TIFFTAG_CLEANFAXDATA: - *va_arg(ap, uint16*) = sp->cleanfaxdata; + *va_arg(ap, uint16_t*) = sp->cleanfaxdata; break; case TIFFTAG_CONSECUTIVEBADFAXLINES: - *va_arg(ap, uint32*) = sp->badfaxrun; + *va_arg(ap, uint32_t*) = sp->badfaxrun; break; default: return (*sp->vgetparent)(tif, tag, ap); @@ -1341,9 +1280,9 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags) if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) fprintf(fd, "%suncompressed data", sep); } - fprintf(fd, " (%lu = 0x%lx)\n", - (unsigned long) sp->groupoptions, - (unsigned long) sp->groupoptions); + fprintf(fd, " (%" PRIu32 " = 0x%" PRIx32 ")\n", + sp->groupoptions, + sp->groupoptions); } if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) { fprintf(fd, " Fax Data:"); @@ -1358,15 +1297,15 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags) fprintf(fd, " uncorrected errors"); break; } - fprintf(fd, " (%u = 0x%x)\n", + fprintf(fd, " (%"PRIu16" = 0x%"PRIx16")\n", sp->cleanfaxdata, sp->cleanfaxdata); } if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) - fprintf(fd, " Bad Fax Lines: %lu\n", - (unsigned long) sp->badfaxlines); + fprintf(fd, " Bad Fax Lines: %" PRIu32 "\n", + sp->badfaxlines); if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) - fprintf(fd, " Consecutive Bad Fax Lines: %lu\n", - (unsigned long) sp->badfaxrun); + fprintf(fd, " Consecutive Bad Fax Lines: %" PRIu32 "\n", + sp->badfaxrun); if (sp->printdir) (*sp->printdir)(tif, fd, flags); } @@ -1389,7 +1328,7 @@ InitCCITTFax3(TIFF* tif) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (Fax3CodecState)); if (tif->tif_data == NULL) { @@ -1473,7 +1412,7 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme) * Decode the requested amount of G4-encoded data. */ static int -Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { DECLARE_STATE_2D(tif, sp, "Fax4Decode"); (void) s; @@ -1490,7 +1429,7 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) pb = sp->refruns; b1 = *pb++; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); printf("-------------------- %d\n", tif->tif_row); fflush(stdout); #endif @@ -1500,13 +1439,13 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer overrun detected : %d bytes available, %d bits needed", - (int)occ, lastx); + "Buffer overrun detected : %"TIFF_SSIZE_FORMAT" bytes available, %d bits needed", + occ, lastx); return -1; } (*sp->fill)(buf, thisrun, pa, lastx); SETVALUE(0); /* imaginary change for reference */ - SWAP(uint32*, sp->curruns, sp->refruns); + SWAP(uint32_t*, sp->curruns, sp->refruns); buf += sp->b.rowbytes; occ -= sp->b.rowbytes; sp->line++; @@ -1522,8 +1461,8 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer overrun detected : %d bytes available, %d bits needed", - (int)occ, lastx); + "Buffer overrun detected : %"TIFF_SSIZE_FORMAT" bytes available, %d bits needed", + occ, lastx); return -1; } (*sp->fill)(buf, thisrun, pa, lastx); @@ -1539,7 +1478,7 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) * Encode the requested amount of data. */ static int -Fax4Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +Fax4Encode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "Fax4Encode"; Fax3CodecState *sp = EncoderState(tif); @@ -1611,7 +1550,7 @@ TIFFInitCCITTFax4(TIFF* tif, int scheme) * Decode the requested amount of RLE-encoded data. */ static int -Fax3DecodeRLE(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +Fax3DecodeRLE(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); int mode = sp->b.mode; @@ -1628,8 +1567,8 @@ Fax3DecodeRLE(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) RunLength = 0; pa = thisrun; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %"PRIu32"\n", tif->tif_row); fflush(stdout); #endif EXPAND1D(EOFRLE); @@ -1643,7 +1582,7 @@ Fax3DecodeRLE(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) } else if (mode & FAXMODE_WORDALIGN) { int n = BitsAvail - (BitsAvail &~ 15); ClrBits(n); - if (BitsAvail == 0 && !isAligned(cp, uint16)) + if (BitsAvail == 0 && !isAligned(cp, uint16_t)) cp++; } buf += sp->b.rowbytes; diff --git a/tiff/libtiff/tif_fax3.h b/tiff/libtiff/tif_fax3.h index 701716cc..fdafe492 100644 --- a/tiff/libtiff/tif_fax3.h +++ b/tiff/libtiff/tif_fax3.h @@ -41,7 +41,7 @@ * The routine must have the type signature given below; * for example: * - * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) + * fillruns(unsigned char* buf, uint32_t* runs, uint32_t* erun, uint32_t lastx) * * where buf is place to set the bits, runs is the array of b&w run * lengths (white then black), erun is the last run in the array, and @@ -50,7 +50,7 @@ * data in the run array as needed (e.g. to append zero runs to bring * the count up to a nice multiple). */ -typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); +typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32_t*, uint32_t*, uint32_t); /* * The default run filler; made external for other decoders. @@ -58,7 +58,7 @@ typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); #if defined(__cplusplus) extern "C" { #endif -extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); +extern void _TIFFFax3fillruns(unsigned char*, uint32_t*, uint32_t*, uint32_t); #if defined(__cplusplus) } #endif @@ -84,7 +84,7 @@ extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); typedef struct { /* state table entry */ unsigned char State; /* see above */ unsigned char Width; /* width of code in bits */ - uint32 Param; /* unsigned 32-bit run length in bits (holds on 16 bit actually, but cannot be changed. See above warning) */ + uint32_t Param; /* unsigned 32-bit run length in bits (holds on 16 bit actually, but cannot be changed. See above warning) */ } TIFFFaxTabEnt; extern const TIFFFaxTabEnt TIFFFaxMainTable[]; @@ -141,7 +141,7 @@ extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; goto eoflab; \ BitsAvail = (n); /* pad with zeros */ \ } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ + BitAcc |= ((uint32_t) bitmap[*cp++])<<BitsAvail; \ BitsAvail += 8; \ } \ } \ @@ -155,13 +155,13 @@ extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; goto eoflab; \ BitsAvail = (n); /* pad with zeros */ \ } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ + BitAcc |= ((uint32_t) bitmap[*cp++])<<BitsAvail; \ if ((BitsAvail += 8) < (n)) { \ if (EndOfData()) { \ /* NB: we know BitsAvail is non-zero here */ \ BitsAvail = (n); /* pad with zeros */ \ } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ + BitAcc |= ((uint32_t) bitmap[*cp++])<<BitsAvail; \ BitsAvail += 8; \ } \ } \ diff --git a/tiff/libtiff/tif_getimage.c b/tiff/libtiff/tif_getimage.c index 3460af74..a1b6570b 100644 --- a/tiff/libtiff/tif_getimage.c +++ b/tiff/libtiff/tif_getimage.c @@ -31,10 +31,10 @@ #include <stdio.h> #include <limits.h> -static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); +static int gtTileContig(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); +static int gtTileSeparate(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); +static int gtStripContig(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); +static int gtStripSeparate(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); static int PickContigCase(TIFFRGBAImage*); static int PickSeparateCase(TIFFRGBAImage*); @@ -75,7 +75,7 @@ int TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) { TIFFDirectory* td = &tif->tif_dir; - uint16 photometric; + uint16_t photometric; int colorchannels; if (!tif->tif_decodestatus) { @@ -90,7 +90,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) case 16: break; default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + sprintf(emsg, "Sorry, can not handle images with %"PRIu16"-bit samples", td->td_bitspersample); return (0); } @@ -120,8 +120,8 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) && td->td_samplesperpixel != 1 && td->td_bitspersample < 8 ) { sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", + "Sorry, can not handle contiguous data with %s=%"PRIu16", " + "and %s=%"PRIu16" and Bits/Sample=%"PRIu16"", photoTag, photometric, "Samples/pixel", td->td_samplesperpixel, td->td_bitspersample); @@ -150,7 +150,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) break; case PHOTOMETRIC_SEPARATED: { - uint16 inkset; + uint16_t inkset; TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); if (inkset != INKSET_CMYK) { sprintf(emsg, @@ -160,7 +160,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) } if (td->td_samplesperpixel < 4) { sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", + "Sorry, can not handle separated image with %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel); return 0; } @@ -181,13 +181,13 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) return (0); } if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%"PRIu16, "Planarconfiguration", td->td_planarconfig); return (0); } if ( td->td_samplesperpixel != 3 || colorchannels != 3 ) { sprintf(emsg, - "Sorry, can not handle image with %s=%d, %s=%d", + "Sorry, can not handle image with %s=%"PRIu16", %s=%d", "Samples/pixel", td->td_samplesperpixel, "colorchannels", colorchannels); return 0; @@ -196,7 +196,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) case PHOTOMETRIC_CIELAB: if ( td->td_samplesperpixel != 3 || colorchannels != 3 || td->td_bitspersample != 8 ) { sprintf(emsg, - "Sorry, can not handle image with %s=%d, %s=%d and %s=%d", + "Sorry, can not handle image with %s=%"PRIu16", %s=%d and %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel, "colorchannels", colorchannels, "Bits/sample", td->td_bitspersample); @@ -204,7 +204,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) } break; default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", + sprintf(emsg, "Sorry, can not handle image with %s=%"PRIu16, photoTag, photometric); return (0); } @@ -254,7 +254,7 @@ TIFFRGBAImageEnd(TIFFRGBAImage* img) static int isCCITTCompression(TIFF* tif) { - uint16 compress; + uint16_t compress; TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); return (compress == COMPRESSION_CCITTFAX3 || compress == COMPRESSION_CCITTFAX4 || @@ -265,12 +265,12 @@ isCCITTCompression(TIFF* tif) int TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) { - uint16* sampleinfo; - uint16 extrasamples; - uint16 planarconfig; - uint16 compress; + uint16_t* sampleinfo; + uint16_t extrasamples; + uint16_t planarconfig; + uint16_t compress; int colorchannels; - uint16 *red_orig, *green_orig, *blue_orig; + uint16_t *red_orig, *green_orig, *blue_orig; int n_color; if( !TIFFRGBAImageOK(tif, emsg) ) @@ -302,7 +302,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) case 16: break; default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + sprintf(emsg, "Sorry, can not handle images with %"PRIu16"-bit samples", img->bitspersample); goto fail_return; } @@ -366,9 +366,9 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) /* copy the colormaps so we can modify them */ n_color = (1U << img->bitspersample); - img->redcmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->greencmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->bluecmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); + img->redcmap = (uint16_t *) _TIFFmalloc(sizeof(uint16_t) * n_color); + img->greencmap = (uint16_t *) _TIFFmalloc(sizeof(uint16_t) * n_color); + img->bluecmap = (uint16_t *) _TIFFmalloc(sizeof(uint16_t) * n_color); if( !img->redcmap || !img->greencmap || !img->bluecmap ) { sprintf(emsg, "Out of memory for colormap copy"); goto fail_return; @@ -385,8 +385,8 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) && img->samplesperpixel != 1 && img->bitspersample < 8 ) { sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", + "Sorry, can not handle contiguous data with %s=%"PRIu16", " + "and %s=%"PRIu16" and Bits/Sample=%"PRIu16, photoTag, img->photometric, "Samples/pixel", img->samplesperpixel, img->bitspersample); @@ -428,15 +428,15 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) break; case PHOTOMETRIC_SEPARATED: { - uint16 inkset; + uint16_t inkset; TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); if (inkset != INKSET_CMYK) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + sprintf(emsg, "Sorry, can not handle separated image with %s=%"PRIu16, "InkSet", inkset); goto fail_return; } if (img->samplesperpixel < 4) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + sprintf(emsg, "Sorry, can not handle separated image with %s=%"PRIu16, "Samples/pixel", img->samplesperpixel); goto fail_return; } @@ -459,7 +459,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) goto fail_return; } if (planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%"PRIu16, "Planarconfiguration", planarconfig); return (0); } @@ -470,7 +470,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) case PHOTOMETRIC_CIELAB: break; default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", + sprintf(emsg, "Sorry, can not handle image with %s=%"PRIu16, photoTag, img->photometric); goto fail_return; } @@ -498,7 +498,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) } int -TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +TIFFRGBAImageGet(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { if (img->get == NULL) { TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No \"get\" routine setup"); @@ -518,15 +518,15 @@ TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) */ int TIFFReadRGBAImageOriented(TIFF* tif, - uint32 rwidth, uint32 rheight, uint32* raster, - int orientation, int stop) + uint32_t rwidth, uint32_t rheight, uint32_t* raster, + int orientation, int stop) { char emsg[1024] = ""; TIFFRGBAImage img; int ok; if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) { - img.req_orientation = (uint16)orientation; + img.req_orientation = (uint16_t)orientation; /* XXX verify rwidth and rheight against width and height */ ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth, rwidth, img.height); @@ -544,7 +544,7 @@ TIFFReadRGBAImageOriented(TIFF* tif, */ int TIFFReadRGBAImage(TIFF* tif, - uint32 rwidth, uint32 rheight, uint32* raster, int stop) + uint32_t rwidth, uint32_t rheight, uint32_t* raster, int stop) { return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster, ORIENTATION_BOTLEFT, stop); @@ -618,21 +618,21 @@ setorientation(TIFFRGBAImage* img) * SamplesPerPixel == 1 */ static int -gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +gtTileContig(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; - uint32 col, row, y, rowstoread; + uint32_t col, row, y, rowstoread; tmsize_t pos; - uint32 tw, th; + uint32_t tw, th; unsigned char* buf = NULL; - int32 fromskew, toskew; - uint32 nrow; + int32_t fromskew, toskew; + uint32_t nrow; int ret = 1, flip; - uint32 this_tw, tocol; - int32 this_toskew, leftmost_toskew; - int32 leftmost_fromskew; - uint32 leftmost_tw; + uint32_t this_tw, tocol; + int32_t this_toskew, leftmost_toskew; + int32_t leftmost_fromskew; + uint32_t leftmost_tw; tmsize_t bufsize; bufsize = TIFFTileSize(tif); @@ -651,7 +651,7 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = h - 1; - toskew = -(int32)(tw + w); + toskew = -(int32_t)(tw + w); } else { if (tw > (INT_MAX + w)) { @@ -659,7 +659,7 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = 0; - toskew = -(int32)(tw - w); + toskew = -(int32_t)(tw - w); } /* @@ -708,19 +708,19 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) this_toskew = toskew; } - y += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32_t) nrow : (int32_t) nrow); } _TIFFfree(buf); if (flip & FLIP_HORIZONTALLY) { - uint32 line; + uint32_t line; for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; + uint32_t *left = raster + (line * w); + uint32_t *right = left + w - 1; while ( left < right ) { - uint32 temp = *left; + uint32_t temp = *left; *left = *right; *right = temp; left++; @@ -739,13 +739,13 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) * We assume that all such images are RGB. */ static int -gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +gtTileSeparate(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileSeparateRoutine put = img->put.separate; - uint32 col, row, y, rowstoread; + uint32_t col, row, y, rowstoread; tmsize_t pos; - uint32 tw, th; + uint32_t tw, th; unsigned char* buf = NULL; unsigned char* p0 = NULL; unsigned char* p1 = NULL; @@ -753,15 +753,15 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) unsigned char* pa = NULL; tmsize_t tilesize; tmsize_t bufsize; - int32 fromskew, toskew; + int32_t fromskew, toskew; int alpha = img->alpha; - uint32 nrow; + uint32_t nrow; int ret = 1, flip; - uint16 colorchannels; - uint32 this_tw, tocol; - int32 this_toskew, leftmost_toskew; - int32 leftmost_fromskew; - uint32 leftmost_tw; + uint16_t colorchannels; + uint32_t this_tw, tocol; + int32_t this_toskew, leftmost_toskew; + int32_t leftmost_fromskew; + uint32_t leftmost_tw; tilesize = TIFFTileSize(tif); bufsize = _TIFFMultiplySSize(tif, alpha?4:3,tilesize, "gtTileSeparate"); @@ -779,7 +779,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = h - 1; - toskew = -(int32)(tw + w); + toskew = -(int32_t)(tw + w); } else { if (tw > (INT_MAX + w)) { @@ -787,7 +787,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = 0; - toskew = -(int32)(tw - w); + toskew = -(int32_t)(tw - w); } switch( img->photometric ) @@ -897,18 +897,18 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) this_toskew = toskew; } - y += ((flip & FLIP_VERTICALLY) ?-(int32) nrow : (int32) nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32_t) nrow : (int32_t) nrow); } if (flip & FLIP_HORIZONTALLY) { - uint32 line; + uint32_t line; for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; + uint32_t *left = raster + (line * w); + uint32_t *right = left + w - 1; while ( left < right ) { - uint32 temp = *left; + uint32_t temp = *left; *left = *right; *right = temp; left++; @@ -928,18 +928,18 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) * SamplesPerPixel == 1 */ static int -gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +gtStripContig(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; - uint32 row, y, nrow, nrowsub, rowstoread; + uint32_t row, y, nrow, nrowsub, rowstoread; tmsize_t pos; unsigned char* buf = NULL; - uint32 rowsperstrip; - uint16 subsamplinghor,subsamplingver; - uint32 imagewidth = img->width; + uint32_t rowsperstrip; + uint16_t subsamplinghor,subsamplingver; + uint32_t imagewidth = img->width; tmsize_t scanline; - int32 fromskew, toskew; + int32_t fromskew, toskew; int ret = 1, flip; tmsize_t maxstripsize; @@ -958,10 +958,10 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = h - 1; - toskew = -(int32)(w + w); + toskew = -(int32_t)(w + w); } else { y = 0; - toskew = -(int32)(w - w); + toskew = -(int32_t)(w - w); } TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); @@ -970,7 +970,7 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) fromskew = (w < imagewidth ? imagewidth - w : 0); for (row = 0; row < h; row += nrow) { - uint32 temp; + uint32_t temp; rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; nrow = (row + rowstoread > h ? h - row : rowstoread); nrowsub = nrow; @@ -996,18 +996,18 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) pos = ((row + img->row_offset) % rowsperstrip) * scanline + \ ((tmsize_t) img->col_offset * img->samplesperpixel); (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos); - y += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32_t) nrow : (int32_t) nrow); } if (flip & FLIP_HORIZONTALLY) { - uint32 line; + uint32_t line; for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; + uint32_t *left = raster + (line * w); + uint32_t *right = left + w - 1; while ( left < right ) { - uint32 temp = *left; + uint32_t temp = *left; *left = *right; *right = temp; left++; @@ -1027,23 +1027,23 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) * We assume that all such images are RGB. */ static int -gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +gtStripSeparate(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileSeparateRoutine put = img->put.separate; unsigned char *buf = NULL; unsigned char *p0 = NULL, *p1 = NULL, *p2 = NULL, *pa = NULL; - uint32 row, y, nrow, rowstoread; + uint32_t row, y, nrow, rowstoread; tmsize_t pos; tmsize_t scanline; - uint32 rowsperstrip, offset_row; - uint32 imagewidth = img->width; + uint32_t rowsperstrip, offset_row; + uint32_t imagewidth = img->width; tmsize_t stripsize; tmsize_t bufsize; - int32 fromskew, toskew; + int32_t fromskew, toskew; int alpha = img->alpha; int ret = 1, flip; - uint16 colorchannels; + uint16_t colorchannels; stripsize = TIFFStripSize(tif); bufsize = _TIFFMultiplySSize(tif,alpha?4:3,stripsize, "gtStripSeparate"); @@ -1058,11 +1058,11 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = h - 1; - toskew = -(int32)(w + w); + toskew = -(int32_t)(w + w); } else { y = 0; - toskew = -(int32)(w - w); + toskew = -(int32_t)(w - w); } switch( img->photometric ) @@ -1083,7 +1083,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) fromskew = (w < imagewidth ? imagewidth - w : 0); for (row = 0; row < h; row += nrow) { - uint32 temp; + uint32_t temp; rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; nrow = (row + rowstoread > h ? h - row : rowstoread); offset_row = row + img->row_offset; @@ -1155,18 +1155,18 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) ((tmsize_t) img->col_offset * img->samplesperpixel); (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL)); - y += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32_t) nrow : (int32_t) nrow); } if (flip & FLIP_HORIZONTALLY) { - uint32 line; + uint32_t line; for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; + uint32_t *left = raster + (line * w); + uint32_t *right = left + w - 1; while ( left < right ) { - uint32 temp = *left; + uint32_t temp = *left; *left = *right; *right = temp; left++; @@ -1206,7 +1206,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) #define NOP #define UNROLL8(w, op1, op2) { \ - uint32 _x; \ + uint32_t _x; \ for (_x = w; _x >= 8; _x -= 8) { \ op1; \ REPEAT8(op2); \ @@ -1217,7 +1217,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) } \ } #define UNROLL4(w, op1, op2) { \ - uint32 _x; \ + uint32_t _x; \ for (_x = w; _x >= 4; _x -= 4) { \ op1; \ REPEAT4(op2); \ @@ -1228,7 +1228,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) } \ } #define UNROLL2(w, op1, op2) { \ - uint32 _x; \ + uint32_t _x; \ for (_x = w; _x >= 2; _x -= 2) { \ op1; \ REPEAT2(op2); \ @@ -1242,25 +1242,25 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) #define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } #define SKEW4(r,g,b,a,skew) { r += skew; g += skew; b += skew; a+= skew; } -#define A1 (((uint32)0xffL)<<24) +#define A1 (((uint32_t)0xffL)<<24) #define PACK(r,g,b) \ - ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|A1) + ((uint32_t)(r)|((uint32_t)(g)<<8)|((uint32_t)(b)<<16)|A1) #define PACK4(r,g,b,a) \ - ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(a)<<24)) + ((uint32_t)(r)|((uint32_t)(g)<<8)|((uint32_t)(b)<<16)|((uint32_t)(a)<<24)) #define W2B(v) (((v)>>8)&0xff) /* TODO: PACKW should have be made redundant in favor of Bitdepth16To8 LUT */ #define PACKW(r,g,b) \ - ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|A1) + ((uint32_t)W2B(r)|((uint32_t)W2B(g)<<8)|((uint32_t)W2B(b)<<16)|A1) #define PACKW4(r,g,b,a) \ - ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|((uint32)W2B(a)<<24)) + ((uint32_t)W2B(r)|((uint32_t)W2B(g)<<8)|((uint32_t)W2B(b)<<16)|((uint32_t)W2B(a)<<24)) #define DECLAREContigPutFunc(name) \ static void name(\ TIFFRGBAImage* img, \ - uint32* cp, \ - uint32 x, uint32 y, \ - uint32 w, uint32 h, \ - int32 fromskew, int32 toskew, \ + uint32_t* cp, \ + uint32_t x, uint32_t y, \ + uint32_t w, uint32_t h, \ + int32_t fromskew, int32_t toskew, \ unsigned char* pp \ ) @@ -1269,7 +1269,7 @@ static void name(\ */ DECLAREContigPutFunc(put8bitcmaptile) { - uint32** PALmap = img->PALmap; + uint32_t** PALmap = img->PALmap; int samplesperpixel = img->samplesperpixel; (void) y; @@ -1289,12 +1289,12 @@ DECLAREContigPutFunc(put8bitcmaptile) */ DECLAREContigPutFunc(put4bitcmaptile) { - uint32** PALmap = img->PALmap; + uint32_t** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 2; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1306,12 +1306,12 @@ DECLAREContigPutFunc(put4bitcmaptile) */ DECLAREContigPutFunc(put2bitcmaptile) { - uint32** PALmap = img->PALmap; + uint32_t** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 4; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1323,12 +1323,12 @@ DECLAREContigPutFunc(put2bitcmaptile) */ DECLAREContigPutFunc(put1bitcmaptile) { - uint32** PALmap = img->PALmap; + uint32_t** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 8; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1341,7 +1341,7 @@ DECLAREContigPutFunc(put1bitcmaptile) DECLAREContigPutFunc(putgreytile) { int samplesperpixel = img->samplesperpixel; - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) y; for( ; h > 0; --h) { @@ -1361,13 +1361,13 @@ DECLAREContigPutFunc(putgreytile) DECLAREContigPutFunc(putagreytile) { int samplesperpixel = img->samplesperpixel; - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) y; for( ; h > 0; --h) { for (x = w; x > 0; --x) { - *cp++ = BWmap[*pp][0] & ((uint32)*(pp+1) << 24 | ~A1); + *cp++ = BWmap[*pp][0] & ((uint32_t)*(pp + 1) << 24 | ~A1); pp += samplesperpixel; } cp += toskew; @@ -1381,11 +1381,11 @@ DECLAREContigPutFunc(putagreytile) DECLAREContigPutFunc(put16bitbwtile) { int samplesperpixel = img->samplesperpixel; - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) y; for( ; h > 0; --h) { - uint16 *wp = (uint16 *) pp; + uint16_t *wp = (uint16_t *) pp; for (x = w; x > 0; --x) { @@ -1405,12 +1405,12 @@ DECLAREContigPutFunc(put16bitbwtile) */ DECLAREContigPutFunc(put1bitbwtile) { - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 8; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1422,12 +1422,12 @@ DECLAREContigPutFunc(put1bitbwtile) */ DECLAREContigPutFunc(put2bitbwtile) { - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 4; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1439,12 +1439,12 @@ DECLAREContigPutFunc(put2bitbwtile) */ DECLAREContigPutFunc(put4bitbwtile) { - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 2; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1498,8 +1498,8 @@ DECLAREContigPutFunc(putRGBUAcontig8bittile) (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { - uint32 r, g, b, a; - uint8* m; + uint32_t r, g, b, a; + uint8_t* m; for (x = w; x > 0; --x) { a = pp[3]; m = img->UaToAa+((size_t) a<<8); @@ -1520,7 +1520,7 @@ DECLAREContigPutFunc(putRGBUAcontig8bittile) DECLAREContigPutFunc(putRGBcontig16bittile) { int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; + uint16_t *wp = (uint16_t *)pp; (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { @@ -1542,7 +1542,7 @@ DECLAREContigPutFunc(putRGBcontig16bittile) DECLAREContigPutFunc(putRGBAAcontig16bittile) { int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; + uint16_t *wp = (uint16_t *)pp; (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { @@ -1565,12 +1565,12 @@ DECLAREContigPutFunc(putRGBAAcontig16bittile) DECLAREContigPutFunc(putRGBUAcontig16bittile) { int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; + uint16_t *wp = (uint16_t *)pp; (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { - uint32 r,g,b,a; - uint8* m; + uint32_t r,g,b,a; + uint8_t* m; for (x = w; x > 0; --x) { a = img->Bitdepth16To8[wp[3]]; m = img->UaToAa+((size_t) a<<8); @@ -1593,7 +1593,7 @@ DECLAREContigPutFunc(putRGBUAcontig16bittile) DECLAREContigPutFunc(putRGBcontig8bitCMYKtile) { int samplesperpixel = img->samplesperpixel; - uint16 r, g, b, k; + uint16_t r, g, b, k; (void) x; (void) y; fromskew *= samplesperpixel; @@ -1619,7 +1619,7 @@ DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) { int samplesperpixel = img->samplesperpixel; TIFFRGBValue* Map = img->Map; - uint16 r, g, b, k; + uint16_t r, g, b, k; (void) y; fromskew *= samplesperpixel; @@ -1640,10 +1640,10 @@ DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) #define DECLARESepPutFunc(name) \ static void name(\ TIFFRGBAImage* img,\ - uint32* cp,\ - uint32 x, uint32 y, \ - uint32 w, uint32 h,\ - int32 fromskew, int32 toskew,\ + uint32_t* cp,\ + uint32_t x, uint32_t y, \ + uint32_t w, uint32_t h,\ + int32_t fromskew, int32_t toskew,\ unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a\ ) @@ -1680,7 +1680,7 @@ DECLARESepPutFunc(putCMYKseparate8bittile) { (void) img; (void) y; for( ; h > 0; --h) { - uint32 rv, gv, bv, kv; + uint32_t rv, gv, bv, kv; for (x = w; x > 0; --x) { kv = 255 - *a++; rv = (kv*(255-*r++))/255; @@ -1700,8 +1700,8 @@ DECLARESepPutFunc(putRGBUAseparate8bittile) { (void) img; (void) y; for( ; h > 0; --h) { - uint32 rv, gv, bv, av; - uint8* m; + uint32_t rv, gv, bv, av; + uint8_t* m; for (x = w; x > 0; --x) { av = *a++; m = img->UaToAa+((size_t) av<<8); @@ -1720,9 +1720,9 @@ DECLARESepPutFunc(putRGBUAseparate8bittile) */ DECLARESepPutFunc(putRGBseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; + uint16_t *wr = (uint16_t*) r; + uint16_t *wg = (uint16_t*) g; + uint16_t *wb = (uint16_t*) b; (void) img; (void) y; (void) a; for( ; h > 0; --h) { for (x = 0; x < w; x++) @@ -1739,10 +1739,10 @@ DECLARESepPutFunc(putRGBseparate16bittile) */ DECLARESepPutFunc(putRGBAAseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; + uint16_t *wr = (uint16_t*) r; + uint16_t *wg = (uint16_t*) g; + uint16_t *wb = (uint16_t*) b; + uint16_t *wa = (uint16_t*) a; (void) img; (void) y; for( ; h > 0; --h) { for (x = 0; x < w; x++) @@ -1760,14 +1760,14 @@ DECLARESepPutFunc(putRGBAAseparate16bittile) */ DECLARESepPutFunc(putRGBUAseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; + uint16_t *wr = (uint16_t*) r; + uint16_t *wg = (uint16_t*) g; + uint16_t *wb = (uint16_t*) b; + uint16_t *wa = (uint16_t*) a; (void) img; (void) y; for( ; h > 0; --h) { - uint32 r2,g2,b2,a2; - uint8* m; + uint32_t r2,g2,b2,a2; + uint8_t* m; for (x = w; x > 0; --x) { a2 = img->Bitdepth16To8[*wa++]; m = img->UaToAa+((size_t) a2<<8); @@ -1787,7 +1787,7 @@ DECLARESepPutFunc(putRGBUAseparate16bittile) DECLAREContigPutFunc(putcontig8bitCIELab) { float X, Y, Z; - uint32 r, g, b; + uint32_t r, g, b; (void) y; fromskew *= 3; for( ; h > 0; --h) { @@ -1811,7 +1811,7 @@ DECLAREContigPutFunc(putcontig8bitCIELab) */ #define YCbCrtoRGB(dst, Y) { \ - uint32 r, g, b; \ + uint32_t r, g, b; \ TIFFYCbCrtoRGB(img->ycbcr, (Y), Cb, Cr, &r, &g, &b); \ dst = PACK(r, g, b); \ } @@ -1827,20 +1827,20 @@ DECLAREContigPutFunc(putcontig8bitCIELab) #ifdef notdef static void putcontig8bitYCbCrGenericTile( TIFFRGBAImage* img, - uint32* cp, - uint32 x, uint32 y, - uint32 w, uint32 h, - int32 fromskew, int32 toskew, + uint32_t* cp, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h, + int32_t fromskew, int32_t toskew, unsigned char* pp, int h_group, int v_group ) { - uint32* cp1 = cp+w+toskew; - uint32* cp2 = cp1+w+toskew; - uint32* cp3 = cp2+w+toskew; - int32 incr = 3*w+4*toskew; - int32 Cb, Cr; + uint32_t* cp1 = cp+w+toskew; + uint32_t* cp2 = cp1+w+toskew; + uint32_t* cp3 = cp2+w+toskew; + int32_t incr = 3*w+4*toskew; + int32_t Cb, Cr; int group_size = v_group * h_group + 2; (void) y; @@ -1897,10 +1897,10 @@ static void putcontig8bitYCbCrGenericTile( */ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) { - uint32* cp1 = cp+w+toskew; - uint32* cp2 = cp1+w+toskew; - uint32* cp3 = cp2+w+toskew; - int32 incr = 3*w+4*toskew; + uint32_t* cp1 = cp + w + toskew; + uint32_t* cp2 = cp1 + w + toskew; + uint32_t* cp3 = cp2 + w + toskew; + int32_t incr = 3 * w + 4 * toskew; (void) y; /* adjust fromskew */ @@ -1909,8 +1909,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) for (; h >= 4; h -= 4) { x = w>>2; do { - int32 Cb = pp[16]; - int32 Cr = pp[17]; + int32_t Cb = pp[16]; + int32_t Cr = pp[17]; YCbCrtoRGB(cp [0], pp[ 0]); YCbCrtoRGB(cp [1], pp[ 1]); @@ -1944,8 +1944,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) } else { while (h > 0) { for (x = w; x > 0;) { - int32 Cb = pp[16]; - int32 Cr = pp[17]; + int32_t Cb = pp[16]; + int32_t Cr = pp[17]; switch (x) { default: switch (h) { @@ -2003,8 +2003,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) { - uint32* cp1 = cp+w+toskew; - int32 incr = 2*toskew+w; + uint32_t* cp1 = cp + w + toskew; + int32_t incr = 2 * toskew + w; (void) y; fromskew = (fromskew / 4) * (4*2+2); @@ -2012,8 +2012,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) for (; h >= 2; h -= 2) { x = w>>2; do { - int32 Cb = pp[8]; - int32 Cr = pp[9]; + int32_t Cb = pp[8]; + int32_t Cr = pp[9]; YCbCrtoRGB(cp [0], pp[0]); YCbCrtoRGB(cp [1], pp[1]); @@ -2035,8 +2035,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) } else { while (h > 0) { for (x = w; x > 0;) { - int32 Cb = pp[8]; - int32 Cr = pp[9]; + int32_t Cb = pp[8]; + int32_t Cr = pp[9]; switch (x) { default: switch (h) { @@ -2089,8 +2089,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) do { x = w>>2; while(x>0) { - int32 Cb = pp[4]; - int32 Cr = pp[5]; + int32_t Cb = pp[4]; + int32_t Cr = pp[5]; YCbCrtoRGB(cp [0], pp[0]); YCbCrtoRGB(cp [1], pp[1]); @@ -2104,8 +2104,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) if( (w&3) != 0 ) { - int32 Cb = pp[4]; - int32 Cr = pp[5]; + int32_t Cb = pp[4]; + int32_t Cr = pp[5]; switch( (w&3) ) { case 3: YCbCrtoRGB(cp [2], pp[2]); /*-fallthrough*/ @@ -2129,16 +2129,16 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) { - uint32* cp2; - int32 incr = 2*toskew+w; + uint32_t* cp2; + int32_t incr = 2 * toskew + w; (void) y; fromskew = (fromskew / 2) * (2*2+2); cp2 = cp+w+toskew; while (h>=2) { x = w; while (x>=2) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; + uint32_t Cb = pp[4]; + uint32_t Cr = pp[5]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp[1], pp[1]); YCbCrtoRGB(cp2[0], pp[2]); @@ -2149,8 +2149,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) x -= 2; } if (x==1) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; + uint32_t Cb = pp[4]; + uint32_t Cr = pp[5]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp2[0], pp[2]); cp ++ ; @@ -2165,8 +2165,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) if (h==1) { x = w; while (x>=2) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; + uint32_t Cb = pp[4]; + uint32_t Cr = pp[5]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp[1], pp[1]); cp += 2; @@ -2175,8 +2175,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) x -= 2; } if (x==1) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; + uint32_t Cb = pp[4]; + uint32_t Cr = pp[5]; YCbCrtoRGB(cp[0], pp[0]); } } @@ -2192,8 +2192,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) do { x = w>>1; while(x>0) { - int32 Cb = pp[2]; - int32 Cr = pp[3]; + int32_t Cb = pp[2]; + int32_t Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp[1], pp[1]); @@ -2205,8 +2205,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) if( (w&1) != 0 ) { - int32 Cb = pp[2]; - int32 Cr = pp[3]; + int32_t Cb = pp[2]; + int32_t Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); @@ -2224,16 +2224,16 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr12tile) { - uint32* cp2; - int32 incr = 2*toskew+w; + uint32_t* cp2; + int32_t incr = 2 * toskew + w; (void) y; fromskew = (fromskew / 1) * (1 * 2 + 2); cp2 = cp+w+toskew; while (h>=2) { x = w; do { - uint32 Cb = pp[2]; - uint32 Cr = pp[3]; + uint32_t Cb = pp[2]; + uint32_t Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp2[0], pp[1]); cp ++; @@ -2248,8 +2248,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr12tile) if (h==1) { x = w; do { - uint32 Cb = pp[2]; - uint32 Cr = pp[3]; + uint32_t Cb = pp[2]; + uint32_t Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); cp ++; pp += 4; @@ -2267,8 +2267,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr11tile) do { x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ do { - int32 Cb = pp[1]; - int32 Cr = pp[2]; + int32_t Cb = pp[1]; + int32_t Cr = pp[2]; YCbCrtoRGB(*cp++, pp[0]); @@ -2290,7 +2290,7 @@ DECLARESepPutFunc(putseparate8bitYCbCr11tile) for( ; h > 0; --h) { x = w; do { - uint32 dr, dg, db; + uint32_t dr, dg, db; TIFFYCbCrtoRGB(img->ycbcr,*r++,*g++,*b++,&dr,&dg,&db); *cp++ = PACK(dr,dg,db); } while (--x); @@ -2317,7 +2317,7 @@ initYCbCrConversion(TIFFRGBAImage* img) TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long)) + 4*256*sizeof (TIFFRGBValue) + 2*256*sizeof (int) - + 3*256*sizeof (int32) + + 3*256*sizeof (int32_t) ); if (img->ycbcr == NULL) { TIFFErrorExt(img->tif->tif_clientdata, module, @@ -2412,18 +2412,18 @@ makebwmap(TIFFRGBAImage* img) int bitspersample = img->bitspersample; int nsamples = 8 / bitspersample; int i; - uint32* p; + uint32_t* p; if( nsamples == 0 ) nsamples = 1; - img->BWmap = (uint32**) _TIFFmalloc( - 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); + img->BWmap = (uint32_t**) _TIFFmalloc( + 256*sizeof (uint32_t *) + (256 * nsamples * sizeof(uint32_t))); if (img->BWmap == NULL) { TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No space for B&W mapping table"); return (0); } - p = (uint32*)(img->BWmap + 256); + p = (uint32_t*)(img->BWmap + 256); for (i = 0; i < 256; i++) { TIFFRGBValue c; img->BWmap[i] = p; @@ -2467,13 +2467,13 @@ makebwmap(TIFFRGBAImage* img) static int setupMap(TIFFRGBAImage* img) { - int32 x, range; + int32_t x, range; - range = (int32)((1L<<img->bitspersample)-1); + range = (int32_t)((1L << img->bitspersample) - 1); /* treat 16 bit the same as eight bit */ if( img->bitspersample == 16 ) - range = (int32) 255; + range = (int32_t) 255; img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue)); if (img->Map == NULL) { @@ -2507,9 +2507,9 @@ setupMap(TIFFRGBAImage* img) static int checkcmap(TIFFRGBAImage* img) { - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; + uint16_t* r = img->redcmap; + uint16_t* g = img->greencmap; + uint16_t* b = img->bluecmap; long n = 1L<<img->bitspersample; while (n-- > 0) @@ -2521,13 +2521,13 @@ checkcmap(TIFFRGBAImage* img) static void cvtcmap(TIFFRGBAImage* img) { - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; + uint16_t* r = img->redcmap; + uint16_t* g = img->greencmap; + uint16_t* b = img->bluecmap; long i; for (i = (1L<<img->bitspersample)-1; i >= 0; i--) { -#define CVT(x) ((uint16)((x)>>8)) +#define CVT(x) ((uint16_t)((x)>>8)) r[i] = CVT(r[i]); g[i] = CVT(g[i]); b[i] = CVT(b[i]); @@ -2547,19 +2547,19 @@ makecmap(TIFFRGBAImage* img) { int bitspersample = img->bitspersample; int nsamples = 8 / bitspersample; - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; - uint32 *p; + uint16_t* r = img->redcmap; + uint16_t* g = img->greencmap; + uint16_t* b = img->bluecmap; + uint32_t *p; int i; - img->PALmap = (uint32**) _TIFFmalloc( - 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); + img->PALmap = (uint32_t**) _TIFFmalloc( + 256*sizeof (uint32_t *) + (256 * nsamples * sizeof(uint32_t))); if (img->PALmap == NULL) { TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No space for Palette mapping table"); return (0); } - p = (uint32*)(img->PALmap + 256); + p = (uint32_t*)(img->PALmap + 256); for (i = 0; i < 256; i++) { TIFFRGBValue c; img->PALmap[i] = p; @@ -2746,8 +2746,8 @@ PickContigCase(TIFFRGBAImage* img) * Joris: added support for the [1,2] case, nonetheless, to accommodate * some OJPEG files */ - uint16 SubsamplingHor; - uint16 SubsamplingVer; + uint16_t SubsamplingHor; + uint16_t SubsamplingVer; TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &SubsamplingHor, &SubsamplingVer); switch ((SubsamplingHor<<4)|SubsamplingVer) { case 0x44: @@ -2845,7 +2845,7 @@ PickSeparateCase(TIFFRGBAImage* img) { if (initYCbCrConversion(img)!=0) { - uint16 hs, vs; + uint16_t hs, vs; TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); switch ((hs<<4)|vs) { case 0x11: @@ -2864,8 +2864,8 @@ static int BuildMapUaToAa(TIFFRGBAImage* img) { static const char module[]="BuildMapUaToAa"; - uint8* m; - uint16 na,nv; + uint8_t* m; + uint16_t na,nv; assert(img->UaToAa==NULL); img->UaToAa=_TIFFmalloc(65536); if (img->UaToAa==NULL) @@ -2877,7 +2877,7 @@ BuildMapUaToAa(TIFFRGBAImage* img) for (na=0; na<256; na++) { for (nv=0; nv<256; nv++) - *m++=(uint8)((nv*na+127)/255); + *m++=(uint8_t)((nv * na + 127) / 255); } return(1); } @@ -2886,8 +2886,8 @@ static int BuildMapBitdepth16To8(TIFFRGBAImage* img) { static const char module[]="BuildMapBitdepth16To8"; - uint8* m; - uint32 n; + uint8_t* m; + uint32_t n; assert(img->Bitdepth16To8==NULL); img->Bitdepth16To8=_TIFFmalloc(65536); if (img->Bitdepth16To8==NULL) @@ -2897,7 +2897,7 @@ BuildMapBitdepth16To8(TIFFRGBAImage* img) } m=img->Bitdepth16To8; for (n=0; n<65536; n++) - *m++=(uint8)((n+128)/257); + *m++=(uint8_t)((n + 128) / 257); return(1); } @@ -2911,20 +2911,20 @@ BuildMapBitdepth16To8(TIFFRGBAImage* img) int -TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) +TIFFReadRGBAStrip(TIFF* tif, uint32_t row, uint32_t * raster ) { return TIFFReadRGBAStripExt(tif, row, raster, 0 ); } int -TIFFReadRGBAStripExt(TIFF* tif, uint32 row, uint32 * raster, int stop_on_error) +TIFFReadRGBAStripExt(TIFF* tif, uint32_t row, uint32_t * raster, int stop_on_error) { char emsg[1024] = ""; TIFFRGBAImage img; int ok; - uint32 rowsperstrip, rows_to_read; + uint32_t rowsperstrip, rows_to_read; if( TIFFIsTiled( tif ) ) { @@ -2969,7 +2969,7 @@ TIFFReadRGBAStripExt(TIFF* tif, uint32 row, uint32 * raster, int stop_on_error) */ int -TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) +TIFFReadRGBATile(TIFF* tif, uint32_t col, uint32_t row, uint32_t * raster) { return TIFFReadRGBATileExt(tif, col, row, raster, 0 ); @@ -2977,14 +2977,14 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) int -TIFFReadRGBATileExt(TIFF* tif, uint32 col, uint32 row, uint32 * raster, int stop_on_error ) +TIFFReadRGBATileExt(TIFF* tif, uint32_t col, uint32_t row, uint32_t * raster, int stop_on_error ) { char emsg[1024] = ""; TIFFRGBAImage img; int ok; - uint32 tile_xsize, tile_ysize; - uint32 read_xsize, read_ysize; - uint32 i_row; + uint32_t tile_xsize, tile_ysize; + uint32_t read_xsize, read_ysize; + uint32_t i_row; /* * Verify that our request is legal - on a tile file, and on a @@ -3060,14 +3060,14 @@ TIFFReadRGBATileExt(TIFF* tif, uint32 col, uint32 row, uint32 * raster, int stop for( i_row = 0; i_row < read_ysize; i_row++ ) { memmove( raster + (tile_ysize - i_row - 1) * tile_xsize, raster + (read_ysize - i_row - 1) * read_xsize, - read_xsize * sizeof(uint32) ); + read_xsize * sizeof(uint32_t) ); _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize+read_xsize, - 0, sizeof(uint32) * (tile_xsize - read_xsize) ); + 0, sizeof(uint32_t) * (tile_xsize - read_xsize) ); } for( i_row = read_ysize; i_row < tile_ysize; i_row++ ) { _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize, - 0, sizeof(uint32) * tile_xsize ); + 0, sizeof(uint32_t) * tile_xsize ); } return (ok); diff --git a/tiff/libtiff/tif_jbig.c b/tiff/libtiff/tif_jbig.c index a3500e0b..74086338 100644 --- a/tiff/libtiff/tif_jbig.c +++ b/tiff/libtiff/tif_jbig.c @@ -46,7 +46,7 @@ static int JBIGSetupDecode(TIFF* tif) return 1; } -static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) +static int JBIGDecode(TIFF* tif, uint8_t* buffer, tmsize_t size, uint16_t s) { struct jbg_dec_state decoder; int decodeStatus = 0; @@ -101,14 +101,14 @@ static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) if( (tmsize_t)decodedSize < size ) { TIFFWarningExt(tif->tif_clientdata, "JBIG", - "Only decoded %lu bytes, whereas %lu requested", - decodedSize, (unsigned long)size); + "Only decoded %lu bytes, whereas %"TIFF_SSIZE_FORMAT" requested", + decodedSize, size); } else if( (tmsize_t)decodedSize > size ) { TIFFErrorExt(tif->tif_clientdata, "JBIG", - "Decoded %lu bytes, whereas %lu were requested", - decodedSize, (unsigned long)size); + "Decoded %lu bytes, whereas %"TIFF_SSIZE_FORMAT" were requested", + decodedSize, size); jbg_dec_free(&decoder); return 0; } @@ -133,7 +133,7 @@ static int JBIGSetupEncode(TIFF* tif) return 1; } -static int JBIGCopyEncodedData(TIFF* tif, unsigned char* pp, size_t cc, uint16 s) +static int JBIGCopyEncodedData(TIFF* tif, unsigned char* pp, size_t cc, uint16_t s) { (void) s; while (cc > 0) @@ -173,7 +173,7 @@ static void JBIGOutputBie(unsigned char* buffer, size_t len, void* userData) JBIGCopyEncodedData(tif, buffer, len, 0); } -static int JBIGEncode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) +static int JBIGEncode(TIFF* tif, uint8_t* buffer, tmsize_t size, uint16_t s) { TIFFDirectory* dir = &tif->tif_dir; struct jbg_enc_state encoder; diff --git a/tiff/libtiff/tif_jpeg.c b/tiff/libtiff/tif_jpeg.c index d051471e..73265808 100644 --- a/tiff/libtiff/tif_jpeg.c +++ b/tiff/libtiff/tif_jpeg.c @@ -44,8 +44,8 @@ */ #include <setjmp.h> -int TIFFFillStrip(TIFF* tif, uint32 strip); -int TIFFFillTile(TIFF* tif, uint32 tile); +int TIFFFillStrip(TIFF* tif, uint32_t strip); +int TIFFFillTile(TIFF* tif, uint32_t tile); int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode ); int TIFFJPEGIsFullStripRequired_12(TIFF* tif); @@ -161,9 +161,9 @@ typedef struct { jpeg_source_mgr src; /* data source for decompression */ /* private state */ TIFF* tif; /* back link needed by some code */ - uint16 photometric; /* copy of PhotometricInterpretation */ - uint16 h_sampling; /* luminance sampling factors */ - uint16 v_sampling; + uint16_t photometric; /* copy of PhotometricInterpretation */ + uint16_t h_sampling; /* luminance sampling factors */ + uint16_t v_sampling; tmsize_t bytesperline; /* decompressed bytes per scanline */ /* pointers to intermediate buffers when processing downsampled data */ JSAMPARRAY ds_buffer[MAX_COMPONENTS]; @@ -177,7 +177,7 @@ typedef struct { TIFFTileMethod deftparent; /* super-class method */ /* pseudo-tag fields */ void* jpegtables; /* JPEGTables tag value, or NULL */ - uint32 jpegtables_length; /* number of bytes in same */ + uint32_t jpegtables_length; /* number of bytes in same */ int jpegquality; /* Compression quality level */ int jpegcolormode; /* Auto RGB<=>YCbCr convert? */ int jpegtablesmode; /* What to put in JPEGTables */ @@ -188,12 +188,12 @@ typedef struct { #define JState(tif) ((JPEGState*)(tif)->tif_data) -static int JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -static int JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -static int JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -static int JPEGEncodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int JPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); +static int JPEGDecodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); +static int JPEGEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); +static int JPEGEncodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); static int JPEGInitializeLibJPEG(TIFF * tif, int decode ); -static int DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int DecodeRowError(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); #define FIELD_JPEGTABLES (FIELD_CODEC+0) @@ -489,7 +489,7 @@ std_term_destination(j_compress_ptr cinfo) JPEGState* sp = (JPEGState*) cinfo; TIFF* tif = sp->tif; - tif->tif_rawcp = (uint8*) sp->dest.next_output_byte; + tif->tif_rawcp = (uint8_t*) sp->dest.next_output_byte; tif->tif_rawcc = tif->tif_rawdatasize - (tmsize_t) sp->dest.free_in_buffer; /* NB: libtiff does the final buffer flush */ @@ -543,7 +543,7 @@ tables_term_destination(j_compress_ptr cinfo) JPEGState* sp = (JPEGState*) cinfo; /* set tables length to number of bytes actually emitted */ - sp->jpegtables_length -= (uint32) sp->dest.free_in_buffer; + sp->jpegtables_length -= (uint32_t) sp->dest.free_in_buffer; } static int @@ -733,18 +733,18 @@ struct JPEGFixupTagsSubsamplingData { TIFF* tif; void* buffer; - uint32 buffersize; - uint8* buffercurrentbyte; - uint32 bufferbytesleft; - uint64 fileoffset; - uint64 filebytesleft; - uint8 filepositioned; + uint32_t buffersize; + uint8_t* buffercurrentbyte; + uint32_t bufferbytesleft; + uint64_t fileoffset; + uint64_t filebytesleft; + uint8_t filepositioned; }; static void JPEGFixupTagsSubsampling(TIFF* tif); static int JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data); -static int JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result); -static int JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result); -static void JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16 skiplength); +static int JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8_t* result); +static int JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16_t* result); +static void JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16_t skiplength); #endif @@ -790,7 +790,7 @@ JPEGFixupTagsSubsampling(TIFF* tif) */ static const char module[] = "JPEGFixupTagsSubsampling"; struct JPEGFixupTagsSubsamplingData m; - uint64 fileoffset = TIFFGetStrileOffset(tif, 0); + uint64_t fileoffset = TIFFGetStrileOffset(tif, 0); if( fileoffset == 0 ) { @@ -824,7 +824,7 @@ static int JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) { static const char module[] = "JPEGFixupTagsSubsamplingSec"; - uint8 m; + uint8_t m; while (1) { while (1) @@ -869,7 +869,7 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) case JPEG_MARKER_DRI: /* this type of marker has data, but it has no use to us and should be skipped */ { - uint16 n; + uint16_t n; if (!JPEGFixupTagsSubsamplingReadWord(data,&n)) return(0); if (n<2) @@ -886,10 +886,10 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) case JPEG_MARKER_SOF10: /* Progressive arithmetic: normally not allowed by TechNote, but that doesn't hurt supporting it */ /* this marker contains the subsampling factors we're scanning for */ { - uint16 n; - uint16 o; - uint8 p; - uint8 ph,pv; + uint16_t n; + uint16_t o; + uint8_t p; + uint8_t ph,pv; if (!JPEGFixupTagsSubsamplingReadWord(data,&n)) return(0); if (n!=8+data->tif->tif_dir.td_samplesperpixel*3) @@ -922,10 +922,10 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) if ((ph!=data->tif->tif_dir.td_ycbcrsubsampling[0])||(pv!=data->tif->tif_dir.td_ycbcrsubsampling[1])) { TIFFWarningExt(data->tif->tif_clientdata,module, - "Auto-corrected former TIFF subsampling values [%d,%d] to match subsampling values inside JPEG compressed data [%d,%d]", - (int)data->tif->tif_dir.td_ycbcrsubsampling[0], - (int)data->tif->tif_dir.td_ycbcrsubsampling[1], - (int)ph,(int)pv); + "Auto-corrected former TIFF subsampling values [%"PRIu16",%"PRIu16"] to match subsampling values inside JPEG compressed data [%"PRIu8",%"PRIu8"]", + data->tif->tif_dir.td_ycbcrsubsampling[0], + data->tif->tif_dir.td_ycbcrsubsampling[1], + ph, pv); data->tif->tif_dir.td_ycbcrsubsampling[0]=ph; data->tif->tif_dir.td_ycbcrsubsampling[1]=pv; } @@ -938,11 +938,11 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) } static int -JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result) +JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8_t* result) { if (data->bufferbytesleft==0) { - uint32 m; + uint32_t m; if (data->filebytesleft==0) return(0); if (!data->filepositioned) @@ -954,8 +954,8 @@ JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint data->filepositioned=1; } m=data->buffersize; - if ((uint64)m>data->filebytesleft) - m=(uint32)data->filebytesleft; + if ((uint64_t)m > data->filebytesleft) + m=(uint32_t)data->filebytesleft; assert(m<0x80000000UL); if (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m) return(0); @@ -971,10 +971,10 @@ JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint } static int -JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result) +JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16_t* result) { - uint8 ma; - uint8 mb; + uint8_t ma; + uint8_t mb; if (!JPEGFixupTagsSubsamplingReadByte(data,&ma)) return(0); if (!JPEGFixupTagsSubsamplingReadByte(data,&mb)) @@ -984,17 +984,17 @@ JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint } static void -JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16 skiplength) +JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16_t skiplength) { - if ((uint32)skiplength<=data->bufferbytesleft) + if ((uint32_t)skiplength <= data->bufferbytesleft) { data->buffercurrentbyte+=skiplength; data->bufferbytesleft-=skiplength; } else { - uint16 m; - m=(uint16)(skiplength-data->bufferbytesleft); + uint16_t m; + m=(uint16_t)(skiplength - data->bufferbytesleft); if (m<=data->filebytesleft) { data->bufferbytesleft=0; @@ -1098,12 +1098,12 @@ int TIFFJPEGIsFullStripRequired(TIFF* tif) * Set up for decoding a strip or tile. */ /*ARGSUSED*/ static int -JPEGPreDecode(TIFF* tif, uint16 s) +JPEGPreDecode(TIFF* tif, uint16_t s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; static const char module[] = "JPEGPreDecode"; - uint32 segment_width, segment_height; + uint32_t segment_width, segment_height; int downsampled_output; int ci; @@ -1128,7 +1128,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) return (0); - tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcp = (uint8_t*) sp->src.next_input_byte; tif->tif_rawcc = sp->src.bytes_in_buffer; /* @@ -1157,7 +1157,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) sp->cinfo.d.image_height < segment_height) { TIFFWarningExt(tif->tif_clientdata, module, "Improper JPEG strip/tile size, " - "expected %dx%d, got %dx%d", + "expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); @@ -1172,7 +1172,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) /* we can safely recover from that. */ TIFFWarningExt(tif->tif_clientdata, module, "JPEG strip size exceeds expected dimensions," - " expected %dx%d, got %dx%d", + " expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); } @@ -1186,7 +1186,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) */ TIFFErrorExt(tif->tif_clientdata, module, "JPEG strip/tile size exceeds expected dimensions," - " expected %dx%d, got %dx%d", + " expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); return (0); @@ -1240,15 +1240,15 @@ JPEGPreDecode(TIFF* tif, uint16 s) { TIFFErrorExt(tif->tif_clientdata, module, "Reading this image would require libjpeg to allocate " - "at least %u bytes. " - "This is disabled since above the %u threshold. " + "at least %"PRIu64" bytes. " + "This is disabled since above the %ld threshold. " "You may override this restriction by defining the " "LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, " "or setting the JPEGMEM environment variable to a value greater " - "or equal to '%uM'", - (unsigned)(nRequiredMemory), - (unsigned)(sp->cinfo.d.mem->max_memory_to_use), - (unsigned)((nRequiredMemory + 1000000 - 1) / 1000000)); + "or equal to '%"PRIu64"M'", + nRequiredMemory, + sp->cinfo.d.mem->max_memory_to_use, + (nRequiredMemory + 1000000u - 1u) / 1000000u); return 0; } } @@ -1259,7 +1259,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG sampling factors %d,%d\n" - "Apparently should be %d,%d.", + "Apparently should be %"PRIu16",%"PRIu16".", sp->cinfo.d.comp_info[0].h_samp_factor, sp->cinfo.d.comp_info[0].v_samp_factor, sp->h_sampling, sp->v_sampling); @@ -1332,7 +1332,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) */ #if !JPEG_LIB_MK1_OR_12BIT static int -JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); tmsize_t nrows; @@ -1377,7 +1377,7 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) } /* Update information on consumed data */ - tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcp = (uint8_t*) sp->src.next_input_byte; tif->tif_rawcc = sp->src.bytes_in_buffer; /* Close down the decompressor if we've finished the strip or tile. */ @@ -1388,7 +1388,7 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) #if JPEG_LIB_MK1_OR_12BIT /*ARGSUSED*/ static int -JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); tmsize_t nrows; @@ -1483,7 +1483,7 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) } /* Update information on consumed data */ - tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcp = (uint8_t*) sp->src.next_input_byte; tif->tif_rawcc = sp->src.bytes_in_buffer; /* Close down the decompressor if we've finished the strip or tile. */ @@ -1493,7 +1493,7 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) #endif /* JPEG_LIB_MK1_OR_12BIT */ /*ARGSUSED*/ static int -DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +DecodeRowError(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { (void) buf; @@ -1510,7 +1510,7 @@ DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * Returned data is downsampled per sampling factors. */ /*ARGSUSED*/ static int -JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGDecodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); tmsize_t nrows; @@ -1521,7 +1521,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) /* For last strip, limit number of rows to its truncated height */ /* even if the codestream height is larger (which is not compliant, */ /* but that we tolerate) */ - if( (uint32)nrows > td->td_imagelength - tif->tif_row && !isTiled(tif) ) + if((uint32_t)nrows > td->td_imagelength - tif->tif_row && !isTiled(tif) ) nrows = td->td_imagelength - tif->tif_row; /* data is expected to be read in multiples of a scanline */ @@ -1793,7 +1793,7 @@ JPEGSetupEncode(TIFF* tif) if( td->td_bitspersample > 16 ) { TIFFErrorExt(tif->tif_clientdata, module, - "BitsPerSample %d not allowed for JPEG", + "BitsPerSample %"PRIu16" not allowed for JPEG", td->td_bitspersample); return (0); } @@ -1823,8 +1823,8 @@ JPEGSetupEncode(TIFF* tif) case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ case PHOTOMETRIC_MASK: TIFFErrorExt(tif->tif_clientdata, module, - "PhotometricInterpretation %d not allowed for JPEG", - (int) sp->photometric); + "PhotometricInterpretation %"PRIu16" not allowed for JPEG", + sp->photometric); return (0); default: /* TIFF 6.0 forbids subsampling of all other color spaces */ @@ -1847,8 +1847,8 @@ JPEGSetupEncode(TIFF* tif) if (td->td_bitspersample != BITS_IN_JSAMPLE ) #endif { - TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG", - (int) td->td_bitspersample); + TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %"PRIu16" not allowed for JPEG", + td->td_bitspersample); return (0); } sp->cinfo.c.data_precision = td->td_bitspersample; @@ -1858,22 +1858,22 @@ JPEGSetupEncode(TIFF* tif) if (isTiled(tif)) { if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "JPEG tile height must be multiple of %d", - sp->v_sampling * DCTSIZE); + "JPEG tile height must be multiple of %"PRIu32, + (uint32_t)(sp->v_sampling * DCTSIZE)); return (0); } if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "JPEG tile width must be multiple of %d", - sp->h_sampling * DCTSIZE); + "JPEG tile width must be multiple of %"PRIu32, + (uint32_t)(sp->h_sampling * DCTSIZE)); return (0); } } else { if (td->td_rowsperstrip < td->td_imagelength && (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "RowsPerStrip must be multiple of %d for JPEG", - sp->v_sampling * DCTSIZE); + "RowsPerStrip must be multiple of %"PRIu32" for JPEG", + (uint32_t)(sp->v_sampling * DCTSIZE)); return (0); } } @@ -1906,12 +1906,12 @@ JPEGSetupEncode(TIFF* tif) * Set encoding state at the start of a strip or tile. */ static int -JPEGPreEncode(TIFF* tif, uint16 s) +JPEGPreEncode(TIFF* tif, uint16_t s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; static const char module[] = "JPEGPreEncode"; - uint32 segment_width, segment_height; + uint32_t segment_width, segment_height; int downsampled_input; assert(sp != NULL); @@ -2043,7 +2043,7 @@ JPEGPreEncode(TIFF* tif, uint16 s) * "Standard" case: incoming data is not downsampled. */ static int -JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); tmsize_t nrows; @@ -2121,7 +2121,7 @@ JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * Incoming data is expected to be downsampled per sampling factors. */ static int -JPEGEncodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGEncodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); JSAMPLE* inptr; @@ -2295,17 +2295,17 @@ JPEGResetUpsampled( TIFF* tif ) } static int -JPEGVSetField(TIFF* tif, uint32 tag, va_list ap) +JPEGVSetField(TIFF* tif, uint32_t tag, va_list ap) { JPEGState* sp = JState(tif); const TIFFField* fip; - uint32 v32; + uint32_t v32; assert(sp != NULL); switch (tag) { case TIFFTAG_JPEGTABLES: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 == 0) { /* XXX */ return (0); @@ -2350,7 +2350,7 @@ JPEGVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -JPEGVGetField(TIFF* tif, uint32 tag, va_list ap) +JPEGVGetField(TIFF* tif, uint32_t tag, va_list ap) { JPEGState* sp = JState(tif); @@ -2358,7 +2358,7 @@ JPEGVGetField(TIFF* tif, uint32 tag, va_list ap) switch (tag) { case TIFFTAG_JPEGTABLES: - *va_arg(ap, uint32*) = sp->jpegtables_length; + *va_arg(ap, uint32_t*) = sp->jpegtables_length; *va_arg(ap, const void**) = sp->jpegtables; break; case TIFFTAG_JPEGQUALITY: @@ -2386,15 +2386,15 @@ JPEGPrintDir(TIFF* tif, FILE* fd, long flags) if( sp != NULL ) { if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) - fprintf(fd, " JPEG Tables: (%lu bytes)\n", - (unsigned long) sp->jpegtables_length); + fprintf(fd, " JPEG Tables: (%"PRIu32" bytes)\n", + sp->jpegtables_length); if (sp->printdir) (*sp->printdir)(tif, fd, flags); } } -static uint32 -JPEGDefaultStripSize(TIFF* tif, uint32 s) +static uint32_t +JPEGDefaultStripSize(TIFF* tif, uint32_t s) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; @@ -2406,7 +2406,7 @@ JPEGDefaultStripSize(TIFF* tif, uint32 s) } static void -JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) +JPEGDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; @@ -2510,7 +2510,7 @@ TIFFInitJPEG(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (JPEGState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (JPEGState)); if (tif->tif_data == NULL) { TIFFErrorExt(tif->tif_clientdata, diff --git a/tiff/libtiff/tif_lerc.c b/tiff/libtiff/tif_lerc.c new file mode 100644 index 00000000..a4aeb4a1 --- /dev/null +++ b/tiff/libtiff/tif_lerc.c @@ -0,0 +1,1277 @@ +/* +* Copyright (c) 2018, Even Rouault +* Author: <even.rouault at spatialys.com> +* +* Permission to use, copy, modify, distribute, and sell this software and +* its documentation for any purpose is hereby granted without fee, provided +* that (i) the above copyright notices and this permission notice appear in +* all copies of the software and related documentation, and (ii) the names of +* Sam Leffler and Silicon Graphics may not be used in any advertising or +* publicity relating to the software without the specific, prior written +* permission of Sam Leffler and Silicon Graphics. +* +* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +* +* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +* OF THIS SOFTWARE. +*/ + +#include "tiffiop.h" +#ifdef LERC_SUPPORT +/* +* TIFF Library. +* +* LERC Compression Support +* +*/ + +#include "Lerc_c_api.h" +#include "zlib.h" +#ifdef ZSTD_SUPPORT +#include "zstd.h" +#endif + +#if LIBDEFLATE_SUPPORT +#include "libdeflate.h" +#endif +#define LIBDEFLATE_MAX_COMPRESSION_LEVEL 12 + +#include <assert.h> + +#define LSTATE_INIT_DECODE 0x01 +#define LSTATE_INIT_ENCODE 0x02 + +#ifndef LERC_AT_LEAST_VERSION +#define LERC_AT_LEAST_VERSION(maj,min,patch) 0 +#endif + +/* +* State block for each open TIFF file using LERC compression/decompression. +*/ +typedef struct { + double maxzerror; /* max z error */ + int lerc_version; + int additional_compression; + int zstd_compress_level; /* zstd */ + int zipquality; /* deflate */ + int state; /* state flags */ + + uint32_t segment_width; + uint32_t segment_height; + + unsigned int uncompressed_size; + unsigned int uncompressed_alloc; + uint8_t *uncompressed_buffer; + unsigned int uncompressed_offset; + + unsigned int mask_size; + uint8_t *mask_buffer; + + unsigned int compressed_size; + void *compressed_buffer; + +#if LIBDEFLATE_SUPPORT + struct libdeflate_decompressor* libdeflate_dec; + struct libdeflate_compressor* libdeflate_enc; +#endif + + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ +} LERCState; + +#define LState(tif) ((LERCState*) (tif)->tif_data) +#define DecoderState(tif) LState(tif) +#define EncoderState(tif) LState(tif) + +static int LERCEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int LERCDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); + +static int +LERCFixupTags(TIFF* tif) +{ + (void) tif; + return 1; +} + +static int +LERCSetupDecode(TIFF* tif) +{ + LERCState* sp = DecoderState(tif); + + assert(sp != NULL); + + /* if we were last encoding, terminate this mode */ + if (sp->state & LSTATE_INIT_ENCODE) { + sp->state = 0; + } + + sp->state |= LSTATE_INIT_DECODE; + return 1; +} + +static int GetLercDataType(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "GetLercDataType"; + + if( td->td_sampleformat == SAMPLEFORMAT_INT && + td->td_bitspersample == 8 ) + { + return 0; + } + + if( td->td_sampleformat == SAMPLEFORMAT_UINT && + td->td_bitspersample == 8 ) + { + return 1; + } + + if( td->td_sampleformat == SAMPLEFORMAT_INT && + td->td_bitspersample == 16 ) + { + return 2; + } + + if( td->td_sampleformat == SAMPLEFORMAT_UINT && + td->td_bitspersample == 16 ) + { + return 3; + } + + if( td->td_sampleformat == SAMPLEFORMAT_INT && + td->td_bitspersample == 32 ) + { + return 4; + } + + if( td->td_sampleformat == SAMPLEFORMAT_UINT && + td->td_bitspersample == 32 ) + { + return 5; + } + + if( td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + td->td_bitspersample == 32 ) + { + return 6; + } + + if( td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + td->td_bitspersample == 64 ) + { + return 7; + } + + TIFFErrorExt(tif->tif_clientdata, module, + "Unsupported combination of SampleFormat and td_bitspersample"); + return -1; +} + +static int SetupUncompressedBuffer(TIFF* tif, LERCState* sp, + const char* module) +{ + TIFFDirectory *td = &tif->tif_dir; + uint64_t new_size_64; + uint64_t new_alloc_64; + unsigned int new_size; + unsigned int new_alloc; + + sp->uncompressed_offset = 0; + + if (isTiled(tif)) { + sp->segment_width = td->td_tilewidth; + sp->segment_height = td->td_tilelength; + } else { + sp->segment_width = td->td_imagewidth; + sp->segment_height = td->td_imagelength - tif->tif_row; + if (sp->segment_height > td->td_rowsperstrip) + sp->segment_height = td->td_rowsperstrip; + } + + new_size_64 = (uint64_t)sp->segment_width * sp->segment_height * + (td->td_bitspersample / 8); + if( td->td_planarconfig == PLANARCONFIG_CONTIG ) + { + new_size_64 *= td->td_samplesperpixel; + } + + new_size = (unsigned int)new_size_64; + sp->uncompressed_size = new_size; + + /* add some margin as we are going to use it also to store deflate/zstd compressed data */ + new_alloc_64 = 100 + new_size_64 + new_size_64 / 3; +#ifdef ZSTD_SUPPORT + { + size_t zstd_max = ZSTD_compressBound((size_t)new_size_64); + if( new_alloc_64 < zstd_max ) + { + new_alloc_64 = zstd_max; + } + } +#endif + new_alloc = (unsigned int)new_alloc_64; + if( new_alloc != new_alloc_64 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Too large uncompressed strip/tile"); + _TIFFfree(sp->uncompressed_buffer); + sp->uncompressed_buffer = 0; + sp->uncompressed_alloc = 0; + return 0; + } + + if( sp->uncompressed_alloc < new_alloc ) + { + _TIFFfree(sp->uncompressed_buffer); + sp->uncompressed_buffer = _TIFFmalloc(new_alloc); + if( !sp->uncompressed_buffer ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate buffer"); + _TIFFfree(sp->uncompressed_buffer); + sp->uncompressed_buffer = 0; + sp->uncompressed_alloc = 0; + return 0; + } + sp->uncompressed_alloc = new_alloc; + } + + if( (td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_extrasamples > 0 && + td->td_sampleinfo[td->td_extrasamples-1] == EXTRASAMPLE_UNASSALPHA && + GetLercDataType(tif) == 1 ) || + (td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + (td->td_planarconfig == PLANARCONFIG_SEPARATE || + td->td_samplesperpixel == 1) && + (td->td_bitspersample == 32 || td->td_bitspersample == 64 )) ) + { + unsigned int mask_size = sp->segment_width * sp->segment_height; + if( sp->mask_size < mask_size ) + { + void* mask_buffer = _TIFFrealloc(sp->mask_buffer, mask_size); + if( mask_buffer == NULL ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate buffer"); + sp->mask_size = 0; + _TIFFfree(sp->uncompressed_buffer); + sp->uncompressed_buffer = 0; + sp->uncompressed_alloc = 0; + return 0; + } + sp->mask_buffer = (uint8_t*)mask_buffer; + sp->mask_size = mask_size; + } + } + + return 1; +} + +/* +* Setup state for decoding a strip. +*/ +static int +LERCPreDecode(TIFF* tif, uint16_t s) +{ + static const char module[] = "LERCPreDecode"; + lerc_status lerc_ret; + TIFFDirectory *td = &tif->tif_dir; + LERCState* sp = DecoderState(tif); + int lerc_data_type; + unsigned int infoArray[8]; + unsigned nomask_bands = td->td_samplesperpixel; + int ndims; + int use_mask = 0; + uint8_t* lerc_data = tif->tif_rawcp; + unsigned int lerc_data_size = (unsigned int)tif->tif_rawcc; + + (void) s; + assert(sp != NULL); + if( sp->state != LSTATE_INIT_DECODE ) + tif->tif_setupdecode(tif); + + lerc_data_type = GetLercDataType(tif); + if( lerc_data_type < 0 ) + return 0; + + if( !SetupUncompressedBuffer(tif, sp, module) ) + return 0; + + if( sp->additional_compression != LERC_ADD_COMPRESSION_NONE ) + { + if( sp->compressed_size < sp->uncompressed_alloc ) + { + _TIFFfree(sp->compressed_buffer); + sp->compressed_buffer = _TIFFmalloc(sp->uncompressed_alloc); + if( !sp->compressed_buffer ) + { + sp->compressed_size = 0; + return 0; + } + sp->compressed_size = sp->uncompressed_alloc; + } + } + + if( sp->additional_compression == LERC_ADD_COMPRESSION_DEFLATE ) + { +#if LIBDEFLATE_SUPPORT + enum libdeflate_result res; + size_t lerc_data_sizet = 0; + if( sp->libdeflate_dec == NULL ) + { + sp->libdeflate_dec = libdeflate_alloc_decompressor(); + if( sp->libdeflate_dec == NULL ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate decompressor"); + return 0; + } + } + + res = libdeflate_zlib_decompress( + sp->libdeflate_dec, tif->tif_rawcp, (size_t)tif->tif_rawcc, + sp->compressed_buffer, sp->compressed_size, + &lerc_data_sizet); + if( res != LIBDEFLATE_SUCCESS ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Decoding error at scanline %lu", + (unsigned long) tif->tif_row); + return 0; + } + assert( lerc_data_sizet == (unsigned int)lerc_data_sizet ); + lerc_data = sp->compressed_buffer; + lerc_data_size = (unsigned int)lerc_data_sizet; +#else + z_stream strm; + int zlib_ret; + + memset(&strm, 0, sizeof(strm)); + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; + zlib_ret = inflateInit(&strm); + if( zlib_ret != Z_OK ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "inflateInit() failed"); + inflateEnd(&strm); + return 0; + } + + strm.avail_in = (uInt)tif->tif_rawcc; + strm.next_in = tif->tif_rawcp; + strm.avail_out = sp->compressed_size; + strm.next_out = sp->compressed_buffer; + zlib_ret = inflate(&strm, Z_FINISH); + if( zlib_ret != Z_STREAM_END && zlib_ret != Z_OK ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "inflate() failed"); + inflateEnd(&strm); + return 0; + } + lerc_data = sp->compressed_buffer; + lerc_data_size = sp->compressed_size - strm.avail_out; + inflateEnd(&strm); +#endif + } + else if( sp->additional_compression == LERC_ADD_COMPRESSION_ZSTD ) + { +#ifdef ZSTD_SUPPORT + size_t zstd_ret; + + zstd_ret = ZSTD_decompress(sp->compressed_buffer, + sp->compressed_size, + tif->tif_rawcp, + tif->tif_rawcc); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_decompress(): %s", + ZSTD_getErrorName(zstd_ret)); + return 0; + } + + lerc_data = sp->compressed_buffer; + lerc_data_size = (unsigned int)zstd_ret; +#else + TIFFErrorExt(tif->tif_clientdata, module, "ZSTD support missing"); + return 0; +#endif + } + else if( sp->additional_compression != LERC_ADD_COMPRESSION_NONE ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unhandled additional compression"); + return 0; + } + + lerc_ret = lerc_getBlobInfo( + lerc_data, + lerc_data_size, + infoArray, + NULL, + 8, + 0); + if( lerc_ret != 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "lerc_getBlobInfo() failed"); + return 0; + } + + /* If the configuration is compatible of a LERC mask, and that the */ + /* LERC info has dim == samplesperpixel - 1, then there is a LERC */ + /* mask. */ + if( td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_extrasamples > 0 && + td->td_sampleinfo[td->td_extrasamples-1] == EXTRASAMPLE_UNASSALPHA && + GetLercDataType(tif) == 1 && + infoArray[2] == td->td_samplesperpixel - 1U ) + { + use_mask = 1; + nomask_bands --; + } + else if( td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + (td->td_planarconfig == PLANARCONFIG_SEPARATE || + td->td_samplesperpixel == 1) && + (td->td_bitspersample == 32 || td->td_bitspersample == 64) ) + { + use_mask = 1; + } + + ndims = td->td_planarconfig == PLANARCONFIG_CONTIG ? + nomask_bands : 1; + + /* Info returned in infoArray is { version, dataType, nDim, nCols, + nRows, nBands, nValidPixels, blobSize } */ + if( infoArray[0] != (unsigned)sp->lerc_version ) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Unexpected version number: %d. Expected: %d", + infoArray[0], sp->lerc_version); + } + if( infoArray[1] != (unsigned)lerc_data_type ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected dataType: %d. Expected: %d", + infoArray[1], lerc_data_type); + return 0; + } + if( infoArray[2] != (unsigned)ndims ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected nDim: %d. Expected: %d", + infoArray[2], ndims); + return 0; + } + if( infoArray[3] != sp->segment_width ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected nCols: %d. Expected: %du", + infoArray[3], sp->segment_width); + return 0; + } + if( infoArray[4] != sp->segment_height ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected nRows: %d. Expected: %u", + infoArray[4], sp->segment_height); + return 0; + } + if( infoArray[5] != 1 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected nBands: %d. Expected: %d", + infoArray[5], 1); + return 0; + } + if( infoArray[7] != lerc_data_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected blobSize: %d. Expected: %u", + infoArray[7], + lerc_data_size); + return 0; + } + + lerc_ret = lerc_decode( + lerc_data, + lerc_data_size, +#if LERC_AT_LEAST_VERSION(3,0,0) + use_mask ? 1 : 0, +#endif + use_mask ? sp->mask_buffer : NULL, + ndims, + sp->segment_width, + sp->segment_height, + 1, + lerc_data_type, + sp->uncompressed_buffer); + if( lerc_ret != 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "lerc_decode() failed"); + return 0; + } + + /* Interleave alpha mask with other samples. */ + if( use_mask && GetLercDataType(tif) == 1 ) + { + unsigned src_stride = + (td->td_samplesperpixel - 1) * (td->td_bitspersample / 8); + unsigned dst_stride = + td->td_samplesperpixel * (td->td_bitspersample / 8); + unsigned i = sp->segment_width * sp->segment_height; + /* Operate from end to begin to be able to move in place */ + while( i > 0 && i > nomask_bands ) + { + i --; + sp->uncompressed_buffer[ + i * dst_stride + td->td_samplesperpixel - 1] = + 255 * sp->mask_buffer[i]; + memcpy( sp->uncompressed_buffer + i * dst_stride, + sp->uncompressed_buffer + i * src_stride, + src_stride ); + } + /* First pixels must use memmove due to overlapping areas */ + while( i > 0 ) + { + i --; + sp->uncompressed_buffer[ + i * dst_stride + td->td_samplesperpixel - 1] = + 255 * sp->mask_buffer[i]; + memmove( sp->uncompressed_buffer + i * dst_stride, + sp->uncompressed_buffer + i * src_stride, + src_stride ); + } + } + else if( use_mask && td->td_sampleformat == SAMPLEFORMAT_IEEEFP ) + { + const unsigned nb_pixels = sp->segment_width * sp->segment_height; + unsigned i; +#if HOST_BIGENDIAN + const unsigned char nan_bytes[] = { 0x7f, 0xc0, 0, 0 }; +#else + const unsigned char nan_bytes[] = { 0, 0, 0xc0, 0x7f }; +#endif + float nan_float32; + memcpy(&nan_float32, nan_bytes, 4); + + if( td->td_bitspersample == 32 ) + { + for( i = 0; i < nb_pixels; i++ ) + { + if( sp->mask_buffer[i] == 0 ) + ((float*)sp->uncompressed_buffer)[i] = nan_float32; + } + } + else + { + const double nan_float64 = nan_float32; + for( i = 0; i < nb_pixels; i++ ) + { + if( sp->mask_buffer[i] == 0 ) + ((double*)sp->uncompressed_buffer)[i] = nan_float64; + } + } + } + + return 1; +} + +/* +* Decode a strip, tile or scanline. +*/ +static int +LERCDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) +{ + static const char module[] = "LERCDecode"; + LERCState* sp = DecoderState(tif); + + (void) s; + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_DECODE); + + if( sp->uncompressed_buffer == 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Uncompressed buffer not allocated"); + return 0; + } + + if( (uint64_t)sp->uncompressed_offset + + (uint64_t)occ > sp->uncompressed_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Too many bytes read"); + return 0; + } + + memcpy(op, + sp->uncompressed_buffer + sp->uncompressed_offset, + occ); + sp->uncompressed_offset += (unsigned)occ; + + return 1; +} + +static int +LERCSetupEncode(TIFF* tif) +{ + LERCState* sp = EncoderState(tif); + + assert(sp != NULL); + if (sp->state & LSTATE_INIT_DECODE) { + sp->state = 0; + } + + sp->state |= LSTATE_INIT_ENCODE; + + return 1; +} + +/* +* Reset encoding state at the start of a strip. +*/ +static int +LERCPreEncode(TIFF* tif, uint16_t s) +{ + static const char module[] = "LERCPreEncode"; + LERCState *sp = EncoderState(tif); + int lerc_data_type; + + (void) s; + assert(sp != NULL); + if( sp->state != LSTATE_INIT_ENCODE ) + tif->tif_setupencode(tif); + + lerc_data_type = GetLercDataType(tif); + if( lerc_data_type < 0 ) + return 0; + + if( !SetupUncompressedBuffer(tif, sp, module) ) + return 0; + + return 1; +} + +/* +* Encode a chunk of pixels. +*/ +static int +LERCEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) +{ + static const char module[] = "LERCEncode"; + LERCState *sp = EncoderState(tif); + + (void)s; + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_ENCODE); + + if( (uint64_t)sp->uncompressed_offset + + (uint64_t)cc > sp->uncompressed_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Too many bytes written"); + return 0; + } + + memcpy(sp->uncompressed_buffer + sp->uncompressed_offset, + bp, cc); + sp->uncompressed_offset += (unsigned)cc; + + return 1; +} + +/* +* Finish off an encoded strip by flushing it. +*/ +static int +LERCPostEncode(TIFF* tif) +{ + lerc_status lerc_ret; + static const char module[] = "LERCPostEncode"; + LERCState *sp = EncoderState(tif); + unsigned int numBytes = 0; + unsigned int numBytesWritten = 0; + TIFFDirectory *td = &tif->tif_dir; + int use_mask = 0; + unsigned dst_nbands = td->td_samplesperpixel; + + if( sp->uncompressed_offset != sp->uncompressed_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected number of bytes in the buffer"); + return 0; + } + + /* Extract alpha mask (if containing only 0 and 255 values, */ + /* and compact array of regular bands */ + if( td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_extrasamples > 0 && + td->td_sampleinfo[td->td_extrasamples-1] == EXTRASAMPLE_UNASSALPHA && + GetLercDataType(tif) == 1 ) + { + const unsigned dst_stride = (td->td_samplesperpixel - 1) * + (td->td_bitspersample / 8); + const unsigned src_stride = td->td_samplesperpixel * + (td->td_bitspersample / 8); + unsigned i = 0; + const unsigned nb_pixels = sp->segment_width * sp->segment_height; + + use_mask = 1; + for( i = 0 ; i < nb_pixels; i++) + { + int v = sp->uncompressed_buffer[ + i * src_stride + td->td_samplesperpixel - 1]; + if( v != 0 && v != 255 ) + { + use_mask = 0; + break; + } + } + + if( use_mask ) + { + dst_nbands --; + /* First pixels must use memmove due to overlapping areas */ + for( i = 0 ;i < dst_nbands && i < nb_pixels; i++) + { + memmove( sp->uncompressed_buffer + i * dst_stride, + sp->uncompressed_buffer + i * src_stride, + dst_stride ); + sp->mask_buffer[i] = sp->uncompressed_buffer[ + i * src_stride + td->td_samplesperpixel - 1]; + } + for(; i < nb_pixels; i++) + { + memcpy( sp->uncompressed_buffer + i * dst_stride, + sp->uncompressed_buffer + i * src_stride, + dst_stride ); + sp->mask_buffer[i] = sp->uncompressed_buffer[ + i * src_stride + td->td_samplesperpixel - 1]; + } + } + } + else if( td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + (td->td_planarconfig == PLANARCONFIG_SEPARATE || + dst_nbands == 1) && + (td->td_bitspersample == 32 || td->td_bitspersample == 64 ) ) + { + /* Check for NaN values */ + unsigned i; + const unsigned nb_pixels = sp->segment_width * sp->segment_height; + if( td->td_bitspersample == 32 ) + { + for( i = 0; i < nb_pixels; i++ ) + { + const float val = ((float*)sp->uncompressed_buffer)[i]; + if( val != val ) + { + use_mask = 1; + break; + } + } + } + else + { + for( i = 0; i < nb_pixels; i++ ) + { + const double val = ((double*)sp->uncompressed_buffer)[i]; + if( val != val ) + { + use_mask = 1; + break; + } + } + } + + if( use_mask ) + { + if( td->td_bitspersample == 32 ) + { + for( i = 0; i < nb_pixels; i++ ) + { + const float val = ((float*)sp->uncompressed_buffer)[i]; + sp->mask_buffer[i] = ( val == val ) ? 255 : 0; + } + } + else + { + for( i = 0; i < nb_pixels; i++ ) + { + const double val = ((double*)sp->uncompressed_buffer)[i]; + sp->mask_buffer[i] = ( val == val ) ? 255 : 0; + } + } + } + } + + +#if 0 + lerc_ret = lerc_computeCompressedSize( + sp->uncompressed_buffer, + sp->lerc_version, + GetLercDataType(tif), + td->td_planarconfig == PLANARCONFIG_CONTIG ? + dst_nbands : 1, + sp->segment_width, + sp->segment_height, + 1, + use_mask ? sp->mask_buffer : NULL, + sp->maxzerror, + &numBytes); + if( lerc_ret != 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "lerc_computeCompressedSize() failed"); + return 0; + } +#else + numBytes = sp->uncompressed_alloc; +#endif + + if( sp->compressed_size < numBytes ) + { + _TIFFfree(sp->compressed_buffer); + sp->compressed_buffer = _TIFFmalloc(numBytes); + if( !sp->compressed_buffer ) + { + sp->compressed_size = 0; + return 0; + } + sp->compressed_size = numBytes; + } + + lerc_ret = lerc_encodeForVersion( + sp->uncompressed_buffer, + sp->lerc_version, + GetLercDataType(tif), + td->td_planarconfig == PLANARCONFIG_CONTIG ? + dst_nbands : 1, + sp->segment_width, + sp->segment_height, + 1, +#if LERC_AT_LEAST_VERSION(3,0,0) + use_mask ? 1 : 0, +#endif + use_mask ? sp->mask_buffer : NULL, + sp->maxzerror, + sp->compressed_buffer, + sp->compressed_size, + &numBytesWritten); + if( lerc_ret != 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "lerc_encode() failed"); + return 0; + } + assert( numBytesWritten < numBytes ); + + if( sp->additional_compression == LERC_ADD_COMPRESSION_DEFLATE ) + { +#if LIBDEFLATE_SUPPORT + if( sp->libdeflate_enc == NULL ) + { + /* To get results as good as zlib, we ask for an extra */ + /* level of compression */ + sp->libdeflate_enc = libdeflate_alloc_compressor( + sp->zipquality == Z_DEFAULT_COMPRESSION ? 7 : + sp->zipquality >= 6 && sp->zipquality <= 9 ? sp->zipquality + 1 : + sp->zipquality); + if( sp->libdeflate_enc == NULL ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate compressor"); + return 0; + } + } + + /* Should not happen normally */ + if( libdeflate_zlib_compress_bound(sp->libdeflate_enc, numBytesWritten) > + sp->uncompressed_alloc ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Output buffer for libdeflate too small"); + return 0; + } + + tif->tif_rawcc = libdeflate_zlib_compress( + sp->libdeflate_enc, + sp->compressed_buffer, numBytesWritten, + sp->uncompressed_buffer, sp->uncompressed_alloc); + + if( tif->tif_rawcc == 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Encoder error at scanline %lu", + (unsigned long) tif->tif_row); + return 0; + } +#else + z_stream strm; + int zlib_ret; + int cappedQuality = sp->zipquality; + if( cappedQuality > Z_BEST_COMPRESSION ) + cappedQuality = Z_BEST_COMPRESSION; + + memset(&strm, 0, sizeof(strm)); + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; + zlib_ret = deflateInit(&strm, cappedQuality); + if( zlib_ret != Z_OK ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "deflateInit() failed"); + return 0; + } + + strm.avail_in = numBytesWritten; + strm.next_in = sp->compressed_buffer; + strm.avail_out = sp->uncompressed_alloc; + strm.next_out = sp->uncompressed_buffer; + zlib_ret = deflate(&strm, Z_FINISH); + if( zlib_ret == Z_STREAM_END ) + { + tif->tif_rawcc = sp->uncompressed_alloc - strm.avail_out; + } + deflateEnd(&strm); + if( zlib_ret != Z_STREAM_END ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "deflate() failed"); + return 0; + } +#endif + { + int ret; + uint8_t* tif_rawdata_backup = tif->tif_rawdata; + tif->tif_rawdata = sp->uncompressed_buffer; + ret = TIFFFlushData1(tif); + tif->tif_rawdata = tif_rawdata_backup; + if( !ret ) + { + return 0; + } + } + } + else if( sp->additional_compression == LERC_ADD_COMPRESSION_ZSTD ) + { +#ifdef ZSTD_SUPPORT + size_t zstd_ret = ZSTD_compress( sp->uncompressed_buffer, + sp->uncompressed_alloc, + sp->compressed_buffer, + numBytesWritten, + sp->zstd_compress_level ); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_compress(): %s", + ZSTD_getErrorName(zstd_ret)); + return 0; + } + + { + int ret; + uint8_t* tif_rawdata_backup = tif->tif_rawdata; + tif->tif_rawdata = sp->uncompressed_buffer; + tif->tif_rawcc = zstd_ret; + ret = TIFFFlushData1(tif); + tif->tif_rawdata = tif_rawdata_backup; + if( !ret ) + { + return 0; + } + } +#else + TIFFErrorExt(tif->tif_clientdata, module, "ZSTD support missing"); + return 0; +#endif + } + else if( sp->additional_compression != LERC_ADD_COMPRESSION_NONE ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unhandled additional compression"); + return 0; + } + else + { + int ret; + uint8_t* tif_rawdata_backup = tif->tif_rawdata; + tif->tif_rawdata = sp->compressed_buffer; + tif->tif_rawcc = numBytesWritten; + ret = TIFFFlushData1(tif); + tif->tif_rawdata = tif_rawdata_backup; + if( !ret ) + return 0; + } + + return 1; +} + +static void +LERCCleanup(TIFF* tif) +{ + LERCState* sp = LState(tif); + + assert(sp != 0); + + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; + + _TIFFfree(sp->uncompressed_buffer); + _TIFFfree(sp->compressed_buffer); + _TIFFfree(sp->mask_buffer); + +#if LIBDEFLATE_SUPPORT + if( sp->libdeflate_dec ) + libdeflate_free_decompressor(sp->libdeflate_dec); + if( sp->libdeflate_enc ) + libdeflate_free_compressor(sp->libdeflate_enc); +#endif + + _TIFFfree(sp); + tif->tif_data = NULL; + + _TIFFSetDefaultCompressionState(tif); +} + +static const TIFFField LERCFields[] = { + { TIFFTAG_LERC_PARAMETERS, TIFF_VARIABLE2, TIFF_VARIABLE2, + TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, + FIELD_CUSTOM, FALSE, TRUE, "LercParameters", NULL }, + { TIFFTAG_LERC_MAXZERROR, 0, 0, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "LercMaximumError", NULL }, + { TIFFTAG_LERC_VERSION, 0, 0, TIFF_ANY, 0, TIFF_SETGET_UINT32, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, FALSE, FALSE, "LercVersion", NULL }, + { TIFFTAG_LERC_ADD_COMPRESSION, 0, 0, TIFF_ANY, 0, TIFF_SETGET_UINT32, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, FALSE, FALSE, "LercAdditionalCompression", NULL }, + { TIFFTAG_ZSTD_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "ZSTD zstd_compress_level", NULL }, + { TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, + TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL }, +}; + +static int LERCVSetFieldBase(TIFF* tif, uint32_t tag, ...) +{ + LERCState* sp = LState(tif); + int ret; + va_list ap; + va_start(ap, tag); + ret = (*sp->vsetparent)(tif, tag, ap); + va_end(ap); + return ret; +} + +static int +LERCVSetField(TIFF* tif, uint32_t tag, va_list ap) +{ + static const char module[] = "LERCVSetField"; + LERCState* sp = LState(tif); + + switch (tag) { + case TIFFTAG_LERC_PARAMETERS: + { + uint32_t count = va_arg(ap, int); + int* params = va_arg(ap, int*); + if( count < 2 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid count for LercParameters: %u", count); + return 0; + } + sp->lerc_version = params[0]; + sp->additional_compression = params[1]; + return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, + count, params); + } + case TIFFTAG_LERC_MAXZERROR: + sp->maxzerror = va_arg(ap, double); + return 1; + case TIFFTAG_LERC_VERSION: + { + int params[2] = {0, 0}; + int version = va_arg(ap, int); + if( version != LERC_VERSION_2_4 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid value for LercVersion: %d", version); + return 0; + } + sp->lerc_version = version; + params[0] = sp->lerc_version; + params[1] = sp->additional_compression; + return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, + 2, params); + } + case TIFFTAG_LERC_ADD_COMPRESSION: + { + int params[2] = {0, 0}; + int additional_compression = va_arg(ap, int); +#ifndef ZSTD_SUPPORT + if( additional_compression == LERC_ADD_COMPRESSION_ZSTD ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "LERC_ZSTD requested, but ZSTD not available"); + return 0; + } +#endif + if( additional_compression != LERC_ADD_COMPRESSION_NONE && + additional_compression != LERC_ADD_COMPRESSION_DEFLATE && + additional_compression != LERC_ADD_COMPRESSION_ZSTD ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid value for LercAdditionalCompression: %d", + additional_compression); + return 0; + } + sp->additional_compression = additional_compression; + params[0] = sp->lerc_version; + params[1] = sp->additional_compression; + return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, + 2, params); + } +#ifdef ZSTD_SUPPORT + case TIFFTAG_ZSTD_LEVEL: + { + sp->zstd_compress_level = (int) va_arg(ap, int); + if( sp->zstd_compress_level <= 0 || + sp->zstd_compress_level > ZSTD_maxCLevel() ) + { + TIFFWarningExt(tif->tif_clientdata, module, + "ZSTD_LEVEL should be between 1 and %d", + ZSTD_maxCLevel()); + } + return 1; + } +#endif + case TIFFTAG_ZIPQUALITY: + { + sp->zipquality = (int) va_arg(ap, int); + if( sp->zipquality < Z_DEFAULT_COMPRESSION || + sp->zipquality > LIBDEFLATE_MAX_COMPRESSION_LEVEL ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid ZipQuality value. Should be in [-1,%d] range", + LIBDEFLATE_MAX_COMPRESSION_LEVEL); + return 0; + } + +#if LIBDEFLATE_SUPPORT + if( sp->libdeflate_enc ) + { + libdeflate_free_compressor(sp->libdeflate_enc); + sp->libdeflate_enc = NULL; + } +#endif + + return (1); + } + default: + return (*sp->vsetparent)(tif, tag, ap); + } + /*NOTREACHED*/ +} + +static int +LERCVGetField(TIFF* tif, uint32_t tag, va_list ap) +{ + LERCState* sp = LState(tif); + + switch (tag) { + case TIFFTAG_LERC_MAXZERROR: + *va_arg(ap, double*) = sp->maxzerror; + break; + case TIFFTAG_LERC_VERSION: + *va_arg(ap, int*) = sp->lerc_version; + break; + case TIFFTAG_LERC_ADD_COMPRESSION: + *va_arg(ap, int*) = sp->additional_compression; + break; + case TIFFTAG_ZSTD_LEVEL: + *va_arg(ap, int*) = sp->zstd_compress_level; + break; + case TIFFTAG_ZIPQUALITY: + *va_arg(ap, int*) = sp->zipquality; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return 1; +} + +int TIFFInitLERC(TIFF* tif, int scheme) +{ + static const char module[] = "TIFFInitLERC"; + LERCState* sp; + + (void) scheme; + assert( scheme == COMPRESSION_LERC ); + + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, LERCFields, TIFFArrayCount(LERCFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging LERC codec-specific tags failed"); + return 0; + } + + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8_t*) _TIFFcalloc(1, sizeof(LERCState)); + if (tif->tif_data == NULL) + goto bad; + sp = LState(tif); + + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = LERCVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = LERCVSetField; /* hook for codec tags */ + + /* + * Install codec methods. + */ + tif->tif_fixuptags = LERCFixupTags; + tif->tif_setupdecode = LERCSetupDecode; + tif->tif_predecode = LERCPreDecode; + tif->tif_decoderow = LERCDecode; + tif->tif_decodestrip = LERCDecode; + tif->tif_decodetile = LERCDecode; + tif->tif_setupencode = LERCSetupEncode; + tif->tif_preencode = LERCPreEncode; + tif->tif_postencode = LERCPostEncode; + tif->tif_encoderow = LERCEncode; + tif->tif_encodestrip = LERCEncode; + tif->tif_encodetile = LERCEncode; + tif->tif_cleanup = LERCCleanup; + + /* Default values for codec-specific fields */ + TIFFSetField(tif, TIFFTAG_LERC_VERSION, LERC_VERSION_2_4); + TIFFSetField(tif, TIFFTAG_LERC_ADD_COMPRESSION, LERC_ADD_COMPRESSION_NONE); + sp->maxzerror = 0.0; + sp->zstd_compress_level = 9; /* default comp. level */ + sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */ + sp->state = 0; + + return 1; +bad: + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LERC state block"); + return 0; +} +#endif /* LERC_SUPPORT */ diff --git a/tiff/libtiff/tif_luv.c b/tiff/libtiff/tif_luv.c index 3bd02e88..13765eab 100644 --- a/tiff/libtiff/tif_luv.c +++ b/tiff/libtiff/tif_luv.c @@ -161,9 +161,9 @@ struct logLuvState { int encode_meth; /* encoding method */ int pixel_size; /* bytes per pixel */ - uint8* tbuf; /* translation buffer */ + uint8_t* tbuf; /* translation buffer */ tmsize_t tbuflen; /* buffer length */ - void (*tfunc)(LogLuvState*, uint8*, tmsize_t); + void (*tfunc)(LogLuvState*, uint8_t*, tmsize_t); TIFFVSetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ @@ -180,7 +180,7 @@ struct logLuvState { * Decode a string of 16-bit gray pixels. */ static int -LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogL16Decode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogL16Decode"; LogLuvState* sp = DecoderState(tif); @@ -188,8 +188,8 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - int16* tp; - int16 b; + int16_t* tp; + int16_t b; tmsize_t cc; int rc; @@ -200,14 +200,14 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) op; + tp = (int16_t*) op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (int16*) sp->tbuf; + tp = (int16_t*) sp->tbuf; } _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); @@ -220,35 +220,28 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) if( cc < 2 ) break; rc = *bp++ + (2-128); - b = (int16)(*bp++ << shft); + b = (int16_t)(*bp++ << shft); cc -= 2; while (rc-- && i < npixels) tp[i++] |= b; } else { /* non-run */ rc = *bp++; /* nul is noop */ while (--cc && rc-- && i < npixels) - tp[i++] |= (int16)*bp++ << shft; + tp[i++] |= (int16_t)*bp++ << shft; } } if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif - tif->tif_rawcp = (uint8*) bp; + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (0); } } (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (1); } @@ -257,7 +250,7 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * Decode a string of 24-bit pixels. */ static int -LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogLuvDecode24(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogLuvDecode24"; LogLuvState* sp = DecoderState(tif); @@ -265,7 +258,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - uint32* tp; + uint32_t* tp; (void)s; assert(s == 0); @@ -274,16 +267,16 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32 *)op; + tp = (uint32_t *)op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (uint32 *) sp->tbuf; + tp = (uint32_t *) sp->tbuf; } - /* copy to array of uint32 */ + /* copy to array of uint32_t */ bp = (unsigned char*) tif->tif_rawcp; cc = tif->tif_rawcc; for (i = 0; i < npixels && cc >= 3; i++) { @@ -291,20 +284,13 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) bp += 3; cc -= 3; } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); return (0); } (*sp->tfunc)(sp, op, npixels); @@ -315,7 +301,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * Decode a string of 32-bit pixels. */ static int -LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogLuvDecode32(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogLuvDecode32"; LogLuvState* sp; @@ -323,8 +309,8 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - uint32* tp; - uint32 b; + uint32_t* tp; + uint32_t b; tmsize_t cc; int rc; @@ -336,14 +322,14 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) op; + tp = (uint32_t*) op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; } _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); @@ -356,35 +342,28 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) if( cc < 2 ) break; rc = *bp++ + (2-128); - b = (uint32)*bp++ << shft; + b = (uint32_t)*bp++ << shft; cc -= 2; while (rc-- && i < npixels) tp[i++] |= b; } else { /* non-run */ rc = *bp++; /* nul is noop */ while (--cc && rc-- && i < npixels) - tp[i++] |= (uint32)*bp++ << shft; + tp[i++] |= (uint32_t)*bp++ << shft; } } if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif - tif->tif_rawcp = (uint8*) bp; + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (0); } } (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (1); } @@ -395,7 +374,7 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * is row by row. */ static int -LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvDecodeStrip(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFScanlineSize(tif); @@ -416,7 +395,7 @@ LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * is row by row. */ static int -LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvDecodeTile(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFTileRowSize(tif); @@ -435,7 +414,7 @@ LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 16-bit pixels. */ static int -LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogL16Encode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogL16Encode"; LogLuvState* sp = EncoderState(tif); @@ -443,9 +422,9 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) tmsize_t i; tmsize_t j; tmsize_t npixels; - uint8* op; - int16* tp; - int16 b; + uint8_t* op; + int16_t* tp; + int16_t b; tmsize_t occ; int rc=0, mask; tmsize_t beg; @@ -456,9 +435,9 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) bp; + tp = (int16_t*) bp; else { - tp = (int16*) sp->tbuf; + tp = (int16_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -481,7 +460,7 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } mask = 0xff << shft; /* find next run */ for (beg = i; beg < npixels; beg += rc) { - b = (int16) (tp[beg] & mask); + b = (int16_t) (tp[beg] & mask); rc = 1; while (rc < 127+2 && beg+rc < npixels && (tp[beg+rc] & mask) == b) @@ -490,12 +469,12 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) break; /* long enough */ } if (beg-i > 1 && beg-i < MINRUN) { - b = (int16) (tp[i] & mask);/*check short run */ + b = (int16_t) (tp[i] & mask);/*check short run */ j = i+1; while ((tp[j++] & mask) == b) if (j == beg) { - *op++ = (uint8)(128-2+j-i); - *op++ = (uint8)(b >> shft); + *op++ = (uint8_t)(128 - 2 + j - i); + *op++ = (uint8_t)(b >> shft); occ -= 2; i = beg; break; @@ -511,15 +490,15 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8) j; occ--; + *op++ = (uint8_t) j; occ--; while (j--) { - *op++ = (uint8) (tp[i++] >> shft & 0xff); + *op++ = (uint8_t) (tp[i++] >> shft & 0xff); occ--; } } if (rc >= MINRUN) { /* write out run */ - *op++ = (uint8) (128-2+rc); - *op++ = (uint8) (tp[beg] >> shft & 0xff); + *op++ = (uint8_t) (128 - 2 + rc); + *op++ = (uint8_t) (tp[beg] >> shft & 0xff); occ -= 2; } else rc = 0; @@ -535,15 +514,15 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 24-bit pixels. */ static int -LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncode24(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogLuvEncode24"; LogLuvState* sp = EncoderState(tif); tmsize_t i; tmsize_t npixels; tmsize_t occ; - uint8* op; - uint32* tp; + uint8_t* op; + uint32_t* tp; (void)s; assert(s == 0); @@ -551,9 +530,9 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; + tp = (uint32_t*) bp; else { - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -573,9 +552,9 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8)(*tp >> 16); - *op++ = (uint8)(*tp >> 8 & 0xff); - *op++ = (uint8)(*tp++ & 0xff); + *op++ = (uint8_t)(*tp >> 16); + *op++ = (uint8_t)(*tp >> 8 & 0xff); + *op++ = (uint8_t)(*tp++ & 0xff); occ -= 3; } tif->tif_rawcp = op; @@ -588,7 +567,7 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 32-bit pixels. */ static int -LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncode32(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogLuvEncode32"; LogLuvState* sp = EncoderState(tif); @@ -596,9 +575,9 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) tmsize_t i; tmsize_t j; tmsize_t npixels; - uint8* op; - uint32* tp; - uint32 b; + uint8_t* op; + uint32_t* tp; + uint32_t b; tmsize_t occ; int rc=0, mask; tmsize_t beg; @@ -610,9 +589,9 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; + tp = (uint32_t*) bp; else { - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -648,8 +627,8 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) j = i+1; while ((tp[j++] & mask) == b) if (j == beg) { - *op++ = (uint8)(128-2+j-i); - *op++ = (uint8)(b >> shft); + *op++ = (uint8_t)(128 - 2 + j - i); + *op++ = (uint8_t)(b >> shft); occ -= 2; i = beg; break; @@ -665,15 +644,15 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8) j; occ--; + *op++ = (uint8_t) j; occ--; while (j--) { - *op++ = (uint8)(tp[i++] >> shft & 0xff); + *op++ = (uint8_t)(tp[i++] >> shft & 0xff); occ--; } } if (rc >= MINRUN) { /* write out run */ - *op++ = (uint8) (128-2+rc); - *op++ = (uint8)(tp[beg] >> shft & 0xff); + *op++ = (uint8_t) (128 - 2 + rc); + *op++ = (uint8_t)(tp[beg] >> shft & 0xff); occ -= 2; } else rc = 0; @@ -690,7 +669,7 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncodeStrip(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFScanlineSize(tif); @@ -710,7 +689,7 @@ LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncodeTile(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFTileRowSize(tif); @@ -790,9 +769,9 @@ LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */ } static void -L16toY(LogLuvState* sp, uint8* op, tmsize_t n) +L16toY(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; + int16_t* l16 = (int16_t*) sp->tbuf; float* yp = (float*) op; while (n-- > 0) @@ -800,32 +779,32 @@ L16toY(LogLuvState* sp, uint8* op, tmsize_t n) } static void -L16toGry(LogLuvState* sp, uint8* op, tmsize_t n) +L16toGry(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; - uint8* gp = (uint8*) op; + int16_t* l16 = (int16_t*) sp->tbuf; + uint8_t* gp = (uint8_t*) op; while (n-- > 0) { double Y = LogL16toY(*l16++); - *gp++ = (uint8) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y))); + *gp++ = (uint8_t) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256. * sqrt(Y))); } } static void -L16fromY(LogLuvState* sp, uint8* op, tmsize_t n) +L16fromY(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; + int16_t* l16 = (int16_t*) sp->tbuf; float* yp = (float*) op; while (n-- > 0) - *l16++ = (int16) (LogL16fromY(*yp++, sp->encode_meth)); + *l16++ = (int16_t) (LogL16fromY(*yp++, sp->encode_meth)); } #if !LOGLUV_PUBLIC static #endif void -XYZtoRGB24(float xyz[3], uint8 rgb[3]) +XYZtoRGB24(float xyz[3], uint8_t rgb[3]) { double r, g, b; /* assume CCIR-709 primaries */ @@ -834,9 +813,9 @@ XYZtoRGB24(float xyz[3], uint8 rgb[3]) b = 0.061*xyz[0] + -0.224*xyz[1] + 1.163*xyz[2]; /* assume 2.0 gamma for speed */ /* could use integer sqrt approx., but this is probably faster */ - rgb[0] = (uint8)((r<=0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r))); - rgb[1] = (uint8)((g<=0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g))); - rgb[2] = (uint8)((b<=0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b))); + rgb[0] = (uint8_t)((r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256. * sqrt(r))); + rgb[1] = (uint8_t)((g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256. * sqrt(g))); + rgb[2] = (uint8_t)((b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256. * sqrt(b))); } #if !LOGLUV_PUBLIC @@ -979,7 +958,7 @@ uv_decode(double *up, double *vp, int c) /* decode (u',v') index */ static #endif void -LogLuv24toXYZ(uint32 p, float XYZ[3]) +LogLuv24toXYZ(uint32_t p, float XYZ[3]) { int Ce; double L, u, v, s, x, y; @@ -1006,7 +985,7 @@ LogLuv24toXYZ(uint32 p, float XYZ[3]) #if !LOGLUV_PUBLIC static #endif -uint32 +uint32_t LogLuv24fromXYZ(float XYZ[3], int em) { int Le, Ce; @@ -1030,9 +1009,9 @@ LogLuv24fromXYZ(float XYZ[3], int em) } static void -Luv24toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1043,30 +1022,30 @@ Luv24toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { double u, v; - *luv3++ = (int16)((*luv >> 12 & 0xffd) + 13314); + *luv3++ = (int16_t)((*luv >> 12 & 0xffd) + 13314); if (uv_decode(&u, &v, *luv&0x3fff) < 0) { u = U_NEU; v = V_NEU; } - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); + *luv3++ = (int16_t)(u * (1L << 15)); + *luv3++ = (int16_t)(v * (1L << 15)); luv++; } } static void -Luv24toRGB(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toRGB(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + uint8_t* rgb = (uint8_t*) op; while (n-- > 0) { float xyz[3]; @@ -1078,9 +1057,9 @@ Luv24toRGB(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24fromXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1090,10 +1069,10 @@ Luv24fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24fromLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { int Le, Ce; @@ -1111,7 +1090,7 @@ Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) sp->encode_meth); if (Ce < 0) /* never happens */ Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); - *luv++ = (uint32)Le << 14 | Ce; + *luv++ = (uint32_t)Le << 14 | Ce; luv3 += 3; } } @@ -1120,7 +1099,7 @@ Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) static #endif void -LogLuv32toXYZ(uint32 p, float XYZ[3]) +LogLuv32toXYZ(uint32_t p, float XYZ[3]) { double L, u, v, s, x, y; /* decode luminance */ @@ -1144,7 +1123,7 @@ LogLuv32toXYZ(uint32 p, float XYZ[3]) #if !LOGLUV_PUBLIC static #endif -uint32 +uint32_t LogLuv32fromXYZ(float XYZ[3], int em) { unsigned int Le, ue, ve; @@ -1171,9 +1150,9 @@ LogLuv32fromXYZ(float XYZ[3], int em) } static void -Luv32toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1183,28 +1162,28 @@ Luv32toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { double u, v; - *luv3++ = (int16)(*luv >> 16); + *luv3++ = (int16_t)(*luv >> 16); u = 1./UVSCALE * ((*luv>>8 & 0xff) + .5); v = 1./UVSCALE * ((*luv & 0xff) + .5); - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); + *luv3++ = (int16_t)(u * (1L << 15)); + *luv3++ = (int16_t)(v * (1L << 15)); luv++; } } static void -Luv32toRGB(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toRGB(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + uint8_t* rgb = (uint8_t*) op; while (n-- > 0) { float xyz[3]; @@ -1216,9 +1195,9 @@ Luv32toRGB(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32fromXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1228,30 +1207,30 @@ Luv32fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32fromLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; if (sp->encode_meth == SGILOGENCODE_NODITHER) { while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (luv3[1]*(uint32)(UVSCALE+.5) >> 7 & 0xff00) | - (luv3[2]*(uint32)(UVSCALE+.5) >> 15 & 0xff); + *luv++ = (uint32_t)luv3[0] << 16 | + (luv3[1]*(uint32_t)(UVSCALE + .5) >> 7 & 0xff00) | + (luv3[2]*(uint32_t)(UVSCALE + .5) >> 15 & 0xff); luv3 += 3; } return; } while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (tiff_itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) | - (tiff_itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff); + *luv++ = (uint32_t)luv3[0] << 16 | + (tiff_itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) | + (tiff_itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff); luv3 += 3; } } static void -_logLuvNop(LogLuvState* sp, uint8* op, tmsize_t n) +_logLuvNop(LogLuvState* sp, uint8_t* op, tmsize_t n) { (void) sp; (void) op; (void) n; } @@ -1294,7 +1273,7 @@ LogL16InitState(TIFF* tif) if( td->td_samplesperpixel != 1 ) { TIFFErrorExt(tif->tif_clientdata, module, - "Sorry, can not handle LogL image with %s=%d", + "Sorry, can not handle LogL image with %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel); return 0; } @@ -1307,10 +1286,10 @@ LogL16InitState(TIFF* tif) sp->pixel_size = sizeof (float); break; case SGILOGDATAFMT_16BIT: - sp->pixel_size = sizeof (int16); + sp->pixel_size = sizeof (int16_t); break; case SGILOGDATAFMT_8BIT: - sp->pixel_size = sizeof (uint8); + sp->pixel_size = sizeof (uint8_t); break; default: TIFFErrorExt(tif->tif_clientdata, module, @@ -1323,8 +1302,8 @@ LogL16InitState(TIFF* tif) sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip); else sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength); - if (multiply_ms(sp->tbuflen, sizeof (int16)) == 0 || - (sp->tbuf = (uint8*) _TIFFmalloc(sp->tbuflen * sizeof (int16))) == NULL) { + if (multiply_ms(sp->tbuflen, sizeof (int16_t)) == 0 || + (sp->tbuf = (uint8_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16_t))) == NULL) { TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); return (0); } @@ -1406,13 +1385,13 @@ LogLuvInitState(TIFF* tif) sp->pixel_size = 3*sizeof (float); break; case SGILOGDATAFMT_16BIT: - sp->pixel_size = 3*sizeof (int16); + sp->pixel_size = 3*sizeof (int16_t); break; case SGILOGDATAFMT_RAW: - sp->pixel_size = sizeof (uint32); + sp->pixel_size = sizeof (uint32_t); break; case SGILOGDATAFMT_8BIT: - sp->pixel_size = 3*sizeof (uint8); + sp->pixel_size = 3*sizeof (uint8_t); break; default: TIFFErrorExt(tif->tif_clientdata, module, @@ -1425,8 +1404,8 @@ LogLuvInitState(TIFF* tif) sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip); else sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength); - if (multiply_ms(sp->tbuflen, sizeof (uint32)) == 0 || - (sp->tbuf = (uint8*) _TIFFmalloc(sp->tbuflen * sizeof (uint32))) == NULL) { + if (multiply_ms(sp->tbuflen, sizeof (uint32_t)) == 0 || + (sp->tbuf = (uint8_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32_t))) == NULL) { TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); return (0); } @@ -1495,7 +1474,7 @@ LogLuvSetupDecode(TIFF* tif) return (1); default: TIFFErrorExt(tif->tif_clientdata, module, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); break; } @@ -1559,7 +1538,7 @@ LogLuvSetupEncode(TIFF* tif) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); return (0); } @@ -1617,7 +1596,7 @@ LogLuvCleanup(TIFF* tif) } static int -LogLuvVSetField(TIFF* tif, uint32 tag, va_list ap) +LogLuvVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "LogLuvVSetField"; LogLuvState* sp = DecoderState(tif); @@ -1680,7 +1659,7 @@ LogLuvVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -LogLuvVGetField(TIFF* tif, uint32 tag, va_list ap) +LogLuvVGetField(TIFF* tif, uint32_t tag, va_list ap) { LogLuvState *sp = (LogLuvState *)tif->tif_data; @@ -1719,7 +1698,7 @@ TIFFInitSGILog(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LogLuvState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (LogLuvState)); if (tif->tif_data == NULL) goto bad; sp = (LogLuvState*) tif->tif_data; diff --git a/tiff/libtiff/tif_lzma.c b/tiff/libtiff/tif_lzma.c index e150bd63..fc046475 100644 --- a/tiff/libtiff/tif_lzma.c +++ b/tiff/libtiff/tif_lzma.c @@ -61,8 +61,8 @@ typedef struct { #define DecoderState(tif) LState(tif) #define EncoderState(tif) LState(tif) -static int LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int LZMAEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int LZMADecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); static const char * LZMAStrerror(lzma_ret ret) @@ -125,7 +125,7 @@ LZMASetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -LZMAPreDecode(TIFF* tif, uint16 s) +LZMAPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "LZMAPreDecode"; LZMAState* sp = DecoderState(tif); @@ -160,7 +160,7 @@ LZMAPreDecode(TIFF* tif, uint16 s) } static int -LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LZMADecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LZMADecode"; LZMAState* sp = DecoderState(tif); @@ -206,19 +206,19 @@ LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) } if (ret != LZMA_OK) { TIFFErrorExt(tif->tif_clientdata, module, - "Decoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, LZMAStrerror(ret)); + "Decoding error at scanline %"PRIu32", %s", + tif->tif_row, LZMAStrerror(ret)); break; } } while (sp->stream.avail_out > 0); if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %lu (short %lu bytes)", - (unsigned long) tif->tif_row, (unsigned long) sp->stream.avail_out); + "Not enough data at scanline %"PRIu32" (short %"TIFF_SIZE_FORMAT" bytes)", + tif->tif_row, sp->stream.avail_out); return 0; } - tif->tif_rawcp = (uint8 *)sp->stream.next_in; /* cast away const */ + tif->tif_rawcp = (uint8_t *)sp->stream.next_in; /* cast away const */ tif->tif_rawcc = sp->stream.avail_in; return 1; @@ -243,7 +243,7 @@ LZMASetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -LZMAPreEncode(TIFF* tif, uint16 s) +LZMAPreEncode(TIFF* tif, uint16_t s) { static const char module[] = "LZMAPreEncode"; LZMAState *sp = EncoderState(tif); @@ -274,7 +274,7 @@ LZMAPreEncode(TIFF* tif, uint16 s) * Encode a chunk of pixels. */ static int -LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LZMAEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LZMAEncode"; LZMAState *sp = EncoderState(tif); @@ -294,8 +294,8 @@ LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); if (ret != LZMA_OK) { TIFFErrorExt(tif->tif_clientdata, module, - "Encoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, LZMAStrerror(ret)); + "Encoding error at scanline %"PRIu32", %s", + tif->tif_row, LZMAStrerror(ret)); return 0; } if (sp->stream.avail_out == 0) { @@ -367,7 +367,7 @@ LZMACleanup(TIFF* tif) } static int -LZMAVSetField(TIFF* tif, uint32 tag, va_list ap) +LZMAVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "LZMAVSetField"; LZMAState* sp = LState(tif); @@ -394,7 +394,7 @@ LZMAVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -LZMAVGetField(TIFF* tif, uint32 tag, va_list ap) +LZMAVGetField(TIFF* tif, uint32_t tag, va_list ap) { LZMAState* sp = LState(tif); @@ -435,7 +435,7 @@ TIFFInitLZMA(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZMAState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(LZMAState)); if (tif->tif_data == NULL) goto bad; sp = LState(tif); diff --git a/tiff/libtiff/tif_lzw.c b/tiff/libtiff/tif_lzw.c index d92d0fd3..c06aec40 100644 --- a/tiff/libtiff/tif_lzw.c +++ b/tiff/libtiff/tif_lzw.c @@ -107,7 +107,7 @@ typedef struct { /* * Encoding-specific state. */ -typedef uint16 hcode_t; /* codes fit in 16 bits */ +typedef uint16_t hcode_t; /* codes fit in 16 bits */ typedef struct { long hash; hcode_t code; @@ -123,7 +123,7 @@ typedef struct code_ent { unsigned char firstchar; /* first token of string */ } code_t; -typedef int (*decodeFunc)(TIFF*, uint8*, tmsize_t, uint16); +typedef int (*decodeFunc)(TIFF*, uint8_t*, tmsize_t, uint16_t); typedef struct { LZWBaseState base; @@ -132,7 +132,7 @@ typedef struct { long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ long dec_restart; /* restart count */ #ifdef LZW_CHECKEOS - uint64 dec_bitsleft; /* available bits in raw data */ + uint64_t dec_bitsleft; /* available bits in raw data */ tmsize_t old_tif_rawcc; /* value of tif_rawcc at the end of the previous TIFLZWDecode() call */ #endif decodeFunc dec_decode; /* regular or backwards compatible */ @@ -149,7 +149,7 @@ typedef struct { long enc_ratio; /* current compression ratio */ long enc_incount; /* (input) data bytes encoded */ long enc_outcount; /* encoded (output) bytes */ - uint8* enc_rawlimit; /* bound on tif_rawdata buffer */ + uint8_t* enc_rawlimit; /* bound on tif_rawdata buffer */ hash_t* enc_hashtab; /* kept separate for small machines */ } LZWCodecState; @@ -157,9 +157,9 @@ typedef struct { #define DecoderState(tif) ((LZWCodecState*) LZWState(tif)) #define EncoderState(tif) ((LZWCodecState*) LZWState(tif)) -static int LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); +static int LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s); #ifdef LZW_COMPAT -static int LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); +static int LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s); #endif static void cl_hash(LZWCodecState*); @@ -173,9 +173,9 @@ static void cl_hash(LZWCodecState*); * strip is suppose to be terminated with CODE_EOI. */ #define NextCode(_tif, _sp, _bp, _code, _get) { \ - if ((_sp)->dec_bitsleft < (uint64)nbits) { \ + if ((_sp)->dec_bitsleft < (uint64_t)nbits) { \ TIFFWarningExt(_tif->tif_clientdata, module, \ - "LZWDecode: Strip %d not terminated with EOI code", \ + "LZWDecode: Strip %"PRIu32" not terminated with EOI code", \ _tif->tif_curstrip); \ _code = CODE_EOI; \ } else { \ @@ -207,7 +207,7 @@ LZWSetupDecode(TIFF* tif) * Allocate state block so tag methods have storage to record * values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZWCodecState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(LZWCodecState)); if (tif->tif_data == NULL) { TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW state block"); @@ -256,7 +256,7 @@ LZWSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -LZWPreDecode(TIFF* tif, uint16 s) +LZWPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "LZWPreDecode"; LZWCodecState *sp = DecoderState(tif); @@ -352,12 +352,12 @@ static void codeLoop(TIFF* tif, const char* module) { TIFFErrorExt(tif->tif_clientdata, module, - "Bogus encoding, loop in the code table; scanline %d", + "Bogus encoding, loop in the code table; scanline %"PRIu32, tif->tif_row); } static int -LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) { static const char module[] = "LZWDecode"; LZWCodecState *sp = DecoderState(tif); @@ -426,7 +426,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) bp = (unsigned char *)tif->tif_rawcp; #ifdef LZW_CHECKEOS - sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3); + sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3); #endif nbits = sp->lzw_nbits; nextdata = sp->lzw_nextdata; @@ -454,7 +454,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) break; if (code > CODE_CLEAR) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", + "LZWDecode: Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -471,7 +471,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if (free_entp < &sp->dec_codetab[0] || free_entp >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -480,7 +480,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if (free_entp->next < &sp->dec_codetab[0] || free_entp->next >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -503,7 +503,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if(codep->length == 0) { TIFFErrorExt(tif->tif_clientdata, module, "Wrong length of decoded string: " - "data probably corrupted at scanline %d", + "data probably corrupted at scanline %"PRIu32, tif->tif_row); return (0); } @@ -552,8 +552,8 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) } } - tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp ); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc -= (tmsize_t)((uint8_t*) bp - tif->tif_rawcp ); + tif->tif_rawcp = (uint8_t*) bp; #ifdef LZW_CHECKEOS sp->old_tif_rawcc = tif->tif_rawcc; #endif @@ -566,15 +566,9 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) sp->dec_maxcodep = maxcodep; if (occ > 0) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %I64d bytes)", - tif->tif_row, (unsigned __int64) occ); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %llu bytes)", - tif->tif_row, (unsigned long long) occ); -#endif + "Not enough data at scanline %"PRIu32" (short %ld bytes)", + tif->tif_row, occ); return (0); } return (1); @@ -597,7 +591,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) } static int -LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) { static const char module[] = "LZWDecodeCompat"; LZWCodecState *sp = DecoderState(tif); @@ -660,7 +654,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) bp = (unsigned char *)tif->tif_rawcp; #ifdef LZW_CHECKEOS - sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3); + sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3); #endif nbits = sp->lzw_nbits; nextdata = sp->lzw_nextdata; @@ -688,7 +682,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) break; if (code > CODE_CLEAR) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", + "LZWDecode: Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -705,7 +699,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if (free_entp < &sp->dec_codetab[0] || free_entp >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", tif->tif_row); + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -713,7 +707,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if (free_entp->next < &sp->dec_codetab[0] || free_entp->next >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", tif->tif_row); + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } free_entp->firstchar = free_entp->next->firstchar; @@ -735,7 +729,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if(codep->length == 0) { TIFFErrorExt(tif->tif_clientdata, module, "Wrong length of decoded " - "string: data probably corrupted at scanline %d", + "string: data probably corrupted at scanline %"PRIu32, tif->tif_row); return (0); } @@ -776,8 +770,8 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) } } - tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp ); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc -= (tmsize_t)((uint8_t*) bp - tif->tif_rawcp ); + tif->tif_rawcp = (uint8_t*) bp; #ifdef LZW_CHECKEOS sp->old_tif_rawcc = tif->tif_rawcc; #endif @@ -790,15 +784,9 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) sp->dec_maxcodep = maxcodep; if (occ > 0) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %I64d bytes)", - tif->tif_row, (unsigned __int64) occ); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %llu bytes)", - tif->tif_row, (unsigned long long) occ); -#endif + "Not enough data at scanline %"PRIu32" (short %ld bytes)", + tif->tif_row, occ); return (0); } return (1); @@ -829,7 +817,7 @@ LZWSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -LZWPreEncode(TIFF* tif, uint16 s) +LZWPreEncode(TIFF* tif, uint16_t s) { LZWCodecState *sp = EncoderState(tif); @@ -896,7 +884,7 @@ LZWPreEncode(TIFF* tif, uint16 s) * for the decoder. */ static int -LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LZWEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { register LZWCodecState *sp = EncoderState(tif); register long fcode; @@ -908,8 +896,8 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) unsigned long nextdata; long nextbits; int free_ent, maxcode, nbits; - uint8* op; - uint8* limit; + uint8_t* op; + uint8_t* limit; (void) s; if (sp == NULL) @@ -1067,7 +1055,7 @@ static int LZWPostEncode(TIFF* tif) { register LZWCodecState *sp = EncoderState(tif); - uint8* op = tif->tif_rawcp; + uint8_t* op = tif->tif_rawcp; long nextbits = sp->lzw_nextbits; unsigned long nextdata = sp->lzw_nextdata; long outcount = sp->enc_outcount; @@ -1163,7 +1151,7 @@ TIFFInitLZW(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LZWCodecState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (LZWCodecState)); if (tif->tif_data == NULL) goto bad; DecoderState(tif)->dec_codetab = NULL; diff --git a/tiff/libtiff/tif_next.c b/tiff/libtiff/tif_next.c index 0ba61aed..695fc5d4 100644 --- a/tiff/libtiff/tif_next.c +++ b/tiff/libtiff/tif_next.c @@ -44,12 +44,12 @@ #define WHITE ((1<<2)-1) static int -NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { static const char module[] = "NeXTDecode"; unsigned char *bp, *op; tmsize_t cc; - uint8* row; + uint8_t* row; tmsize_t scanline, n; (void) s; @@ -101,9 +101,9 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) break; } default: { - uint32 npixels = 0, grey; + uint32_t npixels = 0, grey; tmsize_t op_offset = 0; - uint32 imagewidth = tif->tif_dir.td_imagewidth; + uint32_t imagewidth = tif->tif_dir.td_imagewidth; if( isTiled(tif) ) imagewidth = tif->tif_dir.td_tilewidth; @@ -115,7 +115,7 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) */ op = row; for (;;) { - grey = (uint32)((n>>6) & 0x3); + grey = (uint32_t)((n >> 6) & 0x3); n &= 0x3f; /* * Ensure the run does not exceed the scanline @@ -127,8 +127,8 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) if (npixels >= imagewidth) break; if (op_offset >= scanline ) { - TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld", - (long) tif->tif_row); + TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %"PRIu32, + tif->tif_row); return (0); } if (cc == 0) @@ -140,17 +140,17 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) } } } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (1); bad: - TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld", - (long) tif->tif_row); + TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %"PRIu32, + tif->tif_row); return (0); } static int -NeXTPreDecode(TIFF* tif, uint16 s) +NeXTPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "NeXTPreDecode"; TIFFDirectory *td = &tif->tif_dir; @@ -158,7 +158,7 @@ NeXTPreDecode(TIFF* tif, uint16 s) if( td->td_bitspersample != 2 ) { - TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d", + TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %"PRIu16, td->td_bitspersample); return (0); } diff --git a/tiff/libtiff/tif_ojpeg.c b/tiff/libtiff/tif_ojpeg.c index d9000764..102f9940 100644 --- a/tiff/libtiff/tif_ojpeg.c +++ b/tiff/libtiff/tif_ojpeg.c @@ -141,7 +141,7 @@ * enough so as to not result in significant call overhead. It should be at least a few * bytes to accommodate some structures (this is verified in asserts), but it would not be * sensible to make it this small anyway, and it should be at most 64K since it is indexed - * with uint16. We recommend 2K. + * with uint16_t. We recommend 2K. * EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has * absolutely no effect. That is why most people insist the EGYPTIANWALK is a bit silly. */ @@ -258,118 +258,118 @@ typedef struct { TIFFVGetMethod vgetparent; TIFFVSetMethod vsetparent; TIFFPrintMethod printdir; - uint64 file_size; - uint32 image_width; - uint32 image_length; - uint32 strile_width; - uint32 strile_length; - uint32 strile_length_total; - uint8 samples_per_pixel; - uint8 plane_sample_offset; - uint8 samples_per_pixel_per_plane; - uint64 jpeg_interchange_format; - uint64 jpeg_interchange_format_length; - uint8 jpeg_proc; - uint8 subsamplingcorrect; - uint8 subsamplingcorrect_done; - uint8 subsampling_tag; - uint8 subsampling_hor; - uint8 subsampling_ver; - uint8 subsampling_force_desubsampling_inside_decompression; - uint8 qtable_offset_count; - uint8 dctable_offset_count; - uint8 actable_offset_count; - uint64 qtable_offset[3]; - uint64 dctable_offset[3]; - uint64 actable_offset[3]; - uint8* qtable[4]; - uint8* dctable[4]; - uint8* actable[4]; - uint16 restart_interval; - uint8 restart_index; - uint8 sof_log; - uint8 sof_marker_id; - uint32 sof_x; - uint32 sof_y; - uint8 sof_c[3]; - uint8 sof_hv[3]; - uint8 sof_tq[3]; - uint8 sos_cs[3]; - uint8 sos_tda[3]; + uint64_t file_size; + uint32_t image_width; + uint32_t image_length; + uint32_t strile_width; + uint32_t strile_length; + uint32_t strile_length_total; + uint8_t samples_per_pixel; + uint8_t plane_sample_offset; + uint8_t samples_per_pixel_per_plane; + uint64_t jpeg_interchange_format; + uint64_t jpeg_interchange_format_length; + uint8_t jpeg_proc; + uint8_t subsamplingcorrect; + uint8_t subsamplingcorrect_done; + uint8_t subsampling_tag; + uint8_t subsampling_hor; + uint8_t subsampling_ver; + uint8_t subsampling_force_desubsampling_inside_decompression; + uint8_t qtable_offset_count; + uint8_t dctable_offset_count; + uint8_t actable_offset_count; + uint64_t qtable_offset[3]; + uint64_t dctable_offset[3]; + uint64_t actable_offset[3]; + uint8_t* qtable[4]; + uint8_t* dctable[4]; + uint8_t* actable[4]; + uint16_t restart_interval; + uint8_t restart_index; + uint8_t sof_log; + uint8_t sof_marker_id; + uint32_t sof_x; + uint32_t sof_y; + uint8_t sof_c[3]; + uint8_t sof_hv[3]; + uint8_t sof_tq[3]; + uint8_t sos_cs[3]; + uint8_t sos_tda[3]; struct { - uint8 log; + uint8_t log; OJPEGStateInBufferSource in_buffer_source; - uint32 in_buffer_next_strile; - uint64 in_buffer_file_pos; - uint64 in_buffer_file_togo; + uint32_t in_buffer_next_strile; + uint64_t in_buffer_file_pos; + uint64_t in_buffer_file_togo; } sos_end[3]; - uint8 readheader_done; - uint8 writeheader_done; - uint16 write_cursample; - uint32 write_curstrile; - uint8 libjpeg_session_active; - uint8 libjpeg_jpeg_query_style; + uint8_t readheader_done; + uint8_t writeheader_done; + uint16_t write_cursample; + uint32_t write_curstrile; + uint8_t libjpeg_session_active; + uint8_t libjpeg_jpeg_query_style; jpeg_error_mgr libjpeg_jpeg_error_mgr; jpeg_decompress_struct libjpeg_jpeg_decompress_struct; jpeg_source_mgr libjpeg_jpeg_source_mgr; - uint8 subsampling_convert_log; - uint32 subsampling_convert_ylinelen; - uint32 subsampling_convert_ylines; - uint32 subsampling_convert_clinelen; - uint32 subsampling_convert_clines; - uint32 subsampling_convert_ybuflen; - uint32 subsampling_convert_cbuflen; - uint32 subsampling_convert_ycbcrbuflen; - uint8* subsampling_convert_ycbcrbuf; - uint8* subsampling_convert_ybuf; - uint8* subsampling_convert_cbbuf; - uint8* subsampling_convert_crbuf; - uint32 subsampling_convert_ycbcrimagelen; - uint8** subsampling_convert_ycbcrimage; - uint32 subsampling_convert_clinelenout; - uint32 subsampling_convert_state; - uint32 bytes_per_line; /* if the codec outputs subsampled data, a 'line' in bytes_per_line */ - uint32 lines_per_strile; /* and lines_per_strile means subsampling_ver desubsampled rows */ + uint8_t subsampling_convert_log; + uint32_t subsampling_convert_ylinelen; + uint32_t subsampling_convert_ylines; + uint32_t subsampling_convert_clinelen; + uint32_t subsampling_convert_clines; + uint32_t subsampling_convert_ybuflen; + uint32_t subsampling_convert_cbuflen; + uint32_t subsampling_convert_ycbcrbuflen; + uint8_t* subsampling_convert_ycbcrbuf; + uint8_t* subsampling_convert_ybuf; + uint8_t* subsampling_convert_cbbuf; + uint8_t* subsampling_convert_crbuf; + uint32_t subsampling_convert_ycbcrimagelen; + uint8_t** subsampling_convert_ycbcrimage; + uint32_t subsampling_convert_clinelenout; + uint32_t subsampling_convert_state; + uint32_t bytes_per_line; /* if the codec outputs subsampled data, a 'line' in bytes_per_line */ + uint32_t lines_per_strile; /* and lines_per_strile means subsampling_ver desubsampled rows */ OJPEGStateInBufferSource in_buffer_source; - uint32 in_buffer_next_strile; - uint32 in_buffer_strile_count; - uint64 in_buffer_file_pos; - uint8 in_buffer_file_pos_log; - uint64 in_buffer_file_togo; - uint16 in_buffer_togo; - uint8* in_buffer_cur; - uint8 in_buffer[OJPEG_BUFFER]; + uint32_t in_buffer_next_strile; + uint32_t in_buffer_strile_count; + uint64_t in_buffer_file_pos; + uint8_t in_buffer_file_pos_log; + uint64_t in_buffer_file_togo; + uint16_t in_buffer_togo; + uint8_t* in_buffer_cur; + uint8_t in_buffer[OJPEG_BUFFER]; OJPEGStateOutState out_state; - uint8 out_buffer[OJPEG_BUFFER]; - uint8* skip_buffer; + uint8_t out_buffer[OJPEG_BUFFER]; + uint8_t* skip_buffer; #ifdef GS_TIFF_BUILD jpeg_cust_mem_data jmem; jpeg_cust_mem_data *jmem_parent; #endif } OJPEGState; -static int OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap); -static int OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap); +static int OJPEGVGetField(TIFF* tif, uint32_t tag, va_list ap); +static int OJPEGVSetField(TIFF* tif, uint32_t tag, va_list ap); static void OJPEGPrintDir(TIFF* tif, FILE* fd, long flags); static int OJPEGFixupTags(TIFF* tif); static int OJPEGSetupDecode(TIFF* tif); -static int OJPEGPreDecode(TIFF* tif, uint16 s); +static int OJPEGPreDecode(TIFF* tif, uint16_t s); static int OJPEGPreDecodeSkipRaw(TIFF* tif); static int OJPEGPreDecodeSkipScanlines(TIFF* tif); -static int OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -static int OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc); -static int OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc); -static void OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc); +static int OJPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); +static int OJPEGDecodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc); +static int OJPEGDecodeScanlines(TIFF* tif, uint8_t* buf, tmsize_t cc); +static void OJPEGPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc); static int OJPEGSetupEncode(TIFF* tif); -static int OJPEGPreEncode(TIFF* tif, uint16 s); -static int OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int OJPEGPreEncode(TIFF* tif, uint16_t s); +static int OJPEGEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); static int OJPEGPostEncode(TIFF* tif); static void OJPEGCleanup(TIFF* tif); static void OJPEGSubsamplingCorrect(TIFF* tif); static int OJPEGReadHeaderInfo(TIFF* tif); -static int OJPEGReadSecondarySos(TIFF* tif, uint16 s); +static int OJPEGReadSecondarySos(TIFF* tif, uint16_t s); static int OJPEGWriteHeaderInfo(TIFF* tif); static void OJPEGLibjpegSessionAbort(TIFF* tif); @@ -377,45 +377,45 @@ static int OJPEGReadHeaderInfoSec(TIFF* tif); static int OJPEGReadHeaderInfoSecStreamDri(TIFF* tif); static int OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif); static int OJPEGReadHeaderInfoSecStreamDht(TIFF* tif); -static int OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id); +static int OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8_t marker_id); static int OJPEGReadHeaderInfoSecStreamSos(TIFF* tif); static int OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif); static int OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif); static int OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif); static int OJPEGReadBufferFill(OJPEGState* sp); -static int OJPEGReadByte(OJPEGState* sp, uint8* byte); -static int OJPEGReadBytePeek(OJPEGState* sp, uint8* byte); +static int OJPEGReadByte(OJPEGState* sp, uint8_t* byte); +static int OJPEGReadBytePeek(OJPEGState* sp, uint8_t* byte); static void OJPEGReadByteAdvance(OJPEGState* sp); -static int OJPEGReadWord(OJPEGState* sp, uint16* word); -static int OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem); -static void OJPEGReadSkip(OJPEGState* sp, uint16 len); - -static int OJPEGWriteStream(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len); -static int OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len); +static int OJPEGReadWord(OJPEGState* sp, uint16_t* word); +static int OJPEGReadBlock(OJPEGState* sp, uint16_t len, void* mem); +static void OJPEGReadSkip(OJPEGState* sp, uint16_t len); + +static int OJPEGWriteStream(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamQTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len); +static void OJPEGWriteStreamDcTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len); +static void OJPEGWriteStreamAcTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len); +static void OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32_t* len); +static int OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32_t* len); #ifdef LIBJPEG_ENCAP_EXTERNAL extern int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image); +extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8_t require_image); extern int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines); -extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines); +extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32_t max_lines); +extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32_t max_lines); extern void jpeg_encap_unwind(TIFF* tif); #else static int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* j); -static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image); +static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8_t require_image); static int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines); -static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines); +static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32_t max_lines); +static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32_t max_lines); static void jpeg_encap_unwind(TIFF* tif); #endif @@ -473,7 +473,7 @@ TIFFInitOJPEG(TIFF* tif, int scheme) tif->tif_encodestrip=OJPEGEncode; tif->tif_encodetile=OJPEGEncode; tif->tif_cleanup=OJPEGCleanup; - tif->tif_data=(uint8*)sp; + tif->tif_data=(uint8_t*)sp; /* tif tag methods */ sp->vgetparent=tif->tif_tagmethods.vgetfield; tif->tif_tagmethods.vgetfield=OJPEGVGetField; @@ -492,40 +492,40 @@ TIFFInitOJPEG(TIFF* tif, int scheme) } static int -OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap) +OJPEGVGetField(TIFF* tif, uint32_t tag, va_list ap) { OJPEGState* sp=(OJPEGState*)tif->tif_data; switch(tag) { case TIFFTAG_JPEGIFOFFSET: - *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format; + *va_arg(ap, uint64_t*)=(uint64_t)sp->jpeg_interchange_format; break; case TIFFTAG_JPEGIFBYTECOUNT: - *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format_length; + *va_arg(ap, uint64_t*)=(uint64_t)sp->jpeg_interchange_format_length; break; case TIFFTAG_YCBCRSUBSAMPLING: if (sp->subsamplingcorrect_done==0) OJPEGSubsamplingCorrect(tif); - *va_arg(ap,uint16*)=(uint16)sp->subsampling_hor; - *va_arg(ap,uint16*)=(uint16)sp->subsampling_ver; + *va_arg(ap, uint16_t*)=(uint16_t)sp->subsampling_hor; + *va_arg(ap, uint16_t*)=(uint16_t)sp->subsampling_ver; break; case TIFFTAG_JPEGQTABLES: - *va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count; + *va_arg(ap, uint32_t*)=(uint32_t)sp->qtable_offset_count; *va_arg(ap,const void**)=(const void*)sp->qtable_offset; break; case TIFFTAG_JPEGDCTABLES: - *va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count; + *va_arg(ap, uint32_t*)=(uint32_t)sp->dctable_offset_count; *va_arg(ap,const void**)=(const void*)sp->dctable_offset; break; case TIFFTAG_JPEGACTABLES: - *va_arg(ap,uint32*)=(uint32)sp->actable_offset_count; + *va_arg(ap, uint32_t*)=(uint32_t)sp->actable_offset_count; *va_arg(ap,const void**)=(const void*)sp->actable_offset; break; case TIFFTAG_JPEGPROC: - *va_arg(ap,uint16*)=(uint16)sp->jpeg_proc; + *va_arg(ap, uint16_t*)=(uint16_t)sp->jpeg_proc; break; case TIFFTAG_JPEGRESTARTINTERVAL: - *va_arg(ap,uint16*)=sp->restart_interval; + *va_arg(ap, uint16_t*)=sp->restart_interval; break; default: return (*sp->vgetparent)(tif,tag,ap); @@ -534,32 +534,32 @@ OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap) } static int -OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) +OJPEGVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[]="OJPEGVSetField"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 ma; - uint64* mb; - uint32 n; + uint32_t ma; + uint64_t* mb; + uint32_t n; const TIFFField* fip; switch(tag) { case TIFFTAG_JPEGIFOFFSET: - sp->jpeg_interchange_format=(uint64)va_arg(ap,uint64); + sp->jpeg_interchange_format=(uint64_t)va_arg(ap, uint64_t); break; case TIFFTAG_JPEGIFBYTECOUNT: - sp->jpeg_interchange_format_length=(uint64)va_arg(ap,uint64); + sp->jpeg_interchange_format_length=(uint64_t)va_arg(ap, uint64_t); break; case TIFFTAG_YCBCRSUBSAMPLING: sp->subsampling_tag=1; - sp->subsampling_hor=(uint8)va_arg(ap,uint16_vap); - sp->subsampling_ver=(uint8)va_arg(ap,uint16_vap); + sp->subsampling_hor=(uint8_t)va_arg(ap, uint16_vap); + sp->subsampling_ver=(uint8_t)va_arg(ap, uint16_vap); tif->tif_dir.td_ycbcrsubsampling[0]=sp->subsampling_hor; tif->tif_dir.td_ycbcrsubsampling[1]=sp->subsampling_ver; break; case TIFFTAG_JPEGQTABLES: - ma=(uint32)va_arg(ap,uint32); + ma=(uint32_t)va_arg(ap, uint32_t); if (ma!=0) { if (ma>3) @@ -567,14 +567,14 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) TIFFErrorExt(tif->tif_clientdata,module,"JpegQTables tag has incorrect count"); return(0); } - sp->qtable_offset_count=(uint8)ma; - mb=(uint64*)va_arg(ap,uint64*); + sp->qtable_offset_count=(uint8_t)ma; + mb=(uint64_t*)va_arg(ap, uint64_t*); for (n=0; n<ma; n++) sp->qtable_offset[n]=mb[n]; } break; case TIFFTAG_JPEGDCTABLES: - ma=(uint32)va_arg(ap,uint32); + ma=(uint32_t)va_arg(ap, uint32_t); if (ma!=0) { if (ma>3) @@ -582,14 +582,14 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) TIFFErrorExt(tif->tif_clientdata,module,"JpegDcTables tag has incorrect count"); return(0); } - sp->dctable_offset_count=(uint8)ma; - mb=(uint64*)va_arg(ap,uint64*); + sp->dctable_offset_count=(uint8_t)ma; + mb=(uint64_t*)va_arg(ap, uint64_t*); for (n=0; n<ma; n++) sp->dctable_offset[n]=mb[n]; } break; case TIFFTAG_JPEGACTABLES: - ma=(uint32)va_arg(ap,uint32); + ma=(uint32_t)va_arg(ap, uint32_t); if (ma!=0) { if (ma>3) @@ -597,17 +597,17 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) TIFFErrorExt(tif->tif_clientdata,module,"JpegAcTables tag has incorrect count"); return(0); } - sp->actable_offset_count=(uint8)ma; - mb=(uint64*)va_arg(ap,uint64*); + sp->actable_offset_count=(uint8_t)ma; + mb=(uint64_t*)va_arg(ap, uint64_t*); for (n=0; n<ma; n++) sp->actable_offset[n]=mb[n]; } break; case TIFFTAG_JPEGPROC: - sp->jpeg_proc=(uint8)va_arg(ap,uint16_vap); + sp->jpeg_proc=(uint8_t)va_arg(ap, uint16_vap); break; case TIFFTAG_JPEGRESTARTINTERVAL: - sp->restart_interval=(uint16)va_arg(ap,uint16_vap); + sp->restart_interval=(uint16_t)va_arg(ap, uint16_vap); break; default: return (*sp->vsetparent)(tif,tag,ap); @@ -624,38 +624,38 @@ static void OJPEGPrintDir(TIFF* tif, FILE* fd, long flags) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; + uint8_t m; (void)flags; assert(sp!=NULL); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMAT)) - fprintf(fd," JpegInterchangeFormat: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format); + fprintf(fd," JpegInterchangeFormat: %" PRIu64 "\n",(uint64_t)sp->jpeg_interchange_format); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH)) - fprintf(fd," JpegInterchangeFormatLength: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format_length); + fprintf(fd," JpegInterchangeFormatLength: %" PRIu64 "\n",(uint64_t)sp->jpeg_interchange_format_length); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGQTABLES)) { fprintf(fd," JpegQTables:"); for (m=0; m<sp->qtable_offset_count; m++) - fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->qtable_offset[m]); + fprintf(fd," %" PRIu64,(uint64_t)sp->qtable_offset[m]); fprintf(fd,"\n"); } if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGDCTABLES)) { fprintf(fd," JpegDcTables:"); for (m=0; m<sp->dctable_offset_count; m++) - fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->dctable_offset[m]); + fprintf(fd," %" PRIu64,(uint64_t)sp->dctable_offset[m]); fprintf(fd,"\n"); } if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGACTABLES)) { fprintf(fd," JpegAcTables:"); for (m=0; m<sp->actable_offset_count; m++) - fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->actable_offset[m]); + fprintf(fd," %" PRIu64,(uint64_t)sp->actable_offset[m]); fprintf(fd,"\n"); } if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGPROC)) - fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc); + fprintf(fd," JpegProc: %"PRIu8"\n", sp->jpeg_proc); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGRESTARTINTERVAL)) - fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval); + fprintf(fd," JpegRestartInterval: %"PRIu16"\n", sp->restart_interval); if (sp->printdir) (*sp->printdir)(tif, fd, flags); } @@ -676,10 +676,10 @@ OJPEGSetupDecode(TIFF* tif) } static int -OJPEGPreDecode(TIFF* tif, uint16 s) +OJPEGPreDecode(TIFF* tif, uint16_t s) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 m; + uint32_t m; if (sp->subsamplingcorrect_done==0) OJPEGSubsamplingCorrect(tif); if (sp->readheader_done==0) @@ -704,7 +704,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s) } if (sp->writeheader_done==0) { - sp->plane_sample_offset=(uint8)s; + sp->plane_sample_offset=(uint8_t)s; sp->write_cursample=s; sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; if ((sp->in_buffer_file_pos_log==0) || @@ -743,7 +743,7 @@ static int OJPEGPreDecodeSkipRaw(TIFF* tif) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 m; + uint32_t m; m=sp->lines_per_strile; if (sp->subsampling_convert_state!=0) { @@ -778,7 +778,7 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif) { static const char module[]="OJPEGPreDecodeSkipScanlines"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 m; + uint32_t m; if (sp->skip_buffer==NULL) { sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line); @@ -797,7 +797,7 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif) } static int -OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +OJPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { static const char module[]="OJPEGDecode"; OJPEGState* sp=(OJPEGState*)tif->tif_data; @@ -825,19 +825,19 @@ OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) } static int -OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc) +OJPEGDecodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc) { static const char module[]="OJPEGDecodeRaw"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8* m; + uint8_t* m; tmsize_t n; - uint8* oy; - uint8* ocb; - uint8* ocr; - uint8* p; - uint32 q; - uint8* r; - uint8 sx,sy; + uint8_t* oy; + uint8_t* ocb; + uint8_t* ocr; + uint8_t* p; + uint32_t q; + uint8_t* r; + uint8_t sx,sy; if (cc%sp->bytes_per_line!=0) { TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read"); @@ -883,11 +883,11 @@ OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc) } static int -OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc) +OJPEGDecodeScanlines(TIFF* tif, uint8_t* buf, tmsize_t cc) { static const char module[]="OJPEGDecodeScanlines"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8* m; + uint8_t* m; tmsize_t n; if (cc%sp->bytes_per_line!=0) { @@ -908,7 +908,7 @@ OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc) } static void -OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc) +OJPEGPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc) { OJPEGState* sp=(OJPEGState*)tif->tif_data; (void)buf; @@ -931,7 +931,7 @@ OJPEGSetupEncode(TIFF* tif) } static int -OJPEGPreEncode(TIFF* tif, uint16 s) +OJPEGPreEncode(TIFF* tif, uint16_t s) { static const char module[]="OJPEGPreEncode"; (void)s; @@ -940,7 +940,7 @@ OJPEGPreEncode(TIFF* tif, uint16 s) } static int -OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +OJPEGEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { static const char module[]="OJPEGEncode"; (void)buf; @@ -1010,8 +1010,8 @@ OJPEGSubsamplingCorrect(TIFF* tif) { static const char module[]="OJPEGSubsamplingCorrect"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 mh; - uint8 mv; + uint8_t mh; + uint8_t mv; assert(sp->subsamplingcorrect_done==0); if ((tif->tif_dir.td_samplesperpixel!=3) || ((tif->tif_dir.td_photometric!=PHOTOMETRIC_YCBCR) && @@ -1039,21 +1039,21 @@ OJPEGSubsamplingCorrect(TIFF* tif) if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampling_inside_decompression==0)) { if (sp->subsampling_tag==0) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%d,%d] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%"PRIu8",%"PRIu8"] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver); else - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%d,%d] does not match subsampling tag values [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%"PRIu8",%"PRIu8"] does not match subsampling tag values [%"PRIu8",%"PRIu8"]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv); } if (sp->subsampling_force_desubsampling_inside_decompression!=0) { if (sp->subsampling_tag==0) TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data does not match default values [2,2] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression"); else - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%d,%d] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%"PRIu8",%"PRIu8"] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv); } if (sp->subsampling_force_desubsampling_inside_decompression==0) { if (sp->subsampling_hor<sp->subsampling_ver) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%"PRIu8",%"PRIu8"] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); } } sp->subsamplingcorrect_done=1; @@ -1077,7 +1077,7 @@ OJPEGReadHeaderInfo(TIFF* tif) { sp->strile_width=sp->image_width; sp->strile_length=tif->tif_dir.td_rowsperstrip; - if( sp->strile_length == (uint32)-1 ) + if( sp->strile_length == (uint32_t)-1 ) sp->strile_length = sp->image_length; sp->strile_length_total=sp->image_length; } @@ -1093,7 +1093,7 @@ OJPEGReadHeaderInfo(TIFF* tif) { if (tif->tif_dir.td_samplesperpixel!=3) { - TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); + TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %"PRIu8" not supported for this compression scheme",sp->samples_per_pixel); return(0); } sp->samples_per_pixel=3; @@ -1116,7 +1116,7 @@ OJPEGReadHeaderInfo(TIFF* tif) TIFFErrorExt(tif->tif_clientdata,module,"Incompatible vertical subsampling and image strip/tile length"); return(0); } - sp->restart_interval=(uint16)(((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))*(sp->strile_length/(sp->subsampling_ver*8))); + sp->restart_interval=(uint16_t)(((sp->strile_width + sp->subsampling_hor * 8 - 1) / (sp->subsampling_hor * 8)) * (sp->strile_length / (sp->subsampling_ver * 8))); } if (OJPEGReadHeaderInfoSec(tif)==0) return(0); @@ -1130,15 +1130,15 @@ OJPEGReadHeaderInfo(TIFF* tif) } static int -OJPEGReadSecondarySos(TIFF* tif, uint16 s) +OJPEGReadSecondarySos(TIFF* tif, uint16_t s) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; + uint8_t m; assert(s>0); assert(s<3); assert(sp->sos_end[0].log!=0); assert(sp->sos_end[s].log==0); - sp->plane_sample_offset=(uint8)(s-1); + sp->plane_sample_offset=(uint8_t)(s - 1); while(sp->sos_end[sp->plane_sample_offset].log==0) sp->plane_sample_offset--; sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source; @@ -1269,8 +1269,8 @@ OJPEGWriteHeaderInfo(TIFF* tif) { static const char module[]="OJPEGWriteHeaderInfo"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8** m; - uint32 n; + uint8_t** m; + uint32_t n; /* if a previous attempt failed, don't try again */ if (sp->libjpeg_session_active != 0) return 0; @@ -1337,16 +1337,16 @@ OJPEGWriteHeaderInfo(TIFF* tif) sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen; sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen; sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_clines; - sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*)); + sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8_t*)); if (sp->subsampling_convert_ycbcrimage==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } m=sp->subsampling_convert_ycbcrimage; - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3); - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines); - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines+sp->subsampling_convert_clines); + *m++=(uint8_t*)(sp->subsampling_convert_ycbcrimage + 3); + *m++=(uint8_t*)(sp->subsampling_convert_ycbcrimage + 3 + sp->subsampling_convert_ylines); + *m++=(uint8_t*)(sp->subsampling_convert_ycbcrimage + 3 + sp->subsampling_convert_ylines + sp->subsampling_convert_clines); for (n=0; n<sp->subsampling_convert_ylines; n++) *m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen; for (n=0; n<sp->subsampling_convert_clines; n++) @@ -1373,8 +1373,8 @@ OJPEGWriteHeaderInfo(TIFF* tif) return(0); if(sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width ) { TIFFErrorExt(tif->tif_clientdata,module, - "jpeg_start_decompress() returned image_width = %d, " - "expected %d", + "jpeg_start_decompress() returned image_width = %u, " + "expected %"PRIu32, sp->libjpeg_jpeg_decompress_struct.image_width, sp->strile_width); return 0; @@ -1383,7 +1383,7 @@ OJPEGWriteHeaderInfo(TIFF* tif) sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor != sp->subsampling_ver) { TIFFErrorExt(tif->tif_clientdata,module, "jpeg_start_decompress() returned max_h_samp_factor = %d " - "and max_v_samp_factor = %d, expected %d and %d", + "and max_v_samp_factor = %d, expected %"PRIu8" and %"PRIu8, sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor, sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor, sp->subsampling_hor, @@ -1409,9 +1409,9 @@ OJPEGReadHeaderInfoSec(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSec"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint16 n; - uint8 o; + uint8_t m; + uint16_t n; + uint8_t o; if (sp->file_size==0) sp->file_size=TIFFGetFileSize(tif); if (sp->jpeg_interchange_format!=0) @@ -1424,7 +1424,7 @@ OJPEGReadHeaderInfoSec(TIFF* tif) else { if ((sp->jpeg_interchange_format_length==0) || - (sp->jpeg_interchange_format > TIFF_UINT64_MAX - sp->jpeg_interchange_format_length) || + (sp->jpeg_interchange_format > UINT64_MAX - sp->jpeg_interchange_format_length) || (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size)) sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format; } @@ -1508,7 +1508,7 @@ OJPEGReadHeaderInfoSec(TIFF* tif) return(0); break; default: - TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m); + TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %"PRIu8" in JPEG data", m); return(0); } } while(m!=JPEG_MARKER_SOS); @@ -1544,7 +1544,7 @@ OJPEGReadHeaderInfoSecStreamDri(TIFF* tif) occurred so far */ static const char module[]="OJPEGReadHeaderInfoSecStreamDri"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; + uint16_t m; if (OJPEGReadWord(sp,&m)==0) return(0); if (m!=4) @@ -1564,10 +1564,10 @@ OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif) /* this is a table marker, and it is to be saved as a whole for exact pushing on the jpeg stream later on */ static const char module[]="OJPEGReadHeaderInfoSecStreamDqt"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint32 na; - uint8* nb; - uint8 o; + uint16_t m; + uint32_t na; + uint8_t* nb; + uint8_t o; if (OJPEGReadWord(sp,&m)==0) return(0); if (m<=2) @@ -1588,23 +1588,23 @@ OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif) TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); return(0); } - na=sizeof(uint32)+69; + na= sizeof(uint32_t) + 69; nb=_TIFFmalloc(na); if (nb==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)nb=na; - nb[sizeof(uint32)]=255; - nb[sizeof(uint32)+1]=JPEG_MARKER_DQT; - nb[sizeof(uint32)+2]=0; - nb[sizeof(uint32)+3]=67; - if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) { + *(uint32_t*)nb=na; + nb[sizeof(uint32_t)]=255; + nb[sizeof(uint32_t) + 1]=JPEG_MARKER_DQT; + nb[sizeof(uint32_t) + 2]=0; + nb[sizeof(uint32_t) + 3]=67; + if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32_t) + 4]) == 0) { _TIFFfree(nb); return(0); } - o=nb[sizeof(uint32)+4]&15; + o= nb[sizeof(uint32_t) + 4] & 15; if (3<o) { TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); @@ -1627,10 +1627,10 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif) /* TODO: the following assumes there is only one table in this marker... but i'm not quite sure that assumption is guaranteed correct */ static const char module[]="OJPEGReadHeaderInfoSecStreamDht"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint32 na; - uint8* nb; - uint8 o; + uint16_t m; + uint32_t na; + uint8_t* nb; + uint8_t o; if (OJPEGReadWord(sp,&m)==0) return(0); if (m<=2) @@ -1645,23 +1645,23 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif) } else { - na=sizeof(uint32)+2+m; + na= sizeof(uint32_t) + 2 + m; nb=_TIFFmalloc(na); if (nb==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)nb=na; - nb[sizeof(uint32)]=255; - nb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - nb[sizeof(uint32)+2]=(m>>8); - nb[sizeof(uint32)+3]=(m&255); - if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) { + *(uint32_t*)nb=na; + nb[sizeof(uint32_t)]=255; + nb[sizeof(uint32_t) + 1]=JPEG_MARKER_DHT; + nb[sizeof(uint32_t) + 2]=(m >> 8); + nb[sizeof(uint32_t) + 3]=(m & 255); + if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32_t) + 4]) == 0) { _TIFFfree(nb); return(0); } - o=nb[sizeof(uint32)+4]; + o=nb[sizeof(uint32_t) + 4]; if ((o&240)==0) { if (3<o) @@ -1698,16 +1698,16 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif) } static int -OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id) +OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8_t marker_id) { /* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */ static const char module[]="OJPEGReadHeaderInfoSecStreamSof"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint16 n; - uint8 o; - uint16 p; - uint16 q; + uint16_t m; + uint16_t n; + uint8_t o; + uint16_t p; + uint16_t q; if (sp->sof_log!=0) { TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); @@ -1757,7 +1757,7 @@ OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id) /* Y: Number of lines */ if (OJPEGReadWord(sp,&p)==0) return(0); - if (((uint32)p<sp->image_length) && ((uint32)p<sp->strile_length_total)) + if (((uint32_t)p < sp->image_length) && ((uint32_t)p < sp->strile_length_total)) { TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected height"); return(0); @@ -1766,12 +1766,12 @@ OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id) /* X: Number of samples per line */ if (OJPEGReadWord(sp,&p)==0) return(0); - if (((uint32)p<sp->image_width) && ((uint32)p<sp->strile_width)) + if (((uint32_t)p < sp->image_width) && ((uint32_t)p < sp->strile_width)) { TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected width"); return(0); } - if ((uint32)p>sp->strile_width) + if ((uint32_t)p > sp->strile_width) { TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data image width exceeds expected image width"); return(0); @@ -1855,9 +1855,9 @@ OJPEGReadHeaderInfoSecStreamSos(TIFF* tif) /* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */ static const char module[]="OJPEGReadHeaderInfoSecStreamSos"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint8 n; - uint8 o; + uint16_t m; + uint8_t n; + uint8_t o; assert(sp->subsamplingcorrect==0); if (sp->sof_log==0) { @@ -1902,11 +1902,11 @@ OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSecTablesQTable"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint32 oa; - uint8* ob; - uint32 p; + uint8_t m; + uint8_t n; + uint32_t oa; + uint8_t* ob; + uint32_t p; if (sp->qtable_offset[0]==0) { TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); @@ -1925,21 +1925,21 @@ OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif) return(0); } } - oa=sizeof(uint32)+69; + oa= sizeof(uint32_t) + 69; ob=_TIFFmalloc(oa); if (ob==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)ob=oa; - ob[sizeof(uint32)]=255; - ob[sizeof(uint32)+1]=JPEG_MARKER_DQT; - ob[sizeof(uint32)+2]=0; - ob[sizeof(uint32)+3]=67; - ob[sizeof(uint32)+4]=m; + *(uint32_t*)ob=oa; + ob[sizeof(uint32_t)]=255; + ob[sizeof(uint32_t) + 1]=JPEG_MARKER_DQT; + ob[sizeof(uint32_t) + 2]=0; + ob[sizeof(uint32_t) + 3]=67; + ob[sizeof(uint32_t) + 4]=m; TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); - p=(uint32)TIFFReadFile(tif,&ob[sizeof(uint32)+5],64); + p=(uint32_t)TIFFReadFile(tif, &ob[sizeof(uint32_t) + 5], 64); if (p!=64) { _TIFFfree(ob); @@ -1961,13 +1961,13 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSecTablesDcTable"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint8 o[16]; - uint32 p; - uint32 q; - uint32 ra; - uint8* rb; + uint8_t m; + uint8_t n; + uint8_t o[16]; + uint32_t p; + uint32_t q; + uint32_t ra; + uint8_t* rb; if (sp->dctable_offset[0]==0) { TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); @@ -1987,28 +1987,28 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif) } } TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET); - p=(uint32)TIFFReadFile(tif,o,16); + p=(uint32_t)TIFFReadFile(tif, o, 16); if (p!=16) return(0); q=0; for (n=0; n<16; n++) q+=o[n]; - ra=sizeof(uint32)+21+q; + ra= sizeof(uint32_t) + 21 + q; rb=_TIFFmalloc(ra); if (rb==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)rb=ra; - rb[sizeof(uint32)]=255; - rb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - rb[sizeof(uint32)+2]=(uint8)((19+q)>>8); - rb[sizeof(uint32)+3]=((19+q)&255); - rb[sizeof(uint32)+4]=m; + *(uint32_t*)rb=ra; + rb[sizeof(uint32_t)]=255; + rb[sizeof(uint32_t) + 1]=JPEG_MARKER_DHT; + rb[sizeof(uint32_t) + 2]=(uint8_t)((19 + q) >> 8); + rb[sizeof(uint32_t) + 3]=((19 + q) & 255); + rb[sizeof(uint32_t) + 4]=m; for (n=0; n<16; n++) - rb[sizeof(uint32)+5+n]=o[n]; - p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); + rb[sizeof(uint32_t) + 5 + n]=o[n]; + p=(uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q); if (p!=q) { _TIFFfree(rb); @@ -2030,13 +2030,13 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSecTablesAcTable"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint8 o[16]; - uint32 p; - uint32 q; - uint32 ra; - uint8* rb; + uint8_t m; + uint8_t n; + uint8_t o[16]; + uint32_t p; + uint32_t q; + uint32_t ra; + uint8_t* rb; if (sp->actable_offset[0]==0) { TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); @@ -2056,28 +2056,28 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif) } } TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET); - p=(uint32)TIFFReadFile(tif,o,16); + p=(uint32_t)TIFFReadFile(tif, o, 16); if (p!=16) return(0); q=0; for (n=0; n<16; n++) q+=o[n]; - ra=sizeof(uint32)+21+q; + ra= sizeof(uint32_t) + 21 + q; rb=_TIFFmalloc(ra); if (rb==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)rb=ra; - rb[sizeof(uint32)]=255; - rb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - rb[sizeof(uint32)+2]=(uint8)((19+q)>>8); - rb[sizeof(uint32)+3]=((19+q)&255); - rb[sizeof(uint32)+4]=(16|m); + *(uint32_t*)rb=ra; + rb[sizeof(uint32_t)]=255; + rb[sizeof(uint32_t) + 1]=JPEG_MARKER_DHT; + rb[sizeof(uint32_t) + 2]=(uint8_t)((19 + q) >> 8); + rb[sizeof(uint32_t) + 3]=((19 + q) & 255); + rb[sizeof(uint32_t) + 4]=(16 | m); for (n=0; n<16; n++) - rb[sizeof(uint32)+5+n]=o[n]; - p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); + rb[sizeof(uint32_t) + 5 + n]=o[n]; + p=(uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q); if (p!=q) { _TIFFfree(rb); @@ -2097,7 +2097,7 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif) static int OJPEGReadBufferFill(OJPEGState* sp) { - uint16 m; + uint16_t m; tmsize_t n; /* TODO: double-check: when subsamplingcorrect is set, no call to TIFFErrorExt or TIFFWarningExt should be made * in any other case, seek or read errors should be passed through */ @@ -2111,16 +2111,16 @@ OJPEGReadBufferFill(OJPEGState* sp) sp->in_buffer_file_pos_log=1; } m=OJPEG_BUFFER; - if ((uint64)m>sp->in_buffer_file_togo) - m=(uint16)sp->in_buffer_file_togo; + if ((uint64_t)m > sp->in_buffer_file_togo) + m=(uint16_t)sp->in_buffer_file_togo; n=TIFFReadFile(sp->tif,sp->in_buffer,(tmsize_t)m); if (n==0) return(0); assert(n>0); assert(n<=OJPEG_BUFFER); assert(n<65536); - assert((uint64)n<=sp->in_buffer_file_togo); - m=(uint16)n; + assert((uint64_t)n <= sp->in_buffer_file_togo); + m=(uint16_t)n; sp->in_buffer_togo=m; sp->in_buffer_cur=sp->in_buffer; sp->in_buffer_file_togo-=m; @@ -2152,7 +2152,7 @@ OJPEGReadBufferFill(OJPEGState* sp) return 0; if (sp->in_buffer_file_pos!=0) { - uint64 bytecount = TIFFGetStrileByteCountWithErr(sp->tif, sp->in_buffer_next_strile, &err); + uint64_t bytecount = TIFFGetStrileByteCountWithErr(sp->tif, sp->in_buffer_next_strile, &err); if( err ) return 0; if (sp->in_buffer_file_pos>=sp->file_size) @@ -2164,7 +2164,7 @@ OJPEGReadBufferFill(OJPEGState* sp) sp->in_buffer_file_togo=bytecount; if (sp->in_buffer_file_togo==0) sp->in_buffer_file_pos=0; - else if (sp->in_buffer_file_pos > TIFF_UINT64_MAX - sp->in_buffer_file_togo || + else if (sp->in_buffer_file_pos > UINT64_MAX - sp->in_buffer_file_togo || sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size) sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; } @@ -2180,7 +2180,7 @@ OJPEGReadBufferFill(OJPEGState* sp) } static int -OJPEGReadByte(OJPEGState* sp, uint8* byte) +OJPEGReadByte(OJPEGState* sp, uint8_t* byte) { if (sp->in_buffer_togo==0) { @@ -2195,7 +2195,7 @@ OJPEGReadByte(OJPEGState* sp, uint8* byte) } static int -OJPEGReadBytePeek(OJPEGState* sp, uint8* byte) +OJPEGReadBytePeek(OJPEGState* sp, uint8_t* byte) { if (sp->in_buffer_togo==0) { @@ -2216,9 +2216,9 @@ OJPEGReadByteAdvance(OJPEGState* sp) } static int -OJPEGReadWord(OJPEGState* sp, uint16* word) +OJPEGReadWord(OJPEGState* sp, uint16_t* word) { - uint8 m; + uint8_t m; if (OJPEGReadByte(sp,&m)==0) return(0); *word=(m<<8); @@ -2229,11 +2229,11 @@ OJPEGReadWord(OJPEGState* sp, uint16* word) } static int -OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) +OJPEGReadBlock(OJPEGState* sp, uint16_t len, void* mem) { - uint16 mlen; - uint8* mmem; - uint16 n; + uint16_t mlen; + uint8_t* mmem; + uint16_t n; assert(len>0); mlen=len; mmem=mem; @@ -2258,10 +2258,10 @@ OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) } static void -OJPEGReadSkip(OJPEGState* sp, uint16 len) +OJPEGReadSkip(OJPEGState* sp, uint16_t len) { - uint16 m; - uint16 n; + uint16_t m; + uint16_t n; m=len; n=m; if (n>sp->in_buffer_togo) @@ -2273,8 +2273,8 @@ OJPEGReadSkip(OJPEGState* sp, uint16 len) { assert(sp->in_buffer_togo==0); n=m; - if ((uint64)n>sp->in_buffer_file_togo) - n=(uint16)sp->in_buffer_file_togo; + if ((uint64_t)n > sp->in_buffer_file_togo) + n=(uint16_t)sp->in_buffer_file_togo; sp->in_buffer_file_pos+=n; sp->in_buffer_file_togo-=n; sp->in_buffer_file_pos_log=0; @@ -2288,7 +2288,7 @@ OJPEGReadSkip(OJPEGState* sp, uint16 len) } static int -OJPEGWriteStream(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStream(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; *len=0; @@ -2361,7 +2361,7 @@ OJPEGWriteStream(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; assert(OJPEG_BUFFER>=2); @@ -2373,43 +2373,43 @@ OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +OJPEGWriteStreamQTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; if (sp->qtable[table_index]!=0) { - *mem=(void*)(sp->qtable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->qtable[table_index])-sizeof(uint32); + *mem=(void*)(sp->qtable[table_index]+sizeof(uint32_t)); + *len= *((uint32_t*)sp->qtable[table_index]) - sizeof(uint32_t); } sp->out_state++; } static void -OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +OJPEGWriteStreamDcTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; if (sp->dctable[table_index]!=0) { - *mem=(void*)(sp->dctable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->dctable[table_index])-sizeof(uint32); + *mem=(void*)(sp->dctable[table_index]+sizeof(uint32_t)); + *len= *((uint32_t*)sp->dctable[table_index]) - sizeof(uint32_t); } sp->out_state++; } static void -OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +OJPEGWriteStreamAcTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; if (sp->actable[table_index]!=0) { - *mem=(void*)(sp->actable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->actable[table_index])-sizeof(uint32); + *mem=(void*)(sp->actable[table_index]+sizeof(uint32_t)); + *len= *((uint32_t*)sp->actable[table_index]) - sizeof(uint32_t); } sp->out_state++; } static void -OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; assert(OJPEG_BUFFER>=6); @@ -2428,10 +2428,10 @@ OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; + uint8_t m; assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3); assert(255>=8+sp->samples_per_pixel_per_plane*3); sp->out_buffer[0]=255; @@ -2442,10 +2442,10 @@ OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) /* P */ sp->out_buffer[4]=8; /* Y */ - sp->out_buffer[5]=(uint8)(sp->sof_y>>8); + sp->out_buffer[5]=(uint8_t)(sp->sof_y >> 8); sp->out_buffer[6]=(sp->sof_y&255); /* X */ - sp->out_buffer[7]=(uint8)(sp->sof_x>>8); + sp->out_buffer[7]=(uint8_t)(sp->sof_x >> 8); sp->out_buffer[8]=(sp->sof_x&255); /* Nf */ sp->out_buffer[9]=sp->samples_per_pixel_per_plane; @@ -2464,10 +2464,10 @@ OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; + uint8_t m; assert(OJPEG_BUFFER>=2+6+sp->samples_per_pixel_per_plane*2); assert(255>=6+sp->samples_per_pixel_per_plane*2); sp->out_buffer[0]=255; @@ -2496,7 +2496,7 @@ OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len) } static int -OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; if (sp->in_buffer_togo==0) @@ -2529,7 +2529,7 @@ OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; assert(OJPEG_BUFFER>=2); @@ -2544,7 +2544,7 @@ OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; assert(OJPEG_BUFFER>=2); @@ -2569,7 +2569,7 @@ jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) #ifndef LIBJPEG_ENCAP_EXTERNAL static int -jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image) +jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8_t require_image) { if( SETJMP(sp->exit_jmpbuf) ) return 0; @@ -2595,7 +2595,7 @@ jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) #ifndef LIBJPEG_ENCAP_EXTERNAL static int -jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines) +jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32_t max_lines) { if( SETJMP(sp->exit_jmpbuf) ) return 0; @@ -2608,7 +2608,7 @@ jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* s #ifndef LIBJPEG_ENCAP_EXTERNAL static int -jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines) +jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32_t max_lines) { if( SETJMP(sp->exit_jmpbuf) ) return 0; @@ -2659,7 +2659,7 @@ OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo) TIFF *tif = TIFF_FROM_CINFO(cinfo); OJPEGState* sp=(OJPEGState*)tif->tif_data; void* mem=0; - uint32 len=0U; + uint32_t len=0U; if (OJPEGWriteStream(tif,&mem,&len)==0) { TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Premature end of JPEG data"); diff --git a/tiff/libtiff/tif_open.c b/tiff/libtiff/tif_open.c index 0534773a..eec5469d 100644 --- a/tiff/libtiff/tif_open.c +++ b/tiff/libtiff/tif_open.c @@ -88,19 +88,19 @@ TIFFClientOpen( /* The following are configuration checks. They should be redundant, but should not * compile to any actual code in an optimised release build anyway. If any of them * fail, (makefile-based or other) configuration is not correct */ - assert(sizeof(uint8)==1); - assert(sizeof(int8)==1); - assert(sizeof(uint16)==2); - assert(sizeof(int16)==2); - assert(sizeof(uint32)==4); - assert(sizeof(int32)==4); - assert(sizeof(uint64)==8); - assert(sizeof(int64)==8); + assert(sizeof(uint8_t) == 1); + assert(sizeof(int8_t) == 1); + assert(sizeof(uint16_t) == 2); + assert(sizeof(int16_t) == 2); + assert(sizeof(uint32_t) == 4); + assert(sizeof(int32_t) == 4); + assert(sizeof(uint64_t) == 8); + assert(sizeof(int64_t) == 8); assert(sizeof(tmsize_t)==sizeof(void*)); { union{ - uint8 a8[2]; - uint16 a16; + uint8_t a8[2]; + uint16_t a16; } n; n.a8[0]=1; n.a8[1]=0; @@ -124,10 +124,10 @@ TIFFClientOpen( tif->tif_name = (char *)tif + sizeof (TIFF); strcpy(tif->tif_name, name); tif->tif_mode = m &~ (O_CREAT|O_TRUNC); - tif->tif_curdir = (uint16) -1; /* non-existent directory */ + tif->tif_curdir = (uint16_t) -1; /* non-existent directory */ tif->tif_curoff = 0; - tif->tif_curstrip = (uint32) -1; /* invalid strip */ - tif->tif_row = (uint32) -1; /* read/write pre-increment */ + tif->tif_curstrip = (uint32_t) -1; /* invalid strip */ + tif->tif_row = (uint32_t) -1; /* read/write pre-increment */ tif->tif_clientdata = clientdata; if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) { TIFFErrorExt(clientdata, module, @@ -373,11 +373,11 @@ TIFFClientOpen( #endif ) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF or MDI file, bad magic number %d (0x%x)", + "Not a TIFF or MDI file, bad magic number %"PRIu16" (0x%"PRIx16")", #else ) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad magic number %d (0x%x)", + "Not a TIFF file, bad magic number %"PRIu16" (0x%"PRIx16")", #endif tif->tif_header.common.tiff_magic, tif->tif_header.common.tiff_magic); @@ -397,7 +397,7 @@ TIFFClientOpen( if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC)&& (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG)) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad version number %d (0x%x)", + "Not a TIFF file, bad version number %"PRIu16" (0x%"PRIx16")", tif->tif_header.common.tiff_version, tif->tif_header.common.tiff_version); goto bad; @@ -410,7 +410,7 @@ TIFFClientOpen( } else { - if (!ReadOK(tif, ((uint8*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig)-sizeof(TIFFHeaderClassic)))) + if (!ReadOK(tif, ((uint8_t*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig) - sizeof(TIFFHeaderClassic)))) { TIFFErrorExt(tif->tif_clientdata, name, "Cannot read TIFF header"); @@ -424,7 +424,7 @@ TIFFClientOpen( if (tif->tif_header.big.tiff_offsetsize != 8) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad BigTIFF offsetsize %d (0x%x)", + "Not a TIFF file, bad BigTIFF offsetsize %"PRIu16" (0x%"PRIx16")", tif->tif_header.big.tiff_offsetsize, tif->tif_header.big.tiff_offsetsize); goto bad; @@ -432,7 +432,7 @@ TIFFClientOpen( if (tif->tif_header.big.tiff_unused != 0) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad BigTIFF unused %d (0x%x)", + "Not a TIFF file, bad BigTIFF unused %"PRIu16" (0x%"PRIx16")", tif->tif_header.big.tiff_unused, tif->tif_header.big.tiff_unused); goto bad; @@ -600,7 +600,7 @@ TIFFIsTiled(TIFF* tif) /* * Return current row being read/written. */ -uint32 +uint32_t TIFFCurrentRow(TIFF* tif) { return (tif->tif_row); @@ -609,7 +609,7 @@ TIFFCurrentRow(TIFF* tif) /* * Return index of the current directory. */ -uint16 +uint16_t TIFFCurrentDirectory(TIFF* tif) { return (tif->tif_curdir); @@ -618,7 +618,7 @@ TIFFCurrentDirectory(TIFF* tif) /* * Return current strip. */ -uint32 +uint32_t TIFFCurrentStrip(TIFF* tif) { return (tif->tif_curstrip); @@ -627,7 +627,7 @@ TIFFCurrentStrip(TIFF* tif) /* * Return current tile. */ -uint32 +uint32_t TIFFCurrentTile(TIFF* tif) { return (tif->tif_curtile); diff --git a/tiff/libtiff/tif_packbits.c b/tiff/libtiff/tif_packbits.c index a8f29e87..76569ad7 100644 --- a/tiff/libtiff/tif_packbits.c +++ b/tiff/libtiff/tif_packbits.c @@ -32,11 +32,11 @@ #include <stdio.h> static int -PackBitsPreEncode(TIFF* tif, uint16 s) +PackBitsPreEncode(TIFF* tif, uint16_t s) { (void) s; - tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t)); + tif->tif_data = (uint8_t*)_TIFFmalloc(sizeof(tmsize_t)); if (tif->tif_data == NULL) return (0); /* @@ -61,12 +61,12 @@ PackBitsPostEncode(TIFF* tif) * Encode a run of pixels. */ static int -PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +PackBitsEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { unsigned char* bp = (unsigned char*) buf; - uint8* op; - uint8* ep; - uint8* lastliteral; + uint8_t* op; + uint8_t* ep; + uint8_t* lastliteral; long n, slop; int b; enum { BASE, LITERAL, RUN, LITERAL_RUN } state; @@ -114,17 +114,17 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) if (n > 1) { state = RUN; if (n > 128) { - *op++ = (uint8) -127; - *op++ = (uint8) b; + *op++ = (uint8_t) -127; + *op++ = (uint8_t) b; n -= 128; goto again; } - *op++ = (uint8)(-(n-1)); - *op++ = (uint8) b; + *op++ = (uint8_t)(-(n - 1)); + *op++ = (uint8_t) b; } else { lastliteral = op; *op++ = 0; - *op++ = (uint8) b; + *op++ = (uint8_t) b; state = LITERAL; } break; @@ -132,33 +132,33 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) if (n > 1) { state = LITERAL_RUN; if (n > 128) { - *op++ = (uint8) -127; - *op++ = (uint8) b; + *op++ = (uint8_t) -127; + *op++ = (uint8_t) b; n -= 128; goto again; } - *op++ = (uint8)(-(n-1)); /* encode run */ - *op++ = (uint8) b; + *op++ = (uint8_t)(-(n - 1)); /* encode run */ + *op++ = (uint8_t) b; } else { /* extend literal */ if (++(*lastliteral) == 127) state = BASE; - *op++ = (uint8) b; + *op++ = (uint8_t) b; } break; case RUN: /* last object was run */ if (n > 1) { if (n > 128) { - *op++ = (uint8) -127; - *op++ = (uint8) b; + *op++ = (uint8_t) -127; + *op++ = (uint8_t) b; n -= 128; goto again; } - *op++ = (uint8)(-(n-1)); - *op++ = (uint8) b; + *op++ = (uint8_t)(-(n - 1)); + *op++ = (uint8_t) b; } else { lastliteral = op; *op++ = 0; - *op++ = (uint8) b; + *op++ = (uint8_t) b; state = LITERAL; } break; @@ -169,7 +169,7 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * case we convert literal-run-literal * to a single literal. */ - if (n == 1 && op[-2] == (uint8) -1 && + if (n == 1 && op[-2] == (uint8_t) -1 && *lastliteral < 126) { state = (((*lastliteral) += 2) == 127 ? BASE : LITERAL); @@ -192,7 +192,7 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * when it was encoded by strips. */ static int -PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +PackBitsEncodeChunk(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowsize = *(tmsize_t*)tif->tif_data; @@ -211,7 +211,7 @@ PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } static int -PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "PackBitsDecode"; char *bp; @@ -238,8 +238,8 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) if( occ < (tmsize_t)n ) { TIFFWarningExt(tif->tif_clientdata, module, - "Discarding %lu bytes to avoid buffer overrun", - (unsigned long) ((tmsize_t)n - occ)); + "Discarding %"TIFF_SSIZE_FORMAT" bytes to avoid buffer overrun", + (tmsize_t)n - occ); n = (long)occ; } if( cc == 0 ) @@ -252,13 +252,13 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) b = *bp++; cc--; while (n-- > 0) - *op++ = (uint8) b; + *op++ = (uint8_t) b; } else { /* copy next n+1 bytes literally */ if (occ < (tmsize_t)(n + 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Discarding %lu bytes to avoid buffer overrun", - (unsigned long) ((tmsize_t)n - occ + 1)); + "Discarding %"TIFF_SSIZE_FORMAT" bytes to avoid buffer overrun", + (tmsize_t)n - occ + 1); n = (long)occ - 1; } if (cc < (tmsize_t) (n+1)) @@ -272,12 +272,12 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) bp += n; cc -= n; } } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; if (occ > 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data for scanline %lu", - (unsigned long) tif->tif_row); + "Not enough data for scanline %"PRIu32, + tif->tif_row); return (0); } return (1); diff --git a/tiff/libtiff/tif_pixarlog.c b/tiff/libtiff/tif_pixarlog.c index f2912015..87c67097 100644 --- a/tiff/libtiff/tif_pixarlog.c +++ b/tiff/libtiff/tif_pixarlog.c @@ -109,8 +109,8 @@ static float LogK1, LogK2; #define REPEAT(n, op) { int i; i=n; do { i--; op; } while (i>0); } static void -horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, - float *ToLinearF) +horizontalAccumulateF(uint16_t *wp, int n, int stride, float *op, + float *ToLinearF) { register unsigned int cr, cg, cb, ca, mask; register float t0, t1, t2, t3; @@ -172,14 +172,14 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, } static void -horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, - float *ToLinearF) +horizontalAccumulate12(uint16_t *wp, int n, int stride, int16_t *op, + float *ToLinearF) { register unsigned int cr, cg, cb, ca, mask; register float t0, t1, t2, t3; #define SCALE12 2048.0F -#define CLAMP12(t) (((t) < 3071) ? (uint16) (t) : 3071) +#define CLAMP12(t) (((t) < 3071) ? (uint16_t) (t) : 3071) if (n >= stride) { mask = CODE_MASK; @@ -240,8 +240,8 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, } static void -horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, - uint16 *ToLinear16) +horizontalAccumulate16(uint16_t *wp, int n, int stride, uint16_t *op, + uint16_t *ToLinear16) { register unsigned int cr, cg, cb, ca, mask; @@ -292,7 +292,7 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, * differencing undone. */ static void -horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) +horizontalAccumulate11(uint16_t *wp, int n, int stride, uint16_t *op) { register unsigned int cr, cg, cb, ca, mask; @@ -306,9 +306,9 @@ horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) wp += 3; op += 3; n -= 3; - op[0] = (uint16)((cr += wp[0]) & mask); - op[1] = (uint16)((cg += wp[1]) & mask); - op[2] = (uint16)((cb += wp[2]) & mask); + op[0] = (uint16_t)((cr += wp[0]) & mask); + op[1] = (uint16_t)((cg += wp[1]) & mask); + op[2] = (uint16_t)((cb += wp[2]) & mask); } } else if (stride == 4) { op[0] = wp[0]; op[1] = wp[1]; @@ -319,10 +319,10 @@ horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) wp += 4; op += 4; n -= 4; - op[0] = (uint16)((cr += wp[0]) & mask); - op[1] = (uint16)((cg += wp[1]) & mask); - op[2] = (uint16)((cb += wp[2]) & mask); - op[3] = (uint16)((ca += wp[3]) & mask); + op[0] = (uint16_t)((cr += wp[0]) & mask); + op[1] = (uint16_t)((cg += wp[1]) & mask); + op[2] = (uint16_t)((cb += wp[2]) & mask); + op[3] = (uint16_t)((ca += wp[3]) & mask); } } else { REPEAT(stride, *op = *wp&mask; wp++; op++) @@ -337,8 +337,8 @@ horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) } static void -horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, - unsigned char *ToLinear8) +horizontalAccumulate8(uint16_t *wp, int n, int stride, unsigned char *op, + unsigned char *ToLinear8) { register unsigned int cr, cg, cb, ca, mask; @@ -386,8 +386,8 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, static void -horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op, - unsigned char *ToLinear8) +horizontalAccumulate8abgr(uint16_t *wp, int n, int stride, unsigned char *op, + unsigned char *ToLinear8) { register unsigned int cr, cg, cb, ca, mask; register unsigned char t0, t1, t2, t3; @@ -458,8 +458,8 @@ typedef struct { TIFFPredictorState predict; z_stream stream; tmsize_t tbuf_size; /* only set/used on reading for now */ - uint16 *tbuf; - uint16 stride; + uint16_t *tbuf; + uint16_t stride; int state; int user_datafmt; int quality; @@ -469,11 +469,11 @@ typedef struct { TIFFVSetMethod vsetparent; /* super-class method */ float *ToLinearF; - uint16 *ToLinear16; + uint16_t *ToLinear16; unsigned char *ToLinear8; - uint16 *FromLT2; - uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16 *From8; + uint16_t *FromLT2; + uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */ + uint16_t *From8; } PixarLogState; @@ -496,11 +496,11 @@ PixarLogMakeTables(PixarLogState *sp) int i, j; double b, c, linstep, v; float *ToLinearF; - uint16 *ToLinear16; + uint16_t *ToLinear16; unsigned char *ToLinear8; - uint16 *FromLT2; - uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16 *From8; + uint16_t *FromLT2; + uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */ + uint16_t *From8; c = log(RATIO); nlin = (int)(1./c); /* nlin must be an integer */ @@ -511,11 +511,11 @@ PixarLogMakeTables(PixarLogState *sp) LogK1 = (float)(1./c); /* if (v >= 2) token = k1*log(v*k2) */ LogK2 = (float)(1./b); lt2size = (int)(2./linstep) + 1; - FromLT2 = (uint16 *)_TIFFmalloc(lt2size*sizeof(uint16)); - From14 = (uint16 *)_TIFFmalloc(16384*sizeof(uint16)); - From8 = (uint16 *)_TIFFmalloc(256*sizeof(uint16)); + FromLT2 = (uint16_t *)_TIFFmalloc(lt2size * sizeof(uint16_t)); + From14 = (uint16_t *)_TIFFmalloc(16384 * sizeof(uint16_t)); + From8 = (uint16_t *)_TIFFmalloc(256 * sizeof(uint16_t)); ToLinearF = (float *)_TIFFmalloc(TSIZEP1 * sizeof(float)); - ToLinear16 = (uint16 *)_TIFFmalloc(TSIZEP1 * sizeof(uint16)); + ToLinear16 = (uint16_t *)_TIFFmalloc(TSIZEP1 * sizeof(uint16_t)); ToLinear8 = (unsigned char *)_TIFFmalloc(TSIZEP1 * sizeof(unsigned char)); if (FromLT2 == NULL || From14 == NULL || From8 == NULL || ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL) { @@ -548,7 +548,7 @@ PixarLogMakeTables(PixarLogState *sp) for (i = 0; i < TSIZEP1; i++) { v = ToLinearF[i]*65535.0 + 0.5; - ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16)v; + ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16_t)v; v = ToLinearF[i]*255.0 + 0.5; ToLinear8[i] = (v > 255.0) ? 255 : (unsigned char)v; } @@ -557,7 +557,7 @@ PixarLogMakeTables(PixarLogState *sp) for (i = 0; i < lt2size; i++) { if ((i*linstep)*(i*linstep) > ToLinearF[j]*ToLinearF[j+1]) j++; - FromLT2[i] = (uint16)j; + FromLT2[i] = (uint16_t)j; } /* @@ -569,14 +569,14 @@ PixarLogMakeTables(PixarLogState *sp) for (i = 0; i < 16384; i++) { while ((i/16383.)*(i/16383.) > ToLinearF[j]*ToLinearF[j+1]) j++; - From14[i] = (uint16)j; + From14[i] = (uint16_t)j; } j = 0; for (i = 0; i < 256; i++) { while ((i/255.)*(i/255.) > ToLinearF[j]*ToLinearF[j+1]) j++; - From8[i] = (uint16)j; + From8[i] = (uint16_t)j; } Fltsize = (float)(lt2size/2); @@ -594,8 +594,8 @@ PixarLogMakeTables(PixarLogState *sp) #define DecoderState(tif) ((PixarLogState*) (tif)->tif_data) #define EncoderState(tif) ((PixarLogState*) (tif)->tif_data) -static int PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int PixarLogEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); #define PIXARLOGDATAFMT_UNKNOWN -1 @@ -667,7 +667,7 @@ PixarLogSetupDecode(TIFF* tif) TIFFDirectory *td = &tif->tif_dir; PixarLogState* sp = DecoderState(tif); tmsize_t tbuf_size; - uint32 strip_height; + uint32_t strip_height; assert(sp != NULL); @@ -690,12 +690,12 @@ PixarLogSetupDecode(TIFF* tif) sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1); tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), - strip_height), sizeof(uint16)); + strip_height), sizeof(uint16_t)); /* add one more stride in case input ends mid-stride */ - tbuf_size = add_ms(tbuf_size, sizeof(uint16) * sp->stride); + tbuf_size = add_ms(tbuf_size, sizeof(uint16_t) * sp->stride); if (tbuf_size == 0) return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); + sp->tbuf = (uint16_t *) _TIFFmalloc(tbuf_size); if (sp->tbuf == NULL) return (0); sp->tbuf_size = tbuf_size; @@ -706,7 +706,7 @@ PixarLogSetupDecode(TIFF* tif) sp->tbuf = NULL; sp->tbuf_size = 0; TIFFErrorExt(tif->tif_clientdata, module, - "PixarLog compression can't handle bits depth/data format combination (depth: %d)", + "PixarLog compression can't handle bits depth/data format combination (depth: %"PRIu16")", td->td_bitspersample); return (0); } @@ -727,7 +727,7 @@ PixarLogSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -PixarLogPreDecode(TIFF* tif, uint16 s) +PixarLogPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "PixarLogPreDecode"; PixarLogState* sp = DecoderState(tif); @@ -749,7 +749,7 @@ PixarLogPreDecode(TIFF* tif, uint16 s) } static int -PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "PixarLogDecode"; TIFFDirectory *td = &tif->tif_dir; @@ -757,7 +757,7 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t nsamples; int llen; - uint16 *up; + uint16_t *up; switch (sp->user_datafmt) { case PIXARLOGDATAFMT_FLOAT: @@ -766,7 +766,7 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) case PIXARLOGDATAFMT_16BIT: case PIXARLOGDATAFMT_12BITPICIO: case PIXARLOGDATAFMT_11BITLOG: - nsamples = occ / sizeof(uint16); /* XXX uint16 == 16 bits */ + nsamples = occ / sizeof(uint16_t); /* XXX uint16_t == 16 bits */ break; case PIXARLOGDATAFMT_8BIT: case PIXARLOGDATAFMT_8BITABGR: @@ -774,7 +774,7 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } @@ -792,8 +792,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) we need to simplify this code to reflect a ZLib that is likely updated to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ - sp->stream.avail_out = (uInt) (nsamples * sizeof(uint16)); - if (sp->stream.avail_out != nsamples * sizeof(uint16)) + sp->stream.avail_out = (uInt) (nsamples * sizeof(uint16_t)); + if (sp->stream.avail_out != nsamples * sizeof(uint16_t)) { TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); return (0); @@ -811,8 +811,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) } if (state == Z_DATA_ERROR) { TIFFErrorExt(tif->tif_clientdata, module, - "Decoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)"); + "Decoding error at scanline %"PRIu32", %s", + tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)"); return (0); } if (state != Z_OK) { @@ -825,8 +825,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) /* hopefully, we got all the bytes we needed */ if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)", - (unsigned long) tif->tif_row, (TIFF_UINT64_T) sp->stream.avail_out); + "Not enough data at scanline %"PRIu32" (short %u bytes)", + tif->tif_row, sp->stream.avail_out); return (0); } @@ -845,8 +845,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) */ if (nsamples % llen) { TIFFWarningExt(tif->tif_clientdata, module, - "stride %lu is not a multiple of sample count, " - "%lu, data truncated.", (unsigned long) llen, (unsigned long) nsamples); + "stride %d is not a multiple of sample count, " + "%"TIFF_SSIZE_FORMAT", data truncated.", llen, nsamples); nsamples -= nsamples % llen; } @@ -859,18 +859,18 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) break; case PIXARLOGDATAFMT_16BIT: horizontalAccumulate16(up, llen, sp->stride, - (uint16 *)op, sp->ToLinear16); - op += llen * sizeof(uint16); + (uint16_t *)op, sp->ToLinear16); + op += llen * sizeof(uint16_t); break; case PIXARLOGDATAFMT_12BITPICIO: horizontalAccumulate12(up, llen, sp->stride, - (int16 *)op, sp->ToLinearF); - op += llen * sizeof(int16); + (int16_t *)op, sp->ToLinearF); + op += llen * sizeof(int16_t); break; case PIXARLOGDATAFMT_11BITLOG: horizontalAccumulate11(up, llen, sp->stride, - (uint16 *)op); - op += llen * sizeof(uint16); + (uint16_t *)op); + op += llen * sizeof(uint16_t); break; case PIXARLOGDATAFMT_8BIT: horizontalAccumulate8(up, llen, sp->stride, @@ -884,7 +884,7 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "Unsupported bits/sample: %d", + "Unsupported bits/sample: %"PRIu16, td->td_bitspersample); return (0); } @@ -908,16 +908,16 @@ PixarLogSetupEncode(TIFF* tif) sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1); tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), - td->td_rowsperstrip), sizeof(uint16)); + td->td_rowsperstrip), sizeof(uint16_t)); if (tbuf_size == 0) return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); + sp->tbuf = (uint16_t *) _TIFFmalloc(tbuf_size); if (sp->tbuf == NULL) return (0); if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) sp->user_datafmt = PixarLogGuessDataFmt(td); if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { - TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %d bit linear encodings", td->td_bitspersample); + TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %"PRIu16" bit linear encodings", td->td_bitspersample); return (0); } @@ -934,7 +934,7 @@ PixarLogSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -PixarLogPreEncode(TIFF* tif, uint16 s) +PixarLogPreEncode(TIFF* tif, uint16_t s) { static const char module[] = "PixarLogPreEncode"; PixarLogState *sp = EncoderState(tif); @@ -956,9 +956,9 @@ PixarLogPreEncode(TIFF* tif, uint16 s) } static void -horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) +horizontalDifferenceF(float *ip, int n, int stride, uint16_t *wp, uint16_t *FromLT2) { - int32 r1, g1, b1, a1, r2, g2, b2, a2, mask; + int32_t r1, g1, b1, a1, r2, g2, b2, a2, mask; float fltsize = Fltsize; #define CLAMP(v) ( (v<(float)0.) ? 0 \ @@ -969,39 +969,39 @@ horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) mask = CODE_MASK; if (n >= stride) { if (stride == 3) { - r2 = wp[0] = (uint16) CLAMP(ip[0]); - g2 = wp[1] = (uint16) CLAMP(ip[1]); - b2 = wp[2] = (uint16) CLAMP(ip[2]); + r2 = wp[0] = (uint16_t) CLAMP(ip[0]); + g2 = wp[1] = (uint16_t) CLAMP(ip[1]); + b2 = wp[2] = (uint16_t) CLAMP(ip[2]); n -= 3; while (n > 0) { n -= 3; wp += 3; ip += 3; - r1 = (int32) CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = (int32) CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = (int32) CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1; + r1 = (int32_t) CLAMP(ip[0]); wp[0] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = (int32_t) CLAMP(ip[1]); wp[1] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = (int32_t) CLAMP(ip[2]); wp[2] = (uint16_t)((b1 - b2) & mask); b2 = b1; } } else if (stride == 4) { - r2 = wp[0] = (uint16) CLAMP(ip[0]); - g2 = wp[1] = (uint16) CLAMP(ip[1]); - b2 = wp[2] = (uint16) CLAMP(ip[2]); - a2 = wp[3] = (uint16) CLAMP(ip[3]); + r2 = wp[0] = (uint16_t) CLAMP(ip[0]); + g2 = wp[1] = (uint16_t) CLAMP(ip[1]); + b2 = wp[2] = (uint16_t) CLAMP(ip[2]); + a2 = wp[3] = (uint16_t) CLAMP(ip[3]); n -= 4; while (n > 0) { n -= 4; wp += 4; ip += 4; - r1 = (int32) CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = (int32) CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = (int32) CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1; - a1 = (int32) CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1; + r1 = (int32_t) CLAMP(ip[0]); wp[0] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = (int32_t) CLAMP(ip[1]); wp[1] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = (int32_t) CLAMP(ip[2]); wp[2] = (uint16_t)((b1 - b2) & mask); b2 = b1; + a1 = (int32_t) CLAMP(ip[3]); wp[3] = (uint16_t)((a1 - a2) & mask); a2 = a1; } } else { - REPEAT(stride, wp[0] = (uint16) CLAMP(ip[0]); wp++; ip++) + REPEAT(stride, wp[0] = (uint16_t) CLAMP(ip[0]); wp++; ip++) n -= stride; while (n > 0) { REPEAT(stride, - wp[0] = (uint16)(((int32)CLAMP(ip[0])-(int32)CLAMP(ip[-stride])) & mask); + wp[0] = (uint16_t)(((int32_t)CLAMP(ip[0]) - (int32_t)CLAMP(ip[-stride])) & mask); wp++; ip++) n -= stride; } @@ -1010,8 +1010,8 @@ horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) } static void -horizontalDifference16(unsigned short *ip, int n, int stride, - unsigned short *wp, uint16 *From14) +horizontalDifference16(unsigned short *ip, int n, int stride, + unsigned short *wp, uint16_t *From14) { register int r1, g1, b1, a1, r2, g2, b2, a2, mask; @@ -1029,9 +1029,9 @@ horizontalDifference16(unsigned short *ip, int n, int stride, n -= 3; wp += 3; ip += 3; - r1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1; + r1 = CLAMP(ip[0]); wp[0] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = CLAMP(ip[1]); wp[1] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = CLAMP(ip[2]); wp[2] = (uint16_t)((b1 - b2) & mask); b2 = b1; } } else if (stride == 4) { r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); @@ -1041,17 +1041,17 @@ horizontalDifference16(unsigned short *ip, int n, int stride, n -= 4; wp += 4; ip += 4; - r1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1; - a1 = CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1; + r1 = CLAMP(ip[0]); wp[0] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = CLAMP(ip[1]); wp[1] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = CLAMP(ip[2]); wp[2] = (uint16_t)((b1 - b2) & mask); b2 = b1; + a1 = CLAMP(ip[3]); wp[3] = (uint16_t)((a1 - a2) & mask); a2 = a1; } } else { REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++) n -= stride; while (n > 0) { REPEAT(stride, - wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask); + wp[0] = (uint16_t)((CLAMP(ip[0]) - CLAMP(ip[-stride])) & mask); wp++; ip++) n -= stride; } @@ -1061,8 +1061,8 @@ horizontalDifference16(unsigned short *ip, int n, int stride, static void -horizontalDifference8(unsigned char *ip, int n, int stride, - unsigned short *wp, uint16 *From8) +horizontalDifference8(unsigned char *ip, int n, int stride, + unsigned short *wp, uint16_t *From8) { register int r1, g1, b1, a1, r2, g2, b2, a2, mask; @@ -1077,9 +1077,9 @@ horizontalDifference8(unsigned char *ip, int n, int stride, n -= 3; while (n > 0) { n -= 3; - r1 = CLAMP(ip[3]); wp[3] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = CLAMP(ip[4]); wp[4] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = CLAMP(ip[5]); wp[5] = (uint16)((b1-b2) & mask); b2 = b1; + r1 = CLAMP(ip[3]); wp[3] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = CLAMP(ip[4]); wp[4] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = CLAMP(ip[5]); wp[5] = (uint16_t)((b1 - b2) & mask); b2 = b1; wp += 3; ip += 3; } @@ -1089,10 +1089,10 @@ horizontalDifference8(unsigned char *ip, int n, int stride, n -= 4; while (n > 0) { n -= 4; - r1 = CLAMP(ip[4]); wp[4] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = CLAMP(ip[5]); wp[5] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = CLAMP(ip[6]); wp[6] = (uint16)((b1-b2) & mask); b2 = b1; - a1 = CLAMP(ip[7]); wp[7] = (uint16)((a1-a2) & mask); a2 = a1; + r1 = CLAMP(ip[4]); wp[4] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = CLAMP(ip[5]); wp[5] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = CLAMP(ip[6]); wp[6] = (uint16_t)((b1 - b2) & mask); b2 = b1; + a1 = CLAMP(ip[7]); wp[7] = (uint16_t)((a1 - a2) & mask); a2 = a1; wp += 4; ip += 4; } @@ -1101,7 +1101,7 @@ horizontalDifference8(unsigned char *ip, int n, int stride, n -= stride; while (n > 0) { REPEAT(stride, - wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask); + wp[0] = (uint16_t)((CLAMP(ip[0]) - CLAMP(ip[-stride])) & mask); wp++; ip++) n -= stride; } @@ -1113,7 +1113,7 @@ horizontalDifference8(unsigned char *ip, int n, int stride, * Encode a chunk of pixels. */ static int -PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +PixarLogEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "PixarLogEncode"; TIFFDirectory *td = &tif->tif_dir; @@ -1132,7 +1132,7 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) case PIXARLOGDATAFMT_16BIT: case PIXARLOGDATAFMT_12BITPICIO: case PIXARLOGDATAFMT_11BITLOG: - n = cc / sizeof(uint16); /* XXX uint16 == 16 bits */ + n = cc / sizeof(uint16_t); /* XXX uint16_t == 16 bits */ break; case PIXARLOGDATAFMT_8BIT: case PIXARLOGDATAFMT_8BITABGR: @@ -1140,13 +1140,13 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } llen = sp->stride * td->td_imagewidth; - /* Check against the number of elements (of size uint16) of sp->tbuf */ + /* Check against the number of elements (of size uint16_t) of sp->tbuf */ if( n > ((tmsize_t)td->td_rowsperstrip * llen) ) { TIFFErrorExt(tif->tif_clientdata, module, @@ -1162,9 +1162,9 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) bp += llen * sizeof(float); break; case PIXARLOGDATAFMT_16BIT: - horizontalDifference16((uint16 *)bp, llen, - sp->stride, up, sp->From14); - bp += llen * sizeof(uint16); + horizontalDifference16((uint16_t *)bp, llen, + sp->stride, up, sp->From14); + bp += llen * sizeof(uint16_t); break; case PIXARLOGDATAFMT_8BIT: horizontalDifference8((unsigned char *)bp, llen, @@ -1173,7 +1173,7 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } @@ -1184,8 +1184,8 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) we need to simplify this code to reflect a ZLib that is likely updated to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ - sp->stream.avail_in = (uInt) (n * sizeof(uint16)); - if ((sp->stream.avail_in / sizeof(uint16)) != (uInt) n) + sp->stream.avail_in = (uInt) (n * sizeof(uint16_t)); + if ((sp->stream.avail_in / sizeof(uint16_t)) != (uInt) n) { TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); @@ -1309,7 +1309,7 @@ PixarLogCleanup(TIFF* tif) } static int -PixarLogVSetField(TIFF* tif, uint32 tag, va_list ap) +PixarLogVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "PixarLogVSetField"; PixarLogState *sp = (PixarLogState *)tif->tif_data; @@ -1371,7 +1371,7 @@ PixarLogVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -PixarLogVGetField(TIFF* tif, uint32 tag, va_list ap) +PixarLogVGetField(TIFF* tif, uint32_t tag, va_list ap) { PixarLogState *sp = (PixarLogState *)tif->tif_data; @@ -1416,7 +1416,7 @@ TIFFInitPixarLog(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (PixarLogState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (PixarLogState)); if (tif->tif_data == NULL) goto bad; sp = (PixarLogState*) tif->tif_data; diff --git a/tiff/libtiff/tif_predict.c b/tiff/libtiff/tif_predict.c index c0233974..4aa4af69 100644 --- a/tiff/libtiff/tif_predict.c +++ b/tiff/libtiff/tif_predict.c @@ -32,22 +32,22 @@ #define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) -static int horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc); -static int swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc); -static int swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc); -static int swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc); -static int swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc); -static int fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc); -static int fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc); -static int PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); -static int PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); -static int PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s); +static int horAcc8(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horAcc16(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horAcc32(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int swabHorAcc16(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int swabHorAcc32(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horDiff8(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horDiff16(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horDiff32(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int swabHorDiff16(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int swabHorDiff32(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int fpAcc(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int fpDiff(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int PredictorDecodeRow(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s); +static int PredictorDecodeTile(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s); +static int PredictorEncodeRow(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int PredictorEncodeTile(TIFF* tif, uint8_t* bp0, tmsize_t cc0, uint16_t s); static int PredictorSetup(TIFF* tif) @@ -66,7 +66,7 @@ PredictorSetup(TIFF* tif) && td->td_bitspersample != 16 && td->td_bitspersample != 32) { TIFFErrorExt(tif->tif_clientdata, module, - "Horizontal differencing \"Predictor\" not supported with %d-bit samples", + "Horizontal differencing \"Predictor\" not supported with %"PRIu16"-bit samples", td->td_bitspersample); return 0; } @@ -74,7 +74,7 @@ PredictorSetup(TIFF* tif) case PREDICTOR_FLOATINGPOINT: if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) { TIFFErrorExt(tif->tif_clientdata, module, - "Floating point \"Predictor\" not supported with %d data format", + "Floating point \"Predictor\" not supported with %"PRIu16" data format", td->td_sampleformat); return 0; } @@ -83,7 +83,7 @@ PredictorSetup(TIFF* tif) && td->td_bitspersample != 32 && td->td_bitspersample != 64) { /* Should 64 be allowed? */ TIFFErrorExt(tif->tif_clientdata, module, - "Floating point \"Predictor\" not supported with %d-bit samples", + "Floating point \"Predictor\" not supported with %"PRIu16"-bit samples", td->td_bitspersample); return 0; } @@ -277,7 +277,7 @@ PredictorSetupEncode(TIFF* tif) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc) +horAcc8(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; @@ -334,9 +334,9 @@ horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) +swabHorAcc16(TIFF* tif, uint8_t* cp0, tmsize_t cc) { - uint16* wp = (uint16*) cp0; + uint16_t* wp = (uint16_t*) cp0; tmsize_t wc = cc / 2; TIFFSwabArrayOfShort(wp, wc); @@ -345,10 +345,10 @@ swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) +horAcc16(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; - uint16* wp = (uint16*) cp0; + uint16_t* wp = (uint16_t*) cp0; tmsize_t wc = cc / 2; if((cc%(2*stride))!=0) @@ -361,7 +361,7 @@ horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) if (wc > stride) { wc -= stride; do { - REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] + (unsigned int)wp[0]) & 0xffff); wp++) + REPEAT4(stride, wp[stride] = (uint16_t)(((unsigned int)wp[stride] + (unsigned int)wp[0]) & 0xffff); wp++) wc -= stride; } while (wc > 0); } @@ -369,9 +369,9 @@ horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) +swabHorAcc32(TIFF* tif, uint8_t* cp0, tmsize_t cc) { - uint32* wp = (uint32*) cp0; + uint32_t* wp = (uint32_t*) cp0; tmsize_t wc = cc / 4; TIFFSwabArrayOfLong(wp, wc); @@ -380,10 +380,10 @@ swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) +horAcc32(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; - uint32* wp = (uint32*) cp0; + uint32_t* wp = (uint32_t*) cp0; tmsize_t wc = cc / 4; if((cc%(4*stride))!=0) @@ -407,14 +407,14 @@ horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) * Floating point predictor accumulation routine. */ static int -fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) +fpAcc(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; - uint32 bps = tif->tif_dir.td_bitspersample / 8; + uint32_t bps = tif->tif_dir.td_bitspersample / 8; tmsize_t wc = cc / bps; tmsize_t count = cc; - uint8 *cp = (uint8 *) cp0; - uint8 *tmp; + uint8_t *cp = (uint8_t *) cp0; + uint8_t *tmp; if(cc%(bps*stride)!=0) { @@ -423,7 +423,7 @@ fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) return 0; } - tmp = (uint8 *)_TIFFmalloc(cc); + tmp = (uint8_t *)_TIFFmalloc(cc); if (!tmp) return 0; @@ -434,9 +434,9 @@ fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) } _TIFFmemcpy(tmp, cp0, cc); - cp = (uint8 *) cp0; + cp = (uint8_t *) cp0; for (count = 0; count < wc; count++) { - uint32 byte; + uint32_t byte; for (byte = 0; byte < bps; byte++) { #if WORDS_BIGENDIAN cp[bps * count + byte] = tmp[byte * wc + count]; @@ -454,7 +454,7 @@ fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) * Decode a scanline and apply the predictor routine. */ static int -PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +PredictorDecodeRow(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) { TIFFPredictorState *sp = PredictorState(tif); @@ -476,7 +476,7 @@ PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) * strip/tile dimensions. */ static int -PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +PredictorDecodeTile(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) { TIFFPredictorState *sp = PredictorState(tif); @@ -506,7 +506,7 @@ PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc) +horDiff8(TIFF* tif, uint8_t* cp0, tmsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); tmsize_t stride = sp->stride; @@ -560,11 +560,11 @@ horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) +horDiff16(TIFF* tif, uint8_t* cp0, tmsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); tmsize_t stride = sp->stride; - uint16 *wp = (uint16*) cp0; + uint16_t *wp = (uint16_t*) cp0; tmsize_t wc = cc/2; if((cc%(2*stride))!=0) @@ -578,7 +578,7 @@ horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) wc -= stride; wp += wc - 1; do { - REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--) + REPEAT4(stride, wp[stride] = (uint16_t)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--) wc -= stride; } while (wc > 0); } @@ -586,9 +586,9 @@ horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) +swabHorDiff16(TIFF* tif, uint8_t* cp0, tmsize_t cc) { - uint16* wp = (uint16*) cp0; + uint16_t* wp = (uint16_t*) cp0; tmsize_t wc = cc / 2; if( !horDiff16(tif, cp0, cc) ) @@ -600,11 +600,11 @@ swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) +horDiff32(TIFF* tif, uint8_t* cp0, tmsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); tmsize_t stride = sp->stride; - uint32 *wp = (uint32*) cp0; + uint32_t *wp = (uint32_t*) cp0; tmsize_t wc = cc/4; if((cc%(4*stride))!=0) @@ -626,9 +626,9 @@ horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) +swabHorDiff32(TIFF* tif, uint8_t* cp0, tmsize_t cc) { - uint32* wp = (uint32*) cp0; + uint32_t* wp = (uint32_t*) cp0; tmsize_t wc = cc / 4; if( !horDiff32(tif, cp0, cc) ) @@ -643,14 +643,14 @@ swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) */ TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) +fpDiff(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; - uint32 bps = tif->tif_dir.td_bitspersample / 8; + uint32_t bps = tif->tif_dir.td_bitspersample / 8; tmsize_t wc = cc / bps; tmsize_t count; - uint8 *cp = (uint8 *) cp0; - uint8 *tmp; + uint8_t *cp = (uint8_t *) cp0; + uint8_t *tmp; if((cc%(bps*stride))!=0) { @@ -659,13 +659,13 @@ fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) return 0; } - tmp = (uint8 *)_TIFFmalloc(cc); + tmp = (uint8_t *)_TIFFmalloc(cc); if (!tmp) return 0; _TIFFmemcpy(tmp, cp0, cc); for (count = 0; count < wc; count++) { - uint32 byte; + uint32_t byte; for (byte = 0; byte < bps; byte++) { #if WORDS_BIGENDIAN cp[byte * wc + count] = tmp[bps * count + byte]; @@ -677,7 +677,7 @@ fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) } _TIFFfree(tmp); - cp = (uint8 *) cp0; + cp = (uint8_t *) cp0; cp += cc - stride - 1; for (count = cc; count > stride; count -= stride) REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--) @@ -685,7 +685,7 @@ fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +PredictorEncodeRow(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { TIFFPredictorState *sp = PredictorState(tif); @@ -700,11 +700,11 @@ PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } static int -PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s) +PredictorEncodeTile(TIFF* tif, uint8_t* bp0, tmsize_t cc0, uint16_t s) { static const char module[] = "PredictorEncodeTile"; TIFFPredictorState *sp = PredictorState(tif); - uint8 *working_copy; + uint8_t *working_copy; tmsize_t cc = cc0, rowsize; unsigned char* bp; int result_code; @@ -717,12 +717,12 @@ PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s) * Do predictor manipulation in a working buffer to avoid altering * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965 */ - working_copy = (uint8*) _TIFFmalloc(cc0); + working_copy = (uint8_t*) _TIFFmalloc(cc0); if( working_copy == NULL ) { TIFFErrorExt(tif->tif_clientdata, module, - "Out of memory allocating " TIFF_SSIZE_FORMAT " byte temp buffer.", - cc0 ); + "Out of memory allocating %" PRId64 " byte temp buffer.", + (int64_t) cc0 ); return 0; } memcpy( working_copy, bp0, cc0 ); @@ -756,7 +756,7 @@ static const TIFFField predictFields[] = { }; static int -PredictorVSetField(TIFF* tif, uint32 tag, va_list ap) +PredictorVSetField(TIFF* tif, uint32_t tag, va_list ap) { TIFFPredictorState *sp = PredictorState(tif); @@ -765,7 +765,7 @@ PredictorVSetField(TIFF* tif, uint32 tag, va_list ap) switch (tag) { case TIFFTAG_PREDICTOR: - sp->predictor = (uint16) va_arg(ap, uint16_vap); + sp->predictor = (uint16_t) va_arg(ap, uint16_vap); TIFFSetFieldBit(tif, FIELD_PREDICTOR); break; default: @@ -776,7 +776,7 @@ PredictorVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -PredictorVGetField(TIFF* tif, uint32 tag, va_list ap) +PredictorVGetField(TIFF* tif, uint32_t tag, va_list ap) { TIFFPredictorState *sp = PredictorState(tif); @@ -785,7 +785,7 @@ PredictorVGetField(TIFF* tif, uint32 tag, va_list ap) switch (tag) { case TIFFTAG_PREDICTOR: - *va_arg(ap, uint16*) = (uint16)sp->predictor; + *va_arg(ap, uint16_t*) = (uint16_t)sp->predictor; break; default: return (*sp->vgetparent)(tif, tag, ap); diff --git a/tiff/libtiff/tif_predict.h b/tiff/libtiff/tif_predict.h index a326b9b8..597faa16 100644 --- a/tiff/libtiff/tif_predict.h +++ b/tiff/libtiff/tif_predict.h @@ -32,7 +32,7 @@ * ``Library-private'' Support for the Predictor Tag */ -typedef int (*TIFFEncodeDecodeMethod)(TIFF* tif, uint8* buf, tmsize_t size); +typedef int (*TIFFEncodeDecodeMethod)(TIFF* tif, uint8_t* buf, tmsize_t size); /* * Codecs that want to support the Predictor tag must place diff --git a/tiff/libtiff/tif_print.c b/tiff/libtiff/tif_print.c index a0737941..347dbdaf 100644 --- a/tiff/libtiff/tif_print.c +++ b/tiff/libtiff/tif_print.c @@ -65,62 +65,43 @@ static const char * const orientNames[] = { static void _TIFFPrintField(FILE* fd, const TIFFField *fip, - uint32 value_count, void *raw_data) + uint32_t value_count, void *raw_data) { - uint32 j; + uint32_t j; fprintf(fd, " %s: ", fip->field_name); for(j = 0; j < value_count; j++) { if(fip->field_type == TIFF_BYTE) - fprintf(fd, "%u", ((uint8 *) raw_data)[j]); + fprintf(fd, "%"PRIu8, ((uint8_t *) raw_data)[j]); else if(fip->field_type == TIFF_UNDEFINED) - fprintf(fd, "0x%x", - (unsigned int) ((unsigned char *) raw_data)[j]); + fprintf(fd, "0x%"PRIx8, ((uint8_t *) raw_data)[j]); else if(fip->field_type == TIFF_SBYTE) - fprintf(fd, "%d", ((int8 *) raw_data)[j]); + fprintf(fd, "%"PRId8, ((int8_t *) raw_data)[j]); else if(fip->field_type == TIFF_SHORT) - fprintf(fd, "%u", ((uint16 *) raw_data)[j]); + fprintf(fd, "%"PRIu16, ((uint16_t *) raw_data)[j]); else if(fip->field_type == TIFF_SSHORT) - fprintf(fd, "%d", ((int16 *) raw_data)[j]); + fprintf(fd, "%"PRId16, ((int16_t *) raw_data)[j]); else if(fip->field_type == TIFF_LONG) - fprintf(fd, "%lu", - (unsigned long)((uint32 *) raw_data)[j]); + fprintf(fd, "%"PRIu32, ((uint32_t *) raw_data)[j]); else if(fip->field_type == TIFF_SLONG) - fprintf(fd, "%ld", (long)((int32 *) raw_data)[j]); + fprintf(fd, "%"PRId32, ((int32_t *) raw_data)[j]); else if(fip->field_type == TIFF_IFD) - fprintf(fd, "0x%lx", - (unsigned long)((uint32 *) raw_data)[j]); + fprintf(fd, "0x%"PRIx32, ((uint32_t *) raw_data)[j]); else if(fip->field_type == TIFF_RATIONAL || fip->field_type == TIFF_SRATIONAL || fip->field_type == TIFF_FLOAT) fprintf(fd, "%f", ((float *) raw_data)[j]); else if(fip->field_type == TIFF_LONG8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "%I64u", - (unsigned __int64)((uint64 *) raw_data)[j]); -#else - fprintf(fd, "%llu", - (unsigned long long)((uint64 *) raw_data)[j]); -#endif + fprintf(fd, "%"PRIu64, ((uint64_t *) raw_data)[j]); else if(fip->field_type == TIFF_SLONG8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "%I64d", (__int64)((int64 *) raw_data)[j]); -#else - fprintf(fd, "%lld", (long long)((int64 *) raw_data)[j]); -#endif + fprintf(fd, "%"PRId64, ((int64_t *) raw_data)[j]); else if(fip->field_type == TIFF_IFD8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "0x%I64x", - (unsigned __int64)((uint64 *) raw_data)[j]); -#else - fprintf(fd, "0x%llx", - (unsigned long long)((uint64 *) raw_data)[j]); -#endif + fprintf(fd, "0x%"PRIx64, ((uint64_t *) raw_data)[j]); else if(fip->field_type == TIFF_FLOAT) fprintf(fd, "%f", ((float *)raw_data)[j]); else if(fip->field_type == TIFF_DOUBLE) - fprintf(fd, "%f", ((double *) raw_data)[j]); + fprintf(fd, "%lf", ((double *) raw_data)[j]); else if(fip->field_type == TIFF_ASCII) { fprintf(fd, "%s", (char *) raw_data); break; @@ -138,8 +119,8 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip, } static int -_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, - uint32 value_count, void *raw_data) +_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32_t tag, + uint32_t value_count, void *raw_data) { (void) tif; @@ -153,14 +134,14 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, case TIFFTAG_INKSET: if (value_count == 2 && fip->field_type == TIFF_SHORT) { fprintf(fd, " Ink Set: "); - switch (*((uint16*)raw_data)) { + switch (*((uint16_t*)raw_data)) { case INKSET_CMYK: fprintf(fd, "CMYK\n"); break; default: - fprintf(fd, "%u (0x%x)\n", - *((uint16*)raw_data), - *((uint16*)raw_data)); + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", + *((uint16_t*)raw_data), + *((uint16_t*)raw_data)); break; } return 1; @@ -169,8 +150,8 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, case TIFFTAG_DOTRANGE: if (value_count == 2 && fip->field_type == TIFF_SHORT) { - fprintf(fd, " Dot Range: %u-%u\n", - ((uint16*)raw_data)[0], ((uint16*)raw_data)[1]); + fprintf(fd, " Dot Range: %"PRIu16"-%"PRIu16"\n", + ((uint16_t*)raw_data)[0], ((uint16_t*)raw_data)[1]); return 1; } return 0; @@ -185,7 +166,7 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, case TIFFTAG_XMLPACKET: { - uint32 i; + uint32_t i; fprintf(fd, " XMLPacket (XMP Metadata):\n" ); for(i = 0; i < value_count; i++) @@ -199,18 +180,18 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, * defined as array of LONG values. */ fprintf(fd, - " RichTIFFIPTC Data: <present>, %lu bytes\n", - (unsigned long) value_count * 4); + " RichTIFFIPTC Data: <present>, %"PRIu32" bytes\n", + value_count * 4u); return 1; case TIFFTAG_PHOTOSHOP: - fprintf(fd, " Photoshop Data: <present>, %lu bytes\n", - (unsigned long) value_count); + fprintf(fd, " Photoshop Data: <present>, %"PRIu32" bytes\n", + value_count); return 1; case TIFFTAG_ICCPROFILE: - fprintf(fd, " ICC Profile: <present>, %lu bytes\n", - (unsigned long) value_count); + fprintf(fd, " ICC Profile: <present>, %"PRIu32" bytes\n", + value_count); return 1; case TIFFTAG_STONITS: @@ -237,15 +218,9 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) char *sep; long l, n; -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "TIFF Directory at offset 0x%I64x (%I64u)\n", - (unsigned __int64) tif->tif_diroff, - (unsigned __int64) tif->tif_diroff); -#else - fprintf(fd, "TIFF Directory at offset 0x%llx (%llu)\n", - (unsigned long long) tif->tif_diroff, - (unsigned long long) tif->tif_diroff); -#endif + fprintf(fd, "TIFF Directory at offset 0x%"PRIu64" (%"PRIx64")\n", + tif->tif_diroff, + tif->tif_diroff); if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { fprintf(fd, " Subfile Type:"); sep = " "; @@ -259,23 +234,23 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } if (td->td_subfiletype & FILETYPE_MASK) fprintf(fd, "%stransparency mask", sep); - fprintf(fd, " (%lu = 0x%lx)\n", - (unsigned long) td->td_subfiletype, (long) td->td_subfiletype); + fprintf(fd, " (%"PRIu32" = 0x%"PRIx32")\n", + td->td_subfiletype, td->td_subfiletype); } if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { - fprintf(fd, " Image Width: %lu Image Length: %lu", - (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength); + fprintf(fd, " Image Width: %"PRIu32" Image Length: %"PRIu32, + td->td_imagewidth, td->td_imagelength); if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) - fprintf(fd, " Image Depth: %lu", - (unsigned long) td->td_imagedepth); + fprintf(fd, " Image Depth: %"PRIu32, + td->td_imagedepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) { - fprintf(fd, " Tile Width: %lu Tile Length: %lu", - (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength); + fprintf(fd, " Tile Width: %"PRIu32" Tile Length: %"PRIu32, + td->td_tilewidth, td->td_tilelength); if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) - fprintf(fd, " Tile Depth: %lu", - (unsigned long) td->td_tiledepth); + fprintf(fd, " Tile Depth: %"PRIu32, + td->td_tiledepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { @@ -293,7 +268,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " pixels/cm"); break; default: - fprintf(fd, " (unit %u = 0x%x)", + fprintf(fd, " (unit %"PRIu16" = 0x%"PRIx16")", td->td_resolutionunit, td->td_resolutionunit); break; @@ -305,7 +280,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " Position: %g, %g\n", td->td_xposition, td->td_yposition); if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) - fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample); + fprintf(fd, " Bits/Sample: %"PRIu16"\n", td->td_bitspersample); if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { fprintf(fd, " Sample Format: "); switch (td->td_sampleformat) { @@ -328,7 +303,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "complex IEEE floating point\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_sampleformat, td->td_sampleformat); break; } @@ -339,7 +314,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if (c) fprintf(fd, "%s\n", c->name); else - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_compression, td->td_compression); } if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { @@ -355,15 +330,15 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "CIE Log2(L) (u',v')\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_photometric, td->td_photometric); break; } } } if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) { - uint16 i; - fprintf(fd, " Extra Samples: %u<", td->td_extrasamples); + uint16_t i; + fprintf(fd, " Extra Samples: %"PRIu16"<", td->td_extrasamples); sep = ""; for (i = 0; i < td->td_extrasamples; i++) { switch (td->td_sampleinfo[i]) { @@ -377,7 +352,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "%sunassoc-alpha", sep); break; default: - fprintf(fd, "%s%u (0x%x)", sep, + fprintf(fd, "%s%"PRIu16" (0x%"PRIx16")", sep, td->td_sampleinfo[i], td->td_sampleinfo[i]); break; } @@ -387,7 +362,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } if (TIFFFieldSet(tif,FIELD_INKNAMES)) { char* cp; - uint16 i; + uint16_t i; fprintf(fd, " Ink Names: "); i = td->td_samplesperpixel; sep = ""; @@ -415,7 +390,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "error diffused\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_threshholding, td->td_threshholding); break; } @@ -430,14 +405,14 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "lsb-to-msb\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_fillorder, td->td_fillorder); break; } } if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) { - fprintf(fd, " YCbCr Subsampling: %u, %u\n", + fprintf(fd, " YCbCr Subsampling: %"PRIu16", %"PRIu16"\n", td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1] ); } if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { @@ -450,35 +425,35 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "cosited\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_ycbcrpositioning, td->td_ycbcrpositioning); break; } } if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) - fprintf(fd, " Halftone Hints: light %u dark %u\n", + fprintf(fd, " Halftone Hints: light %"PRIu16" dark %"PRIu16"\n", td->td_halftonehints[0], td->td_halftonehints[1]); if (TIFFFieldSet(tif,FIELD_ORIENTATION)) { fprintf(fd, " Orientation: "); if (td->td_orientation < NORIENTNAMES) fprintf(fd, "%s\n", orientNames[td->td_orientation]); else - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_orientation, td->td_orientation); } if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) - fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); + fprintf(fd, " Samples/Pixel: %"PRIx16"\n", td->td_samplesperpixel); if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { fprintf(fd, " Rows/Strip: "); - if (td->td_rowsperstrip == (uint32) -1) + if (td->td_rowsperstrip == (uint32_t) -1) fprintf(fd, "(infinite)\n"); else - fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip); + fprintf(fd, "%"PRIu32"\n", td->td_rowsperstrip); } if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) - fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); + fprintf(fd, " Min Sample Value: %"PRIu16"\n", td->td_minsamplevalue); if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) - fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); + fprintf(fd, " Max Sample Value: %"PRIu16"\n", td->td_maxsamplevalue); if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) { int i; int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; @@ -505,13 +480,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "separate image planes\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_planarconfig, td->td_planarconfig); break; } } if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) - fprintf(fd, " Page Number: %u-%u\n", + fprintf(fd, " Page Number: %"PRIu16"-%"PRIu16"\n", td->td_pagenumber[0], td->td_pagenumber[1]); if (TIFFFieldSet(tif,FIELD_COLORMAP)) { fprintf(fd, " Color Map: "); @@ -519,7 +494,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "\n"); n = 1L<<td->td_bitspersample; for (l = 0; l < n; l++) - fprintf(fd, " %5ld: %5u %5u %5u\n", + fprintf(fd, " %5ld: %5"PRIu16" %5"PRIu16" %5"PRIu16"\n", l, td->td_colormap[0][l], td->td_colormap[1][l], @@ -541,11 +516,11 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "\n"); n = 1L<<td->td_bitspersample; for (l = 0; l < n; l++) { - uint16 i; - fprintf(fd, " %2ld: %5u", + uint16_t i; + fprintf(fd, " %2ld: %5"PRIu16, l, td->td_transferfunction[0][l]); for (i = 1; i < td->td_samplesperpixel - td->td_extrasamples && i < 3; i++) - fprintf(fd, " %5u", + fprintf(fd, " %5"PRIu16, td->td_transferfunction[i][l]); fputc('\n', fd); } @@ -553,16 +528,11 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "(present)\n"); } if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) { - uint16 i; + uint16_t i; fprintf(fd, " SubIFD Offsets:"); for (i = 0; i < td->td_nsubifd; i++) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, " %5I64u", - (unsigned __int64) td->td_subifd[i]); -#else - fprintf(fd, " %5llu", - (unsigned long long) td->td_subifd[i]); -#endif + fprintf(fd, " %5"PRIu64, + td->td_subifd[i]); fputc('\n', fd); } @@ -575,9 +545,9 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) count = (short) TIFFGetTagListCount(tif); for(i = 0; i < count; i++) { - uint32 tag = TIFFGetTagListEntry(tif, i); + uint32_t tag = TIFFGetTagListEntry(tif, i); const TIFFField *fip; - uint32 value_count; + uint32_t value_count; int mem_alloc = 0; void *raw_data; @@ -590,7 +560,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) continue; } else if (fip->field_readcount == TIFF_VARIABLE ) { - uint16 small_value_count; + uint16_t small_value_count; if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1) continue; value_count = small_value_count; @@ -613,7 +583,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) handled this way ... likely best if we move it into the directory structure with an explicit field in libtiff 4.1 and assign it a FIELD_ value */ - static uint16 dotrange[2]; + static uint16_t dotrange[2]; raw_data = dotrange; TIFFGetField(tif, tag, dotrange+0, dotrange+1); } else if (fip->field_type == TIFF_ASCII @@ -654,23 +624,16 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if ((flags & TIFFPRINT_STRIPS) && TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { - uint32 s; + uint32_t s; - fprintf(fd, " %lu %s:\n", - (unsigned long) td->td_nstrips, + fprintf(fd, " %"PRIu32" %s:\n", + td->td_nstrips, isTiled(tif) ? "Tiles" : "Strips"); for (s = 0; s < td->td_nstrips; s++) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, " %3lu: [%8I64u, %8I64u]\n", - (unsigned long) s, - (unsigned __int64) TIFFGetStrileOffset(tif, s), - (unsigned __int64) TIFFGetStrileByteCount(tif, s)); -#else - fprintf(fd, " %3lu: [%8llu, %8llu]\n", - (unsigned long) s, - (unsigned long long) TIFFGetStrileOffset(tif, s), - (unsigned long long) TIFFGetStrileByteCount(tif, s)); -#endif + fprintf(fd, " %3"PRIu32": [%8"PRIu64", %8"PRIu64"]\n", + s, + TIFFGetStrileOffset(tif, s), + TIFFGetStrileByteCount(tif, s)); } } diff --git a/tiff/libtiff/tif_read.c b/tiff/libtiff/tif_read.c index c4c868b1..a4c60b4f 100644 --- a/tiff/libtiff/tif_read.c +++ b/tiff/libtiff/tif_read.c @@ -29,31 +29,31 @@ #include "tiffiop.h" #include <stdio.h> -int TIFFFillStrip(TIFF* tif, uint32 strip); -int TIFFFillTile(TIFF* tif, uint32 tile); -static int TIFFStartStrip(TIFF* tif, uint32 strip); -static int TIFFStartTile(TIFF* tif, uint32 tile); +int TIFFFillStrip(TIFF* tif, uint32_t strip); +int TIFFFillTile(TIFF* tif, uint32_t tile); +static int TIFFStartStrip(TIFF* tif, uint32_t strip); +static int TIFFStartTile(TIFF* tif, uint32_t tile); static int TIFFCheckRead(TIFF*, int); static tmsize_t -TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,const char* module); +TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, const char* module); static tmsize_t -TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module); +TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* module); -#define NOSTRIP ((uint32)(-1)) /* undefined state */ -#define NOTILE ((uint32)(-1)) /* undefined state */ +#define NOSTRIP ((uint32_t)(-1)) /* undefined state */ +#define NOTILE ((uint32_t)(-1)) /* undefined state */ #define INITIAL_THRESHOLD (1024 * 1024) #define THRESHOLD_MULTIPLIER 10 #define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD) -#define TIFF_INT64_MAX ((((int64)0x7FFFFFFF) << 32) | 0xFFFFFFFF) +#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF) /* Read 'size' bytes in tif_rawdata buffer starting at offset 'rawdata_offset' * Returns 1 in case of success, 0 otherwise. */ -static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, - tmsize_t rawdata_offset, - int is_strip, uint32 strip_or_tile, - const char* module ) +static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size, + tmsize_t rawdata_offset, + int is_strip, uint32_t strip_or_tile, + const char* module ) { #if SIZEOF_SIZE_T == 8 tmsize_t threshold = INITIAL_THRESHOLD; @@ -66,8 +66,8 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, /* file size */ if( size > 1000 * 1000 * 1000 ) { - uint64 filesize = TIFFGetFileSize(tif); - if( (uint64)size >= filesize ) + uint64_t filesize = TIFFGetFileSize(tif); + if((uint64_t)size >= filesize ) { TIFFErrorExt(tif->tif_clientdata, module, "Chunk size requested is larger than file size."); @@ -95,22 +95,22 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, } #endif if (already_read + to_read + rawdata_offset > tif->tif_rawdatasize) { - uint8* new_rawdata; + uint8_t* new_rawdata; assert((tif->tif_flags & TIFF_MYBUFFER) != 0); tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64( - (uint64)already_read + to_read + rawdata_offset, 1024); + (uint64_t)already_read + to_read + rawdata_offset, 1024); if (tif->tif_rawdatasize==0) { TIFFErrorExt(tif->tif_clientdata, module, "Invalid buffer size"); return 0; } - new_rawdata = (uint8*) _TIFFrealloc( + new_rawdata = (uint8_t*) _TIFFrealloc( tif->tif_rawdata, tif->tif_rawdatasize); if( new_rawdata == 0 ) { TIFFErrorExt(tif->tif_clientdata, module, - "No space for data buffer at scanline %lu", - (unsigned long) tif->tif_row); + "No space for data buffer at scanline %"PRIu32, + tif->tif_row); _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = 0; tif->tif_rawdatasize = 0; @@ -130,49 +130,26 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, if (bytes_read != to_read) { memset( tif->tif_rawdata + rawdata_offset + already_read, 0, tif->tif_rawdatasize - rawdata_offset - already_read ); -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) if( is_strip ) { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %I64u bytes, " - "expected %I64u", - (unsigned long) tif->tif_row, - (unsigned __int64) already_read, - (unsigned __int64) size); + "Read error at scanline %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, " + "expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + already_read, + size); } else { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu, tile %lu; " - "got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile, - (unsigned __int64) already_read, - (unsigned __int64) size); + "Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; " + "got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT"", + tif->tif_row, + tif->tif_col, + strip_or_tile, + already_read, + size); } -#else - if( is_strip ) - { - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %llu bytes, " - "expected %llu", - (unsigned long) tif->tif_row, - (unsigned long long) already_read, - (unsigned long long) size); - } - else - { - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu, tile %lu; " - "got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile, - (unsigned long long) already_read, - (unsigned long long) size); - } -#endif return 0; } } @@ -186,7 +163,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) static const char module[] = "TIFFFillStripPartial"; register TIFFDirectory *td = &tif->tif_dir; tmsize_t unused_data; - uint64 read_offset; + uint64_t read_offset; tmsize_t to_read; tmsize_t read_ahead_mod; /* tmsize_t bytecountm; */ @@ -211,8 +188,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) tif->tif_curstrip = NOSTRIP; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold part of strip %lu", - (unsigned long) strip); + "Data buffer too small to hold part of strip %d", + strip); return (0); } } @@ -246,8 +223,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) if (!SeekOK(tif, read_offset)) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, (unsigned long) strip); + "Seek error at scanline %"PRIu32", strip %d", + tif->tif_row, strip); return 0; } @@ -258,8 +235,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) to_read = read_ahead_mod - unused_data; else to_read = tif->tif_rawdatasize - unused_data; - if( (uint64) to_read > TIFFGetStrileByteCount(tif, strip) - - tif->tif_rawdataoff - tif->tif_rawdataloaded ) + if((uint64_t) to_read > TIFFGetStrileByteCount(tif, strip) + - tif->tif_rawdataoff - tif->tif_rawdataloaded ) { to_read = (tmsize_t) TIFFGetStrileByteCount(tif, strip) - tif->tif_rawdataoff - tif->tif_rawdataloaded; @@ -300,7 +277,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) /* For JPEG, if there are multiple scans (can generally be known */ /* with the read_ahead used), we need to read the whole strip */ if( tif->tif_dir.td_compression==COMPRESSION_JPEG && - (uint64)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip) ) + (uint64_t)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip) ) { if( TIFFJPEGIsFullStripRequired(tif) ) { @@ -326,10 +303,10 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) * strips. */ static int -TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) +TIFFSeek(TIFF* tif, uint32_t row, uint16_t sample ) { register TIFFDirectory *td = &tif->tif_dir; - uint32 strip; + uint32_t strip; int whole_strip; tmsize_t read_ahead = 0; @@ -338,19 +315,19 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) */ if (row >= td->td_imagelength) { /* out of range */ TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Row out of range, max %lu", - (unsigned long) row, - (unsigned long) td->td_imagelength); + "%"PRIu32": Row out of range, max %"PRIu32"", + row, + td->td_imagelength); return (0); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Sample out of range, max %lu", - (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + "%"PRIu16": Sample out of range, max %"PRIu16"", + sample, td->td_samplesperpixel); return (0); } - strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip; + strip = (uint32_t)sample * td->td_stripsperimage + row / td->td_rowsperstrip; } else strip = row / td->td_rowsperstrip; @@ -412,7 +389,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) else if( !whole_strip ) { if( ((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < read_ahead - && (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < TIFFGetStrileByteCount(tif, strip) ) + && (uint64_t) tif->tif_rawdataoff + tif->tif_rawdataloaded < TIFFGetStrileByteCount(tif, strip) ) { if( !TIFFFillStripPartial(tif,strip,read_ahead,0) ) return 0; @@ -457,7 +434,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) } int -TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) +TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample) { int e; @@ -468,13 +445,13 @@ TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) * Decompress desired row into user buffer. */ e = (*tif->tif_decoderow) - (tif, (uint8*) buf, tif->tif_scanlinesize, sample); + (tif, (uint8_t*) buf, tif->tif_scanlinesize, sample); /* we are now poised at the beginning of the next row */ tif->tif_row = row + 1; if (e) - (*tif->tif_postdecode)(tif, (uint8*) buf, + (*tif->tif_postdecode)(tif, (uint8_t*) buf, tif->tif_scanlinesize); } return (e > 0 ? 1 : -1); @@ -485,22 +462,22 @@ TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) * rows in the strip (check for truncated last strip on any * of the separations). */ -static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16* pplane) +static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32_t strip, uint16_t* pplane) { static const char module[] = "TIFFReadEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; - uint32 rowsperstrip; - uint32 stripsperplane; - uint32 stripinplane; - uint32 rows; + uint32_t rowsperstrip; + uint32_t stripsperplane; + uint32_t stripinplane; + uint32_t rows; tmsize_t stripsize; if (!TIFFCheckRead(tif,0)) return((tmsize_t)(-1)); if (strip>=td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata,module, - "%lu: Strip out of range, max %lu",(unsigned long)strip, - (unsigned long)td->td_nstrips); + "%"PRIu32": Strip out of range, max %"PRIu32, strip, + td->td_nstrips); return((tmsize_t)(-1)); } @@ -509,7 +486,7 @@ static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16 rowsperstrip=td->td_imagelength; stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip); stripinplane=(strip%stripsperplane); - if( pplane ) *pplane=(uint16)(strip/stripsperplane); + if( pplane ) *pplane=(uint16_t)(strip / stripsperplane); rows=td->td_imagelength-stripinplane*rowsperstrip; if (rows>rowsperstrip) rows=rowsperstrip; @@ -524,12 +501,12 @@ static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16 * amount into the user-supplied buffer. */ tmsize_t -TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) +TIFFReadEncodedStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size) { static const char module[] = "TIFFReadEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; tmsize_t stripsize; - uint16 plane; + uint16_t plane; stripsize=TIFFReadEncodedStripGetStripSize(tif, strip, &plane); if (stripsize==((tmsize_t)(-1))) @@ -569,12 +546,12 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) * * calls regular TIFFReadEncodedStrip() if *buf != NULL */ tmsize_t -_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip, +_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32_t strip, void **buf, tmsize_t bufsizetoalloc, tmsize_t size_to_read) { tmsize_t this_stripsize; - uint16 plane; + uint16_t plane; if( *buf != NULL ) { @@ -606,8 +583,8 @@ _TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip, } static tmsize_t -TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, - const char* module) +TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, + const char* module) { assert((tif->tif_flags&TIFF_NOREADRAW)==0); if (!isMapped(tif)) { @@ -615,32 +592,24 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip))) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, (unsigned long) strip); + "Seek error at scanline %"PRIu32", strip %"PRIu32, + tif->tif_row, strip); return ((tmsize_t)(-1)); } cc = TIFFReadFile(tif, buf, size); if (cc != size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned __int64) cc, - (unsigned __int64) size); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long long) cc, - (unsigned long long) size); -#endif + "Read error at scanline %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + cc, + size); return ((tmsize_t)(-1)); } } else { tmsize_t ma = 0; tmsize_t n; - if ((TIFFGetStrileOffset(tif, strip) > (uint64)TIFF_TMSIZE_T_MAX)|| - ((ma=(tmsize_t)TIFFGetStrileOffset(tif, strip))>tif->tif_size)) + if ((TIFFGetStrileOffset(tif, strip) > (uint64_t)TIFF_TMSIZE_T_MAX) || + ((ma=(tmsize_t)TIFFGetStrileOffset(tif, strip))>tif->tif_size)) { n=0; } @@ -657,21 +626,12 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, n=size; } if (n!=size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu, strip %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) strip, - (unsigned __int64) n, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu, strip %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) strip, - (unsigned long long) n, - (unsigned long long) size); -#endif + "Read error at scanline %"PRIu32", strip %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + strip, + n, + size); return ((tmsize_t)(-1)); } _TIFFmemcpy(buf, tif->tif_base + ma, @@ -681,7 +641,7 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, } static tmsize_t -TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip, +TIFFReadRawStripOrTile2(TIFF* tif, uint32_t strip_or_tile, int is_strip, tmsize_t size, const char* module) { assert( !isMapped(tif) ); @@ -691,17 +651,17 @@ TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip, if( is_strip ) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, - (unsigned long) strip_or_tile); + "Seek error at scanline %"PRIu32", strip %"PRIu32, + tif->tif_row, + strip_or_tile); } else { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at row %lu, col %lu, tile %lu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile); + "Seek error at row %"PRIu32", col %"PRIu32", tile %"PRIu32, + tif->tif_row, + tif->tif_col, + strip_or_tile); } return ((tmsize_t)(-1)); } @@ -719,20 +679,20 @@ TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip, * Read a strip of data from the file. */ tmsize_t -TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) +TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size) { static const char module[] = "TIFFReadRawStrip"; TIFFDirectory *td = &tif->tif_dir; - uint64 bytecount64; + uint64_t bytecount64; tmsize_t bytecountm; if (!TIFFCheckRead(tif, 0)) return ((tmsize_t)(-1)); if (strip >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Strip out of range, max %lu", - (unsigned long) strip, - (unsigned long) td->td_nstrips); + "%"PRIu32": Strip out of range, max %"PRIu32, + strip, + td->td_nstrips); return ((tmsize_t)(-1)); } if (tif->tif_flags&TIFF_NOREADRAW) @@ -742,7 +702,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) return ((tmsize_t)(-1)); } bytecount64 = TIFFGetStrileByteCount(tif, strip); - if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64) + if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64) bytecountm = size; else bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module); @@ -753,7 +713,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) } TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static uint64 NoSanitizeSubUInt64(uint64 a, uint64 b) +static uint64_t NoSanitizeSubUInt64(uint64_t a, uint64_t b) { return a - b; } @@ -763,26 +723,19 @@ static uint64 NoSanitizeSubUInt64(uint64 a, uint64 b) * expanded, as necessary, to hold the strip's data. */ int -TIFFFillStrip(TIFF* tif, uint32 strip) +TIFFFillStrip(TIFF* tif, uint32_t strip) { static const char module[] = "TIFFFillStrip"; TIFFDirectory *td = &tif->tif_dir; if ((tif->tif_flags&TIFF_NOREADRAW)==0) { - uint64 bytecount = TIFFGetStrileByteCount(tif, strip); - if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Invalid strip byte count %I64u, strip %lu", - (unsigned __int64) bytecount, - (unsigned long) strip); -#else + uint64_t bytecount = TIFFGetStrileByteCount(tif, strip); + if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) { TIFFErrorExt(tif->tif_clientdata, module, - "Invalid strip byte count %llu, strip %lu", - (unsigned long long) bytecount, - (unsigned long) strip); -#endif + "Invalid strip byte count %"PRIu64", strip %"PRIu32, + bytecount, + strip); return (0); } @@ -795,24 +748,16 @@ TIFFFillStrip(TIFF* tif, uint32 strip) /* Hopefully they are safe enough for all codecs */ tmsize_t stripsize = TIFFStripSize(tif); if( stripsize != 0 && - (bytecount - 4096) / 10 > (uint64)stripsize ) + (bytecount - 4096) / 10 > (uint64_t)stripsize ) { - uint64 newbytecount = (uint64)stripsize * 10 + 4096; - if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX ) + uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096; + if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFWarningExt(tif->tif_clientdata, module, - "Too large strip byte count %I64u, strip %lu. Limiting to %I64u", - (unsigned __int64) bytecount, - (unsigned long) strip, - (unsigned __int64) newbytecount); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Too large strip byte count %llu, strip %lu. Limiting to %llu", - (unsigned long long) bytecount, - (unsigned long) strip, - (unsigned long long) newbytecount); -#endif + "Too large strip byte count %"PRIu64", strip %"PRIu32". Limiting to %"PRIu64, + bytecount, + strip, + newbytecount); bytecount = newbytecount; } } @@ -828,30 +773,20 @@ TIFFFillStrip(TIFF* tif, uint32 strip) * comparison (which can overflow) we do the following * two comparisons: */ - if (bytecount > (uint64)tif->tif_size || - TIFFGetStrileOffset(tif, strip) > (uint64)tif->tif_size - bytecount) { + if (bytecount > (uint64_t)tif->tif_size || + TIFFGetStrileOffset(tif, strip) > (uint64_t)tif->tif_size - bytecount) { /* * This error message might seem strange, but * it's what would happen if a read were done * instead. */ -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - - "Read error on strip %lu; " - "got %I64u bytes, expected %I64u", - (unsigned long) strip, - (unsigned __int64) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), - (unsigned __int64) bytecount); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Read error on strip %lu; " - "got %llu bytes, expected %llu", - (unsigned long) strip, - (unsigned long long) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), - (unsigned long long) bytecount); -#endif + "Read error on strip %"PRIu32"; " + "got %"PRIu64" bytes, expected %"PRIu64, + strip, + NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), + bytecount); tif->tif_curstrip = NOSTRIP; return (0); } @@ -897,7 +832,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip) */ tmsize_t bytecountm; bytecountm=(tmsize_t)bytecount; - if ((uint64)bytecountm!=bytecount) + if ((uint64_t)bytecountm != bytecount) { TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); return(0); @@ -906,8 +841,8 @@ TIFFFillStrip(TIFF* tif, uint32 strip) tif->tif_curstrip = NOSTRIP; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold strip %lu", - (unsigned long) strip); + "Data buffer too small to hold strip %"PRIu32, + strip); return (0); } } @@ -962,7 +897,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip) * tile is selected by the (x,y,z,s) coordinates. */ tmsize_t -TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) +TIFFReadTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) return ((tmsize_t)(-1)); @@ -975,7 +910,7 @@ TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) * amount into the user-supplied buffer. */ tmsize_t -TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) +TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size) { static const char module[] = "TIFFReadEncodedTile"; TIFFDirectory *td = &tif->tif_dir; @@ -985,8 +920,8 @@ TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } @@ -1012,8 +947,8 @@ TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) else if (size > tilesize) size = tilesize; if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, - (uint8*) buf, size, (uint16)(tile/td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (uint8*) buf, size); + (uint8_t*) buf, size, (uint16_t)(tile / td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (uint8_t*) buf, size); return (size); } else return ((tmsize_t)(-1)); @@ -1028,7 +963,7 @@ TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) tmsize_t _TIFFReadTileAndAllocBuffer(TIFF* tif, void **buf, tmsize_t bufsizetoalloc, - uint32 x, uint32 y, uint32 z, uint16 s) + uint32_t x, uint32_t y, uint32_t z, uint16_t s) { if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) return ((tmsize_t)(-1)); @@ -1045,9 +980,9 @@ _TIFFReadTileAndAllocBuffer(TIFF* tif, * * calls regular TIFFReadEncodedTile() if *buf != NULL */ tmsize_t -_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, - void **buf, tmsize_t bufsizetoalloc, - tmsize_t size_to_read) +_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32_t tile, + void **buf, tmsize_t bufsizetoalloc, + tmsize_t size_to_read) { static const char module[] = "_TIFFReadEncodedTileAndAllocBuffer"; TIFFDirectory *td = &tif->tif_dir; @@ -1062,8 +997,8 @@ _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } @@ -1083,15 +1018,15 @@ _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, else if (size_to_read > tilesize) size_to_read = tilesize; if( (*tif->tif_decodetile)(tif, - (uint8*) *buf, size_to_read, (uint16)(tile/td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (uint8*) *buf, size_to_read); + (uint8_t*) *buf, size_to_read, (uint16_t)(tile / td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (uint8_t*) *buf, size_to_read); return (size_to_read); } else return ((tmsize_t)(-1)); } static tmsize_t -TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module) +TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* module) { assert((tif->tif_flags&TIFF_NOREADRAW)==0); if (!isMapped(tif)) { @@ -1099,29 +1034,20 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m if (!SeekOK(tif, TIFFGetStrileOffset(tif, tile))) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at row %lu, col %lu, tile %lu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile); + "Seek error at row %"PRIu32", col %"PRIu32", tile %"PRIu32, + tif->tif_row, + tif->tif_col, + tile); return ((tmsize_t)(-1)); } cc = TIFFReadFile(tif, buf, size); if (cc != size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned __int64) cc, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long long) cc, - (unsigned long long) size); -#endif + "Read error at row %"PRIu32", col %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + tif->tif_col, + cc, + size); return ((tmsize_t)(-1)); } } else { @@ -1129,30 +1055,20 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m tmsize_t n; ma=(tmsize_t)TIFFGetStrileOffset(tif, tile); mb=ma+size; - if ((TIFFGetStrileOffset(tif, tile) > (uint64)TIFF_TMSIZE_T_MAX)||(ma>tif->tif_size)) + if ((TIFFGetStrileOffset(tif, tile) > (uint64_t)TIFF_TMSIZE_T_MAX) || (ma > tif->tif_size)) n=0; else if ((mb<ma)||(mb<size)||(mb>tif->tif_size)) n=tif->tif_size-ma; else n=size; if (n!=size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, -"Read error at row %lu, col %lu, tile %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile, - (unsigned __int64) n, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, -"Read error at row %lu, col %lu, tile %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile, - (unsigned long long) n, - (unsigned long long) size); -#endif +"Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + tif->tif_col, + tile, + n, + size); return ((tmsize_t)(-1)); } _TIFFmemcpy(buf, tif->tif_base + ma, size); @@ -1164,19 +1080,19 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m * Read a tile of data from the file. */ tmsize_t -TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) +TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size) { static const char module[] = "TIFFReadRawTile"; TIFFDirectory *td = &tif->tif_dir; - uint64 bytecount64; + uint64_t bytecount64; tmsize_t bytecountm; if (!TIFFCheckRead(tif, 1)) return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } if (tif->tif_flags&TIFF_NOREADRAW) @@ -1186,7 +1102,7 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) return ((tmsize_t)(-1)); } bytecount64 = TIFFGetStrileByteCount(tif, tile); - if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64) + if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64) bytecountm = size; else bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module); @@ -1201,26 +1117,19 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) * expanded, as necessary, to hold the tile's data. */ int -TIFFFillTile(TIFF* tif, uint32 tile) +TIFFFillTile(TIFF* tif, uint32_t tile) { static const char module[] = "TIFFFillTile"; TIFFDirectory *td = &tif->tif_dir; if ((tif->tif_flags&TIFF_NOREADRAW)==0) { - uint64 bytecount = TIFFGetStrileByteCount(tif, tile); - if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + uint64_t bytecount = TIFFGetStrileByteCount(tif, tile); + if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) { TIFFErrorExt(tif->tif_clientdata, module, - "%I64u: Invalid tile byte count, tile %lu", - (unsigned __int64) bytecount, - (unsigned long) tile); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "%llu: Invalid tile byte count, tile %lu", - (unsigned long long) bytecount, - (unsigned long) tile); -#endif + "%"PRIu64": Invalid tile byte count, tile %"PRIu32, + bytecount, + tile); return (0); } @@ -1233,24 +1142,16 @@ TIFFFillTile(TIFF* tif, uint32 tile) /* Hopefully they are safe enough for all codecs */ tmsize_t stripsize = TIFFTileSize(tif); if( stripsize != 0 && - (bytecount - 4096) / 10 > (uint64)stripsize ) + (bytecount - 4096) / 10 > (uint64_t)stripsize ) { - uint64 newbytecount = (uint64)stripsize * 10 + 4096; - if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX ) + uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096; + if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFWarningExt(tif->tif_clientdata, module, - "Too large tile byte count %I64u, tile %lu. Limiting to %I64u", - (unsigned __int64) bytecount, - (unsigned long) tile, - (unsigned __int64) newbytecount); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Too large tile byte count %llu, tile %lu. Limiting to %llu", - (unsigned long long) bytecount, - (unsigned long) tile, - (unsigned long long) newbytecount); -#endif + "Too large tile byte count %"PRIu64", tile %"PRIu32". Limiting to %"PRIu64, + bytecount, + tile, + newbytecount); bytecount = newbytecount; } } @@ -1266,8 +1167,8 @@ TIFFFillTile(TIFF* tif, uint32 tile) * comparison (which can overflow) we do the following * two comparisons: */ - if (bytecount > (uint64)tif->tif_size || - TIFFGetStrileOffset(tif, tile) > (uint64)tif->tif_size - bytecount) { + if (bytecount > (uint64_t)tif->tif_size || + TIFFGetStrileOffset(tif, tile) > (uint64_t)tif->tif_size - bytecount) { tif->tif_curtile = NOTILE; return (0); } @@ -1308,7 +1209,7 @@ TIFFFillTile(TIFF* tif, uint32 tile) */ tmsize_t bytecountm; bytecountm=(tmsize_t)bytecount; - if ((uint64)bytecountm!=bytecount) + if ((uint64_t)bytecountm != bytecount) { TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); return(0); @@ -1317,8 +1218,8 @@ TIFFFillTile(TIFF* tif, uint32 tile) tif->tif_curtile = NOTILE; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold tile %lu", - (unsigned long) tile); + "Data buffer too small to hold tile %"PRIu32, + tile); return (0); } } @@ -1390,10 +1291,10 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) } if (bp) { tif->tif_rawdatasize = size; - tif->tif_rawdata = (uint8*) bp; + tif->tif_rawdata = (uint8_t*) bp; tif->tif_flags &= ~TIFF_MYBUFFER; } else { - tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024); + tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64_t)size, 1024); if (tif->tif_rawdatasize==0) { TIFFErrorExt(tif->tif_clientdata, module, "Invalid buffer size"); @@ -1401,13 +1302,13 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) } /* Initialize to zero to avoid uninitialized buffers in case of */ /* short reads (http://bugzilla.maptools.org/show_bug.cgi?id=2651) */ - tif->tif_rawdata = (uint8*) _TIFFcalloc(1, tif->tif_rawdatasize); + tif->tif_rawdata = (uint8_t*) _TIFFcalloc(1, tif->tif_rawdatasize); tif->tif_flags |= TIFF_MYBUFFER; } if (tif->tif_rawdata == NULL) { TIFFErrorExt(tif->tif_clientdata, module, - "No space for data buffer at scanline %lu", - (unsigned long) tif->tif_row); + "No space for data buffer at scanline %"PRIu32, + tif->tif_row); tif->tif_rawdatasize = 0; return (0); } @@ -1419,7 +1320,7 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) * strip has just been read in. */ static int -TIFFStartStrip(TIFF* tif, uint32 strip) +TIFFStartStrip(TIFF* tif, uint32_t strip) { TIFFDirectory *td = &tif->tif_dir; @@ -1446,7 +1347,7 @@ TIFFStartStrip(TIFF* tif, uint32 strip) tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip); } if ((*tif->tif_predecode)(tif, - (uint16)(strip / td->td_stripsperimage)) == 0 ) { + (uint16_t)(strip / td->td_stripsperimage)) == 0 ) { /* Needed for example for scanline access, if tif_predecode */ /* fails, and we try to read the same strip again. Without invalidating */ /* tif_curstrip, we'd call tif_decoderow() on a possibly invalid */ @@ -1462,11 +1363,11 @@ TIFFStartStrip(TIFF* tif, uint32 strip) * tile has just been read in. */ static int -TIFFStartTile(TIFF* tif, uint32 tile) +TIFFStartTile(TIFF* tif, uint32_t tile) { static const char module[] = "TIFFStartTile"; TIFFDirectory *td = &tif->tif_dir; - uint32 howmany32; + uint32_t howmany32; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupdecode)(tif)) @@ -1501,7 +1402,7 @@ TIFFStartTile(TIFF* tif, uint32 tile) tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile); } return ((*tif->tif_predecode)(tif, - (uint16)(tile/td->td_stripsperimage))); + (uint16_t)(tile / td->td_stripsperimage))); } static int @@ -1529,14 +1430,14 @@ TIFFCheckRead(TIFF* tif, int tiles) * inbuf content must be writable (if bit reversal is needed) * Returns 1 in case of success, 0 otherwise. */ -int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile, +int TIFFReadFromUserBuffer(TIFF* tif, uint32_t strile, void* inbuf, tmsize_t insize, void* outbuf, tmsize_t outsize) { static const char module[] = "TIFFReadFromUserBuffer"; TIFFDirectory *td = &tif->tif_dir; int ret = 1; - uint32 old_tif_flags = tif->tif_flags; + uint32_t old_tif_flags = tif->tif_flags; tmsize_t old_rawdatasize = tif->tif_rawdatasize; void* old_rawdata = tif->tif_rawdata; @@ -1567,29 +1468,29 @@ int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile, if( TIFFIsTiled(tif) ) { if( !TIFFStartTile(tif, strile) || - !(*tif->tif_decodetile)(tif, (uint8*) outbuf, outsize, - (uint16)(strile/td->td_stripsperimage)) ) + !(*tif->tif_decodetile)(tif, (uint8_t*) outbuf, outsize, + (uint16_t)(strile / td->td_stripsperimage)) ) { ret = 0; } } else { - uint32 rowsperstrip=td->td_rowsperstrip; - uint32 stripsperplane; + uint32_t rowsperstrip=td->td_rowsperstrip; + uint32_t stripsperplane; if (rowsperstrip>td->td_imagelength) rowsperstrip=td->td_imagelength; stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip); if( !TIFFStartStrip(tif, strile) || - !(*tif->tif_decodestrip)(tif, (uint8*) outbuf, outsize, - (uint16)(strile/stripsperplane)) ) + !(*tif->tif_decodestrip)(tif, (uint8_t*) outbuf, outsize, + (uint16_t)(strile / stripsperplane)) ) { ret = 0; } } if( ret ) { - (*tif->tif_postdecode)(tif, (uint8*) outbuf, outsize); + (*tif->tif_postdecode)(tif, (uint8_t*) outbuf, outsize); } if (!isFillOrder(tif, td->td_fillorder) && @@ -1608,37 +1509,37 @@ int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile, } void -_TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFNoPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; (void) buf; (void) cc; } void -_TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFSwab16BitData(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; assert((cc & 1) == 0); - TIFFSwabArrayOfShort((uint16*) buf, cc/2); + TIFFSwabArrayOfShort((uint16_t*) buf, cc / 2); } void -_TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFSwab24BitData(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; assert((cc % 3) == 0); - TIFFSwabArrayOfTriples((uint8*) buf, cc/3); + TIFFSwabArrayOfTriples((uint8_t*) buf, cc / 3); } void -_TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFSwab32BitData(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; assert((cc & 3) == 0); - TIFFSwabArrayOfLong((uint32*) buf, cc/4); + TIFFSwabArrayOfLong((uint32_t*) buf, cc / 4); } void -_TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFSwab64BitData(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; assert((cc & 7) == 0); diff --git a/tiff/libtiff/tif_stream.cxx b/tiff/libtiff/tif_stream.cxx index 7f640a9c..ea224169 100644 --- a/tiff/libtiff/tif_stream.cxx +++ b/tiff/libtiff/tif_stream.cxx @@ -28,9 +28,7 @@ #include "tiffiop.h" #include <iostream> -#ifndef __VMS using namespace std; -#endif /* ISO C++ uses a 'std::streamsize' type to define counts. This makes @@ -82,10 +80,10 @@ extern "C" { static tmsize_t _tiffisReadProc(thandle_t fd, void* buf, tmsize_t size); static tmsize_t _tiffosWriteProc(thandle_t fd, void* buf, tmsize_t size); static tmsize_t _tiffisWriteProc(thandle_t, void*, tmsize_t); - static uint64 _tiffosSeekProc(thandle_t fd, uint64 off, int whence); - static uint64 _tiffisSeekProc(thandle_t fd, uint64 off, int whence); - static uint64 _tiffosSizeProc(thandle_t fd); - static uint64 _tiffisSizeProc(thandle_t fd); + static uint64_t _tiffosSeekProc(thandle_t fd, uint64_t off, int whence); + static uint64_t _tiffisSeekProc(thandle_t fd, uint64_t off, int whence); + static uint64_t _tiffosSizeProc(thandle_t fd); + static uint64_t _tiffisSizeProc(thandle_t fd); static int _tiffosCloseProc(thandle_t fd); static int _tiffisCloseProc(thandle_t fd); static int _tiffDummyMapProc(thandle_t , void** base, toff_t* size ); @@ -148,26 +146,26 @@ _tiffisWriteProc(thandle_t, void*, tmsize_t) return 0; } -static uint64 -_tiffosSeekProc(thandle_t fd, uint64 off, int whence) +static uint64_t +_tiffosSeekProc(thandle_t fd, uint64_t off, int whence) { tiffos_data *data = reinterpret_cast<tiffos_data *>(fd); ostream *os = data->stream; // if the stream has already failed, don't do anything if( os->fail() ) - return static_cast<uint64>(-1); + return static_cast<uint64_t>(-1); switch(whence) { case SEEK_SET: { // Compute 64-bit offset - uint64 new_offset = static_cast<uint64>(data->start_pos) + off; + uint64_t new_offset = static_cast<uint64_t>(data->start_pos) + off; // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(new_offset); - if (static_cast<uint64>(offset) != new_offset) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != new_offset) + return static_cast<uint64_t>(-1); os->seekp(offset, ios::beg); break; @@ -176,8 +174,8 @@ _tiffosSeekProc(thandle_t fd, uint64 off, int whence) { // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(off); - if (static_cast<uint64>(offset) != off) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != off) + return static_cast<uint64_t>(-1); os->seekp(offset, ios::cur); break; @@ -186,8 +184,8 @@ _tiffosSeekProc(thandle_t fd, uint64 off, int whence) { // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(off); - if (static_cast<uint64>(offset) != off) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != off) + return static_cast<uint64_t>(-1); os->seekp(offset, ios::end); break; @@ -199,11 +197,7 @@ _tiffosSeekProc(thandle_t fd, uint64 off, int whence) // ostrstream/ostringstream does. In that situation, add intermediate // '\0' characters. if( os->fail() ) { -#ifdef __VMS - int old_state; -#else ios::iostate old_state; -#endif ios::pos_type origin; old_state = os->rdstate(); @@ -226,28 +220,28 @@ _tiffosSeekProc(thandle_t fd, uint64 off, int whence) os->clear(old_state); // only do something if desired seek position is valid - if( (static_cast<uint64>(origin) + off) > static_cast<uint64>(data->start_pos) ) { - uint64 num_fill; + if((static_cast<uint64_t>(origin) + off) > static_cast<uint64_t>(data->start_pos) ) { + uint64_t num_fill; // clear the fail bit os->clear(os->rdstate() & ~ios::failbit); // extend the stream to the expected size os->seekp(0, ios::end); - num_fill = (static_cast<uint64>(origin)) + off - os->tellp(); - for( uint64 i = 0; i < num_fill; i++ ) + num_fill = (static_cast<uint64_t>(origin)) + off - os->tellp(); + for(uint64_t i = 0; i < num_fill; i++ ) os->put('\0'); // retry the seek - os->seekp(static_cast<ios::off_type>(static_cast<uint64>(origin) + off), ios::beg); + os->seekp(static_cast<ios::off_type>(static_cast<uint64_t>(origin) + off), ios::beg); } } - return static_cast<uint64>(os->tellp()); + return static_cast<uint64_t>(os->tellp()); } -static uint64 -_tiffisSeekProc(thandle_t fd, uint64 off, int whence) +static uint64_t +_tiffisSeekProc(thandle_t fd, uint64_t off, int whence) { tiffis_data *data = reinterpret_cast<tiffis_data *>(fd); @@ -255,12 +249,12 @@ _tiffisSeekProc(thandle_t fd, uint64 off, int whence) case SEEK_SET: { // Compute 64-bit offset - uint64 new_offset = static_cast<uint64>(data->start_pos) + off; + uint64_t new_offset = static_cast<uint64_t>(data->start_pos) + off; // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(new_offset); - if (static_cast<uint64>(offset) != new_offset) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != new_offset) + return static_cast<uint64_t>(-1); data->stream->seekg(offset, ios::beg); break; @@ -269,8 +263,8 @@ _tiffisSeekProc(thandle_t fd, uint64 off, int whence) { // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(off); - if (static_cast<uint64>(offset) != off) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != off) + return static_cast<uint64_t>(-1); data->stream->seekg(offset, ios::cur); break; @@ -279,18 +273,18 @@ _tiffisSeekProc(thandle_t fd, uint64 off, int whence) { // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(off); - if (static_cast<uint64>(offset) != off) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != off) + return static_cast<uint64_t>(-1); data->stream->seekg(offset, ios::end); break; } } - return (uint64) (data->stream->tellg() - data->start_pos); + return (uint64_t) (data->stream->tellg() - data->start_pos); } -static uint64 +static uint64_t _tiffosSizeProc(thandle_t fd) { tiffos_data *data = reinterpret_cast<tiffos_data *>(fd); @@ -302,10 +296,10 @@ _tiffosSizeProc(thandle_t fd) len = os->tellp(); os->seekp(pos); - return (uint64) len; + return (uint64_t) len; } -static uint64 +static uint64_t _tiffisSizeProc(thandle_t fd) { tiffis_data *data = reinterpret_cast<tiffis_data *>(fd); @@ -316,7 +310,7 @@ _tiffisSizeProc(thandle_t fd) len = data->stream->tellg(); data->stream->seekg(pos); - return (uint64) len; + return (uint64_t) len; } static int diff --git a/tiff/libtiff/tif_strip.c b/tiff/libtiff/tif_strip.c index c08c60a7..d7b27526 100644 --- a/tiff/libtiff/tif_strip.c +++ b/tiff/libtiff/tif_strip.c @@ -32,12 +32,12 @@ /* * Compute which strip a (row,sample) value is in. */ -uint32 -TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) +uint32_t +TIFFComputeStrip(TIFF* tif, uint32_t row, uint16_t sample) { static const char module[] = "TIFFComputeStrip"; TIFFDirectory *td = &tif->tif_dir; - uint32 strip; + uint32_t strip; strip = row / td->td_rowsperstrip; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { @@ -47,7 +47,7 @@ TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) (unsigned long) sample, (unsigned long) td->td_samplesperpixel); return (0); } - strip += (uint32)sample*td->td_stripsperimage; + strip += (uint32_t)sample * td->td_stripsperimage; } return (strip); } @@ -55,16 +55,16 @@ TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) /* * Compute how many strips are in an image. */ -uint32 +uint32_t TIFFNumberOfStrips(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; - uint32 nstrips; + uint32_t nstrips; - nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 : - TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip)); + nstrips = (td->td_rowsperstrip == (uint32_t) -1 ? 1 : + TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip)); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel, + nstrips = _TIFFMultiply32(tif, nstrips, (uint32_t)td->td_samplesperpixel, "TIFFNumberOfStrips"); return (nstrips); } @@ -72,12 +72,12 @@ TIFFNumberOfStrips(TIFF* tif) /* * Compute the # bytes in a variable height, row-aligned strip. */ -uint64 -TIFFVStripSize64(TIFF* tif, uint32 nrows) +uint64_t +TIFFVStripSize64(TIFF* tif, uint32_t nrows) { static const char module[] = "TIFFVStripSize64"; TIFFDirectory *td = &tif->tif_dir; - if (nrows==(uint32)(-1)) + if (nrows==(uint32_t)(-1)) nrows=td->td_imagelength; if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&& (td->td_photometric == PHOTOMETRIC_YCBCR)&& @@ -91,12 +91,12 @@ TIFFVStripSize64(TIFF* tif, uint32 nrows) * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ - uint16 ycbcrsubsampling[2]; - uint16 samplingblock_samples; - uint32 samplingblocks_hor; - uint32 samplingblocks_ver; - uint64 samplingrow_samples; - uint64 samplingrow_size; + uint16_t ycbcrsubsampling[2]; + uint16_t samplingblock_samples; + uint32_t samplingblocks_hor; + uint32_t samplingblocks_ver; + uint64_t samplingrow_samples; + uint64_t samplingrow_size; if(td->td_samplesperpixel!=3) { TIFFErrorExt(tif->tif_clientdata,module, @@ -125,10 +125,10 @@ TIFFVStripSize64(TIFF* tif, uint32 nrows) return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module)); } tmsize_t -TIFFVStripSize(TIFF* tif, uint32 nrows) +TIFFVStripSize(TIFF* tif, uint32_t nrows) { static const char module[] = "TIFFVStripSize"; - uint64 m; + uint64_t m; m=TIFFVStripSize64(tif,nrows); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -136,43 +136,36 @@ TIFFVStripSize(TIFF* tif, uint32 nrows) /* * Compute the # bytes in a raw strip. */ -uint64 -TIFFRawStripSize64(TIFF* tif, uint32 strip) +uint64_t +TIFFRawStripSize64(TIFF* tif, uint32_t strip) { static const char module[] = "TIFFRawStripSize64"; - uint64 bytecount = TIFFGetStrileByteCount(tif, strip); + uint64_t bytecount = TIFFGetStrileByteCount(tif, strip); if (bytecount == 0) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "%I64u: Invalid strip byte count, strip %lu", - (unsigned __int64) bytecount, + "%"PRIu64": Invalid strip byte count, strip %lu", + (uint64_t) bytecount, (unsigned long) strip); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "%llu: Invalid strip byte count, strip %lu", - (unsigned long long) bytecount, - (unsigned long) strip); -#endif - bytecount = (uint64) -1; + bytecount = (uint64_t) -1; } return bytecount; } tmsize_t -TIFFRawStripSize(TIFF* tif, uint32 strip) +TIFFRawStripSize(TIFF* tif, uint32_t strip) { static const char module[] = "TIFFRawStripSize"; - uint64 m; + uint64_t m; tmsize_t n; m=TIFFRawStripSize64(tif,strip); - if (m==(uint64)(-1)) + if (m==(uint64_t)(-1)) n=(tmsize_t)(-1); else { n=(tmsize_t)m; - if ((uint64)n!=m) + if ((uint64_t)n != m) { TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); n=0; @@ -189,11 +182,11 @@ TIFFRawStripSize(TIFF* tif, uint32 strip) * truncated to reflect the actual space required * to hold the strip. */ -uint64 +uint64_t TIFFStripSize64(TIFF* tif) { TIFFDirectory* td = &tif->tif_dir; - uint32 rps = td->td_rowsperstrip; + uint32_t rps = td->td_rowsperstrip; if (rps > td->td_imagelength) rps = td->td_imagelength; return (TIFFVStripSize64(tif, rps)); @@ -202,7 +195,7 @@ tmsize_t TIFFStripSize(TIFF* tif) { static const char module[] = "TIFFStripSize"; - uint64 m; + uint64_t m; m=TIFFStripSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -213,32 +206,32 @@ TIFFStripSize(TIFF* tif) * request is <1 then we choose a strip size according * to certain heuristics. */ -uint32 -TIFFDefaultStripSize(TIFF* tif, uint32 request) +uint32_t +TIFFDefaultStripSize(TIFF* tif, uint32_t request) { return (*tif->tif_defstripsize)(tif, request); } -uint32 -_TIFFDefaultStripSize(TIFF* tif, uint32 s) +uint32_t +_TIFFDefaultStripSize(TIFF* tif, uint32_t s) { - if ((int32) s < 1) { + if ((int32_t) s < 1) { /* * If RowsPerStrip is unspecified, try to break the * image up into strips that are approximately * STRIP_SIZE_DEFAULT bytes long. */ - uint64 scanlinesize; - uint64 rows; + uint64_t scanlinesize; + uint64_t rows; scanlinesize=TIFFScanlineSize64(tif); if (scanlinesize==0) scanlinesize=1; - rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize; + rows= (uint64_t)STRIP_SIZE_DEFAULT / scanlinesize; if (rows==0) rows=1; else if (rows>0xFFFFFFFF) rows=0xFFFFFFFF; - s=(uint32)rows; + s=(uint32_t)rows; } return (s); } @@ -253,23 +246,23 @@ _TIFFDefaultStripSize(TIFF* tif, uint32 s) * subsampling lines divided by vertical subsampling. It should thus make * sense when multiplied by a multiple of vertical subsampling. */ -uint64 +uint64_t TIFFScanlineSize64(TIFF* tif) { static const char module[] = "TIFFScanlineSize64"; TIFFDirectory *td = &tif->tif_dir; - uint64 scanline_size; + uint64_t scanline_size; if (td->td_planarconfig==PLANARCONFIG_CONTIG) { if ((td->td_photometric==PHOTOMETRIC_YCBCR)&& (td->td_samplesperpixel==3)&& (!isUpSampled(tif))) { - uint16 ycbcrsubsampling[2]; - uint16 samplingblock_samples; - uint32 samplingblocks_hor; - uint64 samplingrow_samples; - uint64 samplingrow_size; + uint16_t ycbcrsubsampling[2]; + uint16_t samplingblock_samples; + uint32_t samplingblocks_hor; + uint64_t samplingrow_samples; + uint64_t samplingrow_size; if(td->td_samplesperpixel!=3) { TIFFErrorExt(tif->tif_clientdata,module, @@ -294,7 +287,7 @@ TIFFScanlineSize64(TIFF* tif) } else { - uint64 scanline_samples; + uint64_t scanline_samples; scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module); scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8); } @@ -314,7 +307,7 @@ tmsize_t TIFFScanlineSize(TIFF* tif) { static const char module[] = "TIFFScanlineSize"; - uint64 m; + uint64_t m; m=TIFFScanlineSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -325,12 +318,12 @@ TIFFScanlineSize(TIFF* tif) * I/O size returned by TIFFScanlineSize which may be less * if data is store as separate planes). */ -uint64 +uint64_t TIFFRasterScanlineSize64(TIFF* tif) { static const char module[] = "TIFFRasterScanlineSize64"; TIFFDirectory *td = &tif->tif_dir; - uint64 scanline; + uint64_t scanline; scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module); if (td->td_planarconfig == PLANARCONFIG_CONTIG) { @@ -344,7 +337,7 @@ tmsize_t TIFFRasterScanlineSize(TIFF* tif) { static const char module[] = "TIFFRasterScanlineSize"; - uint64 m; + uint64_t m; m=TIFFRasterScanlineSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } diff --git a/tiff/libtiff/tif_swab.c b/tiff/libtiff/tif_swab.c index b174ba69..3d4bb6ca 100644 --- a/tiff/libtiff/tif_swab.c +++ b/tiff/libtiff/tif_swab.c @@ -31,22 +31,22 @@ #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabShort) void -TIFFSwabShort(uint16* wp) +TIFFSwabShort(uint16_t* wp) { register unsigned char* cp = (unsigned char*) wp; unsigned char t; - assert(sizeof(uint16)==2); + assert(sizeof(uint16_t) == 2); t = cp[1]; cp[1] = cp[0]; cp[0] = t; } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong) void -TIFFSwabLong(uint32* lp) +TIFFSwabLong(uint32_t* lp) { register unsigned char* cp = (unsigned char*) lp; unsigned char t; - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; } @@ -54,11 +54,11 @@ TIFFSwabLong(uint32* lp) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong8) void -TIFFSwabLong8(uint64* lp) +TIFFSwabLong8(uint64_t* lp) { register unsigned char* cp = (unsigned char*) lp; unsigned char t; - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); t = cp[7]; cp[7] = cp[0]; cp[0] = t; t = cp[6]; cp[6] = cp[1]; cp[1] = t; t = cp[5]; cp[5] = cp[2]; cp[2] = t; @@ -68,11 +68,11 @@ TIFFSwabLong8(uint64* lp) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfShort) void -TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n) +TIFFSwabArrayOfShort(register uint16_t* wp, tmsize_t n) { register unsigned char* cp; register unsigned char t; - assert(sizeof(uint16)==2); + assert(sizeof(uint16_t) == 2); /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char*) wp; @@ -84,7 +84,7 @@ TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfTriples) void -TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n) +TIFFSwabArrayOfTriples(register uint8_t* tp, tmsize_t n) { unsigned char* cp; unsigned char t; @@ -100,11 +100,11 @@ TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong) void -TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n) +TIFFSwabArrayOfLong(register uint32_t* lp, tmsize_t n) { register unsigned char *cp; register unsigned char t; - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char *)lp; @@ -117,11 +117,11 @@ TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong8) void -TIFFSwabArrayOfLong8(register uint64* lp, tmsize_t n) +TIFFSwabArrayOfLong8(register uint64_t* lp, tmsize_t n) { register unsigned char *cp; register unsigned char t; - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char *)lp; @@ -281,7 +281,7 @@ TIFFGetBitRevTable(int reversed) } void -TIFFReverseBits(uint8* cp, tmsize_t n) +TIFFReverseBits(uint8_t* cp, tmsize_t n) { for (; n > 8; n -= 8) { cp[0] = TIFFBitRevTable[cp[0]]; diff --git a/tiff/libtiff/tif_thunder.c b/tiff/libtiff/tif_thunder.c index b56e3c35..3e703d8b 100644 --- a/tiff/libtiff/tif_thunder.c +++ b/tiff/libtiff/tif_thunder.c @@ -61,7 +61,7 @@ static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; if (npixels++ & 1) \ *op++ |= lastpixel; \ else \ - op[0] = (uint8) (lastpixel << 4); \ + op[0] = (uint8_t) (lastpixel << 4); \ } \ } @@ -83,7 +83,7 @@ ThunderSetupDecode(TIFF* tif) } static int -ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) +ThunderDecode(TIFF* tif, uint8_t* op, tmsize_t maxpixels) { static const char module[] = "ThunderDecode"; register unsigned char *bp; @@ -112,10 +112,10 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) } else lastpixel |= lastpixel << 4; npixels += n; - if (npixels > maxpixels) - n -= npixels - maxpixels; - for (; n > 0; n -= 2) - *op++ = (uint8) lastpixel; + if (npixels < maxpixels) { + for (; n > 0; n -= 2) + *op++ = (uint8_t) lastpixel; + } if (n == -1) *--op &= 0xf0; lastpixel &= 0xf; @@ -139,24 +139,15 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) break; } } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; if (npixels != maxpixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "%s data at scanline %lu (%I64u != %I64u)", + "%s data at scanline %lu (%"PRIu64" != %"PRIu64")", npixels < maxpixels ? "Not enough" : "Too much", (unsigned long) tif->tif_row, - (unsigned __int64) npixels, - (unsigned __int64) maxpixels); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "%s data at scanline %lu (%llu != %llu)", - npixels < maxpixels ? "Not enough" : "Too much", - (unsigned long) tif->tif_row, - (unsigned long long) npixels, - (unsigned long long) maxpixels); -#endif + (uint64_t) npixels, + (uint64_t) maxpixels); return (0); } @@ -164,10 +155,10 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) } static int -ThunderDecodeRow(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +ThunderDecodeRow(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { static const char module[] = "ThunderDecodeRow"; - uint8* row = buf; + uint8_t* row = buf; (void) s; if (occ % tif->tif_scanlinesize) diff --git a/tiff/libtiff/tif_tile.c b/tiff/libtiff/tif_tile.c index 661cc771..058be9f7 100644 --- a/tiff/libtiff/tif_tile.c +++ b/tiff/libtiff/tif_tile.c @@ -32,27 +32,27 @@ /* * Compute which tile an (x,y,z,s) value is in. */ -uint32 -TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) +uint32_t +TIFFComputeTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { TIFFDirectory *td = &tif->tif_dir; - uint32 dx = td->td_tilewidth; - uint32 dy = td->td_tilelength; - uint32 dz = td->td_tiledepth; - uint32 tile = 1; + uint32_t dx = td->td_tilewidth; + uint32_t dy = td->td_tilelength; + uint32_t dz = td->td_tiledepth; + uint32_t tile = 1; if (td->td_imagedepth == 1) z = 0; - if (dx == (uint32) -1) + if (dx == (uint32_t) -1) dx = td->td_imagewidth; - if (dy == (uint32) -1) + if (dy == (uint32_t) -1) dy = td->td_imagelength; - if (dz == (uint32) -1) + if (dz == (uint32_t) -1) dz = td->td_imagedepth; if (dx != 0 && dy != 0 && dz != 0) { - uint32 xpt = TIFFhowmany_32(td->td_imagewidth, dx); - uint32 ypt = TIFFhowmany_32(td->td_imagelength, dy); - uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz); + uint32_t xpt = TIFFhowmany_32(td->td_imagewidth, dx); + uint32_t ypt = TIFFhowmany_32(td->td_imagelength, dy); + uint32_t zpt = TIFFhowmany_32(td->td_imagedepth, dz); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) tile = (xpt*ypt*zpt)*s + @@ -70,7 +70,7 @@ TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) * against the image bounds. */ int -TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) +TIFFCheckTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { TIFFDirectory *td = &tif->tif_dir; @@ -109,20 +109,20 @@ TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) /* * Compute how many tiles are in an image. */ -uint32 +uint32_t TIFFNumberOfTiles(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; - uint32 dx = td->td_tilewidth; - uint32 dy = td->td_tilelength; - uint32 dz = td->td_tiledepth; - uint32 ntiles; + uint32_t dx = td->td_tilewidth; + uint32_t dy = td->td_tilelength; + uint32_t dz = td->td_tiledepth; + uint32_t ntiles; - if (dx == (uint32) -1) + if (dx == (uint32_t) -1) dx = td->td_imagewidth; - if (dy == (uint32) -1) + if (dy == (uint32_t) -1) dy = td->td_imagelength; - if (dz == (uint32) -1) + if (dz == (uint32_t) -1) dz = td->td_imagedepth; ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : _TIFFMultiply32(tif, _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx), @@ -138,13 +138,13 @@ TIFFNumberOfTiles(TIFF* tif) /* * Compute the # bytes in each row of a tile. */ -uint64 +uint64_t TIFFTileRowSize64(TIFF* tif) { static const char module[] = "TIFFTileRowSize64"; TIFFDirectory *td = &tif->tif_dir; - uint64 rowsize; - uint64 tilerowsize; + uint64_t rowsize; + uint64_t tilerowsize; if (td->td_tilelength == 0) { @@ -180,7 +180,7 @@ tmsize_t TIFFTileRowSize(TIFF* tif) { static const char module[] = "TIFFTileRowSize"; - uint64 m; + uint64_t m; m=TIFFTileRowSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -188,8 +188,8 @@ TIFFTileRowSize(TIFF* tif) /* * Compute the # bytes in a variable length, row-aligned tile. */ -uint64 -TIFFVTileSize64(TIFF* tif, uint32 nrows) +uint64_t +TIFFVTileSize64(TIFF* tif, uint32_t nrows) { static const char module[] = "TIFFVTileSize64"; TIFFDirectory *td = &tif->tif_dir; @@ -209,12 +209,12 @@ TIFFVTileSize64(TIFF* tif, uint32 nrows) * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ - uint16 ycbcrsubsampling[2]; - uint16 samplingblock_samples; - uint32 samplingblocks_hor; - uint32 samplingblocks_ver; - uint64 samplingrow_samples; - uint64 samplingrow_size; + uint16_t ycbcrsubsampling[2]; + uint16_t samplingblock_samples; + uint32_t samplingblocks_hor; + uint32_t samplingblocks_ver; + uint64_t samplingrow_samples; + uint64_t samplingrow_size; TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, ycbcrsubsampling+1); if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4) @@ -237,10 +237,10 @@ TIFFVTileSize64(TIFF* tif, uint32 nrows) return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module)); } tmsize_t -TIFFVTileSize(TIFF* tif, uint32 nrows) +TIFFVTileSize(TIFF* tif, uint32_t nrows) { static const char module[] = "TIFFVTileSize"; - uint64 m; + uint64_t m; m=TIFFVTileSize64(tif,nrows); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -248,7 +248,7 @@ TIFFVTileSize(TIFF* tif, uint32 nrows) /* * Compute the # bytes in a row-aligned tile. */ -uint64 +uint64_t TIFFTileSize64(TIFF* tif) { return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength)); @@ -257,7 +257,7 @@ tmsize_t TIFFTileSize(TIFF* tif) { static const char module[] = "TIFFTileSize"; - uint64 m; + uint64_t m; m=TIFFTileSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -269,18 +269,18 @@ TIFFTileSize(TIFF* tif) * to certain heuristics. */ void -TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) +TIFFDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th) { (*tif->tif_deftilesize)(tif, tw, th); } void -_TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) +_TIFFDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th) { (void) tif; - if (*(int32*) tw < 1) + if (*(int32_t*) tw < 1) *tw = 256; - if (*(int32*) th < 1) + if (*(int32_t*) th < 1) *th = 256; /* roundup to a multiple of 16 per the spec */ if (*tw & 0xf) diff --git a/tiff/libtiff/tif_unix.c b/tiff/libtiff/tif_unix.c index bea1ef78..cb543542 100644 --- a/tiff/libtiff/tif_unix.c +++ b/tiff/libtiff/tif_unix.c @@ -120,18 +120,18 @@ _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) /* return ((tmsize_t) write(fdh.fd, buf, bytes_total)); */ } -static uint64 -_tiffSeekProc(thandle_t fd, uint64 off, int whence) +static uint64_t +_tiffSeekProc(thandle_t fd, uint64_t off, int whence) { fd_as_handle_union_t fdh; _TIFF_off_t off_io = (_TIFF_off_t) off; - if ((uint64) off_io != off) + if ((uint64_t) off_io != off) { errno=EINVAL; - return (uint64) -1; /* this is really gross */ + return (uint64_t) -1; /* this is really gross */ } fdh.h = fd; - return((uint64)_TIFF_lseek_f(fdh.fd,off_io,whence)); + return((uint64_t)_TIFF_lseek_f(fdh.fd, off_io, whence)); } static int @@ -142,7 +142,7 @@ _tiffCloseProc(thandle_t fd) return(close(fdh.fd)); } -static uint64 +static uint64_t _tiffSizeProc(thandle_t fd) { _TIFF_stat_s sb; @@ -151,7 +151,7 @@ _tiffSizeProc(thandle_t fd) if (_TIFF_fstat_f(fdh.fd,&sb)<0) return(0); else - return((uint64)sb.st_size); + return((uint64_t)sb.st_size); } #ifdef HAVE_MMAP @@ -160,9 +160,9 @@ _tiffSizeProc(thandle_t fd) static int _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - uint64 size64 = _tiffSizeProc(fd); + uint64_t size64 = _tiffSizeProc(fd); tmsize_t sizem = (tmsize_t)size64; - if (size64 && (uint64)sizem==size64) { + if (size64 && (uint64_t)sizem == size64) { fd_as_handle_union_t fdh; fdh.h = fd; *pbase = (void*) diff --git a/tiff/libtiff/tif_webp.c b/tiff/libtiff/tif_webp.c index a00478f6..d5b99d35 100644 --- a/tiff/libtiff/tif_webp.c +++ b/tiff/libtiff/tif_webp.c @@ -43,13 +43,13 @@ * file using WEBP compression/decompression. */ typedef struct { - uint16 nSamples; /* number of samples per pixel */ + uint16_t nSamples; /* number of samples per pixel */ int lossless; /* lossy/lossless compression */ int quality_level; /* compression level */ WebPPicture sPicture; /* WebP Picture */ WebPConfig sEncoderConfig; /* WebP encoder config */ - uint8* pBuffer; /* buffer to hold raw data on encoding */ + uint8_t* pBuffer; /* buffer to hold raw data on encoding */ unsigned int buffer_offset; /* current offset into the buffer */ unsigned int buffer_size; @@ -67,8 +67,8 @@ typedef struct { #define DecoderState(tif) LState(tif) #define EncoderState(tif) LState(tif) -static int TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int TWebPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int TWebPEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int TWebPDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); static int TWebPDatasetWriter(const uint8_t* data, size_t data_size, @@ -79,7 +79,7 @@ int TWebPDatasetWriter(const uint8_t* data, size_t data_size, if ( (tif->tif_rawcc + (tmsize_t)data_size) > tif->tif_rawdatasize ) { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer too small by " TIFF_SIZE_FORMAT " bytes.", + "Buffer too small by %"TIFF_SIZE_FORMAT" bytes.", (size_t) (tif->tif_rawcc + data_size - tif->tif_rawdatasize)); return 0; } else { @@ -94,7 +94,7 @@ int TWebPDatasetWriter(const uint8_t* data, size_t data_size, * Encode a chunk of pixels. */ static int -TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +TWebPEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "TWebPEncode"; WebPState *sp = EncoderState(tif); @@ -103,8 +103,8 @@ TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) assert(sp != NULL); assert(sp->state == LSTATE_INIT_ENCODE); - if( (uint64)sp->buffer_offset + - (uint64)cc > sp->buffer_size ) + if((uint64_t)sp->buffer_offset + + (uint64_t)cc > sp->buffer_size ) { TIFFErrorExt(tif->tif_clientdata, module, "Too many bytes to be written"); @@ -120,7 +120,7 @@ TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } static int -TWebPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +TWebPDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "WebPDecode"; VP8StatusCode status = VP8_STATUS_OK; @@ -159,7 +159,7 @@ TWebPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) buf = WebPIDecGetRGB(sp->psDecoder, ¤t_y, NULL, NULL, &stride); if ((buf != NULL) && - (occ <= stride * (current_y - sp->last_y))) { + (occ <= (tmsize_t)stride * (current_y - sp->last_y))) { memcpy(op, buf + (sp->last_y * stride), occ); @@ -196,8 +196,8 @@ static int TWebPSetupDecode(TIFF* tif) { static const char module[] = "WebPSetupDecode"; - uint16 nBitsPerSample = tif->tif_dir.td_bitspersample; - uint16 sampleFormat = tif->tif_dir.td_sampleformat; + uint16_t nBitsPerSample = tif->tif_dir.td_bitspersample; + uint16_t sampleFormat = tif->tif_dir.td_sampleformat; WebPState* sp = DecoderState(tif); assert(sp != NULL); @@ -248,10 +248,10 @@ TWebPSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -TWebPPreDecode(TIFF* tif, uint16 s) +TWebPPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "TWebPPreDecode"; - uint32 segment_width, segment_height; + uint32_t segment_width, segment_height; WebPState* sp = DecoderState(tif); TIFFDirectory* td = &tif->tif_dir; (void) s; @@ -313,8 +313,8 @@ static int TWebPSetupEncode(TIFF* tif) { static const char module[] = "WebPSetupEncode"; - uint16 nBitsPerSample = tif->tif_dir.td_bitspersample; - uint16 sampleFormat = tif->tif_dir.td_sampleformat; + uint16_t nBitsPerSample = tif->tif_dir.td_bitspersample; + uint16_t sampleFormat = tif->tif_dir.td_sampleformat; WebPState* sp = EncoderState(tif); assert(sp != NULL); @@ -390,10 +390,10 @@ TWebPSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -TWebPPreEncode(TIFF* tif, uint16 s) +TWebPPreEncode(TIFF* tif, uint16_t s) { static const char module[] = "TWebPPreEncode"; - uint32 segment_width, segment_height; + uint32_t segment_width, segment_height; WebPState *sp = EncoderState(tif); TIFFDirectory* td = &tif->tif_dir; @@ -567,7 +567,7 @@ TWebPCleanup(TIFF* tif) } static int -TWebPVSetField(TIFF* tif, uint32 tag, va_list ap) +TWebPVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "WebPVSetField"; WebPState* sp = LState(tif); @@ -601,7 +601,7 @@ TWebPVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -TWebPVGetField(TIFF* tif, uint32 tag, va_list ap) +TWebPVGetField(TIFF* tif, uint32_t tag, va_list ap) { WebPState* sp = LState(tif); @@ -649,7 +649,7 @@ TIFFInitWebP(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof(WebPState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(WebPState)); if (tif->tif_data == NULL) goto bad; sp = LState(tif); diff --git a/tiff/libtiff/tif_win32.c b/tiff/libtiff/tif_win32.c index 89645693..c6ca1519 100644 --- a/tiff/libtiff/tif_win32.c +++ b/tiff/libtiff/tif_win32.c @@ -65,18 +65,18 @@ _tiffReadProc(thandle_t fd, void* buf, tmsize_t size) /* tmsize_t is 64bit on 64bit systems, but the WinAPI ReadFile takes * 32bit sizes, so we loop through the data in suitable 32bit sized * chunks */ - uint8* ma; - uint64 mb; + uint8_t* ma; + uint64_t mb; DWORD n; DWORD o; tmsize_t p; - ma=(uint8*)buf; + ma=(uint8_t*)buf; mb=size; p=0; while (mb>0) { n=0x80000000UL; - if ((uint64)n>mb) + if ((uint64_t)n>mb) n=(DWORD)mb; if (!ReadFile(fd,(LPVOID)ma,n,&o,NULL)) return(0); @@ -95,18 +95,18 @@ _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) /* tmsize_t is 64bit on 64bit systems, but the WinAPI WriteFile takes * 32bit sizes, so we loop through the data in suitable 32bit sized * chunks */ - uint8* ma; - uint64 mb; + uint8_t* ma; + uint64_t mb; DWORD n; DWORD o; tmsize_t p; - ma=(uint8*)buf; + ma=(uint8_t*)buf; mb=size; p=0; while (mb>0) { n=0x80000000UL; - if ((uint64)n>mb) + if ((uint64_t)n>mb) n=(DWORD)mb; if (!WriteFile(fd,(LPVOID)ma,n,&o,NULL)) return(0); @@ -119,8 +119,8 @@ _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) return(p); } -static uint64 -_tiffSeekProc(thandle_t fd, uint64 off, int whence) +static uint64_t +_tiffSeekProc(thandle_t fd, uint64_t off, int whence) { LARGE_INTEGER offli; DWORD dwMoveMethod; @@ -152,7 +152,7 @@ _tiffCloseProc(thandle_t fd) return (CloseHandle(fd) ? 0 : -1); } -static uint64 +static uint64_t _tiffSizeProc(thandle_t fd) { LARGE_INTEGER m; @@ -185,13 +185,13 @@ _tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize) static int _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - uint64 size; + uint64_t size; tmsize_t sizem; HANDLE hMapFile; size = _tiffSizeProc(fd); sizem = (tmsize_t)size; - if (!size || (uint64)sizem!=size) + if (!size || (uint64_t)sizem!=size) return (0); /* By passing in 0 for the maximum file size, it specifies that we @@ -404,10 +404,6 @@ _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) #ifndef _WIN32_WCE -#if (_MSC_VER < 1500) -# define vsnprintf _vsnprintf -#endif - static void Win32WarningHandler(const char* module, const char* fmt, va_list ap) { diff --git a/tiff/libtiff/tif_write.c b/tiff/libtiff/tif_write.c index 3af69ab4..b5ef21d0 100644 --- a/tiff/libtiff/tif_write.c +++ b/tiff/libtiff/tif_write.c @@ -40,16 +40,16 @@ ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ TIFFWriteBufferSetup((tif), NULL, (tmsize_t) -1)) -static int TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module); -static int TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc); +static int TIFFGrowStrips(TIFF* tif, uint32_t delta, const char* module); +static int TIFFAppendToStrip(TIFF* tif, uint32_t strip, uint8_t* data, tmsize_t cc); int -TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) +TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample) { static const char module[] = "TIFFWriteScanline"; register TIFFDirectory *td; int status, imagegrew = 0; - uint32 strip; + uint32_t strip; if (!WRITECHECKSTRIPS(tif, module)) return (-1); @@ -166,9 +166,9 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) } /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) buf, tif->tif_scanlinesize ); + tif->tif_postdecode(tif, (uint8_t*) buf, tif->tif_scanlinesize ); - status = (*tif->tif_encoderow)(tif, (uint8*) buf, + status = (*tif->tif_encoderow)(tif, (uint8_t*) buf, tif->tif_scanlinesize, sample); /* we are now poised at the beginning of the next row */ @@ -180,14 +180,14 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) /* more bytes available in the output buffer than the previous byte count, */ /* so that TIFFAppendToStrip() will detect the overflow when it is called the first */ /* time if the new compressed tile is bigger than the older one. (GDAL #4771) */ -static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32 strip_or_tile) +static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32_t strip_or_tile) { TIFFDirectory *td = &tif->tif_dir; if( td->td_stripbytecount_p[strip_or_tile] > 0 ) { /* The +1 is to ensure at least one extra bytes */ /* The +4 is because the LZW encoder flushes 4 bytes before the limit */ - uint64 safe_buffer_size = (uint64)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4); + uint64_t safe_buffer_size = (uint64_t)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4); if( tif->tif_rawdatasize <= (tmsize_t)safe_buffer_size ) { if( !(TIFFWriteBufferSetup(tif, NULL, @@ -209,11 +209,11 @@ static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32 strip_or_tile) * NB: Image length must be setup before writing. */ tmsize_t -TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) +TIFFWriteEncodedStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; - uint16 sample; + uint16_t sample; if (!WRITECHECKSTRIPS(tif, module)) return ((tmsize_t) -1); @@ -273,26 +273,26 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) if( td->td_compression == COMPRESSION_NONE ) { /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*) data, cc); + TIFFReverseBits((uint8_t*) data, cc); if (cc > 0 && - !TIFFAppendToStrip(tif, strip, (uint8*) data, cc)) + !TIFFAppendToStrip(tif, strip, (uint8_t*) data, cc)) return ((tmsize_t) -1); return (cc); } - sample = (uint16)(strip / td->td_stripsperimage); + sample = (uint16_t)(strip / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tmsize_t) -1); /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); - if (!(*tif->tif_encodestrip)(tif, (uint8*) data, cc, sample)) + if (!(*tif->tif_encodestrip)(tif, (uint8_t*) data, cc, sample)) return ((tmsize_t) -1); if (!(*tif->tif_postencode)(tif)) return ((tmsize_t) -1); @@ -313,7 +313,7 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) * NB: Image length must be setup before writing. */ tmsize_t -TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) +TIFFWriteRawStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteRawStrip"; TIFFDirectory *td = &tif->tif_dir; @@ -352,7 +352,7 @@ TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) return ((tmsize_t) -1); } tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - return (TIFFAppendToStrip(tif, strip, (uint8*) data, cc) ? + return (TIFFAppendToStrip(tif, strip, (uint8_t*) data, cc) ? cc : (tmsize_t) -1); } @@ -361,7 +361,7 @@ TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) * tile is selected by the (x,y,z,s) coordinates. */ tmsize_t -TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) +TIFFWriteTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { if (!TIFFCheckTile(tif, x, y, z, s)) return ((tmsize_t)(-1)); @@ -388,12 +388,12 @@ TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) * the image on each write (as TIFFWriteScanline does). */ tmsize_t -TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) +TIFFWriteEncodedTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteEncodedTile"; TIFFDirectory *td; - uint16 sample; - uint32 howmany32; + uint16_t sample; + uint32_t howmany32; if (!WRITECHECKTILES(tif, module)) return ((tmsize_t)(-1)); @@ -457,31 +457,31 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) if( td->td_compression == COMPRESSION_NONE ) { /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*) data, cc); + TIFFReverseBits((uint8_t*) data, cc); if (cc > 0 && - !TIFFAppendToStrip(tif, tile, (uint8*) data, cc)) + !TIFFAppendToStrip(tif, tile, (uint8_t*) data, cc)) return ((tmsize_t) -1); return (cc); } - sample = (uint16)(tile/td->td_stripsperimage); + sample = (uint16_t)(tile / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tmsize_t)(-1)); /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); - if (!(*tif->tif_encodetile)(tif, (uint8*) data, cc, sample)) + if (!(*tif->tif_encodetile)(tif, (uint8_t*) data, cc, sample)) return ((tmsize_t) -1); if (!(*tif->tif_postencode)(tif)) return ((tmsize_t)(-1)); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*)tif->tif_rawdata, tif->tif_rawcc); + TIFFReverseBits((uint8_t*)tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, tif->tif_rawdata, tif->tif_rawcc)) return ((tmsize_t)(-1)); @@ -500,7 +500,7 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) * the image on each write (as TIFFWriteScanline does). */ tmsize_t -TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) +TIFFWriteRawTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteRawTile"; @@ -512,7 +512,7 @@ TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) (unsigned long) tif->tif_dir.td_nstrips); return ((tmsize_t)(-1)); } - return (TIFFAppendToStrip(tif, tile, (uint8*) data, cc) ? + return (TIFFAppendToStrip(tif, tile, (uint8_t*) data, cc) ? cc : (tmsize_t)(-1)); } @@ -542,11 +542,11 @@ TIFFSetupStrips(TIFF* tif) } if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_stripsperimage /= td->td_samplesperpixel; - td->td_stripoffset_p = (uint64 *) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + td->td_stripoffset_p = (uint64_t *) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64_t), "for \"StripOffsets\" array"); - td->td_stripbytecount_p = (uint64 *) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + td->td_stripbytecount_p = (uint64_t *) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64_t), "for \"StripByteCounts\" array"); if (td->td_stripoffset_p == NULL || td->td_stripbytecount_p == NULL) return (0); @@ -554,8 +554,8 @@ TIFFSetupStrips(TIFF* tif) * Place data at the end-of-file * (by setting offsets to zero). */ - _TIFFmemset(td->td_stripoffset_p, 0, td->td_nstrips*sizeof (uint64)); - _TIFFmemset(td->td_stripbytecount_p, 0, td->td_nstrips*sizeof (uint64)); + _TIFFmemset(td->td_stripoffset_p, 0, td->td_nstrips*sizeof (uint64_t)); + _TIFFmemset(td->td_stripbytecount_p, 0, td->td_nstrips*sizeof (uint64_t)); TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); return (1); @@ -688,7 +688,7 @@ TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size) tif->tif_flags |= TIFF_MYBUFFER; } else tif->tif_flags &= ~TIFF_MYBUFFER; - tif->tif_rawdata = (uint8*) bp; + tif->tif_rawdata = (uint8_t*) bp; tif->tif_rawdatasize = size; tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; @@ -700,17 +700,17 @@ TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size) * Grow the strip data structures by delta strips. */ static int -TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) +TIFFGrowStrips(TIFF* tif, uint32_t delta, const char* module) { TIFFDirectory *td = &tif->tif_dir; - uint64* new_stripoffset; - uint64* new_stripbytecount; + uint64_t* new_stripoffset; + uint64_t* new_stripbytecount; assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - new_stripoffset = (uint64*)_TIFFrealloc(td->td_stripoffset_p, - (td->td_nstrips + delta) * sizeof (uint64)); - new_stripbytecount = (uint64*)_TIFFrealloc(td->td_stripbytecount_p, - (td->td_nstrips + delta) * sizeof (uint64)); + new_stripoffset = (uint64_t*)_TIFFrealloc(td->td_stripoffset_p, + (td->td_nstrips + delta) * sizeof (uint64_t)); + new_stripbytecount = (uint64_t*)_TIFFrealloc(td->td_stripbytecount_p, + (td->td_nstrips + delta) * sizeof (uint64_t)); if (new_stripoffset == NULL || new_stripbytecount == NULL) { if (new_stripoffset) _TIFFfree(new_stripoffset); @@ -723,9 +723,9 @@ TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) td->td_stripoffset_p = new_stripoffset; td->td_stripbytecount_p = new_stripbytecount; _TIFFmemset(td->td_stripoffset_p + td->td_nstrips, - 0, delta*sizeof (uint64)); + 0, delta*sizeof (uint64_t)); _TIFFmemset(td->td_stripbytecount_p + td->td_nstrips, - 0, delta*sizeof (uint64)); + 0, delta*sizeof (uint64_t)); td->td_nstrips += delta; tif->tif_flags |= TIFF_DIRTYDIRECT; @@ -736,19 +736,19 @@ TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) * Append the data to the specified strip. */ static int -TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) +TIFFAppendToStrip(TIFF* tif, uint32_t strip, uint8_t* data, tmsize_t cc) { static const char module[] = "TIFFAppendToStrip"; TIFFDirectory *td = &tif->tif_dir; - uint64 m; - int64 old_byte_count = -1; + uint64_t m; + int64_t old_byte_count = -1; if (td->td_stripoffset_p[strip] == 0 || tif->tif_curoff == 0) { assert(td->td_nstrips > 0); if( td->td_stripbytecount_p[strip] != 0 && td->td_stripoffset_p[strip] != 0 - && td->td_stripbytecount_p[strip] >= (uint64) cc ) + && td->td_stripbytecount_p[strip] >= (uint64_t) cc ) { /* * There is already tile data on disk, and the new tile @@ -785,8 +785,8 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) m = tif->tif_curoff+cc; if (!(tif->tif_flags&TIFF_BIGTIFF)) - m = (uint32)m; - if ((m<tif->tif_curoff)||(m<(uint64)cc)) + m = (uint32_t)m; + if ((m<tif->tif_curoff)||(m<(uint64_t)cc)) { TIFFErrorExt(tif->tif_clientdata, module, "Maximum TIFF file size exceeded"); return (0); @@ -799,7 +799,7 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) tif->tif_curoff = m; td->td_stripbytecount_p[strip] += cc; - if( (int64) td->td_stripbytecount_p[strip] != old_byte_count ) + if((int64_t) td->td_stripbytecount_p[strip] != old_byte_count ) tif->tif_flags |= TIFF_DIRTYSTRIP; return (1); @@ -816,7 +816,7 @@ TIFFFlushData1(TIFF* tif) if (tif->tif_rawcc > 0 && tif->tif_flags & TIFF_BUF4WRITE ) { if (!isFillOrder(tif, tif->tif_dir.td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*)tif->tif_rawdata, + TIFFReverseBits((uint8_t*)tif->tif_rawdata, tif->tif_rawcc); if (!TIFFAppendToStrip(tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, diff --git a/tiff/libtiff/tif_zip.c b/tiff/libtiff/tif_zip.c index e71c312c..be35e49b 100644 --- a/tiff/libtiff/tif_zip.c +++ b/tiff/libtiff/tif_zip.c @@ -85,8 +85,8 @@ typedef struct { #define DecoderState(tif) ZState(tif) #define EncoderState(tif) ZState(tif) -static int ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int ZIPEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int ZIPDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); static int ZIPFixupTags(TIFF* tif) @@ -126,7 +126,7 @@ ZIPSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -ZIPPreDecode(TIFF* tif, uint16 s) +ZIPPreDecode(TIFF* tif, uint16_t s) { ZIPState* sp = DecoderState(tif); @@ -144,12 +144,12 @@ ZIPPreDecode(TIFF* tif, uint16 s) we need to simplify this code to reflect a ZLib that is likely updated to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ - sp->stream.avail_in = (uint64)tif->tif_rawcc < 0xFFFFFFFFU ? (uInt) tif->tif_rawcc : 0xFFFFFFFFU; + sp->stream.avail_in = (uint64_t)tif->tif_rawcc < 0xFFFFFFFFU ? (uInt) tif->tif_rawcc : 0xFFFFFFFFU; return (inflateReset(&sp->stream) == Z_OK); } static int -ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +ZIPDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "ZIPDecode"; ZIPState* sp = DecoderState(tif); @@ -174,20 +174,20 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) /* Check if we are in the situation where we can use libdeflate */ if (isTiled(tif)) { - if( TIFFTileSize64(tif) != (uint64)occ ) + if( TIFFTileSize64(tif) != (uint64_t)occ ) break; } else { - uint32 strip_height = td->td_imagelength - tif->tif_row; + uint32_t strip_height = td->td_imagelength - tif->tif_row; if (strip_height > td->td_rowsperstrip) strip_height = td->td_rowsperstrip; - if( TIFFVStripSize64(tif, strip_height) != (uint64)occ ) + if( TIFFVStripSize64(tif, strip_height) != (uint64_t)occ ) break; } /* Check for overflow */ - if( (size_t)tif->tif_rawcc != (uint64)tif->tif_rawcc ) + if( (size_t)tif->tif_rawcc != (uint64_t)tif->tif_rawcc ) break; - if( (size_t)occ != (uint64)occ ) + if( (size_t)occ != (uint64_t)occ ) break; /* Go for decompression using libdeflate */ @@ -238,8 +238,8 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) appropriately even before we simplify it */ do { int state; - uInt avail_in_before = (uint64)tif->tif_rawcc <= 0xFFFFFFFFU ? (uInt)tif->tif_rawcc : 0xFFFFFFFFU; - uInt avail_out_before = (uint64)occ < 0xFFFFFFFFU ? (uInt) occ : 0xFFFFFFFFU; + uInt avail_in_before = (uint64_t)tif->tif_rawcc <= 0xFFFFFFFFU ? (uInt)tif->tif_rawcc : 0xFFFFFFFFU; + uInt avail_out_before = (uint64_t)occ < 0xFFFFFFFFU ? (uInt) occ : 0xFFFFFFFFU; sp->stream.avail_in = avail_in_before; sp->stream.avail_out = avail_out_before; state = inflate(&sp->stream, Z_PARTIAL_FLUSH); @@ -261,8 +261,8 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) } while (occ > 0); if (occ != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)", - (unsigned long) tif->tif_row, (TIFF_UINT64_T) occ); + "Not enough data at scanline %lu (short %" PRIu64 " bytes)", + (unsigned long) tif->tif_row, (uint64_t) occ); return (0); } @@ -301,7 +301,7 @@ ZIPSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -ZIPPreEncode(TIFF* tif, uint16 s) +ZIPPreEncode(TIFF* tif, uint16_t s) { ZIPState *sp = EncoderState(tif); @@ -318,7 +318,7 @@ ZIPPreEncode(TIFF* tif, uint16 s) we need to simplify this code to reflect a ZLib that is likely updated to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ - sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; return (deflateReset(&sp->stream) == Z_OK); } @@ -326,7 +326,7 @@ ZIPPreEncode(TIFF* tif, uint16 s) * Encode a chunk of pixels. */ static int -ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +ZIPEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "ZIPEncode"; ZIPState *sp = EncoderState(tif); @@ -356,20 +356,20 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) /* Check if we are in the situation where we can use libdeflate */ if (isTiled(tif)) { - if( TIFFTileSize64(tif) != (uint64)cc ) + if( TIFFTileSize64(tif) != (uint64_t)cc ) break; } else { - uint32 strip_height = td->td_imagelength - tif->tif_row; + uint32_t strip_height = td->td_imagelength - tif->tif_row; if (strip_height > td->td_rowsperstrip) strip_height = td->td_rowsperstrip; - if( TIFFVStripSize64(tif, strip_height) != (uint64)cc ) + if( TIFFVStripSize64(tif, strip_height) != (uint64_t)cc ) break; } /* Check for overflow */ - if( (size_t)tif->tif_rawdatasize != (uint64)tif->tif_rawdatasize ) + if( (size_t)tif->tif_rawdatasize != (uint64_t)tif->tif_rawdatasize ) break; - if( (size_t)cc != (uint64)cc ) + if( (size_t)cc != (uint64_t)cc ) break; /* Go for compression using libdeflate */ @@ -430,7 +430,7 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ do { - uInt avail_in_before = (uint64)cc <= 0xFFFFFFFFU ? (uInt)cc : 0xFFFFFFFFU; + uInt avail_in_before = (uint64_t)cc <= 0xFFFFFFFFU ? (uInt)cc : 0xFFFFFFFFU; sp->stream.avail_in = avail_in_before; if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { TIFFErrorExt(tif->tif_clientdata, module, @@ -443,7 +443,7 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) if (!TIFFFlushData1(tif)) return 0; sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; } cc -= (avail_in_before - sp->stream.avail_in); } while (cc > 0); @@ -478,7 +478,7 @@ ZIPPostEncode(TIFF* tif) if (!TIFFFlushData1(tif)) return 0; sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; } break; default: @@ -524,7 +524,7 @@ ZIPCleanup(TIFF* tif) } static int -ZIPVSetField(TIFF* tif, uint32 tag, va_list ap) +ZIPVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "ZIPVSetField"; ZIPState* sp = ZState(tif); @@ -588,7 +588,7 @@ ZIPVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -ZIPVGetField(TIFF* tif, uint32 tag, va_list ap) +ZIPVGetField(TIFF* tif, uint32_t tag, va_list ap) { ZIPState* sp = ZState(tif); @@ -636,7 +636,7 @@ TIFFInitZIP(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFcalloc(sizeof (ZIPState), 1); + tif->tif_data = (uint8_t*) _TIFFcalloc(sizeof (ZIPState), 1); if (tif->tif_data == NULL) goto bad; sp = ZState(tif); diff --git a/tiff/libtiff/tif_zstd.c b/tiff/libtiff/tif_zstd.c index 66135e03..14ac0811 100644 --- a/tiff/libtiff/tif_zstd.c +++ b/tiff/libtiff/tif_zstd.c @@ -57,8 +57,8 @@ typedef struct { #define DecoderState(tif) LState(tif) #define EncoderState(tif) LState(tif) -static int ZSTDEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int ZSTDDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int ZSTDEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int ZSTDDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); static int ZSTDFixupTags(TIFF* tif) @@ -89,7 +89,7 @@ ZSTDSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -ZSTDPreDecode(TIFF* tif, uint16 s) +ZSTDPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "ZSTDPreDecode"; ZSTDState* sp = DecoderState(tif); @@ -125,7 +125,7 @@ ZSTDPreDecode(TIFF* tif, uint16 s) } static int -ZSTDDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +ZSTDDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "ZSTDDecode"; ZSTDState* sp = DecoderState(tif); @@ -192,7 +192,7 @@ ZSTDSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -ZSTDPreEncode(TIFF* tif, uint16 s) +ZSTDPreEncode(TIFF* tif, uint16_t s) { static const char module[] = "ZSTDPreEncode"; ZSTDState *sp = EncoderState(tif); @@ -233,7 +233,7 @@ ZSTDPreEncode(TIFF* tif, uint16 s) * Encode a chunk of pixels. */ static int -ZSTDEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +ZSTDEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "ZSTDEncode"; ZSTDState *sp = EncoderState(tif); @@ -326,7 +326,7 @@ ZSTDCleanup(TIFF* tif) } static int -ZSTDVSetField(TIFF* tif, uint32 tag, va_list ap) +ZSTDVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "ZSTDVSetField"; ZSTDState* sp = LState(tif); @@ -349,7 +349,7 @@ ZSTDVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -ZSTDVGetField(TIFF* tif, uint32 tag, va_list ap) +ZSTDVGetField(TIFF* tif, uint32_t tag, va_list ap) { ZSTDState* sp = LState(tif); @@ -375,6 +375,7 @@ TIFFInitZSTD(TIFF* tif, int scheme) static const char module[] = "TIFFInitZSTD"; ZSTDState* sp; + (void) scheme; assert( scheme == COMPRESSION_ZSTD ); /* @@ -389,7 +390,7 @@ TIFFInitZSTD(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof(ZSTDState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(ZSTDState)); if (tif->tif_data == NULL) goto bad; sp = LState(tif); diff --git a/tiff/libtiff/tiff.h b/tiff/libtiff/tiff.h index 2d4a4767..bd79270c 100644 --- a/tiff/libtiff/tiff.h +++ b/tiff/libtiff/tiff.h @@ -56,24 +56,37 @@ /* * Intrinsic data types required by the file format: * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * 64-bit quantities int64/uint64 + * 8-bit quantities int8_t/uint_8_t + * 16-bit quantities int16_t/uint_16_t + * 32-bit quantities int32_t/uint_32_t + * 64-bit quantities int64_t/uint_64_t * strings unsigned char* */ +#ifdef __GNUC__ +#define TIFF_GCC_DEPRECATED __attribute__((deprecated)) +#else +#define TIFF_GCC_DEPRECATED +#endif +#ifdef _MSC_VER +#define TIFF_MSC_DEPRECATED __declspec(deprecated("libtiff type deprecated; please use corresponding C99 stdint.h type")) +#else +#define TIFF_MSC_DEPRECATED +#endif -typedef TIFF_INT8_T int8; -typedef TIFF_UINT8_T uint8; +#ifndef TIFF_DISABLE_DEPRECATED +typedef TIFF_MSC_DEPRECATED int8_t int8 TIFF_GCC_DEPRECATED; +typedef TIFF_MSC_DEPRECATED uint8_t uint8 TIFF_GCC_DEPRECATED; -typedef TIFF_INT16_T int16; -typedef TIFF_UINT16_T uint16; +typedef TIFF_MSC_DEPRECATED int16_t int16 TIFF_GCC_DEPRECATED; +typedef TIFF_MSC_DEPRECATED uint16_t uint16 TIFF_GCC_DEPRECATED; -typedef TIFF_INT32_T int32; -typedef TIFF_UINT32_T uint32; +typedef TIFF_MSC_DEPRECATED int32_t int32 TIFF_GCC_DEPRECATED; +typedef TIFF_MSC_DEPRECATED uint32_t uint32 TIFF_GCC_DEPRECATED; + +typedef TIFF_MSC_DEPRECATED int64_t int64 TIFF_GCC_DEPRECATED; +typedef TIFF_MSC_DEPRECATED uint64_t uint64 TIFF_GCC_DEPRECATED; +#endif /* TIFF_DISABLE_DEPRECATED */ -typedef TIFF_INT64_T int64; -typedef TIFF_UINT64_T uint64; /* * Some types as promoted in a variable argument list @@ -89,20 +102,20 @@ typedef int uint16_vap; * TIFF header. */ typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ + uint16_t tiff_magic; /* magic number (defines byte order) */ + uint16_t tiff_version; /* TIFF version number */ } TIFFHeaderCommon; typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint32 tiff_diroff; /* byte offset to first directory */ + uint16_t tiff_magic; /* magic number (defines byte order) */ + uint16_t tiff_version; /* TIFF version number */ + uint32_t tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint16 tiff_offsetsize; /* size of offsets, should be 8 */ - uint16 tiff_unused; /* unused word, should be 0 */ - uint64 tiff_diroff; /* byte offset to first directory */ + uint16_t tiff_magic; /* magic number (defines byte order) */ + uint16_t tiff_version; /* TIFF version number */ + uint16_t tiff_offsetsize; /* size of offsets, should be 8 */ + uint16_t tiff_unused; /* unused word, should be 0 */ + uint64_t tiff_diroff; /* byte offset to first directory */ } TIFFHeaderBig; @@ -197,6 +210,7 @@ typedef enum { #define COMPRESSION_LZMA 34925 /* LZMA2 */ #define COMPRESSION_ZSTD 50000 /* ZSTD: WARNING not registered in Adobe-maintained registry */ #define COMPRESSION_WEBP 50001 /* WEBP: WARNING not registered in Adobe-maintained registry */ +#define COMPRESSION_JXL 50002 /* JPEGXL: WARNING not registered in Adobe-maintained registry */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ @@ -465,7 +479,7 @@ typedef enum { #define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ #define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */ /* tags 34908-34914 are private tags registered to SGI */ -#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. parms */ +#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. params */ #define TIFFTAG_FAXSUBADDRESS 34909 /* received SubAddr string */ #define TIFFTAG_FAXRECVTIME 34910 /* receive time (secs) */ #define TIFFTAG_FAXDCS 34911 /* encoded fax ses. params, Table 2/T.30 */ diff --git a/tiff/libtiff/tiffconf.h.cmake.in b/tiff/libtiff/tiffconf.h.cmake.in index 9b4b0328..66ab3541 100644 --- a/tiff/libtiff/tiffconf.h.cmake.in +++ b/tiff/libtiff/tiffconf.h.cmake.in @@ -7,6 +7,12 @@ #ifndef _TIFFCONF_ #define _TIFFCONF_ + +#include <stddef.h> +#include <stdint.h> +#include <inttypes.h> + + /* Signed 16-bit type */ #define TIFF_INT16_T @TIFF_INT16_T@ @@ -31,18 +37,12 @@ /* Unsigned 8-bit type */ #define TIFF_UINT8_T @TIFF_UINT8_T@ -/* Unsigned size type */ -#define TIFF_SIZE_T @TIFF_SIZE_T@ - /* Signed size type */ #define TIFF_SSIZE_T @TIFF_SSIZE_T@ -/* Pointer difference type */ -#define TIFF_PTRDIFF_T @TIFF_PTRDIFF_T@ - /* Compatibility stuff. */ -/* Define as 0 or 1 according to the floating point format suported by the +/* Define as 0 or 1 according to the floating point format supported by the machine */ #cmakedefine HAVE_IEEEFP 1 @@ -62,6 +62,9 @@ /* Support JBIG compression (requires JBIG-KIT library) */ #cmakedefine JBIG_SUPPORT +/* Support LERC compression */ +#cmakedefine LERC_SUPPORT 1 + /* Support LogLuv high dynamic range encoding */ #cmakedefine LOGLUV_SUPPORT 1 @@ -91,7 +94,7 @@ #cmakedefine LIBDEFLATE_SUPPORT 1 /* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ + images to multiple strips of ~8Kb to reduce memory usage) */ #cmakedefine STRIPCHOP_DEFAULT 1 /* Enable SubIFD tag (330) support */ diff --git a/tiff/libtiff/tiffconf.h.in b/tiff/libtiff/tiffconf.h.in index 9bd6a2de..6703eb0e 100644 --- a/tiff/libtiff/tiffconf.h.in +++ b/tiff/libtiff/tiffconf.h.in @@ -7,6 +7,12 @@ #ifndef _TIFFCONF_ #define _TIFFCONF_ + +#include <stddef.h> +#include <stdint.h> +#include <inttypes.h> + + /* Signed 16-bit type */ #undef TIFF_INT16_T @@ -34,12 +40,9 @@ /* Signed size type */ #undef TIFF_SSIZE_T -/* Pointer difference type */ -#undef TIFF_PTRDIFF_T - /* Compatibility stuff. */ -/* Define as 0 or 1 according to the floating point format suported by the +/* Define as 0 or 1 according to the floating point format supported by the machine */ #undef HAVE_IEEEFP @@ -59,6 +62,9 @@ /* Support JBIG compression (requires JBIG-KIT library) */ #undef JBIG_SUPPORT +/* Support LERC compression */ +#undef LERC_SUPPORT + /* Support LogLuv high dynamic range encoding */ #undef LOGLUV_SUPPORT @@ -88,7 +94,7 @@ #undef LIBDEFLATE_SUPPORT /* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ + images to multiple strips of ~8Kb to reduce memory usage) */ #undef STRIPCHOP_DEFAULT /* Enable SubIFD tag (330) support */ diff --git a/tiff/libtiff/tiffconf.vc.h b/tiff/libtiff/tiffconf.vc.h index fb37a755..94f637bf 100644 --- a/tiff/libtiff/tiffconf.vc.h +++ b/tiff/libtiff/tiffconf.vc.h @@ -142,6 +142,84 @@ #define PHOTOSHOP_SUPPORT #define IPTC_SUPPORT + +typedef char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef long long int64_t; +typedef unsigned long long uint64_t; + +#ifndef UINT32_MAX +#define UINT32_MAX 0xFFFFFFFF +#endif + +#ifndef UINT64_MAX +#define UINT64_MAX 0xFFFFFFFFFFFFFFFF +#endif + +#ifndef INT64_MAX +#define INT64_MAX 0x7FFFFFFFFFFFFFFF +#endif + +#ifndef SIZE_MAX +#if _WIN64 +#define SIZE_MAX UINT64_MAX +#else +#define SIZE_MAX UINT32_MAX +#endif +#endif + +#ifndef PRIu8 +#define PRIu8 "u" +#endif + +#ifndef PRId8 +#define PRId8 "d" +#endif + +#ifndef PRIx8 +#define PRIx8 "x" +#endif + +#ifndef PRIu16 +#define PRIu16 "u" +#endif + +#ifndef PRId16 +#define PRId16 "d" +#endif + +#ifndef PRIx16 +#define PRIx16 "x" +#endif + +#ifndef PRIu32 +#define PRIu32 "u" +#endif + +#ifndef PRId32 +#define PRId32 "d" +#endif + +#ifndef PRIx32 +#define PRIx32 "x" +#endif + +#ifndef PRIu64 +#define PRIu64 "llu" +#endif + +#ifndef PRId64 +#define PRId64 "lld" +#endif + +#ifndef PRIx64 +#define PRIx64 "llx" +#endif + #endif /* _TIFFCONF_ */ /* * Local Variables: diff --git a/tiff/libtiff/tiffconf.wince.h b/tiff/libtiff/tiffconf.wince.h deleted file mode 100644 index 013b0960..00000000 --- a/tiff/libtiff/tiffconf.wince.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Windows CE platform tiffconf.wince.h - * Created by Mateusz Loskot (mateusz@loskot.net) - * - * NOTE: Requires WCELIBCEX library with wceex_* functions, - * It's an extension to C library on Windows CE platform. - * For example, HAVE_STDIO_H definition indicates there are - * following files available: - * stdio.h - from Windows CE / Windows Mobile SDK - * wce_stdio.h - from WCELIBCEX library - */ - - -/* - Configuration defines for installed libtiff. - This file maintained for backward compatibility. Do not use definitions - from this file in your programs. -*/ - -#ifndef _WIN32_WCE -# error This version of tif_config.h header is dedicated for Windows CE platform! -#endif - - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* Compatibility stuff. */ - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#define HOST_BIGENDIAN 0 - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Support JPEG compression (requires IJG JPEG library) */ -/* #undef JPEG_SUPPORT */ - -/* Support LogLuv high dynamic range encoding */ -#define LOGLUV_SUPPORT 1 - -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 - -/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation - fails with unpatched IJG JPEG library) */ -/* #undef OJPEG_SUPPORT */ - -/* Support Macintosh PackBits algorithm */ -#define PACKBITS_SUPPORT 1 - -/* Support Pixar log-format algorithm (requires Zlib) */ -/* #undef PIXARLOG_SUPPORT */ - -/* Support ThunderScan 4-bit RLE algorithm */ -#define THUNDER_SUPPORT 1 - -/* Support Deflate compression */ -/* #undef ZIP_SUPPORT */ - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP - -/* Enable SubIFD tag (330) support */ -#define SUBIFD_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 - -/* - * Feature support definitions. - * XXX: These macros are obsoleted. Don't use them in your apps! - * Macros stays here for backward compatibility and should be always defined. - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT - -#endif /* _TIFFCONF_ */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/tiff/libtiff/tiffio.h b/tiff/libtiff/tiffio.h index a4512434..ba6b853b 100644 --- a/tiff/libtiff/tiffio.h +++ b/tiff/libtiff/tiffio.h @@ -60,16 +60,18 @@ typedef struct tiff TIFF; */ /* * this is the machine addressing size type, only it's signed, so make it - * int32 on 32bit machines, int64 on 64bit machines + * int32_t on 32bit machines, int64_t on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; -typedef uint64 toff_t; /* file offset */ +#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1) + +typedef uint64_t toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ -typedef uint32 ttag_t; /* directory tag */ -typedef uint16 tdir_t; /* directory index */ -typedef uint16 tsample_t; /* sample number */ -typedef uint32 tstrile_t; /* strip or tile number */ +typedef uint32_t ttag_t; /* directory tag */ +typedef uint16_t tdir_t; /* directory index */ +typedef uint16_t tsample_t; /* sample number */ +typedef uint32_t tstrile_t; /* strip or tile number */ typedef tstrile_t tstrip_t; /* strip number */ typedef tstrile_t ttile_t; /* tile number */ typedef tmsize_t tsize_t; /* i/o size in bytes */ @@ -140,9 +142,9 @@ typedef struct { float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ - uint32 d_Vrwg; - uint32 d_Vrwb; + uint32_t d_Vrwr; /* Pixel values for ref. white */ + uint32_t d_Vrwg; + uint32_t d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; @@ -155,9 +157,9 @@ typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; + int32_t* Cr_g_tab; + int32_t* Cb_g_tab; + int32_t* Y_tab; } TIFFYCbCrToRGB; typedef struct { /* CIE Lab 1976->RGB support */ @@ -186,11 +188,11 @@ typedef struct _TIFFRGBAImage TIFFRGBAImage; * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*); + (TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, int32_t, + unsigned char*); typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); + (TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, int32_t, + unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ @@ -199,18 +201,18 @@ struct _TIFFRGBAImage { int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 req_orientation; /* requested orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap palette */ - uint16* greencmap; - uint16* bluecmap; + uint32_t width; /* image width */ + uint32_t height; /* image height */ + uint16_t bitspersample; /* image bits/sample */ + uint16_t samplesperpixel; /* image samples/pixel */ + uint16_t orientation; /* image orientation */ + uint16_t req_orientation; /* requested orientation */ + uint16_t photometric; /* image photometric interp */ + uint16_t* redcmap; /* colormap palette */ + uint16_t* greencmap; + uint16_t* bluecmap; /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); + int (*get)(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); /* put decoded strip/tile */ union { void (*any)(TIFFRGBAImage*); @@ -218,13 +220,13 @@ struct _TIFFRGBAImage { tileSeparateRoutine separate; } put; TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ + uint32_t** BWmap; /* black&white map */ + uint32_t** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - uint8* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ - uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ + uint8_t* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ + uint8_t* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ int row_offset; int col_offset; @@ -249,7 +251,7 @@ struct _TIFFRGBAImage { typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; - uint16 scheme; + uint16_t scheme; TIFFInitMethod init; } TIFFCodec; @@ -282,10 +284,10 @@ typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); -extern const TIFFCodec* TIFFFindCODEC(uint16); -extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); +extern const TIFFCodec* TIFFFindCODEC(uint16_t); +extern TIFFCodec* TIFFRegisterCODEC(uint16_t, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); -extern int TIFFIsCODECConfigured(uint16); +extern int TIFFIsCODECConfigured(uint16_t); extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* @@ -304,31 +306,31 @@ extern void _TIFFfree(void* p); ** Stuff, related to tag handling and creating custom tags. */ extern int TIFFGetTagListCount( TIFF * ); -extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); +extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index ); #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ +#define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */ #define FIELD_CUSTOM 65 typedef struct _TIFFField TIFFField; typedef struct _TIFFFieldArray TIFFFieldArray; -extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); -extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); +extern const TIFFField* TIFFFindField(TIFF *, uint32_t, TIFFDataType); +extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32_t); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); -extern uint32 TIFFFieldTag(const TIFFField*); +extern uint32_t TIFFFieldTag(const TIFFField*); extern const char* TIFFFieldName(const TIFFField*); extern TIFFDataType TIFFFieldDataType(const TIFFField*); extern int TIFFFieldPassCount(const TIFFField*); extern int TIFFFieldReadCount(const TIFFField*); extern int TIFFFieldWriteCount(const TIFFField*); -typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); +typedef int (*TIFFVSetMethod)(TIFF*, uint32_t, va_list); +typedef int (*TIFFVGetMethod)(TIFF*, uint32_t, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef struct { @@ -345,32 +347,32 @@ extern void TIFFCleanup(TIFF* tif); extern void TIFFClose(TIFF* tif); extern int TIFFFlush(TIFF* tif); extern int TIFFFlushData(TIFF* tif); -extern int TIFFGetField(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); -extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); +extern int TIFFGetField(TIFF* tif, uint32_t tag, ...); +extern int TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap); +extern int TIFFGetFieldDefaulted(TIFF* tif, uint32_t tag, ...); +extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32_t tag, va_list ap); extern int TIFFReadDirectory(TIFF* tif); extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); extern int TIFFReadGPSDirectory(TIFF* tif, toff_t diroff); -extern uint64 TIFFScanlineSize64(TIFF* tif); +extern uint64_t TIFFScanlineSize64(TIFF* tif); extern tmsize_t TIFFScanlineSize(TIFF* tif); -extern uint64 TIFFRasterScanlineSize64(TIFF* tif); +extern uint64_t TIFFRasterScanlineSize64(TIFF* tif); extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); -extern uint64 TIFFStripSize64(TIFF* tif); +extern uint64_t TIFFStripSize64(TIFF* tif); extern tmsize_t TIFFStripSize(TIFF* tif); -extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); -extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); -extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); -extern uint64 TIFFTileRowSize64(TIFF* tif); +extern uint64_t TIFFRawStripSize64(TIFF* tif, uint32_t strip); +extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32_t strip); +extern uint64_t TIFFVStripSize64(TIFF* tif, uint32_t nrows); +extern tmsize_t TIFFVStripSize(TIFF* tif, uint32_t nrows); +extern uint64_t TIFFTileRowSize64(TIFF* tif); extern tmsize_t TIFFTileRowSize(TIFF* tif); -extern uint64 TIFFTileSize64(TIFF* tif); +extern uint64_t TIFFTileSize64(TIFF* tif); extern tmsize_t TIFFTileSize(TIFF* tif); -extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); -extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); -extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); +extern uint64_t TIFFVTileSize64(TIFF* tif, uint32_t nrows); +extern tmsize_t TIFFVTileSize(TIFF* tif, uint32_t nrows); +extern uint32_t TIFFDefaultStripSize(TIFF* tif, uint32_t request); +extern void TIFFDefaultTileSize(TIFF*, uint32_t*, uint32_t*); extern int TIFFFileno(TIFF*); extern int TIFFSetFileno(TIFF*, int); extern thandle_t TIFFClientdata(TIFF*); @@ -389,12 +391,12 @@ extern TIFFCloseProc TIFFGetCloseProc(TIFF*); extern TIFFSizeProc TIFFGetSizeProc(TIFF*); extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); -extern uint32 TIFFCurrentRow(TIFF*); -extern uint16 TIFFCurrentDirectory(TIFF*); -extern uint16 TIFFNumberOfDirectories(TIFF*); -extern uint64 TIFFCurrentDirOffset(TIFF*); -extern uint32 TIFFCurrentStrip(TIFF*); -extern uint32 TIFFCurrentTile(TIFF* tif); +extern uint32_t TIFFCurrentRow(TIFF*); +extern uint16_t TIFFCurrentDirectory(TIFF*); +extern uint16_t TIFFNumberOfDirectories(TIFF*); +extern uint64_t TIFFCurrentDirOffset(TIFF*); +extern uint32_t TIFFCurrentStrip(TIFF*); +extern uint32_t TIFFCurrentTile(TIFF* tif); extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFSetupStrips(TIFF *); @@ -405,14 +407,14 @@ extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFCreateGPSDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, uint16); -extern int TIFFSetSubDirectory(TIFF*, uint64); -extern int TIFFUnlinkDirectory(TIFF*, uint16); -extern int TIFFSetField(TIFF*, uint32, ...); -extern int TIFFVSetField(TIFF*, uint32, va_list); -extern int TIFFUnsetField(TIFF*, uint32); +extern int TIFFSetDirectory(TIFF*, uint16_t); +extern int TIFFSetSubDirectory(TIFF*, uint64_t); +extern int TIFFUnlinkDirectory(TIFF*, uint16_t); +extern int TIFFSetField(TIFF*, uint32_t, ...); +extern int TIFFVSetField(TIFF*, uint32_t, va_list); +extern int TIFFUnsetField(TIFF*, uint32_t); extern int TIFFWriteDirectory(TIFF *); -extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); +extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); extern int TIFFDeferStrileArrayWriting(TIFF *); @@ -423,26 +425,26 @@ extern void TIFFSetJpegMemFunction(TIFF *, void *(*fn)(thandle_t)); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, +extern int TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample = 0); +extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample = 0); +extern int TIFFReadRGBAImage(TIFF*, uint32_t, uint32_t, uint32_t*, int = 0); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32_t, uint32_t, uint32_t*, int = ORIENTATION_BOTLEFT, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); +extern int TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample); +extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample); +extern int TIFFReadRGBAImage(TIFF*, uint32_t, uint32_t, uint32_t*, int); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32_t, uint32_t, uint32_t*, int, int); #endif -extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); -extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error ); -extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error ); +extern int TIFFReadRGBAStrip(TIFF*, uint32_t, uint32_t * ); +extern int TIFFReadRGBATile(TIFF*, uint32_t, uint32_t, uint32_t * ); +extern int TIFFReadRGBAStripExt(TIFF*, uint32_t, uint32_t *, int stop_on_error ); +extern int TIFFReadRGBATileExt(TIFF*, uint32_t, uint32_t, uint32_t *, int stop_on_error ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); +extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); # ifdef __WIN32__ @@ -466,44 +468,44 @@ extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFNumberOfTiles(TIFF*); -extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); -extern uint32 TIFFNumberOfStrips(TIFF*); -extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile, +extern uint32_t TIFFComputeTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s); +extern int TIFFCheckTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s); +extern uint32_t TIFFNumberOfTiles(TIFF*); +extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s); +extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s); +extern uint32_t TIFFComputeStrip(TIFF*, uint32_t, uint16_t); +extern uint32_t TIFFNumberOfStrips(TIFF*); +extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size); +extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size); +extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size); +extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size); +extern int TIFFReadFromUserBuffer(TIFF* tif, uint32_t strile, void* inbuf, tmsize_t insize, void* outbuf, tmsize_t outsize); -extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); -extern void TIFFSwabShort(uint16*); -extern void TIFFSwabLong(uint32*); -extern void TIFFSwabLong8(uint64*); +extern void TIFFSwabShort(uint16_t*); +extern void TIFFSwabLong(uint32_t*); +extern void TIFFSwabLong8(uint64_t*); extern void TIFFSwabFloat(float*); extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); -extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); -extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); -extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); +extern void TIFFSwabArrayOfShort(uint16_t* wp, tmsize_t n); +extern void TIFFSwabArrayOfTriples(uint8_t* tp, tmsize_t n); +extern void TIFFSwabArrayOfLong(uint32_t* lp, tmsize_t n); +extern void TIFFSwabArrayOfLong8(uint64_t* lp, tmsize_t n); extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); -extern void TIFFReverseBits(uint8* cp, tmsize_t n); +extern void TIFFReverseBits(uint8_t* cp, tmsize_t n); extern const unsigned char* TIFFGetBitRevTable(int); -extern uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile); -extern uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile); -extern uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr); -extern uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr); +extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile); +extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile); +extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile, int *pbErr); +extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile, int *pbErr); #ifdef LOGLUV_PUBLIC #define U_NEU 0.210526316 @@ -511,34 +513,34 @@ extern uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr #define UVSCALE 410. extern double LogL16toY(int); extern double LogL10toY(int); -extern void XYZtoRGB24(float*, uint8*); +extern void XYZtoRGB24(float*, uint8_t*); extern int uv_decode(double*, double*, int); -extern void LogLuv24toXYZ(uint32, float*); -extern void LogLuv32toXYZ(uint32, float*); +extern void LogLuv24toXYZ(uint32_t, float*); +extern void LogLuv32toXYZ(uint32_t, float*); #if defined(c_plusplus) || defined(__cplusplus) extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); +extern uint32_t LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); +extern uint32_t LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); #else extern int LogL16fromY(double, int); extern int LogL10fromY(double, int); extern int uv_encode(double, double, int); -extern uint32 LogLuv24fromXYZ(float*, int); -extern uint32 LogLuv32fromXYZ(float*, int); +extern uint32_t LogLuv24fromXYZ(float*, int); +extern uint32_t LogLuv32fromXYZ(float*, int); #endif #endif /* LOGLUV_PUBLIC */ extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); -extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, - float *, float *, float *); +extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t, + float *, float *, float *); extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, - uint32 *, uint32 *, uint32 *); + uint32_t *, uint32_t *, uint32_t *); extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); -extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, - uint32 *, uint32 *, uint32 *); +extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t, + uint32_t *, uint32_t *, uint32_t *); /**************************************************************************** * O B S O L E T E D I N T E R F A C E S @@ -557,7 +559,7 @@ typedef struct { char *field_name; /* ASCII name */ } TIFFFieldInfo; -extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); +extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32_t); #if defined(c_plusplus) || defined(__cplusplus) } diff --git a/tiff/libtiff/tiffiop.h b/tiff/libtiff/tiffiop.h index b22acb3c..907c05f4 100644 --- a/tiff/libtiff/tiffiop.h +++ b/tiff/libtiff/tiffiop.h @@ -38,9 +38,7 @@ # include <sys/types.h> #endif -#ifdef HAVE_STRING_H -# include <string.h> -#endif +#include <string.h> #ifdef HAVE_ASSERT_H # include <assert.h> @@ -48,19 +46,6 @@ # define assert(x) #endif -#ifdef HAVE_SEARCH_H -# include <search.h> -#else -extern void *lfind(const void *, const void *, size_t *, size_t, - int (*)(const void *, const void *)); -#endif - -#if !defined(HAVE_SNPRINTF) && !defined(HAVE__SNPRINTF) -#undef snprintf -#define snprintf _TIFF_snprintf_f -extern int snprintf(char* str, size_t size, const char* format, ...); -#endif - #include "tiffio.h" #include "tif_dir.h" @@ -77,19 +62,6 @@ extern int snprintf(char* str, size_t size, const char* format, ...); #define FALSE 0 #endif -#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0)) -#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1) - -/* - * Largest 32-bit unsigned integer value. - */ -#define TIFF_UINT32_MAX 0xFFFFFFFFU - -/* - * Largest 64-bit unsigned integer value. - */ -#define TIFF_UINT64_MAX (((uint64)(TIFF_UINT32_MAX)) << 32 | TIFF_UINT32_MAX) - typedef struct client_info { struct client_info *next; void *data; @@ -105,18 +77,18 @@ typedef tidataval_t* tidata_t; /* reference to internal image data */ typedef void (*TIFFVoidMethod)(TIFF*); typedef int (*TIFFBoolMethod)(TIFF*); -typedef int (*TIFFPreMethod)(TIFF*, uint16); -typedef int (*TIFFCodeMethod)(TIFF* tif, uint8* buf, tmsize_t size, uint16 sample); -typedef int (*TIFFSeekMethod)(TIFF*, uint32); -typedef void (*TIFFPostMethod)(TIFF* tif, uint8* buf, tmsize_t size); -typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); -typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); +typedef int (*TIFFPreMethod)(TIFF*, uint16_t); +typedef int (*TIFFCodeMethod)(TIFF* tif, uint8_t* buf, tmsize_t size, uint16_t sample); +typedef int (*TIFFSeekMethod)(TIFF*, uint32_t); +typedef void (*TIFFPostMethod)(TIFF* tif, uint8_t* buf, tmsize_t size); +typedef uint32_t (*TIFFStripMethod)(TIFF*, uint32_t); +typedef void (*TIFFTileMethod)(TIFF*, uint32_t*, uint32_t*); struct tiff { char* tif_name; /* name of open file */ int tif_fd; /* open file descriptor */ int tif_mode; /* open mode (O_*) */ - uint32 tif_flags; + uint32_t tif_flags; #define TIFF_FILLORDER 0x00003U /* natural bit fill order for machine */ #define TIFF_DIRTYHEADER 0x00004U /* header must be written on close */ #define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */ @@ -143,11 +115,11 @@ struct tiff { #define TIFF_DEFERSTRILELOAD 0x1000000U /* defer strip/tile offset/bytecount array loading. */ #define TIFF_LAZYSTRILELOAD 0x2000000U /* lazy/ondemand loading of strip/tile offset/bytecount values. Only used if TIFF_DEFERSTRILELOAD is set and in read-only mode */ #define TIFF_CHOPPEDUPARRAYS 0x4000000U /* set when allocChoppedUpStripArrays() has modified strip array */ - uint64 tif_diroff; /* file offset of current directory */ - uint64 tif_nextdiroff; /* file offset of following directory */ - uint64* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */ - uint16 tif_dirlistsize; /* number of entries in offset list */ - uint16 tif_dirnumber; /* number of already seen directories */ + uint64_t tif_diroff; /* file offset of current directory */ + uint64_t tif_nextdiroff; /* file offset of following directory */ + uint64_t* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */ + uint16_t tif_dirlistsize; /* number of entries in offset list */ + uint16_t tif_dirnumber; /* number of already seen directories */ TIFFDirectory tif_dir; /* internal rep of current directory */ TIFFDirectory tif_customdir; /* custom IFDs are separated from the main ones */ union { @@ -155,18 +127,18 @@ struct tiff { TIFFHeaderClassic classic; TIFFHeaderBig big; } tif_header; - uint16 tif_header_size; /* file's header block and its length */ - uint32 tif_row; /* current scanline */ - uint16 tif_curdir; /* current directory (index) */ - uint32 tif_curstrip; /* current strip for read/write */ - uint64 tif_curoff; /* current offset for read/write */ - uint64 tif_dataoff; /* current offset for writing dir */ + uint16_t tif_header_size; /* file's header block and its length */ + uint32_t tif_row; /* current scanline */ + uint16_t tif_curdir; /* current directory (index) */ + uint32_t tif_curstrip; /* current strip for read/write */ + uint64_t tif_curoff; /* current offset for read/write */ + uint64_t tif_dataoff; /* current offset for writing dir */ /* SubIFD support */ - uint16 tif_nsubifd; /* remaining subifds to write */ - uint64 tif_subifdoff; /* offset for patching SubIFD link */ + uint16_t tif_nsubifd; /* remaining subifds to write */ + uint64_t tif_subifdoff; /* offset for patching SubIFD link */ /* tiling support */ - uint32 tif_col; /* current column (offset by row too) */ - uint32 tif_curtile; /* current tile for read/write */ + uint32_t tif_col; /* current column (offset by row too) */ + uint32_t tif_curtile; /* current tile for read/write */ tmsize_t tif_tilesize; /* # of bytes in a tile */ /* compression scheme hooks */ int tif_decodestatus; @@ -188,18 +160,18 @@ struct tiff { TIFFVoidMethod tif_cleanup; /* cleanup state routine */ TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */ TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */ - uint8* tif_data; /* compression scheme private data */ + uint8_t* tif_data; /* compression scheme private data */ /* input/output buffering */ tmsize_t tif_scanlinesize; /* # of bytes in a scanline */ tmsize_t tif_scanlineskew; /* scanline skew for reading strips */ - uint8* tif_rawdata; /* raw data buffer */ + uint8_t* tif_rawdata; /* raw data buffer */ tmsize_t tif_rawdatasize; /* # of bytes in raw data buffer */ tmsize_t tif_rawdataoff; /* rawdata offset within strip */ tmsize_t tif_rawdataloaded;/* amount of data in rawdata */ - uint8* tif_rawcp; /* current spot in raw buffer */ + uint8_t* tif_rawcp; /* current spot in raw buffer */ tmsize_t tif_rawcc; /* bytes unread from raw buffer */ /* memory-mapped file support */ - uint8* tif_base; /* base of mapped file */ + uint8_t* tif_base; /* base of mapped file */ tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */ TIFFMapFileProc tif_mapproc; /* map file method */ TIFFUnmapFileProc tif_unmapproc; /* unmap file method */ @@ -261,18 +233,18 @@ struct tiff { (TIFFWriteFile((tif),(buf),(size))==(size)) #endif -/* NB: the uint32 casts are to silence certain ANSI-C compilers */ -#define TIFFhowmany_32(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \ - ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \ +/* NB: the uint32_t casts are to silence certain ANSI-C compilers */ +#define TIFFhowmany_32(x, y) (((uint32_t)x < (0xffffffff - (uint32_t)(y-1))) ? \ + ((((uint32_t)(x))+(((uint32_t)(y))-1))/((uint32_t)(y))) : \ 0U) /* Variant of TIFFhowmany_32() that doesn't return 0 if x close to MAXUINT. */ /* Caution: TIFFhowmany_32_maxuint_compat(x,y)*y might overflow */ #define TIFFhowmany_32_maxuint_compat(x, y) \ - (((uint32)(x) / (uint32)(y)) + ((((uint32)(x) % (uint32)(y)) != 0) ? 1 : 0)) -#define TIFFhowmany8_32(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) + (((uint32_t)(x) / (uint32_t)(y)) + ((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0)) +#define TIFFhowmany8_32(x) (((x)&0x07)?((uint32_t)(x)>>3)+1:(uint32_t)(x)>>3) #define TIFFroundup_32(x, y) (TIFFhowmany_32(x,y)*(y)) -#define TIFFhowmany_64(x, y) ((((uint64)(x))+(((uint64)(y))-1))/((uint64)(y))) -#define TIFFhowmany8_64(x) (((x)&0x07)?((uint64)(x)>>3)+1:(uint64)(x)>>3) +#define TIFFhowmany_64(x, y) ((((uint64_t)(x))+(((uint64_t)(y))-1))/((uint64_t)(y))) +#define TIFFhowmany8_64(x) (((x)&0x07)?((uint64_t)(x)>>3)+1:(uint64_t)(x)>>3) #define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y)) /* Safe multiply which returns zero if there is an *unsigned* integer overflow. This macro is not safe for *signed* integer types */ @@ -345,38 +317,38 @@ typedef size_t TIFFIOSize_t; extern "C" { #endif extern int _TIFFgetMode(const char* mode, const char* module); -extern int _TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoTileEncode(TIFF*, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoTileDecode(TIFF*, uint8* pp, tmsize_t cc, uint16 s); -extern void _TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc); -extern int _TIFFNoPreCode(TIFF* tif, uint16 s); -extern int _TIFFNoSeek(TIFF* tif, uint32 off); -extern void _TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc); -extern void _TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc); -extern void _TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc); -extern void _TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc); +extern int _TIFFNoRowEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoStripEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoTileEncode(TIFF*, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoRowDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoStripDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoTileDecode(TIFF*, uint8_t* pp, tmsize_t cc, uint16_t s); +extern void _TIFFNoPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc); +extern int _TIFFNoPreCode(TIFF* tif, uint16_t s); +extern int _TIFFNoSeek(TIFF* tif, uint32_t off); +extern void _TIFFSwab16BitData(TIFF* tif, uint8_t* buf, tmsize_t cc); +extern void _TIFFSwab24BitData(TIFF* tif, uint8_t* buf, tmsize_t cc); +extern void _TIFFSwab32BitData(TIFF* tif, uint8_t* buf, tmsize_t cc); +extern void _TIFFSwab64BitData(TIFF* tif, uint8_t* buf, tmsize_t cc); extern int TIFFFlushData1(TIFF* tif); extern int TIFFDefaultDirectory(TIFF* tif); extern void _TIFFSetDefaultCompressionState(TIFF* tif); -extern int _TIFFRewriteField(TIFF *, uint16, TIFFDataType, tmsize_t, void *); +extern int _TIFFRewriteField(TIFF *, uint16_t, TIFFDataType, tmsize_t, void *); extern int TIFFSetCompressionScheme(TIFF* tif, int scheme); extern int TIFFSetDefaultCompressionState(TIFF* tif); -extern uint32 _TIFFDefaultStripSize(TIFF* tif, uint32 s); -extern void _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th); +extern uint32_t _TIFFDefaultStripSize(TIFF* tif, uint32_t s); +extern void _TIFFDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th); extern int _TIFFDataSize(TIFFDataType type); /*--: Rational2Double: Return size of TIFFSetGetFieldType in bytes. */ extern int _TIFFSetGetFieldSize(TIFFSetGetFieldType setgettype); -extern void _TIFFsetByteArray(void**, void*, uint32); +extern void _TIFFsetByteArray(void**, void*, uint32_t); extern void _TIFFsetString(char**, char*); -extern void _TIFFsetShortArray(uint16**, uint16*, uint32); -extern void _TIFFsetLongArray(uint32**, uint32*, uint32); -extern void _TIFFsetFloatArray(float**, float*, uint32); -extern void _TIFFsetDoubleArray(double**, double*, uint32); +extern void _TIFFsetShortArray(uint16_t**, uint16_t*, uint32_t); +extern void _TIFFsetLongArray(uint32_t**, uint32_t*, uint32_t); +extern void _TIFFsetFloatArray(float**, float*, uint32_t); +extern void _TIFFsetDoubleArray(double**, double*, uint32_t); extern void _TIFFprintAscii(FILE*, const char*); extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); @@ -386,30 +358,30 @@ extern TIFFErrorHandler _TIFFerrorHandler; extern TIFFErrorHandlerExt _TIFFwarningHandlerExt; extern TIFFErrorHandlerExt _TIFFerrorHandlerExt; -extern uint32 _TIFFMultiply32(TIFF*, uint32, uint32, const char*); -extern uint64 _TIFFMultiply64(TIFF*, uint64, uint64, const char*); +extern uint32_t _TIFFMultiply32(TIFF*, uint32_t, uint32_t, const char*); +extern uint64_t _TIFFMultiply64(TIFF*, uint64_t, uint64_t, const char*); extern tmsize_t _TIFFMultiplySSize(TIFF*, tmsize_t, tmsize_t, const char*); -extern tmsize_t _TIFFCastUInt64ToSSize(TIFF*, uint64, const char*); +extern tmsize_t _TIFFCastUInt64ToSSize(TIFF*, uint64_t, const char*); extern void* _TIFFCheckMalloc(TIFF*, tmsize_t, tmsize_t, const char*); extern void* _TIFFCheckRealloc(TIFF*, void*, tmsize_t, tmsize_t, const char*); -extern double _TIFFUInt64ToDouble(uint64); -extern float _TIFFUInt64ToFloat(uint64); +extern double _TIFFUInt64ToDouble(uint64_t); +extern float _TIFFUInt64ToFloat(uint64_t); extern float _TIFFClampDoubleToFloat(double); extern tmsize_t -_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip, +_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32_t strip, void **buf, tmsize_t bufsizetoalloc, tmsize_t size_to_read); extern tmsize_t -_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, - void **buf, tmsize_t bufsizetoalloc, - tmsize_t size_to_read); +_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32_t tile, + void **buf, tmsize_t bufsizetoalloc, + tmsize_t size_to_read); extern tmsize_t _TIFFReadTileAndAllocBuffer(TIFF* tif, void **buf, tmsize_t bufsizetoalloc, - uint32 x, uint32 y, uint32 z, uint16 s); + uint32_t x, uint32_t y, uint32_t z, uint16_t s); extern int _TIFFSeekOK(TIFF* tif, toff_t off); extern int TIFFInitDumpMode(TIFF*, int); @@ -448,6 +420,9 @@ extern int TIFFInitPixarLog(TIFF*, int); #ifdef LOGLUV_SUPPORT extern int TIFFInitSGILog(TIFF*, int); #endif +#ifdef LERC_SUPPORT +extern int TIFFInitLERC(TIFF* tif, int); +#endif #ifdef LZMA_SUPPORT extern int TIFFInitLZMA(TIFF*, int); #endif @@ -457,11 +432,7 @@ extern int TIFFInitZSTD(TIFF*, int); #ifdef WEBP_SUPPORT extern int TIFFInitWebP(TIFF*, int); #endif -#ifdef VMS extern const TIFFCodec _TIFFBuiltinCODECS[]; -#else -extern TIFFCodec _TIFFBuiltinCODECS[]; -#endif #if defined(__cplusplus) } diff --git a/tiff/libtiff/tiffvers.h b/tiff/libtiff/tiffvers.h index 0cce798b..dbe55961 100644 --- a/tiff/libtiff/tiffvers.h +++ b/tiff/libtiff/tiffvers.h @@ -1,4 +1,4 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.2.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.3.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a @@ -6,4 +6,4 @@ * version checking should be done based on the * string returned by TIFFGetVersion. */ -#define TIFFLIB_VERSION 20201219 +#define TIFFLIB_VERSION 20210416 diff --git a/tiff/m4/libtool.m4 b/tiff/m4/libtool.m4 index a3bc337b..a6d21ae5 100644 --- a/tiff/m4/libtool.m4 +++ b/tiff/m4/libtool.m4 @@ -728,7 +728,6 @@ _LT_CONFIG_SAVE_COMMANDS([ cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. @@ -1042,8 +1041,8 @@ int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$AR cr libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cr libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF @@ -1493,7 +1492,7 @@ need_locks=$enable_libtool_lock m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} -: ${AR_FLAGS=cru} +: ${AR_FLAGS=cr} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) @@ -2887,6 +2886,18 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) dynamic_linker='GNU/Linux ld.so' ;; +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + netbsd*) version_type=sunos need_lib_prefix=no @@ -3546,7 +3557,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; -netbsd*) +netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else @@ -4052,7 +4063,8 @@ _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD + if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" @@ -4424,7 +4436,7 @@ m4_if([$1], [CXX], [ ;; esac ;; - netbsd*) + netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise @@ -4692,6 +4704,12 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; + # flang / f18. f95 an alias for gfortran or flang on Debian + flang* | f18* | f95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) @@ -4936,6 +4954,9 @@ m4_if([$1], [CXX], [ ;; esac ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; @@ -4998,6 +5019,9 @@ dnl Note also adjust exclude_expsyms for C++ above. openbsd* | bitrig*) with_gnu_ld=no ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes @@ -5252,7 +5276,7 @@ _LT_EOF fi ;; - netbsd*) + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= @@ -5773,6 +5797,7 @@ _LT_EOF if test yes = "$lt_cv_irix_exported_symbol"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi + _LT_TAGVAR(link_all_deplibs, $1)=no else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' @@ -5794,7 +5819,7 @@ _LT_EOF esac ;; - netbsd*) + netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else @@ -6420,7 +6445,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else GXX=no @@ -6795,7 +6820,7 @@ if test yes != "$_lt_caught_CXX_error"; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -6860,7 +6885,7 @@ if test yes != "$_lt_caught_CXX_error"; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -7199,7 +7224,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # FIXME: insert proper C++ library support @@ -7283,7 +7308,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. @@ -7294,7 +7319,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' diff --git a/tiff/man/CMakeLists.txt b/tiff/man/CMakeLists.txt index be5e2949..ea2998d1 100644 --- a/tiff/man/CMakeLists.txt +++ b/tiff/man/CMakeLists.txt @@ -93,5 +93,3 @@ install(FILES ${man1_MANS} DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1") install(FILES ${man3_MANS} DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man3") - -extra_dist(${man1_MANS} ${man3_MANS}) diff --git a/tiff/man/Makefile.in b/tiff/man/Makefile.in index 4568bfe7..0ca917e1 100644 --- a/tiff/man/Makefile.in +++ b/tiff/man/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -122,8 +122,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) @@ -320,6 +322,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/man/TIFFDataWidth.3tiff b/tiff/man/TIFFDataWidth.3tiff index efcd39d7..d69cd115 100644 --- a/tiff/man/TIFFDataWidth.3tiff +++ b/tiff/man/TIFFDataWidth.3tiff @@ -65,7 +65,7 @@ Currently following data types are supported: .br .IR TIFFDataWidth returns a number of bytes occupied by the item of given type. 0 returned when -uknown data type supplied. +unknown data type supplied. .SH "SEE ALSO" .BR libtiff (3TIFF), .PP diff --git a/tiff/man/TIFFFieldPassCount.3tiff b/tiff/man/TIFFFieldPassCount.3tiff index ff14c520..45018573 100644 --- a/tiff/man/TIFFFieldPassCount.3tiff +++ b/tiff/man/TIFFFieldPassCount.3tiff @@ -48,13 +48,13 @@ or When a .I count is required, it will be of type -.BR uint32 +.BR uint32_t when .BR TIFFFieldReadCount reports .BR TIFF_VARIABLE2 , and of type -.BR uint16 +.BR uint16_t otherwise. (This distinction is critical for use of .BR TIFFGetField , but normally not so for use of diff --git a/tiff/man/TIFFFieldReadCount.3tiff b/tiff/man/TIFFFieldReadCount.3tiff index b6a4546c..80bcc6b3 100644 --- a/tiff/man/TIFFFieldReadCount.3tiff +++ b/tiff/man/TIFFFieldReadCount.3tiff @@ -38,7 +38,7 @@ but there are some special values: .br .BR TIFF_VARIABLE indicates that a variable number of values is possible; then, a -.BR uint16 +.BR uint16_t .I count argument and a pointer .I data @@ -51,7 +51,7 @@ is the same as except that the .I count argument must have type -.BR uint32 . +.BR uint32_t . .br .BR TIFF_SPP indicates that the number of arguments is equal to the image's diff --git a/tiff/man/TIFFFieldTag.3tiff b/tiff/man/TIFFFieldTag.3tiff index 3d1e83d0..2fe41841 100644 --- a/tiff/man/TIFFFieldTag.3tiff +++ b/tiff/man/TIFFFieldTag.3tiff @@ -27,7 +27,7 @@ TIFFFieldTag \- Get TIFF field tag value from field information .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "uint32 TIFFFieldTag(const TIFFField* " fip ")" +.BI "uint32_t TIFFFieldTag(const TIFFField* " fip ")" .SH DESCRIPTION .BR TIFFFieldTag returns the numeric tag value for a TIFF field. diff --git a/tiff/man/TIFFFieldWriteCount.3tiff b/tiff/man/TIFFFieldWriteCount.3tiff index f80290fe..bfc7222c 100644 --- a/tiff/man/TIFFFieldWriteCount.3tiff +++ b/tiff/man/TIFFFieldWriteCount.3tiff @@ -38,7 +38,7 @@ but there are some special values: .br .BR TIFF_VARIABLE indicates that a variable number of values is possible; then, a -.BR uint16 +.BR uint16_t .I count argument and a pointer .I data @@ -51,7 +51,7 @@ is the same as except that the .I count argument must have type -.BR uint32 . +.BR uint32_t . (On most modern machines, this makes no practical difference, and the .I count argument can simply be an diff --git a/tiff/man/TIFFGetField.3tiff b/tiff/man/TIFFGetField.3tiff index 431f4ae9..dc158578 100644 --- a/tiff/man/TIFFGetField.3tiff +++ b/tiff/man/TIFFGetField.3tiff @@ -103,78 +103,78 @@ meaning of each tag and their possible values. \fITag Name\fP \fICount\fP \fITypes\fP \fINotes\fP .sp 5p TIFFTAG_ARTIST 1 const char** -TIFFTAG_BADFAXLINES 1 uint32* -TIFFTAG_BITSPERSAMPLE 1 uint16* -TIFFTAG_CLEANFAXDATA 1 uint16* -TIFFTAG_COLORMAP 3 const uint16** 1<<BitsPerSample arrays -TIFFTAG_COMPRESSION 1 uint16* -TIFFTAG_CONSECUTIVEBADFAXLINES 1 uint32* +TIFFTAG_BADFAXLINES 1 uint32_t* +TIFFTAG_BITSPERSAMPLE 1 uint16_t* +TIFFTAG_CLEANFAXDATA 1 uint16_t* +TIFFTAG_COLORMAP 3 const uint16_t** 1<<BitsPerSample arrays +TIFFTAG_COMPRESSION 1 uint16_t* +TIFFTAG_CONSECUTIVEBADFAXLINES 1 uint32_t* TIFFTAG_COPYRIGHT 1 const char** -TIFFTAG_DATATYPE 1 uint16* +TIFFTAG_DATATYPE 1 uint16_t* TIFFTAG_DATETIME 1 const char** TIFFTAG_DOCUMENTNAME 1 const char** -TIFFTAG_DOTRANGE 2 uint16* -TIFFTAG_EXTRASAMPLES 2 uint16*,const uint16** count & types array +TIFFTAG_DOTRANGE 2 uint16_t* +TIFFTAG_EXTRASAMPLES 2 uint16_t*,const uint16_t** count & types array TIFFTAG_FAXFILLFUNC 1 TIFFFaxFillFunc* G3/G4 compression pseudo-tag TIFFTAG_FAXMODE 1 int* G3/G4 compression pseudo-tag -TIFFTAG_FILLORDER 1 uint16* -TIFFTAG_GROUP3OPTIONS 1 uint32* -TIFFTAG_GROUP4OPTIONS 1 uint32* -TIFFTAG_HALFTONEHINTS 2 uint16* +TIFFTAG_FILLORDER 1 uint16_t* +TIFFTAG_GROUP3OPTIONS 1 uint32_t* +TIFFTAG_GROUP4OPTIONS 1 uint32_t* +TIFFTAG_HALFTONEHINTS 2 uint16_t* TIFFTAG_HOSTCOMPUTER 1 const char** -TIFFTAG_ICCPROFILE 2 const uint32*,const void** count, profile data -TIFFTAG_IMAGEDEPTH 1 uint32* +TIFFTAG_ICCPROFILE 2 const uint32_t*,const void** count, profile data +TIFFTAG_IMAGEDEPTH 1 uint32_t* TIFFTAG_IMAGEDESCRIPTION 1 const char** -TIFFTAG_IMAGELENGTH 1 uint32* -TIFFTAG_IMAGEWIDTH 1 uint32* +TIFFTAG_IMAGELENGTH 1 uint32_t* +TIFFTAG_IMAGEWIDTH 1 uint32_t* TIFFTAG_INKNAMES 1 const char** -TIFFTAG_INKSET 1 uint16* +TIFFTAG_INKSET 1 uint16_t* TIFFTAG_JPEGCOLORMODE 1 int* JPEG pseudo-tag TIFFTAG_JPEGQUALITY 1 int* JPEG pseudo-tag -TIFFTAG_JPEGTABLES 2 uint32*,const void** count & tables +TIFFTAG_JPEGTABLES 2 uint32_t*,const void** count & tables TIFFTAG_JPEGTABLESMODE 1 int* JPEG pseudo-tag TIFFTAG_MAKE 1 const char** -TIFFTAG_MATTEING 1 uint16* -TIFFTAG_MAXSAMPLEVALUE 1 uint16* -TIFFTAG_MINSAMPLEVALUE 1 uint16* +TIFFTAG_MATTEING 1 uint16_t* +TIFFTAG_MAXSAMPLEVALUE 1 uint16_t* +TIFFTAG_MINSAMPLEVALUE 1 uint16_t* TIFFTAG_MODEL 1 const char** -TIFFTAG_ORIENTATION 1 uint16* +TIFFTAG_ORIENTATION 1 uint16_t* TIFFTAG_PAGENAME 1 const char** -TIFFTAG_PAGENUMBER 2 uint16* -TIFFTAG_PHOTOMETRIC 1 uint16* -TIFFTAG_PHOTOSHOP 2 uint32*,const void** count, data -TIFFTAG_PLANARCONFIG 1 uint16* -TIFFTAG_PREDICTOR 1 uint16* +TIFFTAG_PAGENUMBER 2 uint16_t* +TIFFTAG_PHOTOMETRIC 1 uint16_t* +TIFFTAG_PHOTOSHOP 2 uint32_t*,const void** count, data +TIFFTAG_PLANARCONFIG 1 uint16_t* +TIFFTAG_PREDICTOR 1 uint16_t* TIFFTAG_PRIMARYCHROMATICITIES 1 const float** 6-entry array TIFFTAG_REFERENCEBLACKWHITE 1 const float** 6-entry array -TIFFTAG_RESOLUTIONUNIT 1 uint16* -TIFFTAG_RICHTIFFIPTC 2 uint32*,const void** count, data -TIFFTAG_ROWSPERSTRIP 1 uint32* -TIFFTAG_SAMPLEFORMAT 1 uint16* -TIFFTAG_SAMPLESPERPIXEL 1 uint16* +TIFFTAG_RESOLUTIONUNIT 1 uint16_t* +TIFFTAG_RICHTIFFIPTC 2 uint32_t*,const void** count, data +TIFFTAG_ROWSPERSTRIP 1 uint32_t* +TIFFTAG_SAMPLEFORMAT 1 uint16_t* +TIFFTAG_SAMPLESPERPIXEL 1 uint16_t* TIFFTAG_SMAXSAMPLEVALUE 1 double* TIFFTAG_SMINSAMPLEVALUE 1 double* TIFFTAG_SOFTWARE 1 const char** TIFFTAG_STONITS 1 const double** -TIFFTAG_STRIPBYTECOUNTS 1 const uint64** -TIFFTAG_STRIPOFFSETS 1 const uint64** -TIFFTAG_SUBFILETYPE 1 uint32* -TIFFTAG_SUBIFD 2 uint16*,const uint64** count & offsets array +TIFFTAG_STRIPBYTECOUNTS 1 const uint64_t** +TIFFTAG_STRIPOFFSETS 1 const uint64_t** +TIFFTAG_SUBFILETYPE 1 uint32_t* +TIFFTAG_SUBIFD 2 uint16_t*,const uint64_t** count & offsets array TIFFTAG_TARGETPRINTER 1 const char** -TIFFTAG_THRESHHOLDING 1 uint16* -TIFFTAG_TILEBYTECOUNTS 1 const uint64** -TIFFTAG_TILEDEPTH 1 uint32* -TIFFTAG_TILELENGTH 1 uint32* -TIFFTAG_TILEOFFSETS 1 const uint64** -TIFFTAG_TILEWIDTH 1 uint32* -TIFFTAG_TRANSFERFUNCTION 1 or 3\(dg const uint16**1<<BitsPerSample entry arrays +TIFFTAG_THRESHHOLDING 1 uint16_t* +TIFFTAG_TILEBYTECOUNTS 1 const uint64_t** +TIFFTAG_TILEDEPTH 1 uint32_t* +TIFFTAG_TILELENGTH 1 uint32_t* +TIFFTAG_TILEOFFSETS 1 const uint64_t** +TIFFTAG_TILEWIDTH 1 uint32_t* +TIFFTAG_TRANSFERFUNCTION 1 or 3\(dg const uint16_t**1<<BitsPerSample entry arrays TIFFTAG_WHITEPOINT 1 const float** 2-entry array -TIFFTAG_XMLPACKET 2 uint32*,const void** count, data +TIFFTAG_XMLPACKET 2 uint32_t*,const void** count, data TIFFTAG_XPOSITION 1 float* TIFFTAG_XRESOLUTION 1 float* TIFFTAG_YCBCRCOEFFICIENTS 1 const float** 3-entry array -TIFFTAG_YCBCRPOSITIONING 1 uint16* -TIFFTAG_YCBCRSUBSAMPLING 2 uint16* +TIFFTAG_YCBCRPOSITIONING 1 uint16_t* +TIFFTAG_YCBCRSUBSAMPLING 2 uint16_t* TIFFTAG_YPOSITION 1 float* TIFFTAG_YRESOLUTION 1 float*\(dd .fi @@ -196,11 +196,11 @@ and ASCII string from the tag 36867 you can use the following code: .PP .RS .nf -uint32 count; +uint32_t count; void *data; TIFFGetField(tiff, 33424, &count, &data); -printf("Tag %d: %d, count %d\n", 33424, *(uint32 *)data, count); +printf("Tag %d: %d, count %d\n", 33424, *(uint32_t *)data, count); TIFFGetField(tiff, 36867, &count, &data); printf("Tag %d: %s, count %d\n", 36867, (char *)data, count); .fi diff --git a/tiff/man/TIFFRGBAImage.3tiff b/tiff/man/TIFFRGBAImage.3tiff index fe6064fc..2c5f79c4 100644 --- a/tiff/man/TIFFRGBAImage.3tiff +++ b/tiff/man/TIFFRGBAImage.3tiff @@ -36,7 +36,7 @@ TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet, TIFFRGBAImageEnd .br .BI "int TIFFRGBAImageBegin(TIFFRGBAImage *" img ", TIFF* " tif ", int " stopOnError ", char " emsg[1024] ")" .br -.BI "int TIFFRGBAImageGet(TIFFRGBAImage *" img ", uint32* " raster ", uint32 " width " , uint32 " height ")" +.BI "int TIFFRGBAImageGet(TIFFRGBAImage *" img ", uint32_t* " raster ", uint32_t " width " , uint32_t " height ")" .br .BI "void TIFFRGBAImageEnd(TIFFRGBAImage *" img ")" .br @@ -162,9 +162,9 @@ the raster is being filled: .nf .ft C static void -putContigAndDraw(TIFFRGBAImage* img, uint32* raster, - uint32 x, uint32 y, uint32 w, uint32 h, - int32 fromskew, int32 toskew, +putContigAndDraw(TIFFRGBAImage* img, uint32_t* raster, + uint32_t x, uint32_t y, uint32_t w, uint32_t h, + int32_t fromskew, int32_t toskew, unsigned char* cp) { (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp); diff --git a/tiff/man/TIFFReadEncodedStrip.3tiff b/tiff/man/TIFFReadEncodedStrip.3tiff index 05ddefb9..8d1ad6c5 100644 --- a/tiff/man/TIFFReadEncodedStrip.3tiff +++ b/tiff/man/TIFFReadEncodedStrip.3tiff @@ -30,7 +30,7 @@ file .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "tmsize_t TIFFReadEncodedStrip(TIFF *" tif ", uint32 " strip ", void *" buf ", tmsize_t " size ")" +.BI "tmsize_t TIFFReadEncodedStrip(TIFF *" tif ", uint32_t " strip ", void *" buf ", tmsize_t " size ")" .SH DESCRIPTION Read the specified strip of data and place up to .I size diff --git a/tiff/man/TIFFReadRGBAImage.3tiff b/tiff/man/TIFFReadRGBAImage.3tiff index 920fc370..a17f71ed 100644 --- a/tiff/man/TIFFReadRGBAImage.3tiff +++ b/tiff/man/TIFFReadRGBAImage.3tiff @@ -37,9 +37,9 @@ into a fixed-format raster .br .B "#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)" .sp -.BI "int TIFFReadRGBAImage(TIFF *" tif ", uint32 " width ", uint32 " height ", uint32 *" raster ", int " stopOnError ")" +.BI "int TIFFReadRGBAImage(TIFF *" tif ", uint32_t " width ", uint32_t " height ", uint32_t *" raster ", int " stopOnError ")" .br -.BI "int TIFFReadRGBAImageOriented(TIFF *" tif ", uint32 " width ", uint32 " height ", uint32 *" raster ", int " orientation ", int " stopOnError ")" +.BI "int TIFFReadRGBAImageOriented(TIFF *" tif ", uint32_t " width ", uint32_t " height ", uint32_t *" raster ", int " orientation ", int " stopOnError ")" .br .SH DESCRIPTION .IR TIFFReadRGBAImage @@ -109,7 +109,7 @@ transparently. Raster pixels are returned uncorrected by any colorimetry information present in the directory. .PP -The paramater +The parameter .I stopOnError specifies how to act if an error is encountered while reading the image. diff --git a/tiff/man/TIFFReadRGBAStrip.3tiff b/tiff/man/TIFFReadRGBAStrip.3tiff index 31604124..803a99af 100644 --- a/tiff/man/TIFFReadRGBAStrip.3tiff +++ b/tiff/man/TIFFReadRGBAStrip.3tiff @@ -36,7 +36,7 @@ TIFFReadRGBAStrip \- read and decode an image strip into a fixed-format raster .br .B "#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)" .sp -.BI "int TIFFReadRGBAStrip(TIFF *" tif ", uint32 " row ", uint32 *" raster ")" +.BI "int TIFFReadRGBAStrip(TIFF *" tif ", uint32_t " row ", uint32_t *" raster ")" .SH DESCRIPTION .IR TIFFReadRGBAStrip reads a single strip of a strip-based image into memory, storing the result in diff --git a/tiff/man/TIFFReadRGBATile.3tiff b/tiff/man/TIFFReadRGBATile.3tiff index 5b9b4bf2..4ee59180 100644 --- a/tiff/man/TIFFReadRGBATile.3tiff +++ b/tiff/man/TIFFReadRGBATile.3tiff @@ -36,7 +36,7 @@ TIFFReadRGBATile \- read and decode an image tile into a fixed-format raster .br .B "#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)" .sp -.BI "int TIFFReadRGBATile(TIFF *" tif ", uint32 " x ", uint32 " y ", uint32 *" raster ")" +.BI "int TIFFReadRGBATile(TIFF *" tif ", uint32_t " x ", uint32_t " y ", uint32_t *" raster ")" .SH DESCRIPTION .IR TIFFReadRGBATile reads a single tile of a tile-based image into memory, storing the result in diff --git a/tiff/man/TIFFReadScanline.3tiff b/tiff/man/TIFFReadScanline.3tiff index ca4b8368..9a61fc85 100644 --- a/tiff/man/TIFFReadScanline.3tiff +++ b/tiff/man/TIFFReadScanline.3tiff @@ -30,7 +30,7 @@ file .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "int TIFFReadScanline(TIFF *" tif ", tdata_t " buf ", uint32 " row ", tsample_t " sample ")" +.BI "int TIFFReadScanline(TIFF *" tif ", tdata_t " buf ", uint32_t " row ", tsample_t " sample ")" .SH DESCRIPTION Read the data for the specified row into the (user supplied) data buffer .IR buf . diff --git a/tiff/man/TIFFReadTile.3tiff b/tiff/man/TIFFReadTile.3tiff index cf0f21dc..5bfbbd36 100644 --- a/tiff/man/TIFFReadTile.3tiff +++ b/tiff/man/TIFFReadTile.3tiff @@ -30,7 +30,7 @@ file .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "tsize_t TIFFReadTile(TIFF *" tif ", tdata_t " buf ", uint32 " x ", uint32 " y ", uint32 " z ", tsample_t " sample ")" +.BI "tsize_t TIFFReadTile(TIFF *" tif ", tdata_t " buf ", uint32_t " x ", uint32_t " y ", uint32_t " z ", tsample_t " sample ")" .SH DESCRIPTION Return the data for the tile .I containing diff --git a/tiff/man/TIFFSetDirectory.3tiff b/tiff/man/TIFFSetDirectory.3tiff index 734c0155..d5b49908 100644 --- a/tiff/man/TIFFSetDirectory.3tiff +++ b/tiff/man/TIFFSetDirectory.3tiff @@ -32,7 +32,7 @@ file .sp .BI "int TIFFSetDirectory(TIFF *" tif ", tdir_t " dirnum ")" .br -.BI "int TIFFSetSubDirectory(TIFF *" tif ", uint64 " diroff ")" +.BI "int TIFFSetSubDirectory(TIFF *" tif ", uint64_t " diroff ")" .SH DESCRIPTION .I TIFFSetDirectory changes the current directory and reads its contents with diff --git a/tiff/man/TIFFSetField.3tiff b/tiff/man/TIFFSetField.3tiff index df2a5ea2..f614e075 100644 --- a/tiff/man/TIFFSetField.3tiff +++ b/tiff/man/TIFFSetField.3tiff @@ -85,11 +85,11 @@ The data types are: is null-terminated string and corresponds to the .SM ASCII data type; -.I uint16 +.I uint16_t is an unsigned 16-bit value; -.I uint32 +.I uint32_t is an unsigned 32-bit value; -.I uint16* +.I uint16_t* is an array of unsigned 16-bit values. .I void* is an array of data values of unspecified type. @@ -103,73 +103,73 @@ specification for information on the meaning of each tag. \fITag Name\fP \fICount\fP \fITypes\fP \fINotes\fP .sp 5p TIFFTAG_ARTIST 1 char* -TIFFTAG_BADFAXLINES 1 uint32 -TIFFTAG_BITSPERSAMPLE 1 uint16 \(dg -TIFFTAG_CLEANFAXDATA 1 uint16 -TIFFTAG_COLORMAP 3 uint16* 1<<BitsPerSample arrays -TIFFTAG_COMPRESSION 1 uint16 \(dg -TIFFTAG_CONSECUTIVEBADFAXLINES 1 uint32 +TIFFTAG_BADFAXLINES 1 uint32_t +TIFFTAG_BITSPERSAMPLE 1 uint16_t \(dg +TIFFTAG_CLEANFAXDATA 1 uint16_t +TIFFTAG_COLORMAP 3 uint16_t* 1<<BitsPerSample arrays +TIFFTAG_COMPRESSION 1 uint16_t \(dg +TIFFTAG_CONSECUTIVEBADFAXLINES 1 uint32_t TIFFTAG_COPYRIGHT 1 char* TIFFTAG_DATETIME 1 char* TIFFTAG_DOCUMENTNAME 1 char* -TIFFTAG_DOTRANGE 2 uint16 -TIFFTAG_EXTRASAMPLES 2 uint16,uint16* \(dg count & types array +TIFFTAG_DOTRANGE 2 uint16_t +TIFFTAG_EXTRASAMPLES 2 uint16_t,uint16_t* \(dg count & types array TIFFTAG_FAXFILLFUNC 1 TIFFFaxFillFunc G3/G4 compression pseudo-tag TIFFTAG_FAXMODE 1 int \(dg G3/G4 compression pseudo-tag -TIFFTAG_FILLORDER 1 uint16 \(dg -TIFFTAG_GROUP3OPTIONS 1 uint32 \(dg -TIFFTAG_GROUP4OPTIONS 1 uint32 \(dg -TIFFTAG_HALFTONEHINTS 2 uint16 +TIFFTAG_FILLORDER 1 uint16_t \(dg +TIFFTAG_GROUP3OPTIONS 1 uint32_t \(dg +TIFFTAG_GROUP4OPTIONS 1 uint32_t \(dg +TIFFTAG_HALFTONEHINTS 2 uint16_t TIFFTAG_HOSTCOMPUTER 1 char* -TIFFTAG_ICCPROFILE 2 uint32,void* count, profile data -TIFFTAG_IMAGEDEPTH 1 uint32 \(dg +TIFFTAG_ICCPROFILE 2 uint32_t,void* count, profile data +TIFFTAG_IMAGEDEPTH 1 uint32_t \(dg TIFFTAG_IMAGEDESCRIPTION 1 char* -TIFFTAG_IMAGELENGTH 1 uint32 -TIFFTAG_IMAGEWIDTH 1 uint32 \(dg -TIFFTAG_INKNAMES 2 uint16, char* -TIFFTAG_INKSET 1 uint16 \(dg +TIFFTAG_IMAGELENGTH 1 uint32_t +TIFFTAG_IMAGEWIDTH 1 uint32_t \(dg +TIFFTAG_INKNAMES 2 uint16_t, char* +TIFFTAG_INKSET 1 uint16_t \(dg TIFFTAG_JPEGCOLORMODE 1 int \(dg JPEG pseudo-tag TIFFTAG_JPEGQUALITY 1 int JPEG pseudo-tag -TIFFTAG_JPEGTABLES 2 uint32*,void* \(dg count & tables +TIFFTAG_JPEGTABLES 2 uint32_t*,void* \(dg count & tables TIFFTAG_JPEGTABLESMODE 1 int \(dg JPEG pseudo-tag TIFFTAG_MAKE 1 char* -TIFFTAG_MATTEING 1 uint16 \(dg -TIFFTAG_MAXSAMPLEVALUE 1 uint16 -TIFFTAG_MINSAMPLEVALUE 1 uint16 +TIFFTAG_MATTEING 1 uint16_t \(dg +TIFFTAG_MAXSAMPLEVALUE 1 uint16_t +TIFFTAG_MINSAMPLEVALUE 1 uint16_t TIFFTAG_MODEL 1 char* -TIFFTAG_ORIENTATION 1 uint16 +TIFFTAG_ORIENTATION 1 uint16_t TIFFTAG_PAGENAME 1 char* -TIFFTAG_PAGENUMBER 2 uint16 -TIFFTAG_PHOTOMETRIC 1 uint16 -TIFFTAG_PHOTOSHOP ? uint32,void* count, data -TIFFTAG_PLANARCONFIG 1 uint16 \(dg -TIFFTAG_PREDICTOR 1 uint16 \(dg +TIFFTAG_PAGENUMBER 2 uint16_t +TIFFTAG_PHOTOMETRIC 1 uint16_t +TIFFTAG_PHOTOSHOP ? uint32_t,void* count, data +TIFFTAG_PLANARCONFIG 1 uint16_t \(dg +TIFFTAG_PREDICTOR 1 uint16_t \(dg TIFFTAG_PRIMARYCHROMATICITIES 1 float* 6-entry array TIFFTAG_REFERENCEBLACKWHITE 1 float* \(dg 6-entry array -TIFFTAG_RESOLUTIONUNIT 1 uint16 -TIFFTAG_RICHTIFFIPTC 2 uint32,void* count, data -TIFFTAG_ROWSPERSTRIP 1 uint32 \(dg must be > 0 -TIFFTAG_SAMPLEFORMAT 1 uint16 \(dg -TIFFTAG_SAMPLESPERPIXEL 1 uint16 \(dg value must be <= 4 +TIFFTAG_RESOLUTIONUNIT 1 uint16_t +TIFFTAG_RICHTIFFIPTC 2 uint32_t,void* count, data +TIFFTAG_ROWSPERSTRIP 1 uint32_t \(dg must be > 0 +TIFFTAG_SAMPLEFORMAT 1 uint16_t \(dg +TIFFTAG_SAMPLESPERPIXEL 1 uint16_t \(dg value must be <= 4 TIFFTAG_SMAXSAMPLEVALUE 1 double TIFFTAG_SMINSAMPLEVALUE 1 double TIFFTAG_SOFTWARE 1 char* TIFFTAG_STONITS 1 double \(dg -TIFFTAG_SUBFILETYPE 1 uint32 -TIFFTAG_SUBIFD 2 uint16,uint64* count & offsets array +TIFFTAG_SUBFILETYPE 1 uint32_t +TIFFTAG_SUBIFD 2 uint16_t,uint64_t* count & offsets array TIFFTAG_TARGETPRINTER 1 char* -TIFFTAG_THRESHHOLDING 1 uint16 -TIFFTAG_TILEDEPTH 1 uint32 \(dg -TIFFTAG_TILELENGTH 1 uint32 \(dg must be a multiple of 8 -TIFFTAG_TILEWIDTH 1 uint32 \(dg must be a multiple of 8 -TIFFTAG_TRANSFERFUNCTION 1 or 3\(dd uint16* 1<<BitsPerSample entry arrays +TIFFTAG_THRESHHOLDING 1 uint16_t +TIFFTAG_TILEDEPTH 1 uint32_t \(dg +TIFFTAG_TILELENGTH 1 uint32_t \(dg must be a multiple of 8 +TIFFTAG_TILEWIDTH 1 uint32_t \(dg must be a multiple of 8 +TIFFTAG_TRANSFERFUNCTION 1 or 3\(dd uint16_t* 1<<BitsPerSample entry arrays TIFFTAG_WHITEPOINT 1 float* 2-entry array -TIFFTAG_XMLPACKET 2 uint32,void* count, data +TIFFTAG_XMLPACKET 2 uint32_t,void* count, data TIFFTAG_XPOSITION 1 float TIFFTAG_XRESOLUTION 1 float TIFFTAG_YCBCRCOEFFICIENTS 1 float* \(dg 3-entry array -TIFFTAG_YCBCRPOSITIONING 1 uint16 \(dg -TIFFTAG_YCBCRSAMPLING 2 uint16 \(dg +TIFFTAG_YCBCRPOSITIONING 1 uint16_t \(dg +TIFFTAG_YCBCRSAMPLING 2 uint16_t \(dg TIFFTAG_YPOSITION 1 float TIFFTAG_YRESOLUTION 1 float .fi diff --git a/tiff/man/TIFFWriteScanline.3tiff b/tiff/man/TIFFWriteScanline.3tiff index a51cec52..bf6e6a8d 100644 --- a/tiff/man/TIFFWriteScanline.3tiff +++ b/tiff/man/TIFFWriteScanline.3tiff @@ -30,7 +30,7 @@ file .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "int TIFFWriteScanline(TIFF *" tif ", tdata_t " buf ", uint32 " row ", tsample_t " sample ")" +.BI "int TIFFWriteScanline(TIFF *" tif ", tdata_t " buf ", uint32_t " row ", tsample_t " sample ")" .SH DESCRIPTION Write data to a file at the specified row. The .I sample diff --git a/tiff/man/TIFFWriteTile.3tiff b/tiff/man/TIFFWriteTile.3tiff index a6700258..7e86ae00 100644 --- a/tiff/man/TIFFWriteTile.3tiff +++ b/tiff/man/TIFFWriteTile.3tiff @@ -30,7 +30,7 @@ file .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "tsize_t TIFFWriteTile(TIFF *" tif ", tdata_t " buf ", uint32 " x ", uint32 " y ", uint32 " z ", tsample_t " sample ")" +.BI "tsize_t TIFFWriteTile(TIFF *" tif ", tdata_t " buf ", uint32_t " x ", uint32_t " y ", uint32_t " z ", tsample_t " sample ")" .SH DESCRIPTION Write the data for the tile .I containing diff --git a/tiff/man/TIFFcodec.3tiff b/tiff/man/TIFFcodec.3tiff index aa3a8c63..1fb41816 100644 --- a/tiff/man/TIFFcodec.3tiff +++ b/tiff/man/TIFFcodec.3tiff @@ -29,13 +29,13 @@ TIFFFindCODEC, TIFFRegisterCODEC, TIFFUnRegisterCODEC, TIFFIsCODECConfigured .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "const TIFFCodec* TIFFFindCODEC(uint16 " scheme ");" +.BI "const TIFFCodec* TIFFFindCODEC(uint16_t " scheme ");" .br -.BI "TIFFCodec* TIFFRegisterCODEC(uint16 " scheme ", const char *" method ", TIFFInitMethod " init ");" +.BI "TIFFCodec* TIFFRegisterCODEC(uint16_t " scheme ", const char *" method ", TIFFInitMethod " init ");" .br .BI "void TIFFUnRegisterCODEC(TIFFCodec *" codec ");" .br -.BI "int TIFFIsCODECConfigured(uint16 " scheme ");" +.BI "int TIFFIsCODECConfigured(uint16_t " scheme ");" .SH DESCRIPTION .I libtiff supports a variety of compression schemes implemented by software diff --git a/tiff/man/TIFFcolor.3tiff b/tiff/man/TIFFcolor.3tiff index 1d2bb2b8..d1e74a7c 100644 --- a/tiff/man/TIFFcolor.3tiff +++ b/tiff/man/TIFFcolor.3tiff @@ -30,13 +30,13 @@ TIFFXYZToRGB \- color conversion routines. .sp .BI "int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *" ycbcr ", float *" luma ", float *"refBlackWhite" );" .br -.BI "void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *" ycbcr ", uint32 " Y ", int32 " Cb ", int32 " Cr ", uint32 *" R ", uint32 *" G ", uint32 *" B " );" +.BI "void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *" ycbcr ", uint32_t " Y ", int32_t " Cb ", int32_t " Cr ", uint32_t *" R ", uint32_t *" G ", uint32_t *" B " );" .sp .BI "int TIFFCIELabToRGBInit(TIFFCIELabToRGB *" cielab ", const TIFFDisplay *" display ", float *" refWhite ");" .br -.BI "void TIFFCIELabToXYZ(TIFFCIELabToRGB *" cielab ", uint32 " L ", int32 " a ", int32 " b ", float *" X ", float *" Y ", float *" Z ");" +.BI "void TIFFCIELabToXYZ(TIFFCIELabToRGB *" cielab ", uint32_t " L ", int32_t " a ", int32_t " b ", float *" X ", float *" Y ", float *" Z ");" .br -.BI "void TIFFXYZToRGB(TIFFCIELabToRGB *" cielab ", float " X ", float " Y ", float " Z" , uint32 *" R ", uint32 *" G ", uint32 *" B ");" +.BI "void TIFFXYZToRGB(TIFFCIELabToRGB *" cielab ", float " X ", float " Y ", float " Z" , uint32_t *" R ", uint32_t *" G ", uint32_t *" B ");" .SH DESCRIPTION TIFF supports several color spaces for images stored in that format. There is usually a problem of application to handle the data properly and convert @@ -65,9 +65,9 @@ typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; + int32_t* Cr_g_tab; + int32_t* Cb_g_tab; + int32_t* Y_tab; } TIFFYCbCrToRGB; .fi .RE @@ -89,14 +89,14 @@ should helps to understand the the technique: .RS .nf float *luma, *refBlackWhite; -uint16 hs, vs; +uint16_t hs, vs; /* Initialize structures */ ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB), sizeof(long)) + 4*256*sizeof(TIFFRGBValue) + 2*256*sizeof(int) - + 3*256*sizeof(int32)); + + 3*256*sizeof(int32_t)); if (ycbcr == NULL) { TIFFError("YCbCr->RGB", "No space for YCbCr->RGB conversion state"); @@ -109,9 +109,9 @@ if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) < 0) exit(0); /* Start conversion */ -uint32 r, g, b; -uint32 Y; -int32 Cb, Cr; +uint32_t r, g, b; +uint32_t Y; +int32_t Cb, Cr; for each pixel in image TIFFYCbCrtoRGB(img->ycbcr, Y, Cb, Cr, &r, &g, &b); @@ -158,9 +158,9 @@ typedef struct { float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ - uint32 d_Vrwg; - uint32 d_Vrwb; + uint32_t d_Vrwr; /* Pixel values for ref. white */ + uint32_t d_Vrwg; + uint32_t d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; @@ -245,9 +245,9 @@ if (TIFFCIELabToRGBInit(cielab, &display_sRGB, refWhite) < 0) { } /* Now we can start to convert */ -uint32 r, g, b; -uint32 L; -int32 a, b; +uint32_t r, g, b; +uint32_t L; +int32_t a, b; float X, Y, Z; for each pixel in image diff --git a/tiff/man/TIFFquery.3tiff b/tiff/man/TIFFquery.3tiff index 4d95f5f4..1e56a0ec 100644 --- a/tiff/man/TIFFquery.3tiff +++ b/tiff/man/TIFFquery.3tiff @@ -41,7 +41,7 @@ TIFFGetVersion .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "uint32 TIFFCurrentRow(TIFF* " tif ")" +.BI "uint32_t TIFFCurrentRow(TIFF* " tif ")" .br .BI "tstrip_t TIFFCurrentStrip(TIFF* " tif ")" .br diff --git a/tiff/man/TIFFstrip.3tiff b/tiff/man/TIFFstrip.3tiff index ce3f718c..f8b765ad 100644 --- a/tiff/man/TIFFstrip.3tiff +++ b/tiff/man/TIFFstrip.3tiff @@ -29,15 +29,15 @@ TIFFComputeStrip, TIFFNumberOfStrips \- strip-related utility routines .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "uint32 TIFFDefaultStripSize(TIFF *" tif ", uint32 " estimate ")" +.BI "uint32_t TIFFDefaultStripSize(TIFF *" tif ", uint32_t " estimate ")" .br .BI "tmsize_t TIFFStripSize(TIFF *" tif ")" .br -.BI "tmsize_t TIFFVStripSize(TIFF *" tif ", uint32 " nrows ")" +.BI "tmsize_t TIFFVStripSize(TIFF *" tif ", uint32_t " nrows ")" .br -.BI "tmsize_t TIFFRawStripSize(TIFF *" tif ", uint32 " strip ")" +.BI "tmsize_t TIFFRawStripSize(TIFF *" tif ", uint32_t " strip ")" .br -.BI "tstrip_t TIFFComputeStrip(TIFF *" tif ", uint32 " row ", tsample_t " sample ")" +.BI "tstrip_t TIFFComputeStrip(TIFF *" tif ", uint32_t " row ", tsample_t " sample ")" .br .BI "tstrip_t TIFFNumberOfStrips(TIFF *" tif ")" .SH DESCRIPTION diff --git a/tiff/man/TIFFswab.3tiff b/tiff/man/TIFFswab.3tiff index 3d7a47bc..44325223 100644 --- a/tiff/man/TIFFswab.3tiff +++ b/tiff/man/TIFFswab.3tiff @@ -33,13 +33,13 @@ TIFFSwabArrayOfShort, TIFFSwabArrayOfLong \- byte- and bit-swapping routines .br .BI "void TIFFReverseBits(u_char *" data ", unsigned long " nbytes ")" .br -.BI "void TIFFSwabShort(uint16 *" data ")" +.BI "void TIFFSwabShort(uint16_t *" data ")" .br -.BI "void TIFFSwabLong(uint32 *" data ")" +.BI "void TIFFSwabLong(uint32_t *" data ")" .br -.BI "void TIFFSwabArrayOfShort(uint16 *" data ", unsigned long " nshorts ")" +.BI "void TIFFSwabArrayOfShort(uint16_t *" data ", unsigned long " nshorts ")" .br -.BI "void TIFFSwabArrayOfLong(uint32 *" data ", unsigned long " nlongs ")" +.BI "void TIFFSwabArrayOfLong(uint32_t *" data ", unsigned long " nlongs ")" .SH DESCRIPTION The following routines are used by the library to swap 16- and 32-bit data and to reverse the order of bits in bytes. diff --git a/tiff/man/TIFFtile.3tiff b/tiff/man/TIFFtile.3tiff index 10310a06..7928e406 100644 --- a/tiff/man/TIFFtile.3tiff +++ b/tiff/man/TIFFtile.3tiff @@ -30,17 +30,17 @@ routines .SH SYNOPSIS .B "#include <tiffio.h>" .sp -.BI "void TIFFDefaultTileSize(TIFF *" tif ", uint32 *" tw ", uint32 *" th ")" +.BI "void TIFFDefaultTileSize(TIFF *" tif ", uint32_t *" tw ", uint32_t *" th ")" .br .BI "tsize_t TIFFTileSize(TIFF *" tif ")" .br .BI "tsize_t TIFFTileRowSize(TIFF *" tif ")" .br -.BI "tsize_t TIFFVTileSize(TIFF *" tif ", uint32 " nrows ")" +.BI "tsize_t TIFFVTileSize(TIFF *" tif ", uint32_t " nrows ")" .br -.BI "ttile_t TIFFComputeTile(TIFF *" tif ", uint32 " x ", uint32 " y ", uint32 " z ", tsample_t " sample ")" +.BI "ttile_t TIFFComputeTile(TIFF *" tif ", uint32_t " x ", uint32_t " y ", uint32_t " z ", tsample_t " sample ")" .br -.BI "int TIFFCheckTile(TIFF *" tif ", uint32 " x ", uint32 " y ", uint32 " z ", tsample_t " sample ")" +.BI "int TIFFCheckTile(TIFF *" tif ", uint32_t " x ", uint32_t " y ", uint32_t " z ", tsample_t " sample ")" .br .BI "ttile_t TIFFNumberOfTiles(TIFF *" tif ")" .br diff --git a/tiff/man/libtiff.3tiff b/tiff/man/libtiff.3tiff index 8e9ff35b..1f646789 100644 --- a/tiff/man/libtiff.3tiff +++ b/tiff/man/libtiff.3tiff @@ -93,20 +93,20 @@ The following typedefs are exposed to users either through function definitions or through parameters passed through the varargs interfaces. .in +.5i .sp 5p -.ta +\w'typedef unsigned <\fIthing\fP> uint32; 'u +.ta +\w'typedef unsigned <\fIthing\fP> uint32_t; 'u .nf -typedef unsigned short uint16; 16-bit unsigned integer -typedef unsigned <\fIthing\fP> uint32; 32-bit unsigned integer +typedef unsigned short uint16_t; 16-bit unsigned integer +typedef unsigned <\fIthing\fP> uint32_t; 32-bit unsigned integer .sp 5p typedef unsigned int ttag_t; directory tag -typedef uint16 tdir_t; directory index -typedef uint16 tsample_t; sample number -typedef uint32 tstrip_t; strip number -typedef uint32 ttile_t; tile number -typedef int32 tsize_t; i/o size in bytes +typedef uint16_t tdir_t; directory index +typedef uint16_t tsample_t; sample number +typedef uint32_t tstrip_t; strip number +typedef uint32_t ttile_t; tile number +typedef int32_t tsize_t; i/o size in bytes typedef void* tdata_t; image data ref typedef void* thandle_t; client data handle -typedef int32 toff_t; file offset +typedef int32_t toff_t; file offset .fi .sp 5p .in -.5i @@ -134,7 +134,7 @@ a varargs interface and .SM "ANSI C" restricts the type of the parameter before an ellipsis to be a promoted type. .I toff_t -is defined as int32 because TIFF file offsets are (unsigned) 32-bit +is defined as int32_t because TIFF file offsets are (unsigned) 32-bit quantities. A signed value is used because some interfaces return \-1 on error. Finally, note that user-specified data references are passed as opaque handles and only cast at the lowest layers where their type is presumed. diff --git a/tiff/man/tiffcrop.1 b/tiff/man/tiffcrop.1 index d7a4c4d7..d133f652 100644 --- a/tiff/man/tiffcrop.1 +++ b/tiff/man/tiffcrop.1 @@ -133,7 +133,7 @@ or may be used to specify all odd or even numbered images counting from one. Note that internally, TIFF images are numbered from zero rather than one but since this convention is not obvious to most users, tiffcrop used 1 -to specifiy the first image in a multipage file. The word +to specify the first image in a multipage file. The word .B last may be used in place of a number in the sequence to indicate the final image in the file without knowing how many images there are. @@ -144,8 +144,8 @@ to process the 1st, 5th through 7th, and final image in the file. .TP .B \-E top|bottom|left|right Specify the top, bottom, left, or right edge as the reference from -which to calcuate the width and length of crop regions or sequence -of postions for zones. When used with the \-e option for exporting +which to calculate the width and length of crop regions or sequence +of positions for zones. When used with the \-e option for exporting zones or regions, the reference edge determines how composite images are arranged. Using \-E left or right causes successive zones or regions to be merged horizontally whereas using \-E top or bottom @@ -549,11 +549,11 @@ additional ones may be added in the future. It will handle tiled images with bit depths that are not a multiple of eight that tiffcp may refuse to read. .PP .I Tiffcrop -was designed to handle large files containing many moderate sized images -with memory usage that is independent of the number of images in the file. +was designed to handle large files containing many moderate sized images +with memory usage that is independent of the number of images in the file. In order to support compression modes that are not based on individual scanlines, e.g. JPEG, it now reads images by strip or tile rather than by -indvidual scanlines. In addition to the memory required by the input and +individual scanlines. In addition to the memory required by the input and output buffers associated with .I LibTIFF one or more buffers at least as large as the largest image to be read are diff --git a/tiff/man/tiffsplit.1 b/tiff/man/tiffsplit.1 index fe309f42..6b0b5121 100644 --- a/tiff/man/tiffsplit.1 +++ b/tiff/man/tiffsplit.1 @@ -57,6 +57,18 @@ the default prefix of is used. .SH OPTIONS None. +.SH EXIT STATUS +.I tiffsplit +exits with one of the following values: +.PD 0 +.TP +.B 0 +Success +.TP +.B 1 +An error occurred either reading the input or writing results. +.RE +.PD .SH BUGS Only a select set of ``known tags'' is copied when splitting. .SH "SEE ALSO" diff --git a/tiff/nmake.opt b/tiff/nmake.opt deleted file mode 100644 index d9bf15f1..00000000 --- a/tiff/nmake.opt +++ /dev/null @@ -1,220 +0,0 @@ -# -# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. - -# Compile time parameters for MS Visual C++ compiler. -# You may edit this file to specify building options. - -# Options: -# DEBUG - set to disable optimizations and link with debug runtimes -# -# Usage examples (see details below): -# nmake -f makefile.vc -# nmake -f makefile.vc DEBUG=1 -# nmake -f makefile.vc clean -# -# -###### Edit the following lines to choose a feature set you need. ####### -# - -# -# Comment out the following lines to disable internal codecs. -# -# Support for CCITT Group 3 & 4 algorithms -CCITT_SUPPORT = 1 -# Support for Macintosh PackBits algorithm -PACKBITS_SUPPORT = 1 -# Support for LZW algorithm -LZW_SUPPORT = 1 -# Support for ThunderScan 4-bit RLE algorithm -THUNDER_SUPPORT = 1 -# Support for NeXT 2-bit RLE algorithm -NEXT_SUPPORT = 1 -# Support for LogLuv high dynamic range encoding -LOGLUV_SUPPORT = 1 - -# -# Uncomment and edit following lines to enable JPEG support. -# -#JPEG_SUPPORT = 1 -#JPEGDIR = d:/projects/jpeg-6b -#JPEG_INCLUDE = -I$(JPEGDIR) -#JPEG_LIB = $(JPEGDIR)/Release/jpeg.lib - -# -# Uncomment and edit following lines to enable ZIP support -# (required for Deflate compression and Pixar log-format) -# -#ZIP_SUPPORT = 1 -#ZLIBDIR = d:/projects/zlib-1.2.1 -#ZLIB_INCLUDE = -I$(ZLIBDIR) -#ZLIB_LIB = $(ZLIBDIR)/zlib.lib - -# -# Uncomment and edit following lines to enable ISO JBIG support -# -#JBIG_SUPPORT = 1 -#JBIGDIR = d:/projects/jbigkit -#JBIG_INCLUDE = -I$(JBIGDIR)/libjbig -#JBIG_LIB = $(JBIGDIR)/libjbig/jbig.lib - -# -# Uncomment following line to enable Pixar log-format algorithm -# (Zlib required). -# -#PIXARLOG_SUPPORT = 1 - -# -# Comment out the following lines to disable strip chopping -# (whether or not to convert single-strip uncompressed images to mutiple -# strips of specified size to reduce memory usage). Default strip size -# is 8192 bytes, it can be configured via the STRIP_SIZE_DEFAULT parameter -# -STRIPCHOP_SUPPORT = 1 -STRIP_SIZE_DEFAULT = 8192 - -# -# Comment out the following lines to disable treating the fourth sample with -# no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA -# files but don't mark the alpha properly. -# -EXTRASAMPLE_AS_ALPHA_SUPPORT = 1 - -# -# Comment out the following lines to disable picking up YCbCr subsampling -# info from the JPEG data stream to support files lacking the tag. -# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details. -# -CHECK_JPEG_YCBCR_SUBSAMPLING = 1 - -# -####################### Compiler related options. ####################### -# - - -# Indicate if the compiler provides strtoll/strtoull (default 1) -# Users of MSVC++ 14.0 ("Visual Studio 2015") and later should set this to 1 -HAVE_STRTOLL = 1 - -# -# Pick debug or optimized build flags. We default to an optimized build -# with no debugging information. -# NOTE: /EHsc option required if you want to build the C++ stream API -# -!IFDEF DEBUG -OPTFLAGS = /MDd /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE -!ELSE -OPTFLAGS = /Ox /MD /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE -!ENDIF -#OPTFLAGS = /Zi - -# -# Uncomment following line to enable using Windows Common RunTime Library -# instead of Windows specific system calls. See notes on top of tif_unix.c -# module for details. -# -USE_WIN_CRT_LIB = 1 - -# Compiler specific options. You may probably want to adjust compilation -# parameters in CFLAGS variable. Refer to your compiler documentation -# for the option reference. -# -MAKE = nmake /nologo -CC = cl /nologo -CXX = cl /nologo -AR = lib /nologo -LD = link /nologo - -CFLAGS = $(OPTFLAGS) $(INCL) $(EXTRAFLAGS) -CXXFLAGS = $(OPTFLAGS) $(INCL) $(EXTRAFLAGS) -EXTRAFLAGS = -DHAVE_CONFIG_H -LIBS = - -# Name of the output shared library -DLLNAME = libtiff.dll - -# -########### There is nothing to edit below this line normally. ########### -# - -# Set the native cpu bit order -EXTRAFLAGS = -DFILLODER_LSB2MSB $(EXTRAFLAGS) - -# Codec stuff -!IFDEF CCITT_SUPPORT -EXTRAFLAGS = -DCCITT_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF PACKBITS_SUPPORT -EXTRAFLAGS = -DPACKBITS_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF LZW_SUPPORT -EXTRAFLAGS = -DLZW_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF THUNDER_SUPPORT -EXTRAFLAGS = -DTHUNDER_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF NEXT_SUPPORT -EXTRAFLAGS = -DNEXT_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF LOGLUV_SUPPORT -EXTRAFLAGS = -DLOGLUV_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF JPEG_SUPPORT -LIBS = $(LIBS) $(JPEG_LIB) -EXTRAFLAGS = -DJPEG_SUPPORT -DOJPEG_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF ZIP_SUPPORT -LIBS = $(LIBS) $(ZLIB_LIB) -EXTRAFLAGS = -DZIP_SUPPORT $(EXTRAFLAGS) -!IFDEF PIXARLOG_SUPPORT -EXTRAFLAGS = -DPIXARLOG_SUPPORT $(EXTRAFLAGS) -!ENDIF -!ENDIF - -!IFDEF JBIG_SUPPORT -LIBS = $(LIBS) $(JBIG_LIB) -EXTRAFLAGS = -DJBIG_SUPPORT $(EXTRAFLAGS) -!ENDIF - -!IFDEF STRIPCHOP_SUPPORT -EXTRAFLAGS = -DSTRIPCHOP_DEFAULT=TIFF_STRIPCHOP -DSTRIP_SIZE_DEFAULT=$(STRIP_SIZE_DEFAULT) $(EXTRAFLAGS) -!ENDIF - -!IFDEF EXTRASAMPLE_AS_ALPHA_SUPPORT -EXTRAFLAGS = -DDEFAULT_EXTRASAMPLE_AS_ALPHA $(EXTRAFLAGS) -!ENDIF - -!IFDEF CHECK_JPEG_YCBCR_SUBSAMPLING -EXTRAFLAGS = -DCHECK_JPEG_YCBCR_SUBSAMPLING $(EXTRAFLAGS) -!ENDIF - -!IFDEF USE_WIN_CRT_LIB -EXTRAFLAGS = -DAVOID_WIN32_FILEIO $(EXTRAFLAGS) -!ELSE -EXTRAFLAGS = -DUSE_WIN32_FILEIO $(EXTRAFLAGS) -!ENDIF diff --git a/tiff/port/CMakeLists.txt b/tiff/port/CMakeLists.txt index b7eb3a29..21db9773 100644..100755 --- a/tiff/port/CMakeLists.txt +++ b/tiff/port/CMakeLists.txt @@ -22,47 +22,30 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -set(port_HEADERS libport.h) -set(port_SOURCES dummy.c) -set(port_optional_SOURCES - getopt.c - lfind.c - strcasecmp.c - strtol.c - strtoll.c - strtoul.c - strtoull.c) +# Generate headers +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libport_config.h.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/libport_config.h + @ONLY) -set(port_USED_FILES ${port_SOURCES} ${port_HEADERS}) +set(port_HEADERS libport.h) +# Only build if any needed features are missing if(NOT HAVE_GETOPT) - list(APPEND port_USED_FILES getopt.c) -endif() -if(NOT HAVE_LFIND) - list(APPEND port_USED_FILES lfind.c) -endif() -if(MSVC AND NOT HAVE_SNPRINTF) - list(APPEND port_USED_FILES snprintf.c) -endif() -if(NOT HAVE_STRCASECMP) - list(APPEND port_USED_FILES strcasecmp.c) -endif() -if(NOT HAVE_STRTOL) - list(APPEND port_USED_FILES strtol.c) -endif() -if(NOT HAVE_STRTOLL) - list(APPEND port_USED_FILES strtoll.c) -endif() -if(NOT HAVE_STRTOUL) - list(APPEND port_USED_FILES strtoul.c) -endif() -if(NOT HAVE_STRTOULL) - list(APPEND port_USED_FILES strtoull.c) -endif() + add_library(port STATIC) -add_library(port STATIC ${port_USED_FILES}) + # Add getopt if missing + if(NOT HAVE_GETOPT) + target_sources(port PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/getopt.c) + endif() -foreach(file ${port_USED_FILES}) - list(APPEND tiff_port_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${file}") -endforeach() -set(tiff_port_SOURCES ${tiff_port_SOURCES} PARENT_SCOPE) + target_include_directories(port PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}) +else() + # Dummy interface library + add_library(port INTERFACE) + target_include_directories(port INTERFACE + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}) +endif() diff --git a/tiff/port/Makefile.am b/tiff/port/Makefile.am index 250479fe..088a2f7b 100644 --- a/tiff/port/Makefile.am +++ b/tiff/port/Makefile.am @@ -25,11 +25,8 @@ EXTRA_DIST = \ CMakeLists.txt \ - Makefile.vc \ libport.h \ - snprintf.c \ - _strtol.h \ - _strtoul.h + libport_config.h.cmake.in noinst_LTLIBRARIES = libport.la libport_la_SOURCES = dummy.c libport.h diff --git a/tiff/port/Makefile.in b/tiff/port/Makefile.in index ba9d98f8..d5a7c155 100644 --- a/tiff/port/Makefile.in +++ b/tiff/port/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -123,8 +123,9 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) @@ -147,14 +148,10 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/libtiff depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles -am__depfiles_remade = $(DEPDIR)/getopt.Plo $(DEPDIR)/lfind.Plo \ - $(DEPDIR)/snprintf.Plo $(DEPDIR)/strcasecmp.Plo \ - $(DEPDIR)/strtol.Plo $(DEPDIR)/strtoll.Plo \ - $(DEPDIR)/strtoul.Plo $(DEPDIR)/strtoull.Plo \ - ./$(DEPDIR)/dummy.Plo +am__depfiles_remade = $(DEPDIR)/getopt.Plo ./$(DEPDIR)/dummy.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -181,7 +178,8 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)libport_config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. @@ -200,9 +198,8 @@ am__define_uniq_tagged_files = \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp \ - getopt.c lfind.c snprintf.c strcasecmp.c strtol.c strtoll.c \ - strtoul.c strtoull.c +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libport_config.h.in \ + $(top_srcdir)/config/depcomp getopt.c DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ @@ -343,6 +340,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -354,16 +352,14 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ CMakeLists.txt \ - Makefile.vc \ libport.h \ - snprintf.c \ - _strtol.h \ - _strtoul.h + libport_config.h.cmake.in noinst_LTLIBRARIES = libport.la libport_la_SOURCES = dummy.c libport.h libport_la_LIBADD = @LTLIBOBJS@ -all: all-am +all: libport_config.h + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj @@ -397,6 +393,17 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +libport_config.h: stamp-h4 + @test -f $@ || rm -f stamp-h4 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h4 + +stamp-h4: $(srcdir)/libport_config.h.in $(top_builddir)/config.status + @rm -f stamp-h4 + cd $(top_builddir) && $(SHELL) ./config.status port/libport_config.h + +distclean-hdr: + -rm -f libport_config.h stamp-h4 + clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ @@ -418,13 +425,6 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/lfind.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/snprintf.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasecmp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtol.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoll.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoul.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoull.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @@ -547,7 +547,7 @@ distdir-am: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(LTLIBRARIES) +all-am: Makefile $(LTLIBRARIES) libport_config.h installdirs: install: install-am install-exec: install-exec-am @@ -586,17 +586,10 @@ clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ distclean: distclean-am -rm -f $(DEPDIR)/getopt.Plo - -rm -f $(DEPDIR)/lfind.Plo - -rm -f $(DEPDIR)/snprintf.Plo - -rm -f $(DEPDIR)/strcasecmp.Plo - -rm -f $(DEPDIR)/strtol.Plo - -rm -f $(DEPDIR)/strtoll.Plo - -rm -f $(DEPDIR)/strtoul.Plo - -rm -f $(DEPDIR)/strtoull.Plo -rm -f ./$(DEPDIR)/dummy.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags + distclean-hdr distclean-tags dvi: dvi-am @@ -640,13 +633,6 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(DEPDIR)/getopt.Plo - -rm -f $(DEPDIR)/lfind.Plo - -rm -f $(DEPDIR)/snprintf.Plo - -rm -f $(DEPDIR)/strcasecmp.Plo - -rm -f $(DEPDIR)/strtol.Plo - -rm -f $(DEPDIR)/strtoll.Plo - -rm -f $(DEPDIR)/strtoul.Plo - -rm -f $(DEPDIR)/strtoull.Plo -rm -f ./$(DEPDIR)/dummy.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -666,21 +652,21 @@ ps-am: uninstall-am: -.MAKE: install-am install-strip +.MAKE: all install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am + distclean-generic distclean-hdr distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile diff --git a/tiff/port/Makefile.vc b/tiff/port/Makefile.vc deleted file mode 100644 index e4471af5..00000000 --- a/tiff/port/Makefile.vc +++ /dev/null @@ -1,83 +0,0 @@ -# -# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# -# Makefile for MS Visual C and Watcom C compilers. -# -# To build: -# C:\libtiff\port> nmake /f makefile.vc - -!INCLUDE ..\nmake.opt - -HAVE_STRTOL = 1 -HAVE_STRTOUL = 1 - -# strtoul()/strtoull() are provided together -!IF $(HAVE_STRTOLL) -HAVE_STRTOULL = 1 -!ELSE -HAVE_STRTOULL = 0 -!endif - -!IF $(HAVE_STRTOL) -STRTOL_OBJ = -!ELSE -STRTOL_OBJ = strtol.obj -!ENDIF - -!IF $(HAVE_STRTOUL) -STRTOUL_OBJ = -!ELSE -STRTOUL_OBJ = strtoul.obj -!ENDIF - -!IF $(HAVE_STRTOLL) -STRTOLL_OBJ = -!ELSE -STRTOLL_OBJ = strtoll.obj -!ENDIF - -!IF $(HAVE_STRTOULL) -STRTOULL_OBJ = -!ELSE -STRTOULL_OBJ = strtoull.obj -!ENDIF - -INCL = -I..\libtiff - -OBJ = \ - snprintf.obj \ - strcasecmp.obj \ - $(STRTOL_OBJ) \ - $(STRTOUL_OBJ) \ - $(STRTOLL_OBJ) \ - $(STRTOULL_OBJ) \ - getopt.obj - -all: libport.lib - -libport.lib: $(OBJ) - $(AR) /out:libport.lib $(OBJ) - -clean: - -del *.obj - -del *.lib - diff --git a/tiff/port/_strtol.h b/tiff/port/_strtol.h deleted file mode 100644 index 73a10063..00000000 --- a/tiff/port/_strtol.h +++ /dev/null @@ -1,160 +0,0 @@ -/* $NetBSD: _strtol.h,v 1.11 2017/07/06 21:08:44 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * Original version ID: - * NetBSD: src/lib/libc/locale/_wcstol.h,v 1.2 2003/08/07 16:43:03 agc Exp - */ - -#include <assert.h> - -/* - * function template for strtol, strtoll and strtoimax. - * - * parameters: - * _FUNCNAME : function name - * __INT : return type - * __INT_MIN : lower limit of the return type - * __INT_MAX : upper limit of the return type - */ -__INT -_FUNCNAME(const char *nptr, char **endptr, int base) -{ - const char *s; - __INT acc, cutoff; - unsigned char c; - int i, neg, any, cutlim; - - assert(nptr != NULL); - /* endptr may be NULL */ - - /* check base value */ - if (base && (base < 2 || base > 36)) { - errno = EINVAL; - if (endptr != NULL) - /* LINTED interface specification */ - *endptr = (char *)(nptr); - return 0; - } - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - s = nptr; - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X') && - ((s[1] >= '0' && s[1] <= '9') || - (s[1] >= 'a' && s[1] <= 'f') || - (s[1] >= 'A' && s[1] <= 'F'))) { - c = s[1]; - s += 2; - base = 16; - } else if (base == 0) - base = (c == '0' ? 8 : 10); - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for longs is - * [-2147483648..2147483647] and the input base is 10, - * cutoff will be set to 214748364 and cutlim to either - * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated - * a value > 214748364, or equal but the next digit is > 7 (or 8), - * the number is too big, and we will return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - cutoff = (__INT)(neg ? __INT_MIN : __INT_MAX); - cutlim = (int)(cutoff % base); - cutoff /= base; - if (neg) { - if (cutlim > 0) { - cutlim -= base; - cutoff += 1; - } - cutlim = -cutlim; - } - for (acc = 0, any = 0;; c = *s++) { - if (c >= '0' && c <= '9') - i = c - '0'; - else if (c >= 'a' && c <= 'z') - i = (c - 'a') + 10; - else if (c >= 'A' && c <= 'Z') - i = (c - 'A') + 10; - else - break; - if (i >= base) - break; - if (any < 0) - continue; - if (neg) { - if (acc < cutoff || (acc == cutoff && i > cutlim)) { - acc = __INT_MIN; - any = -1; - errno = ERANGE; - } else { - any = 1; - acc *= base; - acc -= i; - } - } else { - if (acc > cutoff || (acc == cutoff && i > cutlim)) { - acc = __INT_MAX; - any = -1; - errno = ERANGE; - } else { - any = 1; - acc *= base; - acc += i; - } - } - } - if (endptr != NULL) - /* LINTED interface specification */ - *endptr = (char *)(any ? s - 1 : nptr); - return(acc); -} diff --git a/tiff/port/_strtoul.h b/tiff/port/_strtoul.h deleted file mode 100644 index 5cb62168..00000000 --- a/tiff/port/_strtoul.h +++ /dev/null @@ -1,127 +0,0 @@ -/* $NetBSD: _strtoul.h,v 1.11 2017/07/06 21:08:44 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * Original version ID: - * NetBSD: src/lib/libc/locale/_wcstoul.h,v 1.2 2003/08/07 16:43:03 agc Exp - */ - -#include <assert.h> - -/* - * function template for strtoul, strtoull and strtoumax. - * - * parameters: - * _FUNCNAME : function name - * __UINT : return type - * __UINT_MAX : upper limit of the return type - */ -__UINT -_FUNCNAME(const char *nptr, char **endptr, int base) -{ - const char *s; - __UINT acc, cutoff; - unsigned char c; - int i, neg, any, cutlim; - - assert(nptr != NULL); - /* endptr may be NULL */ - - /* check base value */ - if (base && (base < 2 || base > 36)) { - errno = EINVAL; - if (endptr != NULL) - /* LINTED interface specification */ - *endptr = (char *)(nptr); - return 0; - } - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - s = nptr; - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X') && - ((s[1] >= '0' && s[1] <= '9') || - (s[1] >= 'a' && s[1] <= 'f') || - (s[1] >= 'A' && s[1] <= 'F'))) { - c = s[1]; - s += 2; - base = 16; - } else if (base == 0) - base = (c == '0' ? 8 : 10); - - /* - * See strtol for comments as to the logic used. - */ - cutoff = ((__UINT)__UINT_MAX / (__UINT)base); - cutlim = (int)((__UINT)__UINT_MAX % (__UINT)base); - for (acc = 0, any = 0;; c = *s++) { - if (c >= '0' && c <= '9') - i = c - '0'; - else if (c >= 'a' && c <= 'z') - i = (c - 'a') + 10; - else if (c >= 'A' && c <= 'Z') - i = (c - 'A') + 10; - else - break; - if (i >= base) - break; - if (any < 0) - continue; - if (acc > cutoff || (acc == cutoff && i > cutlim)) { - acc = __UINT_MAX; - any = -1; - errno = ERANGE; - } else { - any = 1; - acc *= (__UINT)base; - acc += i; - } - } - if (neg && any > 0) - acc = -acc; - if (endptr != NULL) - /* LINTED interface specification */ - *endptr = (char *)(any ? s - 1 : nptr); - return(acc); -} diff --git a/tiff/port/lfind.c b/tiff/port/lfind.c deleted file mode 100644 index 00ab6495..00000000 --- a/tiff/port/lfind.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Roger L. Snyder. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if 0 -static char sccsid[] = "@(#)lsearch.c 8.1 (Berkeley) 6/4/93"; -__RCSID("$NetBSD: lsearch.c,v 1.2 2005/07/06 15:47:15 drochner Exp $"); -#endif - -#ifdef _WIN32_WCE -# include <wce_types.h> -#else -# include <sys/types.h> -#endif - -#ifndef NULL -# define NULL 0 -#endif - -void * -lfind(const void *key, const void *base, size_t *nmemb, size_t size, - int(*compar)(const void *, const void *)) -{ - char *element, *end; - - end = (char *)base + *nmemb * size; - for (element = (char *)base; element < end; element += size) - if (!compar(element, key)) /* key found */ - return element; - - return NULL; -} diff --git a/tiff/port/libport.h b/tiff/port/libport.h index 9f2dace1..cd8acf98 100644 --- a/tiff/port/libport.h +++ b/tiff/port/libport.h @@ -24,9 +24,13 @@ #ifndef _LIBPORT_ #define _LIBPORT_ -#if defined(HAVE_CONFIG_H) -# include <tif_config.h> -#endif +#include <libport_config.h> + +#if HAVE_GETOPT +# if HAVE_UNISTD_H +# include <unistd.h> +# endif +#else int getopt(int argc, char * const argv[], const char *optstring); extern char *optarg; @@ -34,38 +38,6 @@ extern int opterr; extern int optind; extern int optopt; -int strcasecmp(const char *s1, const char *s2); - -#ifndef HAVE_GETOPT -# define HAVE_GETOPT 1 -#endif - -#if !defined(HAVE_STRTOL) -long strtol(const char *nptr, char **endptr, int base); -#endif -#if !defined(HAVE_STRTOLL) -long long strtoll(const char *nptr, char **endptr, int base); -#endif -#if !defined(HAVE_STRTOUL) -unsigned long strtoul(const char *nptr, char **endptr, int base); -#endif -#if !defined(HAVE_STRTOULL) -unsigned long long strtoull(const char *nptr, char **endptr, int base); -#endif - -#if 0 -void * -lfind(const void *key, const void *base, size_t *nmemb, size_t size, - int(*compar)(const void *, const void *)); -#endif - -#if !defined(HAVE_SNPRINTF) -#undef vsnprintf -#define vsnprintf _TIFF_vsnprintf_f - -#undef snprintf -#define snprintf _TIFF_snprintf_f -int snprintf(char* str, size_t size, const char* format, ...); #endif #endif /* ndef _LIBPORT_ */ diff --git a/tiff/port/libport_config.h.cmake.in b/tiff/port/libport_config.h.cmake.in new file mode 100644 index 00000000..7446f872 --- /dev/null +++ b/tiff/port/libport_config.h.cmake.in @@ -0,0 +1,13 @@ +/* libtiff/libport_config.h.cmake.in. Not generated, but originated from autoheader. */ +/* This file must be kept up-to-date with needed substitutions from port/libport_config.h.in. */ + +#ifndef _LIBPORT_CONFIG_H_ +#define _LIBPORT_CONFIG_H_ + +/* Define to 1 if you have the `getopt' function. */ +#cmakedefine HAVE_GETOPT 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +#endif /* _LIBPORT_CONFIG_H_ */ diff --git a/tiff/port/libport_config.h.in b/tiff/port/libport_config.h.in new file mode 100644 index 00000000..b904f619 --- /dev/null +++ b/tiff/port/libport_config.h.in @@ -0,0 +1,12 @@ +/* libtiff/libport_config.h.in. Not generated, but originated from autoheader. */ + +#ifndef _LIBPORT_CONFIG_H_ +#define _LIBPORT_CONFIG_H_ + +/* Define to 1 if you have the `getopt' function. */ +#undef HAVE_GETOPT + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +#endif /* _LIBPORT_CONFIG_H_ */ diff --git a/tiff/port/snprintf.c b/tiff/port/snprintf.c deleted file mode 100644 index 3542ab75..00000000 --- a/tiff/port/snprintf.c +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Workaround for lack of snprintf(3) in Visual Studio. See - * http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010/8712996#8712996 - * It's a trivial wrapper around the builtin _vsnprintf_s and - * _vscprintf functions. - */ - -#ifdef _MSC_VER - -#include <stdio.h> -#include <stdarg.h> -#include "libport.h" - -int _TIFF_vsnprintf_f(char* str, size_t size, const char* format, va_list ap) -{ - int count = -1; - - if (size != 0) -#if _MSC_VER <= 1310 - count = _vsnprintf(str, size, format, ap); -#else - count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); -#endif - if (count == -1) - count = _vscprintf(format, ap); - - return count; -} - -int _TIFF_snprintf_f(char* str, size_t size, const char* format, ...) -{ - int count; - va_list ap; - - va_start(ap, format); - count = vsnprintf(str, size, format, ap); - va_end(ap); - - return count; -} - -#endif // _MSC_VER diff --git a/tiff/port/strcasecmp.c b/tiff/port/strcasecmp.c deleted file mode 100644 index 65e2b411..00000000 --- a/tiff/port/strcasecmp.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if 0 -static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93"; -__RCSID("$NetBSD: strcasecmp.c,v 1.16 2003/08/07 16:43:49 agc Exp $"); -#endif - -#include <ctype.h> -#include <string.h> -#include "libport.h" - -int -strcasecmp(const char *s1, const char *s2) -{ - const unsigned char *us1 = (const unsigned char *)s1, - *us2 = (const unsigned char *)s2; - - while (tolower((int) *us1) == tolower((int) *us2++)) - if (*us1++ == '\0') - return (0); - return (tolower((int) *us1) - tolower((int) *--us2)); -} diff --git a/tiff/port/strtol.c b/tiff/port/strtol.c deleted file mode 100644 index a355dde9..00000000 --- a/tiff/port/strtol.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $ */ - -/*- - * Copyright (c) 2005 The DragonFly Project. All rights reserved. - * Copyright (c) 2003 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if 0 -__RCSID("$NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $"); -#endif - -#include <assert.h> -#include <ctype.h> -#include <errno.h> -#include <limits.h> -#include <stdlib.h> - -#define _FUNCNAME strtol -#define __INT long -#define __INT_MIN LONG_MIN -#define __INT_MAX LONG_MAX - -#include "_strtol.h" diff --git a/tiff/port/strtoll.c b/tiff/port/strtoll.c deleted file mode 100644 index 4784b098..00000000 --- a/tiff/port/strtoll.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $ */ - -/*- - * Copyright (c) 2005 The DragonFly Project. All rights reserved. - * Copyright (c) 2003 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if 0 -__RCSID("$NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $"); -#endif - -#include <assert.h> -#include <ctype.h> -#include <errno.h> -#include <stdlib.h> - -#define _FUNCNAME strtoll -#define __INT long long -#define __INT_MIN LLONG_MIN -#define __INT_MAX LLONG_MAX - -#include "_strtol.h" diff --git a/tiff/port/strtoul.c b/tiff/port/strtoul.c deleted file mode 100644 index dbd44f16..00000000 --- a/tiff/port/strtoul.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $ */ - -/*- - * Copyright (c) 2005 The DragonFly Project. All rights reserved. - * Copyright (c) 2003 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if 0 -__RCSID("$NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $"); -#endif - -#include <assert.h> -#include <ctype.h> -#include <errno.h> -#include <limits.h> -#include <stdlib.h> - -#define _FUNCNAME strtoul -#define __UINT unsigned long int -#define __UINT_MAX ULONG_MAX - -#include "_strtoul.h" diff --git a/tiff/port/strtoull.c b/tiff/port/strtoull.c deleted file mode 100644 index 91e4ddfb..00000000 --- a/tiff/port/strtoull.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $ */ - -/*- - * Copyright (c) 2005 The DragonFly Project. All rights reserved. - * Copyright (c) 2003 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if 0 -__RCSID("$NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $"); -#endif - -#include <assert.h> -#include <ctype.h> -#include <errno.h> -#include <limits.h> -#include <stdlib.h> - -#define _FUNCNAME strtoull -#define __UINT unsigned long long int -#define __UINT_MAX ULLONG_MAX - -#include "_strtoul.h" diff --git a/tiff/test/CMakeLists.txt b/tiff/test/CMakeLists.txt index bffb8bf7..0a445c94 100644 --- a/tiff/test/CMakeLists.txt +++ b/tiff/test/CMakeLists.txt @@ -22,11 +22,6 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -include_directories(${PROJECT_SOURCE_DIR}/libtiff - ${PROJECT_BINARY_DIR}/libtiff - ${CMAKE_CURRENT_BINARY_DIR} - ${TIFF_INCLUDES}) - # Test scripts (not used by CMake) set(TESTSCRIPTS bmp2tiff_palette.sh @@ -168,58 +163,65 @@ set(IMAGES_EXTRA_DIST ${PNMIMAGES} ${TIFFIMAGES}) -extra_dist( - ${TESTSCRIPTS} - ${IMAGES_EXTRA_DIST} - common.sh) - set(noinst_HEADERS tifftest.h) -add_executable(ascii_tag ascii_tag.c) -target_link_libraries(ascii_tag tiff port) +add_executable(ascii_tag) +target_sources(ascii_tag PRIVATE ascii_tag.c) +target_link_libraries(ascii_tag PRIVATE tiff port) -add_executable(long_tag long_tag.c check_tag.c) -target_link_libraries(long_tag tiff port) +add_executable(long_tag) +target_sources(long_tag PRIVATE long_tag.c check_tag.c) +target_link_libraries(long_tag PRIVATE tiff port) -add_executable(short_tag short_tag.c check_tag.c) -target_link_libraries(short_tag tiff port) +add_executable(short_tag) +target_sources(short_tag PRIVATE short_tag.c check_tag.c) +target_link_libraries(short_tag PRIVATE tiff port) -add_executable(strip_rw strip_rw.c strip.c test_arrays.c test_arrays.h) -target_link_libraries(strip_rw tiff port) +add_executable(strip_rw) +target_sources(strip_rw PRIVATE strip_rw.c strip.c test_arrays.c test_arrays.h) +target_link_libraries(strip_rw PRIVATE tiff port) -add_executable(rewrite rewrite_tag.c) -target_link_libraries(rewrite tiff port) +add_executable(rewrite) +target_sources(rewrite PRIVATE rewrite_tag.c) +target_link_libraries(rewrite PRIVATE tiff port) if(JPEG_SUPPORT) - add_executable(raw_decode raw_decode.c) - target_link_libraries(raw_decode tiff port) + add_executable(raw_decode) + target_sources(raw_decode PRIVATE raw_decode.c) + target_link_libraries(raw_decode PRIVATE tiff port JPEG::JPEG) endif() -add_executable(custom_dir custom_dir.c) -target_link_libraries(custom_dir tiff port) +add_executable(custom_dir) +target_sources(custom_dir PRIVATE custom_dir.c) +target_link_libraries(custom_dir PRIVATE tiff port) if(NOT BUILD_SHARED_LIBS) -add_executable(rational_precision2double rational_precision2double.c) -target_link_libraries(rational_precision2double tiff port) +add_executable(rational_precision2double) +target_sources(rational_precision2double PRIVATE rational_precision2double.c) +target_link_libraries(rational_precision2double PRIVATE tiff port) add_test(NAME "rational_precision2double" COMMAND "rational_precision2double") endif() if(NOT BUILD_SHARED_LIBS) -add_executable(custom_dir_EXIF_231 custom_dir_EXIF_231.c) -target_link_libraries(custom_dir_EXIF_231 tiff port) +add_executable(custom_dir_EXIF_231) +target_sources(custom_dir_EXIF_231 PRIVATE custom_dir_EXIF_231.c) +target_link_libraries(custom_dir_EXIF_231 PRIVATE tiff port) add_test(NAME "custom_dir_EXIF_231" COMMAND "custom_dir_EXIF_231") endif() -add_executable(defer_strile_loading defer_strile_loading.c) -target_link_libraries(defer_strile_loading tiff port) +add_executable(defer_strile_loading) +target_sources(defer_strile_loading PRIVATE defer_strile_loading.c) +target_link_libraries(defer_strile_loading PRIVATE tiff port) -add_executable(defer_strile_writing defer_strile_writing.c) -target_link_libraries(defer_strile_writing tiff port) +add_executable(defer_strile_writing) +target_sources(defer_strile_writing PRIVATE defer_strile_writing.c) +target_link_libraries(defer_strile_writing PRIVATE tiff port) -add_executable(testtypes testtypes.c) -target_link_libraries(testtypes tiff port) +add_executable(testtypes) +target_sources(testtypes PRIVATE testtypes.c) +target_link_libraries(testtypes PRIVATE tiff port) if(WEBP_SUPPORT AND EMSCRIPTEN) # Emscripten is pretty finnicky about linker flags. diff --git a/tiff/test/Makefile.in b/tiff/test/Makefile.in index 15b7b826..0c2ceb4e 100644 --- a/tiff/test/Makefile.in +++ b/tiff/test/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -132,8 +132,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HAVE_JPEG_TRUE@am__EXEEXT_1 = raw_decode$(EXEEXT) @@ -192,7 +194,7 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/libtiff -I$(top_builddir)/port depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/ascii_tag.Po \ @@ -661,6 +663,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/tiff/test/ascii_tag.c b/tiff/test/ascii_tag.c index 9a56d31d..944dd57c 100644 --- a/tiff/test/ascii_tag.c +++ b/tiff/test/ascii_tag.c @@ -108,8 +108,8 @@ main() for (i = 0; i < NTAGS; i++) { if (!TIFFSetField(tif, ascii_tags[i].tag, ascii_tags[i].value)) { - fprintf(stderr, "Can't set tag %lu.\n", - (unsigned long)ascii_tags[i].tag); + fprintf(stderr, "Can't set tag %"PRIu32".\n", + ascii_tags[i].tag); goto failure; } } @@ -144,8 +144,8 @@ main() for (i = 0; i < NTAGS; i++) { if (!TIFFGetField(tif, ascii_tags[i].tag, &value) || strcmp(value, ascii_tags[i].value)) { - fprintf(stderr, "Can't get tag %lu.\n", - (unsigned long)ascii_tags[i].tag); + fprintf(stderr, "Can't get tag %"PRIu32".\n", + ascii_tags[i].tag); goto failure; } } diff --git a/tiff/test/check_tag.c b/tiff/test/check_tag.c index 5750d683..63554866 100644 --- a/tiff/test/check_tag.c +++ b/tiff/test/check_tag.c @@ -30,18 +30,18 @@ #include "tiffio.h" int -CheckShortField(TIFF *tif, const ttag_t field, const uint16 value) +CheckShortField(TIFF *tif, const ttag_t field, const uint16_t value) { - uint16 tmp = 123; + uint16_t tmp = 123; if (!TIFFGetField(tif, field, &tmp)) { - fprintf (stderr, "Problem fetching tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Problem fetching tag %"PRIu32".\n", + field); return -1; } if (tmp != value) { - fprintf (stderr, "Wrong SHORT value fetched for tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Wrong SHORT value fetched for tag %"PRIu32".\n", + field); return -1; } @@ -49,18 +49,18 @@ CheckShortField(TIFF *tif, const ttag_t field, const uint16 value) } int -CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values) +CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16_t *values) { - uint16 tmp[2] = { 123, 456 }; + uint16_t tmp[2] = {123, 456 }; if (!TIFFGetField(tif, field, tmp, tmp + 1)) { - fprintf (stderr, "Problem fetching tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Problem fetching tag %"PRIu32".\n", + field); return -1; } if (tmp[0] != values[0] || tmp[1] != values[1]) { - fprintf (stderr, "Wrong SHORT PAIR fetched for tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Wrong SHORT PAIR fetched for tag %"PRIu32".\n", + field); return -1; } @@ -68,18 +68,18 @@ CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values) } int -CheckLongField(TIFF *tif, const ttag_t field, const uint32 value) +CheckLongField(TIFF *tif, const ttag_t field, const uint32_t value) { - uint32 tmp = 123; + uint32_t tmp = 123; if (!TIFFGetField(tif, field, &tmp)) { - fprintf (stderr, "Problem fetching tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Problem fetching tag %"PRIu32".\n", + field); return -1; } if (tmp != value) { - fprintf (stderr, "Wrong LONG value fetched for tag %lu.\n", - (unsigned long) field); + fprintf (stderr, "Wrong LONG value fetched for tag %"PRIu32".\n", + field); return -1; } diff --git a/tiff/test/custom_dir.c b/tiff/test/custom_dir.c index 3b3ad279..42290ae8 100644 --- a/tiff/test/custom_dir.c +++ b/tiff/test/custom_dir.c @@ -42,12 +42,12 @@ static const char filename[] = "custom_dir.tif"; #define SPP 3 /* Samples per pixel */ -const uint16 width = 1; -const uint16 length = 1; -const uint16 bps = 8; -const uint16 photometric = PHOTOMETRIC_RGB; -const uint16 rows_per_strip = 1; -const uint16 planarconfig = PLANARCONFIG_CONTIG; +const uint16_t width = 1; +const uint16_t length = 1; +const uint16_t bps = 8; +const uint16_t photometric = PHOTOMETRIC_RGB; +const uint16_t rows_per_strip = 1; +const uint16_t planarconfig = PLANARCONFIG_CONTIG; static TIFFField customFields[] = { @@ -62,11 +62,11 @@ main() { TIFF *tif; unsigned char buf[SPP] = { 0, 127, 255 }; - uint64 dir_offset = 0, dir_offset2 = 0; - uint64 read_dir_offset = 0, read_dir_offset2 = 0; - uint64 *dir_offset2_ptr = NULL; + uint64_t dir_offset = 0, dir_offset2 = 0; + uint64_t read_dir_offset = 0, read_dir_offset2 = 0; + uint64_t *dir_offset2_ptr = NULL; char *ascii_value; - uint16 count16 = 0; + uint16_t count16 = 0; /* We write the main directory as a simple image. */ diff --git a/tiff/test/custom_dir_EXIF_231.c b/tiff/test/custom_dir_EXIF_231.c index 4c70e48f..892c442b 100644 --- a/tiff/test/custom_dir_EXIF_231.c +++ b/tiff/test/custom_dir_EXIF_231.c @@ -1,4 +1,3 @@ - /* * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.com> * @@ -40,7 +39,7 @@ /*------------ - * This version writes the GPS and EXIF tags correctly, without additonal main-IFD and parameters! + * This version writes the GPS and EXIF tags correctly, without additional main-IFD and parameters! * In contrary, custom_dir.c does write additional main-IFD and parameters to file. -------------*/ @@ -67,6 +66,7 @@ #include "tif_config.h" #include <stdio.h> +#include <stdbool.h> #include <string.h> #include <math.h> #include <errno.h> @@ -88,12 +88,12 @@ static const char filename[] = "custom_dir_EXIF_231.tif"; static const char filenameBigTiff[] = "custom_dir_EXIF_231_Big.tif"; #define SPP 3 /* Samples per pixel */ -const uint16 width = 1; -const uint16 length = 1; -const uint16 bps = 8; -const uint16 photometric = PHOTOMETRIC_RGB; -const uint16 rows_per_strip = 1; -const uint16 planarconfig = PLANARCONFIG_CONTIG; +const uint16_t width = 1; +const uint16_t length = 1; +const uint16_t bps = 8; +const uint16_t photometric = PHOTOMETRIC_RGB; +const uint16_t rows_per_strip = 1; +const uint16_t planarconfig = PLANARCONFIG_CONTIG; int @@ -150,9 +150,9 @@ int write_test_tiff(TIFF *tif, const char *filenameRead) { unsigned char buf[SPP] = { 0, 127, 255 }; - uint64 dir_offset = 0; - uint64 dir_offset_GPS = 0, dir_offset_EXIF = 0; - uint64 read_dir_offset = 0; + uint64_t dir_offset = 0; + uint64_t dir_offset_GPS = 0, dir_offset_EXIF = 0; + uint64_t read_dir_offset = 0; /*-- Additional variables --*/ int retCode, retCode2; unsigned char exifVersion[4] = {'0','2','3','1'}; /* EXIF 2.31 version is 4 characters of a string! */ @@ -161,7 +161,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) float auxFloat = 0.0f; double auxDouble = 0.0; char auxChar = 0; - uint32 auxUint32 = 0; + uint32_t auxUint32 = 0; short auxShort=0; long auxLong = 0; void *pVoid; @@ -200,7 +200,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) float auxFloatArrayN2[3] = { -1.0f / 7.0f, -61.23456789012345f, -62.3f }; /* -- Variables for reading -- */ - uint16 count16 = 0; + uint16_t count16 = 0; union { long Long; short Short1; @@ -332,7 +332,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) goto failure; } - /*- Varable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */ + /*- Variable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */ if (!TIFFSetField(tif, TIFFTAG_BLACKLEVEL, 3, auxFloatArrayN1)) { fprintf(stderr, "Can't set TIFFTAG_BLACKLEVEL tag.\n"); goto failure; @@ -597,6 +597,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) nTags = tFieldArray->count; for (i=0; i<nTags; i++) { + bool deferredSetField = false; tTag = tFieldArray->fields[i].field_tag; tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ tWriteCount = tFieldArray->fields[i].field_writecount; @@ -659,7 +660,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ /*-- Check, if it is a single parameter, a fixed array or a variable array */ if (tWriteCount == 1) { - fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); } else { /*-- Either fix or variable array --*/ /* For arrays, distinguishing between float or double is essential, even for writing */ @@ -690,46 +691,55 @@ write_test_tiff(TIFF *tif, const char *filenameRead) case TIFF_SETGET_C32_SINT8: /* For arrays, distinguishing between float or double is essential, even for writing */ pVoid = &auxCharArrayW[i]; + deferredSetField = true; + break; case TIFF_SETGET_C0_UINT16: case TIFF_SETGET_C0_SINT16: case TIFF_SETGET_C16_UINT16: case TIFF_SETGET_C16_SINT16: case TIFF_SETGET_C32_UINT16: case TIFF_SETGET_C32_SINT16: - if (pVoid == NULL) pVoid = &auxShortArrayW[i]; + pVoid = &auxShortArrayW[i]; + deferredSetField = true; + break; case TIFF_SETGET_C0_UINT32: case TIFF_SETGET_C0_SINT32: case TIFF_SETGET_C16_UINT32: case TIFF_SETGET_C16_SINT32: case TIFF_SETGET_C32_UINT32: case TIFF_SETGET_C32_SINT32: - if (pVoid == NULL) pVoid = &auxLongArrayW[i]; - /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array or a variable array */ - if (tWriteCount == 1) { - fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + pVoid = &auxLongArrayW[i]; + deferredSetField = true; + break; + default: + fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); + }; /*-- switch() --*/ + + if (deferredSetField) { + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf(stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", + tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFSetField(tif, tTag, pVoid)) { + fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } } else { - /*-- Either fix or variable array --*/ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) { - /* fixed array with needed arraysize defined in .field_writecount */ - if (!TIFFSetField( tif, tTag, pVoid)) { - fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); - goto failure; - } - } else { - /* special treatment of variable array */ - /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ - if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) { - fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); - goto failure; - } + /* special treatment of variable array */ + /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ + if (!TIFFSetField(tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) { + fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; } } - break; - default: - fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); - }; /*-- switch() --*/ + } + } } /*-- for() --*/ /*================= EXIF: END Writing arbitrary data to the EXIF fields END END END ==============*/ #endif /*-- WRITE_ALL_EXIF_TAGS --*/ @@ -784,12 +794,12 @@ write_test_tiff(TIFF *tif, const char *filenameRead) retCode = TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32 ); if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGEWIDTH"); } if (auxUint32 != width) { - fprintf (stderr, "Read value of IMAGEWIDTH %d differs from set value %d\n", auxUint32, width); + fprintf (stderr, "Read value of IMAGEWIDTH %"PRIu32" differs from set value %"PRIu16"\n", auxUint32, width); } retCode = TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32 ); if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGELENGTH"); } if (auxUint32 != width) { - fprintf (stderr, "Read value of TIFFTAG_IMAGELENGTH %d differs from set value %d\n", auxUint32, length); + fprintf (stderr, "Read value of TIFFTAG_IMAGELENGTH %"PRIu32" differs from set value %"PRIu16"\n", auxUint32, length); } #ifdef ADDITIONAL_TAGS @@ -956,7 +966,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* New interface allows also double precision for TIFF_RATIONAL */ auxDouble = auxDblUnion.dbl; } else { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */ auxDouble = (double)auxDblUnion.flt1; } /* compare read values with written ones */ @@ -999,7 +1009,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* New interface allows also double precision for TIFF_RATIONAL */ auxDouble = auxDblUnion.dbl; } else { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */ auxDouble = (double)auxDblUnion.flt1; } /* compare read values with written ones */ @@ -1027,7 +1037,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* New interface allows also double precision for TIFF_RATIONAL */ auxDouble = auxDblUnion.dbl; } else { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */ auxDouble = (double)auxDblUnion.flt1; } /* compare read values with written ones */ @@ -1078,6 +1088,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) } for (i=0; i<nTags; i++) { + bool deferredSetField = false; tTag = tFieldArray->fields[i].field_tag; tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ tWriteCount = tFieldArray->fields[i].field_writecount; @@ -1096,7 +1107,8 @@ write_test_tiff(TIFF *tif, const char *filenameRead) break; } /* Save string from temporary buffer and compare with written string. */ - strncpy(auxCharArray, pAscii, sizeof(auxCharArray)); + strncpy(auxCharArray, pAscii, sizeof(auxCharArray) - 1u); + auxCharArray[sizeof(auxCharArray) - 1u] = '\0'; if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxCharArray); retCode2 = strncmp(auxCharArray, auxTextArrayW[i], auxLong); if (retCode2 != 0) { @@ -1188,7 +1200,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) auxDouble = auxDblUnion.dbl; } else { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE always as FLOAT */ auxDouble = (double)auxDblUnion.flt1; } } @@ -1216,7 +1228,7 @@ write_test_tiff(TIFF *tif, const char *filenameRead) /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ /*-- Check, if it is a single parameter, a fixed array or a variable array */ if (tWriteCount == 1) { - fprintf (stderr, "Reading: WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + fprintf (stderr, "Reading: WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); } else { /*-- Either fix or variable array --*/ /* For arrays, distinguishing between float or double is essential. */ @@ -1277,99 +1289,113 @@ write_test_tiff(TIFF *tif, const char *filenameRead) case TIFF_SETGET_C32_SINT8: /* For arrays, distinguishing between float or double is essential, even for writing */ pVoid = &auxCharArrayW[i]; - case TIFF_SETGET_C0_UINT16: + deferredSetField = true; + break; + case TIFF_SETGET_C0_UINT16: case TIFF_SETGET_C0_SINT16: case TIFF_SETGET_C16_UINT16: case TIFF_SETGET_C16_SINT16: case TIFF_SETGET_C32_UINT16: case TIFF_SETGET_C32_SINT16: - if (pVoid == NULL) pVoid = &auxShortArrayW[i]; + pVoid = &auxShortArrayW[i]; + deferredSetField = true; +break; case TIFF_SETGET_C0_UINT32: case TIFF_SETGET_C0_SINT32: case TIFF_SETGET_C16_UINT32: case TIFF_SETGET_C16_SINT32: case TIFF_SETGET_C32_UINT32: case TIFF_SETGET_C32_SINT32: - if (pVoid == NULL) pVoid = &auxLongArrayW[i]; - /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array or a variable array */ - if (tWriteCount == 1) { - fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + pVoid = &auxLongArrayW[i]; + deferredSetField = true; + break; + default: + fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); + GOTOFAILURE + }; /*-- switch() --*/ + + if(deferredSetField) { + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf(stderr, "WriteCount for .set_field_type %d should be -1 or greater than 1! %s\n", + tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFGetField(tif, tTag, &pVoidArray)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* set tWriteCount to number of read samples for next steps */ + auxLong = tWriteCount; } else { - /*-- Either fix or variable array --*/ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) { - /* fixed array with needed arraysize defined in .field_writecount */ - if (!TIFFGetField( tif, tTag, &pVoidArray)) { - fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* set tWriteCount to number of read samples for next steps */ - auxLong = tWriteCount; - } else { - /* special treatment of variable array */ - /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ - if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) { - fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* set tWriteCount to number of read samples for next steps */ - auxLong = unionLong.Short1; + /* special treatment of variable array */ + /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ + if (!TIFFGetField(tif, tTag, &unionLong, &pVoidArray)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; } - /* Save values from temporary array */ - if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 || - tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 || - tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8 ) { - memcpy(&auxCharArray, pVoidArray,(auxLong * sizeof(auxCharArray[0]))); - /* Compare and check values */ - for (j=0; j<auxLong; j++) { - if (tTag == EXIFTAG_EXIFVERSION) { - /*-- Use exifVersion[] instead of auxCharArrayW[] for differently set EXIFVERSION tag */ - if (auxCharArray[j] != exifVersion[j]) { - fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } else { - if (auxCharArray[j] != auxCharArrayW[i + j]) { - fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxCharArray[j], auxCharArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } - } - } else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || tSetFieldType == TIFF_SETGET_C0_SINT16 || - tSetFieldType == TIFF_SETGET_C16_UINT16 || tSetFieldType == TIFF_SETGET_C16_SINT16 || - tSetFieldType == TIFF_SETGET_C32_UINT16 || tSetFieldType == TIFF_SETGET_C32_SINT16 ) { - memcpy(&auxShortArray, pVoidArray,(auxLong * sizeof(auxShortArray[0]))); - /* Compare and check values */ - for (j=0; j<auxLong; j++) { - if (auxShortArray[j] != auxShortArrayW[i+j]) { - fprintf (stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, auxShortArray[j], auxShortArrayW[i+j]); + /* set tWriteCount to number of read samples for next steps */ + auxLong = unionLong.Short1; + } + /* Save values from temporary array */ + if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 || + tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 || + tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8) { + memcpy(&auxCharArray, pVoidArray, (auxLong * sizeof(auxCharArray[0]))); + /* Compare and check values */ + for (j = 0; j < auxLong; j++) { + if (tTag == EXIFTAG_EXIFVERSION) { + /*-- Use exifVersion[] instead of auxCharArrayW[] for differently set EXIFVERSION tag */ + if (auxCharArray[j] != exifVersion[j]) { + fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, + j, auxCharArray[j], auxCharArrayW[i + j]); GOTOFAILURE_ALL_EXIF } - } - } else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || tSetFieldType == TIFF_SETGET_C0_SINT32 || - tSetFieldType == TIFF_SETGET_C16_UINT32 || tSetFieldType == TIFF_SETGET_C16_SINT32 || - tSetFieldType == TIFF_SETGET_C32_UINT32 || tSetFieldType == TIFF_SETGET_C32_SINT32 ) { - memcpy(&auxLongArray, pVoidArray,(auxLong * sizeof(auxLongArray[0]))); - /* Compare and check values */ - for (j=0; j<auxLong; j++) { - if (auxLongArray[j] != auxLongArrayW[i+j]) { - fprintf (stderr, "Read value %d of %s #%d %ld differs from set value %ld\n", i, tFieldName, j, auxLongArray[j], auxLongArrayW[i+j]); + } else { + if (auxCharArray[j] != auxCharArrayW[i + j]) { + fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, + j, auxCharArray[j], auxCharArrayW[i + j]); GOTOFAILURE_ALL_EXIF } } - } else { - fprintf (stderr, "SetFieldType %d not defined within switch case reading for UINT for %s.\n", tSetFieldType, tFieldName); - GOTOFAILURE } + } else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || tSetFieldType == TIFF_SETGET_C0_SINT16 || + tSetFieldType == TIFF_SETGET_C16_UINT16 || tSetFieldType == TIFF_SETGET_C16_SINT16 || + tSetFieldType == TIFF_SETGET_C32_UINT16 || tSetFieldType == TIFF_SETGET_C32_SINT16) { + memcpy(&auxShortArray, pVoidArray, (auxLong * sizeof(auxShortArray[0]))); + /* Compare and check values */ + for (j = 0; j < auxLong; j++) { + if (auxShortArray[j] != auxShortArrayW[i + j]) { + fprintf(stderr, "Read value %d of %s #%d %d differs from set value %d\n", i, tFieldName, j, + auxShortArray[j], auxShortArrayW[i + j]); + GOTOFAILURE_ALL_EXIF + } + } + } else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || tSetFieldType == TIFF_SETGET_C0_SINT32 || + tSetFieldType == TIFF_SETGET_C16_UINT32 || tSetFieldType == TIFF_SETGET_C16_SINT32 || + tSetFieldType == TIFF_SETGET_C32_UINT32 || tSetFieldType == TIFF_SETGET_C32_SINT32) { + memcpy(&auxLongArray, pVoidArray, (auxLong * sizeof(auxLongArray[0]))); + /* Compare and check values */ + for (j = 0; j < auxLong; j++) { + if (auxLongArray[j] != auxLongArrayW[i + j]) { + fprintf(stderr, "Read value %d of %s #%d %ld differs from set value %ld\n", i, tFieldName, + j, auxLongArray[j], auxLongArrayW[i + j]); + GOTOFAILURE_ALL_EXIF + } + } + } else { + fprintf(stderr, "SetFieldType %d not defined within switch case reading for UINT for %s.\n", + tSetFieldType, tFieldName); + GOTOFAILURE } - break; - default: - fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); - GOTOFAILURE - }; /*-- switch() --*/ + } + } } /*-- for() --*/ /*================= EXIF: END Reading arbitrary data to the EXIF fields END END END ==============*/ #endif /*-- READ_ALL_EXIF_TAGS --*/ diff --git a/tiff/test/defer_strile_writing.c b/tiff/test/defer_strile_writing.c index 4e358567..b918a228 100644 --- a/tiff/test/defer_strile_writing.c +++ b/tiff/test/defer_strile_writing.c @@ -131,7 +131,7 @@ int test(const char* mode, int tiled, int height) ret = TIFFForceStrileArrayWriting(tif); assert(ret); - /* Now write data on frist directory */ + /* Now write data on first directory */ ret = TIFFSetDirectory( tif, 0 ); assert(ret); diff --git a/tiff/test/long_tag.c b/tiff/test/long_tag.c index 4bfdf805..79f0235c 100644 --- a/tiff/test/long_tag.c +++ b/tiff/test/long_tag.c @@ -37,22 +37,22 @@ #include "tiffio.h" -extern int CheckLongField(TIFF *, ttag_t, uint32); +extern int CheckLongField(TIFF *, ttag_t, uint32_t); const char *filename = "long_test.tiff"; static struct Tags { ttag_t tag; short count; - uint32 value; + uint32_t value; } long_tags[] = { { TIFFTAG_SUBFILETYPE, 1, FILETYPE_REDUCEDIMAGE|FILETYPE_PAGE|FILETYPE_MASK } }; #define NTAGS (sizeof (long_tags) / sizeof (long_tags[0])) -const uint32 width = 1; -const uint32 length = 1; -const uint32 rows_per_strip = 1; +const uint32_t width = 1; +const uint32_t length = 1; +const uint32_t rows_per_strip = 1; int main(int argc, char **argv) diff --git a/tiff/test/rational_precision2double.c b/tiff/test/rational_precision2double.c index e33cc97d..4e5c0bbf 100644 --- a/tiff/test/rational_precision2double.c +++ b/tiff/test/rational_precision2double.c @@ -72,12 +72,12 @@ int write_test_tiff(TIFF *tif, const char *filenameRead, int blnAllCustomTags); #define SPP 3 /* Samples per pixel */ -const uint16 width = 1; -const uint16 length = 1; -const uint16 bps = 8; -const uint16 photometric = PHOTOMETRIC_RGB; -const uint16 rows_per_strip = 1; -const uint16 planarconfig = PLANARCONFIG_CONTIG; +const uint16_t width = 1; +const uint16_t length = 1; +const uint16_t bps = 8; +const uint16_t photometric = PHOTOMETRIC_RGB; +const uint16_t rows_per_strip = 1; +const uint16_t planarconfig = PLANARCONFIG_CONTIG; /*-- Additional custom TIFF tags for testing of Rational2Double precision --*/ #define TIFFTAG_RATIONAL_DOUBLE 60000 @@ -148,11 +148,11 @@ It merges in our new fields and then calls the next extender if there is one in static void _XTIFFDefaultDirectory(TIFF *tif) { - uint32 n, nadded; + uint32_t n, nadded; /* Install the extended Tag field info */ n = N(tifFieldInfo); - //_TIFFMergeFields(tif, const TIFFField info[], uint32 n); + //_TIFFMergeFields(tif, const TIFFField info[], uint32_t n); nadded = _TIFFMergeFields(tif, tifFieldInfo, n); (void)nadded; @@ -261,8 +261,8 @@ write_test_tiff(TIFF* tif, const char* filenameRead, int blnAllCustomTags) { int retCode; float auxFloat = 0.0f; double auxDouble = 0.0; - uint16 auxUint16 = 0; - uint32 auxUint32 = 0; + uint16_t auxUint16 = 0; + uint32_t auxUint32 = 0; long auxLong = 0; void* pVoid; int blnIsRational2Double; @@ -292,7 +292,7 @@ write_test_tiff(TIFF* tif, const char* filenameRead, int blnAllCustomTags) { float auxFloatArrayResolutions[4] = {5.456789f, 6.666666f, 0.0033f, 5.0f / 213.0f}; /* -- Variables for reading -- */ - uint16 count16 = 0; + uint16_t count16 = 0; union { long Long; short Short1; diff --git a/tiff/test/raw_decode.c b/tiff/test/raw_decode.c index a2fca03a..b8d12aa6 100644 --- a/tiff/test/raw_decode.c +++ b/tiff/test/raw_decode.c @@ -59,7 +59,7 @@ "JPEGLib: JPEG parameter struct mismatch: library thinks size is 432, caller expects 464" - For such users we wil fix the problem here. See install.doc file from + For such users we will fix the problem here. See install.doc file from the JPEG library distribution for details. */ @@ -120,24 +120,24 @@ static int check_rgb_pixel( int pixel, return 1; } -static int check_rgba_pixel( int pixel, - int min_red, int max_red, - int min_green, int max_green, - int min_blue, int max_blue, - int min_alpha, int max_alpha, - uint32 *buffer ) { +static int check_rgba_pixel(int pixel, + int min_red, int max_red, + int min_green, int max_green, + int min_blue, int max_blue, + int min_alpha, int max_alpha, + uint32_t *buffer ) { /* RGBA images are upside down - adjust for normal ordering */ int adjusted_pixel = pixel % 128 + (127 - (pixel/128)) * 128; - uint32 rgba = buffer[adjusted_pixel]; - - if( TIFFGetR(rgba) >= (uint32) min_red && - TIFFGetR(rgba) <= (uint32) max_red && - TIFFGetG(rgba) >= (uint32) min_green && - TIFFGetG(rgba) <= (uint32) max_green && - TIFFGetB(rgba) >= (uint32) min_blue && - TIFFGetB(rgba) <= (uint32) max_blue && - TIFFGetA(rgba) >= (uint32) min_alpha && - TIFFGetA(rgba) <= (uint32) max_alpha ) { + uint32_t rgba = buffer[adjusted_pixel]; + + if( TIFFGetR(rgba) >= (uint32_t) min_red && + TIFFGetR(rgba) <= (uint32_t) max_red && + TIFFGetG(rgba) >= (uint32_t) min_green && + TIFFGetG(rgba) <= (uint32_t) max_green && + TIFFGetB(rgba) >= (uint32_t) min_blue && + TIFFGetB(rgba) <= (uint32_t) max_blue && + TIFFGetA(rgba) >= (uint32_t) min_alpha && + TIFFGetA(rgba) <= (uint32_t) max_alpha ) { return 0; } @@ -160,7 +160,7 @@ main(int argc, char **argv) unsigned short h, v; int status; unsigned char *buffer; - uint32 *rgba_buffer; + uint32_t *rgba_buffer; tsize_t sz, szout; unsigned int pixel_status = 0; @@ -261,8 +261,8 @@ main(int argc, char **argv) */ tif = TIFFOpen(srcfile,"r"); - sz = 128 * 128 * sizeof(uint32); - rgba_buffer = (uint32 *) malloc(sz); + sz = 128 * 128 * sizeof(uint32_t); + rgba_buffer = (uint32_t *) malloc(sz); if (!TIFFReadRGBATile( tif, 1*128, 2*128, rgba_buffer )) { fprintf( stderr, "TIFFReadRGBATile() returned failure code.\n" ); @@ -271,7 +271,7 @@ main(int argc, char **argv) /* * Currently TIFFReadRGBATile() just uses JPEGCOLORMODE_RGB so this - * trivally matches the last results. Eventually we should actually + * trivially matches the last results. Eventually we should actually * accomplish it from the YCbCr subsampled buffer ourselves in which * case the results may be subtly different but similar. */ diff --git a/tiff/test/rewrite_tag.c b/tiff/test/rewrite_tag.c index 1708b024..2c988e3b 100644 --- a/tiff/test/rewrite_tag.c +++ b/tiff/test/rewrite_tag.c @@ -39,8 +39,8 @@ #include "tiffio.h" #include "tiffiop.h" -const uint32 length = 40; -const uint32 rows_per_strip = 1; +const uint32_t length = 40; +const uint32_t rows_per_strip = 1; int test_packbits() @@ -49,7 +49,7 @@ int test_packbits() int i; unsigned char buf[10] = {0,0,0,0,0,0,0,0,0,0}; - uint32 width = 10; + uint32_t width = 10; int length = 20; const char *filename = "test_packbits.tif"; @@ -137,16 +137,16 @@ int test_packbits() /************************************************************************/ /* rewrite_test() */ /************************************************************************/ -int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, - uint64 base_value ) +int rewrite_test(const char *filename, uint32_t width, int length, int bigtiff, + uint64_t base_value ) { TIFF *tif; int i; unsigned char *buf; - uint64 *rowoffset, *rowbytes; - uint64 *upd_rowoffset; - uint64 *upd_bytecount; + uint64_t *rowoffset, *rowbytes; + uint64_t *upd_rowoffset = NULL; + uint64_t *upd_bytecount = NULL; buf = calloc(1, width); assert(buf); @@ -223,7 +223,7 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, goto failure; } - upd_rowoffset = (uint64 *) _TIFFmalloc(sizeof(uint64) * length); + upd_rowoffset = (uint64_t *) _TIFFmalloc(sizeof(uint64_t) * length); for( i = 0; i < length; i++ ) upd_rowoffset[i] = base_value + i*width; @@ -235,8 +235,9 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, } _TIFFfree( upd_rowoffset ); + upd_rowoffset = NULL; - upd_bytecount = (uint64 *) _TIFFmalloc(sizeof(uint64) * length); + upd_bytecount = (uint64_t *) _TIFFmalloc(sizeof(uint64_t) * length); for( i = 0; i < length; i++ ) upd_bytecount[i] = 100 + i*width; @@ -248,6 +249,7 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, } _TIFFfree( upd_bytecount ); + upd_bytecount = NULL; TIFFClose(tif); @@ -268,7 +270,7 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, for( i = 0; i < length; i++ ) { - uint64 expect = base_value + i*width; + uint64_t expect = base_value + i * width; if( rowoffset[i] != expect ) { @@ -291,7 +293,7 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, for( i = 0; i < length; i++ ) { - uint64 expect = 100 + i*width; + uint64_t expect = 100 + i * width; if( rowbytes[i] != expect ) { @@ -317,6 +319,14 @@ int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, /* Something goes wrong; close file and return unsuccessful status. */ TIFFClose(tif); free(buf); + if( upd_rowoffset != NULL ) + { + _TIFFfree( upd_rowoffset ); + } + if ( upd_bytecount != NULL ) + { + _TIFFfree( upd_bytecount ); + } /* unlink(filename); */ return 1; diff --git a/tiff/test/short_tag.c b/tiff/test/short_tag.c index 75e7f5d5..89197b02 100644 --- a/tiff/test/short_tag.c +++ b/tiff/test/short_tag.c @@ -41,16 +41,16 @@ static const char filename[] = "short_test.tiff"; #define SPP 3 /* Samples per pixel */ -const uint16 width = 1; -const uint16 length = 1; -const uint16 bps = 8; -const uint16 photometric = PHOTOMETRIC_RGB; -const uint16 rows_per_strip = 1; -const uint16 planarconfig = PLANARCONFIG_CONTIG; +const uint16_t width = 1; +const uint16_t length = 1; +const uint16_t bps = 8; +const uint16_t photometric = PHOTOMETRIC_RGB; +const uint16_t rows_per_strip = 1; +const uint16_t planarconfig = PLANARCONFIG_CONTIG; static const struct { const ttag_t tag; - const uint16 value; + const uint16_t value; } short_single_tags[] = { { TIFFTAG_COMPRESSION, COMPRESSION_NONE }, { TIFFTAG_FILLORDER, FILLORDER_MSB2LSB }, @@ -66,7 +66,7 @@ static const struct { static const struct { const ttag_t tag; - const uint16 values[2]; + const uint16_t values[2]; } short_paired_tags[] = { { TIFFTAG_PAGENUMBER, {1, 1} }, { TIFFTAG_HALFTONEHINTS, {0, 255} }, @@ -121,8 +121,8 @@ main() for (i = 0; i < NSINGLETAGS; i++) { if (!TIFFSetField(tif, short_single_tags[i].tag, short_single_tags[i].value)) { - fprintf(stderr, "Can't set tag %lu.\n", - (unsigned long)short_single_tags[i].tag); + fprintf(stderr, "Can't set tag %"PRIu32".\n", + short_single_tags[i].tag); goto failure; } } @@ -131,8 +131,8 @@ main() if (!TIFFSetField(tif, short_paired_tags[i].tag, short_paired_tags[i].values[0], short_paired_tags[i].values[1])) { - fprintf(stderr, "Can't set tag %lu.\n", - (unsigned long)short_paired_tags[i].tag); + fprintf(stderr, "Can't set tag %"PRIu32".\n", + short_paired_tags[i].tag); goto failure; } } diff --git a/tiff/test/strip.c b/tiff/test/strip.c index f2cb7735..004a66a2 100644 --- a/tiff/test/strip.c +++ b/tiff/test/strip.c @@ -57,8 +57,8 @@ write_strips(TIFF *tif, const tdata_t array, const tsize_t size) if (TIFFWriteEncodedStrip(tif, strip, (char *)array + offset, bufsize) != bufsize) { - fprintf (stderr, "Can't write strip %lu.\n", - (unsigned long)strip); + fprintf (stderr, "Can't write strip %"PRIu32".\n", + strip); return -1; } } @@ -97,13 +97,13 @@ read_strips(TIFF *tif, const tdata_t array, const tsize_t size) bufsize = stripsize; if (TIFFReadEncodedStrip(tif, strip, buf, -1) != bufsize) { - fprintf (stderr, "Can't read strip %lu.\n", - (unsigned long)strip); + fprintf (stderr, "Can't read strip %"PRIu32".\n", + strip); return -1; } if (memcmp(buf, (char *)array + offset, bufsize) != 0) { - fprintf (stderr, "Wrong data read for strip %lu.\n", - (unsigned long)strip); + fprintf (stderr, "Wrong data read for strip %"PRIu32".\n", + strip); _TIFFfree(buf); return -1; } @@ -115,11 +115,11 @@ read_strips(TIFF *tif, const tdata_t array, const tsize_t size) } int -create_image_striped(const char *name, uint32 width, uint32 length, - uint32 rowsperstrip, uint16 compression, - uint16 spp, uint16 bps, uint16 photometric, - uint16 sampleformat, uint16 planarconfig, - const tdata_t array, const tsize_t size) +create_image_striped(const char *name, uint32_t width, uint32_t length, + uint32_t rowsperstrip, uint16_t compression, + uint16_t spp, uint16_t bps, uint16_t photometric, + uint16_t sampleformat, uint16_t planarconfig, + const tdata_t array, const tsize_t size) { TIFF *tif; @@ -169,25 +169,25 @@ failure: TIFFClose(tif); openfailure: fprintf (stderr, "Can't create test TIFF file %s:\n" -" ImageWidth=%ld, ImageLength=%ld, RowsPerStrip=%ld, Compression=%d,\n" -" BitsPerSample=%d, SamplesPerPixel=%d, SampleFormat=%d,\n" -" PlanarConfiguration=%d, PhotometricInterpretation=%d.\n", - name, (long) width, (long) length, (long) rowsperstrip, +" ImageWidth=%"PRIu32", ImageLength=%"PRIu32", RowsPerStrip=%"PRIu32", Compression=%"PRIu16",\n" +" BitsPerSample=%"PRIu16", SamplesPerPixel=%"PRIu16", SampleFormat=%"PRIu16",\n" +" PlanarConfiguration=%"PRIu16", PhotometricInterpretation=%"PRIu16".\n", + name, width, length, rowsperstrip, compression, bps, spp, sampleformat, planarconfig, photometric); return -1; } int -read_image_striped(const char *name, uint32 width, uint32 length, - uint32 rowsperstrip, uint16 compression, - uint16 spp, uint16 bps, uint16 photometric, - uint16 sampleformat, uint16 planarconfig, - const tdata_t array, const tsize_t size) +read_image_striped(const char *name, uint32_t width, uint32_t length, + uint32_t rowsperstrip, uint16_t compression, + uint16_t spp, uint16_t bps, uint16_t photometric, + uint16_t sampleformat, uint16_t planarconfig, + const tdata_t array, const tsize_t size) { TIFF *tif; - uint16 value_u16; - uint32 value_u32; + uint16_t value_u16; + uint32_t value_u32; /* Test whether we can read written values. */ tif = TIFFOpen(name, "r"); @@ -247,10 +247,10 @@ failure: TIFFClose(tif); openfailure: fprintf (stderr, "Can't read test TIFF file %s:\n" -" ImageWidth=%ld, ImageLength=%ld, RowsPerStrip=%ld, Compression=%d,\n" -" BitsPerSample=%d, SamplesPerPixel=%d, SampleFormat=%d,\n" -" PlanarConfiguration=%d, PhotometricInterpretation=%d.\n", - name, (long) width, (long) length, (long) rowsperstrip, +" ImageWidth=%"PRIu32", ImageLength=%"PRIu32", RowsPerStrip=%"PRIu32", Compression=%"PRIu16",\n" +" BitsPerSample=%"PRIu16", SamplesPerPixel=%"PRIu16", SampleFormat=%"PRIu16",\n" +" PlanarConfiguration=%"PRIu16", PhotometricInterpretation=%"PRIu16".\n", + name, width, length, rowsperstrip, compression, bps, spp, sampleformat, planarconfig, photometric); return -1; @@ -259,7 +259,7 @@ openfailure: int write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size) { - uint32 length, row; + uint32_t length, row; tsize_t scanlinesize, offset; (void) size; @@ -277,7 +277,7 @@ write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size) for (offset = 0, row = 0; row < length; offset+=scanlinesize, row++) { if (TIFFWriteScanline(tif, (char *)array + offset, row, 0) == -1) { fprintf (stderr, - "Can't write image data at row %lu.\n", (long) row); + "Can't write image data at row %"PRIu32".\n", row); return -1; } } diff --git a/tiff/test/strip_rw.c b/tiff/test/strip_rw.c index bcf7d735..866329b1 100644 --- a/tiff/test/strip_rw.c +++ b/tiff/test/strip_rw.c @@ -39,22 +39,22 @@ #include "test_arrays.h" extern int -create_image_striped(const char *, uint32, uint32, uint32, uint16, uint16, - uint16, uint16, uint16, uint16, const tdata_t, - const tsize_t); +create_image_striped(const char *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t, + uint16_t, uint16_t, uint16_t, uint16_t, const tdata_t, + const tsize_t); extern int -read_image_striped(const char *, uint32, uint32, uint32, uint16, uint16, - uint16, uint16, uint16, uint16, const tdata_t, - const tsize_t); +read_image_striped(const char *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t, + uint16_t, uint16_t, uint16_t, uint16_t, const tdata_t, + const tsize_t); const char *filename = "strip_test.tiff"; int main(int argc, char **argv) { - uint32 rowsperstrip; - uint16 compression; - uint16 spp, bps, photometric, sampleformat, planarconfig; + uint32_t rowsperstrip; + uint16_t compression; + uint16_t spp, bps, photometric, sampleformat, planarconfig; (void) argc; (void) argv; diff --git a/tiff/test/testtypes.c b/tiff/test/testtypes.c index a36d21e5..0405b94f 100644 --- a/tiff/test/testtypes.c +++ b/tiff/test/testtypes.c @@ -42,16 +42,15 @@ int main() { - CHECK_TYPE(TIFF_INT8_T, 1) - CHECK_TYPE(TIFF_INT16_T, 2) - CHECK_TYPE(TIFF_INT32_T, 4) - CHECK_TYPE(TIFF_INT64_T, 8) - CHECK_TYPE(TIFF_UINT8_T, 1) - CHECK_TYPE(TIFF_UINT16_T, 2) - CHECK_TYPE(TIFF_UINT32_T, 4) - CHECK_TYPE(TIFF_UINT64_T, 8) - CHECK_TYPE(TIFF_SIZE_T, sizeof(size_t)) - CHECK_TYPE(TIFF_SSIZE_T, sizeof(size_t)) + CHECK_TYPE(int8_t, 1) + CHECK_TYPE(int16_t, 2) + CHECK_TYPE(int32_t, 4) + CHECK_TYPE(int64_t, 8) + CHECK_TYPE(uint8_t, 1) + CHECK_TYPE(uint16_t, 2) + CHECK_TYPE(uint32_t, 4) + CHECK_TYPE(uint64_t, 8) + CHECK_TYPE(tmsize_t , sizeof(size_t)) return 0; } diff --git a/tiff/test/tifftest.h b/tiff/test/tifftest.h index 391b0f64..694f66cc 100644 --- a/tiff/test/tifftest.h +++ b/tiff/test/tifftest.h @@ -32,9 +32,9 @@ #include "tiffio.h" -int CheckShortField(TIFF *, const ttag_t, const uint16); -int CheckShortPairedField(TIFF *, const ttag_t, const uint16*); -int CheckLongField(TIFF *, const ttag_t, const uint32); +int CheckShortField(TIFF *, const ttag_t, const uint16_t); +int CheckShortPairedField(TIFF *, const ttag_t, const uint16_t*); +int CheckLongField(TIFF *, const ttag_t, const uint32_t); #endif /* _TIFFTEST_ */ diff --git a/tiff/tools/CMakeLists.txt b/tiff/tools/CMakeLists.txt index ff2a1ddc..66b8e0bb 100644..100755 --- a/tiff/tools/CMakeLists.txt +++ b/tiff/tools/CMakeLists.txt @@ -22,73 +22,88 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -extra_dist(Makefile.vc) +add_executable(fax2ps) +target_sources(fax2ps PRIVATE fax2ps.c) +target_link_libraries(fax2ps PRIVATE tiff port) -include_directories(${PROJECT_SOURCE_DIR}/libtiff - ${PROJECT_BINARY_DIR}/libtiff - ${PROJECT_SOURCE_DIR}/port - ${CMAKE_CURRENT_BINARY_DIR}) +add_executable(fax2tiff) +target_sources(fax2tiff PRIVATE fax2tiff.c) +target_link_libraries(fax2tiff PRIVATE tiff port) -add_executable(fax2ps fax2ps.c) -target_link_libraries(fax2ps tiff port) +add_executable(pal2rgb) +target_sources(pal2rgb PRIVATE pal2rgb.c) +target_link_libraries(pal2rgb PRIVATE tiff port) -add_executable(fax2tiff fax2tiff.c) -target_link_libraries(fax2tiff tiff port) +add_executable(ppm2tiff) +target_sources(ppm2tiff PRIVATE ppm2tiff.c) +target_link_libraries(ppm2tiff PRIVATE tiff port) -add_executable(pal2rgb pal2rgb.c) -target_link_libraries(pal2rgb tiff port) +add_executable(raw2tiff) +target_sources(raw2tiff PRIVATE raw2tiff.c) +target_link_libraries(raw2tiff PRIVATE tiff port CMath::CMath) -add_executable(ppm2tiff ppm2tiff.c) -target_link_libraries(ppm2tiff tiff port) +add_executable(rgb2ycbcr) +target_sources(rgb2ycbcr PRIVATE rgb2ycbcr.c) +target_link_libraries(rgb2ycbcr PRIVATE tiff port) -add_executable(raw2tiff raw2tiff.c) -target_link_libraries(raw2tiff tiff port) +add_executable(thumbnail) +target_sources(thumbnail PRIVATE thumbnail.c) +target_link_libraries(thumbnail PRIVATE tiff port CMath::CMath) -add_executable(rgb2ycbcr rgb2ycbcr.c) -target_link_libraries(rgb2ycbcr tiff port) +add_executable(tiff2bw) +target_sources(tiff2bw PRIVATE tiff2bw.c) +target_link_libraries(tiff2bw PRIVATE tiff port) -add_executable(thumbnail thumbnail.c) -target_link_libraries(thumbnail tiff port) +add_executable(tiff2pdf) +target_sources(tiff2pdf PRIVATE tiff2pdf.c) +target_link_libraries(tiff2pdf PRIVATE tiff port) -add_executable(tiff2bw tiff2bw.c) -target_link_libraries(tiff2bw tiff port) +add_executable(tiff2ps) +target_sources(tiff2ps PRIVATE tiff2ps.c) +target_link_libraries(tiff2ps PRIVATE tiff port CMath::CMath) -add_executable(tiff2pdf tiff2pdf.c) -target_link_libraries(tiff2pdf tiff port) +add_executable(tiff2rgba) +target_sources(tiff2rgba PRIVATE tiff2rgba.c) +target_link_libraries(tiff2rgba PRIVATE tiff port) -add_executable(tiff2ps tiff2ps.c) -target_link_libraries(tiff2ps tiff port) +add_executable(tiffcmp) +target_sources(tiffcmp PRIVATE tiffcmp.c) +target_link_libraries(tiffcmp PRIVATE tiff port) -add_executable(tiff2rgba tiff2rgba.c) -target_link_libraries(tiff2rgba tiff port) +add_executable(tiffcp) +target_sources(tiffcp PRIVATE tiffcp.c) +target_link_libraries(tiffcp PRIVATE tiff port) -add_executable(tiffcmp tiffcmp.c) -target_link_libraries(tiffcmp tiff port) +add_executable(tiffcrop) +target_sources(tiffcrop PRIVATE tiffcrop.c) +target_link_libraries(tiffcrop PRIVATE tiff port CMath::CMath) -add_executable(tiffcp tiffcp.c) -target_link_libraries(tiffcp tiff port) +add_executable(tiffdither) +target_sources(tiffdither PRIVATE tiffdither.c) +target_link_libraries(tiffdither PRIVATE tiff port) -add_executable(tiffcrop tiffcrop.c) -target_link_libraries(tiffcrop tiff port) +add_executable(tiffdump) +target_sources(tiffdump PRIVATE tiffdump.c) +target_link_libraries(tiffdump PRIVATE tiff port) -add_executable(tiffdither tiffdither.c) -target_link_libraries(tiffdither tiff port) +add_executable(tiffinfo) +target_sources(tiffinfo PRIVATE tiffinfo.c) +target_link_libraries(tiffinfo PRIVATE tiff port) -add_executable(tiffdump tiffdump.c) -target_link_libraries(tiffdump tiff port) +add_executable(tiffmedian) +target_sources(tiffmedian PRIVATE tiffmedian.c) +target_link_libraries(tiffmedian PRIVATE tiff port) -add_executable(tiffinfo tiffinfo.c) -target_link_libraries(tiffinfo tiff port) +add_executable(tiffset) +target_sources(tiffset PRIVATE tiffset.c) +target_link_libraries(tiffset PRIVATE tiff port) -add_executable(tiffmedian tiffmedian.c) -target_link_libraries(tiffmedian tiff port) - -add_executable(tiffset tiffset.c) -target_link_libraries(tiffset tiff port) - -add_executable(tiffsplit tiffsplit.c) -target_link_libraries(tiffsplit tiff port) +add_executable(tiffsplit) +target_sources(tiffsplit PRIVATE tiffsplit.c) +target_link_libraries(tiffsplit PRIVATE tiff port) +# rgb2ycbcr and thumbnail are intended to *NOT* be installed. They are for +# testing purposes only. install(TARGETS fax2ps fax2tiff pal2rgb @@ -110,15 +125,10 @@ install(TARGETS fax2ps RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") if(HAVE_OPENGL) - if(OPENGL_INCLUDE_DIR) - include_directories(${OPENGL_INCLUDE_DIR}) - endif() - if(GLUT_INCLUDE_DIR) - include_directories(${GLUT_INCLUDE_DIR}) - endif() - - add_executable(tiffgt tiffgt.c) - target_link_libraries(tiffgt tiff port ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) + add_executable(tiffgt) + target_sources(tiffgt PRIVATE tiffgt.c) + target_link_libraries(tiffgt PRIVATE tiff port) + target_link_libraries(tiffgt PRIVATE OpenGL::GL GLUT::GLUT) install(TARGETS tiffgt RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") diff --git a/tiff/tools/Makefile.am b/tiff/tools/Makefile.am index 3054bee3..c8142b05 100644 --- a/tiff/tools/Makefile.am +++ b/tiff/tools/Makefile.am @@ -27,8 +27,7 @@ LIBPORT = $(top_builddir)/port/libport.la LIBTIFF = $(top_builddir)/libtiff/libtiff.la EXTRA_DIST = \ - CMakeLists.txt \ - Makefile.vc + CMakeLists.txt bin_PROGRAMS = \ fax2ps \ @@ -128,7 +127,7 @@ tiffgt_SOURCES = tiffgt.c tiffgt_CFLAGS = $(CFLAGS) $(GLUT_CFLAGS) $(AM_CFLAGS) tiffgt_LDADD = $(LIBTIFF) $(LIBPORT) $(X_LIBS) $(GLUT_LIBS) -AM_CPPFLAGS = -I$(top_srcdir)/libtiff +AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port echo: (echo $(CFLAGS)) diff --git a/tiff/tools/Makefile.in b/tiff/tools/Makefile.in index 8b1a2460..fc1bff84 100644 --- a/tiff/tools/Makefile.in +++ b/tiff/tools/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -133,8 +133,10 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libtiff/tif_config.h \ - $(top_builddir)/libtiff/tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/libtiff/tif_config.h \ + $(top_builddir)/libtiff/tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HAVE_OPENGL_TRUE@am__EXEEXT_1 = tiffgt$(EXEEXT) @@ -224,7 +226,7 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/libtiff +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/libtiff -I$(top_builddir)/port depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/fax2ps.Po ./$(DEPDIR)/fax2tiff.Po \ @@ -437,6 +439,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -449,8 +452,7 @@ top_srcdir = @top_srcdir@ LIBPORT = $(top_builddir)/port/libport.la LIBTIFF = $(top_builddir)/libtiff/libtiff.la EXTRA_DIST = \ - CMakeLists.txt \ - Makefile.vc + CMakeLists.txt @HAVE_RPATH_TRUE@AM_LDFLAGS = $(LIBDIR) fax2ps_SOURCES = fax2ps.c @@ -496,7 +498,7 @@ tiffsplit_LDADD = $(LIBTIFF) $(LIBPORT) tiffgt_SOURCES = tiffgt.c tiffgt_CFLAGS = $(CFLAGS) $(GLUT_CFLAGS) $(AM_CFLAGS) tiffgt_LDADD = $(LIBTIFF) $(LIBPORT) $(X_LIBS) $(GLUT_LIBS) -AM_CPPFLAGS = -I$(top_srcdir)/libtiff +AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port all: all-am .SUFFIXES: diff --git a/tiff/tools/Makefile.vc b/tiff/tools/Makefile.vc deleted file mode 100644 index 453db43e..00000000 --- a/tiff/tools/Makefile.vc +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> -# -# Permission to use, copy, modify, distribute, and sell this software and -# its documentation for any purpose is hereby granted without fee, provided -# that (i) the above copyright notices and this permission notice appear in -# all copies of the software and related documentation, and (ii) the names of -# Sam Leffler and Silicon Graphics may not be used in any advertising or -# publicity relating to the software without the specific, prior written -# permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# -# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# -# Makefile for MS Visual C and Watcom C compilers. -# -# To build: -# C:\libtiff\tools> nmake /f makefile.vc - -!INCLUDE ..\nmake.opt - -TARGETS = tiffinfo.exe tiffdump.exe fax2tiff.exe \ - fax2ps.exe pal2rgb.exe ppm2tiff.exe \ - rgb2ycbcr.exe thumbnail.exe raw2tiff.exe \ - tiff2bw.exe tiff2rgba.exe tiff2pdf.exe tiff2ps.exe \ - tiffcmp.exe tiffcp.exe tiffcrop.exe tiffdither.exe \ - tiffmedian.exe tiffset.exe tiffsplit.exe - -INCL = -I..\libtiff -I..\port -DNEED_LIBPORT -LIBS = $(LIBS) ..\port\libport.lib ..\libtiff\libtiff.lib - -default: $(TARGETS) - -.c.exe: - $(CC) $(CFLAGS) $*.c $(EXTRA_OBJ) $(LIBS) - -tiffgt.exe: - $(CC) $(CFLAGS) tiffgt.c $(EXTRA_OBJ) $(LIBS) - -clean: - -del *.exe - -del *.exe.manifest - -del *.obj diff --git a/tiff/tools/fax2ps.c b/tiff/tools/fax2ps.c index f59f4921..625574c6 100644 --- a/tiff/tools/fax2ps.c +++ b/tiff/tools/fax2ps.c @@ -22,6 +22,7 @@ * OF THIS SOFTWARE. */ #include "tif_config.h" +#include "libport.h" #include <stdlib.h> #include <stdio.h> @@ -41,10 +42,6 @@ # include <io.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffiop.h" #include "tiffio.h" @@ -75,7 +72,7 @@ int maxline = 512; /* max output line of PostScript */ * March 13-15, 1995. */ static void -printruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) +printruns(unsigned char* buf, uint32_t* runs, uint32_t* erun, uint32_t lastx) { static struct { char white, black; @@ -89,9 +86,9 @@ printruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) static char* svalue = " !\"#$&'*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abc"; int colormode = 1; /* 0 for white, 1 for black */ - uint32 runlength = 0; + uint32_t runlength = 0; int n = maxline; - uint32 x = 0; + uint32_t x = 0; int l; (void) buf; @@ -129,7 +126,7 @@ printruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) l++; } while (runlength > 0 && runlength <= 6) { - uint32 bitsleft = 6; + uint32_t bitsleft = 6; int t = 0; while (bitsleft) { if (runlength <= bitsleft) { @@ -201,10 +198,10 @@ emitFont(FILE* fd) } void -printTIF(TIFF* tif, uint16 pageNumber) +printTIF(TIFF* tif, uint16_t pageNumber) { - uint32 w, h; - uint16 unit, compression; + uint32_t w, h; + uint16_t unit, compression; float xres, yres, scale = 1.0; tstrip_t s, ns; time_t creation_time; @@ -278,10 +275,10 @@ printTIF(TIFF* tif, uint16 pageNumber) TIFFGetField(tif, TIFFTAG_PAGENUMBER, &pn, &ptotal) int -findPage(TIFF* tif, uint16 pageNumber) +findPage(TIFF* tif, uint16_t pageNumber) { - uint16 pn = (uint16) -1; - uint16 ptotal = (uint16) -1; + uint16_t pn = (uint16_t) -1; + uint16_t ptotal = (uint16_t) -1; if (GetPageNumber(tif)) { while (pn != (pageNumber-1) && TIFFReadDirectory(tif) && GetPageNumber(tif)) ; @@ -291,10 +288,10 @@ findPage(TIFF* tif, uint16 pageNumber) } void -fax2ps(TIFF* tif, uint16 npages, uint16* pages, char* filename) +fax2ps(TIFF* tif, uint16_t npages, uint16_t* pages, char* filename) { if (npages > 0) { - uint16 pn, ptotal; + uint16_t pn, ptotal; int i; if (!GetPageNumber(tif)) @@ -307,7 +304,7 @@ fax2ps(TIFF* tif, uint16 npages, uint16* pages, char* filename) fprintf(stderr, "%s: No page number %d\n", filename, pages[i]); } } else { - uint16 pageNumber = 0; + uint16_t pageNumber = 0; do printTIF(tif, pageNumber++); while (TIFFReadDirectory(tif)); @@ -333,7 +330,7 @@ main(int argc, char** argv) extern int optind; extern char* optarg; #endif - uint16 *pages = NULL, npages = 0, pageNumber; + uint16_t *pages = NULL, npages = 0, pageNumber; int c, dowarnings = 0; /* if 1, enable library warnings */ TIFF* tif; @@ -349,11 +346,11 @@ main(int argc, char** argv) pageWidth = (float)atof(optarg); break; case 'p': /* print specific page */ - pageNumber = (uint16)atoi(optarg); + pageNumber = (uint16_t)atoi(optarg); if (pages) - pages = (uint16*) realloc(pages, (npages+1)*sizeof(uint16)); + pages = (uint16_t*) realloc(pages, (npages + 1) * sizeof(uint16_t)); else - pages = (uint16*) malloc(sizeof(uint16)); + pages = (uint16_t*) malloc(sizeof(uint16_t)); if( pages == NULL ) { fprintf(stderr, "Out of memory\n"); @@ -375,11 +372,12 @@ main(int argc, char** argv) break; case 'h': usage(EXIT_SUCCESS); + break; case '?': usage(EXIT_FAILURE); } if (npages > 0) - qsort(pages, npages, sizeof(uint16), pcompar); + qsort(pages, npages, sizeof(uint16_t), pcompar); if (!dowarnings) TIFFSetWarningHandler(0); if (optind < argc) { @@ -433,29 +431,27 @@ main(int argc, char** argv) return (EXIT_SUCCESS); } -const char* stuff[] = { -"usage: fax2ps [options] [input.tif ...]", -"where options are:", -" -w suppress warning messages", -" -l chars set maximum output line length for generated PostScript", -" -p page# select page to print (can use multiple times)", -" -x xres set default horizontal resolution of input data (dpi)", -" -y yres set default vertical resolution of input data (lpi)", -" -S scale output to page size", -" -W width set output page width (inches), default is 8.5", -" -H height set output page height (inches), default is 11", -NULL -}; +static const char usage_info[] = +"Convert a TIFF facsimile to compressed PostScript\n\n" +"usage: fax2ps [options] [input.tif ...]\n" +"where options are:\n" +" -w suppress warning messages\n" +" -l chars set maximum output line length for generated PostScript\n" +" -p page# select page to print (can use multiple times)\n" +" -x xres set default horizontal resolution of input data (dpi)\n" +" -y yres set default vertical resolution of input data (lpi)\n" +" -S scale output to page size\n" +" -W width set output page width (inches), default is 8.5\n" +" -H height set output page height (inches), default is 11\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/fax2tiff.c b/tiff/tools/fax2tiff.c index eecb41e3..59ed02c0 100644 --- a/tiff/tools/fax2tiff.c +++ b/tiff/tools/fax2tiff.c @@ -26,6 +26,7 @@ * Convert a CCITT Group 3 or 4 FAX file to TIFF Group 3 or 4 format. */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> /* should have atof & getopt */ @@ -42,10 +43,6 @@ # include <io.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffiop.h" #ifndef EXIT_SUCCESS @@ -55,17 +52,17 @@ # define EXIT_FAILURE 1 #endif -#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) +#define TIFFhowmany8(x) (((x)&0x07)?((uint32_t)(x)>>3)+1:(uint32_t)(x)>>3) TIFF *faxTIFF; char *rowbuf; char *refbuf; -uint32 xsize = 1728; +uint32_t xsize = 1728; int verbose; int stretch; -uint16 badfaxrun; -uint32 badfaxlines; +uint16_t badfaxrun; +uint32_t badfaxlines; int copyFaxFile(TIFF* tifin, TIFF* tifout); static void usage(int code); @@ -91,12 +88,12 @@ main(int argc, char* argv[]) int compression_out = COMPRESSION_CCITTFAX3; int fillorder_in = FILLORDER_LSB2MSB; int fillorder_out = FILLORDER_LSB2MSB; - uint32 group3options_in = 0; /* 1d-encoded */ - uint32 group3options_out = 0; /* 1d-encoded */ - uint32 group4options_in = 0; /* compressed */ - uint32 group4options_out = 0; /* compressed */ - uint32 defrowsperstrip = (uint32) 0; - uint32 rowsperstrip; + uint32_t group3options_in = 0; /* 1d-encoded */ + uint32_t group3options_out = 0; /* 1d-encoded */ + uint32_t group4options_in = 0; /* compressed */ + uint32_t group4options_out = 0; /* compressed */ + uint32_t defrowsperstrip = (uint32_t) 0; + uint32_t rowsperstrip; int photometric_in = PHOTOMETRIC_MINISWHITE; int photometric_out = PHOTOMETRIC_MINISWHITE; int mode = FAXMODE_CLASSF; @@ -151,7 +148,7 @@ main(int argc, char* argv[]) resY = (float) atof(optarg); break; case 'X': /* input width */ - xsize = (uint32) atoi(optarg); + xsize = (uint32_t) atoi(optarg); break; /* output-related options */ @@ -218,6 +215,7 @@ main(int argc, char* argv[]) break; case 'h': usage(EXIT_SUCCESS); + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ @@ -297,7 +295,7 @@ main(int argc, char* argv[]) group3options_out); TIFFSetField(out, TIFFTAG_FAXMODE, mode); rowsperstrip = - (defrowsperstrip)?defrowsperstrip:(uint32)-1L; + (defrowsperstrip)?defrowsperstrip:(uint32_t)-1L; break; /* g4 */ @@ -306,7 +304,7 @@ main(int argc, char* argv[]) group4options_out); TIFFSetField(out, TIFFTAG_FAXMODE, mode); rowsperstrip = - (defrowsperstrip)?defrowsperstrip:(uint32)-1L; + (defrowsperstrip)?defrowsperstrip:(uint32_t)-1L; break; default: @@ -338,9 +336,9 @@ main(int argc, char* argv[]) if (verbose) { fprintf(stderr, "%s:\n", argv[optind]); fprintf(stderr, "%d rows in input\n", rows); - fprintf(stderr, "%ld total bad rows\n", - (long) badfaxlines); - fprintf(stderr, "%d max consecutive bad rows\n", badfaxrun); + fprintf(stderr, "%"PRIu32" total bad rows\n", + badfaxlines); + fprintf(stderr, "%"PRIu16" max consecutive bad rows\n", badfaxrun); } if (compression_out == COMPRESSION_CCITTFAX3 && mode == FAXMODE_CLASSF) { @@ -360,9 +358,9 @@ main(int argc, char* argv[]) int copyFaxFile(TIFF* tifin, TIFF* tifout) { - uint32 row; - uint32 linesize = TIFFhowmany8(xsize); - uint16 badrun; + uint32_t row; + uint32_t linesize = TIFFhowmany8(xsize); + uint16_t badrun; int ok; tifin->tif_rawdatasize = (tmsize_t)TIFFGetFileSize(tifin); @@ -408,15 +406,15 @@ copyFaxFile(TIFF* tifin, TIFF* tifout) tifin->tif_row++; if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) { - fprintf(stderr, "%s: Write error at row %ld.\n", - tifout->tif_name, (long) row); + fprintf(stderr, "%s: Write error at row %"PRIu32".\n", + tifout->tif_name, row); break; } row++; if (stretch) { if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) { - fprintf(stderr, "%s: Write error at row %ld.\n", - tifout->tif_name, (long) row); + fprintf(stderr, "%s: Write error at row %"PRIu32".\n", + tifout->tif_name, row); break; } row++; @@ -428,51 +426,53 @@ copyFaxFile(TIFF* tifin, TIFF* tifout) return (row); } -const char* stuff[] = { -"usage: fax2tiff [options] input.raw...", -"where options are:", -" -3 input data is G3-encoded [default]", -" -4 input data is G4-encoded", -" -U input data is uncompressed (G3 or G4)", -" -1 input data is 1D-encoded (G3 only) [default]", -" -2 input data is 2D-encoded (G3 only)", -" -P input is not EOL-aligned (G3 only) [default]", -" -A input is EOL-aligned (G3 only)", -" -M input data has MSB2LSB bit order", -" -L input data has LSB2MSB bit order [default]", -" -B input data has min 0 means black", -" -W input data has min 0 means white [default]", -" -R # input data has # resolution (lines/inch) [default is 196]", -" -X # input data has # width [default is 1728]", -"", -" -o out.tif write output to out.tif", -" -7 generate G3-encoded output [default]", -" -8 generate G4-encoded output", -" -u generate uncompressed output (G3 or G4)", -" -5 generate 1D-encoded output (G3 only)", -" -6 generate 2D-encoded output (G3 only) [default]", -" -p generate not EOL-aligned output (G3 only)", -" -a generate EOL-aligned output (G3 only) [default]", -" -c generate \"classic\" TIFF format", -" -f generate TIFF Class F (TIFF/F) format [default]", -" -m output fill order is MSB2LSB", -" -l output fill order is LSB2MSB [default]", -" -r # make each strip have no more than # rows", -" -s stretch image by duplicating scanlines", -" -v print information about conversion work", -" -z generate LZW compressed output", -NULL -}; +static const char usage_info[] = +"Create a TIFF Class F fax file from raw fax data\n\n" +"usage: fax2tiff [options] input.raw...\n" +"where options are:\n" +" -3 input data is G3-encoded [default]\n" +" -4 input data is G4-encoded\n" +" -U input data is uncompressed (G3 or G4)\n" +" -1 input data is 1D-encoded (G3 only) [default]\n" +" -2 input data is 2D-encoded (G3 only)\n" +" -P input is not EOL-aligned (G3 only) [default]\n" +" -A input is EOL-aligned (G3 only)\n" +" -M input data has MSB2LSB bit order\n" +" -L input data has LSB2MSB bit order [default]\n" +" -B input data has min 0 means black\n" +" -W input data has min 0 means white [default]\n" +" -R # input data has # resolution (lines/inch) [default is 196]\n" +" -X # input data has # width [default is 1728]\n" +"\n" +" -o out.tif write output to out.tif\n" +#ifdef CCITT_SUPPORT +" -7 generate G3-encoded output [default]\n" +" -8 generate G4-encoded output\n" +" -u generate uncompressed output (G3 or G4)\n" +" -5 generate 1D-encoded output (G3 only)\n" +" -6 generate 2D-encoded output (G3 only) [default]\n" +" -p generate not EOL-aligned output (G3 only)\n" +" -a generate EOL-aligned output (G3 only) [default]\n" +#endif +" -c generate \"classic\" TIFF format\n" +" -f generate TIFF Class F (TIFF/F) format [default]\n" +" -m output fill order is MSB2LSB\n" +" -l output fill order is LSB2MSB [default]\n" +" -r # make each strip have no more than # rows\n" +" -s stretch image by duplicating scanlines\n" +" -v print information about conversion work\n" +#ifdef LZW_SUPPORT +" -z generate LZW compressed output\n" +#endif +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/pal2rgb.c b/tiff/tools/pal2rgb.c index bf95cb37..287b31f8 100644 --- a/tiff/tools/pal2rgb.c +++ b/tiff/tools/pal2rgb.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <string.h> @@ -33,10 +34,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" #ifndef EXIT_SUCCESS @@ -53,7 +50,7 @@ static void usage(int code); static void cpTags(TIFF* in, TIFF* out); static int -checkcmap(int n, uint16* r, uint16* g, uint16* b) +checkcmap(int n, uint16_t* r, uint16_t* g, uint16_t* b) { while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) @@ -67,8 +64,8 @@ checkcmap(int n, uint16* r, uint16* g, uint16* b) #define CopyField3(tag, v1, v2, v3) \ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) -static uint16 compression = (uint16) -1; -static uint16 predictor = 0; +static uint16_t compression = (uint16_t) -1; +static uint16_t predictor = 0; static int quality = 75; /* JPEG quality */ static int jpegcolormode = JPEGCOLORMODE_RGB; static int processCompressOptions(char*); @@ -76,13 +73,13 @@ static int processCompressOptions(char*); int main(int argc, char* argv[]) { - uint16 bitspersample, shortv; - uint32 imagewidth, imagelength; - uint16 config = PLANARCONFIG_CONTIG; - uint32 rowsperstrip = (uint32) -1; - uint16 photometric = PHOTOMETRIC_RGB; - uint16 *rmap, *gmap, *bmap; - uint32 row; + uint16_t bitspersample, shortv; + uint32_t imagewidth, imagelength; + uint16_t config = PLANARCONFIG_CONTIG; + uint32_t rowsperstrip = (uint32_t) -1; + uint16_t photometric = PHOTOMETRIC_RGB; + uint16_t *rmap, *gmap, *bmap; + uint32_t row; int cmap = -1; TIFF *in, *out; int c; @@ -114,6 +111,7 @@ main(int argc, char* argv[]) break; case 'h': usage(EXIT_SUCCESS); + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ @@ -153,7 +151,7 @@ main(int argc, char* argv[]) cpTags(in, out); TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); - if (compression != (uint16)-1) + if (compression != (uint16_t)-1) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); else TIFFGetField(in, TIFFTAG_COMPRESSION, &compression); @@ -195,7 +193,7 @@ main(int argc, char* argv[]) } { unsigned char *ibuf, *obuf; register unsigned char* pp; - register uint32 x; + register uint32_t x; tmsize_t tss_in = TIFFScanlineSize(in); tmsize_t tss_out = TIFFScanlineSize(out); if (tss_out / tss_in < 3) { @@ -301,27 +299,27 @@ processCompressOptions(char* opt) if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static void -cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) +cpTag(TIFF* in, TIFF* out, uint16_t tag, uint16_t count, TIFFDataType type) { switch (type) { case TIFF_SHORT: if (count == 1) { - uint16 shortv; + uint16_t shortv; CopyField(tag, shortv); } else if (count == 2) { - uint16 shortv1, shortv2; + uint16_t shortv1, shortv2; CopyField2(tag, shortv1, shortv2); } else if (count == 4) { - uint16 *tr, *tg, *tb, *ta; + uint16_t *tr, *tg, *tb, *ta; CopyField4(tag, tr, tg, tb, ta); - } else if (count == (uint16) -1) { - uint16 shortv1; - uint16* shortav; + } else if (count == (uint16_t) -1) { + uint16_t shortv1; + uint16_t* shortav; CopyField2(tag, shortv1, shortav); } break; case TIFF_LONG: - { uint32 longv; + { uint32_t longv; CopyField(tag, longv); } break; @@ -329,7 +327,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { float floatv; CopyField(tag, floatv); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { float* floatav; CopyField(tag, floatav); } @@ -343,7 +341,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { double doublev; CopyField(tag, doublev); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { double* doubleav; CopyField(tag, doubleav); } @@ -360,9 +358,9 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) #undef CopyField2 #undef CopyField -static struct cpTag { - uint16 tag; - uint16 count; +static const struct cpTag { + uint16_t tag; + uint16_t count; TIFFDataType type; } tags[] = { { TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG }, @@ -384,49 +382,49 @@ static struct cpTag { { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, - { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, - { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, - { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, - { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, - { TIFFTAG_DATETIME, 1, TIFF_ASCII }, - { TIFFTAG_ARTIST, 1, TIFF_ASCII }, - { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, - { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, - { TIFFTAG_PRIMARYCHROMATICITIES, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, - { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, - { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, - { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG }, - { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, + { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, + { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, /*{ TIFFTAG_INKNAMES, 1, TIFF_ASCII },*/ /* Needs much more complicated logic. See tiffcp */ - { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, - { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, - { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, - { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, - { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, - { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16_t) -1, TIFF_RATIONAL }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) static void cpTags(TIFF* in, TIFF* out) { - struct cpTag *p; + const struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) { if( p->tag == TIFFTAG_GROUP3OPTIONS ) { - uint16 compression; + uint16_t compression; if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || compression != COMPRESSION_CCITTFAX3 ) continue; } if( p->tag == TIFFTAG_GROUP4OPTIONS ) { - uint16 compression; + uint16_t compression; if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || compression != COMPRESSION_CCITTFAX4 ) continue; @@ -436,35 +434,42 @@ cpTags(TIFF* in, TIFF* out) } #undef NTAGS -const char* stuff[] = { -"usage: pal2rgb [options] input.tif output.tif", -"where options are:", -" -p contig pack samples contiguously (e.g. RGBRGB...)", -" -p separate store samples separately (e.g. RRR...GGG...BBB...)", -" -r # make each strip have no more than # rows", -" -C 8 assume 8-bit colormap values (instead of 16-bit)", -" -C 16 assume 16-bit colormap values", -"", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c packbits compress output with packbits encoding", -" -c none use no compression algorithm on output", -"", -"LZW and deflate options:", -" # set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", -NULL -}; +static const char usage_info[] = +"Convert a palette color TIFF image to a full color image\n\n" +"usage: pal2rgb [options] input.tif output.tif\n" +"where options are:\n" +" -p contig pack samples contiguously (e.g. RGBRGB...)\n" +" -p separate store samples separately (e.g. RRR...GGG...BBB...)\n" +" -r # make each strip have no more than # rows\n" +" -C 8 assume 8-bit colormap values (instead of 16-bit)\n" +" -C 16 assume 16-bit colormap values\n" +"\n" +#ifdef LZW_SUPPORT +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" +/* " LZW options:\n" */ +" # set predictor value\n" +" For example, -c lzw:2 to get LZW-encoded data with horizontal differencing\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip[:opts] compress output with deflate encoding\n" +/* " Deflate (ZIP) options:\n" */ +" # set predictor value\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits compress output with packbits encoding\n" +#endif +#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) +" -c none use no compression algorithm on output\n" +#endif +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/ppm2tiff.c b/tiff/tools/ppm2tiff.c index c6332439..d0eaee85 100644 --- a/tiff/tools/ppm2tiff.c +++ b/tiff/tools/ppm2tiff.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -41,16 +42,8 @@ # include <io.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif @@ -61,17 +54,17 @@ extern int getopt(int argc, char * const argv[], const char *optstring); #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) -static uint16 compression = COMPRESSION_PACKBITS; -static uint16 predictor = 0; +static uint16_t compression = COMPRESSION_PACKBITS; +static uint16_t predictor = 0; static int quality = 75; /* JPEG quality */ static int jpegcolormode = JPEGCOLORMODE_RGB; -static uint32 g3opts; +static uint32_t g3opts; static void usage(int code); static int processCompressOptions(char*); static void -pack_none (unsigned char *buf, unsigned int smpls, uint16 bps) +pack_none (unsigned char *buf, unsigned int smpls, uint16_t bps) { (void)buf; (void)smpls; @@ -80,7 +73,7 @@ pack_none (unsigned char *buf, unsigned int smpls, uint16 bps) } static void -pack_swab (unsigned char *buf, unsigned int smpls, uint16 bps) +pack_swab (unsigned char *buf, unsigned int smpls, uint16_t bps) { unsigned int s; unsigned char h; @@ -99,13 +92,13 @@ pack_swab (unsigned char *buf, unsigned int smpls, uint16 bps) } static void -pack_bytes (unsigned char *buf, unsigned int smpls, uint16 bps) +pack_bytes (unsigned char *buf, unsigned int smpls, uint16_t bps) { unsigned int s; unsigned int in; unsigned int out; int bits; - uint16 t; + uint16_t t; in = 0; out = 0; @@ -115,7 +108,7 @@ pack_bytes (unsigned char *buf, unsigned int smpls, uint16 bps) for (s = 0; smpls > s; s++) { t <<= bps; - t |= (uint16) buf [in++]; + t |= (uint16_t) buf [in++]; bits += bps; @@ -129,13 +122,13 @@ pack_bytes (unsigned char *buf, unsigned int smpls, uint16 bps) } static void -pack_words (unsigned char *buf, unsigned int smpls, uint16 bps) +pack_words (unsigned char *buf, unsigned int smpls, uint16_t bps) { unsigned int s; unsigned int in; unsigned int out; int bits; - uint32 t; + uint32_t t; in = 0; out = 0; @@ -145,8 +138,8 @@ pack_words (unsigned char *buf, unsigned int smpls, uint16 bps) for (s = 0; smpls > s; s++) { t <<= bps; - t |= (uint32) buf [in++] << 8; - t |= (uint32) buf [in++] << 0; + t |= (uint32_t) buf [in++] << 8; + t |= (uint32_t) buf [in++] << 0; bits += bps; @@ -173,9 +166,6 @@ BadPPM(char* file) } -#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0)) -#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1) - static tmsize_t multiply_ms(tmsize_t m1, tmsize_t m2) { @@ -187,15 +177,15 @@ multiply_ms(tmsize_t m1, tmsize_t m2) int main(int argc, char* argv[]) { - uint16 photometric = 0; - uint32 rowsperstrip = (uint32) -1; + uint16_t photometric = 0; + uint32_t rowsperstrip = (uint32_t) -1; double resolution = -1; unsigned char *buf = NULL; tmsize_t linebytes = 0; int pbm; - uint16 spp = 1; - uint16 bpp = 8; - void (*pack_func) (unsigned char *buf, unsigned int smpls, uint16 bps); + uint16_t spp = 1; + uint16_t bpp = 8; + void (*pack_func) (unsigned char *buf, unsigned int smpls, uint16_t bps); TIFF *out; FILE *in; unsigned int w, h, prec, row; @@ -225,6 +215,7 @@ main(int argc, char* argv[]) break; case 'h': usage(EXIT_SUCCESS); + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ @@ -349,8 +340,8 @@ main(int argc, char* argv[]) out = TIFFOpen(argv[optind], "w"); if (out == NULL) return (EXIT_FAILURE); - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) w); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) h); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t) w); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t) h); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bpp); @@ -379,7 +370,7 @@ main(int argc, char* argv[]) } else { linebytes = multiply_ms(2 * spp, w); } - if (rowsperstrip == (uint32) -1) { + if (rowsperstrip == (uint32_t) -1) { TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, h); } else { TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, @@ -412,8 +403,8 @@ main(int argc, char* argv[]) } for (row = 0; row < h; row++) { if (fread(buf, linebytes, 1, in) != 1) { - fprintf(stderr, "%s: scanline %lu: Read error.\n", - infile, (unsigned long) row); + fprintf(stderr, "%s: scanline %u: Read error.\n", + infile, row); break; } pack_func (buf, w * spp, bpp); @@ -489,38 +480,49 @@ processCompressOptions(char* opt) return (1); } -const char* stuff[] = { -"usage: ppm2tiff [options] input.ppm output.tif", -"where options are:", -" -r # make each strip have no more than # rows", -" -R # set x&y resolution (dpi)", -"", -" -c jpeg[:opts] compress output with JPEG encoding", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c packbits compress output with packbits encoding (the default)", -" -c g3[:opts] compress output with CCITT Group 3 encoding", -" -c g4 compress output with CCITT Group 4 encoding", -" -c none use no compression algorithm on output", -"", -"JPEG options:", -" # set compression quality level (0-100, default 75)", -" r output color image as RGB rather than YCbCr", -"LZW and deflate options:", -" # set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", -NULL -}; +static const char usage_info[] = +"Create a TIFF file from PPM, PGM and PBM image files\n\n" +"usage: ppm2tiff [options] input.ppm output.tif\n" +"where options are:\n" +" -r # make each strip have no more than # rows\n" +" -R # set x&y resolution (dpi)\n" +"\n" +#ifdef JPEG_SUPPORT +" -c jpeg[:opts] compress output with JPEG encoding\n" +/* "JPEG options:\n" */ +" # set compression quality level (0-100, default 75)\n" +" r output color image as RGB rather than YCbCr\n" +#endif +#ifdef LZW_SUPPORT +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" +/* " LZW options:\n" */ +" # set predictor value\n" +" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip[:opts] compress output with deflate encoding\n" +/* " Deflate (ZIP) options:\n" */ +" # set predictor value\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits compress output with packbits encoding (the default)\n" +#endif +#ifdef CCITT_SUPPORT +" -c g3[:opts] compress output with CCITT Group 3 encoding\n" +" -c g4 compress output with CCITT Group 4 encoding\n" +#endif +#if defined(JPEG_SUPPORT) || defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) +" -c none use no compression algorithm on output\n" +#endif +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/raw2tiff.c b/tiff/tools/raw2tiff.c index 8bbdc045..dfee715f 100644 --- a/tiff/tools/raw2tiff.c +++ b/tiff/tools/raw2tiff.c @@ -27,6 +27,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -52,10 +53,6 @@ # include <io.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffiop.h" #include "tiffio.h" @@ -66,10 +63,6 @@ #define EXIT_FAILURE 1 #endif -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - #ifndef O_BINARY # define O_BINARY 0 #endif @@ -79,37 +72,37 @@ typedef enum { BAND } InterleavingType; -static uint16 compression = (uint16) -1; +static uint16_t compression = (uint16_t) -1; static int jpegcolormode = JPEGCOLORMODE_RGB; static int quality = 75; /* JPEG quality */ -static uint16 predictor = 0; +static uint16_t predictor = 0; -static void swapBytesInScanline(void *, uint32, TIFFDataType); -static int guessSize(int, TIFFDataType, _TIFF_off_t, uint32, int, - uint32 *, uint32 *); -static double correlation(void *, void *, uint32, TIFFDataType); +static void swapBytesInScanline(void *, uint32_t, TIFFDataType); +static int guessSize(int, TIFFDataType, _TIFF_off_t, uint32_t, int, + uint32_t *, uint32_t *); +static double correlation(void *, void *, uint32_t, TIFFDataType); static void usage(int); static int processCompressOptions(char*); int main(int argc, char* argv[]) { - uint32 width = 0, length = 0, linebytes, bufsize; - uint32 nbands = 1; /* number of bands in input image*/ + uint32_t width = 0, length = 0, linebytes, bufsize; + uint32_t nbands = 1; /* number of bands in input image*/ _TIFF_off_t hdr_size = 0; /* size of the header to skip */ TIFFDataType dtype = TIFF_BYTE; - int16 depth = 1; /* bytes per pixel in input image */ + int16_t depth = 1; /* bytes per pixel in input image */ int swab = 0; /* byte swapping flag */ InterleavingType interleaving = 0; /* interleaving type flag */ - uint32 rowsperstrip = (uint32) -1; - uint16 photometric = PHOTOMETRIC_MINISBLACK; - uint16 config = PLANARCONFIG_CONTIG; - uint16 fillorder = FILLORDER_LSB2MSB; + uint32_t rowsperstrip = (uint32_t) -1; + uint16_t photometric = PHOTOMETRIC_MINISBLACK; + uint16_t config = PLANARCONFIG_CONTIG; + uint16_t fillorder = FILLORDER_LSB2MSB; int fd; char *outfilename = NULL; TIFF *out; - uint32 row, col, band; + uint32_t row, col, band; int c; unsigned char *buf = NULL, *buf1 = NULL; #if !HAVE_DECL_OPTARG @@ -254,7 +247,7 @@ main(int argc, char* argv[]) TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_VOID); break; } - if (compression == (uint16) -1) + if (compression == (uint16_t) -1) compression = COMPRESSION_PACKBITS; TIFFSetField(out, TIFFTAG_COMPRESSION, compression); switch (compression) { @@ -299,16 +292,14 @@ main(int argc, char* argv[]) hdr_size + (length*band+row)*linebytes, SEEK_SET) == (_TIFF_off_t)-1) { fprintf(stderr, - "%s: %s: scanline %lu: seek error.\n", - argv[0], argv[optind], - (unsigned long) row); + "%s: %s: scanline %"PRIu32": seek error.\n", + argv[0], argv[optind], row); break; } if (read(fd, buf, linebytes) < 0) { fprintf(stderr, - "%s: %s: scanline %lu: Read error.\n", - argv[0], argv[optind], - (unsigned long) row); + "%s: %s: scanline %"PRIu32": Read error.\n", + argv[0], argv[optind], row); break; } if (swab) /* Swap bytes if needed */ @@ -322,9 +313,8 @@ main(int argc, char* argv[]) default: if (read(fd, buf1, bufsize) < 0) { fprintf(stderr, - "%s: %s: scanline %lu: Read error.\n", - argv[0], argv[optind], - (unsigned long) row); + "%s: %s: scanline %"PRIu32": Read error.\n", + argv[0], argv[optind], row); break; } if (swab) /* Swap bytes if needed */ @@ -333,8 +323,8 @@ main(int argc, char* argv[]) } if (TIFFWriteScanline(out, buf1, row, 0) < 0) { - fprintf(stderr, "%s: %s: scanline %lu: Write error.\n", - argv[0], outfilename, (unsigned long) row); + fprintf(stderr, "%s: %s: scanline %"PRIu32": Write error.\n", + argv[0], outfilename, row); break; } } @@ -347,17 +337,17 @@ main(int argc, char* argv[]) } static void -swapBytesInScanline(void *buf, uint32 width, TIFFDataType dtype) +swapBytesInScanline(void *buf, uint32_t width, TIFFDataType dtype) { switch (dtype) { case TIFF_SHORT: case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*)buf, + TIFFSwabArrayOfShort((uint16_t*)buf, (unsigned long)width); break; case TIFF_LONG: case TIFF_SLONG: - TIFFSwabArrayOfLong((uint32*)buf, + TIFFSwabArrayOfLong((uint32_t*)buf, (unsigned long)width); break; /* case TIFF_FLOAT: */ /* FIXME */ @@ -371,14 +361,14 @@ swapBytesInScanline(void *buf, uint32 width, TIFFDataType dtype) } static int -guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands, - int swab, uint32 *width, uint32 *length) +guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32_t nbands, + int swab, uint32_t *width, uint32_t *length) { const float longt = 40.0; /* maximum possible height/width ratio */ char *buf1, *buf2; _TIFF_stat_s filestat; - uint32 w, h, scanlinesize, imagesize; - uint32 depth = TIFFDataWidth(dtype); + uint32_t w, h, scanlinesize, imagesize; + uint32_t depth = TIFFDataWidth(dtype); double cor_coef = 0, tmp; if (_TIFF_fstat_f(fd, &filestat) == -1) { @@ -398,8 +388,8 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands, *length = imagesize / *width; - fprintf(stderr, "Height is guessed as %lu.\n", - (unsigned long)*length); + fprintf(stderr, "Height is guessed as %"PRIu32".\n", + *length); return 1; } else if (*width == 0 && *length != 0) { @@ -407,14 +397,14 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands, *width = imagesize / *length; - fprintf(stderr, "Width is guessed as %lu.\n", - (unsigned long)*width); + fprintf(stderr, "Width is guessed as %"PRIu32".\n", + *width); return 1; } else if (*width == 0 && *length == 0) { unsigned int fail = 0; fprintf(stderr, "Image width and height are not specified.\n"); - w = (uint32) sqrt(imagesize / longt); + w = (uint32_t) sqrt(imagesize / longt); if( w == 0 ) { fprintf(stderr, "Too small image size.\n"); @@ -480,8 +470,8 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands, } fprintf(stderr, - "Width is guessed as %lu, height is guessed as %lu.\n", - (unsigned long)*width, (unsigned long)*length); + "Width is guessed as %"PRIu32", height is guessed as %"PRIu32".\n", + *width, *length); return 1; } else { @@ -496,10 +486,10 @@ guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands, /* Calculate correlation coefficient between two numeric vectors */ static double -correlation(void *buf1, void *buf2, uint32 n_elem, TIFFDataType dtype) +correlation(void *buf1, void *buf2, uint32_t n_elem, TIFFDataType dtype) { double X, Y, M1 = 0.0, M2 = 0.0, D1 = 0.0, D2 = 0.0, K = 0.0; - uint32 i; + uint32_t i; switch (dtype) { case TIFF_BYTE: @@ -523,8 +513,8 @@ correlation(void *buf1, void *buf2, uint32 n_elem, TIFFDataType dtype) break; case TIFF_SHORT: for (i = 0; i < n_elem; i++) { - X = ((uint16 *)buf1)[i]; - Y = ((uint16 *)buf2)[i]; + X = ((uint16_t *)buf1)[i]; + Y = ((uint16_t *)buf2)[i]; M1 += X, M2 += Y; D1 += X * X, D2 += Y * Y; K += X * Y; @@ -532,8 +522,8 @@ correlation(void *buf1, void *buf2, uint32 n_elem, TIFFDataType dtype) break; case TIFF_SSHORT: for (i = 0; i < n_elem; i++) { - X = ((int16 *)buf1)[i]; - Y = ((int16 *)buf2)[i]; + X = ((int16_t *)buf1)[i]; + Y = ((int16_t *)buf2)[i]; M1 += X, M2 += Y; D1 += X * X, D2 += Y * Y; K += X * Y; @@ -541,8 +531,8 @@ correlation(void *buf1, void *buf2, uint32 n_elem, TIFFDataType dtype) break; case TIFF_LONG: for (i = 0; i < n_elem; i++) { - X = ((uint32 *)buf1)[i]; - Y = ((uint32 *)buf2)[i]; + X = ((uint32_t *)buf1)[i]; + Y = ((uint32_t *)buf2)[i]; M1 += X, M2 += Y; D1 += X * X, D2 += Y * Y; K += X * Y; @@ -550,8 +540,8 @@ correlation(void *buf1, void *buf2, uint32 n_elem, TIFFDataType dtype) break; case TIFF_SLONG: for (i = 0; i < n_elem; i++) { - X = ((int32 *)buf1)[i]; - Y = ((int32 *)buf2)[i]; + X = ((int32_t *)buf1)[i]; + Y = ((int32_t *)buf2)[i]; M1 += X, M2 += Y; D1 += X * X, D2 += Y * Y; K += X * Y; @@ -624,75 +614,83 @@ processCompressOptions(char* opt) return (1); } -static const char* stuff[] = { -"raw2tiff --- tool for converting raw byte sequences in TIFF images", -"usage: raw2tiff [options] input.raw output.tif", -"where options are:", -" -L input data has LSB2MSB bit order (default)", -" -M input data has MSB2LSB bit order", -" -r # make each strip have no more than # rows", -" -H # size of input image file header in bytes (0 by default)", -" -w # width of input image in pixels", -" -l # length of input image in lines", -" -b # number of bands in input image (1 by default)", -"", -" -d data_type type of samples in input image", -"where data_type may be:", -" byte 8-bit unsigned integer (default)", -" short 16-bit unsigned integer", -" long 32-bit unsigned integer", -" sbyte 8-bit signed integer", -" sshort 16-bit signed integer", -" slong 32-bit signed integer", -" float 32-bit IEEE floating point", -" double 64-bit IEEE floating point", -"", -" -p photo photometric interpretation (color space) of the input image", -"where photo may be:", -" miniswhite white color represented with 0 value", -" minisblack black color represented with 0 value (default)", -" rgb image has RGB color model", -" cmyk image has CMYK (separated) color model", -" ycbcr image has YCbCr color model", -" cielab image has CIE L*a*b color model", -" icclab image has ICC L*a*b color model", -" itulab image has ITU L*a*b color model", -"", -" -s swap bytes fetched from input file", -"", -" -i config type of samples interleaving in input image", -"where config may be:", -" pixel pixel interleaved data (default)", -" band band interleaved data", -"", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c jpeg[:opts] compress output with JPEG encoding", -" -c packbits compress output with packbits encoding", -" -c none use no compression algorithm on output", -"", -"JPEG options:", -" # set compression quality level (0-100, default 75)", -" r output color image as RGB rather than YCbCr", -"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", -"", -"LZW and deflate options:", -" # set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", -" -o out.tif write output to out.tif", -" -h this help message", -NULL -}; +static const char usage_info[] = +"Create a TIFF file from raw data\n\n" +"usage: raw2tiff [options] input.raw output.tif\n" +"where options are:\n" +" -L input data has LSB2MSB bit order (default)\n" +" -M input data has MSB2LSB bit order\n" +" -r # make each strip have no more than # rows\n" +" -H # size of input image file header in bytes (0 by default)\n" +" -w # width of input image in pixels\n" +" -l # length of input image in lines\n" +" -b # number of bands in input image (1 by default)\n" +"\n" +" -d data_type type of samples in input image\n" +"where data_type may be:\n" +" byte 8-bit unsigned integer (default)\n" +" short 16-bit unsigned integer\n" +" long 32-bit unsigned integer\n" +" sbyte 8-bit signed integer\n" +" sshort 16-bit signed integer\n" +" slong 32-bit signed integer\n" +" float 32-bit IEEE floating point\n" +" double 64-bit IEEE floating point\n" +"\n" +" -p photo photometric interpretation (color space) of the input image\n" +"where photo may be:\n" +" miniswhite white color represented with 0 value\n" +" minisblack black color represented with 0 value (default)\n" +" rgb image has RGB color model\n" +" cmyk image has CMYK (separated) color model\n" +" ycbcr image has YCbCr color model\n" +" cielab image has CIE L*a*b color model\n" +" icclab image has ICC L*a*b color model\n" +" itulab image has ITU L*a*b color model\n" +"\n" +" -s swap bytes fetched from input file\n" +"\n" +" -i config type of samples interleaving in input image\n" +"where config may be:\n" +" pixel pixel interleaved data (default)\n" +" band band interleaved data\n" +"\n" +#ifdef LZW_SUPPORT +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" +/* " LZW options:\n" */ +" # set predictor value\n" +" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip[:opts] compress output with deflate encoding\n" +/* " Deflate (ZIP) options:\n" */ +" # set predictor value\n" +#endif +#ifdef JPEG_SUPPORT +" -c jpeg[:opts] compress output with JPEG encoding\n" +/* " JPEG options:\n" */ +" # set compression quality level (0-100, default 75)\n" +" r output color image as RGB rather than YCbCr\n" +" For example, -c jpeg:r:50 for JPEG-encoded RGB data with 50% comp. quality\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits compress output with packbits encoding\n" +#endif +#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(JPEG_SUPPORT) || defined(PACKBITS_SUPPORT) +" -c none use no compression algorithm on output\n" +#endif +"\n" +" -o out.tif write output to out.tif\n" +" -h this help message\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/rgb2ycbcr.c b/tiff/tools/rgb2ycbcr.c index 482cc5b4..d2a93c2d 100644 --- a/tiff/tools/rgb2ycbcr.c +++ b/tiff/tools/rgb2ycbcr.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <string.h> @@ -32,10 +33,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffiop.h" #include "tiffio.h" @@ -53,17 +50,17 @@ #ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) #endif -#define roundup(x, y) (howmany(x,y)*((uint32)(y))) +#define roundup(x, y) (howmany(x,y)*((uint32_t)(y))) #define LumaRed ycbcrCoeffs[0] #define LumaGreen ycbcrCoeffs[1] #define LumaBlue ycbcrCoeffs[2] -uint16 compression = COMPRESSION_PACKBITS; -uint32 rowsperstrip = (uint32) -1; +uint16_t compression = COMPRESSION_PACKBITS; +uint32_t rowsperstrip = (uint32_t) -1; -uint16 horizSubSampling = 2; /* YCbCr horizontal subsampling */ -uint16 vertSubSampling = 2; /* YCbCr vertical subsampling */ +uint16_t horizSubSampling = 2; /* YCbCr horizontal subsampling */ +uint16_t vertSubSampling = 2; /* YCbCr vertical subsampling */ float ycbcrCoeffs[3] = { .299F, .587F, .114F }; /* default coding range is CCIR Rec 601-1 with no headroom/footroom */ float refBlackWhite[6] = { 0.F, 255.F, 128.F, 255.F, 128.F, 255.F }; @@ -182,17 +179,17 @@ setupLumaTables(void) } static void -cvtClump(unsigned char* op, uint32* raster, uint32 ch, uint32 cw, uint32 w) +cvtClump(unsigned char* op, uint32_t* raster, uint32_t ch, uint32_t cw, uint32_t w) { float Y, Cb = 0, Cr = 0; - uint32 j, k; + uint32_t j, k; /* * Convert ch-by-cw block of RGB * to YCbCr and sample accordingly. */ for (k = 0; k < ch; k++) { for (j = 0; j < cw; j++) { - uint32 RGB = (raster - k*w)[j]; + uint32_t RGB = (raster - k * w)[j]; Y = lumaRed[TIFFGetR(RGB)] + lumaGreen[TIFFGetG(RGB)] + lumaBlue[TIFFGetB(RGB)]; @@ -224,11 +221,11 @@ cvtClump(unsigned char* op, uint32* raster, uint32 ch, uint32 cw, uint32 w) * sample to generate the output data. */ static void -cvtStrip(unsigned char* op, uint32* raster, uint32 nrows, uint32 width) +cvtStrip(unsigned char* op, uint32_t* raster, uint32_t nrows, uint32_t width) { - uint32 x; + uint32_t x; int clumpSize = vertSubSampling * horizSubSampling + 2; - uint32 *tp; + uint32_t *tp; for (; nrows >= vertSubSampling; nrows -= vertSubSampling) { tp = raster; @@ -257,23 +254,23 @@ cvtStrip(unsigned char* op, uint32* raster, uint32 nrows, uint32 width) } static int -cvtRaster(TIFF* tif, uint32* raster, uint32 width, uint32 height) +cvtRaster(TIFF* tif, uint32_t* raster, uint32_t width, uint32_t height) { - uint32 y; + uint32_t y; tstrip_t strip = 0; tsize_t cc, acc; unsigned char* buf; - uint32 rwidth = roundup(width, horizSubSampling); - uint32 rheight = roundup(height, vertSubSampling); - uint32 nrows = (rowsperstrip > rheight ? rheight : rowsperstrip); - uint32 rnrows = roundup(nrows,vertSubSampling); + uint32_t rwidth = roundup(width, horizSubSampling); + uint32_t rheight = roundup(height, vertSubSampling); + uint32_t nrows = (rowsperstrip > rheight ? rheight : rowsperstrip); + uint32_t rnrows = roundup(nrows, vertSubSampling); cc = rnrows*rwidth + 2*((rnrows*rwidth) / (horizSubSampling*vertSubSampling)); buf = (unsigned char*)_TIFFmalloc(cc); // FIXME unchecked malloc - for (y = height; (int32) y > 0; y -= nrows) { - uint32 nr = (y > nrows ? nrows : y); + for (y = height; (int32_t) y > 0; y -= nrows) { + uint32_t nr = (y > nrows ? nrows : y); cvtStrip(buf, raster + (y-1)*width, nr, width); nr = roundup(nr, vertSubSampling); acc = nr*rwidth + @@ -290,12 +287,12 @@ cvtRaster(TIFF* tif, uint32* raster, uint32 width, uint32 height) static int tiffcvt(TIFF* in, TIFF* out) { - uint32 width, height; /* image width & height */ - uint32* raster; /* retrieve RGBA image */ - uint16 shortv; + uint32_t width, height; /* image width & height */ + uint32_t* raster; /* retrieve RGBA image */ + uint16_t shortv; float floatv; char *stringv; - uint32 longv; + uint32_t longv; int result; size_t pixel_count; @@ -307,18 +304,18 @@ tiffcvt(TIFF* in, TIFF* out) if (!width || !height || pixel_count / width != height) { TIFFError(TIFFFileName(in), "Malformed input file; " - "can't allocate buffer for raster of %lux%lu size", - (unsigned long)width, (unsigned long)height); + "can't allocate buffer for raster of %"PRIu32"x%"PRIu32" size", + width, height); return 0; } - raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), - "raster buffer"); + raster = (uint32_t*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32_t), + "raster buffer"); if (raster == 0) { TIFFError(TIFFFileName(in), - "Failed to allocate buffer (%lu elements of %lu each)", - (unsigned long)pixel_count, - (unsigned long)sizeof(uint32)); + "Failed to allocate buffer (%"TIFF_SIZE_FORMAT" elements of %"TIFF_SIZE_FORMAT" each)", + pixel_count, + sizeof(uint32_t)); return (0); } @@ -364,19 +361,34 @@ tiffcvt(TIFF* in, TIFF* out) return result; } -const char* stuff[] = { - "usage: rgb2ycbcr [-c comp] [-r rows] [-h N] [-v N] input... output\n", - "where comp is one of the following compression algorithms:\n", - " jpeg\t\tJPEG encoding\n", - " lzw\t\tLempel-Ziv & Welch encoding\n", - " zip\t\tdeflate encoding\n", - " packbits\tPackBits encoding (default)\n", - " none\t\tno compression\n", - "and the other options are:\n", - " -r\trows/strip\n", - " -h\thorizontal sampling factor (1,2,4)\n", - " -v\tvertical sampling factor (1,2,4)\n", - NULL +const char* usage_info[] = { +/* Help information format modified for the sake of consistency with the other tiff tools */ +/* "usage: rgb2ycbcr [-c comp] [-r rows] [-h N] [-v N] input... output\n", */ +/* "where comp is one of the following compression algorithms:\n", */ +"Convert RGB color, greyscale, or bi-level TIFF images to YCbCr images\n\n" +"usage: rgb2ycbcr [options] input output", +"where options are:", +#ifdef JPEG_SUPPORT +" -c jpeg JPEG encoding", +#endif +#ifdef ZIP_SUPPORT +" -c zip Zip/Deflate encoding", +#endif +#ifdef LZW_SUPPORT +" -c lzw Lempel-Ziv & Welch encoding", +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits PackBits encoding (default)", +#endif +#if defined(JPEG_SUPPORT) || defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) +" -c none no compression", +#endif +"", +/* "and the other options are:\n", */ +" -r rows/strip", +" -h horizontal sampling factor (1,2,4)", +" -v vertical sampling factor (1,2,4)", +NULL }; static void @@ -386,8 +398,8 @@ usage(int code) FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + for (i = 0; usage_info[i] != NULL; i++) + fprintf(out, "%s\n", usage_info[i]); exit(code); } diff --git a/tiff/tools/thumbnail.c b/tiff/tools/thumbnail.c index edb69983..274705d3 100644 --- a/tiff/tools/thumbnail.c +++ b/tiff/tools/thumbnail.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -33,10 +34,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" #ifndef EXIT_SUCCESS @@ -46,14 +43,10 @@ #define EXIT_FAILURE 1 #endif -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - #define streq(a,b) (strcmp(a,b) == 0) #ifndef TIFFhowmany8 -# define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) +# define TIFFhowmany8(x) (((x)&0x07)?((uint32_t)(x)>>3)+1:(uint32_t)(x)>>3) #endif typedef enum { @@ -66,10 +59,10 @@ typedef enum { LINEAR } Contrast; -static uint32 tnw = 216; /* thumbnail width */ -static uint32 tnh = 274; /* thumbnail height */ +static uint32_t tnw = 216; /* thumbnail width */ +static uint32_t tnh = 274; /* thumbnail height */ static Contrast contrast = LINEAR; /* current contrast */ -static uint8* thumbnail; +static uint8_t* thumbnail; static int cpIFD(TIFF*, TIFF*); static int generateThumbnail(TIFF*, TIFF*); @@ -114,7 +107,7 @@ main(int argc, char* argv[]) if( in == NULL ) return 2; - thumbnail = (uint8*) _TIFFmalloc(tnw * tnh); + thumbnail = (uint8_t*) _TIFFmalloc(tnw * tnh); if (!thumbnail) { TIFFError(TIFFFileName(in), "Can't allocate space for thumbnail buffer."); @@ -148,37 +141,37 @@ bad: if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static void -cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) +cpTag(TIFF* in, TIFF* out, uint16_t tag, uint16_t count, TIFFDataType type) { switch (type) { case TIFF_SHORT: if (count == 1) { - uint16 shortv; + uint16_t shortv; CopyField(tag, shortv); } else if (count == 2) { - uint16 shortv1, shortv2; + uint16_t shortv1, shortv2; CopyField2(tag, shortv1, shortv2); } else if (count == 4) { - uint16 *tr, *tg, *tb, *ta; + uint16_t *tr, *tg, *tb, *ta; CopyField4(tag, tr, tg, tb, ta); - } else if (count == (uint16) -1) { - uint16 shortv1; - uint16* shortav; + } else if (count == (uint16_t) -1) { + uint16_t shortv1; + uint16_t* shortav; CopyField2(tag, shortv1, shortav); } break; case TIFF_LONG: - { uint32 longv; + { uint32_t longv; CopyField(tag, longv); } break; case TIFF_LONG8: - { uint64 longv8; + { uint64_t longv8; CopyField(tag, longv8); } break; case TIFF_SLONG8: - { int64 longv8; + { int64_t longv8; CopyField(tag, longv8); } break; @@ -186,7 +179,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { float floatv; CopyField(tag, floatv); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { float* floatav; CopyField(tag, floatav); } @@ -200,7 +193,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { double doublev; CopyField(tag, doublev); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { double* doubleav; CopyField(tag, doubleav); } @@ -221,9 +214,9 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) #undef CopyField2 #undef CopyField -static struct cpTag { - uint16 tag; - uint16 count; +static const struct cpTag { + uint16_t tag; + uint16_t count; TIFFDataType type; } tags[] = { { TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG }, @@ -248,38 +241,38 @@ static struct cpTag { { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, - { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, - { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, - { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, - { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, - { TIFFTAG_DATETIME, 1, TIFF_ASCII }, - { TIFFTAG_ARTIST, 1, TIFF_ASCII }, - { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, - { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, - { TIFFTAG_PRIMARYCHROMATICITIES, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, - { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, - { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, - { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG }, - { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, + { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, + { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, /*{ TIFFTAG_INKNAMES, 1, TIFF_ASCII },*/ /* Needs much more complicated logic. See tiffcp */ - { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, - { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, - { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, - { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, - { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, - { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16_t) -1, TIFF_SHORT }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) static void cpTags(TIFF* in, TIFF* out) { - struct cpTag *p; + const struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) { /* Horrible: but TIFFGetField() expects 2 arguments to be passed */ @@ -287,14 +280,14 @@ cpTags(TIFF* in, TIFF* out) /* isn't used */ if( p->tag == TIFFTAG_GROUP3OPTIONS ) { - uint16 compression; + uint16_t compression; if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || compression != COMPRESSION_CCITTFAX3 ) continue; } if( p->tag == TIFFTAG_GROUP4OPTIONS ) { - uint16 compression; + uint16_t compression; if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || compression != COMPRESSION_CCITTFAX4 ) continue; @@ -312,11 +305,11 @@ cpStrips(TIFF* in, TIFF* out) if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); - uint64 *bytecounts; + uint64_t *bytecounts; TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); for (s = 0; s < ns; s++) { - if (bytecounts[s] > (uint64) bufsize) { + if (bytecounts[s] > (uint64_t) bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[s]); if (!buf) goto bad; @@ -346,11 +339,11 @@ cpTiles(TIFF* in, TIFF* out) if (buf) { ttile_t t, nt = TIFFNumberOfTiles(in); - uint64 *bytecounts; + uint64_t *bytecounts; TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); for (t = 0; t < nt; t++) { - if (bytecounts[t] > (uint64) bufsize) { + if (bytecounts[t] > (uint64_t) bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[t]); if (!buf) goto bad; @@ -386,16 +379,16 @@ cpIFD(TIFF* in, TIFF* out) return (1); } -static uint16 photometric; /* current photometric of raster */ -static uint16 filterWidth; /* filter width in pixels */ -static uint32 stepSrcWidth; /* src image stepping width */ -static uint32 stepDstWidth; /* dest stepping width */ -static uint8* src0; /* horizontal bit stepping (start) */ -static uint8* src1; /* horizontal bit stepping (middle) */ -static uint8* src2; /* horizontal bit stepping (end) */ -static uint32* rowoff; /* row offset for stepping */ -static uint8 cmap[256]; /* colormap indexes */ -static uint8 bits[256]; /* count of bits set */ +static uint16_t photometric; /* current photometric of raster */ +static uint16_t filterWidth; /* filter width in pixels */ +static uint32_t stepSrcWidth; /* src image stepping width */ +static uint32_t stepDstWidth; /* dest stepping width */ +static uint8_t* src0; /* horizontal bit stepping (start) */ +static uint8_t* src1; /* horizontal bit stepping (middle) */ +static uint8_t* src2; /* horizontal bit stepping (end) */ +static uint32_t* rowoff; /* row offset for stepping */ +static uint8_t cmap[256]; /* colormap indexes */ +static uint8_t bits[256]; /* count of bits set */ static void setupBitsTables() @@ -423,10 +416,10 @@ static int clamp(float v, int low, int high) #endif static void -expFill(float pct[], uint32 p, uint32 n) +expFill(float pct[], uint32_t p, uint32_t n) { - uint32 i; - uint32 c = (p * n) / 100; + uint32_t i; + uint32_t c = (p * n) / 100; for (i = 1; i < c; i++) pct[i] = (float) (1-exp(i/((double)(n-1)))/ M_E); for (; i < n; i++) @@ -437,7 +430,7 @@ static void setupCmap() { float pct[256]; /* known to be large enough */ - uint32 i; + uint32_t i; pct[0] = 1; /* force white */ switch (contrast) { case EXP50: expFill(pct, 50, 256); break; @@ -466,10 +459,10 @@ setupCmap() static void initScale() { - src0 = (uint8*) _TIFFmalloc(sizeof (uint8) * tnw); - src1 = (uint8*) _TIFFmalloc(sizeof (uint8) * tnw); - src2 = (uint8*) _TIFFmalloc(sizeof (uint8) * tnw); - rowoff = (uint32*) _TIFFmalloc(sizeof (uint32) * tnw); + src0 = (uint8_t*) _TIFFmalloc(sizeof (uint8_t) * tnw); + src1 = (uint8_t*) _TIFFmalloc(sizeof (uint8_t) * tnw); + src2 = (uint8_t*) _TIFFmalloc(sizeof (uint8_t) * tnw); + rowoff = (uint32_t*) _TIFFmalloc(sizeof (uint32_t) * tnw); filterWidth = 0; stepDstWidth = stepSrcWidth = 0; setupBitsTables(); @@ -480,18 +473,18 @@ initScale() * according to the widths of the src and dst images. */ static void -setupStepTables(uint32 sw) +setupStepTables(uint32_t sw) { if (stepSrcWidth != sw || stepDstWidth != tnw) { int step = sw; int limit = tnw; int err = 0; - uint32 sx = 0; - uint32 x; + uint32_t sx = 0; + uint32_t x; int fw; - uint8 b; + uint8_t b; for (x = 0; x < tnw; x++) { - uint32 sx0 = sx; + uint32_t sx0 = sx; err += step; while (err >= limit) { err -= limit; @@ -514,19 +507,19 @@ setupStepTables(uint32 sw) } static void -setrow(uint8* row, uint32 nrows, const uint8* rows[]) +setrow(uint8_t* row, uint32_t nrows, const uint8_t* rows[]) { - uint32 x; - uint32 area = nrows * filterWidth; + uint32_t x; + uint32_t area = nrows * filterWidth; for (x = 0; x < tnw; x++) { - uint32 mask0 = src0[x]; - uint32 fw = src1[x]; - uint32 mask1 = src1[x]; - uint32 off = rowoff[x]; - uint32 acc = 0; - uint32 y, i; + uint32_t mask0 = src0[x]; + uint32_t fw = src1[x]; + uint32_t mask1 = src1[x]; + uint32_t off = rowoff[x]; + uint32_t acc = 0; + uint32_t y, i; for (y = 0; y < nrows; y++) { - const uint8* src = rows[y] + off; + const uint8_t* src = rows[y] + off; acc += bits[*src++ & mask0]; switch (fw) { default: @@ -556,18 +549,18 @@ setrow(uint8* row, uint32 nrows, const uint8* rows[]) * with a user-selectable contrast curve. */ static void -setImage1(const uint8* br, uint32 rw, uint32 rh) +setImage1(const uint8_t* br, uint32_t rw, uint32_t rh) { int step = rh; int limit = tnh; int err = 0; int bpr = TIFFhowmany8(rw); int sy = 0; - uint8* row = thumbnail; - uint32 dy; + uint8_t* row = thumbnail; + uint32_t dy; for (dy = 0; dy < tnh; dy++) { - const uint8* rows[256]; - uint32 nrows = 1; + const uint8_t* rows[256]; + uint32_t nrows = 1; fprintf(stderr, "bpr=%d, sy=%d, bpr*sy=%d\n", bpr, sy, bpr*sy); rows[0] = br + bpr*sy; err += step; @@ -589,9 +582,9 @@ setImage1(const uint8* br, uint32 rw, uint32 rh) } static void -setImage(const uint8* br, uint32 rw, uint32 rh) +setImage(const uint8_t* br, uint32_t rw, uint32_t rh) { - filterWidth = (uint16) ceil((double) rw / (double) tnw); + filterWidth = (uint16_t) ceil((double) rw / (double) tnw); setupStepTables(rw); setImage1(br, rw, rh); } @@ -601,8 +594,8 @@ generateThumbnail(TIFF* in, TIFF* out) { unsigned char* raster; unsigned char* rp; - uint32 sw, sh, rps; - uint16 bps, spp; + uint32_t sw, sh, rps; + uint16_t bps, spp; tsize_t rowsize, rastersize; tstrip_t s, ns = TIFFNumberOfStrips(in); toff_t diroff[1]; @@ -639,25 +632,26 @@ generateThumbnail(TIFF* in, TIFF* out) _TIFFfree(raster); TIFFSetField(out, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE); - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) tnw); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) tnh); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (uint16) 8); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, (uint16) 1); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t) tnw); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t) tnh); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (uint16_t) 8); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, (uint16_t) 1); TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - cpTag(in, out, TIFFTAG_SOFTWARE, (uint16) -1, TIFF_ASCII); - cpTag(in, out, TIFFTAG_IMAGEDESCRIPTION, (uint16) -1, TIFF_ASCII); - cpTag(in, out, TIFFTAG_DATETIME, (uint16) -1, TIFF_ASCII); - cpTag(in, out, TIFFTAG_HOSTCOMPUTER, (uint16) -1, TIFF_ASCII); + cpTag(in, out, TIFFTAG_SOFTWARE, (uint16_t) -1, TIFF_ASCII); + cpTag(in, out, TIFFTAG_IMAGEDESCRIPTION, (uint16_t) -1, TIFF_ASCII); + cpTag(in, out, TIFFTAG_DATETIME, (uint16_t) -1, TIFF_ASCII); + cpTag(in, out, TIFFTAG_HOSTCOMPUTER, (uint16_t) -1, TIFF_ASCII); diroff[0] = 0UL; TIFFSetField(out, TIFFTAG_SUBIFD, 1, diroff); return (TIFFWriteEncodedStrip(out, 0, thumbnail, tnw*tnh) != -1 && TIFFWriteDirectory(out) != -1); } -const char* stuff[] = { +const char* usage_info[] = { +"Create a TIFF file with thumbnail images\n\n" "usage: thumbnail [options] input.tif output.tif", "where options are:", " -h # specify thumbnail image height (default is 274)", @@ -680,8 +674,8 @@ usage(int code) FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + for (i = 0; usage_info[i] != NULL; i++) + fprintf(out, "%s\n", usage_info[i]); exit(code); } diff --git a/tiff/tools/tiff2bw.c b/tiff/tools/tiff2bw.c index 654bd324..75811e6a 100644 --- a/tiff/tools/tiff2bw.c +++ b/tiff/tools/tiff2bw.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -33,10 +34,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" #include "tiffiop.h" @@ -57,7 +54,7 @@ static void usage(int code); static int processCompressOptions(char*); static void -compresscontig(unsigned char* out, unsigned char* rgb, uint32 n) +compresscontig(unsigned char* out, unsigned char* rgb, uint32_t n) { register int v, red = RED, green = GREEN, blue = BLUE; @@ -71,9 +68,9 @@ compresscontig(unsigned char* out, unsigned char* rgb, uint32 n) static void compresssep(unsigned char* out, - unsigned char* r, unsigned char* g, unsigned char* b, uint32 n) + unsigned char* r, unsigned char* g, unsigned char* b, uint32_t n) { - register uint32 red = RED, green = GREEN, blue = BLUE; + register uint32_t red = RED, green = GREEN, blue = BLUE; while (n-- > 0) *out++ = (unsigned char) @@ -81,7 +78,7 @@ compresssep(unsigned char* out, } static int -checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) +checkcmap(TIFF* tif, int n, uint16_t* r, uint16_t* g, uint16_t* b) { while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) @@ -91,7 +88,7 @@ checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) } static void -compresspalette(unsigned char* out, unsigned char* data, uint32 n, uint16* rmap, uint16* gmap, uint16* bmap) +compresspalette(unsigned char* out, unsigned char* data, uint32_t n, uint16_t* rmap, uint16_t* gmap, uint16_t* bmap) { register int v, red = RED, green = GREEN, blue = BLUE; @@ -104,8 +101,8 @@ compresspalette(unsigned char* out, unsigned char* data, uint32 n, uint16* rmap, } } -static uint16 compression = (uint16) -1; -static uint16 predictor = 0; +static uint16_t compression = (uint16_t) -1; +static uint16_t predictor = 0; static int jpegcolormode = JPEGCOLORMODE_RGB; static int quality = 75; /* JPEG quality */ @@ -114,18 +111,18 @@ static void cpTags(TIFF* in, TIFF* out); int main(int argc, char* argv[]) { - uint32 rowsperstrip = (uint32) -1; + uint32_t rowsperstrip = (uint32_t) -1; TIFF *in, *out; - uint32 w, h; - uint16 samplesperpixel; - uint16 bitspersample; - uint16 config; - uint16 photometric; - uint16* red; - uint16* green; - uint16* blue; + uint32_t w, h; + uint16_t samplesperpixel; + uint16_t bitspersample; + uint16_t config; + uint16_t photometric; + uint16_t* red; + uint16_t* green; + uint16_t* blue; tsize_t rowsize; - register uint32 row; + register uint32_t row; register tsample_t s; unsigned char *inbuf, *outbuf; char thing[1024]; @@ -160,9 +157,12 @@ main(int argc, char* argv[]) break; case 'h': usage(EXIT_SUCCESS); + /*NOTREACHED*/ + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ + break; } if (argc - optind < 2) usage(EXIT_FAILURE); @@ -209,7 +209,7 @@ main(int argc, char* argv[]) TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); cpTags(in, out); - if (compression != (uint16) -1) { + if (compression != (uint16_t) -1) { TIFFSetField(out, TIFFTAG_COMPRESSION, compression); switch (compression) { case COMPRESSION_JPEG: @@ -376,27 +376,27 @@ processCompressOptions(char* opt) if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static void -cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) +cpTag(TIFF* in, TIFF* out, uint16_t tag, uint16_t count, TIFFDataType type) { switch (type) { case TIFF_SHORT: if (count == 1) { - uint16 shortv; + uint16_t shortv; CopyField(tag, shortv); } else if (count == 2) { - uint16 shortv1, shortv2; + uint16_t shortv1, shortv2; CopyField2(tag, shortv1, shortv2); } else if (count == 4) { - uint16 *tr, *tg, *tb, *ta; + uint16_t *tr, *tg, *tb, *ta; CopyField4(tag, tr, tg, tb, ta); - } else if (count == (uint16) -1) { - uint16 shortv1; - uint16* shortav; + } else if (count == (uint16_t) -1) { + uint16_t shortv1; + uint16_t* shortav; CopyField2(tag, shortv1, shortav); } break; case TIFF_LONG: - { uint32 longv; + { uint32_t longv; CopyField(tag, longv); } break; @@ -404,7 +404,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { float floatv; CopyField(tag, floatv); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { float* floatav; CopyField(tag, floatav); } @@ -418,7 +418,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { double doublev; CopyField(tag, doublev); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { double* doubleav; CopyField(tag, doubleav); } @@ -435,9 +435,9 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) #undef CopyField2 #undef CopyField -static struct cpTag { - uint16 tag; - uint16 count; +static const struct cpTag { + uint16_t tag; + uint16_t count; TIFFDataType type; } tags[] = { { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, @@ -449,49 +449,49 @@ static struct cpTag { { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, - { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, - { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, - { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, - { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, - { TIFFTAG_DATETIME, 1, TIFF_ASCII }, - { TIFFTAG_ARTIST, 1, TIFF_ASCII }, - { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, - { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, - { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, - { TIFFTAG_INKSET, 1, TIFF_SHORT }, - { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, - { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, - { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, - { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, - { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, - { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, - { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, - { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, - { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES,(uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16_t) -1, TIFF_SHORT }, + { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) static void cpTags(TIFF* in, TIFF* out) { - struct cpTag *p; + const struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) { if( p->tag == TIFFTAG_GROUP3OPTIONS ) { - uint16 compression; + uint16_t compression; if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || compression != COMPRESSION_CCITTFAX3 ) continue; } if( p->tag == TIFFTAG_GROUP4OPTIONS ) { - uint16 compression; + uint16_t compression; if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || compression != COMPRESSION_CCITTFAX4 ) continue; @@ -501,37 +501,47 @@ cpTags(TIFF* in, TIFF* out) } #undef NTAGS -const char* stuff[] = { -"usage: tiff2bw [options] input.tif output.tif", -"where options are:", -" -R % use #% from red channel", -" -G % use #% from green channel", -" -B % use #% from blue channel", -"", -" -r # make each strip have no more than # rows", -"", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c packbits compress output with packbits encoding", -" -c g3[:opts] compress output with CCITT Group 3 encoding", -" -c g4 compress output with CCITT Group 4 encoding", -" -c none use no compression algorithm on output", -"", -"LZW and deflate options:", -" # set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", -NULL -}; +static const char usage_info[] = +"Convert a color TIFF image to greyscale\n\n" +"usage: tiff2bw [options] input.tif output.tif\n" +"where options are:\n" +" -R % use #% from red channel\n" +" -G % use #% from green channel\n" +" -B % use #% from blue channel\n" +"\n" +" -r # make each strip have no more than # rows\n" +"\n" +#ifdef LZW_SUPPORT +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" +/* " LZW options:\n" */ +" # set predictor value\n" +" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip[:opts] compress output with deflate encoding\n" +/* " Deflate (ZIP) options:\n" */ +" # set predictor value\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits compress output with packbits encoding\n" +#endif +#ifdef CCITT_SUPPORT +" -c g3[:opts] compress output with CCITT Group 3 encoding\n" +" -c g4 compress output with CCITT Group 4 encoding\n" +#endif +#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) +" -c none use no compression algorithm on output\n" +#endif +"\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/tiff2pdf.c b/tiff/tools/tiff2pdf.c index acaef0d6..63751f11 100644 --- a/tiff/tools/tiff2pdf.c +++ b/tiff/tools/tiff2pdf.c @@ -24,8 +24,6 @@ * OF THIS SOFTWARE. */ -#include "tif_config.h" - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -46,16 +44,10 @@ # include <io.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffiop.h" #include "tiffio.h" - -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif +#include "tif_config.h" +#include "libport.h" #ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -128,9 +120,9 @@ typedef enum{ /* This struct defines a logical page of a TIFF. */ typedef struct { tdir_t page_directory; - uint32 page_number; + uint32_t page_number; ttile_t page_tilecount; - uint32 page_extra; + uint32_t page_extra; } T2P_PAGE; /* This struct defines a PDF rectangle's coordinates. */ @@ -150,12 +142,12 @@ typedef struct { /* This struct defines information about the tiles on a PDF page. */ typedef struct { ttile_t tiles_tilecount; - uint32 tiles_tilewidth; - uint32 tiles_tilelength; - uint32 tiles_tilecountx; - uint32 tiles_tilecounty; - uint32 tiles_edgetilewidth; - uint32 tiles_edgetilelength; + uint32_t tiles_tilewidth; + uint32_t tiles_tilelength; + uint32_t tiles_tilecountx; + uint32_t tiles_tilecounty; + uint32_t tiles_edgetilewidth; + uint32_t tiles_edgetilelength; T2P_TILE* tiles_tiles; } T2P_TILES; @@ -165,24 +157,24 @@ typedef struct { T2P_PAGE* tiff_pages; T2P_TILES* tiff_tiles; tdir_t tiff_pagecount; - uint16 tiff_compression; - uint16 tiff_photometric; - uint16 tiff_fillorder; - uint16 tiff_bitspersample; - uint16 tiff_samplesperpixel; - uint16 tiff_planar; - uint32 tiff_width; - uint32 tiff_length; + uint16_t tiff_compression; + uint16_t tiff_photometric; + uint16_t tiff_fillorder; + uint16_t tiff_bitspersample; + uint16_t tiff_samplesperpixel; + uint16_t tiff_planar; + uint32_t tiff_width; + uint32_t tiff_length; float tiff_xres; float tiff_yres; - uint16 tiff_orientation; + uint16_t tiff_orientation; toff_t tiff_dataoffset; tsize_t tiff_datasize; tsize_t tiff_maxdatasize; - uint16 tiff_resunit; - uint16 pdf_centimeters; - uint16 pdf_overrideres; - uint16 pdf_overridepagesize; + uint16_t tiff_resunit; + uint16_t pdf_centimeters; + uint16_t pdf_overrideres; + uint16_t pdf_overridepagesize; float pdf_defaultxres; float pdf_defaultyres; float pdf_xres; @@ -196,14 +188,14 @@ typedef struct { int pdf_image_fillpage; /* 0 (default: no scaling, 1:scale imagesize to pagesize */ T2P_BOX pdf_mediabox; T2P_BOX pdf_imagebox; - uint16 pdf_majorversion; - uint16 pdf_minorversion; - uint32 pdf_catalog; - uint32 pdf_pages; - uint32 pdf_info; - uint32 pdf_palettecs; - uint16 pdf_fitwindow; - uint32 pdf_startxref; + uint16_t pdf_majorversion; + uint16_t pdf_minorversion; + uint32_t pdf_catalog; + uint32_t pdf_pages; + uint32_t pdf_info; + uint32_t pdf_palettecs; + uint16_t pdf_fitwindow; + uint32_t pdf_startxref; #define TIFF2PDF_FILEID_SIZE 33 char pdf_fileid[TIFF2PDF_FILEID_SIZE]; #define TIFF2PDF_DATETIME_SIZE 17 @@ -224,35 +216,35 @@ typedef struct { char pdf_keywords[TIFF2PDF_KEYWORDS_SIZE]; int pdf_keywords_set; t2p_cs_t pdf_colorspace; - uint16 pdf_colorspace_invert; - uint16 pdf_switchdecode; - uint16 pdf_palettesize; + uint16_t pdf_colorspace_invert; + uint16_t pdf_switchdecode; + uint16_t pdf_palettesize; unsigned char* pdf_palette; int pdf_labrange[4]; t2p_compress_t pdf_defaultcompression; - uint16 pdf_defaultcompressionquality; + uint16_t pdf_defaultcompressionquality; t2p_compress_t pdf_compression; - uint16 pdf_compressionquality; /* for deflate : 100 * zipquality + predictor */ - uint16 pdf_nopassthrough; + uint16_t pdf_compressionquality; /* for deflate : 100 * zipquality + predictor */ + uint16_t pdf_nopassthrough; t2p_transcode_t pdf_transcode; t2p_sample_t pdf_sample; - uint32* pdf_xrefoffsets; - uint32 pdf_xrefcount; + uint32_t* pdf_xrefoffsets; + uint32_t pdf_xrefcount; tdir_t pdf_page; #ifdef OJPEG_SUPPORT tdata_t pdf_ojpegdata; - uint32 pdf_ojpegdatalength; - uint32 pdf_ojpegiflength; + uint32_t pdf_ojpegdatalength; + uint32_t pdf_ojpegiflength; #endif float tiff_whitechromaticities[2]; float tiff_primarychromaticities[6]; float tiff_referenceblackwhite[2]; - uint16* tiff_transferfunction[3]; + uint16_t* tiff_transferfunction[3]; int pdf_image_interpolate; /* 0 (default) : do not interpolate, 1 : interpolate */ - uint16 tiff_transferfunctioncount; - uint32 pdf_icccs; - uint32 tiff_iccprofilelength; + uint16_t tiff_transferfunctioncount; + uint32_t pdf_icccs; + uint32_t tiff_iccprofilelength; tdata_t tiff_iccprofile; /* fields for custom read/write procedures */ @@ -263,7 +255,7 @@ typedef struct { /* These functions are called by main. */ -static void tiff2pdf_usage(int); +static void usage_info(int); int tiff2pdf_match_paper_size(float*, float*, char*); /* These functions are used to generate a PDF from a TIFF. */ @@ -296,25 +288,25 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P*, TIFF*, TIFF*, ttile_t); int t2p_process_ojpeg_tables(T2P*, TIFF*); #endif #ifdef JPEG_SUPPORT -int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t, tsize_t*, tstrip_t, uint32); +int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t, tsize_t*, tstrip_t, uint32_t); #endif -void t2p_tile_collapse_left(tdata_t, tsize_t, uint32, uint32, uint32); +void t2p_tile_collapse_left(tdata_t, tsize_t, uint32_t, uint32_t, uint32_t); void t2p_write_advance_directory(T2P*, TIFF*); tsize_t t2p_sample_planar_separate_to_contig(T2P*, unsigned char*, unsigned char*, tsize_t); tsize_t t2p_sample_realize_palette(T2P*, unsigned char*); -tsize_t t2p_sample_abgr_to_rgb(tdata_t, uint32); -tsize_t t2p_sample_rgba_to_rgb(tdata_t, uint32); -tsize_t t2p_sample_rgbaa_to_rgb(tdata_t, uint32); -tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t, uint32); +tsize_t t2p_sample_abgr_to_rgb(tdata_t, uint32_t); +tsize_t t2p_sample_rgba_to_rgb(tdata_t, uint32_t); +tsize_t t2p_sample_rgbaa_to_rgb(tdata_t, uint32_t); +tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t, uint32_t); tsize_t t2p_write_pdf_header(T2P*, TIFF*); -tsize_t t2p_write_pdf_obj_start(uint32, TIFF*); +tsize_t t2p_write_pdf_obj_start(uint32_t, TIFF*); tsize_t t2p_write_pdf_obj_end(TIFF*); tsize_t t2p_write_pdf_name(const unsigned char*, TIFF*); tsize_t t2p_write_pdf_string(const char*, TIFF*); tsize_t t2p_write_pdf_stream(tdata_t, tsize_t, TIFF*); tsize_t t2p_write_pdf_stream_start(TIFF*); tsize_t t2p_write_pdf_stream_end(TIFF*); -tsize_t t2p_write_pdf_stream_dict(tsize_t, uint32, TIFF*); +tsize_t t2p_write_pdf_stream_dict(tsize_t, uint32_t, TIFF*); tsize_t t2p_write_pdf_stream_dict_start(TIFF*); tsize_t t2p_write_pdf_stream_dict_end(TIFF*); tsize_t t2p_write_pdf_stream_length(tsize_t, TIFF*); @@ -323,16 +315,16 @@ tsize_t t2p_write_pdf_info(T2P*, TIFF*, TIFF*); void t2p_pdf_currenttime(T2P*); void t2p_pdf_tifftime(T2P*, TIFF*); tsize_t t2p_write_pdf_pages(T2P*, TIFF*); -tsize_t t2p_write_pdf_page(uint32, T2P*, TIFF*); +tsize_t t2p_write_pdf_page(uint32_t, T2P*, TIFF*); void t2p_compose_pdf_page(T2P*); -void t2p_compose_pdf_page_orient(T2P_BOX*, uint16); -void t2p_compose_pdf_page_orient_flip(T2P_BOX*, uint16); +void t2p_compose_pdf_page_orient(T2P_BOX*, uint16_t); +void t2p_compose_pdf_page_orient_flip(T2P_BOX*, uint16_t); tsize_t t2p_write_pdf_page_content(T2P*, TIFF*); tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t, T2P*, TIFF*); tsize_t t2p_write_pdf_xobject_cs(T2P*, TIFF*); tsize_t t2p_write_pdf_transfer(T2P*, TIFF*); -tsize_t t2p_write_pdf_transfer_dict(T2P*, TIFF*, uint16); -tsize_t t2p_write_pdf_transfer_stream(T2P*, TIFF*, uint16); +tsize_t t2p_write_pdf_transfer_dict(T2P*, TIFF*, uint16_t); +tsize_t t2p_write_pdf_transfer_stream(T2P*, TIFF*, uint16_t); tsize_t t2p_write_pdf_xobject_calcs(T2P*, TIFF*); tsize_t t2p_write_pdf_xobject_icccs(T2P*, TIFF*); tsize_t t2p_write_pdf_xobject_icccs_dict(T2P*, TIFF*); @@ -390,7 +382,7 @@ t2pWriteFile(TIFF *tif, tdata_t data, tmsize_t size) return -1; } -static uint64 +static uint64_t t2pSeekFile(TIFF *tif, toff_t offset, int whence) { thandle_t client = TIFFClientdata(tif); @@ -419,8 +411,8 @@ t2p_writeproc(thandle_t handle, tdata_t data, tmsize_t size) return size; } -static uint64 -t2p_seekproc(thandle_t handle, uint64 offset, int whence) +static uint64_t +t2p_seekproc(thandle_t handle, uint64_t offset, int whence) { T2P *t2p = (T2P*) handle; if (t2p->outputdisable <= 0 && t2p->outputfile) @@ -435,7 +427,7 @@ t2p_closeproc(thandle_t handle) return fclose(t2p->outputfile); } -static uint64 +static uint64_t t2p_sizeproc(thandle_t handle) { (void) handle; @@ -456,10 +448,10 @@ t2p_unmapproc(thandle_t handle, void *data, toff_t offset) } #if defined(OJPEG_SUPPORT) || defined(JPEG_SUPPORT) -static uint64 -checkAdd64(uint64 summand1, uint64 summand2, T2P* t2p) +static uint64_t +checkAdd64(uint64_t summand1, uint64_t summand2, T2P* t2p) { - uint64 bytes = summand1 + summand2; + uint64_t bytes = summand1 + summand2; if (bytes < summand1) { TIFFError(TIFF2PDF_MODULE, "Integer overflow"); @@ -471,10 +463,10 @@ checkAdd64(uint64 summand1, uint64 summand2, T2P* t2p) } #endif /* defined(OJPEG_SUPPORT) || defined(JPEG_SUPPORT) */ -static uint64 -checkMultiply64(uint64 first, uint64 second, T2P* t2p) +static uint64_t +checkMultiply64(uint64_t first, uint64_t second, T2P* t2p) { - uint64 bytes = first * second; + uint64_t bytes = first * second; if (second && bytes / second != first) { TIFFError(TIFF2PDF_MODULE, "Integer overflow"); @@ -557,8 +549,12 @@ checkMultiply64(uint64 first, uint64 second, T2P* t2p) options: -o: output to file name +#ifdef JPEG_SUPPORT -j: compress with JPEG (requires libjpeg configured with libtiff) - -z: compress with Zip/Deflate (requires zlib configured with libtiff) +#endif +#ifdef ZIP_SUPPORT +printf (-z: compress with Zip/Deflate (requires zlib configured with libtiff)); +#endif -q: compression quality -n: no compressed data passthrough -d: do not compress (decompress) @@ -755,10 +751,10 @@ int main(int argc, char** argv){ t2p->pdf_image_interpolate = 1; break; case 'h': - tiff2pdf_usage(EXIT_SUCCESS); + usage_info(EXIT_SUCCESS); goto success; case '?': - tiff2pdf_usage(EXIT_FAILURE); + usage_info(EXIT_FAILURE); goto fail; } } @@ -776,14 +772,14 @@ int main(int argc, char** argv){ } } else { TIFFError(TIFF2PDF_MODULE, "No input file specified"); - tiff2pdf_usage(EXIT_FAILURE); + usage_info(EXIT_FAILURE); goto fail; } if(argc > optind) { TIFFError(TIFF2PDF_MODULE, "No support for multiple input files"); - tiff2pdf_usage(EXIT_FAILURE); + usage_info(EXIT_FAILURE); goto fail; } @@ -845,48 +841,47 @@ success: } -static void tiff2pdf_usage(int code) { - static const char* lines[]={ - "usage: tiff2pdf [options] input.tiff", - "options:", - " -o: output to file name", +static void usage_info(int code) { + static const char lines[]= + "Convert a TIFF image to a PDF document\n\n" + "usage: tiff2pdf [options] input.tiff\n" + "where options are:\n" + " -o: output to file name\n" #ifdef JPEG_SUPPORT - " -j: compress with JPEG", + " -j: compress with JPEG\n" #endif #ifdef ZIP_SUPPORT - " -z: compress with Zip/Deflate", + " -z: compress with Zip/Deflate\n" #endif - " -q: compression quality", - " -n: no compressed data passthrough", - " -d: do not compress (decompress)", - " -i: invert colors", - " -u: set distance unit, 'i' for inch, 'm' for centimeter", - " -x: set x resolution default in dots per unit", - " -y: set y resolution default in dots per unit", - " -w: width in units", - " -l: length in units", - " -r: 'd' for resolution default, 'o' for resolution override", - " -p: paper size, eg \"letter\", \"legal\", \"A4\"", - " -F: make the tiff fill the PDF page", - " -f: set PDF \"Fit Window\" user preference", - " -e: date, overrides image or current date/time default, YYYYMMDDHHMMSS", - " -c: sets document creator, overrides image software default", - " -a: sets document author, overrides image artist default", - " -t: sets document title, overrides image document name default", - " -s: sets document subject, overrides image image description default", - " -k: sets document keywords", - " -b: set PDF \"Interpolate\" user preference", - " -m: set memory allocation limit (in MiB). set to 0 to disable limit", - " -h: usage", - NULL - }; - int i=0; +#if defined(JPEG_SUPPORT) || defined(ZIP_SUPPORT) + " -q: compression quality\n" + " -n: no compressed data passthrough\n" + " -d: do not compress (decompress)\n" +#endif + " -i: invert colors\n" + " -u: set distance unit, 'i' for inch, 'm' for centimeter\n" + " -x: set x resolution default in dots per unit\n" + " -y: set y resolution default in dots per unit\n" + " -w: width in units\n" + " -l: length in units\n" + " -r: 'd' for resolution default, 'o' for resolution override\n" + " -p: paper size, eg \"letter\", \"legal\", \"A4\"\n" + " -F: make the tiff fill the PDF page\n" + " -f: set PDF \"Fit Window\" user preference\n" + " -e: date, overrides image or current date/time default, YYYYMMDDHHMMSS\n" + " -c: sets document creator, overrides image software default\n" + " -a: sets document author, overrides image artist default\n" + " -t: sets document title, overrides image document name default\n" + " -s: sets document subject, overrides image image description default\n" + " -k: sets document keywords\n" + " -b: set PDF \"Interpolate\" user preference\n" + " -m: set memory allocation limit (in MiB). set to 0 to disable limit\n" + " -h: usage\n" + ; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i=0;lines[i]!=NULL;i++){ - fprintf(out, "%s\n", lines[i]); - } + fprintf(out, "%s", lines); return; } @@ -961,8 +956,8 @@ T2P* t2p_init() if(t2p==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_init", - (unsigned long) sizeof(T2P)); + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_init", + sizeof(T2P)); return( (T2P*) NULL ); } _TIFFmemset(t2p, 0x00, sizeof(T2P)); @@ -1021,6 +1016,7 @@ void t2p_free(T2P* t2p) */ void t2p_validate(T2P* t2p){ + (void) t2p; #ifdef JPEG_SUPPORT if(t2p->pdf_defaultcompression==T2P_COMPRESS_JPEG){ @@ -1032,7 +1028,7 @@ void t2p_validate(T2P* t2p){ #endif #ifdef ZIP_SUPPORT if(t2p->pdf_defaultcompression==T2P_COMPRESS_ZIP){ - uint16 m=t2p->pdf_defaultcompressionquality%100; + uint16_t m= t2p->pdf_defaultcompressionquality % 100; if(t2p->pdf_defaultcompressionquality/100 > 9 || (m>1 && m<10) || m>15){ t2p->pdf_defaultcompressionquality=0; @@ -1042,14 +1038,13 @@ void t2p_validate(T2P* t2p){ t2p->pdf_defaultcompressionquality*=100; TIFFError( TIFF2PDF_MODULE, - "PNG Group predictor differencing not implemented, assuming compression quality %u", + "PNG Group predictor differencing not implemented, assuming compression quality %"PRIu16, t2p->pdf_defaultcompressionquality); } t2p->pdf_defaultcompressionquality%=100; if(t2p->pdf_minorversion<2){t2p->pdf_minorversion=2;} } #endif - (void)0; return; } @@ -1066,11 +1061,11 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ tdir_t directorycount=0; tdir_t i=0; - uint16 pagen=0; - uint16 paged=0; - uint16 xuint16=0; - uint16 tiff_transferfunctioncount=0; - uint16* tiff_transferfunction[3]; + uint16_t pagen=0; + uint16_t paged=0; + uint16_t xuint16=0; + uint16_t tiff_transferfunctioncount=0; + uint16_t* tiff_transferfunction[3]; directorycount=TIFFNumberOfDirectories(input); if(directorycount > TIFF_DIR_MAX) { @@ -1085,8 +1080,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if(t2p->tiff_pages==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate " TIFF_SIZE_FORMAT " bytes of memory for tiff_pages array, %s", - (TIFF_SIZE_T) directorycount * sizeof(T2P_PAGE), + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for tiff_pages array, %s", + sizeof(T2P_PAGE) * directorycount, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1096,20 +1091,20 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if(t2p->tiff_tiles==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate " TIFF_SIZE_FORMAT " bytes of memory for tiff_tiles array, %s", - (TIFF_SIZE_T) directorycount * sizeof(T2P_TILES), + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for tiff_tiles array, %s", + sizeof(T2P_TILES) * directorycount, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; } _TIFFmemset( t2p->tiff_tiles, 0x00, directorycount * sizeof(T2P_TILES)); for(i=0;i<directorycount;i++){ - uint32 subfiletype = 0; + uint32_t subfiletype = 0; if(!TIFFSetDirectory(input, i)){ TIFFError( TIFF2PDF_MODULE, - "Can't set directory %u of input file %s", + "Can't set directory %"PRIu16" of input file %s", i, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -1183,8 +1178,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ &(tiff_transferfunction[1]), &(tiff_transferfunction[2]))) { - if((tiff_transferfunction[1] != (uint16*) NULL) && - (tiff_transferfunction[2] != (uint16*) NULL) + if((tiff_transferfunction[1] != (uint16_t*) NULL) && + (tiff_transferfunction[2] != (uint16_t*) NULL) ) { tiff_transferfunctioncount=3; } else { @@ -1198,7 +1193,7 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if (tiff_transferfunctioncount != t2p->tiff_transferfunctioncount){ TIFFError( TIFF2PDF_MODULE, - "Different transfer function on page %d", + "Different transfer function on page %"PRIu16, i); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1269,8 +1264,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ if( t2p->tiff_tiles[i].tiles_tiles == NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate " TIFF_SIZE_FORMAT " bytes of memory for t2p_read_tiff_init, %s", - (TIFF_SIZE_T) t2p->tiff_tiles[i].tiles_tilecount * sizeof(T2P_TILE), + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_read_tiff_init, %s", + sizeof(T2P_TILE) * t2p->tiff_tiles[i].tiles_tilecount, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1290,9 +1285,9 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ int t2p_cmp_t2p_page(const void* e1, const void* e2){ int d; - d = (int32)(((T2P_PAGE*)e1)->page_number) - (int32)(((T2P_PAGE*)e2)->page_number); + d = (int32_t)(((T2P_PAGE*)e1)->page_number) - (int32_t)(((T2P_PAGE*)e2)->page_number); if(d == 0){ - d = (int32)(((T2P_PAGE*)e1)->page_directory) - (int32)(((T2P_PAGE*)e2)->page_directory); + d = (int32_t)(((T2P_PAGE*)e1)->page_directory) - (int32_t)(((T2P_PAGE*)e2)->page_directory); } return d; } @@ -1312,12 +1307,12 @@ int t2p_cmp_t2p_page(const void* e1, const void* e2){ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ int i=0; - uint16* r = NULL; - uint16* g = NULL; - uint16* b = NULL; - uint16* a = NULL; - uint16 xuint16; - uint16* xuint16p; + uint16_t* r = NULL; + uint16_t* g = NULL; + uint16_t* b = NULL; + uint16_t* a = NULL; + uint16_t xuint16; + uint16_t* xuint16p; float* xfloatp; t2p->pdf_transcode = T2P_TRANSCODE_ENCODE; @@ -1359,7 +1354,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( TIFFIsCODECConfigured(t2p->tiff_compression) == 0){ TIFFError( TIFF2PDF_MODULE, - "No support for %s with compression type %u: not configured", + "No support for %s with compression type %"PRIu16": not configured", TIFFFileName(input), t2p->tiff_compression ); @@ -1385,7 +1380,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ default: TIFFError( TIFF2PDF_MODULE, - "No support for %s with %u bits per sample", + "No support for %s with %"PRIu16" bits per sample", TIFFFileName(input), t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; @@ -1396,7 +1391,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->tiff_samplesperpixel>4){ TIFFError( TIFF2PDF_MODULE, - "No support for %s with %u samples per pixel", + "No support for %s with %"PRIu16" samples per pixel", TIFFFileName(input), t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; @@ -1419,7 +1414,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ default: TIFFError( TIFF2PDF_MODULE, - "No support for %s with sample format %u", + "No support for %s with sample format %"PRIu16, TIFFFileName(input), xuint16); t2p->t2p_error = T2P_ERR_ERROR; @@ -1476,7 +1471,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ { TIFFError( TIFF2PDF_MODULE, - "No support for BitsPerSample=%d for RGBA", + "No support for BitsPerSample=%"PRIu16" for RGBA", t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1489,7 +1484,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ { TIFFError( TIFF2PDF_MODULE, - "No support for BitsPerSample=%d for RGBA", + "No support for BitsPerSample=%"PRIu16" for RGBA", t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1513,7 +1508,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ } else { TIFFError( TIFF2PDF_MODULE, - "No support for RGB image %s with %u samples per pixel", + "No support for RGB image %s with %"PRIu16" samples per pixel", TIFFFileName(input), t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; @@ -1522,7 +1517,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ } else { TIFFError( TIFF2PDF_MODULE, - "No support for RGB image %s with %u samples per pixel", + "No support for RGB image %s with %"PRIu16" samples per pixel", TIFFFileName(input), t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; @@ -1564,7 +1559,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->pdf_palette==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_read_tiff_image, %s", + "Can't allocate %"PRIu16" bytes of memory for t2p_read_tiff_image, %s", t2p->pdf_palettesize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -1598,7 +1593,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ } else { TIFFError( TIFF2PDF_MODULE, - "No support for %s because it has %u samples per pixel", + "No support for %s because it has %"PRIu16" samples per pixel", TIFFFileName(input), t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; @@ -1640,7 +1635,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->pdf_palette==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_read_tiff_image, %s", + "Can't allocate %"PRIu16" bytes of memory for t2p_read_tiff_image, %s", t2p->pdf_palettesize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -1672,7 +1667,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( t2p->tiff_samplesperpixel != 3){ TIFFError( TIFF2PDF_MODULE, - "Unsupported samplesperpixel = %d for CIELAB", + "Unsupported samplesperpixel = %"PRIu16" for CIELAB", t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1680,7 +1675,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( t2p->tiff_bitspersample != 8){ TIFFError( TIFF2PDF_MODULE, - "Invalid bitspersample = %d for CIELAB", + "Invalid bitspersample = %"PRIu16" for CIELAB", t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1703,7 +1698,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( t2p->tiff_samplesperpixel != 3){ TIFFError( TIFF2PDF_MODULE, - "Unsupported samplesperpixel = %d for ITULAB", + "Unsupported samplesperpixel = %"PRIu16" for ITULAB", t2p->tiff_samplesperpixel); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1711,7 +1706,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if( t2p->tiff_bitspersample != 8){ TIFFError( TIFF2PDF_MODULE, - "Invalid bitspersample = %d for ITULAB", + "Invalid bitspersample = %"PRIu16" for ITULAB", t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; return; @@ -1734,7 +1729,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ default: TIFFError( TIFF2PDF_MODULE, - "No support for %s with photometric interpretation %u", + "No support for %s with photometric interpretation %"PRIu16, TIFFFileName(input), t2p->tiff_photometric); t2p->t2p_error = T2P_ERR_ERROR; @@ -1756,7 +1751,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->tiff_bitspersample!=8){ TIFFError( TIFF2PDF_MODULE, - "No support for %s with separated planar configuration and %u bits per sample", + "No support for %s with separated planar configuration and %"PRIu16" bits per sample", TIFFFileName(input), t2p->tiff_bitspersample); t2p->t2p_error = T2P_ERR_ERROR; @@ -1766,7 +1761,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ default: TIFFError( TIFF2PDF_MODULE, - "No support for %s with planar configuration %u", + "No support for %s with planar configuration %"PRIu16, TIFFFileName(input), t2p->tiff_planar); t2p->t2p_error = T2P_ERR_ERROR; @@ -1778,7 +1773,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ &(t2p->tiff_orientation)); if(t2p->tiff_orientation>8){ TIFFWarning(TIFF2PDF_MODULE, - "Image %s has orientation %u, assuming 0", + "Image %s has orientation %"PRIu16", assuming 0", TIFFFileName(input), t2p->tiff_orientation); t2p->tiff_orientation=0; } @@ -1824,7 +1819,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ if(t2p->tiff_compression== COMPRESSION_ADOBE_DEFLATE || t2p->tiff_compression==COMPRESSION_DEFLATE){ if(TIFFIsTiled(input) || (TIFFNumberOfStrips(input)==1) ){ - uint16 predictor; + uint16_t predictor; t2p->pdf_transcode = T2P_TRANSCODE_RAW; t2p->pdf_compression=T2P_COMPRESS_ZIP; TIFFGetField(input, TIFFTAG_PREDICTOR, &predictor); @@ -1899,8 +1894,8 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ &(t2p->tiff_transferfunction[0]), &(t2p->tiff_transferfunction[1]), &(t2p->tiff_transferfunction[2]))) { - if((t2p->tiff_transferfunction[1] != (uint16*) NULL) && - (t2p->tiff_transferfunction[2] != (uint16*) NULL) + if((t2p->tiff_transferfunction[1] != (uint16_t*) NULL) && + (t2p->tiff_transferfunction[2] != (uint16_t*) NULL) ) { t2p->tiff_transferfunctioncount=3; } else { @@ -1960,41 +1955,44 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){ return; } -/* +/** + * checks for overflow + */ +static void t2p_set_tiff_datasize(T2P* t2p, uint64_t k) { + if (k != (uint64_t)(tmsize_t)k || (tmsize_t)k < 0) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->tiff_datasize = (tmsize_t)k; +} + +/** This function returns the necessary size of a data buffer to contain the raw or uncompressed image data from the input TIFF for a page. */ - void t2p_read_tiff_size(T2P* t2p, TIFF* input){ - uint64* sbc=NULL; -#if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT) + uint64_t* sbc=NULL; +#if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT) unsigned char* jpt=NULL; tstrip_t i=0; tstrip_t stripcount=0; #endif - uint64 k = 0; + uint64_t k = 0; if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){ -#ifdef CCITT_SUPPORT - if(t2p->pdf_compression == T2P_COMPRESS_G4 ){ - TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); - if (sbc[0] != (uint64)(tmsize_t)sbc[0]) { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - } - t2p->tiff_datasize=(tmsize_t)sbc[0]; - return; - } +#if defined(CCITT_SUPPORT) || defined(ZIP_SUPPORT) +#if defined(CCITT_SUPPORT) && defined(ZIP_SUPPORT) + if(t2p->pdf_compression == T2P_COMPRESS_G4 || t2p->pdf_compression == T2P_COMPRESS_ZIP) +#elif defined(CCITT_SUPPORT) + if(t2p->pdf_compression == T2P_COMPRESS_G4) +#else + if(t2p->pdf_compression == T2P_COMPRESS_ZIP) #endif -#ifdef ZIP_SUPPORT - if(t2p->pdf_compression == T2P_COMPRESS_ZIP){ + { TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); - if (sbc[0] != (uint64)(tmsize_t)sbc[0]) { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - } - t2p->tiff_datasize=(tmsize_t)sbc[0]; + t2p_set_tiff_datasize(t2p, sbc[0]); return; } #endif @@ -2014,7 +2012,7 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ if(TIFFGetField(input, TIFFTAG_JPEGIFOFFSET, &(t2p->tiff_dataoffset))){ if(t2p->tiff_dataoffset != 0){ if(TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, &(t2p->tiff_datasize))!=0){ - if((uint64)t2p->tiff_datasize < k) { + if((uint64_t)t2p->tiff_datasize < k) { TIFFWarning(TIFF2PDF_MODULE, "Input file %s has short JPEG interchange file byte count", TIFFFileName(input)); @@ -2023,11 +2021,7 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ k = checkAdd64(k, 6, t2p); k = checkAdd64(k, stripcount, t2p); k = checkAdd64(k, stripcount, t2p); - t2p->tiff_datasize = (tsize_t) k; - if ((uint64) t2p->tiff_datasize != k) { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - } + t2p_set_tiff_datasize(t2p, k); return; } return; @@ -2043,17 +2037,13 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ k = checkAdd64(k, stripcount, t2p); k = checkAdd64(k, stripcount, t2p); k = checkAdd64(k, 2048, t2p); - t2p->tiff_datasize = (tsize_t) k; - if ((uint64) t2p->tiff_datasize != k) { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - } + t2p_set_tiff_datasize(t2p, k); return; } #endif #ifdef JPEG_SUPPORT if(t2p->tiff_compression == COMPRESSION_JPEG) { - uint32 count = 0; + uint32_t count = 0; if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0 ){ if(count > 4){ k += count; @@ -2077,11 +2067,7 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ } k = checkAdd64(k, 2, t2p); /* use EOI of last strip */ k = checkAdd64(k, 6, t2p); /* for DRI marker of first strip */ - t2p->tiff_datasize = (tsize_t) k; - if ((uint64) t2p->tiff_datasize != k) { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - } + t2p_set_tiff_datasize(t2p, k); return; } #endif @@ -2104,11 +2090,7 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ t2p->t2p_error = T2P_ERR_ERROR; } - t2p->tiff_datasize = (tsize_t) k; - if ((uint64) t2p->tiff_datasize != k) { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - } + t2p_set_tiff_datasize(t2p, k); return; } @@ -2120,12 +2102,12 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){ void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){ - uint64* tbc = NULL; - uint16 edge=0; + uint64_t* tbc = NULL; + uint16_t edge=0; #ifdef JPEG_SUPPORT unsigned char* jpt; #endif - uint64 k; + uint64_t k; edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile); edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile); @@ -2152,7 +2134,7 @@ void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){ #endif #ifdef JPEG_SUPPORT if(t2p->tiff_compression==COMPRESSION_JPEG) { - uint32 count = 0; + uint32_t count = 0; if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt)!=0){ if(count > 4){ k = checkAdd64(k, count, t2p); @@ -2161,11 +2143,7 @@ void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){ } } #endif - t2p->tiff_datasize = (tsize_t) k; - if ((uint64) t2p->tiff_datasize != k) { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - } + t2p_set_tiff_datasize(t2p, k); return; } } @@ -2178,11 +2156,7 @@ void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){ t2p->t2p_error = T2P_ERR_ERROR; } - t2p->tiff_datasize = (tsize_t) k; - if ((uint64) t2p->tiff_datasize != k) { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - } + t2p_set_tiff_datasize(t2p, k); return; } @@ -2263,18 +2237,18 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ tsize_t sepstripsize=0; #ifdef OJPEG_SUPPORT toff_t inputoffset=0; - uint16 h_samp=1; - uint16 v_samp=1; - uint16 ri=1; - uint32 rows=0; + uint16_t h_samp=1; + uint16_t v_samp=1; + uint16_t ri=1; + uint32_t rows=0; #endif /* ifdef OJPEG_SUPPORT */ #ifdef JPEG_SUPPORT unsigned char* jpt; float* xfloatp; - uint64* sbc; + uint64_t* sbc; unsigned char* stripbuffer; tsize_t striplength=0; - uint32 max_striplength=0; + uint32_t max_striplength=0; #endif /* ifdef JPEG_SUPPORT */ /* Fail if prior error (in particular, can't trust tiff_datasize) */ @@ -2288,9 +2262,9 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if (buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for " "t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2323,8 +2297,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer == NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2355,8 +2329,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2431,8 +2405,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2482,13 +2456,13 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ #endif /* ifdef OJPEG_SUPPORT */ #ifdef JPEG_SUPPORT if(t2p->tiff_compression == COMPRESSION_JPEG) { - uint32 count = 0; + uint32_t count = 0; buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2509,7 +2483,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(max_striplength); if(stripbuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"PRId32" bytes of memory for t2p_readwrite_pdf_image, %s", max_striplength, TIFFFileName(input)); _TIFFfree(buffer); @@ -2557,8 +2531,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2574,7 +2548,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ TIFFmin(stripsize, t2p->tiff_datasize - bufferoffset)); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %u of %s", + "Error on decoding strip %"PRIu32" of %s", i, TIFFFileName(input)); _TIFFfree(buffer); @@ -2595,8 +2569,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2605,8 +2579,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ samplebuffer = (unsigned char*) _TIFFmalloc(stripsize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; _TIFFfree(buffer); @@ -2622,7 +2596,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ TIFFmin(sepstripsize, stripsize - samplebufferoffset)); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %u of %s", + "Error on decoding strip %"PRIu32" of %s", i + j*stripcount, TIFFFileName(input)); _TIFFfree(buffer); @@ -2645,8 +2619,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2662,7 +2636,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ TIFFmin(stripsize, t2p->tiff_datasize - bufferoffset)); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %u of %s", + "Error on decoding strip %"PRIu32" of %s", i, TIFFFileName(input)); _TIFFfree(samplebuffer); @@ -2680,8 +2654,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_datasize * t2p->tiff_samplesperpixel); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; _TIFFfree(buffer); @@ -2711,8 +2685,8 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_width*t2p->tiff_length*4); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; _TIFFfree(buffer); @@ -2724,7 +2698,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ input, t2p->tiff_width, t2p->tiff_length, - (uint32*)buffer, + (uint32_t*)buffer, ORIENTATION_TOPLEFT, 0)){ TIFFError(TIFF2PDF_MODULE, @@ -2770,7 +2744,7 @@ dataready: #ifdef JPEG_SUPPORT case T2P_COMPRESS_JPEG: if(t2p->tiff_photometric==PHOTOMETRIC_YCBCR) { - uint16 hor = 0, ver = 0; + uint16_t hor = 0, ver = 0; if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver) !=0 ) { if(hor != 0 && ver != 0){ TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver); @@ -2872,14 +2846,14 @@ dataready: tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_t tile){ - uint16 edge=0; + uint16_t edge=0; tsize_t written=0; unsigned char* buffer=NULL; tsize_t bufferoffset=0; unsigned char* samplebuffer=NULL; tsize_t samplebufferoffset=0; tsize_t read=0; - uint16 i=0; + uint16_t i=0; ttile_t tilecount=0; /* tsize_t tilesize=0; */ ttile_t septilecount=0; @@ -2887,7 +2861,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ #ifdef JPEG_SUPPORT unsigned char* jpt; float* xfloatp; - uint32 xuint32=0; + uint32_t xuint32=0; #endif /* Fail if prior error (in particular, can't trust tiff_datasize) */ @@ -2908,9 +2882,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2936,9 +2910,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -2973,9 +2947,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer=(unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3017,13 +2991,13 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ #ifdef JPEG_SUPPORT if(t2p->tiff_compression == COMPRESSION_JPEG){ unsigned char table_end[2]; - uint32 count = 0; + uint32_t count = 0; buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate " TIFF_SIZE_FORMAT " bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (TIFF_SIZE_T) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3070,9 +3044,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory for " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for " "t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3086,7 +3060,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ t2p->tiff_datasize); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %u of %s", + "Error on decoding tile %"PRIu32" of %s", tile, TIFFFileName(input)); _TIFFfree(buffer); @@ -3104,9 +3078,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3115,9 +3089,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ samplebuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); _TIFFfree(buffer); t2p->t2p_error = T2P_ERR_ERROR; @@ -3133,7 +3107,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ septilesize); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %u of %s", + "Error on decoding tile %"PRIu32" of %s", tile + i*tilecount, TIFFFileName(input)); _TIFFfree(samplebuffer); @@ -3156,9 +3130,9 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %lu bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", - (unsigned long) t2p->tiff_datasize, + t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3171,7 +3145,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ t2p->tiff_datasize); if(read==-1){ TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %u of %s", + "Error on decoding tile %"PRIu32" of %s", tile, TIFFFileName(input)); _TIFFfree(buffer); @@ -3212,7 +3186,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ } if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile) != 0){ - if ((uint64)t2p->tiff_datasize < (uint64)TIFFTileRowSize(input) * (uint64)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength) { + if ((uint64_t)t2p->tiff_datasize < (uint64_t)TIFFTileRowSize(input) * (uint64_t)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength) { /* we don't know how to handle PLANARCONFIG_CONTIG, PHOTOMETRIC_YCBCR with 3 samples per pixel */ TIFFWarning( TIFF2PDF_MODULE, @@ -3277,7 +3251,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ #ifdef JPEG_SUPPORT case T2P_COMPRESS_JPEG: if (t2p->tiff_photometric==PHOTOMETRIC_YCBCR) { - uint16 hor = 0, ver = 0; + uint16_t hor = 0, ver = 0; if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver)!=0) { if (hor != 0 && ver != 0) { TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver); @@ -3331,8 +3305,8 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ if (TIFFStripSize(output) > t2p->tiff_datasize) { TIFFError(TIFF2PDF_MODULE, - "Size mismatch input %ld, output %ld", - t2p->tiff_datasize, TIFFStripSize(output)); + "Size mismatch input %" PRId64 ", output %" PRId64, + (int64_t) t2p->tiff_datasize, (int64_t) TIFFStripSize(output)); _TIFFfree(buffer); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3360,26 +3334,26 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ #ifdef OJPEG_SUPPORT int t2p_process_ojpeg_tables(T2P* t2p, TIFF* input){ - uint16 proc=0; + uint16_t proc=0; void* q; - uint32 q_length=0; + uint32_t q_length=0; void* dc; - uint32 dc_length=0; + uint32_t dc_length=0; void* ac; - uint32 ac_length=0; - uint16* lp; - uint16* pt; - uint16 h_samp=1; - uint16 v_samp=1; + uint32_t ac_length=0; + uint16_t* lp; + uint16_t* pt; + uint16_t h_samp=1; + uint16_t v_samp=1; unsigned char* ojpegdata; - uint16 table_count; - uint32 offset_table; - uint32 offset_ms_l; - uint32 code_count; - uint32 i=0; - uint32 dest=0; - uint16 ri=0; - uint32 rows=0; + uint16_t table_count; + uint32_t offset_table; + uint32_t offset_ms_l; + uint32_t code_count; + uint32_t i=0; + uint32_t dest=0; + uint16_t ri=0; + uint32_t rows=0; if(!TIFFGetField(input, TIFFTAG_JPEGPROC, &proc)){ TIFFError(TIFF2PDF_MODULE, @@ -3452,7 +3426,7 @@ int t2p_process_ojpeg_tables(T2P* t2p, TIFF* input){ if(t2p->pdf_ojpegdata == NULL){ TIFFError(TIFF2PDF_MODULE, "Can't allocate %u bytes of memory for t2p_process_ojpeg_tables, %s", - 2048, + 2048u, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; return(0); @@ -3605,21 +3579,21 @@ int t2p_process_ojpeg_tables(T2P* t2p, TIFF* input){ #ifdef JPEG_SUPPORT int t2p_process_jpeg_strip( - unsigned char* strip, - tsize_t* striplength, - unsigned char* buffer, - tsize_t buffersize, - tsize_t* bufferoffset, - tstrip_t no, - uint32 height){ + unsigned char* strip, + tsize_t* striplength, + unsigned char* buffer, + tsize_t buffersize, + tsize_t* bufferoffset, + tstrip_t no, + uint32_t height){ tsize_t i=0; while (i < *striplength) { tsize_t datalen; - uint16 ri; - uint16 v_samp; - uint16 h_samp; + uint16_t ri; + uint16_t v_samp; + uint16_t h_samp; int j; int ncomp; @@ -3667,7 +3641,7 @@ int t2p_process_jpeg_strip( if( *bufferoffset + 11 + 3*(ncomp-1) >= buffersize ) return(0); for(j=0;j<ncomp;j++){ - uint16 samp = buffer[*bufferoffset+11+(3*j)]; + uint16_t samp = buffer[*bufferoffset + 11 + (3 * j)]; if( (samp>>4) > h_samp) h_samp = (samp>>4); if( (samp & 0x0f) > v_samp) @@ -3675,12 +3649,12 @@ int t2p_process_jpeg_strip( } v_samp*=8; h_samp*=8; - ri=((( ((uint16)(buffer[*bufferoffset+5])<<8) | - (uint16)(buffer[*bufferoffset+6]) )+v_samp-1)/ - v_samp); - ri*=((( ((uint16)(buffer[*bufferoffset+7])<<8) | - (uint16)(buffer[*bufferoffset+8]) )+h_samp-1)/ - h_samp); + ri=(((((uint16_t)(buffer[*bufferoffset + 5]) << 8) | + (uint16_t)(buffer[*bufferoffset + 6]) ) + v_samp - 1) / + v_samp); + ri*=(((((uint16_t)(buffer[*bufferoffset + 7]) << 8) | + (uint16_t)(buffer[*bufferoffset + 8]) ) + h_samp - 1) / + h_samp); buffer[*bufferoffset+5]= (unsigned char) ((height>>8) & 0xff); buffer[*bufferoffset+6]= @@ -3739,13 +3713,13 @@ int t2p_process_jpeg_strip( tilelength buffer of samples. */ void t2p_tile_collapse_left( - tdata_t buffer, - tsize_t scanwidth, - uint32 tilewidth, - uint32 edgetilewidth, - uint32 tilelength){ + tdata_t buffer, + tsize_t scanwidth, + uint32_t tilewidth, + uint32_t edgetilewidth, + uint32_t tilelength){ - uint32 i; + uint32_t i; tsize_t edgescanwidth=0; edgescanwidth = (scanwidth * edgetilewidth + (tilewidth - 1))/ tilewidth; @@ -3804,12 +3778,12 @@ tsize_t t2p_sample_planar_separate_to_contig( tsize_t t2p_sample_realize_palette(T2P* t2p, unsigned char* buffer){ - uint32 sample_count=0; - uint16 component_count=0; - uint32 palette_offset=0; - uint32 sample_offset=0; - uint32 i=0; - uint32 j=0; + uint32_t sample_count=0; + uint16_t component_count=0; + uint32_t palette_offset=0; + uint32_t sample_offset=0; + uint32_t i=0; + uint32_t j=0; size_t data_size; sample_count=t2p->tiff_width*t2p->tiff_length; component_count=t2p->tiff_samplesperpixel; @@ -3844,13 +3818,13 @@ tsize_t t2p_sample_realize_palette(T2P* t2p, unsigned char* buffer){ into RGB interleaved data, discarding A. */ -tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32 samplecount) +tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32_t samplecount) { - uint32 i=0; - uint32 sample=0; + uint32_t i=0; + uint32_t sample=0; for(i=0;i<samplecount;i++){ - sample=((uint32*)data)[i]; + sample=((uint32_t*)data)[i]; ((char*)data)[i*3]= (char) (sample & 0xff); ((char*)data)[i*3+1]= (char) ((sample>>8) & 0xff); ((char*)data)[i*3+2]= (char) ((sample>>16) & 0xff); @@ -3865,18 +3839,18 @@ tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32 samplecount) */ tsize_t -t2p_sample_rgbaa_to_rgb(tdata_t data, uint32 samplecount) +t2p_sample_rgbaa_to_rgb(tdata_t data, uint32_t samplecount) { - uint32 i; + uint32_t i; /* For the 3 first samples, there is overlap between source and * destination, so use memmove(). * See http://bugzilla.maptools.org/show_bug.cgi?id=2577 */ for(i = 0; i < 3 && i < samplecount; i++) - memmove((uint8*)data + i * 3, (uint8*)data + i * 4, 3); + memmove((uint8_t*)data + i * 3, (uint8_t*)data + i * 4, 3); for(; i < samplecount; i++) - memcpy((uint8*)data + i * 3, (uint8*)data + i * 4, 3); + memcpy((uint8_t*)data + i * 3, (uint8_t*)data + i * 4, 3); return(i * 3); } @@ -3887,18 +3861,18 @@ t2p_sample_rgbaa_to_rgb(tdata_t data, uint32 samplecount) */ tsize_t -t2p_sample_rgba_to_rgb(tdata_t data, uint32 samplecount) +t2p_sample_rgba_to_rgb(tdata_t data, uint32_t samplecount) { - uint32 i = 0; - uint32 sample = 0; - uint8 alpha = 0; + uint32_t i = 0; + uint32_t sample = 0; + uint8_t alpha = 0; for (i = 0; i < samplecount; i++) { - sample=((uint32*)data)[i]; - alpha=(uint8)((255 - ((sample >> 24) & 0xff))); - ((uint8 *)data)[i * 3] = (uint8) ((sample >> 16) & 0xff) + alpha; - ((uint8 *)data)[i * 3 + 1] = (uint8) ((sample >> 8) & 0xff) + alpha; - ((uint8 *)data)[i * 3 + 2] = (uint8) (sample & 0xff) + alpha; + sample=((uint32_t*)data)[i]; + alpha=(uint8_t)((255 - ((sample >> 24) & 0xff))); + ((uint8_t *)data)[i * 3] = (uint8_t) ((sample >> 16) & 0xff) + alpha; + ((uint8_t *)data)[i * 3 + 1] = (uint8_t) ((sample >> 8) & 0xff) + alpha; + ((uint8_t *)data)[i * 3 + 2] = (uint8_t) (sample & 0xff) + alpha; } return (i * 3); @@ -3909,9 +3883,9 @@ t2p_sample_rgba_to_rgb(tdata_t data, uint32 samplecount) to unsigned. */ -tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t buffer, uint32 samplecount){ +tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t buffer, uint32_t samplecount){ - uint32 i=0; + uint32_t i=0; for(i=0;i<samplecount;i++){ if( (((unsigned char*)buffer)[(i*3)+1] & 0x80) !=0){ @@ -3941,9 +3915,9 @@ tsize_t t2p_write_pdf_header(T2P* t2p, TIFF* output){ char buffer[16]; int buflen=0; - buflen = snprintf(buffer, sizeof(buffer), "%%PDF-%u.%u ", - t2p->pdf_majorversion&0xff, - t2p->pdf_minorversion&0xff); + buflen = snprintf(buffer, sizeof(buffer), "%%PDF-%"PRIu16".%"PRIu16" ", + (uint16_t) (t2p->pdf_majorversion&0xff), + (uint16_t) (t2p->pdf_minorversion&0xff)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t)"\n%\342\343\317\323\n", 7); @@ -3955,13 +3929,13 @@ tsize_t t2p_write_pdf_header(T2P* t2p, TIFF* output){ This function writes the beginning of a PDF object to output. */ -tsize_t t2p_write_pdf_obj_start(uint32 number, TIFF* output){ +tsize_t t2p_write_pdf_obj_start(uint32_t number, TIFF* output){ tsize_t written=0; char buffer[32]; int buflen=0; - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, number); check_snprintf_ret((T2P*)NULL, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen ); written += t2pWriteFile(output, (tdata_t) " 0 obj\n", 7); @@ -3989,9 +3963,9 @@ tsize_t t2p_write_pdf_obj_end(TIFF* output){ tsize_t t2p_write_pdf_name(const unsigned char* name, TIFF* output){ tsize_t written=0; - uint32 i=0; + uint32_t i=0; char buffer[64]; - uint16 nextchar=0; + uint16_t nextchar=0; size_t namelen=0; namelen = strlen((char *)name); @@ -4087,7 +4061,7 @@ tsize_t t2p_write_pdf_name(const unsigned char* name, TIFF* output){ tsize_t t2p_write_pdf_string(const char* pdfstr, TIFF* output) { tsize_t written = 0; - uint32 i = 0; + uint32_t i = 0; char buffer[64]; size_t len = 0; @@ -4177,7 +4151,7 @@ tsize_t t2p_write_pdf_stream_end(TIFF* output){ This function writes a stream dictionary for a PDF stream to output. */ -tsize_t t2p_write_pdf_stream_dict(tsize_t len, uint32 number, TIFF* output){ +tsize_t t2p_write_pdf_stream_dict(tsize_t len, uint32_t number, TIFF* output){ tsize_t written=0; char buffer[32]; @@ -4187,7 +4161,7 @@ tsize_t t2p_write_pdf_stream_dict(tsize_t len, uint32 number, TIFF* output){ if(len!=0){ written += t2p_write_pdf_stream_length(len, output); } else { - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, number); check_snprintf_ret((T2P*)NULL, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); @@ -4232,7 +4206,7 @@ tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){ char buffer[32]; int buflen=0; - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)len); + buflen=snprintf(buffer, sizeof(buffer), "%"TIFF_SSIZE_FORMAT, len); check_snprintf_ret((T2P*)NULL, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n", 1); @@ -4253,7 +4227,7 @@ tsize_t t2p_write_pdf_catalog(T2P* t2p, TIFF* output) written += t2pWriteFile(output, (tdata_t)"<< \n/Type /Catalog \n/Pages ", 27); - buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_pages); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, TIFFmin((size_t)buflen, sizeof(buffer) - 1)); @@ -4442,7 +4416,7 @@ tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output) } } written += t2pWriteFile(output, (tdata_t) "] \n/Count ", 10); - buflen=snprintf(buffer, sizeof(buffer), "%d", t2p->tiff_pagecount); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, t2p->tiff_pagecount); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " \n>> \n", 6); @@ -4454,7 +4428,7 @@ tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output) This function writes a PDF Page structure to output. */ -tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ +tsize_t t2p_write_pdf_page(uint32_t object, T2P* t2p, TIFF* output){ unsigned int i=0; tsize_t written=0; @@ -4462,7 +4436,7 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ int buflen=0; written += t2pWriteFile(output, (tdata_t) "<<\n/Type /Page \n/Parent ", 24); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_pages); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); @@ -4484,7 +4458,7 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "] \n", 3); written += t2pWriteFile(output, (tdata_t) "/Contents ", 10); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(object + 1)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, object + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); @@ -4493,16 +4467,16 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); for(i=0;i<t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount;i++){ written += t2pWriteFile(output, (tdata_t) "/Im", 3); - buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu16, (uint16_t)(t2p->pdf_page+1u)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "_", 1); - buflen = snprintf(buffer, sizeof(buffer), "%u", i+1); + buflen = snprintf(buffer, sizeof(buffer), "%u", i+1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra)); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, + object+3u+(2u*i)+t2p->tiff_pages[t2p->pdf_page].page_extra); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); @@ -4514,12 +4488,12 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ } else { written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); written += t2pWriteFile(output, (tdata_t) "/Im", 3); - buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu16, (uint16_t)(t2p->pdf_page+1u)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra)); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, + object+3u+(2u*i)+t2p->tiff_pages[t2p->pdf_page].page_extra); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); @@ -4528,8 +4502,8 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ if(t2p->tiff_transferfunctioncount != 0) { written += t2pWriteFile(output, (tdata_t) "/ExtGState <<", 13); t2pWriteFile(output, (tdata_t) "/GS1 ", 5); - buflen = snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(object + 3)); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, + object + 3u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); @@ -4557,14 +4531,14 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ void t2p_compose_pdf_page(T2P* t2p){ - uint32 i=0; - uint32 i2=0; + uint32_t i=0; + uint32_t i2=0; T2P_TILE* tiles=NULL; T2P_BOX* boxp=NULL; - uint32 tilecountx=0; - uint32 tilecounty=0; - uint32 tilewidth=0; - uint32 tilelength=0; + uint32_t tilecountx=0; + uint32_t tilecounty=0; + uint32_t tilewidth=0; + uint32_t tilelength=0; int istiled=0; float f=0; float width_ratio=0; @@ -4763,7 +4737,7 @@ void t2p_compose_pdf_page(T2P* t2p){ return; } -void t2p_compose_pdf_page_orient(T2P_BOX* boxp, uint16 orientation){ +void t2p_compose_pdf_page_orient(T2P_BOX* boxp, uint16_t orientation){ float m1[9]; float f=0.0; @@ -4838,7 +4812,7 @@ void t2p_compose_pdf_page_orient(T2P_BOX* boxp, uint16 orientation){ return; } -void t2p_compose_pdf_page_orient_flip(T2P_BOX* boxp, uint16 orientation){ +void t2p_compose_pdf_page_orient_flip(T2P_BOX* boxp, uint16_t orientation){ float m1[9]; float f=0.0; @@ -4912,7 +4886,7 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ for(i=0;i<t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount; i++){ box=t2p->tiff_tiles[t2p->pdf_page].tiles_tiles[i].tile_box; buflen=snprintf(buffer, sizeof(buffer), - "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d_%ld Do Q\n", + "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%"PRIu16"_%"PRIu32" Do Q\n", t2p->tiff_transferfunctioncount?"/GS1 gs ":"", box.mat[0], box.mat[1], @@ -4920,15 +4894,15 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ box.mat[4], box.mat[6], box.mat[7], - t2p->pdf_page + 1, - (long)(i + 1)); + (uint16_t)(t2p->pdf_page + 1u), + i + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2p_write_pdf_stream(buffer, buflen, output); } } else { box=t2p->pdf_imagebox; buflen=snprintf(buffer, sizeof(buffer), - "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d Do Q\n", + "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%"PRIu16" Do Q\n", t2p->tiff_transferfunctioncount?"/GS1 gs ":"", box.mat[0], box.mat[1], @@ -4936,7 +4910,7 @@ tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ box.mat[4], box.mat[6], box.mat[7], - t2p->pdf_page+1); + (uint16_t)(t2p->pdf_page+1u)); check_snprintf_ret(t2p, buflen, buffer); written += t2p_write_pdf_stream(buffer, buflen, output); } @@ -4960,45 +4934,45 @@ tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t tile, written += t2pWriteFile(output, (tdata_t) "/Type /XObject \n/Subtype /Image \n/Name /Im", 42); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, (uint16_t)(t2p->pdf_page+1u)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); if(tile != 0){ written += t2pWriteFile(output, (tdata_t) "_", 1); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)tile); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, tile); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } written += t2pWriteFile(output, (tdata_t) "\n/Width ", 8); if(tile==0){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_width); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->tiff_width); } else { if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); } else { - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); } } check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n/Height ", 9); if(tile==0){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_length); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->tiff_length); } else { if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); } else { - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); } } check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n/BitsPerComponent ", 19); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, t2p->tiff_bitspersample); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n/ColorSpace ", 13); @@ -5053,11 +5027,11 @@ tsize_t t2p_write_pdf_xobject_cs(T2P* t2p, TIFF* output){ t2p->pdf_colorspace ^= T2P_CS_PALETTE; written += t2p_write_pdf_xobject_cs(t2p, output); t2p->pdf_colorspace |= T2P_CS_PALETTE; - buflen=snprintf(buffer, sizeof(buffer), "%u", (0x0001 << t2p->tiff_bitspersample)-1 ); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, (uint32_t)(0x1u << t2p->tiff_bitspersample)-1u ); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_palettecs ); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_palettecs ); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ]\n", 7); @@ -5116,25 +5090,25 @@ tsize_t t2p_write_pdf_transfer(T2P* t2p, TIFF* output){ written += t2pWriteFile(output, (tdata_t) "<< /Type /ExtGState \n/TR ", 25); if(t2p->tiff_transferfunctioncount == 1){ - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(t2p->pdf_xrefcount + 1)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->pdf_xrefcount + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); } else { written += t2pWriteFile(output, (tdata_t) "[ ", 2); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(t2p->pdf_xrefcount + 1)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->pdf_xrefcount + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(t2p->pdf_xrefcount + 2)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->pdf_xrefcount + 2u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)(t2p->pdf_xrefcount + 3)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->pdf_xrefcount + 3u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); @@ -5146,7 +5120,7 @@ tsize_t t2p_write_pdf_transfer(T2P* t2p, TIFF* output){ return(written); } -tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16 i){ +tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16_t i){ tsize_t written=0; char buffer[32]; @@ -5156,7 +5130,7 @@ tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16 i){ written += t2pWriteFile(output, (tdata_t) "/FunctionType 0 \n", 17); written += t2pWriteFile(output, (tdata_t) "/Domain [0.0 1.0] \n", 19); written += t2pWriteFile(output, (tdata_t) "/Range [0.0 1.0] \n", 18); - buflen=snprintf(buffer, sizeof(buffer), "/Size [%u] \n", (1<<t2p->tiff_bitspersample)); + buflen=snprintf(buffer, sizeof(buffer), "/Size [%"PRIu16"] \n", (uint16_t)(1u<<t2p->tiff_bitspersample)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "/BitsPerSample 16 \n", 19); @@ -5165,7 +5139,7 @@ tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16 i){ return(written); } -tsize_t t2p_write_pdf_transfer_stream(T2P* t2p, TIFF* output, uint16 i){ +tsize_t t2p_write_pdf_transfer_stream(T2P* t2p, TIFF* output, uint16_t i){ tsize_t written=0; @@ -5283,7 +5257,7 @@ tsize_t t2p_write_pdf_xobject_icccs(T2P* t2p, TIFF* output){ int buflen=0; written += t2pWriteFile(output, (tdata_t) "[/ICCBased ", 11); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_icccs); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_icccs); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R] \n", 7); @@ -5298,7 +5272,7 @@ tsize_t t2p_write_pdf_xobject_icccs_dict(T2P* t2p, TIFF* output){ int buflen=0; written += t2pWriteFile(output, (tdata_t) "/N ", 3); - buflen=snprintf(buffer, sizeof(buffer), "%u \n", t2p->tiff_samplesperpixel); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16" \n", t2p->tiff_samplesperpixel); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "/Alternate ", 11); @@ -5379,39 +5353,39 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output written += t2pWriteFile(output, (tdata_t) "<< /K -1 ", 9); if(tile==0){ written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_width); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_width); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_length); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_length); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } else { written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); } @@ -5438,20 +5412,20 @@ tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output if(t2p->pdf_compressionquality%100){ written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); written += t2pWriteFile(output, (tdata_t) "<< /Predictor ", 14); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_compressionquality%100); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, (uint16_t)(t2p->pdf_compressionquality % 100u)); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " /Columns ", 10); - buflen = snprintf(buffer, sizeof(buffer), "%lu", - (unsigned long)t2p->tiff_width); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, + t2p->tiff_width); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " /Colors ", 9); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_samplesperpixel); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, t2p->tiff_samplesperpixel); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " /BitsPerComponent ", 19); - buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu16, t2p->tiff_bitspersample); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) ">>\n", 3); @@ -5474,10 +5448,10 @@ tsize_t t2p_write_pdf_xreftable(T2P* t2p, TIFF* output){ tsize_t written=0; char buffer[64]; int buflen=0; - uint32 i=0; + uint32_t i=0; written += t2pWriteFile(output, (tdata_t) "xref\n0 ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount + 1)); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_xrefcount + 1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " \n0000000000 65535 f \n", 22); @@ -5506,15 +5480,15 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand()); written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17); - buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount+1)); + buflen = snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_xrefcount+1u); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n/Root ", 7); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_catalog); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_catalog); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n/Info ", 12); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_info); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_info); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11); @@ -5524,7 +5498,7 @@ tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, sizeof(t2p->pdf_fileid) - 1); written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16); - buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_startxref); + buflen=snprintf(buffer, sizeof(buffer), "%"PRIu32, t2p->pdf_startxref); check_snprintf_ret(t2p, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n%%EOF\n", 7); @@ -5577,16 +5551,16 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){ tsize_t written=0; ttile_t i2=0; tsize_t streamlen=0; - uint16 i=0; + uint16_t i=0; t2p_read_tiff_init(t2p, input); if(t2p->t2p_error!=T2P_ERR_OK){return(0);} - t2p->pdf_xrefoffsets= (uint32*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,t2p->pdf_xrefcount,sizeof(uint32)) ); + t2p->pdf_xrefoffsets= (uint32_t*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t, t2p->pdf_xrefcount, sizeof(uint32_t)) ); if(t2p->pdf_xrefoffsets==NULL){ TIFFError( TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for t2p_write_pdf", - (unsigned int) (t2p->pdf_xrefcount * sizeof(uint32)) ); + "Can't allocate %"TIFF_SIZE_FORMAT" bytes of memory for t2p_write_pdf", + sizeof(uint32_t) * t2p->pdf_xrefcount); t2p->t2p_error = T2P_ERR_ERROR; return(written); } @@ -5694,8 +5668,8 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){ t2p_read_tiff_size_tile(t2p, input, i2); if (t2p->tiff_maxdatasize && (t2p->tiff_datasize > t2p->tiff_maxdatasize)) { TIFFError(TIFF2PDF_MODULE, - "Allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ". Use -m option to change limit", - (uint64)t2p->tiff_datasize, (uint64)t2p->tiff_maxdatasize); + "Allocation of %" PRIu64 " bytes is forbidden. Limit is %" PRIu64 ". Use -m option to change limit", + (uint64_t)t2p->tiff_datasize, (uint64_t)t2p->tiff_maxdatasize); t2p->t2p_error = T2P_ERR_ERROR; return (0); } @@ -5724,8 +5698,8 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){ t2p_read_tiff_size(t2p, input); if (t2p->tiff_maxdatasize && (t2p->tiff_datasize > t2p->tiff_maxdatasize)) { TIFFError(TIFF2PDF_MODULE, - "Allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ". Use -m option to change limit", - (uint64)t2p->tiff_datasize, (uint64)t2p->tiff_maxdatasize); + "Allocation of %" PRIu64 " bytes is forbidden. Limit is %" PRIu64 ". Use -m option to change limit", + (uint64_t)t2p->tiff_datasize, (uint64_t)t2p->tiff_maxdatasize); t2p->t2p_error = T2P_ERR_ERROR; return (0); } diff --git a/tiff/tools/tiff2ps.c b/tiff/tools/tiff2ps.c index 4ed5eba2..a598ede7 100644 --- a/tiff/tools/tiff2ps.c +++ b/tiff/tools/tiff2ps.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> /* for atof */ @@ -34,10 +35,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" #ifndef EXIT_SUCCESS @@ -64,7 +61,7 @@ * warning messages for incompatible command line options. * Add new command line options to specify PageOrientation * Document Structuring Comment for landscape or portrait - * and code to determine the values from ouput width and height + * and code to determine the values from output width and height * if not specified on the command line. * Add new command line option to specify document creator * as an alterntive to the string "tiff2ps" following model @@ -85,7 +82,7 @@ * * Identified incompatible options and returned errors, eg * -i for imagemask operator is only available for Level2 or - * Level3 Postscript in the current implmentation since there + * Level3 Postscript in the current implementation since there * is a difference in the way the operands are called for Level1 * and there is no function to provide the Level1 version. * -H was not handled properly if -h and/or -w were specified. @@ -96,7 +93,7 @@ * Conversion of TIFF to Postscript with optional rotations * of 90, 180, 270, or auto degrees counterclockwise * Conversion of TIFF to Postscript with entire image scaled - * to maximum of values spedified with -h or -w while + * to maximum of values specified with -h or -w while * maintaining aspect ratio. Same rotations apply. * Conversion of TIFF to Postscript with clipping of output * viewport to height specified with -H, producing multiple @@ -173,9 +170,6 @@ #define EXP_ASCII85ENCODER -/* - * NB: this code assumes uint32 works with printf's %l[ud]. - */ #ifndef TRUE #define TRUE 1 #define FALSE 0 @@ -206,7 +200,7 @@ char *title = NULL; /* optional document title string */ char *creator = NULL; /* optional document creator string */ char pageOrientation[12]; /* set optional PageOrientation DSC to Landscape or Portrait */ int useImagemask = FALSE; /* Use imagemask instead of image operator */ -uint16 res_unit = 0; /* Resolution units: 2 - inches, 3 - cm */ +uint16_t res_unit = 0; /* Resolution units: 2 - inches, 3 - cm */ /* * ASCII85 Encoding Support. @@ -216,14 +210,14 @@ int ascii85count; int ascii85breaklen; int TIFF2PS(FILE*, TIFF*, double, double, double, double, int); -void PSpage(FILE*, TIFF*, uint32, uint32); -void PSColorContigPreamble(FILE*, uint32, uint32, int); -void PSColorSeparatePreamble(FILE*, uint32, uint32, int); -void PSDataColorContig(FILE*, TIFF*, uint32, uint32, int); -void PSDataColorSeparate(FILE*, TIFF*, uint32, uint32, int); -void PSDataPalette(FILE*, TIFF*, uint32, uint32); -void PSDataBW(FILE*, TIFF*, uint32, uint32); -void PSRawDataBW(FILE*, TIFF*, uint32, uint32); +void PSpage(FILE*, TIFF*, uint32_t, uint32_t); +void PSColorContigPreamble(FILE*, uint32_t, uint32_t, int); +void PSColorSeparatePreamble(FILE*, uint32_t, uint32_t, int); +void PSDataColorContig(FILE*, TIFF*, uint32_t, uint32_t, int); +void PSDataColorSeparate(FILE*, TIFF*, uint32_t, uint32_t, int); +void PSDataPalette(FILE*, TIFF*, uint32_t, uint32_t); +void PSDataBW(FILE*, TIFF*, uint32_t, uint32_t); +void PSRawDataBW(FILE*, TIFF*, uint32_t, uint32_t); void Ascii85Init(void); void Ascii85Put(unsigned char code, FILE* fd); void Ascii85Flush(FILE* fd); @@ -242,7 +236,7 @@ int exportMaskedImage(FILE *, double, double, double, double, int, int, double, double, double, int, int); #if defined( EXP_ASCII85ENCODER) -tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, tsize_t raw_l ); +tsize_t Ascii85EncodeBlock(uint8_t * ascii85_p, unsigned f_eod, const uint8_t * raw_p, tsize_t raw_l ); #endif static void usage(int); @@ -253,8 +247,8 @@ static void usage(int); static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ".\n", - (uint64)s, (uint64)maxMalloc); + fprintf(stderr, "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", + s, maxMalloc); fprintf(stderr, " use -M option to change limit.\n"); return NULL; } @@ -270,7 +264,7 @@ main(int argc, char* argv[]) double leftmargin = 0; double pageWidth = 0; double pageHeight = 0; - uint32 diroff = 0; + uint32_t diroff = 0; #if !HAVE_DECL_OPTARG extern char *optarg; extern int optind; @@ -336,7 +330,7 @@ main(int argc, char* argv[]) case '6': case '7': case '8': - case '9': diroff = (uint32) strtoul(optarg, NULL, 0); + case '9': diroff = (uint32_t) strtoul(optarg, NULL, 0); break; default: TIFFError ("-o", "Offset must be a numeric value."); exit (EXIT_FAILURE); @@ -438,7 +432,7 @@ main(int argc, char* argv[]) { if ((level2 == FALSE) && (level3 == FALSE)) { - TIFFError ("-m "," imagemask operator requres Postscript Level2 or Level3"); + TIFFError ("-m "," imagemask operator requires Postscript Level2 or Level3"); exit (EXIT_FAILURE); } } @@ -522,12 +516,12 @@ main(int argc, char* argv[]) return (EXIT_SUCCESS); } -static uint16 samplesperpixel; -static uint16 bitspersample; -static uint16 planarconfiguration; -static uint16 photometric; -static uint16 compression; -static uint16 extrasamples; +static uint16_t samplesperpixel; +static uint16_t bitspersample; +static uint16_t planarconfiguration; +static uint16_t photometric; +static uint16_t compression; +static uint16_t extrasamples; static int alpha; static int @@ -552,7 +546,7 @@ checkImage(TIFF* tif) case PHOTOMETRIC_RGB: if (alpha && bitspersample != 8) { TIFFError(filename, - "Can not handle %d-bit/sample RGB image with alpha", + "Can not handle %"PRIu16"-bit/sample RGB image with alpha", bitspersample); return (0); } @@ -583,7 +577,7 @@ checkImage(TIFF* tif) /* fall through... */ default: TIFFError(filename, - "Can not handle image with PhotometricInterpretation=%d", + "Can not handle image with PhotometricInterpretation=%"PRIu16, photometric); return (0); } @@ -593,7 +587,7 @@ checkImage(TIFF* tif) case 16: break; default: - TIFFError(filename, "Can not handle %d-bit/sample image", + TIFFError(filename, "Can not handle %"PRIu16"-bit/sample image", bitspersample); return (0); } @@ -605,7 +599,7 @@ checkImage(TIFF* tif) #define PS_UNIT_SIZE 72.0F #define PSUNITS(npix,res) ((npix) * (PS_UNIT_SIZE / (res))) -static char RGBcolorimage[] = "\ +static const char RGBcolorimage[] = "\ /bwproc {\n\ rgbproc\n\ dup length 3 idiv string 0 3 0\n\ @@ -635,10 +629,10 @@ static char RGBcolorimage[] = "\ * It is claimed to be part of some future revision of the EPS spec. */ static void -PhotoshopBanner(FILE* fd, uint32 w, uint32 h, int bs, int nc, char* startline) +PhotoshopBanner(FILE* fd, uint32_t w, uint32_t h, int bs, int nc, const char* startline) { - fprintf(fd, "%%ImageData: %ld %ld %d %d 0 %d 2 \"", - (long) w, (long) h, bitspersample, nc, bs); + fprintf(fd, "%%ImageData: %"PRIu32" %"PRIu32" %"PRIu16" %d 0 %d 2 \"", + w, h, bitspersample, nc, bs); fprintf(fd, startline, nc); fprintf(fd, "\"\n"); } @@ -651,7 +645,7 @@ PhotoshopBanner(FILE* fd, uint32 w, uint32 h, int bs, int nc, char* startline) * pprh : image height in PS units (72 dpi) */ static void -setupPageState(TIFF* tif, uint32* pw, uint32* ph, double* pprw, double* pprh) +setupPageState(TIFF* tif, uint32_t* pw, uint32_t* ph, double* pprw, double* pprh) { float xres = 0.0F, yres = 0.0F; @@ -702,7 +696,7 @@ setupPageState(TIFF* tif, uint32* pw, uint32* ph, double* pprw, double* pprh) static int isCCITTCompression(TIFF* tif) { - uint16 compress; + uint16_t compress; TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); return (compress == COMPRESSION_CCITTFAX3 || compress == COMPRESSION_CCITTFAX4 || @@ -712,8 +706,8 @@ isCCITTCompression(TIFF* tif) static tsize_t tf_bytesperrow; static tsize_t ps_bytesperrow; -static uint32 tf_rowsperstrip; -static uint32 tf_numberstrips; +static uint32_t tf_rowsperstrip; +static uint32_t tf_numberstrips; static char *hex = "0123456789abcdef"; /* @@ -1130,7 +1124,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)new_width, (int32_t)new_height); fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", new_width, new_height); } @@ -1142,7 +1136,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (pswidth > psheight) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)pswidth, (long)psheight); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)pswidth, (int32_t)psheight); fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", pswidth, psheight); } @@ -1152,7 +1146,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)reqwidth, (int32_t)reqheight); fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", reqwidth, reqheight); } @@ -1174,7 +1168,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)new_width, (int32_t)new_height); fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", new_width, new_height); } @@ -1186,7 +1180,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (psheight > pswidth) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)psheight, (long)pswidth); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)psheight, (int32_t)pswidth); fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", psheight, pswidth); } @@ -1196,7 +1190,7 @@ int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait"); - fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %"PRId32" %"PRId32"\n", (int32_t)reqwidth, (int32_t)reqheight); fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", reqwidth, reqheight); } @@ -1312,19 +1306,19 @@ int psStart(FILE *fd, int npages, int auto_rotate, int *rotation, double *scale, if (((maxsource == pswidth) && (maxtarget != reqwidth)) || ((maxsource == psheight) && (maxtarget != reqheight))) - { /* optimal orientaion does not match input orientation */ + { /* optimal orientation does not match input orientation */ *rotation = 90; xscale = (reqwidth - left_offset)/psheight; yscale = (reqheight - bottom_offset)/pswidth; } - else /* optimal orientaion matches input orientation */ + else /* optimal orientation matches input orientation */ { xscale = (reqwidth - left_offset)/pswidth; yscale = (reqheight - bottom_offset)/psheight; } *scale = (xscale < yscale) ? xscale : yscale; - /* Do not scale image beyound original size */ + /* Do not scale image beyond original size */ if (*scale > 1.0) *scale = 1.0; @@ -1515,15 +1509,15 @@ int get_viewport (double pgwidth, double pgheight, double pswidth, double psheig int TIFF2PS(FILE* fd, TIFF* tif, double pgwidth, double pgheight, double lm, double bm, int center) { - uint32 pixwidth = 0, pixheight = 0; /* Image width and height in pixels */ + uint32_t pixwidth = 0, pixheight = 0; /* Image width and height in pixels */ double ox = 0.0, oy = 0.0; /* Offset from current Postscript origin */ double pswidth, psheight; /* Original raw image width and height in points */ double view_width, view_height; /* Viewport width and height in points */ double scale = 1.0; double left_offset = lm * PS_UNIT_SIZE; double bottom_offset = bm * PS_UNIT_SIZE; - uint32 subfiletype; - uint16* sampleinfo; + uint32_t subfiletype; + uint16_t* sampleinfo; static int npages = 0; if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox)) @@ -1594,7 +1588,7 @@ int TIFF2PS(FILE* fd, TIFF* tif, double pgwidth, double pgheight, double lm, dou { if (pgwidth != 0 || pgheight != 0) { - /* User did not specify a maxium page height or width using -H or -W flag + /* User did not specify a maximum page height or width using -H or -W flag * but did use -h or -w flag to scale to a specific size page. */ npages++; @@ -1653,7 +1647,7 @@ int TIFF2PS(FILE* fd, TIFF* tif, double pgwidth, double pgheight, double lm, dou return(npages); } -static char DuplexPreamble[] = "\ +static const char DuplexPreamble[] = "\ %%BeginFeature: *Duplex True\n\ systemdict begin\n\ /languagelevel where { pop languagelevel } { 1 } ifelse\n\ @@ -1664,7 +1658,7 @@ end\n\ %%EndFeature\n\ "; -static char TumblePreamble[] = "\ +static const char TumblePreamble[] = "\ %%BeginFeature: *Tumble True\n\ systemdict begin\n\ /languagelevel where { pop languagelevel } { 1 } ifelse\n\ @@ -1675,7 +1669,7 @@ end\n\ %%EndFeature\n\ "; -static char AvoidDeadZonePreamble[] = "\ +static const char AvoidDeadZonePreamble[] = "\ gsave newpath clippath pathbbox grestore\n\ 4 2 roll 2 copy translate\n\ exch 3 1 roll sub 3 1 roll sub exch\n\ @@ -1699,9 +1693,9 @@ PSHead(FILE *fd, double pagewidth, double pageheight, double xoff, double yoff) /* NB: should use PageBoundingBox for each page instead of BoundingBox * * PageBoundingBox DSC added in PSPageSize function, R Nolde 09-01-2010 */ - fprintf(fd, "%%%%Origin: %ld %ld\n", (long) xoff, (long) yoff); - fprintf(fd, "%%%%BoundingBox: 0 0 %ld %ld\n", - (long) ceil(pagewidth), (long) ceil(pageheight)); + fprintf(fd, "%%%%Origin: %"PRId32" %"PRId32"\n", (int32_t) xoff, (int32_t) yoff); + fprintf(fd, "%%%%BoundingBox: 0 0 %"PRId32" %"PRId32"\n", + (int32_t) ceil(pagewidth), (int32_t) ceil(pageheight)); fprintf(fd, "%%%%LanguageLevel: %d\n", (level3 ? 3 : (level2 ? 2 : 1))); if (generateEPSF == TRUE) @@ -1732,7 +1726,7 @@ PSTail(FILE *fd, int npages) } static int -checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) +checkcmap(TIFF* tif, int n, uint16_t* r, uint16_t* g, uint16_t* b) { (void) tif; while (n-- > 0) @@ -1745,7 +1739,7 @@ checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) static void PS_Lvl2colorspace(FILE* fd, TIFF* tif) { - uint16 *rmap, *gmap, *bmap; + uint16_t *rmap, *gmap, *bmap; int i, num_colors; const char * colorspace_p; @@ -1765,7 +1759,7 @@ PS_Lvl2colorspace(FILE* fd, TIFF* tif) /* * Set up PostScript Level 2 colorspace according to - * section 4.8 in the PostScript refenence manual. + * section 4.8 in the PostScript reference manual. */ fputs("% PostScript Level 2 only.\n", fd); if (photometric != PHOTOMETRIC_PALETTE) { @@ -1811,7 +1805,7 @@ PS_Lvl2colorspace(FILE* fd, TIFF* tif) Ascii85Put((unsigned char)bmap[i], fd); } else { fputs((i % 8) ? " " : "\n ", fd); - fprintf(fd, "%02x%02x%02x", + fprintf(fd, "%02"PRIx16"%02"PRIx16"%02"PRIx16"", rmap[i], gmap[i], bmap[i]); } } @@ -1823,21 +1817,21 @@ PS_Lvl2colorspace(FILE* fd, TIFF* tif) } static int -PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) +PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) { int use_rawdata; - uint32 tile_width, tile_height; - uint16 predictor, minsamplevalue, maxsamplevalue; - uint32 repeat_count; + uint32_t tile_width, tile_height; + uint16_t predictor, minsamplevalue, maxsamplevalue; + uint32_t repeat_count; char im_h[64], im_x[64], im_y[64]; - char * imageOp = "image"; + const char * imageOp = "image"; if ( useImagemask && (bitspersample == 1) ) imageOp = "imagemask"; (void)strcpy(im_x, "0"); - (void)snprintf(im_y, sizeof(im_y), "%lu", (long) h); - (void)snprintf(im_h, sizeof(im_h), "%lu", (long) h); + (void)snprintf(im_y, sizeof(im_y), "%"PRIu32, h); + (void)snprintf(im_h, sizeof(im_h), "%"PRIu32, h); tile_width = w; tile_height = h; if (TIFFIsTiled(tif)) { @@ -1858,7 +1852,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) } if (tile_height < h) { fputs("/im_y 0 def\n", fd); - (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h); + (void)snprintf(im_y, sizeof(im_y), "%"PRIu32" im_y sub", h); } } else { repeat_count = tf_numberstrips; @@ -1867,10 +1861,9 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) tile_height = h; if (repeat_count > 1) { fputs("/im_y 0 def\n", fd); - fprintf(fd, "/im_h %lu def\n", - (unsigned long) tile_height); + fprintf(fd, "/im_h %"PRIu32" def\n", tile_height); (void)strcpy(im_h, "im_h"); - (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h); + (void)snprintf(im_y, sizeof(im_y), "%"PRIu32" im_y sub", h); } } @@ -1880,7 +1873,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) fputs("{ % exec\n", fd); if (repeat_count > 1) - fprintf(fd, "%u { %% repeat\n", repeat_count); + fprintf(fd, "%"PRIu32" { %% repeat\n", repeat_count); /* * Output filter options and image dictionary. @@ -1890,7 +1883,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) fd); fputs(" <<\n", fd); fputs(" /ImageType 1\n", fd); - fprintf(fd, " /Width %lu\n", (unsigned long) tile_width); + fprintf(fd, " /Width %"PRIu32"\n", tile_width); /* * Workaround for some software that may crash when last strip * of image contains fewer number of scanlines than specified @@ -1902,15 +1895,15 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) * one-stripped image). */ if (TIFFIsTiled(tif) || tf_numberstrips == 1) - fprintf(fd, " /Height %lu\n", (unsigned long) tile_height); + fprintf(fd, " /Height %"PRIu32"\n", tile_height); else fprintf(fd, " /Height im_h\n"); if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) fputs(" /MultipleDataSources true\n", fd); - fprintf(fd, " /ImageMatrix [ %lu 0 0 %ld %s %s ]\n", - (unsigned long) w, - (long)h, im_x, im_y); - fprintf(fd, " /BitsPerComponent %d\n", bitspersample); + fprintf(fd, " /ImageMatrix [ %"PRIu32" 0 0 %"PRId32" %s %s ]\n", + w, - (int32_t)h, im_x, im_y); + fprintf(fd, " /BitsPerComponent %"PRIu16"\n", bitspersample); fprintf(fd, " /Interpolate %s\n", interpolate ? "true" : "false"); switch (samplesperpixel - extrasamples) { @@ -1927,7 +1920,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) case COMPRESSION_CCITTFAX4: /* * Manage inverting with /Blackis1 flag - * since there migth be uncompressed parts + * since there might be uncompressed parts */ fputs(" /Decode [0 1]\n", fd); break; @@ -1944,7 +1937,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) &minsamplevalue); TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE, &maxsamplevalue); - fprintf(fd, " /Decode [%u %u]\n", + fprintf(fd, " /Decode [%"PRIu16" %"PRIu16"]\n", minsamplevalue, maxsamplevalue); break; default: @@ -1996,7 +1989,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) case COMPRESSION_CCITTFAX4: /* 4: CCITT Group 4 fax encoding */ fputs("\n\t<<\n", fd); if (compression == COMPRESSION_CCITTFAX3) { - uint32 g3_options; + uint32_t g3_options; fputs("\t /EndOfLine true\n", fd); fputs("\t /EndOfBlock false\n", fd); @@ -2011,7 +2004,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) fputs("\t /EncodedByteAlign true\n", fd); } if (compression == COMPRESSION_CCITTFAX4) { - uint32 g4_options; + uint32_t g4_options; fputs("\t /K -1\n", fd); TIFFGetFieldDefaulted(tif, TIFFTAG_GROUP4OPTIONS, @@ -2020,8 +2013,8 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) fputs("\t /Uncompressed true\n", fd); } if (!(tile_width == w && w == 1728U)) - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); + fprintf(fd, "\t /Columns %"PRIu32"\n", + tile_width); fprintf(fd, "\t /Rows %s\n", im_h); if (compression == COMPRESSION_CCITTRLE || compression == COMPRESSION_CCITTRLEW) { @@ -2036,11 +2029,11 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); if (predictor == 2) { fputs("\n\t<<\n", fd); - fprintf(fd, "\t /Predictor %u\n", predictor); - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); - fprintf(fd, "\t /Colors %u\n", samplesperpixel); - fprintf(fd, "\t /BitsPerComponent %u\n", + fprintf(fd, "\t /Predictor %"PRIu16"\n", predictor); + fprintf(fd, "\t /Columns %"PRIu32"\n", + tile_width); + fprintf(fd, "\t /Colors %"PRIu16"\n", samplesperpixel); + fprintf(fd, "\t /BitsPerComponent %"PRIu16"\n", bitspersample); fputs("\t>>", fd); } @@ -2053,11 +2046,11 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) if (predictor > 1) { fprintf(fd, "\t %% PostScript Level 3 only."); fputs("\n\t<<\n", fd); - fprintf(fd, "\t /Predictor %u\n", predictor); - fprintf(fd, "\t /Columns %lu\n", - (unsigned long) tile_width); - fprintf(fd, "\t /Colors %u\n", samplesperpixel); - fprintf(fd, "\t /BitsPerComponent %u\n", + fprintf(fd, "\t /Predictor %"PRIu16"\n", predictor); + fprintf(fd, "\t /Columns %"PRIu32"\n", + tile_width); + fprintf(fd, "\t /Colors %"PRIu16"\n", samplesperpixel); + fprintf(fd, "\t /BitsPerComponent %"PRIu16"\n", bitspersample); fputs("\t>>", fd); } @@ -2101,7 +2094,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) } if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) { - uint16 i; + uint16_t i; /* * NOTE: This code does not work yet... @@ -2116,28 +2109,28 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) fputs(" im_stream status { im_stream flushfile } if\n", fd); if (repeat_count > 1) { if (tile_width < w) { - fprintf(fd, " /im_x im_x %lu add def\n", - (unsigned long) tile_width); + fprintf(fd, " /im_x im_x %"PRIu32" add def\n", + tile_width); if (tile_height < h) { - fprintf(fd, " im_x %lu ge {\n", - (unsigned long) w); + fprintf(fd, " im_x %"PRIu32" ge {\n", + w); fputs(" /im_x 0 def\n", fd); - fprintf(fd, " /im_y im_y %lu add def\n", - (unsigned long) tile_height); + fprintf(fd, " /im_y im_y %"PRIu32" add def\n", + tile_height); fputs(" } if\n", fd); } } if (tile_height < h) { if (tile_width >= w) { - fprintf(fd, " /im_y im_y %lu add def\n", - (unsigned long) tile_height); + fprintf(fd, " /im_y im_y %"PRIu32" add def\n", + tile_height); if (!TIFFIsTiled(tif)) { - fprintf(fd, " /im_h %lu im_y sub", - (unsigned long) h); - fprintf(fd, " dup %lu gt { pop", - (unsigned long) tile_height); - fprintf(fd, " %lu } if def\n", - (unsigned long) tile_height); + fprintf(fd, " /im_h %"PRIu32" im_y sub", + h); + fprintf(fd, " dup %"PRIu32" gt { pop", + tile_height); + fprintf(fd, " %"PRIu32" } if def\n", + tile_height); } } } @@ -2174,18 +2167,18 @@ PS_FlipBytes(unsigned char* buf, tsize_t count) #define MAXLINE 36 int -PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h) +PS_Lvl2page(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) { - uint16 fillorder; + uint16_t fillorder; int use_rawdata, tiled_image, breaklen = MAXLINE; - uint32 chunk_no, num_chunks; - uint64 *bc; + uint32_t chunk_no, num_chunks; + uint64_t *bc; unsigned char *buf_data, *cp; tsize_t chunk_size, byte_count; #if defined( EXP_ASCII85ENCODER ) tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */ + uint8_t * ascii85_p = 0; /* Holds ASCII85 encoded data */ #endif PS_Lvl2colorspace(fd, tif); @@ -2219,8 +2212,8 @@ PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h) } buf_data = (unsigned char *)limitMalloc(chunk_size); if (!buf_data) { - TIFFError(filename, "Can't alloc %lu bytes for %s.", - (unsigned long) chunk_size, tiled_image ? "tiles" : "strips"); + TIFFError(filename, "Can't alloc %"TIFF_SSIZE_FORMAT" bytes for %s.", + chunk_size, tiled_image ? "tiles" : "strips"); return(FALSE); } @@ -2272,7 +2265,7 @@ PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h) chunk_size); } if (byte_count < 0) { - TIFFError(filename, "Can't read %s %d.", + TIFFError(filename, "Can't read %s %"PRIu32".", tiled_image ? "tile" : "strip", chunk_no); if (ascii85) Ascii85Put('\0', fd); @@ -2363,7 +2356,7 @@ PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h) } void -PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h) +PSpage(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) { char * imageOp = "image"; @@ -2397,12 +2390,12 @@ PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h) case PHOTOMETRIC_PALETTE: fprintf(fd, "%s", RGBcolorimage); PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); - fprintf(fd, "/scanLine %ld string def\n", - (long) ps_bytesperrow * 3L); - fprintf(fd, "%lu %lu 8\n", - (unsigned long) w, (unsigned long) h); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "/scanLine %"TIFF_SSIZE_FORMAT" string def\n", + ps_bytesperrow * 3); + fprintf(fd, "%"PRIu32" %"PRIu32" 8\n", + w, h); + fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", + w, h, h); fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); fprintf(fd, "false 3 colorimage\n"); PSDataPalette(fd, tif, w, h); @@ -2410,12 +2403,12 @@ PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h) case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_MINISWHITE: PhotoshopBanner(fd, w, h, 1, 1, imageOp); - fprintf(fd, "/scanLine %ld string def\n", - (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "/scanLine %"TIFF_SSIZE_FORMAT" string def\n", + ps_bytesperrow); + fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", + w, h, bitspersample); + fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", + w, h, h); fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); fprintf(fd, "%s\n", imageOp); @@ -2426,32 +2419,32 @@ PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h) } void -PSColorContigPreamble(FILE* fd, uint32 w, uint32 h, int nc) +PSColorContigPreamble(FILE* fd, uint32_t w, uint32_t h, int nc) { ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); - fprintf(fd, "/line %ld string def\n", (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "/line %"TIFF_SSIZE_FORMAT" string def\n", ps_bytesperrow); + fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", + w, h, bitspersample); + fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", + w, h, h); fprintf(fd, "{currentfile line readhexstring pop} bind\n"); fprintf(fd, "false %d colorimage\n", nc); } void -PSColorSeparatePreamble(FILE* fd, uint32 w, uint32 h, int nc) +PSColorSeparatePreamble(FILE* fd, uint32_t w, uint32_t h, int nc) { int i; PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); for (i = 0; i < nc; i++) - fprintf(fd, "/line%d %ld string def\n", - i, (long) ps_bytesperrow); - fprintf(fd, "%lu %lu %d\n", - (unsigned long) w, (unsigned long) h, bitspersample); - fprintf(fd, "[%lu 0 0 -%lu 0 %lu] \n", - (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "/line%d %"TIFF_SSIZE_FORMAT" string def\n", + i, ps_bytesperrow); + fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", + w, h, bitspersample); + fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"] \n", + w, h, h); for (i = 0; i < nc; i++) fprintf(fd, "{currentfile line%d readhexstring pop}bind\n", i); fprintf(fd, "true %d colorimage\n", nc); @@ -2462,12 +2455,18 @@ PSColorSeparatePreamble(FILE* fd, uint32 w, uint32 h, int nc) putc('\n', fd); \ (len) = MAXLINE-(howmany); \ } -#define PUTHEX(c,fd) putc(hex[((c)>>4)&0xf],fd); putc(hex[(c)&0xf],fd) + +static inline void +puthex(unsigned int c, FILE *fd) +{ + putc(hex[((c)>>4)&0xf],fd); + putc(hex[(c)&0xf],fd); +} void -PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) +PSDataColorContig(FILE* fd, TIFF* tif, uint32_t w, uint32_t h, int nc) { - uint32 row; + uint32_t row; int breaklen = MAXLINE, es = samplesperpixel - nc; tsize_t cc; unsigned char *tf_buf; @@ -2476,7 +2475,7 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) (void) w; if( es < 0 ) { - TIFFError(filename, "Inconsistent value of es: %d (samplesperpixel=%u, nc=%d)", es, samplesperpixel, nc); + TIFFError(filename, "Inconsistent value of es: %d (samplesperpixel=%"PRIu16", nc=%d)", es, samplesperpixel, nc); return; } tf_buf = (unsigned char *) limitMalloc(tf_bytesperrow); @@ -2509,12 +2508,11 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) * where Cback = 1. */ adjust = 255 - cp[nc]; - switch (nc) { - case 4: c = *cp++ + adjust; PUTHEX(c,fd); - case 3: c = *cp++ + adjust; PUTHEX(c,fd); - case 2: c = *cp++ + adjust; PUTHEX(c,fd); - case 1: c = *cp++ + adjust; PUTHEX(c,fd); - } + for (int i = 0; i < nc; ++i) + { + c = *cp++ + adjust; + puthex(c,fd); + } cp += es; } } else { @@ -2523,12 +2521,11 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) */ for (cc = 0; (cc + nc) <= tf_bytesperrow; cc += samplesperpixel) { DOBREAK(breaklen, nc, fd); - switch (nc) { - case 4: c = *cp++; PUTHEX(c,fd); - case 3: c = *cp++; PUTHEX(c,fd); - case 2: c = *cp++; PUTHEX(c,fd); - case 1: c = *cp++; PUTHEX(c,fd); - } + for (int i = 0; i < nc; ++i) + { + c = *cp++; + puthex(c,fd); + } cp += es; } } @@ -2537,9 +2534,9 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) } void -PSDataColorSeparate(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) +PSDataColorSeparate(FILE* fd, TIFF* tif, uint32_t w, uint32_t h, int nc) { - uint32 row; + uint32_t row; int breaklen = MAXLINE; tsize_t cc; tsample_t s, maxs; @@ -2556,25 +2553,26 @@ PSDataColorSeparate(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) for (row = 0; row < h; row++) { for (s = 0; s < maxs; s++) { if (TIFFReadScanline(tif, tf_buf, row, s) < 0) - break; + goto end_loop; for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { DOBREAK(breaklen, 1, fd); c = *cp++; - PUTHEX(c,fd); + puthex(c,fd); } } } +end_loop: _TIFFfree((char *) tf_buf); } #define PUTRGBHEX(c,fd) \ - PUTHEX(rmap[c],fd); PUTHEX(gmap[c],fd); PUTHEX(bmap[c],fd) + puthex(rmap[c],fd); puthex(gmap[c],fd); puthex(bmap[c],fd) void -PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h) +PSDataPalette(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) { - uint16 *rmap, *gmap, *bmap; - uint32 row; + uint16_t *rmap, *gmap, *bmap; + uint32_t row; int breaklen = MAXLINE, nc; tsize_t cc; unsigned char *tf_buf; @@ -2589,7 +2587,7 @@ PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h) case 8: case 4: case 2: case 1: break; default: - TIFFError(filename, "Depth %d not supported", bitspersample); + TIFFError(filename, "Depth %"PRIu16" not supported", bitspersample); return; } nc = 3 * (8 / bitspersample); @@ -2610,7 +2608,7 @@ PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h) } for (row = 0; row < h; row++) { if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) - break; + goto end_loop; for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { DOBREAK(breaklen, nc, fd); switch (bitspersample) { @@ -2640,11 +2638,12 @@ PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h) } } } +end_loop: _TIFFfree((char *) tf_buf); } void -PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) +PSDataBW(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) { int breaklen = MAXLINE; unsigned char* tf_buf; @@ -2654,7 +2653,7 @@ PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) #if defined( EXP_ASCII85ENCODER ) tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8 *ascii85_p = 0; /* Holds ASCII85 encoded data */ + uint8_t *ascii85_p = 0; /* Holds ASCII85 encoded data */ #endif (void) w; (void) h; @@ -2744,14 +2743,14 @@ PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) * where Cback = 1. */ adjust = 255 - cp[1]; - c = *cp++ + adjust; PUTHEX(c,fd); + c = *cp++ + adjust; puthex(c,fd); cp++, cc--; } } else { while (cc-- > 0) { c = *cp++; DOBREAK(breaklen, 1, fd); - PUTHEX(c, fd); + puthex(c, fd); } } } @@ -2774,20 +2773,20 @@ PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) } void -PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) +PSRawDataBW(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) { - uint64 *bc; - uint32 bufsize; + uint64_t *bc; + uint32_t bufsize; int breaklen = MAXLINE; tmsize_t cc; - uint16 fillorder; + uint16_t fillorder; unsigned char *tf_buf; unsigned char *cp, c; tstrip_t s; #if defined( EXP_ASCII85ENCODER ) tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */ + uint8_t * ascii85_p = 0; /* Holds ASCII85 encoded data */ #endif (void) w; (void) h; @@ -2798,11 +2797,11 @@ PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) * Find largest strip: */ - bufsize = (uint32) bc[0]; + bufsize = (uint32_t) bc[0]; for ( s = 0; ++s < tf_numberstrips; ) { if ( bc[s] > bufsize ) - bufsize = (uint32) bc[s]; + bufsize = (uint32_t) bc[s]; } tf_buf = (unsigned char*) limitMalloc(bufsize); @@ -2845,7 +2844,7 @@ PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) for (cp = tf_buf; cc > 0; cc--) { DOBREAK(breaklen, 1, fd); c = *cp++; - PUTHEX(c, fd); + puthex(c, fd); } fputs(">\n", fd); breaklen = MAXLINE; @@ -2882,12 +2881,12 @@ static char* Ascii85Encode(unsigned char* raw) { static char encoded[6]; - uint32 word; + uint32_t word; word = (((raw[0]<<8)+raw[1])<<16) + (raw[2]<<8) + raw[3]; if (word != 0L) { - uint32 q; - uint16 w1; + uint32_t q; + uint16_t w1; q = word / (85L*85*85*85); /* actually only a byte */ encoded[0] = (char) (q + '!'); @@ -2898,7 +2897,7 @@ Ascii85Encode(unsigned char* raw) word -= q * (85L*85*85); q = word / (85*85); encoded[2] = (char) (q + '!'); - w1 = (uint16) (word - q*(85L*85)); + w1 = (uint16_t) (word - q * (85L * 85)); encoded[3] = (char) ((w1 / 85) + '!'); encoded[4] = (char) ((w1 % 85) + '!'); encoded[5] = '\0'; @@ -2984,13 +2983,13 @@ Ascii85Flush(FILE* fd) * *****************************************************************************/ -tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, tsize_t raw_l ) +tsize_t Ascii85EncodeBlock(uint8_t * ascii85_p, unsigned f_eod, const uint8_t * raw_p, tsize_t raw_l ) { char ascii85[5]; /* Encoded 5 tuple */ tsize_t ascii85_l; /* Number of bytes written to ascii85_p[] */ int rc; /* Return code */ - uint32 val32; /* Unencoded 4 tuple */ + uint32_t val32; /* Unencoded 4 tuple */ ascii85_l = 0; /* Nothing written yet */ @@ -3000,10 +2999,10 @@ tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw for ( ; raw_l > 3; raw_l -= 4 ) { - val32 = (uint32)*(++raw_p) << 24; - val32 += (uint32)*(++raw_p) << 16; - val32 += (uint32)*(++raw_p) << 8; - val32 += (uint32)*(++raw_p); + val32 = (uint32_t)*(++raw_p) << 24; + val32 += (uint32_t)*(++raw_p) << 16; + val32 += (uint32_t)*(++raw_p) << 8; + val32 += (uint32_t)*(++raw_p); if ( val32 == 0 ) /* Special case */ { @@ -3048,7 +3047,7 @@ tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw tsize_t len; /* Output this many bytes */ len = raw_l + 1; - val32 = (uint32)*++raw_p << 24; /* Prime the pump */ + val32 = (uint32_t)*++raw_p << 24; /* Prime the pump */ if ( --raw_l > 0 ) val32 += *(++raw_p) << 16; if ( --raw_l > 0 ) val32 += *(++raw_p) << 8; @@ -3087,52 +3086,50 @@ tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw #endif /* EXP_ASCII85ENCODER */ -const char* stuff[] = { -"usage: tiff2ps [options] input.tif ...", -"where options are:", -" -1 generate PostScript Level 1 (default)", -" -2 generate PostScript Level 2", -" -3 generate PostScript Level 3", -" -8 disable use of ASCII85 encoding with PostScript Level 2/3", -" -a convert all directories in file (default is first), Not EPS", -" -b # set the bottom margin to # inches", -" -c center image (-b and -l still add to this)", -" -C name set postscript document creator name", -" -d # set initial directory to # counting from zero", -" -D enable duplex printing (two pages per sheet of paper)", -" -e generate Encapsulated PostScript (EPS) (implies -z)", -" -h # set printed page height to # inches (no default)", -" -w # set printed page width to # inches (no default)", -" -H # split image if height is more than # inches", -" -W # split image if width is more than # inches", -" -L # overLap split images by # inches", -" -i # enable/disable (Nz/0) pixel interpolation (default: enable)", -" -l # set the left margin to # inches", -" -m use \"imagemask\" operator instead of \"image\"", -" -M size set the memory allocation limit in MiB. 0 to disable limit", -" -o # convert directory at file offset # bytes", -" -O file write PostScript to file instead of standard output", -" -p generate regular (non-encapsulated) PostScript", -" -P L or P set optional PageOrientation DSC comment to Landscape or Portrait", -" -r # or auto rotate by 90, 180, 270 degrees or auto", -" -s generate PostScript for a single image", -" -t name set postscript document title. Otherwise the filename is used", -" -T print pages for top edge binding", -" -x override resolution units as centimeters", -" -y override resolution units as inches", -" -z enable printing in the deadzone (only for PostScript Level 2/3)", -NULL -}; +static const char usage_info[] = +"Convert a TIFF image to PostScript\n\n" +"usage: tiff2ps [options] input.tif ...\n" +"where options are:\n" +" -1 generate PostScript Level 1 (default)\n" +" -2 generate PostScript Level 2\n" +" -3 generate PostScript Level 3\n" +" -8 disable use of ASCII85 encoding with PostScript Level 2/3\n" +" -a convert all directories in file (default is first), Not EPS\n" +" -b # set the bottom margin to # inches\n" +" -c center image (-b and -l still add to this)\n" +" -C name set postscript document creator name\n" +" -d # set initial directory to # counting from zero\n" +" -D enable duplex printing (two pages per sheet of paper)\n" +" -e generate Encapsulated PostScript (EPS) (implies -z)\n" +" -h # set printed page height to # inches (no default)\n" +" -w # set printed page width to # inches (no default)\n" +" -H # split image if height is more than # inches\n" +" -W # split image if width is more than # inches\n" +" -L # overLap split images by # inches\n" +" -i # enable/disable (Nz/0) pixel interpolation (default: enable)\n" +" -l # set the left margin to # inches\n" +" -m use \"imagemask\" operator instead of \"image\"\n" +" -M size set the memory allocation limit in MiB. 0 to disable limit\n" +" -o # convert directory at file offset # bytes\n" +" -O file write PostScript to file instead of standard output\n" +" -p generate regular (non-encapsulated) PostScript\n" +" -P L or P set optional PageOrientation DSC comment to Landscape or Portrait\n" +" -r # or auto rotate by 90, 180, 270 degrees or auto\n" +" -s generate PostScript for a single image\n" +" -t name set postscript document title. Otherwise the filename is used\n" +" -T print pages for top edge binding\n" +" -x override resolution units as centimeters\n" +" -y override resolution units as inches\n" +" -z enable printing in the deadzone (only for PostScript Level 2/3)\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/tiff2rgba.c b/tiff/tools/tiff2rgba.c index 764395f6..7077f946 100644 --- a/tiff/tools/tiff2rgba.c +++ b/tiff/tools/tiff2rgba.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <string.h> @@ -32,10 +33,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffiop.h" #include "tiffio.h" @@ -53,13 +50,13 @@ #ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) #endif -#define roundup(x, y) (howmany(x,y)*((uint32)(y))) +#define roundup(x, y) (howmany(x,y)*((uint32_t)(y))) -uint16 compression = COMPRESSION_PACKBITS; -uint32 rowsperstrip = (uint32) -1; -int process_by_block = 0; /* default is whole image at once */ -int no_alpha = 0; -int bigtiff_output = 0; +static uint16_t compression = COMPRESSION_PACKBITS; +static uint32_t rowsperstrip = (uint32_t) -1; +static int process_by_block = 0; /* default is whole image at once */ +static int no_alpha = 0; +static int bigtiff_output = 0; #define DEFAULT_MAX_MALLOC (256 * 1024 * 1024) /* malloc size limit (in bytes) * disabled when set to 0 */ @@ -122,9 +119,11 @@ main(int argc, char* argv[]) case 'h': usage(EXIT_SUCCESS); /*NOTREACHED*/ + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ + break; } if (argc - optind < 2) @@ -156,13 +155,13 @@ static int cvt_by_tile( TIFF *in, TIFF *out ) { - uint32* raster; /* retrieve RGBA image */ - uint32 width, height; /* image width & height */ - uint32 tile_width, tile_height; - uint32 row, col; - uint32 *wrk_line; + uint32_t* raster; /* retrieve RGBA image */ + uint32_t width, height; /* image width & height */ + uint32_t tile_width, tile_height; + uint32_t row, col; + uint32_t *wrk_line; int ok = 1; - uint32 rastersize, wrk_linesize; + uint32_t rastersize, wrk_linesize; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); @@ -179,13 +178,13 @@ cvt_by_tile( TIFF *in, TIFF *out ) /* * Allocate tile buffer */ - rastersize = tile_width * tile_height * sizeof (uint32); - if (tile_width != (rastersize / tile_height) / sizeof( uint32)) + rastersize = tile_width * tile_height * sizeof (uint32_t); + if (tile_width != (rastersize / tile_height) / sizeof( uint32_t)) { TIFFError(TIFFFileName(in), "Integer overflow when calculating raster buffer"); exit(EXIT_FAILURE); } - raster = (uint32*)_TIFFmalloc(rastersize); + raster = (uint32_t*)_TIFFmalloc(rastersize); if (raster == 0) { TIFFError(TIFFFileName(in), "No space for raster buffer"); return (0); @@ -195,13 +194,13 @@ cvt_by_tile( TIFF *in, TIFF *out ) * Allocate a scanline buffer for swapping during the vertical * mirroring pass. */ - wrk_linesize = tile_width * sizeof (uint32); - if (tile_width != wrk_linesize / sizeof (uint32)) + wrk_linesize = tile_width * sizeof (uint32_t); + if (tile_width != wrk_linesize / sizeof (uint32_t)) { TIFFError(TIFFFileName(in), "Integer overflow when calculating wrk_line buffer"); exit(EXIT_FAILURE); } - wrk_line = (uint32*)_TIFFmalloc(wrk_linesize); + wrk_line = (uint32_t*)_TIFFmalloc(wrk_linesize); if (!wrk_line) { TIFFError(TIFFFileName(in), "No space for raster scanline buffer"); ok = 0; @@ -214,7 +213,7 @@ cvt_by_tile( TIFF *in, TIFF *out ) { for( col = 0; ok && col < width; col += tile_width ) { - uint32 i_row; + uint32_t i_row; /* Read the tile into an RGBA array */ if (!TIFFReadRGBATile(in, col, row, raster)) { @@ -237,7 +236,7 @@ cvt_by_tile( TIFF *in, TIFF *out ) */ for( i_row = 0; i_row < tile_height / 2; i_row++ ) { - uint32 *top_line, *bottom_line; + uint32_t *top_line, *bottom_line; top_line = raster + tile_width * i_row; bottom_line = raster + tile_width * (tile_height-i_row-1); @@ -272,12 +271,12 @@ static int cvt_by_strip( TIFF *in, TIFF *out ) { - uint32* raster; /* retrieve RGBA image */ - uint32 width, height; /* image width & height */ - uint32 row; - uint32 *wrk_line; + uint32_t* raster; /* retrieve RGBA image */ + uint32_t width, height; /* image width & height */ + uint32_t row; + uint32_t *wrk_line; int ok = 1; - uint32 rastersize, wrk_linesize; + uint32_t rastersize, wrk_linesize; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); @@ -292,13 +291,13 @@ cvt_by_strip( TIFF *in, TIFF *out ) /* * Allocate strip buffer */ - rastersize = width * rowsperstrip * sizeof (uint32); - if (width != (rastersize / rowsperstrip) / sizeof( uint32)) + rastersize = width * rowsperstrip * sizeof (uint32_t); + if (width != (rastersize / rowsperstrip) / sizeof( uint32_t)) { TIFFError(TIFFFileName(in), "Integer overflow when calculating raster buffer"); exit(EXIT_FAILURE); } - raster = (uint32*)_TIFFmalloc(rastersize); + raster = (uint32_t*)_TIFFmalloc(rastersize); if (raster == 0) { TIFFError(TIFFFileName(in), "No space for raster buffer"); return (0); @@ -308,13 +307,13 @@ cvt_by_strip( TIFF *in, TIFF *out ) * Allocate a scanline buffer for swapping during the vertical * mirroring pass. */ - wrk_linesize = width * sizeof (uint32); - if (width != wrk_linesize / sizeof (uint32)) + wrk_linesize = width * sizeof (uint32_t); + if (width != wrk_linesize / sizeof (uint32_t)) { TIFFError(TIFFFileName(in), "Integer overflow when calculating wrk_line buffer"); exit(EXIT_FAILURE); } - wrk_line = (uint32*)_TIFFmalloc(wrk_linesize); + wrk_line = (uint32_t*)_TIFFmalloc(wrk_linesize); if (!wrk_line) { TIFFError(TIFFFileName(in), "No space for raster scanline buffer"); ok = 0; @@ -356,7 +355,7 @@ cvt_by_strip( TIFF *in, TIFF *out ) for( i_row = 0; i_row < rows_to_write / 2; i_row++ ) { - uint32 *top_line, *bottom_line; + uint32_t *top_line, *bottom_line; top_line = raster + width * i_row; bottom_line = raster + width * (rows_to_write-i_row-1); @@ -396,9 +395,9 @@ static int cvt_whole_image( TIFF *in, TIFF *out ) { - uint32* raster; /* retrieve RGBA image */ - uint32 width, height; /* image width & height */ - uint32 row; + uint32_t* raster; /* retrieve RGBA image */ + uint32_t width, height; /* image width & height */ + uint32_t row; size_t pixel_count; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); @@ -408,24 +407,24 @@ cvt_whole_image( TIFF *in, TIFF *out ) /* XXX: Check the integer overflow. */ if (!width || !height || pixel_count / width != height) { TIFFError(TIFFFileName(in), - "Malformed input file; can't allocate buffer for raster of %lux%lu size", - (unsigned long)width, (unsigned long)height); + "Malformed input file; can't allocate buffer for raster of %"PRIu32"x%"PRIu32" size", + width, height); return 0; } - if (maxMalloc != 0 && (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32) > maxMalloc) { + if (maxMalloc != 0 && (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32_t) > maxMalloc) { TIFFError(TIFFFileName(in), - "Raster size " TIFF_UINT64_FORMAT " over memory limit (" TIFF_UINT64_FORMAT "), try -b option.", - (uint64)pixel_count * sizeof(uint32), (uint64)maxMalloc); + "Raster size %"TIFF_SIZE_FORMAT" over memory limit (%" TIFF_SSIZE_FORMAT "), try -b option.", + pixel_count * sizeof(uint32_t), maxMalloc); return 0; } rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), "raster buffer"); + raster = (uint32_t*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32_t), "raster buffer"); if (raster == 0) { - TIFFError(TIFFFileName(in), "Failed to allocate buffer (%lu elements of %lu each)", - (unsigned long)pixel_count, (unsigned long)sizeof(uint32)); + TIFFError(TIFFFileName(in), "Failed to allocate buffer (%"TIFF_SIZE_FORMAT" elements of %"TIFF_SIZE_FORMAT" each)", + pixel_count, sizeof(uint32_t)); return (0); } @@ -505,12 +504,12 @@ cvt_whole_image( TIFF *in, TIFF *out ) static int tiffcvt(TIFF* in, TIFF* out) { - uint32 width, height; /* image width & height */ - uint16 shortv; + uint32_t width, height; /* image width & height */ + uint16_t shortv; float floatv; char *stringv; - uint32 longv; - uint16 v[1]; + uint32_t longv; + uint16_t v[1]; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); @@ -546,8 +545,8 @@ tiffcvt(TIFF* in, TIFF* out) if (maxMalloc != 0 && TIFFStripSize(in) > maxMalloc) { TIFFError(TIFFFileName(in), - "Strip Size " TIFF_UINT64_FORMAT " over memory limit (" TIFF_UINT64_FORMAT ")", - (uint64)TIFFStripSize(in), (uint64)maxMalloc); + "Strip Size %" TIFF_SSIZE_FORMAT " over memory limit (%" TIFF_SSIZE_FORMAT ")", + TIFFStripSize(in), maxMalloc); return 0; } if( process_by_block && TIFFIsTiled( in ) ) @@ -558,32 +557,44 @@ tiffcvt(TIFF* in, TIFF* out) return( cvt_whole_image( in, out ) ); } -static const char* stuff[] = { - "usage: tiff2rgba [-c comp] [-r rows] [-b] [-n] [-8] [-M size] input... output", - "where comp is one of the following compression algorithms:", - " jpeg\t\tJPEG encoding", - " zip\t\tZip/Deflate encoding", - " lzw\t\tLempel-Ziv & Welch encoding", - " packbits\tPackBits encoding", - " none\t\tno compression", - "and the other options are:", - " -r\trows/strip", - " -b (progress by block rather than as a whole image)", - " -n don't emit alpha component.", - " -8 write BigTIFF file instead of ClassicTIFF", - " -M set the memory allocation limit in MiB. 0 to disable limit", - NULL -}; +static const char usage_info[] = +/* Help information format modified for the sake of consistency with the other tiff tools */ +/* "usage: tiff2rgba [-c comp] [-r rows] [-b] [-n] [-8] [-M size] input... output" */ +/* "where comp is one of the following compression algorithms:" */ +"Convert a TIFF image to RGBA color space\n\n" +"usage: tiff2rgba [options] input output\n" +"where options are:\n" +#ifdef JPEG_SUPPORT +" -c jpeg JPEG encoding\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip Zip/Deflate encoding\n" +#endif +#ifdef LZW_SUPPORT +" -c lzw Lempel-Ziv & Welch encoding\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits PackBits encoding\n" +#endif +#if defined(JPEG_SUPPORT) || defined(ZIP_SUPPORT) || defined(LZW_SUPPORT) || defined(PACKBITS_SUPPORT) +" -c none no compression\n" +#endif +"\n" +/* "and the other options are:\n" */ +" -r rows/strip\n" +" -b (progress by block rather than as a whole image)\n" +" -n don't emit alpha component.\n" +" -8 write BigTIFF file instead of ClassicTIFF\n" +" -M set the memory allocation limit in MiB. 0 to disable limit\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/tiffcmp.c b/tiff/tools/tiffcmp.c index 041d6a2d..2a35fe60 100644 --- a/tiff/tools/tiffcmp.c +++ b/tiff/tools/tiffcmp.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -33,10 +34,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" #ifndef EXIT_SUCCESS @@ -46,27 +43,23 @@ #define EXIT_FAILURE 1 #endif -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - static int stopondiff = 1; static int stoponfirsttag = 1; -static uint16 bitspersample = 1; -static uint16 samplesperpixel = 1; -static uint16 sampleformat = SAMPLEFORMAT_UINT; -static uint32 imagewidth; -static uint32 imagelength; +static uint16_t bitspersample = 1; +static uint16_t samplesperpixel = 1; +static uint16_t sampleformat = SAMPLEFORMAT_UINT; +static uint32_t imagewidth; +static uint32_t imagelength; static void usage(int code); static int tiffcmp(TIFF*, TIFF*); static int cmptags(TIFF*, TIFF*); -static int ContigCompare(int, uint32, unsigned char*, unsigned char*, tsize_t); -static int SeparateCompare(int, int, uint32, unsigned char*, unsigned char*); -static void PrintIntDiff(uint32, int, uint32, uint32, uint32); -static void PrintFloatDiff(uint32, int, uint32, double, double); +static int ContigCompare(int, uint32_t, unsigned char*, unsigned char*, tsize_t); +static int SeparateCompare(int, int, uint32_t, unsigned char*, unsigned char*); +static void PrintIntDiff(uint32_t, int, uint32_t, uint32_t, uint32_t); +static void PrintFloatDiff(uint32_t, int, uint32_t, double, double); -static void leof(const char*, uint32, int); +static void leof(const char*, uint32_t, int); /* * exit with status : @@ -97,9 +90,11 @@ main(int argc, char* argv[]) break; case 'h': usage(EXIT_SUCCESS); + break; case '?': usage(2); /*NOTREACHED*/ + break; } if (argc - optind < 2) usage(2); @@ -130,24 +125,22 @@ main(int argc, char* argv[]) return (0); } -static const char* stuff[] = { -"usage: tiffcmp [options] file1 file2", -"where options are:", -" -l list each byte of image data that differs between the files", -" -z # list specified number of bytes that differs between the files", -" -t ignore any differences in directory tags", -NULL -}; +static const char usage_info[] = +"Compare the tags and data in two TIFF files\n\n" +"usage: tiffcmp [options] file1 file2\n" +"where options are:\n" +" -l list each byte of image data that differs between the files\n" +" -z # list specified number of bytes that differs between the files\n" +" -t ignore any differences in directory tags\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } @@ -166,9 +159,9 @@ static int CheckStringTag(TIFF*, TIFF*, int, char*); static int tiffcmp(TIFF* tif1, TIFF* tif2) { - uint16 config1, config2; + uint16_t config1, config2; tsize_t size1; - uint32 row; + uint32_t row; tsample_t s; unsigned char *buf1, *buf2; @@ -274,7 +267,7 @@ bad1: static int cmptags(TIFF* tif1, TIFF* tif2) { - uint16 compression1, compression2; + uint16_t compression1, compression2; CmpLongField(TIFFTAG_SUBFILETYPE, "SubFileType"); CmpLongField(TIFFTAG_IMAGEWIDTH, "ImageWidth"); CmpLongField(TIFFTAG_IMAGELENGTH, "ImageLength"); @@ -313,13 +306,13 @@ cmptags(TIFF* tif1, TIFF* tif2) CmpShortField(TIFFTAG_GRAYRESPONSEUNIT, "GrayResponseUnit"); CmpShortField(TIFFTAG_COLORRESPONSEUNIT, "ColorResponseUnit"); #ifdef notdef - { uint16 *graycurve; + { uint16_t *graycurve; CmpField(TIFFTAG_GRAYRESPONSECURVE, graycurve); } - { uint16 *red, *green, *blue; + { uint16_t *red, *green, *blue; CmpField3(TIFFTAG_COLORRESPONSECURVE, red, green, blue); } - { uint16 *red, *green, *blue; + { uint16_t *red, *green, *blue; CmpField3(TIFFTAG_COLORMAP, red, green, blue); } #endif @@ -339,11 +332,10 @@ cmptags(TIFF* tif1, TIFF* tif2) } static int -ContigCompare(int sample, uint32 row, - unsigned char* p1, unsigned char* p2, tsize_t size) +ContigCompare(int sample, uint32_t row, + unsigned char* p1, unsigned char* p2, tsize_t size) { - uint32 pix; - int ppb = 8 / bitspersample; + uint32_t pix; int samples_to_test; if (memcmp(p1, p2, size) == 0) @@ -355,9 +347,10 @@ ContigCompare(int sample, uint32 row, case 1: case 2: case 4: case 8: { unsigned char *pix1 = p1, *pix2 = p2; + unsigned bits = 0; - for (pix = 0; pix < imagewidth; pix += ppb) { - int s; + for (pix = 0; pix < imagewidth; pix++) { + int s; for(s = 0; s < samples_to_test; s++) { if (*pix1 != *pix2) { @@ -367,15 +360,17 @@ ContigCompare(int sample, uint32 row, PrintIntDiff(row, sample, pix, *pix1, *pix2); } - pix1++; - pix2++; + bits += bitspersample; + pix1 += (bits / 8); + pix2 += (bits / 8); + bits &= 7; } } break; } case 16: { - uint16 *pix1 = (uint16 *)p1, *pix2 = (uint16 *)p2; + uint16_t *pix1 = (uint16_t *)p1, *pix2 = (uint16_t *)p2; for (pix = 0; pix < imagewidth; pix++) { int s; @@ -393,7 +388,7 @@ ContigCompare(int sample, uint32 row, case 32: if (sampleformat == SAMPLEFORMAT_UINT || sampleformat == SAMPLEFORMAT_INT) { - uint32 *pix1 = (uint32 *)p1, *pix2 = (uint32 *)p2; + uint32_t *pix1 = (uint32_t *)p1, *pix2 = (uint32_t *)p2; for (pix = 0; pix < imagewidth; pix++) { int s; @@ -425,13 +420,13 @@ ContigCompare(int sample, uint32 row, } } } else { - fprintf(stderr, "Sample format %d is not supported.\n", + fprintf(stderr, "Sample format %"PRIu16" is not supported.\n", sampleformat); return -1; } break; default: - fprintf(stderr, "Bit depth %d is not supported.\n", bitspersample); + fprintf(stderr, "Bit depth %"PRIu16" is not supported.\n", bitspersample); return -1; } @@ -439,7 +434,7 @@ ContigCompare(int sample, uint32 row, } static void -PrintIntDiff(uint32 row, int sample, uint32 pix, uint32 w1, uint32 w2) +PrintIntDiff(uint32_t row, int sample, uint32_t pix, uint32_t w1, uint32_t w2) { if (sample < 0) sample = 0; @@ -448,22 +443,22 @@ PrintIntDiff(uint32 row, int sample, uint32 pix, uint32 w1, uint32 w2) case 2: case 4: { - int32 mask1, mask2, s; + int32_t mask1, mask2, s; /* mask1 should have the n lowest bits set, where n == bitspersample */ - mask1 = ((int32)1 << bitspersample) - 1; + mask1 = ((int32_t)1 << bitspersample) - 1; s = (8 - bitspersample); mask2 = mask1 << s; for (; mask2 && pix < imagewidth; mask2 >>= bitspersample, s -= bitspersample, pix++) { if ((w1 & mask2) ^ (w2 & mask2)) { printf( - "Scanline %lu, pixel %lu, sample %d: %01x %01x\n", - (unsigned long) row, - (unsigned long) pix, + "Scanline %"PRIu32", pixel %"PRIu32", sample %d: %01"PRIx32" %01"PRIx32"\n", + row, + pix, sample, - (unsigned int)((w1 >> s) & mask1), - (unsigned int)((w2 >> s) & mask1)); + (w1 >> s) & mask1, + (w2 >> s) & mask1); if (--stopondiff == 0) exit(1); } @@ -471,23 +466,23 @@ PrintIntDiff(uint32 row, int sample, uint32 pix, uint32 w1, uint32 w2) break; } case 8: - printf("Scanline %lu, pixel %lu, sample %d: %02x %02x\n", - (unsigned long) row, (unsigned long) pix, sample, - (unsigned int) w1, (unsigned int) w2); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: %02"PRIx32" %02"PRIx32"\n", + row, pix, sample, + w1, w2); if (--stopondiff == 0) exit(1); break; case 16: - printf("Scanline %lu, pixel %lu, sample %d: %04x %04x\n", - (unsigned long) row, (unsigned long) pix, sample, - (unsigned int) w1, (unsigned int) w2); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: %04"PRIx32" %04"PRIx32"\n", + row, pix, sample, + w1, w2); if (--stopondiff == 0) exit(1); break; case 32: - printf("Scanline %lu, pixel %lu, sample %d: %08x %08x\n", - (unsigned long) row, (unsigned long) pix, sample, - (unsigned int) w1, (unsigned int) w2); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: %08"PRIx32" %08"PRIx32"\n", + row, pix, sample, + w1, w2); if (--stopondiff == 0) exit(1); break; @@ -497,14 +492,14 @@ PrintIntDiff(uint32 row, int sample, uint32 pix, uint32 w1, uint32 w2) } static void -PrintFloatDiff(uint32 row, int sample, uint32 pix, double w1, double w2) +PrintFloatDiff(uint32_t row, int sample, uint32_t pix, double w1, double w2) { if (sample < 0) sample = 0; switch (bitspersample) { case 32: - printf("Scanline %lu, pixel %lu, sample %d: %g %g\n", - (long) row, (long) pix, sample, w1, w2); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: %g %g\n", + row, pix, sample, w1, w2); if (--stopondiff == 0) exit(1); break; @@ -514,17 +509,17 @@ PrintFloatDiff(uint32 row, int sample, uint32 pix, double w1, double w2) } static int -SeparateCompare(int reversed, int sample, uint32 row, - unsigned char* cp1, unsigned char* p2) +SeparateCompare(int reversed, int sample, uint32_t row, + unsigned char* cp1, unsigned char* p2) { - uint32 npixels = imagewidth; + uint32_t npixels = imagewidth; int pixel; cp1 += sample; for (pixel = 0; npixels-- > 0; pixel++, cp1 += samplesperpixel, p2++) { if (*cp1 != *p2) { - printf("Scanline %lu, pixel %lu, sample %ld: ", - (long) row, (long) pixel, (long) sample); + printf("Scanline %"PRIu32", pixel %"PRIu32", sample %d: ", + row, pixel, sample); if (reversed) printf("%02x %02x\n", *p2, *cp1); else @@ -567,14 +562,14 @@ checkTag(TIFF* tif1, TIFF* tif2, int tag, char* name, void* p1, void* p2) static int CheckShortTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - uint16 v1, v2; - CHECK(v1 == v2, "%s: %u %u\n"); + uint16_t v1, v2; + CHECK(v1 == v2, "%s: %"PRIu16" %"PRIu16"\n"); } static int CheckShort2Tag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - uint16 v11, v12, v21, v22; + uint16_t v11, v12, v21, v22; if (TIFFGetField(tif1, tag, &v11, &v12)) { if (!TIFFGetField(tif2, tag, &v21, &v22)) { @@ -584,7 +579,7 @@ CheckShort2Tag(TIFF* tif1, TIFF* tif2, int tag, char* name) } if (v11 == v21 && v12 == v22) return (1); - printf("%s: <%u,%u> <%u,%u>\n", name, v11, v12, v21, v22); + printf("%s: <%"PRIu16",%"PRIu16"> <%"PRIu16",%"PRIu16">\n", name, v11, v12, v21, v22); } else if (TIFFGetField(tif2, tag, &v21, &v22)) printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); else @@ -595,8 +590,8 @@ CheckShort2Tag(TIFF* tif1, TIFF* tif2, int tag, char* name) static int CheckShortArrayTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - uint16 n1, *a1; - uint16 n2, *a2; + uint16_t n1, *a1; + uint16_t n2, *a2; if (TIFFGetField(tif1, tag, &n1, &a1)) { if (!TIFFGetField(tif2, tag, &n2, &a2)) { @@ -606,21 +601,21 @@ CheckShortArrayTag(TIFF* tif1, TIFF* tif2, int tag, char* name) } if (n1 == n2) { char* sep; - uint16 i; + uint16_t i; - if (memcmp(a1, a2, n1 * sizeof(uint16)) == 0) + if (memcmp(a1, a2, n1 * sizeof(uint16_t)) == 0) return (1); - printf("%s: value mismatch, <%u:", name, n1); + printf("%s: value mismatch, <%"PRIu16":", name, n1); sep = ""; for (i = 0; i < n1; i++) - printf("%s%u", sep, a1[i]), sep = ","; - printf("> and <%u: ", n2); + printf("%s%"PRIu16, sep, a1[i]), sep = ","; + printf("> and <%"PRIu16": ", n2); sep = ""; for (i = 0; i < n2; i++) - printf("%s%u", sep, a2[i]), sep = ","; + printf("%s%"PRIu16, sep, a2[i]), sep = ","; printf(">\n"); } else - printf("%s: %u items in %s, %u items in %s", name, + printf("%s: %"PRIu16" items in %s, %"PRIu16" items in %s", name, n1, TIFFFileName(tif1), n2, TIFFFileName(tif2) ); @@ -634,8 +629,8 @@ CheckShortArrayTag(TIFF* tif1, TIFF* tif2, int tag, char* name) static int CheckLongTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - uint32 v1, v2; - CHECK(v1 == v2, "%s: %u %u\n"); + uint32_t v1, v2; + CHECK(v1 == v2, "%s: %"PRIu32" %"PRIu32"\n"); } static int @@ -653,10 +648,10 @@ CheckStringTag(TIFF* tif1, TIFF* tif2, int tag, char* name) } static void -leof(const char* name, uint32 row, int s) +leof(const char* name, uint32_t row, int s) { - printf("%s: EOF at scanline %lu", name, (unsigned long)row); + printf("%s: EOF at scanline %"PRIu32, name, row); if (s >= 0) printf(", sample %d", s); printf("\n"); diff --git a/tiff/tools/tiffcp.c b/tiff/tools/tiffcp.c index e56b1c10..1f889516 100644 --- a/tiff/tools/tiffcp.c +++ b/tiff/tools/tiffcp.c @@ -37,6 +37,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -58,14 +59,6 @@ #define EXIT_FAILURE 1 #endif -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - -#if defined(VMS) -# define unlink delete -#endif - #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) @@ -79,23 +72,24 @@ extern int getopt(int argc, char * const argv[], const char *optstring); static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; static int outtiled = -1; -static uint32 tilewidth; -static uint32 tilelength; +static uint32_t tilewidth; +static uint32_t tilelength; -static uint16 config; -static uint16 compression; -static uint16 predictor; +static uint16_t config; +static uint16_t compression; +static double max_z_error = 0.0; +static uint16_t predictor; static int preset; -static uint16 fillorder; -static uint16 orientation; -static uint32 rowsperstrip; -static uint32 g3opts; +static uint16_t fillorder; +static uint16_t orientation; +static uint32_t rowsperstrip; +static uint32_t g3opts; static int ignore = FALSE; /* if true, ignore read errors */ -static uint32 defg3opts = (uint32) -1; +static uint32_t defg3opts = (uint32_t) -1; static int quality = 75; /* JPEG quality */ static int jpegcolormode = JPEGCOLORMODE_RGB; -static uint16 defcompression = (uint16) -1; -static uint16 defpredictor = (uint16) -1; +static uint16_t defcompression = (uint16_t) -1; +static uint16_t defpredictor = (uint16_t) -1; static int defpreset = -1; static int subcodec = -1; @@ -114,8 +108,8 @@ static int pageInSeq = 0; static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ".\n", - (uint64)s, (uint64)maxMalloc); + fprintf(stderr, "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", + s, maxMalloc); fprintf(stderr, " use -m option to change limit.\n"); return NULL; } @@ -146,8 +140,8 @@ static int nextSrcImage (TIFF *tif, char **imageSpec) } } if (TIFFSetDirectory (tif, nextImage)) return 1; - fprintf (stderr, "%s%c%d not found!\n", - TIFFFileName(tif), comma, (int) nextImage); + fprintf (stderr, "%s%c%"PRIu16" not found!\n", + TIFFFileName(tif), comma, nextImage); } return 0; } @@ -185,12 +179,12 @@ static TIFF* openSrcImage (char **imageSpec) int main(int argc, char* argv[]) { - uint16 defconfig = (uint16) -1; - uint16 deffillorder = 0; - uint32 deftilewidth = (uint32) -1; - uint32 deftilelength = (uint32) -1; - uint32 defrowsperstrip = (uint32) 0; - uint64 diroff = 0; + uint16_t defconfig = (uint16_t) -1; + uint16_t deffillorder = 0; + uint32_t deftilewidth = (uint32_t) -1; + uint32_t deftilelength = (uint32_t) -1; + uint32_t defrowsperstrip = (uint32_t) 0; + uint64_t diroff = 0; TIFF* in; TIFF* out; char mode[10]; @@ -218,7 +212,7 @@ main(int argc, char* argv[]) exit (EXIT_FAILURE); } { - uint16 samples = (uint16) -1; + uint16_t samples = (uint16_t) -1; char **biasFn = &optarg; bias = openSrcImage (biasFn); if (!bias) exit (EXIT_FAILURE); @@ -300,9 +294,11 @@ main(int argc, char* argv[]) case 'h': usage(EXIT_SUCCESS); /*NOTREACHED*/ + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ + break; } if (argc - optind < 2) usage(EXIT_FAILURE); @@ -320,7 +316,7 @@ main(int argc, char* argv[]) } if (diroff != 0 && !TIFFSetSubDirectory(in, diroff)) { TIFFError(TIFFFileName(in), - "Error, setting subdirectory at " TIFF_UINT64_FORMAT, diroff); + "Error, setting subdirectory at %" PRIu64, diroff); (void) TIFFClose(in); (void) TIFFClose(out); return (EXIT_FAILURE); @@ -371,10 +367,28 @@ processZIPOptions(char* cp) } static void +processLERCOptions(char* cp) +{ + if ( (cp = strchr(cp, ':')) ) { + do { + cp++; + if (isdigit((int)*cp)) + max_z_error = atof(cp); + else if (*cp == 's') + subcodec = atoi(++cp); + else if (*cp == 'p') + defpreset = atoi(++cp); + else + usage(EXIT_FAILURE); + } while( (cp = strchr(cp, ':')) ); + } +} + +static void processG3Options(char* cp) { if( (cp = strchr(cp, ':')) ) { - if (defg3opts == (uint32) -1) + if (defg3opts == (uint32_t) -1) defg3opts = 0; do { cp++; @@ -425,6 +439,9 @@ processCompressOptions(char* opt) } else if (strneq(opt, "zip", 3)) { processZIPOptions(opt); defcompression = COMPRESSION_ADOBE_DEFLATE; + } else if (strneq(opt, "lerc", 4)) { + processLERCOptions(opt); + defcompression = COMPRESSION_LERC; } else if (strneq(opt, "lzma", 4)) { processZIPOptions(opt); defcompression = COMPRESSION_LZMA; @@ -443,83 +460,121 @@ processCompressOptions(char* opt) return (1); } -static const char* stuff[] = { -"usage: tiffcp [options] input... output", -"where options are:", -" -a append to output instead of overwriting", -" -o offset set initial directory offset", -" -p contig pack samples contiguously (e.g. RGBRGB...)", -" -p separate store samples separately (e.g. RRR...GGG...BBB...)", -" -s write output in strips", -" -t write output in tiles", -" -x force the merged tiff pages in sequence", -" -8 write BigTIFF instead of default ClassicTIFF", -" -B write big-endian instead of native byte order", -" -L write little-endian instead of native byte order", -" -M disable use of memory-mapped files", -" -C disable strip chopping", -" -i ignore read errors", -" -b file[,#] bias (dark) monochrome image to be subtracted from all others", -" -,=% use % rather than , to separate image #'s (per Note below)", -" -m size set maximum memory allocation size (MiB). 0 to disable limit.", -"", -" -r # make each strip have no more than # rows", -" -w # set output tile width (pixels)", -" -l # set output tile length (pixels)", -"", -" -f lsb2msb force lsb-to-msb FillOrder for output", -" -f msb2lsb force msb-to-lsb FillOrder for output", -"", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c lzma[:opts] compress output with LZMA2 encoding", -" -c zstd[:opts] compress output with ZSTD encoding", -" -c webp[:opts] compress output with WEBP encoding", -" -c jpeg[:opts] compress output with JPEG encoding", -" -c jbig compress output with ISO JBIG encoding", -" -c packbits compress output with packbits encoding", -" -c g3[:opts] compress output with CCITT Group 3 encoding", -" -c g4 compress output with CCITT Group 4 encoding", -" -c sgilog compress output with SGILOG encoding", -" -c none use no compression algorithm on output", -"", -"Group 3 options:", -" 1d use default CCITT Group 3 1D-encoding", -" 2d use optional CCITT Group 3 2D-encoding", -" fill byte-align EOL codes", -"For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", -"", -"JPEG options:", -" # set compression quality level (0-100, default 75)", -" r output color image as RGB rather than YCbCr", -"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", -"", -"LZW, Deflate (ZIP), LZMA2, ZSTD and WEBP options:", -" # set predictor value", -" p# set compression level (preset)", -#if LIBDEFLATE_SUPPORT -" s# set subcodec (0=zlib, 1=libdeflate) (only for Deflate/ZIP)", +static const char usage_info[] = +"Copy, convert, or combine TIFF files\n\n" +"usage: tiffcp [options] input... output\n" +"where options are:\n" +" -a append to output instead of overwriting\n" +" -o offset set initial directory offset\n" +" -p contig pack samples contiguously (e.g. RGBRGB...)\n" +" -p separate store samples separately (e.g. RRR...GGG...BBB...)\n" +" -s write output in strips\n" +" -t write output in tiles\n" +" -x force the merged tiff pages in sequence\n" +" -8 write BigTIFF instead of default ClassicTIFF\n" +" -B write big-endian instead of native byte order\n" +" -L write little-endian instead of native byte order\n" +" -M disable use of memory-mapped files\n" +" -C disable strip chopping\n" +" -i ignore read errors\n" +" -b file[,#] bias (dark) monochrome image to be subtracted from all others\n" +" -,=% use % rather than , to separate image #'s (per Note below)\n" +" -m size set maximum memory allocation size (MiB). 0 to disable limit.\n" +"\n" +" -r # make each strip have no more than # rows\n" +" -w # set output tile width (pixels)\n" +" -l # set output tile length (pixels)\n" +"\n" +" -f lsb2msb force lsb-to-msb FillOrder for output\n" +" -f msb2lsb force msb-to-lsb FillOrder for output\n" +"\n" +#ifdef LZW_SUPPORT +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" +/* " LZW options:" */ +" # set predictor value\n" +" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n" #endif -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing,", -"-c zip:3:p9 for Deflate encoding with maximum compression level and floating", -"point predictor.", -"", -"Note that input filenames may be of the form filename,x,y,z", -"where x, y, and z specify image numbers in the filename to copy.", -"example: tiffcp -c none -b esp.tif,1 esp.tif,0 test.tif", -" subtract 2nd image in esp.tif from 1st yielding uncompressed result test.tif", -NULL -}; +#ifdef ZIP_SUPPORT +" -c zip[:opts] compress output with deflate encoding\n" +/* " Deflate (ZIP) options:", */ +" # set predictor value\n" +" p# set compression level (preset)\n" +" For example, -c zip:3:p9 for maximum compression level and floating\n" +" point predictor.\n" +#endif +#if defined(ZIP_SUPPORT) && defined(LIBDEFLATE_SUPPORT) +" s# set subcodec: 0=zlib, 1=libdeflate (default 1)\n" +/* " (only for Deflate/ZIP)", */ +#endif +#ifdef LERC_SUPPORT +" -c lerc[:opts] compress output with LERC encoding\n" +/* " LERC options:", */ +" # set max_z_error value\n" +" s# set subcodec: 0=none, 1=deflate, 2=zstd (default 0)\n" +" p# set compression level (preset)\n" +" For example, -c lerc:0.5:s2:p22 for max_z_error 0.5,\n" +" zstd additional copression with maximum compression level.\n" +#endif +#ifdef LZMA_SUPPORT +" -c lzma[:opts] compress output with LZMA2 encoding\n" +/* " LZMA options:", */ +" # set predictor value\n" +" p# set compression level (preset)\n" +#endif +#ifdef ZSTD_SUPPORT +" -c zstd[:opts] compress output with ZSTD encoding\n" +/* " ZSTD options:", */ +" # set predictor value\n" +" p# set compression level (preset)\n" +#endif +#ifdef WEBP_SUPPORT +" -c webp[:opts] compress output with WEBP encoding\n" +/* " WEBP options:", */ +" # set predictor value\n" +" p# set compression level (preset)\n" +#endif +#ifdef JPEG_SUPPORT +" -c jpeg[:opts] compress output with JPEG encoding\n" +/* " JPEG options:", */ +" # set compression quality level (0-100, default 75)\n" +" r output color image as RGB rather than YCbCr\n" +" For example, -c jpeg:r:50 for JPEG-encoded RGB with 50% comp. quality\n" +#endif +#ifdef JBIG_SUPPORT +" -c jbig compress output with ISO JBIG encoding\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits compress output with packbits encoding\n" +#endif +#ifdef CCITT_SUPPORT +" -c g3[:opts] compress output with CCITT Group 3 encoding\n" +/* " CCITT Group 3 options:", */ +" 1d use default CCITT Group 3 1D-encoding\n" +" 2d use optional CCITT Group 3 2D-encoding\n" +" fill byte-align EOL codes\n" +" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs\n" +" -c g4 compress output with CCITT Group 4 encoding\n" +#endif +#ifdef LOGLUV_SUPPORT +" -c sgilog compress output with SGILOG encoding\n" +#endif +#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(LZMA_SUPPORT) || defined(ZSTD_SUPPORT) || defined(WEBP_SUPPORT) || defined(JPEG_SUPPORT) || defined(JBIG_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) || defined(LOGLUV_SUPPORT) || defined(LERC_SUPPORT) +" -c none use no compression algorithm on output\n" +#endif +"\n" +"Note that input filenames may be of the form filename,x,y,z\n" +"where x, y, and z specify image numbers in the filename to copy.\n" +"example: tiffcp -b esp.tif,1 esp.tif,0 test.tif\n" +" subtract 2nd image in esp.tif from 1st yielding result test.tif\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } @@ -533,27 +588,27 @@ usage(int code) if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static void -cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) +cpTag(TIFF* in, TIFF* out, uint16_t tag, uint16_t count, TIFFDataType type) { switch (type) { case TIFF_SHORT: if (count == 1) { - uint16 shortv; + uint16_t shortv; CopyField(tag, shortv); } else if (count == 2) { - uint16 shortv1, shortv2; + uint16_t shortv1, shortv2; CopyField2(tag, shortv1, shortv2); } else if (count == 4) { - uint16 *tr, *tg, *tb, *ta; + uint16_t *tr, *tg, *tb, *ta; CopyField4(tag, tr, tg, tb, ta); - } else if (count == (uint16) -1) { - uint16 shortv1; - uint16* shortav; + } else if (count == (uint16_t) -1) { + uint16_t shortv1; + uint16_t* shortav; CopyField2(tag, shortv1, shortav); } break; case TIFF_LONG: - { uint32 longv; + { uint32_t longv; CopyField(tag, longv); } break; @@ -561,7 +616,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { float floatv; CopyField(tag, floatv); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { float* floatav; CopyField(tag, floatav); } @@ -575,21 +630,21 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { double doublev; CopyField(tag, doublev); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { double* doubleav; CopyField(tag, doubleav); } break; default: TIFFError(TIFFFileName(in), - "Data type %d is not supported, tag %d skipped.", + "Data type %"PRIu16" is not supported, tag %d skipped.", tag, type); } } -static struct cpTag { - uint16 tag; - uint16 count; +static const struct cpTag { + uint16_t tag; + uint16_t count; TIFFDataType type; } tags[] = { { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, @@ -600,56 +655,56 @@ static struct cpTag { { TIFFTAG_MODEL, 1, TIFF_ASCII }, { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, - { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, - { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, - { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, - { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, - { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, - { TIFFTAG_DATETIME, 1, TIFF_ASCII }, - { TIFFTAG_ARTIST, 1, TIFF_ASCII }, - { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, - { TIFFTAG_WHITEPOINT, (uint16) -1, TIFF_RATIONAL }, - { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, - { TIFFTAG_INKSET, 1, TIFF_SHORT }, - { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, - { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, - { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, - { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, - { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, - { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, - { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, - { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, - { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, + { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES,(uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16_t) -1, TIFF_SHORT }, + { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) #define CopyTag(tag, count, type) cpTag(in, out, tag, count, type) typedef int (*copyFunc) - (TIFF* in, TIFF* out, uint32 l, uint32 w, uint16 samplesperpixel); -static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16, uint16); + (TIFF* in, TIFF* out, uint32_t l, uint32_t w, uint16_t samplesperpixel); +static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16_t, uint16_t); /* PODD */ static int tiffcp(TIFF* in, TIFF* out) { - uint16 bitspersample = 1, samplesperpixel = 1; - uint16 input_compression, input_photometric = PHOTOMETRIC_MINISBLACK; + uint16_t bitspersample = 1, samplesperpixel = 1; + uint16_t input_compression, input_photometric = PHOTOMETRIC_MINISBLACK; copyFunc cf; - uint32 width, length; - struct cpTag* p; + uint32_t width, length; + const struct cpTag* p; CopyField(TIFFTAG_IMAGEWIDTH, width); CopyField(TIFFTAG_IMAGELENGTH, length); CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample); CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); - if (compression != (uint16)-1) + if (compression != (uint16_t)-1) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); else CopyField(TIFFTAG_COMPRESSION, compression); @@ -660,7 +715,7 @@ tiffcp(TIFF* in, TIFF* out) TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); } else if (input_photometric == PHOTOMETRIC_YCBCR) { /* Otherwise, can't handle subsampled input */ - uint16 subsamplinghor,subsamplingver; + uint16_t subsamplinghor,subsamplingver; TIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver); @@ -732,9 +787,9 @@ tiffcp(TIFF* in, TIFF* out) * input image or, if nothing is defined, use the * library default. */ - if (tilewidth == (uint32) -1) + if (tilewidth == (uint32_t) -1) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); - if (tilelength == (uint32) -1) + if (tilelength == (uint32_t) -1) TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); TIFFDefaultTileSize(out, &tilewidth, &tilelength); TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); @@ -745,20 +800,20 @@ tiffcp(TIFF* in, TIFF* out) * value from the input image or, if nothing is defined, * use the library default. */ - if (rowsperstrip == (uint32) 0) { + if (rowsperstrip == (uint32_t) 0) { if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) { rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); } - if (rowsperstrip > length && rowsperstrip != (uint32)-1) + if (rowsperstrip > length && rowsperstrip != (uint32_t)-1) rowsperstrip = length; } - else if (rowsperstrip == (uint32) -1) + else if (rowsperstrip == (uint32_t) -1) rowsperstrip = length; TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); } - if (config != (uint16) -1) + if (config != (uint16_t) -1) TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); else CopyField(TIFFTAG_PLANARCONFIG, config); @@ -777,12 +832,45 @@ tiffcp(TIFF* in, TIFF* out) CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); CopyTag(TIFFTAG_FAXDCS, 1, TIFF_ASCII); break; + case COMPRESSION_LERC: + if( max_z_error > 0 ) + { + if( TIFFSetField(out, TIFFTAG_LERC_MAXZERROR, max_z_error) != 1 ) + { + return FALSE; + } + } + if( subcodec != -1 ) + { + if( TIFFSetField(out, TIFFTAG_LERC_ADD_COMPRESSION, subcodec) != 1 ) + { + return FALSE; + } + } + if( preset != -1 ) + { + switch (subcodec) { + case LERC_ADD_COMPRESSION_DEFLATE: + if( TIFFSetField(out, TIFFTAG_ZIPQUALITY, preset) != 1 ) + { + return FALSE; + } + break; + case LERC_ADD_COMPRESSION_ZSTD: + if( TIFFSetField( out, TIFFTAG_ZSTD_LEVEL, preset ) != 1 ) + { + return FALSE; + } + break; + } + } + break; case COMPRESSION_LZW: case COMPRESSION_ADOBE_DEFLATE: case COMPRESSION_DEFLATE: case COMPRESSION_LZMA: case COMPRESSION_ZSTD: - if (predictor != (uint16)-1) + if (predictor != (uint16_t)-1) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); else CopyField(TIFFTAG_PREDICTOR, predictor); @@ -819,7 +907,7 @@ tiffcp(TIFF* in, TIFF* out) case COMPRESSION_CCITTFAX3: case COMPRESSION_CCITTFAX4: if (compression == COMPRESSION_CCITTFAX3) { - if (g3opts != (uint32) -1) + if (g3opts != (uint32_t) -1) TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); else @@ -835,13 +923,13 @@ tiffcp(TIFF* in, TIFF* out) break; } { - uint32 len32; + uint32_t len32; void** data; if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); } { - uint16 ninks; + uint16_t ninks; const char* inknames; if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); @@ -890,17 +978,17 @@ tiffcp(TIFF* in, TIFF* out) */ #define DECLAREcpFunc(x) \ static int x(TIFF* in, TIFF* out, \ - uint32 imagelength, uint32 imagewidth, tsample_t spp) + uint32_t imagelength, uint32_t imagewidth, tsample_t spp) #define DECLAREreadFunc(x) \ static int x(TIFF* in, \ - uint8* buf, uint32 imagelength, uint32 imagewidth, tsample_t spp) -typedef int (*readFunc)(TIFF*, uint8*, uint32, uint32, tsample_t); + uint8_t* buf, uint32_t imagelength, uint32_t imagewidth, tsample_t spp) +typedef int (*readFunc)(TIFF*, uint8_t*, uint32_t, uint32_t, tsample_t); #define DECLAREwriteFunc(x) \ static int x(TIFF* out, \ - uint8* buf, uint32 imagelength, uint32 imagewidth, tsample_t spp) -typedef int (*writeFunc)(TIFF*, uint8*, uint32, uint32, tsample_t); + uint8_t* buf, uint32_t imagelength, uint32_t imagewidth, tsample_t spp) +typedef int (*writeFunc)(TIFF*, uint8_t*, uint32_t, uint32_t, tsample_t); /* * Contig -> contig by scanline for rows/strip change. @@ -909,7 +997,7 @@ DECLAREcpFunc(cpContig2ContigByRow) { tsize_t scanlinesize = TIFFScanlineSize(in); tdata_t buf; - uint32 row; + uint32_t row; buf = limitMalloc(scanlinesize); if (!buf) @@ -919,14 +1007,14 @@ DECLAREcpFunc(cpContig2ContigByRow) for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } if (TIFFWriteScanline(out, buf, row, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -938,13 +1026,13 @@ bad: } -typedef void biasFn (void *image, void *bias, uint32 pixels); +typedef void biasFn (void *image, void *bias, uint32_t pixels); #define subtract(bits) \ -static void subtract##bits (void *i, void *b, uint32 pixels)\ +static void subtract##bits (void *i, void *b, uint32_t pixels)\ {\ - uint##bits *image = i;\ - uint##bits *bias = b;\ + uint##bits##_t *image = i;\ + uint##bits##_t *bias = b;\ while (pixels--) {\ *image = *image > *bias ? *image-*bias : 0;\ image++, bias++; \ @@ -974,39 +1062,39 @@ DECLAREcpFunc(cpBiasedContig2Contig) tsize_t biasSize = TIFFScanlineSize(bias); tsize_t bufSize = TIFFScanlineSize(in); tdata_t buf, biasBuf; - uint32 biasWidth = 0, biasLength = 0; + uint32_t biasWidth = 0, biasLength = 0; TIFFGetField(bias, TIFFTAG_IMAGEWIDTH, &biasWidth); TIFFGetField(bias, TIFFTAG_IMAGELENGTH, &biasLength); if (biasSize == bufSize && imagelength == biasLength && imagewidth == biasWidth) { - uint16 sampleBits = 0; + uint16_t sampleBits = 0; biasFn *subtractLine; TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &sampleBits); subtractLine = lineSubtractFn (sampleBits); if (subtractLine) { - uint32 row; + uint32_t row; buf = limitMalloc(bufSize); biasBuf = limitMalloc(bufSize); for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } if (TIFFReadScanline(bias, biasBuf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read biased scanline %lu", - (unsigned long) row); + "Error, can't read biased scanline %"PRIu32, + row); goto bad; } subtractLine (buf, biasBuf, imagewidth); if (TIFFWriteScanline(out, buf, row, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1022,19 +1110,19 @@ bad: return 0; } else { TIFFError(TIFFFileName(in), - "No support for biasing %d bit pixels\n", + "No support for biasing %"PRIu16" bit pixels\n", sampleBits); return 0; } } TIFFError(TIFFFileName(in), - "Bias image %s,%d\nis not the same size as %s,%d\n", + "Bias image %s,%"PRIu16"\nis not the same size as %s,%"PRIu16"\n", TIFFFileName(bias), TIFFCurrentDirectory(bias), TIFFFileName(in), TIFFCurrentDirectory(in)); return 0; } else { TIFFError(TIFFFileName(in), - "Can't bias %s,%d as it has >1 Sample/Pixel\n", + "Can't bias %s,%"PRIu16" as it has >1 Sample/Pixel\n", TIFFFileName(in), TIFFCurrentDirectory(in)); return 0; } @@ -1053,7 +1141,7 @@ DECLAREcpFunc(cpDecodedStrips) (void) imagewidth; (void) spp; if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); - uint32 row = 0; + uint32_t row = 0; _TIFFmemset(buf, 0, stripsize); for (s = 0; s < ns && row < imagelength; s++) { tsize_t cc = (row + rowsperstrip > imagelength) ? @@ -1061,14 +1149,14 @@ DECLAREcpFunc(cpDecodedStrips) if (TIFFReadEncodedStrip(in, s, buf, cc) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read strip %lu", - (unsigned long) s); + "Error, can't read strip %"PRIu32, + s); goto bad; } if (TIFFWriteEncodedStrip(out, s, buf, cc) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %lu", - (unsigned long) s); + "Error, can't write strip %"PRIu32, + s); goto bad; } row += rowsperstrip; @@ -1077,8 +1165,8 @@ DECLAREcpFunc(cpDecodedStrips) return 1; } else { TIFFError(TIFFFileName(in), - "Error, can't allocate memory buffer of size %lu " - "to read strips", (unsigned long) stripsize); + "Error, can't allocate memory buffer of size %"TIFF_SSIZE_FORMAT + " to read strips", stripsize); return 0; } @@ -1094,7 +1182,7 @@ DECLAREcpFunc(cpSeparate2SeparateByRow) { tsize_t scanlinesize = TIFFScanlineSize(in); tdata_t buf; - uint32 row; + uint32_t row; tsample_t s; (void) imagewidth; @@ -1106,14 +1194,14 @@ DECLAREcpFunc(cpSeparate2SeparateByRow) for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } if (TIFFWriteScanline(out, buf, row, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1134,11 +1222,11 @@ DECLAREcpFunc(cpContig2SeparateByRow) tsize_t scanlinesizeout = TIFFScanlineSize(out); tdata_t inbuf; tdata_t outbuf; - register uint8 *inp, *outp; - register uint32 n; - uint32 row; + register uint8_t *inp, *outp; + register uint32_t n; + uint32_t row; tsample_t s; - uint16 bps = 0; + uint16_t bps = 0; (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); if( bps != 8 ) @@ -1161,20 +1249,20 @@ DECLAREcpFunc(cpContig2SeparateByRow) if (TIFFReadScanline(in, inbuf, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } - inp = ((uint8*)inbuf) + s; - outp = (uint8*)outbuf; + inp = ((uint8_t*)inbuf) + s; + outp = (uint8_t*)outbuf; for (n = imagewidth; n-- > 0;) { *outp++ = *inp; inp += spp; } if (TIFFWriteScanline(out, outbuf, row, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1197,11 +1285,11 @@ DECLAREcpFunc(cpSeparate2ContigByRow) tsize_t scanlinesizeout = TIFFScanlineSize(out); tdata_t inbuf; tdata_t outbuf; - register uint8 *inp, *outp; - register uint32 n; - uint32 row; + register uint8_t *inp, *outp; + register uint32_t n; + uint32_t row; tsample_t s; - uint16 bps = 0; + uint16_t bps = 0; (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); if( bps != 8 ) @@ -1224,12 +1312,12 @@ DECLAREcpFunc(cpSeparate2ContigByRow) if (TIFFReadScanline(in, inbuf, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); goto bad; } - inp = (uint8*)inbuf; - outp = ((uint8*)outbuf) + s; + inp = (uint8_t*)inbuf; + outp = ((uint8_t*)outbuf) + s; for (n = imagewidth; n-- > 0;) { *outp = *inp++; outp += spp; @@ -1237,8 +1325,8 @@ DECLAREcpFunc(cpSeparate2ContigByRow) } if (TIFFWriteScanline(out, outbuf, row, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write scanline %lu", - (unsigned long) row); + "Error, can't write scanline %"PRIu32, + row); goto bad; } } @@ -1252,11 +1340,11 @@ bad: } static void -cpStripToTile(uint8* out, uint8* in, - uint32 rows, uint32 cols, int outskew, int64 inskew) +cpStripToTile(uint8_t* out, uint8_t* in, + uint32_t rows, uint32_t cols, int outskew, int64_t inskew) { while (rows-- > 0) { - uint32 j = cols; + uint32_t j = cols; while (j-- > 0) *out++ = *in++; out += outskew; @@ -1265,12 +1353,12 @@ cpStripToTile(uint8* out, uint8* in, } static void -cpContigBufToSeparateBuf(uint8* out, uint8* in, - uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp, - int bytes_per_sample ) +cpContigBufToSeparateBuf(uint8_t* out, uint8_t* in, + uint32_t rows, uint32_t cols, int outskew, int inskew, tsample_t spp, + int bytes_per_sample ) { while (rows-- > 0) { - uint32 j = cols; + uint32_t j = cols; while (j-- > 0) { int n = bytes_per_sample; @@ -1286,12 +1374,12 @@ cpContigBufToSeparateBuf(uint8* out, uint8* in, } static void -cpSeparateBufToContigBuf(uint8* out, uint8* in, - uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp, - int bytes_per_sample) +cpSeparateBufToContigBuf(uint8_t* out, uint8_t* in, + uint32_t rows, uint32_t cols, int outskew, int inskew, tsample_t spp, + int bytes_per_sample) { while (rows-- > 0) { - uint32 j = cols; + uint32_t j = cols; while (j-- > 0) { int n = bytes_per_sample; @@ -1307,7 +1395,7 @@ cpSeparateBufToContigBuf(uint8* out, uint8* in, static int cpImage(TIFF* in, TIFF* out, readFunc fin, writeFunc fout, - uint32 imagelength, uint32 imagewidth, tsample_t spp) + uint32_t imagelength, uint32_t imagewidth, tsample_t spp) { int status = 0; tdata_t buf = NULL; @@ -1321,9 +1409,9 @@ cpImage(TIFF* in, TIFF* out, readFunc fin, writeFunc fout, && bytes / (tsize_t)imagelength == scanlinesize) { buf = limitMalloc(bytes); if (buf) { - if ((*fin)(in, (uint8*)buf, imagelength, - imagewidth, spp)) { - status = (*fout)(out, (uint8*)buf, + if ((*fin)(in, (uint8_t*)buf, imagelength, + imagewidth, spp)) { + status = (*fout)(out, (uint8_t*)buf, imagelength, imagewidth, spp); } _TIFFfree(buf); @@ -1341,16 +1429,16 @@ cpImage(TIFF* in, TIFF* out, readFunc fin, writeFunc fout, DECLAREreadFunc(readContigStripsIntoBuffer) { tsize_t scanlinesize = TIFFScanlineSize(in); - uint8* bufp = buf; - uint32 row; + uint8_t* bufp = buf; + uint32_t row; (void) imagewidth; (void) spp; for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, (tdata_t) bufp, row, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); return 0; } bufp += scanlinesize; @@ -1373,21 +1461,21 @@ DECLAREreadFunc(readSeparateStripsIntoBuffer) _TIFFmemset(scanline, 0, scanlinesize); (void) imagewidth; if (scanline) { - uint8* bufp = (uint8*) buf; - uint32 row; + uint8_t* bufp = (uint8_t*) buf; + uint32_t row; tsample_t s; for (row = 0; row < imagelength; row++) { /* merge channels */ for (s = 0; s < spp; s++) { - uint8* bp = bufp + s; + uint8_t* bp = bufp + s; tsize_t n = scanlinesize; - uint8* sbuf = scanline; + uint8_t* sbuf = scanline; if (TIFFReadScanline(in, scanline, row, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read scanline %lu", - (unsigned long) row); + "Error, can't read scanline %"PRIu32, + row); status = 0; goto done; } @@ -1408,12 +1496,12 @@ DECLAREreadFunc(readContigTilesIntoBuffer) int status = 1; tsize_t tilesize = TIFFTileSize(in); tdata_t tilebuf; - uint32 imagew = TIFFScanlineSize(in); - uint32 tilew = TIFFTileRowSize(in); - int64 iskew = (int64)imagew - (int64)tilew; - uint8* bufp = (uint8*) buf; - uint32 tw, tl; - uint32 row; + uint32_t imagew = TIFFScanlineSize(in); + uint32_t tilew = TIFFTileRowSize(in); + int64_t iskew = (int64_t)imagew - (int64_t)tilew; + uint8_t* bufp = (uint8_t*) buf; + uint32_t tw, tl; + uint32_t row; (void) spp; tilebuf = limitMalloc(tilesize); @@ -1424,23 +1512,22 @@ DECLAREreadFunc(readContigTilesIntoBuffer) (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); for (row = 0; row < imagelength; row += tl) { - uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; - uint32 colb = 0; - uint32 col; + uint32_t nrow = (row + tl > imagelength) ? imagelength - row : tl; + uint32_t colb = 0; + uint32_t col; for (col = 0; col < imagewidth && colb < imagew; col += tw) { if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at %lu %lu", - (unsigned long) col, - (unsigned long) row); + "Error, can't read tile at %"PRIu32" %"PRIu32, + col, row); status = 0; goto done; } if (colb > iskew) { - uint32 width = imagew - colb; - uint32 oskew = tilew - width; + uint32_t width = imagew - colb; + uint32_t oskew = tilew - width; cpStripToTile(bufp + colb, tilebuf, nrow, width, oskew + iskew, oskew ); @@ -1460,15 +1547,15 @@ done: DECLAREreadFunc(readSeparateTilesIntoBuffer) { int status = 1; - uint32 imagew = TIFFRasterScanlineSize(in); - uint32 tilew = TIFFTileRowSize(in); + uint32_t imagew = TIFFRasterScanlineSize(in); + uint32_t tilew = TIFFTileRowSize(in); int iskew; tsize_t tilesize = TIFFTileSize(in); tdata_t tilebuf; - uint8* bufp = (uint8*) buf; - uint32 tw, tl; - uint32 row; - uint16 bps = 0, bytes_per_sample; + uint8_t* bufp = (uint8_t*) buf; + uint32_t tw, tl; + uint32_t row; + uint16_t bps = 0, bytes_per_sample; if (tilew && spp > (INT_MAX / tilew)) { @@ -1498,9 +1585,9 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer) bytes_per_sample = bps/8; for (row = 0; row < imagelength; row += tl) { - uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; - uint32 colb = 0; - uint32 col; + uint32_t nrow = (row + tl > imagelength) ? imagelength - row : tl; + uint32_t colb = 0; + uint32_t col; for (col = 0; col < imagewidth; col += tw) { tsample_t s; @@ -1509,11 +1596,9 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer) if (TIFFReadTile(in, tilebuf, col, row, 0, s) < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at %lu %lu, " - "sample %lu", - (unsigned long) col, - (unsigned long) row, - (unsigned long) s); + "Error, can't read tile at %"PRIu32" %"PRIu32", " + "sample %"PRIu16, + col, row, s); status = 0; goto done; } @@ -1522,7 +1607,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer) * visible portion and skewing factors. */ if (colb + tilew*spp > imagew) { - uint32 width = imagew - colb; + uint32_t width = imagew - colb; int oskew = tilew*spp - width; cpSeparateBufToContigBuf( bufp+colb+s*bytes_per_sample, @@ -1549,18 +1634,18 @@ done: DECLAREwriteFunc(writeBufferToContigStrips) { - uint32 row, rowsperstrip; + uint32_t row, rowsperstrip; tstrip_t strip = 0; (void) imagewidth; (void) spp; (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); for (row = 0; row < imagelength; row += rowsperstrip) { - uint32 nrows = (row+rowsperstrip > imagelength) ? + uint32_t nrows = (row + rowsperstrip > imagelength) ? imagelength-row : rowsperstrip; tsize_t stripsize = TIFFVStripSize(out, nrows); if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %u", strip - 1); + "Error, can't write strip %"PRIu32, strip - 1u); return 0; } buf += stripsize; @@ -1570,8 +1655,8 @@ DECLAREwriteFunc(writeBufferToContigStrips) DECLAREwriteFunc(writeBufferToSeparateStrips) { - uint32 rowsize = imagewidth * spp; - uint32 rowsperstrip; + uint32_t rowsize = imagewidth * spp; + uint32_t rowsperstrip; tsize_t stripsize = TIFFStripSize(out); tdata_t obuf; tstrip_t strip = 0; @@ -1583,19 +1668,19 @@ DECLAREwriteFunc(writeBufferToSeparateStrips) _TIFFmemset(obuf, 0, stripsize); (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); for (s = 0; s < spp; s++) { - uint32 row; + uint32_t row; for (row = 0; row < imagelength; row += rowsperstrip) { - uint32 nrows = (row+rowsperstrip > imagelength) ? + uint32_t nrows = (row + rowsperstrip > imagelength) ? imagelength-row : rowsperstrip; tsize_t stripsize = TIFFVStripSize(out, nrows); cpContigBufToSeparateBuf( - obuf, (uint8*) buf + row*rowsize + s, + obuf, (uint8_t*) buf + row * rowsize + s, nrows, imagewidth, 0, 0, spp, 1); if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write strip %u", - strip - 1); + "Error, can't write strip %"PRIu32, + strip - 1u); _TIFFfree(obuf); return 0; } @@ -1608,14 +1693,14 @@ DECLAREwriteFunc(writeBufferToSeparateStrips) DECLAREwriteFunc(writeBufferToContigTiles) { - uint32 imagew = TIFFScanlineSize(out); - uint32 tilew = TIFFTileRowSize(out); + uint32_t imagew = TIFFScanlineSize(out); + uint32_t tilew = TIFFTileRowSize(out); int iskew = imagew - tilew; tsize_t tilesize = TIFFTileSize(out); tdata_t obuf; - uint8* bufp = (uint8*) buf; - uint32 tl, tw; - uint32 row; + uint8_t* bufp = (uint8_t*) buf; + uint32_t tl, tw; + uint32_t row; (void) spp; @@ -1626,9 +1711,9 @@ DECLAREwriteFunc(writeBufferToContigTiles) (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); for (row = 0; row < imagelength; row += tilelength) { - uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; - uint32 colb = 0; - uint32 col; + uint32_t nrow = (row + tl > imagelength) ? imagelength - row : tl; + uint32_t colb = 0; + uint32_t col; for (col = 0; col < imagewidth && colb < imagew; col += tw) { /* @@ -1636,7 +1721,7 @@ DECLAREwriteFunc(writeBufferToContigTiles) * visible portion and skewing factors. */ if (colb + tilew > imagew) { - uint32 width = imagew - colb; + uint32_t width = imagew - colb; int oskew = tilew - width; cpStripToTile(obuf, bufp + colb, nrow, width, oskew, oskew + iskew); @@ -1645,9 +1730,8 @@ DECLAREwriteFunc(writeBufferToContigTiles) 0, iskew); if (TIFFWriteTile(out, obuf, col, row, 0, 0) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write tile at %lu %lu", - (unsigned long) col, - (unsigned long) row); + "Error, can't write tile at %"PRIu32" %"PRIu32, + col, row); _TIFFfree(obuf); return 0; } @@ -1661,16 +1745,16 @@ DECLAREwriteFunc(writeBufferToContigTiles) DECLAREwriteFunc(writeBufferToSeparateTiles) { - uint32 imagew = TIFFScanlineSize(out); + uint32_t imagew = TIFFScanlineSize(out); tsize_t tilew = TIFFTileRowSize(out); - uint32 iimagew = TIFFRasterScanlineSize(out); + uint32_t iimagew = TIFFRasterScanlineSize(out); int iskew = iimagew - tilew*spp; tsize_t tilesize = TIFFTileSize(out); tdata_t obuf; - uint8* bufp = (uint8*) buf; - uint32 tl, tw; - uint32 row; - uint16 bps = 0, bytes_per_sample; + uint8_t* bufp = (uint8_t*) buf; + uint32_t tl, tw; + uint32_t row; + uint16_t bps = 0, bytes_per_sample; obuf = limitMalloc(TIFFTileSize(out)); if (obuf == NULL) @@ -1694,9 +1778,9 @@ DECLAREwriteFunc(writeBufferToSeparateTiles) bytes_per_sample = bps/8; for (row = 0; row < imagelength; row += tl) { - uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; - uint32 colb = 0; - uint32 col; + uint32_t nrow = (row + tl > imagelength) ? imagelength - row : tl; + uint32_t colb = 0; + uint32_t col; for (col = 0; col < imagewidth; col += tw) { tsample_t s; @@ -1706,7 +1790,7 @@ DECLAREwriteFunc(writeBufferToSeparateTiles) * visible portion and skewing factors. */ if (colb + tilew > imagew) { - uint32 width = (imagew - colb); + uint32_t width = (imagew - colb); int oskew = tilew - width; cpContigBufToSeparateBuf(obuf, @@ -1722,11 +1806,9 @@ DECLAREwriteFunc(writeBufferToSeparateTiles) bytes_per_sample); if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) { TIFFError(TIFFFileName(out), - "Error, can't write tile at %lu %lu " - "sample %lu", - (unsigned long) col, - (unsigned long) row, - (unsigned long) s); + "Error, can't write tile at %"PRIu32" %"PRIu32 + " sample %"PRIu16, + col, row, s); _TIFFfree(obuf); return 0; } @@ -1875,10 +1957,10 @@ DECLAREcpFunc(cpSeparateTiles2SeparateStrips) * Select the appropriate copy function to use. */ static copyFunc -pickCopyFunc(TIFF* in, TIFF* out, uint16 bitspersample, uint16 samplesperpixel) +pickCopyFunc(TIFF* in, TIFF* out, uint16_t bitspersample, uint16_t samplesperpixel) { - uint16 shortv; - uint32 w, l, tw, tl; + uint16_t shortv; + uint32_t w, l, tw, tl; int bychunk; (void) TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &shortv); @@ -1891,7 +1973,7 @@ pickCopyFunc(TIFF* in, TIFF* out, uint16 bitspersample, uint16 samplesperpixel) TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &l); if (!(TIFFIsTiled(out) || TIFFIsTiled(in))) { - uint32 irps = (uint32) -1L; + uint32_t irps = (uint32_t) -1L; TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps); /* if biased, force decoded copying to allow image subtraction */ bychunk = !bias && (rowsperstrip == irps); diff --git a/tiff/tools/tiffcrop.c b/tiff/tools/tiffcrop.c index d20b585a..b85c2ce7 100644 --- a/tiff/tools/tiffcrop.c +++ b/tiff/tools/tiffcrop.c @@ -102,17 +102,19 @@ * includes annotations for image parameters and scanline info. Level * selects which functions dump data, with higher numbers selecting * lower level, scanline level routines. Debug reports a limited set - * of messages to monitor progess without enabling dump logs. + * of messages to monitor progress without enabling dump logs. */ static char tiffcrop_version_id[] = "2.4"; static char tiffcrop_rev_date[] = "12-13-2010"; #include "tif_config.h" +#include "libport.h" #include "tiffiop.h" #include <stdio.h> #include <stdlib.h> +#include <stdint.h> #include <string.h> #include <math.h> #include <ctype.h> @@ -124,10 +126,6 @@ static char tiffcrop_rev_date[] = "12-13-2010"; # include <unistd.h> #endif -#ifdef HAVE_STDINT_H -# include <stdint.h> -#endif - #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif @@ -135,32 +133,18 @@ static char tiffcrop_rev_date[] = "12-13-2010"; #define EXIT_FAILURE 1 #endif -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" -#if defined(VMS) -# define unlink delete -#endif - #ifndef PATH_MAX #define PATH_MAX 1024 #endif -#define TIFF_UINT32_MAX 0xFFFFFFFFU - #define TRUE 1 #define FALSE 0 #ifndef TIFFhowmany -#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) -#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) +#define TIFFhowmany(x, y) ((((uint32_t)(x))+(((uint32_t)(y))-1))/((uint32_t)(y))) +#define TIFFhowmany8(x) (((x)&0x07)?((uint32_t)(x)>>3)+1:(uint32_t)(x)>>3) #endif /* @@ -221,16 +205,16 @@ extern int getopt(int argc, char * const argv[], const char *optstring); /* Offsets into buffer for margins and fixed width and length segments */ struct offset { - uint32 tmargin; - uint32 lmargin; - uint32 bmargin; - uint32 rmargin; - uint32 crop_width; - uint32 crop_length; - uint32 startx; - uint32 endx; - uint32 starty; - uint32 endy; + uint32_t tmargin; + uint32_t lmargin; + uint32_t bmargin; + uint32_t rmargin; + uint32_t crop_width; + uint32_t crop_length; + uint32_t startx; + uint32_t endx; + uint32_t starty; + uint32_t endy; }; /* Description of a zone within the image. Position 1 of 3 zones would be @@ -240,7 +224,7 @@ struct offset { */ struct buffinfo { - uint32 size; /* size of this buffer */ + uint32_t size; /* size of this buffer */ unsigned char *buffer; /* address of the allocated buffer */ }; @@ -250,13 +234,13 @@ struct zone { }; struct pageseg { - uint32 x1; /* index of left edge */ - uint32 x2; /* index of right edge */ - uint32 y1; /* index of top edge */ - uint32 y2; /* index of bottom edge */ + uint32_t x1; /* index of left edge */ + uint32_t x2; /* index of right edge */ + uint32_t y1; /* index of top edge */ + uint32_t y2; /* index of bottom edge */ int position; /* ordinal of segment to be extracted */ int total; /* total equal sized divisions of crop area */ - uint32 buffsize; /* size of buffer needed to hold the cropped zone */ + uint32_t buffsize; /* size of buffer needed to hold the cropped zone */ }; struct coordpairs { @@ -267,13 +251,13 @@ struct coordpairs { }; struct region { - uint32 x1; /* pixel offset of left edge */ - uint32 x2; /* pixel offset of right edge */ - uint32 y1; /* pixel offset of top edge */ - uint32 y2; /* picel offset of bottom edge */ - uint32 width; /* width in pixels */ - uint32 length; /* length in pixels */ - uint32 buffsize; /* size of buffer needed to hold the cropped region */ + uint32_t x1; /* pixel offset of left edge */ + uint32_t x2; /* pixel offset of right edge */ + uint32_t y1; /* pixel offset of top edge */ + uint32_t y2; /* picel offset of bottom edge */ + uint32_t width; /* width in pixels */ + uint32_t length; /* length in pixels */ + uint32_t buffsize; /* size of buffer needed to hold the cropped region */ unsigned char *buffptr; /* address of start of the region */ }; @@ -287,27 +271,27 @@ struct crop_mask { double margins[4]; /* Top, left, bottom, right margins */ float xres; /* Horizontal resolution read from image*/ float yres; /* Vertical resolution read from image */ - uint32 combined_width; /* Width of combined cropped zones */ - uint32 combined_length; /* Length of combined cropped zones */ - uint32 bufftotal; /* Size of buffer needed to hold all the cropped region */ - uint16 img_mode; /* Composite or separate images created from zones or regions */ - uint16 exp_mode; /* Export input images or selections to one or more files */ - uint16 crop_mode; /* Crop options to be applied */ - uint16 res_unit; /* Resolution unit for margins and selections */ - uint16 edge_ref; /* Reference edge for sections extraction and combination */ - uint16 rotation; /* Clockwise rotation of the extracted region or image */ - uint16 mirror; /* Mirror extracted region or image horizontally or vertically */ - uint16 invert; /* Invert the color map of image or region */ - uint16 photometric; /* Status of photometric interpretation for inverted image */ - uint16 selections; /* Number of regions or zones selected */ - uint16 regions; /* Number of regions delimited by corner coordinates */ + uint32_t combined_width; /* Width of combined cropped zones */ + uint32_t combined_length; /* Length of combined cropped zones */ + uint32_t bufftotal; /* Size of buffer needed to hold all the cropped region */ + uint16_t img_mode; /* Composite or separate images created from zones or regions */ + uint16_t exp_mode; /* Export input images or selections to one or more files */ + uint16_t crop_mode; /* Crop options to be applied */ + uint16_t res_unit; /* Resolution unit for margins and selections */ + uint16_t edge_ref; /* Reference edge for sections extraction and combination */ + uint16_t rotation; /* Clockwise rotation of the extracted region or image */ + uint16_t mirror; /* Mirror extracted region or image horizontally or vertically */ + uint16_t invert; /* Invert the color map of image or region */ + uint16_t photometric; /* Status of photometric interpretation for inverted image */ + uint16_t selections; /* Number of regions or zones selected */ + uint16_t regions; /* Number of regions delimited by corner coordinates */ struct region regionlist[MAX_REGIONS]; /* Regions within page or master crop region */ - uint16 zones; /* Number of zones delimited by Ordinal:Total requested */ + uint16_t zones; /* Number of zones delimited by Ordinal:Total requested */ struct zone zonelist[MAX_REGIONS]; /* Zones indices to define a region */ struct coordpairs corners[MAX_REGIONS]; /* Coordinates of upper left and lower right corner */ }; -#define MAX_PAPERNAMES 49 +#define MAX_PAPERNAMES (sizeof(PaperTable)/sizeof(PaperTable[0])) /* was 49 */ #define MAX_PAPERNAME_LENGTH 15 #define DEFAULT_RESUNIT RESUNIT_INCH #define DEFAULT_PAGE_HEIGHT 14.0 @@ -340,7 +324,7 @@ struct paperdef { /* European page sizes corrected from update sent by * thomas . jarosch @ intra2net . com on 5/7/2010 * Paper Size Width Length Aspect Ratio */ -const struct paperdef PaperTable[MAX_PAPERNAMES] = { +static const struct paperdef PaperTable[/*MAX_PAPERNAMES*/] = { {"default", 8.500, 14.000, 0.607}, {"pa4", 8.264, 11.000, 0.751}, {"letter", 8.500, 11.000, 0.773}, @@ -396,16 +380,16 @@ const struct paperdef PaperTable[MAX_PAPERNAMES] = { struct image_data { float xres; float yres; - uint32 width; - uint32 length; - uint16 res_unit; - uint16 bps; - uint16 spp; - uint16 planar; - uint16 photometric; - uint16 orientation; - uint16 compression; - uint16 adjustments; + uint32_t width; + uint32_t length; + uint16_t res_unit; + uint16_t bps; + uint16_t spp; + uint16_t planar; + uint16_t photometric; + uint16_t orientation; + uint16_t compression; + uint16_t adjustments; }; /* Structure to define the output image modifiers */ @@ -417,8 +401,8 @@ struct pagedef { double vmargin; /* margins to subtract from height of sections */ double hres; /* horizontal resolution for output */ double vres; /* vertical resolution for output */ - uint32 mode; /* bitmask of modifiers to page format */ - uint16 res_unit; /* resolution unit for output image */ + uint32_t mode; /* bitmask of modifiers to page format */ + uint16_t res_unit; /* resolution unit for output image */ unsigned int rows; /* number of section rows */ unsigned int cols; /* number of section cols */ unsigned int orient; /* portrait, landscape, seascape, auto */ @@ -437,36 +421,36 @@ struct dump_opts { /* globals */ static int outtiled = -1; -static uint32 tilewidth = 0; -static uint32 tilelength = 0; - -static uint16 config = 0; -static uint16 compression = 0; -static uint16 predictor = 0; -static uint16 fillorder = 0; -static uint32 rowsperstrip = 0; -static uint32 g3opts = 0; +static uint32_t tilewidth = 0; +static uint32_t tilelength = 0; + +static uint16_t config = 0; +static uint16_t compression = 0; +static uint16_t predictor = 0; +static uint16_t fillorder = 0; +static uint32_t rowsperstrip = 0; +static uint32_t g3opts = 0; static int ignore = FALSE; /* if true, ignore read errors */ -static uint32 defg3opts = (uint32) -1; +static uint32_t defg3opts = (uint32_t) -1; static int quality = 100; /* JPEG quality */ /* static int jpegcolormode = -1; was JPEGCOLORMODE_RGB; */ static int jpegcolormode = JPEGCOLORMODE_RGB; -static uint16 defcompression = (uint16) -1; -static uint16 defpredictor = (uint16) -1; +static uint16_t defcompression = (uint16_t) -1; +static uint16_t defpredictor = (uint16_t) -1; static int pageNum = 0; static int little_endian = 1; /* Functions adapted from tiffcp with additions or significant modifications */ -static int readContigStripsIntoBuffer (TIFF*, uint8*); -static int readSeparateStripsIntoBuffer (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); -static int readContigTilesIntoBuffer (TIFF*, uint8*, uint32, uint32, uint32, uint32, tsample_t, uint16); -static int readSeparateTilesIntoBuffer (TIFF*, uint8*, uint32, uint32, uint32, uint32, tsample_t, uint16); -static int writeBufferToContigStrips (TIFF*, uint8*, uint32); -static int writeBufferToContigTiles (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); -static int writeBufferToSeparateStrips (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); -static int writeBufferToSeparateTiles (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); -static int extractContigSamplesToBuffer (uint8 *, uint8 *, uint32, uint32, tsample_t, - uint16, uint16, struct dump_opts *); +static int readContigStripsIntoBuffer (TIFF*, uint8_t*); +static int readSeparateStripsIntoBuffer (TIFF*, uint8_t*, uint32_t, uint32_t, tsample_t, struct dump_opts *); +static int readContigTilesIntoBuffer (TIFF*, uint8_t*, uint32_t, uint32_t, uint32_t, uint32_t, tsample_t, uint16_t); +static int readSeparateTilesIntoBuffer (TIFF*, uint8_t*, uint32_t, uint32_t, uint32_t, uint32_t, tsample_t, uint16_t); +static int writeBufferToContigStrips (TIFF*, uint8_t*, uint32_t); +static int writeBufferToContigTiles (TIFF*, uint8_t*, uint32_t, uint32_t, tsample_t, struct dump_opts *); +static int writeBufferToSeparateStrips (TIFF*, uint8_t*, uint32_t, uint32_t, tsample_t, struct dump_opts *); +static int writeBufferToSeparateTiles (TIFF*, uint8_t*, uint32_t, uint32_t, tsample_t, struct dump_opts *); +static int extractContigSamplesToBuffer (uint8_t *, uint8_t *, uint32_t, uint32_t, tsample_t, + uint16_t, uint16_t, struct dump_opts *); static int processCompressOptions(char*); static void usage(int code); @@ -477,10 +461,10 @@ static void initPageSetup (struct pagedef *, struct pageseg *, struct buffinfo [ static void initDumpOptions(struct dump_opts *); /* Command line and file naming functions */ -void process_command_opts (int, char *[], char *, char *, uint32 *, - uint16 *, uint16 *, uint32 *, uint32 *, uint32 *, - struct crop_mask *, struct pagedef *, - struct dump_opts *, +void process_command_opts (int, char *[], char *, char *, uint32_t *, + uint16_t *, uint16_t *, uint32_t *, uint32_t *, uint32_t *, + struct crop_mask *, struct pagedef *, + struct dump_opts *, unsigned int *, unsigned int *); static int update_output_file (TIFF **, char *, int, char *, unsigned int *); @@ -502,12 +486,12 @@ static int writeSelections(TIFF *, TIFF **, struct crop_mask *, struct image_da char *, char *, unsigned int*, unsigned int); /* Section functions */ -static int createImageSection(uint32, unsigned char **); +static int createImageSection(uint32_t, unsigned char **); static int extractImageSection(struct image_data *, struct pageseg *, unsigned char *, unsigned char *); static int writeSingleSection(TIFF *, TIFF *, struct image_data *, - struct dump_opts *, uint32, uint32, - double, double, unsigned char *); + struct dump_opts *, uint32_t, uint32_t, + double, double, unsigned char *); static int writeImageSections(TIFF *, TIFF *, struct image_data *, struct pagedef *, struct pageseg *, struct dump_opts *, unsigned char *, @@ -517,108 +501,108 @@ static int createCroppedImage(struct image_data *, struct crop_mask *, unsigned char **, unsigned char **); static int writeCroppedImage(TIFF *, TIFF *, struct image_data *image, struct dump_opts * dump, - uint32, uint32, unsigned char *, int, int); + uint32_t, uint32_t, unsigned char *, int, int); /* Image manipulation functions */ -static int rotateContigSamples8bits(uint16, uint16, uint16, uint32, - uint32, uint32, uint8 *, uint8 *); -static int rotateContigSamples16bits(uint16, uint16, uint16, uint32, - uint32, uint32, uint8 *, uint8 *); -static int rotateContigSamples24bits(uint16, uint16, uint16, uint32, - uint32, uint32, uint8 *, uint8 *); -static int rotateContigSamples32bits(uint16, uint16, uint16, uint32, - uint32, uint32, uint8 *, uint8 *); -static int rotateImage(uint16, struct image_data *, uint32 *, uint32 *, - unsigned char **); -static int mirrorImage(uint16, uint16, uint16, uint32, uint32, - unsigned char *); -static int invertImage(uint16, uint16, uint16, uint32, uint32, - unsigned char *); +static int rotateContigSamples8bits(uint16_t, uint16_t, uint16_t, uint32_t, + uint32_t, uint32_t, uint8_t *, uint8_t *); +static int rotateContigSamples16bits(uint16_t, uint16_t, uint16_t, uint32_t, + uint32_t, uint32_t, uint8_t *, uint8_t *); +static int rotateContigSamples24bits(uint16_t, uint16_t, uint16_t, uint32_t, + uint32_t, uint32_t, uint8_t *, uint8_t *); +static int rotateContigSamples32bits(uint16_t, uint16_t, uint16_t, uint32_t, + uint32_t, uint32_t, uint8_t *, uint8_t *); +static int rotateImage(uint16_t, struct image_data *, uint32_t *, uint32_t *, + unsigned char **); +static int mirrorImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t, + unsigned char *); +static int invertImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t, + unsigned char *); /* Functions to reverse the sequence of samples in a scanline */ -static int reverseSamples8bits (uint16, uint16, uint32, uint8 *, uint8 *); -static int reverseSamples16bits (uint16, uint16, uint32, uint8 *, uint8 *); -static int reverseSamples24bits (uint16, uint16, uint32, uint8 *, uint8 *); -static int reverseSamples32bits (uint16, uint16, uint32, uint8 *, uint8 *); -static int reverseSamplesBytes (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamples8bits (uint16_t, uint16_t, uint32_t, uint8_t *, uint8_t *); +static int reverseSamples16bits (uint16_t, uint16_t, uint32_t, uint8_t *, uint8_t *); +static int reverseSamples24bits (uint16_t, uint16_t, uint32_t, uint8_t *, uint8_t *); +static int reverseSamples32bits (uint16_t, uint16_t, uint32_t, uint8_t *, uint8_t *); +static int reverseSamplesBytes (uint16_t, uint16_t, uint32_t, uint8_t *, uint8_t *); /* Functions for manipulating individual samples in an image */ static int extractSeparateRegion(struct image_data *, struct crop_mask *, unsigned char *, unsigned char *, int); static int extractCompositeRegions(struct image_data *, struct crop_mask *, unsigned char *, unsigned char *); -static int extractContigSamples8bits (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32); -static int extractContigSamples16bits (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32); -static int extractContigSamples24bits (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32); -static int extractContigSamples32bits (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32); -static int extractContigSamplesBytes (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32); -static int extractContigSamplesShifted8bits (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32, +static int extractContigSamples8bits (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t); +static int extractContigSamples16bits (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t); +static int extractContigSamples24bits (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t); +static int extractContigSamples32bits (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t); +static int extractContigSamplesBytes (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t); +static int extractContigSamplesShifted8bits (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t, int); -static int extractContigSamplesShifted16bits (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32, +static int extractContigSamplesShifted16bits (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t, int); -static int extractContigSamplesShifted24bits (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32, +static int extractContigSamplesShifted24bits (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t, int); -static int extractContigSamplesShifted32bits (uint8 *, uint8 *, uint32, - tsample_t, uint16, uint16, - tsample_t, uint32, uint32, +static int extractContigSamplesShifted32bits (uint8_t *, uint8_t *, uint32_t, + tsample_t, uint16_t, uint16_t, + tsample_t, uint32_t, uint32_t, int); -static int extractContigSamplesToTileBuffer(uint8 *, uint8 *, uint32, uint32, - uint32, uint32, tsample_t, uint16, - uint16, uint16, struct dump_opts *); +static int extractContigSamplesToTileBuffer(uint8_t *, uint8_t *, uint32_t, uint32_t, + uint32_t, uint32_t, tsample_t, uint16_t, + uint16_t, uint16_t, struct dump_opts *); /* Functions to combine separate planes into interleaved planes */ -static int combineSeparateSamples8bits (uint8 *[], uint8 *, uint32, uint32, - uint16, uint16, FILE *, int, int); -static int combineSeparateSamples16bits (uint8 *[], uint8 *, uint32, uint32, - uint16, uint16, FILE *, int, int); -static int combineSeparateSamples24bits (uint8 *[], uint8 *, uint32, uint32, - uint16, uint16, FILE *, int, int); -static int combineSeparateSamples32bits (uint8 *[], uint8 *, uint32, uint32, - uint16, uint16, FILE *, int, int); +static int combineSeparateSamples8bits (uint8_t *[], uint8_t *, uint32_t, uint32_t, + uint16_t, uint16_t, FILE *, int, int); +static int combineSeparateSamples16bits (uint8_t *[], uint8_t *, uint32_t, uint32_t, + uint16_t, uint16_t, FILE *, int, int); +static int combineSeparateSamples24bits (uint8_t *[], uint8_t *, uint32_t, uint32_t, + uint16_t, uint16_t, FILE *, int, int); +static int combineSeparateSamples32bits (uint8_t *[], uint8_t *, uint32_t, uint32_t, + uint16_t, uint16_t, FILE *, int, int); static int combineSeparateSamplesBytes (unsigned char *[], unsigned char *, - uint32, uint32, tsample_t, uint16, + uint32_t, uint32_t, tsample_t, uint16_t, FILE *, int, int); -static int combineSeparateTileSamples8bits (uint8 *[], uint8 *, uint32, uint32, - uint32, uint32, uint16, uint16, +static int combineSeparateTileSamples8bits (uint8_t *[], uint8_t *, uint32_t, uint32_t, + uint32_t, uint32_t, uint16_t, uint16_t, FILE *, int, int); -static int combineSeparateTileSamples16bits (uint8 *[], uint8 *, uint32, uint32, - uint32, uint32, uint16, uint16, +static int combineSeparateTileSamples16bits (uint8_t *[], uint8_t *, uint32_t, uint32_t, + uint32_t, uint32_t, uint16_t, uint16_t, FILE *, int, int); -static int combineSeparateTileSamples24bits (uint8 *[], uint8 *, uint32, uint32, - uint32, uint32, uint16, uint16, +static int combineSeparateTileSamples24bits (uint8_t *[], uint8_t *, uint32_t, uint32_t, + uint32_t, uint32_t, uint16_t, uint16_t, FILE *, int, int); -static int combineSeparateTileSamples32bits (uint8 *[], uint8 *, uint32, uint32, - uint32, uint32, uint16, uint16, +static int combineSeparateTileSamples32bits (uint8_t *[], uint8_t *, uint32_t, uint32_t, + uint32_t, uint32_t, uint16_t, uint16_t, FILE *, int, int); static int combineSeparateTileSamplesBytes (unsigned char *[], unsigned char *, - uint32, uint32, uint32, uint32, - tsample_t, uint16, FILE *, int, int); + uint32_t, uint32_t, uint32_t, uint32_t, + tsample_t, uint16_t, FILE *, int, int); /* Dump functions for debugging */ static void dump_info (FILE *, int, char *, char *, ...); -static int dump_data (FILE *, int, char *, unsigned char *, uint32); +static int dump_data (FILE *, int, char *, unsigned char *, uint32_t); static int dump_byte (FILE *, int, char *, unsigned char); -static int dump_short (FILE *, int, char *, uint16); -static int dump_long (FILE *, int, char *, uint32); -static int dump_wide (FILE *, int, char *, uint64); -static int dump_buffer (FILE *, int, uint32, uint32, uint32, unsigned char *); +static int dump_short (FILE *, int, char *, uint16_t); +static int dump_long (FILE *, int, char *, uint32_t); +static int dump_wide (FILE *, int, char *, uint64_t); +static int dump_buffer (FILE *, int, uint32_t, uint32_t, uint32_t, unsigned char *); /* End function declarations */ /* Functions derived in whole or in part from tiffcp */ @@ -636,8 +620,8 @@ static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ".\n", - (uint64)s, (uint64)maxMalloc); + fprintf(stderr, "MemoryLimitError: allocation of %" PRIu64 " bytes is forbidden. Limit is %" PRIu64 ".\n", + (uint64_t)s, (uint64_t)maxMalloc); fprintf(stderr, " use -k option to change limit.\n"); return NULL; } return _TIFFmalloc(s); @@ -645,165 +629,176 @@ static void* limitMalloc(tmsize_t s) -static const char* usage_info[] = { -"usage: tiffcrop [options] source1 ... sourceN destination", -"where options are:", -" -h Print this syntax listing", -" -v Print tiffcrop version identifier and last revision date", -" ", -" -a Append to output instead of overwriting", -" -d offset Set initial directory offset, counting first image as one, not zero", -" -p contig Pack samples contiguously (e.g. RGBRGB...)", -" -p separate Store samples separately (e.g. RRR...GGG...BBB...)", -" -s Write output in strips", -" -t Write output in tiles", -" -i Ignore read errors", -" -k size set the memory allocation limit in MiB. 0 to disable limit", -" ", -" -r # Make each strip have no more than # rows", -" -w # Set output tile width (pixels)", -" -l # Set output tile length (pixels)", -" ", -" -f lsb2msb Force lsb-to-msb FillOrder for output", -" -f msb2lsb Force msb-to-lsb FillOrder for output", -"", -" -c lzw[:opts] Compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] Compress output with deflate encoding", -" -c jpeg[:opts] Compress output with JPEG encoding", -" -c packbits Compress output with packbits encoding", -" -c g3[:opts] Compress output with CCITT Group 3 encoding", -" -c g4 Compress output with CCITT Group 4 encoding", -" -c none Use no compression algorithm on output", -" ", -"Group 3 options:", -" 1d Use default CCITT Group 3 1D-encoding", -" 2d Use optional CCITT Group 3 2D-encoding", -" fill Byte-align EOL codes", -"For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", -" ", -"JPEG options:", -" # Set compression quality level (0-100, default 100)", -" raw Output color image as raw YCbCr", -" rgb Output color image as RGB", -"For example, -c jpeg:rgb:50 to get JPEG-encoded RGB data with 50% comp. quality", -" ", -"LZW and deflate options:", -" # Set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", -" ", -"Page and selection options:", -" -N odd|even|#,#-#,#|last sequences and ranges of images within file to process", -" The words odd or even may be used to specify all odd or even numbered images.", -" The word last may be used in place of a number in the sequence to indicate.", -" The final image in the file without knowing how many images there are.", -" Numbers are counted from one even though TIFF IFDs are counted from zero.", -" ", -" -E t|l|r|b edge to use as origin for width and length of crop region", -" -U units [in, cm, px ] inches, centimeters or pixels", -" ", -" -m #,#,#,# margins from edges for selection: top, left, bottom, right separated by commas", -" -X # horizontal dimension of region to extract expressed in current units", -" -Y # vertical dimension of region to extract expressed in current units", -" -Z #:#,#:# zones of the image designated as position X of Y,", -" eg 1:3 would be first of three equal portions measured from reference edge", -" -z x1,y1,x2,y2:...:xN,yN,xN+1,yN+1", -" regions of the image designated by upper left and lower right coordinates", -"", -"Export grouping options:", -" -e c|d|i|m|s export mode for images and selections from input images.", -" When exporting a composite image from multiple zones or regions", -" (combined and image modes), the selections must have equal sizes", -" for the axis perpendicular to the edge specified with -E.", -" c|combined All images and selections are written to a single file (default).", -" with multiple selections from one image combined into a single image.", -" d|divided All images and selections are written to a single file", -" with each selection from one image written to a new image.", -" i|image Each input image is written to a new file (numeric filename sequence)", -" with multiple selections from the image combined into one image.", -" m|multiple Each input image is written to a new file (numeric filename sequence)", -" with each selection from the image written to a new image.", -" s|separated Individual selections from each image are written to separate files.", -"", -"Output options:", -" -H # Set horizontal resolution of output images to #", -" -V # Set vertical resolution of output images to #", -" -J # Set horizontal margin of output page to # expressed in current units", -" when sectioning image into columns x rows using the -S cols:rows option", -" -K # Set verticalal margin of output page to # expressed in current units", -" when sectioning image into columns x rows using the -S cols:rows option", -" ", -" -O orient orientation for output image, portrait, landscape, auto", -" -P page page size for output image segments, eg letter, legal, tabloid, etc", -" use #.#x#.# to specify a custom page size in the currently defined units", -" where #.# represents the width and length", -" -S cols:rows Divide the image into equal sized segments using cols across and rows down.", -" ", -" -F hor|vert|both", -" flip (mirror) image or region horizontally, vertically, or both", -" -R # [90,180,or 270] degrees clockwise rotation of image or extracted region", -" -I [black|white|data|both]", -" invert color space, eg dark to light for bilevel and grayscale images", -" If argument is white or black, set the PHOTOMETRIC_INTERPRETATION ", -" tag to MinIsBlack or MinIsWhite without altering the image data", -" If the argument is data or both, the image data are modified:", -" both inverts the data and the PHOTOMETRIC_INTERPRETATION tag,", -" data inverts the data but not the PHOTOMETRIC_INTERPRETATION tag", -" ", -"-D opt1:value1,opt2:value2,opt3:value3:opt4:value4", -" Debug/dump program progress and/or data to non-TIFF files.", -" Options include the following and must be joined as a comma", -" separate list. The use of this option is generally limited to", -" program debugging and development of future options.", -" ", -" debug:N Display limited program progress indicators where larger N", -" increase the level of detail. Note: Tiffcrop may be compiled with", -" -DDEVELMODE to enable additional very low level debug reporting.", -"", -" Format:txt|raw Format any logged data as ASCII text or raw binary ", -" values. ASCII text dumps include strings of ones and zeroes", -" representing the binary values in the image data plus identifying headers.", -" ", -" level:N Specify the level of detail presented in the dump files.", -" This can vary from dumps of the entire input or output image data to dumps", -" of data processed by specific functions. Current range of levels is 1 to 3.", -" ", -" input:full-path-to-directory/input-dumpname", -" ", -" output:full-path-to-directory/output-dumpnaem", -" ", -" When dump files are being written, each image will be written to a separate", -" file with the name built by adding a numeric sequence value to the dumpname", -" and an extension of .txt for ASCII dumps or .bin for binary dumps.", -" ", -" The four debug/dump options are independent, though it makes little sense to", -" specify a dump file without specifying a detail level.", -" ", -NULL -}; +static const char usage_info[] = +"Copy, crop, convert, extract, and/or process TIFF files\n\n" +"usage: tiffcrop [options] source1 ... sourceN destination\n" +"where options are:\n" +" -h Print this syntax listing\n" +" -v Print tiffcrop version identifier and last revision date\n" +" \n" +" -a Append to output instead of overwriting\n" +" -d offset Set initial directory offset, counting first image as one, not zero\n" +" -p contig Pack samples contiguously (e.g. RGBRGB...)\n" +" -p separate Store samples separately (e.g. RRR...GGG...BBB...)\n" +" -s Write output in strips\n" +" -t Write output in tiles\n" +" -i Ignore read errors\n" +" -k size set the memory allocation limit in MiB. 0 to disable limit\n" +" \n" +" -r # Make each strip have no more than # rows\n" +" -w # Set output tile width (pixels)\n" +" -l # Set output tile length (pixels)\n" +" \n" +" -f lsb2msb Force lsb-to-msb FillOrder for output\n" +" -f msb2lsb Force msb-to-lsb FillOrder for output\n" +"\n" +#ifdef LZW_SUPPORT +" -c lzw[:opts] Compress output with Lempel-Ziv & Welch encoding\n" +/* " LZW options:\n" */ +" # Set predictor value\n" +" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip[:opts] Compress output with deflate encoding\n" +/* " Deflate (ZIP) options:\n" */ +" # Set predictor value\n" +#endif +#ifdef JPEG_SUPPORT +" -c jpeg[:opts] Compress output with JPEG encoding\n" +/* " JPEG options:\n" */ +" # Set compression quality level (0-100, default 100)\n" +" raw Output color image as raw YCbCr (default)\n" +" rgb Output color image as RGB\n" +" For example, -c jpeg:rgb:50 for JPEG-encoded RGB with 50% comp. quality\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits Compress output with packbits encoding\n" +#endif +#ifdef CCITT_SUPPORT +" -c g3[:opts] Compress output with CCITT Group 3 encoding\n" +/* " CCITT Group 3 options:\n" */ +" 1d Use default CCITT Group 3 1D-encoding\n" +" 2d Use optional CCITT Group 3 2D-encoding\n" +" fill Byte-align EOL codes\n" +" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs\n" +" -c g4 Compress output with CCITT Group 4 encoding\n" +#endif +#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(JPEG_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) +" -c none Use no compression algorithm on output\n" +#endif +"\n" +"Page and selection options:\n" +" -N odd|even|#,#-#,#|last sequences and ranges of images within file to process\n" +" The words odd or even may be used to specify all odd or even numbered images.\n" +" The word last may be used in place of a number in the sequence to indicate.\n" +" The final image in the file without knowing how many images there are.\n" +" Numbers are counted from one even though TIFF IFDs are counted from zero.\n" +"\n" +" -E t|l|r|b edge to use as origin for width and length of crop region\n" +" -U units [in, cm, px ] inches, centimeters or pixels\n" +" \n" +" -m #,#,#,# margins from edges for selection: top, left, bottom, right separated by commas\n" +" -X # horizontal dimension of region to extract expressed in current units\n" +" -Y # vertical dimension of region to extract expressed in current units\n" +" -Z #:#,#:# zones of the image designated as position X of Y,\n" +" eg 1:3 would be first of three equal portions measured from reference edge\n" +" -z x1,y1,x2,y2:...:xN,yN,xN+1,yN+1\n" +" regions of the image designated by upper left and lower right coordinates\n" +"\n" +"Export grouping options:\n" +" -e c|d|i|m|s export mode for images and selections from input images.\n" +" When exporting a composite image from multiple zones or regions\n" +" (combined and image modes), the selections must have equal sizes\n" +" for the axis perpendicular to the edge specified with -E.\n" +" c|combined All images and selections are written to a single file (default).\n" +" with multiple selections from one image combined into a single image.\n" +" d|divided All images and selections are written to a single file\n" +" with each selection from one image written to a new image.\n" +" i|image Each input image is written to a new file (numeric filename sequence)\n" +" with multiple selections from the image combined into one image.\n" +" m|multiple Each input image is written to a new file (numeric filename sequence)\n" +" with each selection from the image written to a new image.\n" +" s|separated Individual selections from each image are written to separate files.\n" +"\n" +"Output options:\n" +" -H # Set horizontal resolution of output images to #\n" +" -V # Set vertical resolution of output images to #\n" +" -J # Set horizontal margin of output page to # expressed in current units\n" +" when sectioning image into columns x rows using the -S cols:rows option\n" +" -K # Set verticalal margin of output page to # expressed in current units\n" +" when sectioning image into columns x rows using the -S cols:rows option\n" +" \n" +" -O orient orientation for output image, portrait, landscape, auto\n" +" -P page page size for output image segments, eg letter, legal, tabloid, etc\n" +" use #.#x#.# to specify a custom page size in the currently defined units\n" +" where #.# represents the width and length\n" +" -S cols:rows Divide the image into equal sized segments using cols across and rows down.\n" +"\n" +" -F hor|vert|both\n" +" flip (mirror) image or region horizontally, vertically, or both\n" +" -R # [90,180,or 270] degrees clockwise rotation of image or extracted region\n" +" -I [black|white|data|both]\n" +" invert color space, eg dark to light for bilevel and grayscale images\n" +" If argument is white or black, set the PHOTOMETRIC_INTERPRETATION \n" +" tag to MinIsBlack or MinIsWhite without altering the image data\n" +" If the argument is data or both, the image data are modified:\n" +" both inverts the data and the PHOTOMETRIC_INTERPRETATION tag,\n" +" data inverts the data but not the PHOTOMETRIC_INTERPRETATION tag\n" +"\n" +"-D opt1:value1,opt2:value2,opt3:value3:opt4:value4\n" +" Debug/dump program progress and/or data to non-TIFF files.\n" +" Options include the following and must be joined as a comma\n" +" separate list. The use of this option is generally limited to\n" +" program debugging and development of future options.\n" +"\n" +" debug:N Display limited program progress indicators where larger N\n" +" increase the level of detail. Note: Tiffcrop may be compiled with\n" +" -DDEVELMODE to enable additional very low level debug reporting.\n" +"\n" +" Format:txt|raw Format any logged data as ASCII text or raw binary \n" +" values. ASCII text dumps include strings of ones and zeroes\n" +" representing the binary values in the image data plus identifying headers.\n" +"\n" +" level:N Specify the level of detail presented in the dump files.\n" +" This can vary from dumps of the entire input or output image data to dumps\n" +" of data processed by specific functions. Current range of levels is 1 to 3.\n" +"\n" +" input:full-path-to-directory/input-dumpname\n" +"\n" +" output:full-path-to-directory/output-dumpnaem\n" +"\n" +" When dump files are being written, each image will be written to a separate\n" +" file with the name built by adding a numeric sequence value to the dumpname\n" +" and an extension of .txt for ASCII dumps or .bin for binary dumps.\n" +"\n" +" The four debug/dump options are independent, though it makes little sense to\n" +" specify a dump file without specifying a detail level.\n" +"\n" +; /* This function could be modified to pass starting sample offset * and number of samples as args to select fewer than spp * from input image. These would then be passed to individual * extractContigSampleXX routines. */ -static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, - uint32 imagelength, - uint32 imagewidth, - uint32 tw, uint32 tl, - tsample_t spp, uint16 bps) +static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, + uint32_t imagelength, + uint32_t imagewidth, + uint32_t tw, uint32_t tl, + tsample_t spp, uint16_t bps) { int status = 1; tsample_t sample = 0; tsample_t count = spp; - uint32 row, col, trow; - uint32 nrow, ncol; - uint32 dst_rowsize, shift_width; - uint32 bytes_per_sample, bytes_per_pixel; - uint32 trailing_bits, prev_trailing_bits; - uint32 tile_rowsize = TIFFTileRowSize(in); - uint32 src_offset, dst_offset; - uint32 row_offset, col_offset; - uint8 *bufp = (uint8*) buf; + uint32_t row, col, trow; + uint32_t nrow, ncol; + uint32_t dst_rowsize, shift_width; + uint32_t bytes_per_sample, bytes_per_pixel; + uint32_t trailing_bits, prev_trailing_bits; + uint32_t tile_rowsize = TIFFTileRowSize(in); + uint32_t src_offset, dst_offset; + uint32_t row_offset, col_offset; + uint8_t *bufp = (uint8_t*) buf; unsigned char *src = NULL; unsigned char *dst = NULL; tsize_t tbytes = 0, tile_buffsize = 0; @@ -834,7 +829,7 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, { #ifdef DEBUG2 TIFFError("readContigTilesIntoBuffer", - "Tilesize %lu is too small, using alternate calculation %u", + "Tilesize %"PRId64" is too small, using alternate calculation %"PRIu64, tilesize, tl * tile_rowsize); #endif tile_buffsize = tl * tile_rowsize; @@ -868,9 +863,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, if (tbytes < tilesize && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at row %lu col %lu, Read %lu bytes of %lu", - (unsigned long) col, (unsigned long) row, (unsigned long)tbytes, - (unsigned long)tilesize); + "Error, can't read tile at row %"PRIu32" col %"PRIu32", Read %"TIFF_SSIZE_FORMAT" bytes of %"TIFF_SSIZE_FORMAT, + col, row, tbytes, tilesize); status = 0; _TIFFfree(tilebuf); return status; @@ -919,8 +913,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, spp, bps, count, 0, ncol)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; @@ -933,8 +927,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, prev_trailing_bits)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; @@ -947,8 +941,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, prev_trailing_bits)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; @@ -959,8 +953,8 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, prev_trailing_bits)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; @@ -973,12 +967,12 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, prev_trailing_bits)) { TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %d from tile %lu", - row, (unsigned long)TIFFCurrentTile(in)); + "Unable to extract row %"PRIu32" from tile %"PRIu32, + row, TIFFCurrentTile(in)); return 1; } break; - default: TIFFError("readContigTilesIntoBuffer", "Unsupported bit depth %d", bps); + default: TIFFError("readContigTilesIntoBuffer", "Unsupported bit depth %"PRIu16, bps); return 1; } } @@ -993,20 +987,20 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, return status; } -static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf, - uint32 imagelength, uint32 imagewidth, - uint32 tw, uint32 tl, - uint16 spp, uint16 bps) +static int readSeparateTilesIntoBuffer (TIFF* in, uint8_t *obuf, + uint32_t imagelength, uint32_t imagewidth, + uint32_t tw, uint32_t tl, + uint16_t spp, uint16_t bps) { int i, status = 1, sample; int shift_width, bytes_per_pixel; - uint16 bytes_per_sample; - uint32 row, col; /* Current row and col of image */ - uint32 nrow, ncol; /* Number of rows and cols in current tile */ - uint32 row_offset, col_offset; /* Output buffer offsets */ + uint16_t bytes_per_sample; + uint32_t row, col; /* Current row and col of image */ + uint32_t nrow, ncol; /* Number of rows and cols in current tile */ + uint32_t row_offset, col_offset; /* Output buffer offsets */ tsize_t tbytes = 0, tilesize = TIFFTileSize(in); tsample_t s; - uint8* bufp = (uint8*)obuf; + uint8_t* bufp = (uint8_t*)obuf; unsigned char *srcbuffs[MAX_SAMPLES]; unsigned char *tbuff = NULL; @@ -1040,10 +1034,9 @@ static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf, if (tbytes < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile for row %lu col %lu, " - "sample %lu", - (unsigned long) col, (unsigned long) row, - (unsigned long) s); + "Error, can't read tile for row %"PRIu32" col %"PRIu32", " + "sample %"PRIu16, + col, row, s); status = 0; for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { @@ -1122,7 +1115,7 @@ static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf, break; } break; - default: TIFFError ("readSeparateTilesIntoBuffer", "Unsupported bit depth: %d", bps); + default: TIFFError ("readSeparateTilesIntoBuffer", "Unsupported bit depth: %"PRIu16, bps); status = 0; break; } @@ -1140,9 +1133,9 @@ static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf, return status; } -static int writeBufferToContigStrips(TIFF* out, uint8* buf, uint32 imagelength) +static int writeBufferToContigStrips(TIFF* out, uint8_t* buf, uint32_t imagelength) { - uint32 row, nrows, rowsperstrip; + uint32_t row, nrows, rowsperstrip; tstrip_t strip = 0; tsize_t stripsize; @@ -1154,7 +1147,7 @@ static int writeBufferToContigStrips(TIFF* out, uint8* buf, uint32 imagelength) stripsize = TIFFVStripSize(out, nrows); if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) { - TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); + TIFFError(TIFFFileName(out), "Error, can't write strip %"PRIu32, strip - 1); return 1; } buf += stripsize; @@ -1172,14 +1165,14 @@ static int writeBufferToContigStrips(TIFF* out, uint8* buf, uint32 imagelength) * before any strips or tiles of a different plane are stored. */ static int -writeBufferToSeparateStrips (TIFF* out, uint8* buf, - uint32 length, uint32 width, uint16 spp, - struct dump_opts *dump) +writeBufferToSeparateStrips (TIFF* out, uint8_t* buf, + uint32_t length, uint32_t width, uint16_t spp, + struct dump_opts *dump) { - uint8 *src; - uint16 bps; - uint32 row, nrows, rowsize, rowsperstrip; - uint32 bytes_per_sample; + uint8_t *src; + uint16_t bps; + uint32_t row, nrows, rowsize, rowsperstrip; + uint32_t bytes_per_sample; tsample_t s; tstrip_t strip = 0; tsize_t stripsize = TIFFStripSize(out); @@ -1191,20 +1184,20 @@ writeBufferToSeparateStrips (TIFF* out, uint8* buf, (void) TIFFGetFieldDefaulted(out, TIFFTAG_BITSPERSAMPLE, &bps); bytes_per_sample = (bps + 7) / 8; if( width == 0 || - (uint32)bps * (uint32)spp > TIFF_UINT32_MAX / width || - bps * spp * width > TIFF_UINT32_MAX - 7U ) + (uint32_t)bps * (uint32_t)spp > UINT32_MAX / width || + bps * spp * width > UINT32_MAX - 7U ) { TIFFError(TIFFFileName(out), - "Error, uint32 overflow when computing (bps * spp * width) + 7"); + "Error, uint32_t overflow when computing (bps * spp * width) + 7"); return 1; } rowsize = ((bps * spp * width) + 7U) / 8; /* source has interleaved samples */ if( bytes_per_sample == 0 || - rowsperstrip > TIFF_UINT32_MAX / bytes_per_sample || - rowsperstrip * bytes_per_sample > TIFF_UINT32_MAX / (width + 1) ) + rowsperstrip > UINT32_MAX / bytes_per_sample || + rowsperstrip * bytes_per_sample > UINT32_MAX / (width + 1) ) { TIFFError(TIFFFileName(out), - "Error, uint32 overflow when computing rowsperstrip * " + "Error, uint32_t overflow when computing rowsperstrip * " "bytes_per_sample * (width + 1)"); return 1; } @@ -1239,7 +1232,7 @@ writeBufferToSeparateStrips (TIFF* out, uint8* buf, if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) { - TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); + TIFFError(TIFFFileName(out), "Error, can't write strip %"PRIu32, strip - 1); _TIFFfree(obuf); return 1; } @@ -1253,16 +1246,16 @@ writeBufferToSeparateStrips (TIFF* out, uint8* buf, /* Extract all planes from contiguous buffer into a single tile buffer * to be written out as a tile. */ -static int writeBufferToContigTiles (TIFF* out, uint8* buf, uint32 imagelength, - uint32 imagewidth, tsample_t spp, - struct dump_opts* dump) +static int writeBufferToContigTiles (TIFF* out, uint8_t* buf, uint32_t imagelength, + uint32_t imagewidth, tsample_t spp, + struct dump_opts* dump) { - uint16 bps; - uint32 tl, tw; - uint32 row, col, nrow, ncol; - uint32 src_rowsize, col_offset; - uint32 tile_rowsize = TIFFTileRowSize(out); - uint8* bufp = (uint8*) buf; + uint16_t bps; + uint32_t tl, tw; + uint32_t row, col, nrow, ncol; + uint32_t src_rowsize, col_offset; + uint32_t tile_rowsize = TIFFTileRowSize(out); + uint8_t* bufp = (uint8_t*) buf; tsize_t tile_buffsize = 0; tsize_t tilesize = TIFFTileSize(out); unsigned char *tilebuf = NULL; @@ -1283,7 +1276,7 @@ static int writeBufferToContigTiles (TIFF* out, uint8* buf, uint32 imagelength, { #ifdef DEBUG2 TIFFError("writeBufferToContigTiles", - "Tilesize %lu is too small, using alternate calculation %u", + "Tilesize %"PRId64" is too small, using alternate calculation %"PRIu32, tilesize, tl * tile_rowsize); #endif tile_buffsize = tl * tile_rowsize; @@ -1295,11 +1288,11 @@ static int writeBufferToContigTiles (TIFF* out, uint8* buf, uint32 imagelength, } if( imagewidth == 0 || - (uint32)bps * (uint32)spp > TIFF_UINT32_MAX / imagewidth || - bps * spp * imagewidth > TIFF_UINT32_MAX - 7U ) + (uint32_t)bps * (uint32_t)spp > UINT32_MAX / imagewidth || + bps * spp * imagewidth > UINT32_MAX - 7U ) { TIFFError(TIFFFileName(out), - "Error, uint32 overflow when computing (imagewidth * bps * spp) + 7"); + "Error, uint32_t overflow when computing (imagewidth * bps * spp) + 7"); return 1; } src_rowsize = ((imagewidth * spp * bps) + 7U) / 8; @@ -1324,8 +1317,8 @@ static int writeBufferToContigTiles (TIFF* out, uint8* buf, uint32 imagelength, tw, 0, spp, spp, bps, dump) > 0) { TIFFError("writeBufferToContigTiles", - "Unable to extract data to tile for row %lu, col %lu", - (unsigned long) row, (unsigned long)col); + "Unable to extract data to tile for row %"PRIu32", col %"PRIu32, + row, col); _TIFFfree(tilebuf); return 1; } @@ -1333,8 +1326,8 @@ static int writeBufferToContigTiles (TIFF* out, uint8* buf, uint32 imagelength, if (TIFFWriteTile(out, tilebuf, col, row, 0, 0) < 0) { TIFFError("writeBufferToContigTiles", - "Cannot write tile at %lu %lu", - (unsigned long) col, (unsigned long) row); + "Cannot write tile at %"PRIu32" %"PRIu32, + col, row); _TIFFfree(tilebuf); return 1; } @@ -1348,17 +1341,17 @@ static int writeBufferToContigTiles (TIFF* out, uint8* buf, uint32 imagelength, /* Extract each plane from contiguous buffer into a single tile buffer * to be written out as a tile. */ -static int writeBufferToSeparateTiles (TIFF* out, uint8* buf, uint32 imagelength, - uint32 imagewidth, tsample_t spp, +static int writeBufferToSeparateTiles (TIFF* out, uint8_t* buf, uint32_t imagelength, + uint32_t imagewidth, tsample_t spp, struct dump_opts * dump) { tdata_t obuf = limitMalloc(TIFFTileSize(out)); - uint32 tl, tw; - uint32 row, col, nrow, ncol; - uint32 src_rowsize, col_offset; - uint16 bps; + uint32_t tl, tw; + uint32_t row, col, nrow, ncol; + uint32_t src_rowsize, col_offset; + uint16_t bps; tsample_t s; - uint8* bufp = (uint8*) buf; + uint8_t* bufp = (uint8_t*) buf; if (obuf == NULL) return 1; @@ -1366,14 +1359,17 @@ static int writeBufferToSeparateTiles (TIFF* out, uint8* buf, uint32 imagelength if( !TIFFGetField(out, TIFFTAG_TILELENGTH, &tl) || !TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw) || !TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps) ) + { + _TIFFfree(obuf); return 1; + } if( imagewidth == 0 || - (uint32)bps * (uint32)spp > TIFF_UINT32_MAX / imagewidth || - bps * spp * imagewidth > TIFF_UINT32_MAX - 7 ) + (uint32_t)bps * (uint32_t)spp > UINT32_MAX / imagewidth || + bps * spp * imagewidth > UINT32_MAX - 7 ) { TIFFError(TIFFFileName(out), - "Error, uint32 overflow when computing (imagewidth * bps * spp) + 7"); + "Error, uint32_t overflow when computing (imagewidth * bps * spp) + 7"); _TIFFfree(obuf); return 1; } @@ -1399,8 +1395,8 @@ static int writeBufferToSeparateTiles (TIFF* out, uint8* buf, uint32 imagelength tw, s, 1, spp, bps, dump) > 0) { TIFFError("writeBufferToSeparateTiles", - "Unable to extract data to tile for row %lu, col %lu sample %d", - (unsigned long) row, (unsigned long)col, (int)s); + "Unable to extract data to tile for row %"PRIu32", col %"PRIu32" sample %"PRIu16, + row, col, s); _TIFFfree(obuf); return 1; } @@ -1408,9 +1404,8 @@ static int writeBufferToSeparateTiles (TIFF* out, uint8* buf, uint32 imagelength if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) { TIFFError("writeBufferToseparateTiles", - "Cannot write tile at %lu %lu sample %lu", - (unsigned long) col, (unsigned long) row, - (unsigned long) s); + "Cannot write tile at %"PRIu32" %"PRIu32" sample %"PRIu16, + col, row, s); _TIFFfree(obuf); return 1; } @@ -1426,7 +1421,7 @@ static void processG3Options(char* cp) { if( (cp = strchr(cp, ':')) ) { - if (defg3opts == (uint32) -1) + if (defg3opts == (uint32_t) -1) defg3opts = 0; do { cp++; @@ -1504,15 +1499,13 @@ processCompressOptions(char* opt) static void usage(int code) - { - int i; - FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; +{ + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "\n%s\n", TIFFGetVersion()); - for (i = 0; usage_info[i] != NULL; i++) - fprintf(out, "%s\n", usage_info[i]); - exit(code); - } + fprintf(out, "\n%s\n\n", TIFFGetVersion()); + fprintf(out, "%s", usage_info); + exit(code); +} #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) @@ -1524,27 +1517,27 @@ usage(int code) if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static void -cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) +cpTag(TIFF* in, TIFF* out, uint16_t tag, uint16_t count, TIFFDataType type) { switch (type) { case TIFF_SHORT: if (count == 1) { - uint16 shortv; + uint16_t shortv; CopyField(tag, shortv); } else if (count == 2) { - uint16 shortv1, shortv2; + uint16_t shortv1, shortv2; CopyField2(tag, shortv1, shortv2); } else if (count == 4) { - uint16 *tr, *tg, *tb, *ta; + uint16_t *tr, *tg, *tb, *ta; CopyField4(tag, tr, tg, tb, ta); - } else if (count == (uint16) -1) { - uint16 shortv1; - uint16* shortav; + } else if (count == (uint16_t) -1) { + uint16_t shortv1; + uint16_t* shortav; CopyField2(tag, shortv1, shortav); } break; case TIFF_LONG: - { uint32 longv; + { uint32_t longv; CopyField(tag, longv); } break; @@ -1552,7 +1545,7 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { float floatv; CopyField(tag, floatv); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { float* floatav; CopyField(tag, floatav); } @@ -1566,21 +1559,21 @@ cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) if (count == 1) { double doublev; CopyField(tag, doublev); - } else if (count == (uint16) -1) { + } else if (count == (uint16_t) -1) { double* doubleav; CopyField(tag, doubleav); } break; default: TIFFError(TIFFFileName(in), - "Data type %d is not supported, tag %d skipped", + "Data type %"PRIu16" is not supported, tag %d skipped", tag, type); } } -static struct cpTag { - uint16 tag; - uint16 count; +static const struct cpTag { + uint16_t tag; + uint16_t count; TIFFDataType type; } tags[] = { { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, @@ -1591,41 +1584,41 @@ static struct cpTag { { TIFFTAG_MODEL, 1, TIFF_ASCII }, { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, - { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, - { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, - { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, - { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, - { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, - { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, - { TIFFTAG_DATETIME, 1, TIFF_ASCII }, - { TIFFTAG_ARTIST, 1, TIFF_ASCII }, - { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, - { TIFFTAG_WHITEPOINT, (uint16) -1, TIFF_RATIONAL }, - { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, - { TIFFTAG_INKSET, 1, TIFF_SHORT }, - { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, - { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, - { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, - { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, - { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, - { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, - { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, - { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, - { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, - { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, + { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES,(uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16_t) -1, TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16_t) -1, TIFF_SHORT }, + { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) #define CopyTag(tag, count, type) cpTag(in, out, tag, count, type) /* Functions written by Richard Nolde, with exceptions noted. */ -void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 *dirnum, - uint16 *defconfig, uint16 *deffillorder, uint32 *deftilewidth, - uint32 *deftilelength, uint32 *defrowsperstrip, - struct crop_mask *crop_data, struct pagedef *page, +void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32_t *dirnum, + uint16_t *defconfig, uint16_t *deffillorder, uint32_t *deftilewidth, + uint32_t *deftilelength, uint32_t *defrowsperstrip, + struct crop_mask *crop_data, struct pagedef *page, struct dump_opts *dump, unsigned int *imagelist, unsigned int *image_count ) { @@ -1750,7 +1743,7 @@ void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 &crop_data->corners[i].X1, &crop_data->corners[i].Y1, &crop_data->corners[i].X2, &crop_data->corners[i].Y2) != 4) { - TIFFError ("Unable to parse coordinates for region", "%d %s", i, optarg); + TIFFError ("Unable to parse coordinates for region", "%u %s", i, optarg); TIFFError ("For valid options type", "tiffcrop -h"); exit (EXIT_FAILURE); } @@ -1925,11 +1918,11 @@ void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 TIFFError ("For valid options type", "tiffcrop -h"); exit (EXIT_FAILURE); break; - case 'J': /* horizontal margin for sectioned ouput pages */ + case 'J': /* horizontal margin for sectioned output pages */ page->hmargin = atof(optarg); page->mode |= PAGE_MODE_MARGINS; break; - case 'K': /* vertical margin for sectioned ouput pages*/ + case 'K': /* vertical margin for sectioned output pages*/ page->vmargin = atof(optarg); page->mode |= PAGE_MODE_MARGINS; break; @@ -2036,11 +2029,11 @@ void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 crop_data->crop_mode |= CROP_ROTATE; switch (strtoul(optarg, NULL, 0)) { - case 90: crop_data->rotation = (uint16)90; + case 90: crop_data->rotation = (uint16_t)90; break; - case 180: crop_data->rotation = (uint16)180; + case 180: crop_data->rotation = (uint16_t)180; break; - case 270: crop_data->rotation = (uint16)270; + case 270: crop_data->rotation = (uint16_t)270; break; default: TIFFError ("Rotation must be 90, 180, or 270 degrees clockwise", "%s", optarg); TIFFError ("For valid options type", "tiffcrop -h"); @@ -2211,12 +2204,12 @@ main(int argc, char* argv[]) #if !HAVE_DECL_OPTARG extern int optind; #endif - uint16 defconfig = (uint16) -1; - uint16 deffillorder = 0; - uint32 deftilewidth = (uint32) 0; - uint32 deftilelength = (uint32) 0; - uint32 defrowsperstrip = (uint32) 0; - uint32 dirnum = 0; + uint16_t defconfig = (uint16_t) -1; + uint16_t deffillorder = 0; + uint32_t deftilewidth = (uint32_t) 0; + uint32_t deftilelength = (uint32_t) 0; + uint32_t defrowsperstrip = (uint32_t) 0; + uint32_t dirnum = 0; TIFF *in = NULL; TIFF *out = NULL; @@ -2306,8 +2299,8 @@ main(int argc, char* argv[]) if (dirnum > (total_images)) { TIFFError (TIFFFileName(in), - "Invalid image number %d, File contains only %d images", - (int)dirnum + 1, total_images); + "Invalid image number %"PRIu32", File contains only %"PRIu32" images", + dirnum + 1u, total_images); if (out != NULL) (void) TIFFClose(out); return (1); @@ -2315,7 +2308,7 @@ main(int argc, char* argv[]) if (dirnum != 0 && !TIFFSetDirectory(in, (tdir_t)dirnum)) { - TIFFError(TIFFFileName(in),"Error, setting subdirectory at %d", dirnum); + TIFFError(TIFFFileName(in),"Error, setting subdirectory at %"PRIu32, dirnum); if (out != NULL) (void) TIFFClose(out); return (1); @@ -2353,7 +2346,7 @@ main(int argc, char* argv[]) TIFFError ("Unable to open dump file for writing", "%s", temp_filename); exit (EXIT_FAILURE); } - dump_info(dump.infile, dump.format, "Reading image","%d from %s", + dump_info(dump.infile, dump.format, "Reading image","%u from %s", dump_images, TIFFFileName(in)); } length = strlen(dump.outfilename); @@ -2372,7 +2365,7 @@ main(int argc, char* argv[]) TIFFError ("Unable to open dump file for writing", "%s", temp_filename); exit (EXIT_FAILURE); } - dump_info(dump.outfile, dump.format, "Writing image","%d from %s", + dump_info(dump.outfile, dump.format, "Writing image","%u from %s", dump_images, TIFFFileName(in)); } } @@ -2516,10 +2509,10 @@ main(int argc, char* argv[]) /* Debugging functions */ -static int dump_data (FILE *dumpfile, int format, char *dump_tag, unsigned char *data, uint32 count) +static int dump_data (FILE *dumpfile, int format, char *dump_tag, unsigned char *data, uint32_t count) { int j, k; - uint32 i; + uint32_t i; char dump_array[10]; unsigned char bitset; @@ -2591,7 +2584,7 @@ static int dump_byte (FILE *dumpfile, int format, char *dump_tag, unsigned char return (0); } -static int dump_short (FILE *dumpfile, int format, char *dump_tag, uint16 data) +static int dump_short (FILE *dumpfile, int format, char *dump_tag, uint16_t data) { int j, k; char dump_array[20]; @@ -2628,7 +2621,7 @@ static int dump_short (FILE *dumpfile, int format, char *dump_tag, uint16 data) return (0); } -static int dump_long (FILE *dumpfile, int format, char *dump_tag, uint32 data) +static int dump_long (FILE *dumpfile, int format, char *dump_tag, uint32_t data) { int j, k; char dump_array[40]; @@ -2645,7 +2638,7 @@ static int dump_long (FILE *dumpfile, int format, char *dump_tag, uint32 data) fprintf (dumpfile," %s ", dump_tag); for (j = 0, k = 31; k >= 0; j++, k--) { - bitset = data & (((uint32)1 << k)) ? 1 : 0; + bitset = data & (((uint32_t)1 << k)) ? 1 : 0; sprintf(&dump_array[j], (bitset) ? "1" : "0"); if ((k % 8) == 0) sprintf(&dump_array[++j], " "); @@ -2664,7 +2657,7 @@ static int dump_long (FILE *dumpfile, int format, char *dump_tag, uint32 data) return (0); } -static int dump_wide (FILE *dumpfile, int format, char *dump_tag, uint64 data) +static int dump_wide (FILE *dumpfile, int format, char *dump_tag, uint64_t data) { int j, k; char dump_array[80]; @@ -2681,7 +2674,7 @@ static int dump_wide (FILE *dumpfile, int format, char *dump_tag, uint64 data) fprintf (dumpfile," %s ", dump_tag); for (j = 0, k = 63; k >= 0; j++, k--) { - bitset = data & (((uint64)1 << k)) ? 1 : 0; + bitset = data & (((uint64_t)1 << k)) ? 1 : 0; sprintf(&dump_array[j], (bitset) ? "1" : "0"); if ((k % 8) == 0) sprintf(&dump_array[++j], " "); @@ -2714,11 +2707,11 @@ static void dump_info(FILE *dumpfile, int format, char *prefix, char *msg, ...) } } -static int dump_buffer (FILE* dumpfile, int format, uint32 rows, uint32 width, - uint32 row, unsigned char *buff) +static int dump_buffer (FILE* dumpfile, int format, uint32_t rows, uint32_t width, + uint32_t row, unsigned char *buff) { int j, k; - uint32 i; + uint32_t i; unsigned char * dump_ptr; if (dumpfile == NULL) @@ -2732,8 +2725,8 @@ static int dump_buffer (FILE* dumpfile, int format, uint32 rows, uint32 width, dump_ptr = buff + (i * width); if (format == DUMP_TEXT) dump_info (dumpfile, format, "", - "Row %4d, %d bytes at offset %d", - row + i + 1, width, row * width); + "Row %4"PRIu32", %"PRIu32" bytes at offset %"PRIu32, + row + i + 1u, width, row * width); for (j = 0, k = width; k >= 10; j += 10, k -= 10, dump_ptr += 10) dump_data (dumpfile, format, "", dump_ptr, 10); @@ -2750,15 +2743,15 @@ static int dump_buffer (FILE* dumpfile, int format, uint32 rows, uint32 width, */ static int -extractContigSamplesBytes (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end) +extractContigSamplesBytes (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end) { int i, bytes_per_sample, sindex; - uint32 col, dst_rowsize, bit_offset; - uint32 src_byte /*, src_bit */; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, dst_rowsize, bit_offset; + uint32_t src_byte /*, src_bit */; + uint8_t *src = in; + uint8_t *dst = out; if ((src == NULL) || (dst == NULL)) { @@ -2769,13 +2762,13 @@ extractContigSamplesBytes (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesBytes", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesBytes", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } @@ -2816,16 +2809,16 @@ extractContigSamplesBytes (uint8 *in, uint8 *out, uint32 cols, } /* end extractContigSamplesBytes */ static int -extractContigSamples8bits (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end) +extractContigSamples8bits (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end) { int ready_bits = 0, sindex = 0; - uint32 col, src_byte, src_bit, bit_offset; - uint8 maskbits = 0, matchbits = 0; - uint8 buff1 = 0, buff2 = 0; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, src_byte, src_bit, bit_offset; + uint8_t maskbits = 0, matchbits = 0; + uint8_t buff1 = 0, buff2 = 0; + uint8_t *src = in; + uint8_t *dst = out; if ((src == NULL) || (dst == NULL)) { @@ -2836,18 +2829,18 @@ extractContigSamples8bits (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamples8bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamples8bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } ready_bits = 0; - maskbits = (uint8)-1 >> ( 8 - bps); + maskbits = (uint8_t)-1 >> (8 - bps); buff1 = buff2 = 0; for (col = start; col < end; col++) { /* Compute src byte(s) and bits within byte(s) */ @@ -2893,17 +2886,17 @@ extractContigSamples8bits (uint8 *in, uint8 *out, uint32 cols, } /* end extractContigSamples8bits */ static int -extractContigSamples16bits (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end) +extractContigSamples16bits (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end) { int ready_bits = 0, sindex = 0; - uint32 col, src_byte, src_bit, bit_offset; - uint16 maskbits = 0, matchbits = 0; - uint16 buff1 = 0, buff2 = 0; - uint8 bytebuff = 0; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, src_byte, src_bit, bit_offset; + uint16_t maskbits = 0, matchbits = 0; + uint16_t buff1 = 0, buff2 = 0; + uint8_t bytebuff = 0; + uint8_t *src = in; + uint8_t *dst = out; if ((src == NULL) || (dst == NULL)) { @@ -2914,18 +2907,18 @@ extractContigSamples16bits (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamples16bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamples16bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } ready_bits = 0; - maskbits = (uint16)-1 >> (16 - bps); + maskbits = (uint16_t)-1 >> (16 - bps); for (col = start; col < end; col++) { /* Compute src byte(s) and bits within byte(s) */ @@ -2982,17 +2975,17 @@ extractContigSamples16bits (uint8 *in, uint8 *out, uint32 cols, static int -extractContigSamples24bits (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end) +extractContigSamples24bits (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end) { int ready_bits = 0, sindex = 0; - uint32 col, src_byte, src_bit, bit_offset; - uint32 maskbits = 0, matchbits = 0; - uint32 buff1 = 0, buff2 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, src_byte, src_bit, bit_offset; + uint32_t maskbits = 0, matchbits = 0; + uint32_t buff1 = 0, buff2 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0; + uint8_t *src = in; + uint8_t *dst = out; if ((in == NULL) || (out == NULL)) { @@ -3003,18 +2996,18 @@ extractContigSamples24bits (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamples24bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamples24bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } ready_bits = 0; - maskbits = (uint32)-1 >> ( 32 - bps); + maskbits = (uint32_t)-1 >> (32 - bps); for (col = start; col < end; col++) { /* Compute src byte(s) and bits within byte(s) */ @@ -3091,18 +3084,18 @@ extractContigSamples24bits (uint8 *in, uint8 *out, uint32 cols, } /* end extractContigSamples24bits */ static int -extractContigSamples32bits (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end) +extractContigSamples32bits (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end) { int ready_bits = 0, sindex = 0 /*, shift_width = 0 */; - uint32 col, src_byte, src_bit, bit_offset; - uint32 longbuff1 = 0, longbuff2 = 0; - uint64 maskbits = 0, matchbits = 0; - uint64 buff1 = 0, buff2 = 0, buff3 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, src_byte, src_bit, bit_offset; + uint32_t longbuff1 = 0, longbuff2 = 0; + uint64_t maskbits = 0, matchbits = 0; + uint64_t buff1 = 0, buff2 = 0, buff3 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8_t *src = in; + uint8_t *dst = out; if ((in == NULL) || (out == NULL)) { @@ -3114,19 +3107,19 @@ extractContigSamples32bits (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamples32bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamples32bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } /* shift_width = ((bps + 7) / 8) + 1; */ ready_bits = 0; - maskbits = (uint64)-1 >> ( 64 - bps); + maskbits = (uint64_t)-1 >> (64 - bps); for (col = start; col < end; col++) { /* Compute src byte(s) and bits within byte(s) */ @@ -3157,7 +3150,7 @@ extractContigSamples32bits (uint8 *in, uint8 *out, uint32 cols, longbuff2 = longbuff1; } - buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; buff1 = (buff3 & matchbits) << (src_bit); /* If we have a full buffer's worth, write it out */ @@ -3196,17 +3189,17 @@ extractContigSamples32bits (uint8 *in, uint8 *out, uint32 cols, } /* end extractContigSamples32bits */ static int -extractContigSamplesShifted8bits (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end, - int shift) +extractContigSamplesShifted8bits (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end, + int shift) { int ready_bits = 0, sindex = 0; - uint32 col, src_byte, src_bit, bit_offset; - uint8 maskbits = 0, matchbits = 0; - uint8 buff1 = 0, buff2 = 0; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, src_byte, src_bit, bit_offset; + uint8_t maskbits = 0, matchbits = 0; + uint8_t buff1 = 0, buff2 = 0; + uint8_t *src = in; + uint8_t *dst = out; if ((src == NULL) || (dst == NULL)) { @@ -3217,18 +3210,18 @@ extractContigSamplesShifted8bits (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesShifted8bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesShifted8bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } ready_bits = shift; - maskbits = (uint8)-1 >> ( 8 - bps); + maskbits = (uint8_t)-1 >> (8 - bps); buff1 = buff2 = 0; for (col = start; col < end; col++) { /* Compute src byte(s) and bits within byte(s) */ @@ -3250,7 +3243,7 @@ extractContigSamplesShifted8bits (uint8 *in, uint8 *out, uint32 cols, matchbits = maskbits << (8 - src_bit - bps); buff1 = ((*src) & matchbits) << (src_bit); if ((col == start) && (sindex == sample)) - buff2 = *src & ((uint8)-1) << (shift); + buff2 = *src & ((uint8_t)-1) << (shift); /* If we have a full buffer's worth, write it out */ if (ready_bits >= 8) @@ -3276,18 +3269,18 @@ extractContigSamplesShifted8bits (uint8 *in, uint8 *out, uint32 cols, } /* end extractContigSamplesShifted8bits */ static int -extractContigSamplesShifted16bits (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end, - int shift) +extractContigSamplesShifted16bits (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end, + int shift) { int ready_bits = 0, sindex = 0; - uint32 col, src_byte, src_bit, bit_offset; - uint16 maskbits = 0, matchbits = 0; - uint16 buff1 = 0, buff2 = 0; - uint8 bytebuff = 0; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, src_byte, src_bit, bit_offset; + uint16_t maskbits = 0, matchbits = 0; + uint16_t buff1 = 0, buff2 = 0; + uint8_t bytebuff = 0; + uint8_t *src = in; + uint8_t *dst = out; if ((src == NULL) || (dst == NULL)) { @@ -3298,18 +3291,18 @@ extractContigSamplesShifted16bits (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesShifted16bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesShifted16bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } ready_bits = shift; - maskbits = (uint16)-1 >> (16 - bps); + maskbits = (uint16_t)-1 >> (16 - bps); for (col = start; col < end; col++) { /* Compute src byte(s) and bits within byte(s) */ bit_offset = col * bps * spp; @@ -3334,7 +3327,7 @@ extractContigSamplesShifted16bits (uint8 *in, uint8 *out, uint32 cols, buff1 = (src[1] << 8) | src[0]; if ((col == start) && (sindex == sample)) - buff2 = buff1 & ((uint16)-1) << (8 - shift); + buff2 = buff1 & ((uint16_t)-1) << (8 - shift); buff1 = (buff1 & matchbits) << (src_bit); @@ -3366,18 +3359,18 @@ extractContigSamplesShifted16bits (uint8 *in, uint8 *out, uint32 cols, static int -extractContigSamplesShifted24bits (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end, - int shift) +extractContigSamplesShifted24bits (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end, + int shift) { int ready_bits = 0, sindex = 0; - uint32 col, src_byte, src_bit, bit_offset; - uint32 maskbits = 0, matchbits = 0; - uint32 buff1 = 0, buff2 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, src_byte, src_bit, bit_offset; + uint32_t maskbits = 0, matchbits = 0; + uint32_t buff1 = 0, buff2 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0; + uint8_t *src = in; + uint8_t *dst = out; if ((in == NULL) || (out == NULL)) { @@ -3388,18 +3381,18 @@ extractContigSamplesShifted24bits (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesShifted24bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesShifted24bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } ready_bits = shift; - maskbits = (uint32)-1 >> ( 32 - bps); + maskbits = (uint32_t)-1 >> (32 - bps); for (col = start; col < end; col++) { /* Compute src byte(s) and bits within byte(s) */ @@ -3425,7 +3418,7 @@ extractContigSamplesShifted24bits (uint8 *in, uint8 *out, uint32 cols, buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; if ((col == start) && (sindex == sample)) - buff2 = buff1 & ((uint32)-1) << (16 - shift); + buff2 = buff1 & ((uint32_t)-1) << (16 - shift); buff1 = (buff1 & matchbits) << (src_bit); @@ -3464,19 +3457,19 @@ extractContigSamplesShifted24bits (uint8 *in, uint8 *out, uint32 cols, } /* end extractContigSamplesShifted24bits */ static int -extractContigSamplesShifted32bits (uint8 *in, uint8 *out, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, - tsample_t count, uint32 start, uint32 end, - int shift) +extractContigSamplesShifted32bits (uint8_t *in, uint8_t *out, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, + tsample_t count, uint32_t start, uint32_t end, + int shift) { int ready_bits = 0, sindex = 0 /*, shift_width = 0 */; - uint32 col, src_byte, src_bit, bit_offset; - uint32 longbuff1 = 0, longbuff2 = 0; - uint64 maskbits = 0, matchbits = 0; - uint64 buff1 = 0, buff2 = 0, buff3 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - uint8 *src = in; - uint8 *dst = out; + uint32_t col, src_byte, src_bit, bit_offset; + uint32_t longbuff1 = 0, longbuff2 = 0; + uint64_t maskbits = 0, matchbits = 0; + uint64_t buff1 = 0, buff2 = 0, buff3 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8_t *src = in; + uint8_t *dst = out; if ((in == NULL) || (out == NULL)) { @@ -3488,19 +3481,19 @@ extractContigSamplesShifted32bits (uint8 *in, uint8 *out, uint32 cols, if ((start > end) || (start > cols)) { TIFFError ("extractContigSamplesShifted32bits", - "Invalid start column value %d ignored", start); + "Invalid start column value %"PRIu32" ignored", start); start = 0; } if ((end == 0) || (end > cols)) { TIFFError ("extractContigSamplesShifted32bits", - "Invalid end column value %d ignored", end); + "Invalid end column value %"PRIu32" ignored", end); end = cols; } /* shift_width = ((bps + 7) / 8) + 1; */ ready_bits = shift; - maskbits = (uint64)-1 >> ( 64 - bps); + maskbits = (uint64_t)-1 >> (64 - bps); for (col = start; col < end; col++) { /* Compute src byte(s) and bits within byte(s) */ @@ -3531,9 +3524,9 @@ extractContigSamplesShifted32bits (uint8 *in, uint8 *out, uint32 cols, longbuff2 = longbuff1; } - buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; if ((col == start) && (sindex == sample)) - buff2 = buff3 & ((uint64)-1) << (32 - shift); + buff2 = buff3 & ((uint64_t)-1) << (32 - shift); buff1 = (buff3 & matchbits) << (src_bit); @@ -3572,15 +3565,15 @@ extractContigSamplesShifted32bits (uint8 *in, uint8 *out, uint32 cols, } /* end extractContigSamplesShifted32bits */ static int -extractContigSamplesToBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, - tsample_t sample, uint16 spp, uint16 bps, +extractContigSamplesToBuffer(uint8_t *out, uint8_t *in, uint32_t rows, uint32_t cols, + tsample_t sample, uint16_t spp, uint16_t bps, struct dump_opts *dump) { int shift_width, bytes_per_sample, bytes_per_pixel; - uint32 src_rowsize, src_offset, row, first_col = 0; - uint32 dst_rowsize, dst_offset; + uint32_t src_rowsize, src_offset, row, first_col = 0; + uint32_t dst_rowsize, dst_offset; tsample_t count = 1; - uint8 *src, *dst; + uint8_t *src, *dst; bytes_per_sample = (bps + 7) / 8; bytes_per_pixel = ((bps * spp) + 7) / 8; @@ -3599,7 +3592,7 @@ extractContigSamplesToBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, if ((dump->outfile != NULL) && (dump->level == 4)) { dump_info (dump->outfile, dump->format, "extractContigSamplesToBuffer", - "Sample %d, %d rows", sample + 1, rows + 1); + "Sample %"PRIu32", %"PRIu32" rows", sample + 1u, rows + 1u); } for (row = 0; row < rows; row++) { @@ -3637,7 +3630,7 @@ extractContigSamplesToBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, spp, bps, count, first_col, cols)) return (1); break; - default: TIFFError ("extractContigSamplesToBuffer", "Unsupported bit depth: %d", bps); + default: TIFFError ("extractContigSamplesToBuffer", "Unsupported bit depth: %"PRIu16, bps); return (1); } if ((dump->outfile != NULL) && (dump->level == 4)) @@ -3648,14 +3641,14 @@ extractContigSamplesToBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, } /* end extractContigSamplesToBuffer */ static int -extractContigSamplesToTileBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, - uint32 imagewidth, uint32 tilewidth, tsample_t sample, - uint16 count, uint16 spp, uint16 bps, struct dump_opts *dump) +extractContigSamplesToTileBuffer(uint8_t *out, uint8_t *in, uint32_t rows, uint32_t cols, + uint32_t imagewidth, uint32_t tilewidth, tsample_t sample, + uint16_t count, uint16_t spp, uint16_t bps, struct dump_opts *dump) { int shift_width, bytes_per_sample, bytes_per_pixel; - uint32 src_rowsize, src_offset, row; - uint32 dst_rowsize, dst_offset; - uint8 *src, *dst; + uint32_t src_rowsize, src_offset, row; + uint32_t dst_rowsize, dst_offset; + uint8_t *src, *dst; bytes_per_sample = (bps + 7) / 8; bytes_per_pixel = ((bps * spp) + 7) / 8; @@ -3672,7 +3665,7 @@ extractContigSamplesToTileBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols if ((dump->outfile != NULL) && (dump->level == 4)) { dump_info (dump->outfile, dump->format, "extractContigSamplesToTileBuffer", - "Sample %d, %d rows", sample + 1, rows + 1); + "Sample %"PRIu32", %"PRIu32" rows", sample + 1u, rows + 1u); } src_rowsize = ((bps * spp * imagewidth) + 7) / 8; @@ -3714,7 +3707,7 @@ extractContigSamplesToTileBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols spp, bps, count, 0, cols)) return (1); break; - default: TIFFError ("extractContigSamplesToTileBuffer", "Unsupported bit depth: %d", bps); + default: TIFFError ("extractContigSamplesToTileBuffer", "Unsupported bit depth: %"PRIu16, bps); return (1); } if ((dump->outfile != NULL) && (dump->level == 4)) @@ -3724,14 +3717,14 @@ extractContigSamplesToTileBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols return (0); } /* end extractContigSamplesToTileBuffer */ -static int readContigStripsIntoBuffer (TIFF* in, uint8* buf) +static int readContigStripsIntoBuffer (TIFF* in, uint8_t* buf) { - uint8* bufp = buf; - int32 bytes_read = 0; - uint32 strip, nstrips = TIFFNumberOfStrips(in); - uint32 stripsize = TIFFStripSize(in); - uint32 rows = 0; - uint32 rps = TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); + uint8_t* bufp = buf; + int32_t bytes_read = 0; + uint32_t strip, nstrips = TIFFNumberOfStrips(in); + uint32_t stripsize = TIFFStripSize(in); + uint32_t rows = 0; + uint32_t rps = TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); tsize_t scanline_size = TIFFScanlineSize(in); if (scanline_size == 0) { @@ -3742,14 +3735,13 @@ static int readContigStripsIntoBuffer (TIFF* in, uint8* buf) for (strip = 0; strip < nstrips; strip++) { bytes_read = TIFFReadEncodedStrip (in, strip, bufp, -1); rows = bytes_read / scanline_size; - if ((strip < (nstrips - 1)) && (bytes_read != (int32)stripsize)) - TIFFError("", "Strip %d: read %lu bytes, strip size %lu", - (int)strip + 1, (unsigned long) bytes_read, - (unsigned long)stripsize); + if ((strip < (nstrips - 1)) && (bytes_read != (int32_t)stripsize)) + TIFFError("", "Strip %"PRIu32": read %"PRId32" bytes, strip size %"PRIu32, + strip + 1, bytes_read, stripsize); if (bytes_read < 0 && !ignore) { - TIFFError("", "Error reading strip %lu after %lu rows", - (unsigned long) strip, (unsigned long)rows); + TIFFError("", "Error reading strip %"PRIu32" after %"PRIu32" rows", + strip, rows); return 0; } bufp += stripsize; @@ -3760,11 +3752,11 @@ static int readContigStripsIntoBuffer (TIFF* in, uint8* buf) static int combineSeparateSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, - uint32 cols, uint32 rows, uint16 spp, uint16 bps, + uint32_t cols, uint32_t rows, uint16_t spp, uint16_t bps, FILE *dumpfile, int format, int level) { int i, bytes_per_sample; - uint32 row, col, col_offset, src_rowsize, dst_rowsize, row_offset; + uint32_t row, col, col_offset, src_rowsize, dst_rowsize, row_offset; unsigned char *src; unsigned char *dst; tsample_t s; @@ -3787,7 +3779,7 @@ combineSeparateSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, { for (s = 0; s < spp; s++) { - dump_info (dumpfile, format, "combineSeparateSamplesBytes","Input data, Sample %d", s); + dump_info (dumpfile, format, "combineSeparateSamplesBytes","Input data, Sample %"PRIu16, s); dump_buffer(dumpfile, format, 1, cols, row, srcbuffs[s] + (row * src_rowsize)); } } @@ -3817,17 +3809,17 @@ combineSeparateSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, } /* end combineSeparateSamplesBytes */ static int -combineSeparateSamples8bits (uint8 *in[], uint8 *out, uint32 cols, - uint32 rows, uint16 spp, uint16 bps, - FILE *dumpfile, int format, int level) +combineSeparateSamples8bits (uint8_t *in[], uint8_t *out, uint32_t cols, + uint32_t rows, uint16_t spp, uint16_t bps, + FILE *dumpfile, int format, int level) { int ready_bits = 0; /* int bytes_per_sample = 0; */ - uint32 src_rowsize, dst_rowsize, src_offset; - uint32 bit_offset; - uint32 row, col, src_byte = 0, src_bit = 0; - uint8 maskbits = 0, matchbits = 0; - uint8 buff1 = 0, buff2 = 0; + uint32_t src_rowsize, dst_rowsize, src_offset; + uint32_t bit_offset; + uint32_t row, col, src_byte = 0, src_bit = 0; + uint8_t maskbits = 0, matchbits = 0; + uint8_t buff1 = 0, buff2 = 0; tsample_t s; unsigned char *src = in[0]; unsigned char *dst = out; @@ -3842,7 +3834,7 @@ combineSeparateSamples8bits (uint8 *in[], uint8 *out, uint32 cols, /* bytes_per_sample = (bps + 7) / 8; */ src_rowsize = ((bps * cols) + 7) / 8; dst_rowsize = ((bps * cols * spp) + 7) / 8; - maskbits = (uint8)-1 >> ( 8 - bps); + maskbits = (uint8_t)-1 >> (8 - bps); for (row = 0; row < rows; row++) { @@ -3882,8 +3874,8 @@ combineSeparateSamples8bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_byte (dumpfile, format, "Match bits", matchbits); dump_byte (dumpfile, format, "Src bits", *src); dump_byte (dumpfile, format, "Buff1 bits", buff1); @@ -3900,8 +3892,8 @@ combineSeparateSamples8bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, src_byte, src_bit, dst - out); dump_byte (dumpfile, format, "Final bits", buff1); } } @@ -3917,17 +3909,17 @@ combineSeparateSamples8bits (uint8 *in[], uint8 *out, uint32 cols, } /* end combineSeparateSamples8bits */ static int -combineSeparateSamples16bits (uint8 *in[], uint8 *out, uint32 cols, - uint32 rows, uint16 spp, uint16 bps, - FILE *dumpfile, int format, int level) +combineSeparateSamples16bits (uint8_t *in[], uint8_t *out, uint32_t cols, + uint32_t rows, uint16_t spp, uint16_t bps, + FILE *dumpfile, int format, int level) { int ready_bits = 0 /*, bytes_per_sample = 0 */; - uint32 src_rowsize, dst_rowsize; - uint32 bit_offset, src_offset; - uint32 row, col, src_byte = 0, src_bit = 0; - uint16 maskbits = 0, matchbits = 0; - uint16 buff1 = 0, buff2 = 0; - uint8 bytebuff = 0; + uint32_t src_rowsize, dst_rowsize; + uint32_t bit_offset, src_offset; + uint32_t row, col, src_byte = 0, src_bit = 0; + uint16_t maskbits = 0, matchbits = 0; + uint16_t buff1 = 0, buff2 = 0; + uint8_t bytebuff = 0; tsample_t s; unsigned char *src = in[0]; unsigned char *dst = out; @@ -3942,7 +3934,7 @@ combineSeparateSamples16bits (uint8 *in[], uint8 *out, uint32 cols, /* bytes_per_sample = (bps + 7) / 8; */ src_rowsize = ((bps * cols) + 7) / 8; dst_rowsize = ((bps * cols * spp) + 7) / 8; - maskbits = (uint16)-1 >> (16 - bps); + maskbits = (uint16_t)-1 >> (16 - bps); for (row = 0; row < rows; row++) { @@ -3989,8 +3981,8 @@ combineSeparateSamples16bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_short (dumpfile, format, "Match bits", matchbits); dump_data (dumpfile, format, "Src bits", src, 2); @@ -4027,17 +4019,17 @@ combineSeparateSamples16bits (uint8 *in[], uint8 *out, uint32 cols, } /* end combineSeparateSamples16bits */ static int -combineSeparateSamples24bits (uint8 *in[], uint8 *out, uint32 cols, - uint32 rows, uint16 spp, uint16 bps, - FILE *dumpfile, int format, int level) +combineSeparateSamples24bits (uint8_t *in[], uint8_t *out, uint32_t cols, + uint32_t rows, uint16_t spp, uint16_t bps, + FILE *dumpfile, int format, int level) { int ready_bits = 0 /*, bytes_per_sample = 0 */; - uint32 src_rowsize, dst_rowsize; - uint32 bit_offset, src_offset; - uint32 row, col, src_byte = 0, src_bit = 0; - uint32 maskbits = 0, matchbits = 0; - uint32 buff1 = 0, buff2 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0; + uint32_t src_rowsize, dst_rowsize; + uint32_t bit_offset, src_offset; + uint32_t row, col, src_byte = 0, src_bit = 0; + uint32_t maskbits = 0, matchbits = 0; + uint32_t buff1 = 0, buff2 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0; tsample_t s; unsigned char *src = in[0]; unsigned char *dst = out; @@ -4052,7 +4044,7 @@ combineSeparateSamples24bits (uint8 *in[], uint8 *out, uint32 cols, /* bytes_per_sample = (bps + 7) / 8; */ src_rowsize = ((bps * cols) + 7) / 8; dst_rowsize = ((bps * cols * spp) + 7) / 8; - maskbits = (uint32)-1 >> ( 32 - bps); + maskbits = (uint32_t)-1 >> (32 - bps); for (row = 0; row < rows; row++) { @@ -4072,9 +4064,9 @@ combineSeparateSamples24bits (uint8 *in[], uint8 *out, uint32 cols, { src = in[s] + src_offset + src_byte; if (little_endian) - buff1 = ((uint32)src[0] << 24) | ((uint32)src[1] << 16) | ((uint32)src[2] << 8) | (uint32)src[3]; + buff1 = ((uint32_t)src[0] << 24) | ((uint32_t)src[1] << 16) | ((uint32_t)src[2] << 8) | (uint32_t)src[3]; else - buff1 = ((uint32)src[3] << 24) | ((uint32)src[2] << 16) | ((uint32)src[1] << 8) | (uint32)src[0]; + buff1 = ((uint32_t)src[3] << 24) | ((uint32_t)src[2] << 16) | ((uint32_t)src[1] << 8) | (uint32_t)src[0]; buff1 = (buff1 & matchbits) << (src_bit); /* If we have a full buffer's worth, write it out */ @@ -4101,8 +4093,8 @@ combineSeparateSamples24bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_long (dumpfile, format, "Match bits ", matchbits); dump_data (dumpfile, format, "Src bits ", src, 4); dump_long (dumpfile, format, "Buff1 bits ", buff1); @@ -4151,18 +4143,18 @@ combineSeparateSamples24bits (uint8 *in[], uint8 *out, uint32 cols, } /* end combineSeparateSamples24bits */ static int -combineSeparateSamples32bits (uint8 *in[], uint8 *out, uint32 cols, - uint32 rows, uint16 spp, uint16 bps, - FILE *dumpfile, int format, int level) +combineSeparateSamples32bits (uint8_t *in[], uint8_t *out, uint32_t cols, + uint32_t rows, uint16_t spp, uint16_t bps, + FILE *dumpfile, int format, int level) { int ready_bits = 0 /*, bytes_per_sample = 0, shift_width = 0 */; - uint32 src_rowsize, dst_rowsize, bit_offset, src_offset; - uint32 src_byte = 0, src_bit = 0; - uint32 row, col; - uint32 longbuff1 = 0, longbuff2 = 0; - uint64 maskbits = 0, matchbits = 0; - uint64 buff1 = 0, buff2 = 0, buff3 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint32_t src_rowsize, dst_rowsize, bit_offset, src_offset; + uint32_t src_byte = 0, src_bit = 0; + uint32_t row, col; + uint32_t longbuff1 = 0, longbuff2 = 0; + uint64_t maskbits = 0, matchbits = 0; + uint64_t buff1 = 0, buff2 = 0, buff3 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; tsample_t s; unsigned char *src = in[0]; unsigned char *dst = out; @@ -4177,7 +4169,7 @@ combineSeparateSamples32bits (uint8 *in[], uint8 *out, uint32 cols, /* bytes_per_sample = (bps + 7) / 8; */ src_rowsize = ((bps * cols) + 7) / 8; dst_rowsize = ((bps * cols * spp) + 7) / 8; - maskbits = (uint64)-1 >> ( 64 - bps); + maskbits = (uint64_t)-1 >> (64 - bps); /* shift_width = ((bps + 7) / 8) + 1; */ for (row = 0; row < rows; row++) @@ -4207,7 +4199,7 @@ combineSeparateSamples32bits (uint8 *in[], uint8 *out, uint32 cols, longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; longbuff2 = longbuff1; } - buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; buff1 = (buff3 & matchbits) << (src_bit); /* If we have a full buffer's worth, write it out */ @@ -4238,8 +4230,8 @@ combineSeparateSamples32bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Sample %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Sample %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_wide (dumpfile, format, "Match bits ", matchbits); dump_data (dumpfile, format, "Src bits ", src, 8); dump_wide (dumpfile, format, "Buff1 bits ", buff1); @@ -4283,12 +4275,12 @@ combineSeparateSamples32bits (uint8 *in[], uint8 *out, uint32 cols, static int combineSeparateTileSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, - uint32 cols, uint32 rows, uint32 imagewidth, - uint32 tw, uint16 spp, uint16 bps, + uint32_t cols, uint32_t rows, uint32_t imagewidth, + uint32_t tw, uint16_t spp, uint16_t bps, FILE *dumpfile, int format, int level) { int i, bytes_per_sample; - uint32 row, col, col_offset, src_rowsize, dst_rowsize, src_offset; + uint32_t row, col, col_offset, src_rowsize, dst_rowsize, src_offset; unsigned char *src; unsigned char *dst; tsample_t s; @@ -4310,7 +4302,7 @@ combineSeparateTileSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, { for (s = 0; s < spp; s++) { - dump_info (dumpfile, format, "combineSeparateTileSamplesBytes","Input data, Sample %d", s); + dump_info (dumpfile, format, "combineSeparateTileSamplesBytes","Input data, Sample %"PRIu16, s); dump_buffer(dumpfile, format, 1, cols, row, srcbuffs[s] + (row * src_rowsize)); } } @@ -4343,17 +4335,17 @@ combineSeparateTileSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, } /* end combineSeparateTileSamplesBytes */ static int -combineSeparateTileSamples8bits (uint8 *in[], uint8 *out, uint32 cols, - uint32 rows, uint32 imagewidth, - uint32 tw, uint16 spp, uint16 bps, - FILE *dumpfile, int format, int level) +combineSeparateTileSamples8bits (uint8_t *in[], uint8_t *out, uint32_t cols, + uint32_t rows, uint32_t imagewidth, + uint32_t tw, uint16_t spp, uint16_t bps, + FILE *dumpfile, int format, int level) { int ready_bits = 0; - uint32 src_rowsize, dst_rowsize, src_offset; - uint32 bit_offset; - uint32 row, col, src_byte = 0, src_bit = 0; - uint8 maskbits = 0, matchbits = 0; - uint8 buff1 = 0, buff2 = 0; + uint32_t src_rowsize, dst_rowsize, src_offset; + uint32_t bit_offset; + uint32_t row, col, src_byte = 0, src_bit = 0; + uint8_t maskbits = 0, matchbits = 0; + uint8_t buff1 = 0, buff2 = 0; tsample_t s; unsigned char *src = in[0]; unsigned char *dst = out; @@ -4367,7 +4359,7 @@ combineSeparateTileSamples8bits (uint8 *in[], uint8 *out, uint32 cols, src_rowsize = ((bps * tw) + 7) / 8; dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - maskbits = (uint8)-1 >> ( 8 - bps); + maskbits = (uint8_t)-1 >> (8 - bps); for (row = 0; row < rows; row++) { @@ -4407,8 +4399,8 @@ combineSeparateTileSamples8bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_byte (dumpfile, format, "Match bits", matchbits); dump_byte (dumpfile, format, "Src bits", *src); dump_byte (dumpfile, format, "Buff1 bits", buff1); @@ -4442,18 +4434,18 @@ combineSeparateTileSamples8bits (uint8 *in[], uint8 *out, uint32 cols, } /* end combineSeparateTileSamples8bits */ static int -combineSeparateTileSamples16bits (uint8 *in[], uint8 *out, uint32 cols, - uint32 rows, uint32 imagewidth, - uint32 tw, uint16 spp, uint16 bps, - FILE *dumpfile, int format, int level) +combineSeparateTileSamples16bits (uint8_t *in[], uint8_t *out, uint32_t cols, + uint32_t rows, uint32_t imagewidth, + uint32_t tw, uint16_t spp, uint16_t bps, + FILE *dumpfile, int format, int level) { int ready_bits = 0; - uint32 src_rowsize, dst_rowsize; - uint32 bit_offset, src_offset; - uint32 row, col, src_byte = 0, src_bit = 0; - uint16 maskbits = 0, matchbits = 0; - uint16 buff1 = 0, buff2 = 0; - uint8 bytebuff = 0; + uint32_t src_rowsize, dst_rowsize; + uint32_t bit_offset, src_offset; + uint32_t row, col, src_byte = 0, src_bit = 0; + uint16_t maskbits = 0, matchbits = 0; + uint16_t buff1 = 0, buff2 = 0; + uint8_t bytebuff = 0; tsample_t s; unsigned char *src = in[0]; unsigned char *dst = out; @@ -4467,7 +4459,7 @@ combineSeparateTileSamples16bits (uint8 *in[], uint8 *out, uint32 cols, src_rowsize = ((bps * tw) + 7) / 8; dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - maskbits = (uint16)-1 >> (16 - bps); + maskbits = (uint16_t)-1 >> (16 - bps); for (row = 0; row < rows; row++) { @@ -4513,8 +4505,8 @@ combineSeparateTileSamples16bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_short (dumpfile, format, "Match bits", matchbits); dump_data (dumpfile, format, "Src bits", src, 2); @@ -4551,18 +4543,18 @@ combineSeparateTileSamples16bits (uint8 *in[], uint8 *out, uint32 cols, } /* end combineSeparateTileSamples16bits */ static int -combineSeparateTileSamples24bits (uint8 *in[], uint8 *out, uint32 cols, - uint32 rows, uint32 imagewidth, - uint32 tw, uint16 spp, uint16 bps, - FILE *dumpfile, int format, int level) +combineSeparateTileSamples24bits (uint8_t *in[], uint8_t *out, uint32_t cols, + uint32_t rows, uint32_t imagewidth, + uint32_t tw, uint16_t spp, uint16_t bps, + FILE *dumpfile, int format, int level) { int ready_bits = 0; - uint32 src_rowsize, dst_rowsize; - uint32 bit_offset, src_offset; - uint32 row, col, src_byte = 0, src_bit = 0; - uint32 maskbits = 0, matchbits = 0; - uint32 buff1 = 0, buff2 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0; + uint32_t src_rowsize, dst_rowsize; + uint32_t bit_offset, src_offset; + uint32_t row, col, src_byte = 0, src_bit = 0; + uint32_t maskbits = 0, matchbits = 0; + uint32_t buff1 = 0, buff2 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0; tsample_t s; unsigned char *src = in[0]; unsigned char *dst = out; @@ -4576,7 +4568,7 @@ combineSeparateTileSamples24bits (uint8 *in[], uint8 *out, uint32 cols, src_rowsize = ((bps * tw) + 7) / 8; dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - maskbits = (uint32)-1 >> ( 32 - bps); + maskbits = (uint32_t)-1 >> (32 - bps); for (row = 0; row < rows; row++) { @@ -4625,8 +4617,8 @@ combineSeparateTileSamples24bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Samples %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_long (dumpfile, format, "Match bits ", matchbits); dump_data (dumpfile, format, "Src bits ", src, 4); dump_long (dumpfile, format, "Buff1 bits ", buff1); @@ -4675,19 +4667,19 @@ combineSeparateTileSamples24bits (uint8 *in[], uint8 *out, uint32 cols, } /* end combineSeparateTileSamples24bits */ static int -combineSeparateTileSamples32bits (uint8 *in[], uint8 *out, uint32 cols, - uint32 rows, uint32 imagewidth, - uint32 tw, uint16 spp, uint16 bps, - FILE *dumpfile, int format, int level) +combineSeparateTileSamples32bits (uint8_t *in[], uint8_t *out, uint32_t cols, + uint32_t rows, uint32_t imagewidth, + uint32_t tw, uint16_t spp, uint16_t bps, + FILE *dumpfile, int format, int level) { int ready_bits = 0 /*, shift_width = 0 */; - uint32 src_rowsize, dst_rowsize, bit_offset, src_offset; - uint32 src_byte = 0, src_bit = 0; - uint32 row, col; - uint32 longbuff1 = 0, longbuff2 = 0; - uint64 maskbits = 0, matchbits = 0; - uint64 buff1 = 0, buff2 = 0, buff3 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint32_t src_rowsize, dst_rowsize, bit_offset, src_offset; + uint32_t src_byte = 0, src_bit = 0; + uint32_t row, col; + uint32_t longbuff1 = 0, longbuff2 = 0; + uint64_t maskbits = 0, matchbits = 0; + uint64_t buff1 = 0, buff2 = 0, buff3 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; tsample_t s; unsigned char *src = in[0]; unsigned char *dst = out; @@ -4701,7 +4693,7 @@ combineSeparateTileSamples32bits (uint8 *in[], uint8 *out, uint32 cols, src_rowsize = ((bps * tw) + 7) / 8; dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - maskbits = (uint64)-1 >> ( 64 - bps); + maskbits = (uint64_t)-1 >> (64 - bps); /* shift_width = ((bps + 7) / 8) + 1; */ for (row = 0; row < rows; row++) @@ -4732,7 +4724,7 @@ combineSeparateTileSamples32bits (uint8 *in[], uint8 *out, uint32 cols, longbuff2 = longbuff1; } - buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; buff1 = (buff3 & matchbits) << (src_bit); /* If we have a full buffer's worth, write it out */ @@ -4763,8 +4755,8 @@ combineSeparateTileSamples32bits (uint8 *in[], uint8 *out, uint32 cols, if ((dumpfile != NULL) && (level == 3)) { dump_info (dumpfile, format, "", - "Row %3d, Col %3d, Sample %d, Src byte offset %3d bit offset %2d Dst offset %3d", - row + 1, col + 1, s, src_byte, src_bit, dst - out); + "Row %3"PRIu32", Col %3"PRIu32", Sample %"PRIu16", Src byte offset %3"PRIu32" bit offset %2"PRIu32" Dst offset %3td", + row + 1u, col + 1u, s, src_byte, src_bit, dst - out); dump_wide (dumpfile, format, "Match bits ", matchbits); dump_data (dumpfile, format, "Src bits ", src, 8); dump_wide (dumpfile, format, "Buff1 bits ", buff1); @@ -4807,18 +4799,18 @@ combineSeparateTileSamples32bits (uint8 *in[], uint8 *out, uint32 cols, } /* end combineSeparateTileSamples32bits */ -static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length, - uint32 width, uint16 spp, +static int readSeparateStripsIntoBuffer (TIFF *in, uint8_t *obuf, uint32_t length, + uint32_t width, uint16_t spp, struct dump_opts *dump) { int i, bytes_per_sample, bytes_per_pixel, shift_width, result = 1; - uint32 j; - int32 bytes_read = 0; - uint16 bps = 0, planar; - uint32 nstrips; - uint32 strips_per_sample; - uint32 src_rowsize, dst_rowsize, rows_processed, rps; - uint32 rows_this_strip = 0; + uint32_t j; + int32_t bytes_read = 0; + uint16_t bps = 0, planar; + uint32_t nstrips; + uint32_t strips_per_sample; + uint32_t src_rowsize, dst_rowsize, rows_processed, rps; + uint32_t rows_this_strip = 0; tsample_t s; tstrip_t strip; tsize_t scanlinesize = TIFFScanlineSize(in); @@ -4854,10 +4846,10 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length, if ((dump->infile != NULL) && (dump->level == 3)) { dump_info (dump->infile, dump->format, "", - "Image width %d, length %d, Scanline size, %4d bytes", + "Image width %"PRIu32", length %"PRIu32", Scanline size, %4"PRId64" bytes", width, length, scanlinesize); dump_info (dump->infile, dump->format, "", - "Bits per sample %d, Samples per pixel %d, Shift width %d", + "Bits per sample %"PRIu16", Samples per pixel %"PRIu16", Shift width %d", bps, spp, shift_width); } @@ -4883,7 +4875,7 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length, if (!buff) { TIFFError ("readSeparateStripsIntoBuffer", - "Unable to allocate strip read buffer for sample %d", s); + "Unable to allocate strip read buffer for sample %"PRIu16, s); for (i = 0; i < s; i++) _TIFFfree (srcbuffs[i]); return 0; @@ -4906,13 +4898,13 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length, if (bytes_read < 0 && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read strip %lu for sample %d", - (unsigned long) strip, s + 1); + "Error, can't read strip %"PRIu32" for sample %"PRIu32, + strip, s + 1u); result = 0; break; } #ifdef DEVELMODE - TIFFError("", "Strip %2d, read %5d bytes for %4d scanlines, shift width %d", + TIFFError("", "Strip %2"PRIu32", read %5"PRId32" bytes for %4"PRIu32" scanlines, shift width %d", strip, bytes_read, rows_this_strip, shift_width); #endif } @@ -4970,7 +4962,7 @@ static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length, break; } break; - default: TIFFError ("readSeparateStripsIntoBuffer", "Unsupported bit depth: %d", bps); + default: TIFFError ("readSeparateStripsIntoBuffer", "Unsupported bit depth: %"PRIu16, bps); result = 0; break; } @@ -5002,7 +4994,7 @@ static int get_page_geometry (char *name, struct pagedef *page) { char *ptr; - int n; + unsigned int n; for (ptr = name; *ptr; ptr++) *ptr = (char)tolower((int)*ptr); @@ -5044,11 +5036,11 @@ initPageSetup (struct pagedef *page, struct pageseg *pagelist, for (i = 0; i < MAX_SECTIONS; i++) { - pagelist[i].x1 = (uint32)0; - pagelist[i].x2 = (uint32)0; - pagelist[i].y1 = (uint32)0; - pagelist[i].y2 = (uint32)0; - pagelist[i].buffsize = (uint32)0; + pagelist[i].x1 = (uint32_t)0; + pagelist[i].x2 = (uint32_t)0; + pagelist[i].y1 = (uint32_t)0; + pagelist[i].y2 = (uint32_t)0; + pagelist[i].buffsize = (uint32_t)0; pagelist[i].position = 0; pagelist[i].total = 0; } @@ -5089,15 +5081,15 @@ initCropMasks (struct crop_mask *cps) cps->length = 0; for (i = 0; i < 4; i++) cps->margins[i] = 0.0; - cps->bufftotal = (uint32)0; - cps->combined_width = (uint32)0; - cps->combined_length = (uint32)0; - cps->rotation = (uint16)0; + cps->bufftotal = (uint32_t)0; + cps->combined_width = (uint32_t)0; + cps->combined_length = (uint32_t)0; + cps->rotation = (uint16_t)0; cps->photometric = INVERT_DATA_AND_TAG; - cps->mirror = (uint16)0; - cps->invert = (uint16)0; - cps->zones = (uint32)0; - cps->regions = (uint32)0; + cps->mirror = (uint16_t)0; + cps->invert = (uint16_t)0; + cps->zones = (uint32_t)0; + cps->regions = (uint32_t)0; for (i = 0; i < MAX_REGIONS; i++) { cps->corners[i].X1 = 0.0; @@ -5140,12 +5132,12 @@ computeInputPixelOffsets(struct crop_mask *crop, struct image_data *image, float xres, yres; /* Values for these offsets are in pixels from start of image, not bytes, * and are indexed from zero to width - 1 or length - 1 */ - uint32 tmargin, bmargin, lmargin, rmargin; - uint32 startx, endx; /* offsets of first and last columns to extract */ - uint32 starty, endy; /* offsets of first and last row to extract */ - uint32 width, length, crop_width, crop_length; - uint32 i, max_width, max_length, zwidth, zlength, buffsize; - uint32 x1, x2, y1, y2; + uint32_t tmargin, bmargin, lmargin, rmargin; + uint32_t startx, endx; /* offsets of first and last columns to extract */ + uint32_t starty, endy; /* offsets of first and last row to extract */ + uint32_t width, length, crop_width, crop_length; + uint32_t i, max_width, max_length, zwidth, zlength, buffsize; + uint32_t x1, x2, y1, y2; if (image->res_unit != RESUNIT_INCH && image->res_unit != RESUNIT_CENTIMETER) { @@ -5190,38 +5182,38 @@ computeInputPixelOffsets(struct crop_mask *crop, struct image_data *image, { if ((crop->res_unit == RESUNIT_INCH) || (crop->res_unit == RESUNIT_CENTIMETER)) { - x1 = (uint32) (crop->corners[i].X1 * scale * xres); - x2 = (uint32) (crop->corners[i].X2 * scale * xres); - y1 = (uint32) (crop->corners[i].Y1 * scale * yres); - y2 = (uint32) (crop->corners[i].Y2 * scale * yres); + x1 = (uint32_t) (crop->corners[i].X1 * scale * xres); + x2 = (uint32_t) (crop->corners[i].X2 * scale * xres); + y1 = (uint32_t) (crop->corners[i].Y1 * scale * yres); + y2 = (uint32_t) (crop->corners[i].Y2 * scale * yres); } else { - x1 = (uint32) (crop->corners[i].X1); - x2 = (uint32) (crop->corners[i].X2); - y1 = (uint32) (crop->corners[i].Y1); - y2 = (uint32) (crop->corners[i].Y2); + x1 = (uint32_t) (crop->corners[i].X1); + x2 = (uint32_t) (crop->corners[i].X2); + y1 = (uint32_t) (crop->corners[i].Y1); + y2 = (uint32_t) (crop->corners[i].Y2); } if (x1 < 1) crop->regionlist[i].x1 = 0; else - crop->regionlist[i].x1 = (uint32) (x1 - 1); + crop->regionlist[i].x1 = (uint32_t) (x1 - 1); if (x2 > image->width - 1) crop->regionlist[i].x2 = image->width - 1; else - crop->regionlist[i].x2 = (uint32) (x2 - 1); + crop->regionlist[i].x2 = (uint32_t) (x2 - 1); zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; if (y1 < 1) crop->regionlist[i].y1 = 0; else - crop->regionlist[i].y1 = (uint32) (y1 - 1); + crop->regionlist[i].y1 = (uint32_t) (y1 - 1); if (y2 > image->length - 1) crop->regionlist[i].y2 = image->length - 1; else - crop->regionlist[i].y2 = (uint32) (y2 - 1); + crop->regionlist[i].y2 = (uint32_t) (y2 - 1); zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; @@ -5230,7 +5222,7 @@ computeInputPixelOffsets(struct crop_mask *crop, struct image_data *image, if (zlength > max_length) max_length = zlength; - buffsize = (uint32) + buffsize = (uint32_t) (((zwidth * image->bps * image->spp + 7 ) / 8) * (zlength + 1)); crop->regionlist[i].buffsize = buffsize; @@ -5263,64 +5255,64 @@ computeInputPixelOffsets(struct crop_mask *crop, struct image_data *image, { if (crop->res_unit != RESUNIT_INCH && crop->res_unit != RESUNIT_CENTIMETER) { /* User has specified pixels as reference unit */ - tmargin = (uint32)(crop->margins[0]); - lmargin = (uint32)(crop->margins[1]); - bmargin = (uint32)(crop->margins[2]); - rmargin = (uint32)(crop->margins[3]); + tmargin = (uint32_t)(crop->margins[0]); + lmargin = (uint32_t)(crop->margins[1]); + bmargin = (uint32_t)(crop->margins[2]); + rmargin = (uint32_t)(crop->margins[3]); } else { /* inches or centimeters specified */ - tmargin = (uint32)(crop->margins[0] * scale * yres); - lmargin = (uint32)(crop->margins[1] * scale * xres); - bmargin = (uint32)(crop->margins[2] * scale * yres); - rmargin = (uint32)(crop->margins[3] * scale * xres); + tmargin = (uint32_t)(crop->margins[0] * scale * yres); + lmargin = (uint32_t)(crop->margins[1] * scale * xres); + bmargin = (uint32_t)(crop->margins[2] * scale * yres); + rmargin = (uint32_t)(crop->margins[3] * scale * xres); } if ((lmargin + rmargin) > image->width) { TIFFError("computeInputPixelOffsets", "Combined left and right margins exceed image width"); - lmargin = (uint32) 0; - rmargin = (uint32) 0; + lmargin = (uint32_t) 0; + rmargin = (uint32_t) 0; return (-1); } if ((tmargin + bmargin) > image->length) { TIFFError("computeInputPixelOffsets", "Combined top and bottom margins exceed image length"); - tmargin = (uint32) 0; - bmargin = (uint32) 0; + tmargin = (uint32_t) 0; + bmargin = (uint32_t) 0; return (-1); } } else { /* no margins requested */ - tmargin = (uint32) 0; - lmargin = (uint32) 0; - bmargin = (uint32) 0; - rmargin = (uint32) 0; + tmargin = (uint32_t) 0; + lmargin = (uint32_t) 0; + bmargin = (uint32_t) 0; + rmargin = (uint32_t) 0; } /* Width, height, and margins are expressed as pixel offsets into image */ if (crop->res_unit != RESUNIT_INCH && crop->res_unit != RESUNIT_CENTIMETER) { if (crop->crop_mode & CROP_WIDTH) - width = (uint32)crop->width; + width = (uint32_t)crop->width; else width = image->width - lmargin - rmargin; if (crop->crop_mode & CROP_LENGTH) - length = (uint32)crop->length; + length = (uint32_t)crop->length; else length = image->length - tmargin - bmargin; } else { if (crop->crop_mode & CROP_WIDTH) - width = (uint32)(crop->width * scale * image->xres); + width = (uint32_t)(crop->width * scale * image->xres); else width = image->width - lmargin - rmargin; if (crop->crop_mode & CROP_LENGTH) - length = (uint32)(crop->length * scale * image->yres); + length = (uint32_t)(crop->length * scale * image->yres); else length = image->length - tmargin - bmargin; } @@ -5424,15 +5416,15 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt { struct offset offsets; int i; - int32 test; - uint32 seg, total, need_buff = 0; - uint32 buffsize; - uint32 zwidth, zlength; + int32_t test; + uint32_t seg, total, need_buff = 0; + uint32_t buffsize; + uint32_t zwidth, zlength; memset(&offsets, '\0', sizeof(struct offset)); crop->bufftotal = 0; - crop->combined_width = (uint32)0; - crop->combined_length = (uint32)0; + crop->combined_width = (uint32_t)0; + crop->combined_length = (uint32_t)0; crop->selections = 0; /* Compute pixel offsets if margins or fixed width or length specified */ @@ -5469,9 +5461,9 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt if (dump->outfile != NULL) { - dump_info (dump->outfile, dump->format, "", "Margins: Top: %d Left: %d Bottom: %d Right: %d", + dump_info (dump->outfile, dump->format, "", "Margins: Top: %"PRIu32" Left: %"PRIu32" Bottom: %"PRIu32" Right: %"PRIu32, offsets.tmargin, offsets.lmargin, offsets.bmargin, offsets.rmargin); - dump_info (dump->outfile, dump->format, "", "Crop region within margins: Adjusted Width: %6d Length: %6d", + dump_info (dump->outfile, dump->format, "", "Crop region within margins: Adjusted Width: %6"PRIu32" Length: %6"PRIu32, offsets.crop_width, offsets.crop_length); } @@ -5511,14 +5503,14 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt crop->regionlist[i].y2 = offsets.endy; crop->regionlist[i].x1 = offsets.startx + - (uint32)(offsets.crop_width * 1.0 * (seg - 1) / total); - test = (int32)offsets.startx + - (int32)(offsets.crop_width * 1.0 * seg / total); + (uint32_t)(offsets.crop_width * 1.0 * (seg - 1) / total); + test = (int32_t)offsets.startx + + (int32_t)(offsets.crop_width * 1.0 * seg / total); if (test < 1 ) crop->regionlist[i].x2 = 0; else { - if (test > (int32)(image->width - 1)) + if (test > (int32_t)(image->width - 1)) crop->regionlist[i].x2 = image->width - 1; else crop->regionlist[i].x2 = test - 1; @@ -5526,18 +5518,18 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; /* This is passed to extractCropZone or extractCompositeZones */ - crop->combined_length = (uint32)zlength; + crop->combined_length = (uint32_t)zlength; if (crop->exp_mode == COMPOSITE_IMAGES) - crop->combined_width += (uint32)zwidth; + crop->combined_width += (uint32_t)zwidth; else - crop->combined_width = (uint32)zwidth; + crop->combined_width = (uint32_t)zwidth; break; case EDGE_BOTTOM: /* width from left, zones from bottom to top */ zwidth = offsets.crop_width; crop->regionlist[i].x1 = offsets.startx; crop->regionlist[i].x2 = offsets.endx; - test = offsets.endy - (uint32)(offsets.crop_length * 1.0 * seg / total); + test = offsets.endy - (uint32_t)(offsets.crop_length * 1.0 * seg / total); if (test < 1 ) crop->regionlist[i].y1 = 0; else @@ -5548,7 +5540,7 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt crop->regionlist[i].y2 = 0; else { - if (test > (int32)(image->length - 1)) + if (test > (int32_t)(image->length - 1)) crop->regionlist[i].y2 = image->length - 1; else crop->regionlist[i].y2 = test; @@ -5557,10 +5549,10 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt /* This is passed to extractCropZone or extractCompositeZones */ if (crop->exp_mode == COMPOSITE_IMAGES) - crop->combined_length += (uint32)zlength; + crop->combined_length += (uint32_t)zlength; else - crop->combined_length = (uint32)zlength; - crop->combined_width = (uint32)zwidth; + crop->combined_length = (uint32_t)zlength; + crop->combined_width = (uint32_t)zwidth; break; case EDGE_RIGHT: /* zones from right to left, length from top */ zlength = offsets.crop_length; @@ -5568,14 +5560,14 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt crop->regionlist[i].y2 = offsets.endy; crop->regionlist[i].x1 = offsets.startx + - (uint32)(offsets.crop_width * (total - seg) * 1.0 / total); + (uint32_t)(offsets.crop_width * (total - seg) * 1.0 / total); test = offsets.startx + (offsets.crop_width * (total - seg + 1) * 1.0 / total); if (test < 1 ) crop->regionlist[i].x2 = 0; else { - if (test > (int32)(image->width - 1)) + if (test > (int32_t)(image->width - 1)) crop->regionlist[i].x2 = image->width - 1; else crop->regionlist[i].x2 = test - 1; @@ -5583,11 +5575,11 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; /* This is passed to extractCropZone or extractCompositeZones */ - crop->combined_length = (uint32)zlength; + crop->combined_length = (uint32_t)zlength; if (crop->exp_mode == COMPOSITE_IMAGES) - crop->combined_width += (uint32)zwidth; + crop->combined_width += (uint32_t)zwidth; else - crop->combined_width = (uint32)zwidth; + crop->combined_width = (uint32_t)zwidth; break; case EDGE_TOP: /* width from left, zones from top to bottom */ default: @@ -5595,13 +5587,13 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt crop->regionlist[i].x1 = offsets.startx; crop->regionlist[i].x2 = offsets.endx; - crop->regionlist[i].y1 = offsets.starty + (uint32)(offsets.crop_length * 1.0 * (seg - 1) / total); - test = offsets.starty + (uint32)(offsets.crop_length * 1.0 * seg / total); + crop->regionlist[i].y1 = offsets.starty + (uint32_t)(offsets.crop_length * 1.0 * (seg - 1) / total); + test = offsets.starty + (uint32_t)(offsets.crop_length * 1.0 * seg / total); if (test < 1 ) crop->regionlist[i].y2 = 0; else { - if (test > (int32)(image->length - 1)) + if (test > (int32_t)(image->length - 1)) crop->regionlist[i].y2 = image->length - 1; else crop->regionlist[i].y2 = test - 1; @@ -5610,26 +5602,26 @@ getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opt /* This is passed to extractCropZone or extractCompositeZones */ if (crop->exp_mode == COMPOSITE_IMAGES) - crop->combined_length += (uint32)zlength; + crop->combined_length += (uint32_t)zlength; else - crop->combined_length = (uint32)zlength; - crop->combined_width = (uint32)zwidth; + crop->combined_length = (uint32_t)zlength; + crop->combined_width = (uint32_t)zwidth; break; } /* end switch statement */ - buffsize = (uint32) + buffsize = (uint32_t) ((((zwidth * image->bps * image->spp) + 7 ) / 8) * (zlength + 1)); - crop->regionlist[i].width = (uint32) zwidth; - crop->regionlist[i].length = (uint32) zlength; + crop->regionlist[i].width = (uint32_t) zwidth; + crop->regionlist[i].length = (uint32_t) zlength; crop->regionlist[i].buffsize = buffsize; crop->bufftotal += buffsize; if (dump->outfile != NULL) - dump_info (dump->outfile, dump->format, "", "Zone %d, width: %4d, length: %4d, x1: %4d x2: %4d y1: %4d y2: %4d", - i + 1, (uint32)zwidth, (uint32)zlength, - crop->regionlist[i].x1, crop->regionlist[i].x2, - crop->regionlist[i].y1, crop->regionlist[i].y2); + dump_info (dump->outfile, dump->format, "", "Zone %d, width: %4"PRIu32", length: %4"PRIu32", x1: %4"PRIu32" x2: %4"PRIu32" y1: %4"PRIu32" y2: %4"PRIu32, + i + 1, zwidth, zlength, + crop->regionlist[i].x1, crop->regionlist[i].x2, + crop->regionlist[i].y1, crop->regionlist[i].y2); } return (0); @@ -5643,13 +5635,13 @@ computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, { double scale; double pwidth, plength; /* Output page width and length in user units*/ - uint32 iwidth, ilength; /* Input image width and length in pixels*/ - uint32 owidth, olength; /* Output image width and length in pixels*/ - uint32 orows, ocols; /* rows and cols for output */ - uint32 hmargin, vmargin; /* Horizontal and vertical margins */ - uint32 x1, x2, y1, y2, line_bytes; + uint32_t iwidth, ilength; /* Input image width and length in pixels*/ + uint32_t owidth, olength; /* Output image width and length in pixels*/ + uint32_t orows, ocols; /* rows and cols for output */ + uint32_t hmargin, vmargin; /* Horizontal and vertical margins */ + uint32_t x1, x2, y1, y2, line_bytes; /* unsigned int orientation; */ - uint32 i, j, k; + uint32_t i, j, k; scale = 1.0; if (page->res_unit == RESUNIT_NONE) @@ -5710,7 +5702,7 @@ computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, "Hmargin: %3.2f, Vmargin: %3.2f", page->name, page->vres, page->hres, page->hmargin, page->vmargin); - TIFFError("", "Res_unit: %d, Scale: %3.2f, Page width: %3.2f, length: %3.2f", + TIFFError("", "Res_unit: %"PRIu16", Scale: %3.2f, Page width: %3.2f, length: %3.2f", page->res_unit, scale, pwidth, plength); } @@ -5719,27 +5711,27 @@ computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, { if (page->res_unit == RESUNIT_INCH || page->res_unit == RESUNIT_CENTIMETER) { /* inches or centimeters specified */ - hmargin = (uint32)(page->hmargin * scale * page->hres * ((image->bps + 7)/ 8)); - vmargin = (uint32)(page->vmargin * scale * page->vres * ((image->bps + 7)/ 8)); + hmargin = (uint32_t)(page->hmargin * scale * page->hres * ((image->bps + 7) / 8)); + vmargin = (uint32_t)(page->vmargin * scale * page->vres * ((image->bps + 7) / 8)); } else { /* Otherwise user has specified pixels as reference unit */ - hmargin = (uint32)(page->hmargin * scale * ((image->bps + 7)/ 8)); - vmargin = (uint32)(page->vmargin * scale * ((image->bps + 7)/ 8)); + hmargin = (uint32_t)(page->hmargin * scale * ((image->bps + 7) / 8)); + vmargin = (uint32_t)(page->vmargin * scale * ((image->bps + 7) / 8)); } if ((hmargin * 2.0) > (pwidth * page->hres)) { TIFFError("computeOutputPixelOffsets", "Combined left and right margins exceed page width"); - hmargin = (uint32) 0; + hmargin = (uint32_t) 0; return (-1); } if ((vmargin * 2.0) > (plength * page->vres)) { TIFFError("computeOutputPixelOffsets", "Combined top and bottom margins exceed page length"); - vmargin = (uint32) 0; + vmargin = (uint32_t) 0; return (-1); } } @@ -5763,13 +5755,13 @@ computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, { if (page->mode & PAGE_MODE_PAPERSIZE ) { - owidth = (uint32)((pwidth * page->hres) - (hmargin * 2)); - olength = (uint32)((plength * page->vres) - (vmargin * 2)); + owidth = (uint32_t)((pwidth * page->hres) - (hmargin * 2)); + olength = (uint32_t)((plength * page->vres) - (vmargin * 2)); } else { - owidth = (uint32)(iwidth - (hmargin * 2 * page->hres)); - olength = (uint32)(ilength - (vmargin * 2 * page->vres)); + owidth = (uint32_t)(iwidth - (hmargin * 2 * page->hres)); + olength = (uint32_t)(ilength - (vmargin * 2 * page->vres)); } } @@ -5844,14 +5836,14 @@ computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, /* build the list of offsets for each output section */ for (k = 0, i = 0 && k <= MAX_SECTIONS; i < orows; i++) { - y1 = (uint32)(olength * i); - y2 = (uint32)(olength * (i + 1) - 1); + y1 = (uint32_t)(olength * i); + y2 = (uint32_t)(olength * (i + 1) - 1); if (y2 >= ilength) y2 = ilength - 1; for (j = 0; j < ocols; j++, k++) { - x1 = (uint32)(owidth * j); - x2 = (uint32)(owidth * (j + 1) - 1); + x1 = (uint32_t)(owidth * j); + x2 = (uint32_t)(owidth * (j + 1) - 1); if (x2 >= iwidth) x2 = iwidth - 1; sections[k].x1 = x1; @@ -5869,29 +5861,29 @@ computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, static int loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned char **read_ptr) { - uint32 i; + uint32_t i; float xres = 0.0, yres = 0.0; - uint32 nstrips = 0, ntiles = 0; - uint16 planar = 0; - uint16 bps = 0, spp = 0, res_unit = 0; - uint16 orientation = 0; - uint16 input_compression = 0, input_photometric = 0; - uint16 subsampling_horiz, subsampling_vert; - uint32 width = 0, length = 0; - uint32 stsize = 0, tlsize = 0, buffsize = 0, scanlinesize = 0; - uint32 tw = 0, tl = 0; /* Tile width and length */ - uint32 tile_rowsize = 0; + uint32_t nstrips = 0, ntiles = 0; + uint16_t planar = 0; + uint16_t bps = 0, spp = 0, res_unit = 0; + uint16_t orientation = 0; + uint16_t input_compression = 0, input_photometric = 0; + uint16_t subsampling_horiz, subsampling_vert; + uint32_t width = 0, length = 0; + uint32_t stsize = 0, tlsize = 0, buffsize = 0, scanlinesize = 0; + uint32_t tw = 0, tl = 0; /* Tile width and length */ + uint32_t tile_rowsize = 0; unsigned char *read_buff = NULL; unsigned char *new_buff = NULL; int readunit = 0; - static uint32 prev_readsize = 0; + static uint32_t prev_readsize = 0; TIFFGetFieldDefaulted(in, TIFFTAG_BITSPERSAMPLE, &bps); TIFFGetFieldDefaulted(in, TIFFTAG_SAMPLESPERPIXEL, &spp); TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar); TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation); if (! TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric)) - TIFFError("loadImage","Image lacks Photometric interpreation tag"); + TIFFError("loadImage","Image lacks Photometric interpretation tag"); if (! TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width)) TIFFError("loadimage","Image lacks image width tag"); if(! TIFFGetField(in, TIFFTAG_IMAGELENGTH, &length)) @@ -6066,7 +6058,7 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c if ((bps == 0) || (spp == 0)) { - TIFFError("loadImage", "Invalid samples per pixel (%d) or bits per sample (%d)", + TIFFError("loadImage", "Invalid samples per pixel (%"PRIu16") or bits per sample (%"PRIu16")", spp, bps); return (-1); } @@ -6092,7 +6084,7 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c exit(EXIT_FAILURE); } - if (buffsize < (uint32)(ntiles * tl * tile_rowsize)) + if (buffsize < (uint32_t)(ntiles * tl * tile_rowsize)) { buffsize = ntiles * tl * tile_rowsize; if (ntiles != (buffsize / tl / tile_rowsize)) @@ -6103,19 +6095,19 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c #ifdef DEBUG2 TIFFError("loadImage", - "Tilesize %u is too small, using ntiles * tilelength * tilerowsize %lu", - tlsize, (unsigned long)buffsize); + "Tilesize %"PRIu32" is too small, using ntiles * tilelength * tilerowsize %"PRIu32, + tlsize, buffsize); #endif } if (dump->infile != NULL) dump_info (dump->infile, dump->format, "", - "Tilesize: %u, Number of Tiles: %u, Tile row size: %u", + "Tilesize: %"PRIu32", Number of Tiles: %"PRIu32", Tile row size: %"PRIu32, tlsize, ntiles, tile_rowsize); } else { - uint32 buffsize_check; + uint32_t buffsize_check; readunit = STRIP; TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); stsize = TIFFStripSize(in); @@ -6138,19 +6130,19 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c TIFFError("loadImage", "Integer overflow detected."); exit(EXIT_FAILURE); } - if (buffsize < (uint32) (((length * width * spp * bps) + 7) / 8)) + if (buffsize < (uint32_t) (((length * width * spp * bps) + 7) / 8)) { buffsize = ((length * width * spp * bps) + 7) / 8; #ifdef DEBUG2 TIFFError("loadImage", - "Stripsize %u is too small, using imagelength * width * spp * bps / 8 = %lu", + "Stripsize %"PRIu32" is too small, using imagelength * width * spp * bps / 8 = %"PRIu32, stsize, (unsigned long)buffsize); #endif } if (dump->infile != NULL) dump_info (dump->infile, dump->format, "", - "Stripsize: %u, Number of Strips: %u, Rows per Strip: %u, Scanline size: %u", + "Stripsize: %"PRIu32", Number of Strips: %"PRIu32", Rows per Strip: %"PRIu32", Scanline size: %"PRIu32, stsize, nstrips, rowsperstrip, scanlinesize); } @@ -6169,7 +6161,7 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c if (subsampling_horiz != 1 || subsampling_vert != 1) { TIFFError("loadImage", - "Can't copy/convert subsampled image with subsampling %d horiz %d vert", + "Can't copy/convert subsampled image with subsampling %"PRIu16" horiz %"PRIu16" vert", subsampling_horiz, subsampling_vert); return (-1); } @@ -6269,10 +6261,10 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c if ((dump->infile != NULL) && (dump->level == 2)) { dump_info (dump->infile, dump->format, "loadImage", - "Image width %d, length %d, Raw image data, %4d bytes", + "Image width %"PRIu32", length %"PRIu32", Raw image data, %4"PRIu32" bytes", width, length, buffsize); dump_info (dump->infile, dump->format, "", - "Bits per sample %d, Samples per pixel %d", bps, spp); + "Bits per sample %"PRIu16", Samples per pixel %"PRIu16, bps, spp); for (i = 0; i < length; i++) dump_buffer(dump->infile, dump->format, 1, scanlinesize, @@ -6283,7 +6275,7 @@ loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned c static int correct_orientation(struct image_data *image, unsigned char **work_buff_ptr) { - uint16 mirror, rotation; + uint16_t mirror, rotation; unsigned char *work_buff; work_buff = *work_buff_ptr; @@ -6295,7 +6287,7 @@ static int correct_orientation(struct image_data *image, unsigned char **work_b if ((image->adjustments & MIRROR_HORIZ) || (image->adjustments & MIRROR_VERT)) { - mirror = (uint16)(image->adjustments & MIRROR_BOTH); + mirror = (uint16_t)(image->adjustments & MIRROR_BOTH); if (mirrorImage(image->spp, image->bps, mirror, image->width, image->length, work_buff)) { @@ -6307,17 +6299,17 @@ static int correct_orientation(struct image_data *image, unsigned char **work_b if (image->adjustments & ROTATE_ANY) { if (image->adjustments & ROTATECW_90) - rotation = (uint16) 90; + rotation = (uint16_t) 90; else if (image->adjustments & ROTATECW_180) - rotation = (uint16) 180; + rotation = (uint16_t) 180; else if (image->adjustments & ROTATECW_270) - rotation = (uint16) 270; + rotation = (uint16_t) 270; else { - TIFFError ("correct_orientation", "Invalid rotation value: %d", - image->adjustments & ROTATE_ANY); + TIFFError ("correct_orientation", "Invalid rotation value: %"PRIu16, + (uint16_t) (image->adjustments & ROTATE_ANY)); return (-1); } @@ -6339,13 +6331,13 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, unsigned char *read_buff, unsigned char *crop_buff) { int shift_width, bytes_per_sample, bytes_per_pixel; - uint32 i, trailing_bits, prev_trailing_bits; - uint32 row, first_row, last_row, first_col, last_col; - uint32 src_rowsize, dst_rowsize, src_offset, dst_offset; - uint32 crop_width, crop_length, img_width /*, img_length */; - uint32 prev_length, prev_width, composite_width; - uint16 bps, spp; - uint8 *src, *dst; + uint32_t i, trailing_bits, prev_trailing_bits; + uint32_t row, first_row, last_row, first_col, last_col; + uint32_t src_rowsize, dst_rowsize, src_offset, dst_offset; + uint32_t crop_width, crop_length, img_width /*, img_length */; + uint32_t prev_length, prev_width, composite_width; + uint16_t bps, spp; + uint8_t *src, *dst; tsample_t count, sample = 0; /* Update to extract one or more samples */ img_width = image->width; @@ -6422,7 +6414,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, last_col + 1)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6434,7 +6426,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6446,7 +6438,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6456,7 +6448,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6468,11 +6460,11 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; - default: TIFFError("extractCompositeRegions", "Unsupported bit depth %d", bps); + default: TIFFError("extractCompositeRegions", "Unsupported bit depth %"PRIu16, bps); return (1); } } @@ -6504,7 +6496,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, first_col, last_col + 1)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6516,7 +6508,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6528,7 +6520,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6538,7 +6530,7 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6550,11 +6542,11 @@ extractCompositeRegions(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractCompositeRegions", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; - default: TIFFError("extractCompositeRegions", "Unsupported bit depth %d", bps); + default: TIFFError("extractCompositeRegions", "Unsupported bit depth %"PRIu16, bps); return (1); } } @@ -6588,13 +6580,13 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, int region) { int shift_width, prev_trailing_bits = 0; - uint32 bytes_per_sample, bytes_per_pixel; - uint32 src_rowsize, dst_rowsize; - uint32 row, first_row, last_row, first_col, last_col; - uint32 src_offset, dst_offset; - uint32 crop_width, crop_length, img_width /*, img_length */; - uint16 bps, spp; - uint8 *src, *dst; + uint32_t bytes_per_sample, bytes_per_pixel; + uint32_t src_rowsize, dst_rowsize; + uint32_t row, first_row, last_row, first_col, last_col; + uint32_t src_offset, dst_offset; + uint32_t crop_width, crop_length, img_width /*, img_length */; + uint16_t bps, spp; + uint8_t *src, *dst; tsample_t count, sample = 0; /* Update to extract more or more samples */ img_width = image->width; @@ -6647,7 +6639,7 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, last_col + 1)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6659,7 +6651,7 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6671,7 +6663,7 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6681,7 +6673,7 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; @@ -6693,11 +6685,11 @@ extractSeparateRegion(struct image_data *image, struct crop_mask *crop, prev_trailing_bits)) { TIFFError("extractSeparateRegion", - "Unable to extract row %d", row); + "Unable to extract row %"PRIu32, row); return (1); } break; - default: TIFFError("extractSeparateRegion", "Unsupported bit depth %d", bps); + default: TIFFError("extractSeparateRegion", "Unsupported bit depth %"PRIu16, bps); return (1); } } @@ -6714,19 +6706,19 @@ extractImageSection(struct image_data *image, struct pageseg *section, /* unsigned char *src, *dst; */ #endif - uint32 img_width, img_rowsize; + uint32_t img_width, img_rowsize; #ifdef DEVELMODE - uint32 img_length; + uint32_t img_length; #endif - uint32 j, shift1, shift2, trailing_bits; - uint32 row, first_row, last_row, first_col, last_col; - uint32 src_offset, dst_offset, row_offset, col_offset; - uint32 offset1, offset2, full_bytes; - uint32 sect_width; + uint32_t j, shift1, shift2, trailing_bits; + uint32_t row, first_row, last_row, first_col, last_col; + uint32_t src_offset, dst_offset, row_offset, col_offset; + uint32_t offset1, offset2, full_bytes; + uint32_t sect_width; #ifdef DEVELMODE - uint32 sect_length; + uint32_t sect_length; #endif - uint16 bps, spp; + uint16_t bps, spp; #ifdef DEVELMODE int k; @@ -6774,11 +6766,11 @@ extractImageSection(struct image_data *image, struct pageseg *section, trailing_bits = (sect_width * bps) % 8; #ifdef DEVELMODE - TIFFError ("", "First row: %d, last row: %d, First col: %d, last col: %d\n", + TIFFError ("", "First row: %"PRIu32", last row: %"PRIu32", First col: %"PRIu32", last col: %"PRIu32"\n", first_row, last_row, first_col, last_col); - TIFFError ("", "Image width: %d, Image length: %d, bps: %d, spp: %d\n", + TIFFError ("", "Image width: %"PRIu32", Image length: %"PRIu32", bps: %"PRIu16", spp: %"PRIu16"\n", img_width, img_length, bps, spp); - TIFFError ("", "Sect width: %d, Sect length: %d, full bytes: %d trailing bits %d\n", + TIFFError ("", "Sect width: %"PRIu32", Sect length: %"PRIu32", full bytes: %"PRIu32" trailing bits %"PRIu32"\n", sect_width, sect_length, full_bytes, trailing_bits); #endif @@ -6792,7 +6784,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, src_offset = row_offset + col_offset; #ifdef DEVELMODE - TIFFError ("", "Src offset: %8d, Dst offset: %8d", src_offset, dst_offset); + TIFFError ("", "Src offset: %8"PRIu32", Dst offset: %8"PRIu32, src_offset, dst_offset); #endif _TIFFmemcpy (sect_buff + dst_offset, src_buff + src_offset, full_bytes); dst_offset += full_bytes; @@ -6823,7 +6815,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, sprintf(&bitarray[j], (bitset) ? "1" : "0"); } bitarray[18] = '\0'; - TIFFError ("", "Row: %3d Offset1: %d, Shift1: %d, Offset2: %d, Shift2: %d\n", + TIFFError ("", "Row: %3d Offset1: %"PRIu32", Shift1: %"PRIu32", Offset2: %"PRIu32", Shift2: %"PRIu32"\n", row, offset1, shift1, offset2, shift2); #endif @@ -6833,7 +6825,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, _TIFFmemcpy (sect_buff + dst_offset, src_buff + offset1, full_bytes); #ifdef DEVELMODE - TIFFError ("", " Aligned data src offset1: %8d, Dst offset: %8d\n", offset1, dst_offset); + TIFFError ("", " Aligned data src offset1: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset1, dst_offset); sprintf(&bitarray[18], "\n"); sprintf(&bitarray[19], "\t"); for (j = 20, k = 7; j < 28; j++, k--) @@ -6851,7 +6843,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, bytebuff2 = src_buff[offset2] & ((unsigned char)255 << (7 - shift2)); sect_buff[dst_offset] = bytebuff2; #ifdef DEVELMODE - TIFFError ("", " Trailing bits src offset: %8d, Dst offset: %8d\n", + TIFFError ("", " Trailing bits src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset2, dst_offset); for (j = 30, k = 7; j < 38; j++, k--) { @@ -6867,7 +6859,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, else /* each destination byte will have to be built from two source bytes*/ { #ifdef DEVELMODE - TIFFError ("", " Unalligned data src offset: %8d, Dst offset: %8d\n", offset1 , dst_offset); + TIFFError ("", " Unalligned data src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset1 , dst_offset); #endif for (j = 0; j <= full_bytes; j++) { @@ -6891,7 +6883,7 @@ extractImageSection(struct image_data *image, struct pageseg *section, if (trailing_bits != 0) { #ifdef DEVELMODE - TIFFError ("", " Trailing bits src offset: %8d, Dst offset: %8d\n", offset1 + full_bytes, dst_offset); + TIFFError ("", " Trailing bits src offset: %8"PRIu32", Dst offset: %8"PRIu32"\n", offset1 + full_bytes, dst_offset); #endif if (shift2 > shift1) { @@ -7051,7 +7043,7 @@ writeImageSections(TIFF *in, TIFF *out, struct image_data *image, unsigned char **sect_buff_ptr) { double hres, vres; - uint32 i, k, width, length, sectsize; + uint32_t i, k, width, length, sectsize; unsigned char *sect_buff = *sect_buff_ptr; hres = page->hres; @@ -7061,7 +7053,7 @@ writeImageSections(TIFF *in, TIFF *out, struct image_data *image, if ((k < 1) || (k > MAX_SECTIONS)) { TIFFError("writeImageSections", - "%d Rows and Columns exceed maximum sections\nIncrease resolution or reduce sections", k); + "%"PRIu32" Rows and Columns exceed maximum sections\nIncrease resolution or reduce sections", k); return (-1); } @@ -7069,7 +7061,7 @@ writeImageSections(TIFF *in, TIFF *out, struct image_data *image, { width = sections[i].x2 - sections[i].x1 + 1; length = sections[i].y2 - sections[i].y1 + 1; - sectsize = (uint32) + sectsize = (uint32_t) ceil((width * image->bps + 7) / (double)8) * image->spp * length; /* allocate a buffer if we don't have one already */ if (createImageSection(sectsize, sect_buff_ptr)) @@ -7104,14 +7096,14 @@ writeImageSections(TIFF *in, TIFF *out, struct image_data *image, */ static int writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, - struct dump_opts *dump, uint32 width, uint32 length, + struct dump_opts *dump, uint32_t width, uint32_t length, double hres, double vres, unsigned char *sect_buff) { - uint16 bps, spp; - uint16 input_compression, input_photometric; - uint16 input_planar; - struct cpTag* p; + uint16_t bps, spp; + uint16_t input_compression, input_photometric; + uint16_t input_planar; + const struct cpTag* p; /* Calling this seems to reset the compression mode on the TIFF *in file. TIFFGetField(in, TIFFTAG_JPEGCOLORMODE, &input_jpeg_colormode); @@ -7135,8 +7127,8 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, * if the user has specified a command line option for * a compression option. Should be passed around in one * of the parameters instead of as a global. If no user - * option specified it will still be (uint16) -1. */ - if (compression != (uint16)-1) + * option specified it will still be (uint16_t) -1. */ + if (compression != (uint16_t)-1) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); else { /* OJPEG is no longer supported for writing so upgrade to JPEG */ @@ -7220,9 +7212,9 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, * input image or, if nothing is defined, use the * library default. */ - if (tilewidth == (uint32) 0) + if (tilewidth == (uint32_t) 0) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); - if (tilelength == (uint32) 0) + if (tilelength == (uint32_t) 0) TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); if (tilewidth == 0 || tilelength == 0) @@ -7236,7 +7228,7 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, * value from the input image or, if nothing is defined, * use the library default. */ - if (rowsperstrip == (uint32) 0) + if (rowsperstrip == (uint32_t) 0) { if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); @@ -7247,13 +7239,13 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, } } else - if (rowsperstrip == (uint32) -1) + if (rowsperstrip == (uint32_t) -1) rowsperstrip = length; TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); } TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &input_planar); - if (config != (uint16) -1) + if (config != (uint16_t) -1) TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); else CopyField(TIFFTAG_PLANARCONFIG, config); @@ -7282,7 +7274,7 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, case COMPRESSION_LZW: case COMPRESSION_ADOBE_DEFLATE: case COMPRESSION_DEFLATE: - if (predictor != (uint16)-1) + if (predictor != (uint16_t)-1) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); else CopyField(TIFFTAG_PREDICTOR, predictor); @@ -7290,7 +7282,7 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, case COMPRESSION_CCITTFAX3: case COMPRESSION_CCITTFAX4: if (compression == COMPRESSION_CCITTFAX3) { - if (g3opts != (uint32) -1) + if (g3opts != (uint32_t) -1) TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); else CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); @@ -7305,12 +7297,12 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); break; } - { uint32 len32; + { uint32_t len32; void** data; if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); } - { uint16 ninks; + { uint16_t ninks; const char* inknames; if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); @@ -7374,11 +7366,11 @@ writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, /* Create a buffer to write one section at a time */ static int -createImageSection(uint32 sectsize, unsigned char **sect_buff_ptr) +createImageSection(uint32_t sectsize, unsigned char **sect_buff_ptr) { unsigned char *sect_buff = NULL; unsigned char *new_buff = NULL; - static uint32 prev_sectsize = 0; + static uint32_t prev_sectsize = 0; sect_buff = *sect_buff_ptr; @@ -7423,7 +7415,7 @@ processCropSelections(struct image_data *image, struct crop_mask *crop, unsigned char **read_buff_ptr, struct buffinfo seg_buffs[]) { int i; - uint32 width, length, total_width, total_length; + uint32_t width, length, total_width, total_length; tsize_t cropsize; unsigned char *crop_buff = NULL; unsigned char *read_buff = NULL; @@ -7523,7 +7515,7 @@ processCropSelections(struct image_data *image, struct crop_mask *crop, &crop->combined_length, &crop_buff)) { TIFFError("processCropSelections", - "Failed to rotate composite regions by %d degrees", crop->rotation); + "Failed to rotate composite regions by %"PRIu32" degrees", crop->rotation); return (-1); } seg_buffs[0].buffer = crop_buff; @@ -7629,7 +7621,7 @@ processCropSelections(struct image_data *image, struct crop_mask *crop, &crop->regionlist[i].length, &crop_buff)) { TIFFError("processCropSelections", - "Failed to rotate crop region by %d degrees", crop->rotation); + "Failed to rotate crop region by %"PRIu16" degrees", crop->rotation); return (-1); } total_width += crop->regionlist[i].width; @@ -7647,7 +7639,7 @@ processCropSelections(struct image_data *image, struct crop_mask *crop, /* Copy the crop section of the data from the current image into a buffer * and adjust the IFD values to reflect the new size. If no cropping is - * required, use the origial read buffer as the crop buffer. + * required, use the original read buffer as the crop buffer. * * There is quite a bit of redundancy between this routine and the more * specialized processCropSelections, but this provides @@ -7757,7 +7749,7 @@ createCroppedImage(struct image_data *image, struct crop_mask *crop, &crop->combined_length, crop_buff_ptr)) { TIFFError("createCroppedImage", - "Failed to rotate image or cropped selection by %d degrees", crop->rotation); + "Failed to rotate image or cropped selection by %"PRIu16" degrees", crop->rotation); return (-1); } } @@ -7781,14 +7773,14 @@ createCroppedImage(struct image_data *image, struct crop_mask *crop, * then passed in as an argument. */ static int -writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, - struct dump_opts *dump, uint32 width, uint32 length, +writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, + struct dump_opts *dump, uint32_t width, uint32_t length, unsigned char *crop_buff, int pagenum, int total_pages) { - uint16 bps, spp; - uint16 input_compression, input_photometric; - uint16 input_planar; - struct cpTag* p; + uint16_t bps, spp; + uint16_t input_compression, input_photometric; + uint16_t input_planar; + const struct cpTag* p; input_compression = image->compression; input_photometric = image->photometric; @@ -7806,7 +7798,7 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, ((input_compression == COMPRESSION_JPEG) ? "New Jpeg" : "Non Jpeg")); #endif - if (compression != (uint16)-1) + if (compression != (uint16_t)-1) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); else { @@ -7895,9 +7887,9 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, * input image or, if nothing is defined, use the * library default. */ - if (tilewidth == (uint32) 0) + if (tilewidth == (uint32_t) 0) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); - if (tilelength == (uint32) 0) + if (tilelength == (uint32_t) 0) TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); if (tilewidth == 0 || tilelength == 0) @@ -7910,7 +7902,7 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, * value from the input image or, if nothing is defined, * use the library default. */ - if (rowsperstrip == (uint32) 0) + if (rowsperstrip == (uint32_t) 0) { if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); @@ -7921,13 +7913,13 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, } } else - if (rowsperstrip == (uint32) -1) + if (rowsperstrip == (uint32_t) -1) rowsperstrip = length; TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); } TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &input_planar); - if (config != (uint16) -1) + if (config != (uint16_t) -1) TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); else CopyField(TIFFTAG_PLANARCONFIG, config); @@ -7953,7 +7945,7 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, case COMPRESSION_LZW: case COMPRESSION_ADOBE_DEFLATE: case COMPRESSION_DEFLATE: - if (predictor != (uint16)-1) + if (predictor != (uint16_t)-1) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); else CopyField(TIFFTAG_PREDICTOR, predictor); @@ -7967,7 +7959,7 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, return (-1); } if (compression == COMPRESSION_CCITTFAX3) { - if (g3opts != (uint32) -1) + if (g3opts != (uint32_t) -1) TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); else CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); @@ -7985,12 +7977,12 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, break; default: break; } - { uint32 len32; + { uint32_t len32; void** data; if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); } - { uint16 ninks; + { uint16_t ninks; const char* inknames; if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); @@ -8057,15 +8049,15 @@ writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, } /* end writeCroppedImage */ static int -rotateContigSamples8bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, - uint32 length, uint32 col, uint8 *src, uint8 *dst) +rotateContigSamples8bits(uint16_t rotation, uint16_t spp, uint16_t bps, uint32_t width, + uint32_t length, uint32_t col, uint8_t *src, uint8_t *dst) { int ready_bits = 0; - uint32 src_byte = 0, src_bit = 0; - uint32 row, rowsize = 0, bit_offset = 0; - uint8 matchbits = 0, maskbits = 0; - uint8 buff1 = 0, buff2 = 0; - uint8 *next; + uint32_t src_byte = 0, src_bit = 0; + uint32_t row, rowsize = 0, bit_offset = 0; + uint8_t matchbits = 0, maskbits = 0; + uint8_t buff1 = 0, buff2 = 0; + uint8_t *next; tsample_t sample; if ((src == NULL) || (dst == NULL)) @@ -8076,7 +8068,7 @@ rotateContigSamples8bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, rowsize = ((bps * spp * width) + 7) / 8; ready_bits = 0; - maskbits = (uint8)-1 >> ( 8 - bps); + maskbits = (uint8_t)-1 >> (8 - bps); buff1 = buff2 = 0; for (row = 0; row < length ; row++) @@ -8101,7 +8093,7 @@ rotateContigSamples8bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, break; case 270: next = src + src_byte + (row * rowsize); break; - default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %"PRIu16, rotation); return (1); } matchbits = maskbits << (8 - src_bit - bps); @@ -8133,16 +8125,16 @@ rotateContigSamples8bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, static int -rotateContigSamples16bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, - uint32 length, uint32 col, uint8 *src, uint8 *dst) +rotateContigSamples16bits(uint16_t rotation, uint16_t spp, uint16_t bps, uint32_t width, + uint32_t length, uint32_t col, uint8_t *src, uint8_t *dst) { int ready_bits = 0; - uint32 row, rowsize, bit_offset; - uint32 src_byte = 0, src_bit = 0; - uint16 matchbits = 0, maskbits = 0; - uint16 buff1 = 0, buff2 = 0; - uint8 bytebuff = 0; - uint8 *next; + uint32_t row, rowsize, bit_offset; + uint32_t src_byte = 0, src_bit = 0; + uint16_t matchbits = 0, maskbits = 0; + uint16_t buff1 = 0, buff2 = 0; + uint8_t bytebuff = 0; + uint8_t *next; tsample_t sample; if ((src == NULL) || (dst == NULL)) @@ -8153,7 +8145,7 @@ rotateContigSamples16bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, rowsize = ((bps * spp * width) + 7) / 8; ready_bits = 0; - maskbits = (uint16)-1 >> (16 - bps); + maskbits = (uint16_t)-1 >> (16 - bps); buff1 = buff2 = 0; for (row = 0; row < length; row++) { @@ -8177,7 +8169,7 @@ rotateContigSamples16bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, break; case 270: next = src + src_byte + (row * rowsize); break; - default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %"PRIu16, rotation); return (1); } matchbits = maskbits << (16 - src_bit - bps); @@ -8216,16 +8208,16 @@ rotateContigSamples16bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, } /* end rotateContigSamples16bits */ static int -rotateContigSamples24bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, - uint32 length, uint32 col, uint8 *src, uint8 *dst) +rotateContigSamples24bits(uint16_t rotation, uint16_t spp, uint16_t bps, uint32_t width, + uint32_t length, uint32_t col, uint8_t *src, uint8_t *dst) { int ready_bits = 0; - uint32 row, rowsize, bit_offset; - uint32 src_byte = 0, src_bit = 0; - uint32 matchbits = 0, maskbits = 0; - uint32 buff1 = 0, buff2 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0; - uint8 *next; + uint32_t row, rowsize, bit_offset; + uint32_t src_byte = 0, src_bit = 0; + uint32_t matchbits = 0, maskbits = 0; + uint32_t buff1 = 0, buff2 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0; + uint8_t *next; tsample_t sample; @@ -8237,7 +8229,7 @@ rotateContigSamples24bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, rowsize = ((bps * spp * width) + 7) / 8; ready_bits = 0; - maskbits = (uint32)-1 >> (32 - bps); + maskbits = (uint32_t)-1 >> (32 - bps); buff1 = buff2 = 0; for (row = 0; row < length; row++) { @@ -8261,7 +8253,7 @@ rotateContigSamples24bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, break; case 270: next = src + src_byte + (row * rowsize); break; - default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %"PRIu16, rotation); return (1); } matchbits = maskbits << (32 - src_bit - bps); @@ -8307,18 +8299,18 @@ rotateContigSamples24bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, } /* end rotateContigSamples24bits */ static int -rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, - uint32 length, uint32 col, uint8 *src, uint8 *dst) +rotateContigSamples32bits(uint16_t rotation, uint16_t spp, uint16_t bps, uint32_t width, + uint32_t length, uint32_t col, uint8_t *src, uint8_t *dst) { int ready_bits = 0 /*, shift_width = 0 */; /* int bytes_per_sample, bytes_per_pixel; */ - uint32 row, rowsize, bit_offset; - uint32 src_byte, src_bit; - uint32 longbuff1 = 0, longbuff2 = 0; - uint64 maskbits = 0, matchbits = 0; - uint64 buff1 = 0, buff2 = 0, buff3 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - uint8 *next; + uint32_t row, rowsize, bit_offset; + uint32_t src_byte, src_bit; + uint32_t longbuff1 = 0, longbuff2 = 0; + uint64_t maskbits = 0, matchbits = 0; + uint64_t buff1 = 0, buff2 = 0, buff3 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8_t *next; tsample_t sample; @@ -8337,7 +8329,7 @@ rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, rowsize = ((bps * spp * width) + 7) / 8; ready_bits = 0; - maskbits = (uint64)-1 >> (64 - bps); + maskbits = (uint64_t)-1 >> (64 - bps); buff1 = buff2 = 0; for (row = 0; row < length; row++) { @@ -8361,7 +8353,7 @@ rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, break; case 270: next = src + src_byte + (row * rowsize); break; - default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %"PRIu16, rotation); return (1); } matchbits = maskbits << (64 - src_bit - bps); @@ -8376,7 +8368,7 @@ rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, longbuff2 = longbuff1; } - buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; buff1 = (buff3 & matchbits) << (src_bit); if (ready_bits < 32) @@ -8416,18 +8408,18 @@ rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, /* Rotate an image by a multiple of 90 degrees clockwise */ static int -rotateImage(uint16 rotation, struct image_data *image, uint32 *img_width, - uint32 *img_length, unsigned char **ibuff_ptr) +rotateImage(uint16_t rotation, struct image_data *image, uint32_t *img_width, + uint32_t *img_length, unsigned char **ibuff_ptr) { int shift_width; - uint32 bytes_per_pixel, bytes_per_sample; - uint32 row, rowsize, src_offset, dst_offset; - uint32 i, col, width, length; - uint32 colsize, buffsize, col_offset, pix_offset; + uint32_t bytes_per_pixel, bytes_per_sample; + uint32_t row, rowsize, src_offset, dst_offset; + uint32_t i, col, width, length; + uint32_t colsize, buffsize, col_offset, pix_offset; unsigned char *ibuff; unsigned char *src; unsigned char *dst; - uint16 spp, bps; + uint16_t spp, bps; float res_temp; unsigned char *rbuff = NULL; @@ -8457,7 +8449,7 @@ rotateImage(uint16 rotation, struct image_data *image, uint32 *img_width, case 90: case 180: case 270: break; - default: TIFFError("rotateImage", "Invalid rotation angle %d", rotation); + default: TIFFError("rotateImage", "Invalid rotation angle %"PRIu16, rotation); return (-1); } @@ -8527,7 +8519,7 @@ rotateImage(uint16 rotation, struct image_data *image, uint32 *img_width, return (-1); } break; - default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + default: TIFFError("rotateImage","Unsupported bit depth %"PRIu16, bps); _TIFFfree(rbuff); return (-1); } @@ -8596,7 +8588,7 @@ rotateImage(uint16 rotation, struct image_data *image, uint32 *img_width, return (-1); } break; - default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + default: TIFFError("rotateImage","Unsupported bit depth %"PRIu16, bps); _TIFFfree(rbuff); return (-1); } @@ -8673,7 +8665,7 @@ rotateImage(uint16 rotation, struct image_data *image, uint32 *img_width, return (-1); } break; - default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + default: TIFFError("rotateImage","Unsupported bit depth %"PRIu16, bps); _TIFFfree(rbuff); return (-1); } @@ -8698,15 +8690,15 @@ rotateImage(uint16 rotation, struct image_data *image, uint32 *img_width, } /* end rotateImage */ static int -reverseSamples8bits (uint16 spp, uint16 bps, uint32 width, - uint8 *ibuff, uint8 *obuff) +reverseSamples8bits (uint16_t spp, uint16_t bps, uint32_t width, + uint8_t *ibuff, uint8_t *obuff) { int ready_bits = 0; - uint32 col; - uint32 src_byte, src_bit; - uint32 bit_offset = 0; - uint8 match_bits = 0, mask_bits = 0; - uint8 buff1 = 0, buff2 = 0; + uint32_t col; + uint32_t src_byte, src_bit; + uint32_t bit_offset = 0; + uint8_t match_bits = 0, mask_bits = 0; + uint8_t buff1 = 0, buff2 = 0; unsigned char *src; unsigned char *dst; tsample_t sample; @@ -8718,7 +8710,7 @@ reverseSamples8bits (uint16 spp, uint16 bps, uint32 width, } ready_bits = 0; - mask_bits = (uint8)-1 >> ( 8 - bps); + mask_bits = (uint8_t)-1 >> (8 - bps); dst = obuff; for (col = width; col > 0; col--) { @@ -8763,16 +8755,16 @@ reverseSamples8bits (uint16 spp, uint16 bps, uint32 width, static int -reverseSamples16bits (uint16 spp, uint16 bps, uint32 width, - uint8 *ibuff, uint8 *obuff) +reverseSamples16bits (uint16_t spp, uint16_t bps, uint32_t width, + uint8_t *ibuff, uint8_t *obuff) { int ready_bits = 0; - uint32 col; - uint32 src_byte = 0, high_bit = 0; - uint32 bit_offset = 0; - uint16 match_bits = 0, mask_bits = 0; - uint16 buff1 = 0, buff2 = 0; - uint8 bytebuff = 0; + uint32_t col; + uint32_t src_byte = 0, high_bit = 0; + uint32_t bit_offset = 0; + uint16_t match_bits = 0, mask_bits = 0; + uint16_t buff1 = 0, buff2 = 0; + uint8_t bytebuff = 0; unsigned char *src; unsigned char *dst; tsample_t sample; @@ -8784,7 +8776,7 @@ reverseSamples16bits (uint16 spp, uint16 bps, uint32 width, } ready_bits = 0; - mask_bits = (uint16)-1 >> (16 - bps); + mask_bits = (uint16_t)-1 >> (16 - bps); dst = obuff; for (col = width; col > 0; col--) { @@ -8838,16 +8830,16 @@ reverseSamples16bits (uint16 spp, uint16 bps, uint32 width, } /* end reverseSamples16bits */ static int -reverseSamples24bits (uint16 spp, uint16 bps, uint32 width, - uint8 *ibuff, uint8 *obuff) +reverseSamples24bits (uint16_t spp, uint16_t bps, uint32_t width, + uint8_t *ibuff, uint8_t *obuff) { int ready_bits = 0; - uint32 col; - uint32 src_byte = 0, high_bit = 0; - uint32 bit_offset = 0; - uint32 match_bits = 0, mask_bits = 0; - uint32 buff1 = 0, buff2 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0; + uint32_t col; + uint32_t src_byte = 0, high_bit = 0; + uint32_t bit_offset = 0; + uint32_t match_bits = 0, mask_bits = 0; + uint32_t buff1 = 0, buff2 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0; unsigned char *src; unsigned char *dst; tsample_t sample; @@ -8859,7 +8851,7 @@ reverseSamples24bits (uint16 spp, uint16 bps, uint32 width, } ready_bits = 0; - mask_bits = (uint32)-1 >> (32 - bps); + mask_bits = (uint32_t)-1 >> (32 - bps); dst = obuff; for (col = width; col > 0; col--) { @@ -8922,18 +8914,18 @@ reverseSamples24bits (uint16 spp, uint16 bps, uint32 width, static int -reverseSamples32bits (uint16 spp, uint16 bps, uint32 width, - uint8 *ibuff, uint8 *obuff) +reverseSamples32bits (uint16_t spp, uint16_t bps, uint32_t width, + uint8_t *ibuff, uint8_t *obuff) { int ready_bits = 0 /*, shift_width = 0 */; /* int bytes_per_sample, bytes_per_pixel; */ - uint32 bit_offset; - uint32 src_byte = 0, high_bit = 0; - uint32 col; - uint32 longbuff1 = 0, longbuff2 = 0; - uint64 mask_bits = 0, match_bits = 0; - uint64 buff1 = 0, buff2 = 0, buff3 = 0; - uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint32_t bit_offset; + uint32_t src_byte = 0, high_bit = 0; + uint32_t col; + uint32_t longbuff1 = 0, longbuff2 = 0; + uint64_t mask_bits = 0, match_bits = 0; + uint64_t buff1 = 0, buff2 = 0, buff3 = 0; + uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; unsigned char *src; unsigned char *dst; tsample_t sample; @@ -8945,7 +8937,7 @@ reverseSamples32bits (uint16 spp, uint16 bps, uint32 width, } ready_bits = 0; - mask_bits = (uint64)-1 >> (64 - bps); + mask_bits = (uint64_t)-1 >> (64 - bps); dst = obuff; /* bytes_per_sample = (bps + 7) / 8; */ @@ -8984,7 +8976,7 @@ reverseSamples32bits (uint16 spp, uint16 bps, uint32 width, longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; longbuff2 = longbuff1; } - buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; buff1 = (buff3 & match_bits) << (high_bit); if (ready_bits < 32) @@ -9022,12 +9014,12 @@ reverseSamples32bits (uint16 spp, uint16 bps, uint32 width, } /* end reverseSamples32bits */ static int -reverseSamplesBytes (uint16 spp, uint16 bps, uint32 width, - uint8 *src, uint8 *dst) +reverseSamplesBytes (uint16_t spp, uint16_t bps, uint32_t width, + uint8_t *src, uint8_t *dst) { int i; - uint32 col, bytes_per_pixel, col_offset; - uint8 bytebuff1; + uint32_t col, bytes_per_pixel, col_offset; + uint8_t bytebuff1; unsigned char swapbuff[32]; if ((src == NULL) || (dst == NULL)) @@ -9067,7 +9059,7 @@ reverseSamplesBytes (uint16 spp, uint16 bps, uint32 width, dst -= spp; } break; - default: TIFFError("reverseSamplesBytes","Unsupported bit depth %d", bps); + default: TIFFError("reverseSamplesBytes","Unsupported bit depth %"PRIu16, bps); return (1); } return (0); @@ -9076,11 +9068,11 @@ reverseSamplesBytes (uint16 spp, uint16 bps, uint32 width, /* Mirror an image horizontally or vertically */ static int -mirrorImage(uint16 spp, uint16 bps, uint16 mirror, uint32 width, uint32 length, unsigned char *ibuff) +mirrorImage(uint16_t spp, uint16_t bps, uint16_t mirror, uint32_t width, uint32_t length, unsigned char *ibuff) { int shift_width; - uint32 bytes_per_pixel, bytes_per_sample; - uint32 row, rowsize, row_offset; + uint32_t bytes_per_pixel, bytes_per_sample; + uint32_t row, rowsize, row_offset; unsigned char *line_buff = NULL; unsigned char *src; unsigned char *dst; @@ -9170,7 +9162,7 @@ mirrorImage(uint16 spp, uint16 bps, uint16 mirror, uint32 width, uint32 length, } _TIFFmemcpy (src, line_buff, rowsize); break; - default: TIFFError("mirrorImage","Unsupported bit depth %d", bps); + default: TIFFError("mirrorImage","Unsupported bit depth %"PRIu16, bps); _TIFFfree(line_buff); return (-1); } @@ -9180,7 +9172,7 @@ mirrorImage(uint16 spp, uint16 bps, uint16 mirror, uint32 width, uint32 length, } break; - default: TIFFError ("mirrorImage", "Invalid mirror axis %d", mirror); + default: TIFFError ("mirrorImage", "Invalid mirror axis %"PRIu16, mirror); return (-1); break; } @@ -9190,12 +9182,12 @@ mirrorImage(uint16 spp, uint16 bps, uint16 mirror, uint32 width, uint32 length, /* Invert the light and dark values for a bilevel or grayscale image */ static int -invertImage(uint16 photometric, uint16 spp, uint16 bps, uint32 width, uint32 length, unsigned char *work_buff) +invertImage(uint16_t photometric, uint16_t spp, uint16_t bps, uint32_t width, uint32_t length, unsigned char *work_buff) { - uint32 row, col; + uint32_t row, col; unsigned char *src; - uint16 *src_uint16; - uint32 *src_uint32; + uint16_t *src_uint16; + uint32_t *src_uint32; if (spp != 1) { @@ -9218,7 +9210,7 @@ invertImage(uint16 photometric, uint16 spp, uint16 bps, uint32 width, uint32 len switch (bps) { - case 32: src_uint32 = (uint32 *)src; + case 32: src_uint32 = (uint32_t *)src; for (row = 0; row < length; row++) for (col = 0; col < width; col++) { @@ -9226,7 +9218,7 @@ invertImage(uint16 photometric, uint16 spp, uint16 bps, uint32 width, uint32 len src_uint32++; } break; - case 16: src_uint16 = (uint16 *)src; + case 16: src_uint16 = (uint16_t *)src; for (row = 0; row < length; row++) for (col = 0; col < width; col++) { @@ -9244,7 +9236,7 @@ invertImage(uint16 photometric, uint16 spp, uint16 bps, uint32 width, uint32 len src++; } break; - default: TIFFError("invertImage", "Unsupported bit depth %d", bps); + default: TIFFError("invertImage", "Unsupported bit depth %"PRIu16, bps); return (-1); } diff --git a/tiff/tools/tiffdither.c b/tiff/tools/tiffdither.c index a9d1b7c5..062fd608 100644 --- a/tiff/tools/tiffdither.c +++ b/tiff/tools/tiffdither.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -32,10 +33,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" #include "tiffiop.h" @@ -52,8 +49,8 @@ #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) -uint32 imagewidth; -uint32 imagelength; +uint32_t imagewidth; +uint32_t imagelength; int threshold = 128; static void usage(int code); @@ -69,8 +66,8 @@ fsdither(TIFF* in, TIFF* out) short *thisline, *nextline, *tmpptr; register unsigned char *outptr; register short *thisptr, *nextptr; - register uint32 i, j; - uint32 imax, jmax; + register uint32_t i, j; + uint32_t imax, jmax; int lastline, lastpixel; int bit; tsize_t outlinesize; @@ -156,9 +153,9 @@ fsdither(TIFF* in, TIFF* out) return errcode; } -static uint16 compression = COMPRESSION_PACKBITS; -static uint16 predictor = 0; -static uint32 group3options = 0; +static uint16_t compression = COMPRESSION_PACKBITS; +static uint16_t predictor = 0; +static uint32_t group3options = 0; static void processG3Options(char* cp) @@ -209,11 +206,11 @@ int main(int argc, char* argv[]) { TIFF *in, *out; - uint16 samplesperpixel, bitspersample = 1, shortv; + uint16_t samplesperpixel, bitspersample = 1, shortv; float floatv; char thing[1024]; - uint32 rowsperstrip = (uint32) -1; - uint16 fillorder = 0; + uint32_t rowsperstrip = (uint32_t) -1; + uint16_t fillorder = 0; int c; #if !HAVE_DECL_OPTARG extern int optind; @@ -246,9 +243,12 @@ main(int argc, char* argv[]) break; case 'h': usage(EXIT_SUCCESS); + /*NOTREACHED*/ + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ + break; } if (argc - optind < 2) usage(EXIT_FAILURE); @@ -305,41 +305,49 @@ main(int argc, char* argv[]) return (EXIT_SUCCESS); } -static const char* stuff[] = { -"usage: tiffdither [options] input.tif output.tif", -"where options are:", -" -r # make each strip have no more than # rows", -" -t # set the threshold value for dithering (default 128)", -" -f lsb2msb force lsb-to-msb FillOrder for output", -" -f msb2lsb force msb-to-lsb FillOrder for output", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c packbits compress output with packbits encoding", -" -c g3[:opts] compress output with CCITT Group 3 encoding", -" -c g4 compress output with CCITT Group 4 encoding", -" -c none use no compression algorithm on output", -"", -"Group 3 options:", -" 1d use default CCITT Group 3 1D-encoding", -" 2d use optional CCITT Group 3 2D-encoding", -" fill byte-align EOL codes", -"For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", -"", -"LZW and deflate options:", -" # set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", -NULL -}; +static const char usage_info[] = +"Convert a greyscale image to bilevel using dithering\n\n" +"usage: tiffdither [options] input.tif output.tif\n" +"where options are:\n" +" -r # make each strip have no more than # rows\n" +" -t # set the threshold value for dithering (default 128)\n" +" -f lsb2msb force lsb-to-msb FillOrder for output\n" +" -f msb2lsb force msb-to-lsb FillOrder for output\n" +"\n" +#ifdef LZW_SUPPORT +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" +" # set predictor value\n" +" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip[:opts] compress output with deflate encoding\n" +" # set predictor value\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits compress output with packbits encoding\n" +#endif +#ifdef CCITT_SUPPORT +" -c g3[:opts] compress output with CCITT Group 3 encoding\n" +" Group 3 options:\n" +" 1d use default CCITT Group 3 1D-encoding\n" +" 2d use optional CCITT Group 3 2D-encoding\n" +" fill byte-align EOL codes\n" +" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs\n" +" -c g4 compress output with CCITT Group 4 encoding\n" +#endif +#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) +" -c none use no compression algorithm on output\n" +#endif +"\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } diff --git a/tiff/tools/tiffdump.c b/tiff/tools/tiffdump.c index 00be9dd4..500fffb6 100644 --- a/tiff/tools/tiffdump.c +++ b/tiff/tools/tiffdump.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -46,14 +47,6 @@ # include <io.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - #include "tiffio.h" #ifndef EXIT_SUCCESS @@ -73,35 +66,35 @@ static union TIFFHeaderBig big; TIFFHeaderCommon common; } hdr; -char* appname; -char* curfile; -int swabflag; -int bigendian; -int bigtiff; -uint32 maxitems = 24; /* maximum indirect data items to print */ - -const char* bytefmt = "%s%#02x"; /* BYTE */ -const char* sbytefmt = "%s%d"; /* SBYTE */ -const char* shortfmt = "%s%u"; /* SHORT */ -const char* sshortfmt = "%s%d"; /* SSHORT */ -const char* longfmt = "%s%lu"; /* LONG */ -const char* slongfmt = "%s%ld"; /* SLONG */ -const char* ifdfmt = "%s%#04lx"; /* IFD offset */ -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) -const char* long8fmt = "%s%I64u"; /* LONG8 */ -const char* slong8fmt = "%s%I64d"; /* SLONG8 */ -const char* ifd8fmt = "%s%#08I64x"; /* IFD offset8*/ -#else -const char* long8fmt = "%s%llu"; /* LONG8 */ -const char* slong8fmt = "%s%lld"; /* SLONG8 */ -const char* ifd8fmt = "%s%#08llx"; /* IFD offset8*/ -#endif -const char* rationalfmt = "%s%g"; /* RATIONAL */ -const char* srationalfmt = "%s%g"; /* SRATIONAL */ -const char* floatfmt = "%s%g"; /* FLOAT */ -const char* doublefmt = "%s%g"; /* DOUBLE */ - -static void dump(int, uint64); +static char* appname; +static char* curfile; +static int swabflag; +static int bigendian; +static int bigtiff; +static uint32_t maxitems = 24; /* maximum indirect data items to print */ + +static const char bytefmt[] = "%s%#02" PRIx8; /* BYTE */ +static const char sbytefmt[] = "%s%" PRId8; /* SBYTE */ +static const char shortfmtd[] = "%s%" PRIu16; /* SHORT */ +static const char shortfmth[] = "%s%#" PRIx16; +static const char sshortfmtd[] = "%s%" PRId16; /* SSHORT */ +static const char sshortfmth[] = "%s%#" PRIx16; +static const char longfmtd[] = "%s%" PRIu32; /* LONG */ +static const char longfmth[] = "%s%#" PRIx32; +static const char slongfmtd[] = "%s%" PRId32; /* SLONG */ +static const char slongfmth[] = "%s%#" PRIx32; +static const char ifdfmt[] = "%s%#04" PRIx32; /* IFD offset */ +static const char long8fmt[] = "%s%" PRIu64; /* LONG8 */ +static const char slong8fmt[] = "%s%" PRId64; /* SLONG8 */ +static const char ifd8fmt[] = "%s%#08" PRIx64; /* IFD offset8 */ +static const char rationalfmt[] = "%s%g"; /* RATIONAL */ +static const char srationalfmt[] = "%s%g"; /* SRATIONAL */ +static const char floatfmt[] = "%s%g"; /* FLOAT */ +static const char doublefmt[] = "%s%g"; /* DOUBLE */ + +unsigned int hex_mode; + +static void dump(int, uint64_t); #if !HAVE_DECL_OPTARG extern int optind; @@ -111,6 +104,7 @@ extern char* optarg; void usage() { + fprintf(stderr, "\nDisplay directory information from TIFF files\n\n"); fprintf(stderr, "usage: %s [-h] [-o offset] [-m maxitems] file.tif ...\n", appname); exit(EXIT_FAILURE); } @@ -121,20 +115,18 @@ main(int argc, char* argv[]) int one = 1, fd; int multiplefiles = (argc > 1); int c; - uint64 diroff = 0; + uint64_t diroff = 0; + hex_mode=0; bigendian = (*(char *)&one == 0); appname = argv[0]; while ((c = getopt(argc, argv, "m:o:h")) != -1) { switch (c) { - case 'h': /* print values in hex */ - shortfmt = "%s%#x"; - sshortfmt = "%s%#x"; - longfmt = "%s%#lx"; - slongfmt = "%s%#lx"; + case 'h': /* print values in hex */ + hex_mode=1; break; case 'o': - diroff = (uint64) strtoul(optarg, NULL, 0); + diroff = (uint64_t) strtoul(optarg, NULL, 0); break; case 'm': maxitems = strtoul(optarg, NULL, 0); @@ -164,16 +156,16 @@ main(int argc, char* argv[]) #define ord(e) ((int)e) -static uint64 ReadDirectory(int, unsigned, uint64); +static uint64_t ReadDirectory(int, unsigned, uint64_t); static void ReadError(char*); static void Error(const char*, ...); static void Fatal(const char*, ...); static void -dump(int fd, uint64 diroff) +dump(int fd, uint64_t diroff) { unsigned i, j; - uint64* visited_diroff = NULL; + uint64_t* visited_diroff = NULL; unsigned int count_visited_dir = 0; _TIFF_lseek_f(fd, (_TIFF_off_t) 0, 0); @@ -246,7 +238,7 @@ dump(int fd, uint64 diroff) { size_t alloc_size; alloc_size=TIFFSafeMultiply(tmsize_t,(count_visited_dir + 1), - sizeof(uint64)); + sizeof(uint64_t)); if (alloc_size == 0) { if (visited_diroff) @@ -255,7 +247,7 @@ dump(int fd, uint64 diroff) } else { - visited_diroff = (uint64*) realloc(visited_diroff,alloc_size); + visited_diroff = (uint64_t*) realloc(visited_diroff, alloc_size); } } if( !visited_diroff ) @@ -293,24 +285,24 @@ static const int datawidth[] = { 8, /* 18 = TIFF_IFD8 */ }; #define NWIDTHS (sizeof (datawidth) / sizeof (datawidth[0])) -static void PrintTag(FILE*, uint16); -static void PrintType(FILE*, uint16); -static void PrintData(FILE*, uint16, uint32, unsigned char*); +static void PrintTag(FILE*, uint16_t); +static void PrintType(FILE*, uint16_t); +static void PrintData(FILE*, uint16_t, uint32_t, unsigned char*); /* * Read the next TIFF directory from a file * and convert it to the internal format. * We read directories sequentially. */ -static uint64 -ReadDirectory(int fd, unsigned int ix, uint64 off) +static uint64_t +ReadDirectory(int fd, unsigned int ix, uint64_t off) { - uint16 dircount; - uint32 direntrysize; + uint16_t dircount; + uint32_t direntrysize; void* dirmem = NULL; - uint64 nextdiroff = 0; - uint32 n; - uint8* dp; + uint64_t nextdiroff = 0; + uint32_t n; + uint8_t* dp; if (off == 0) /* no more directories */ goto done; @@ -319,7 +311,7 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) goto done; } if (!bigtiff) { - if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) { + if (read(fd, (char*) &dircount, sizeof (uint16_t)) != sizeof (uint16_t)) { ReadError("directory count"); goto done; } @@ -327,8 +319,8 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) TIFFSwabShort(&dircount); direntrysize = 12; } else { - uint64 dircount64 = 0; - if (read(fd, (char*) &dircount64, sizeof (uint64)) != sizeof (uint64)) { + uint64_t dircount64 = 0; + if (read(fd, (char*) &dircount64, sizeof (uint64_t)) != sizeof (uint64_t)) { ReadError("directory count"); goto done; } @@ -338,7 +330,7 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) Error("Sanity check on directory count failed"); goto done; } - dircount = (uint16)dircount64; + dircount = (uint16_t)dircount64; direntrysize = 20; } dirmem = _TIFFmalloc(TIFFSafeMultiply(tmsize_t,dircount,direntrysize)); @@ -350,57 +342,45 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) if (n != dircount*direntrysize) { n /= direntrysize; Error( -#if defined(__WIN32__) && defined(_MSC_VER) - "Could only read %lu of %u entries in directory at offset %#I64x", - (unsigned long)n, dircount, (unsigned __int64) off); -#else - "Could only read %lu of %u entries in directory at offset %#llx", - (unsigned long)n, dircount, (unsigned long long) off); -#endif + "Could only read %" PRIu32 " of %" PRIu16 " entries in directory at offset %#" PRIu64, + n, dircount, off); dircount = n; nextdiroff = 0; } else { if (!bigtiff) { - uint32 nextdiroff32; - if (read(fd, (char*) &nextdiroff32, sizeof (uint32)) != sizeof (uint32)) + uint32_t nextdiroff32; + if (read(fd, (char*) &nextdiroff32, sizeof (uint32_t)) != sizeof (uint32_t)) nextdiroff32 = 0; if (swabflag) TIFFSwabLong(&nextdiroff32); nextdiroff = nextdiroff32; } else { - if (read(fd, (char*) &nextdiroff, sizeof (uint64)) != sizeof (uint64)) + if (read(fd, (char*) &nextdiroff, sizeof (uint64_t)) != sizeof (uint64_t)) nextdiroff = 0; if (swabflag) TIFFSwabLong8(&nextdiroff); } } -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - printf("Directory %u: offset %I64u (%#I64x) next %I64u (%#I64x)\n", ix, - (unsigned __int64)off, (unsigned __int64)off, - (unsigned __int64)nextdiroff, (unsigned __int64)nextdiroff); -#else - printf("Directory %u: offset %llu (%#llx) next %llu (%#llx)\n", ix, - (unsigned long long)off, (unsigned long long)off, - (unsigned long long)nextdiroff, (unsigned long long)nextdiroff); -#endif - for (dp = (uint8*)dirmem, n = dircount; n > 0; n--) { - uint16 tag; - uint16 type; - uint16 typewidth; - uint64 count; - uint64 datasize; + printf("Directory %u: offset %" PRIu64 " (%#" PRIx64 ") next %" PRIu64 " (%#" PRIx64 ")\n", + ix, off, off, nextdiroff, nextdiroff); + for (dp = (uint8_t*)dirmem, n = dircount; n > 0; n--) { + uint16_t tag; + uint16_t type; + uint16_t typewidth; + uint64_t count; + uint64_t datasize; int datafits; void* datamem; - uint64 dataoffset; + uint64_t dataoffset; int datatruncated; int datasizeoverflow; - tag = *(uint16*)dp; + tag = *(uint16_t*)dp; if (swabflag) TIFFSwabShort(&tag); - dp += sizeof(uint16); - type = *(uint16*)dp; - dp += sizeof(uint16); + dp += sizeof(uint16_t); + type = *(uint16_t*)dp; + dp += sizeof(uint16_t); if (swabflag) TIFFSwabShort(&type); PrintTag(stdout, tag); @@ -409,25 +389,21 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) putchar(' '); if (!bigtiff) { - uint32 count32; - count32 = *(uint32*)dp; + uint32_t count32; + count32 = *(uint32_t*)dp; if (swabflag) TIFFSwabLong(&count32); - dp += sizeof(uint32); + dp += sizeof(uint32_t); count = count32; } else { - memcpy(&count, dp, sizeof(uint64)); + memcpy(&count, dp, sizeof(uint64_t)); if (swabflag) TIFFSwabLong8(&count); - dp += sizeof(uint64); + dp += sizeof(uint64_t); } -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - printf("%I64u<", (unsigned __int64)count); -#else - printf("%llu<", (unsigned long long)count); -#endif + printf("%" PRIu64 "<", count); if (type >= NWIDTHS) typewidth = 0; else @@ -442,15 +418,15 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) { if (datasizeoverflow || datasize>4) { - uint32 dataoffset32; + uint32_t dataoffset32; datafits = 0; datamem = NULL; - dataoffset32 = *(uint32*)dp; + dataoffset32 = *(uint32_t*)dp; if (swabflag) TIFFSwabLong(&dataoffset32); dataoffset = dataoffset32; } - dp += sizeof(uint32); + dp += sizeof(uint32_t); } else { @@ -458,11 +434,11 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) { datafits = 0; datamem = NULL; - memcpy(&dataoffset, dp, sizeof(uint64)); + memcpy(&dataoffset, dp, sizeof(uint64_t)); if (swabflag) TIFFSwabLong8(&dataoffset); } - dp += sizeof(uint64); + dp += sizeof(uint64_t); } if (datasizeoverflow || datasize>0x10000) { @@ -488,7 +464,7 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) _TIFFfree(datamem); datamem = NULL; } - else if (read(fd, datamem, (size_t)datasize) != (TIFF_SSIZE_T)datasize) + else if (read(fd, datamem, (size_t)datasize) != (tmsize_t)datasize) { Error( "Read error accessing tag %u value", tag); @@ -511,27 +487,27 @@ ReadDirectory(int fd, unsigned int ix, uint64 off) break; case TIFF_SHORT: case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*)datamem,(tmsize_t)count); + TIFFSwabArrayOfShort((uint16_t*)datamem, (tmsize_t)count); break; case TIFF_LONG: case TIFF_SLONG: case TIFF_FLOAT: case TIFF_IFD: - TIFFSwabArrayOfLong((uint32*)datamem,(tmsize_t)count); + TIFFSwabArrayOfLong((uint32_t*)datamem, (tmsize_t)count); break; case TIFF_RATIONAL: case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*)datamem,(tmsize_t)count*2); + TIFFSwabArrayOfLong((uint32_t*)datamem, (tmsize_t)count * 2); break; case TIFF_DOUBLE: case TIFF_LONG8: case TIFF_SLONG8: case TIFF_IFD8: - TIFFSwabArrayOfLong8((uint64*)datamem,(tmsize_t)count); + TIFFSwabArrayOfLong8((uint64_t*)datamem, (tmsize_t)count); break; } } - PrintData(stdout,type,(uint32)count,datamem); + PrintData(stdout, type, (uint32_t)count, datamem); if (datatruncated) printf(" ..."); if (!datafits) @@ -549,7 +525,7 @@ done: } static const struct tagname { - uint16 tag; + uint16_t tag; const char* name; } tagnames[] = { { TIFFTAG_SUBFILETYPE, "SubFileType" }, @@ -647,7 +623,7 @@ static const struct tagname { #define NTAGS (sizeof (tagnames) / sizeof (tagnames[0])) static void -PrintTag(FILE* fd, uint16 tag) +PrintTag(FILE* fd, uint16_t tag) { const struct tagname *tp; @@ -660,7 +636,7 @@ PrintTag(FILE* fd, uint16 tag) } static void -PrintType(FILE* fd, uint16 type) +PrintType(FILE* fd, uint16_t type) { static const char *typenames[] = { "0", @@ -695,7 +671,7 @@ PrintType(FILE* fd, uint16 type) #include <ctype.h> static void -PrintASCII(FILE* fd, uint32 cc, const unsigned char* cp) +PrintASCII(FILE* fd, uint32_t cc, const unsigned char* cp) { for (; cc > 0; cc--, cp++) { const char* tp; @@ -717,7 +693,7 @@ PrintASCII(FILE* fd, uint32 cc, const unsigned char* cp) } static void -PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) +PrintData(FILE* fd, uint16_t type, uint32_t count, unsigned char* data) { char* sep = ""; @@ -738,36 +714,36 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) PrintASCII(fd, count, data); break; case TIFF_SHORT: { - uint16 *wp = (uint16*)data; + uint16_t *wp = (uint16_t*)data; while (count-- > 0) - fprintf(fd, shortfmt, sep, *wp++), sep = " "; + fprintf(fd, hex_mode ? shortfmth : shortfmtd, sep, *wp++), sep = " "; break; } case TIFF_SSHORT: { - int16 *wp = (int16*)data; + int16_t *wp = (int16_t*)data; while (count-- > 0) - fprintf(fd, sshortfmt, sep, *wp++), sep = " "; + fprintf(fd, hex_mode ? sshortfmth : sshortfmtd, sep, *wp++), sep = " "; break; } case TIFF_LONG: { - uint32 *lp = (uint32*)data; + uint32_t *lp = (uint32_t*)data; while (count-- > 0) { - fprintf(fd, longfmt, sep, (unsigned long) *lp++); + fprintf(fd, hex_mode ? longfmth : longfmtd, sep, *lp++); sep = " "; } break; } case TIFF_SLONG: { - int32 *lp = (int32*)data; + int32_t *lp = (int32_t*)data; while (count-- > 0) - fprintf(fd, slongfmt, sep, (long) *lp++), sep = " "; + fprintf(fd, hex_mode ? slongfmth : slongfmtd, sep, *lp++), sep = " "; break; } case TIFF_LONG8: { - uint64 *llp = (uint64*)data; + uint64_t *llp = (uint64_t*)data; while (count-- > 0) { - uint64 val; - memcpy(&val, llp, sizeof(uint64)); + uint64_t val; + memcpy(&val, llp, sizeof(uint64_t)); llp ++; fprintf(fd, long8fmt, sep, val); sep = " "; @@ -775,10 +751,10 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) break; } case TIFF_SLONG8: { - int64 *llp = (int64*)data; + int64_t *llp = (int64_t*)data; while (count-- > 0) { - int64 val; - memcpy(&val, llp, sizeof(int64)); + int64_t val; + memcpy(&val, llp, sizeof(int64_t)); llp ++; fprintf(fd, slong8fmt, sep, val); sep = " "; @@ -786,12 +762,11 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) break; } case TIFF_RATIONAL: { - uint32 *lp = (uint32*)data; + uint32_t *lp = (uint32_t*)data; while (count-- > 0) { if (lp[1] == 0) - fprintf(fd, "%sNan (%lu/%lu)", sep, - (unsigned long) lp[0], - (unsigned long) lp[1]); + fprintf(fd, "%sNan (%"PRIu32"/%"PRIu32")", sep, + lp[0], lp[1]); else fprintf(fd, rationalfmt, sep, (double)lp[0] / (double)lp[1]); @@ -801,11 +776,11 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) break; } case TIFF_SRATIONAL: { - int32 *lp = (int32*)data; + int32_t *lp = (int32_t*)data; while (count-- > 0) { if (lp[1] == 0) - fprintf(fd, "%sNan (%ld/%ld)", sep, - (long) lp[0], (long) lp[1]); + fprintf(fd, "%sNan (%"PRId32"/%"PRId32")", sep, + lp[0], lp[1]); else fprintf(fd, srationalfmt, sep, (double)lp[0] / (double)lp[1]); @@ -827,21 +802,18 @@ PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) break; } case TIFF_IFD: { - uint32 *lp = (uint32*)data; + uint32_t *lp = (uint32_t*)data; while (count-- > 0) { - fprintf(fd, ifdfmt, sep, (unsigned long) *lp++); + fprintf(fd, ifdfmt, sep, *lp++); sep = " "; } break; } case TIFF_IFD8: { - uint64 *llp = (uint64*)data; + uint64_t *llp = (uint64_t*)data; while (count-- > 0) { -#if defined(__WIN32__) && defined(_MSC_VER) - fprintf(fd, ifd8fmt, sep, (unsigned __int64) *llp++); -#else - fprintf(fd, ifd8fmt, sep, (unsigned long long) *llp++); -#endif + fprintf(fd, ifd8fmt, sep, *llp++); + sep = " "; sep = " "; } break; diff --git a/tiff/tools/tiffgt.c b/tiff/tools/tiffgt.c index f3cca8c9..f9e1e087 100644 --- a/tiff/tools/tiffgt.c +++ b/tiff/tools/tiffgt.c @@ -24,6 +24,8 @@ */ #include "tif_config.h" +#include "libport.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -55,20 +57,16 @@ #define EXIT_FAILURE 1 #endif -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - -static uint32 width = 0, height = 0; /* window width & height */ -static uint32* raster = NULL; /* displayable image */ +static uint32_t width = 0, height = 0; /* window width & height */ +static uint32_t* raster = NULL; /* displayable image */ static TIFFRGBAImage img; static int order0 = 0, order; -static uint16 photo0 = (uint16) -1, photo; +static uint16_t photo0 = (uint16_t) -1, photo; static int stoponerr = 0; /* stop on read error */ static int verbose = 0; #define TITLE_LENGTH 1024 static char title[TITLE_LENGTH]; /* window title line */ -static uint32 xmax, ymax; +static uint32_t xmax, ymax; static char** filelist = NULL; static int fileindex; static int filenum; @@ -81,7 +79,7 @@ static int prevImage(void); static int nextImage(void); static void setWindowSize(void); static void usage(int); -static uint16 photoArg(const char*); +static uint16_t photoArg(const char*); static void raster_draw(void); static void raster_reshape(int, int); static void raster_keys(unsigned char, int, int); @@ -105,7 +103,7 @@ main(int argc, char* argv[]) { int c; int dirnum = -1; - uint32 diroff = 0; + uint32_t diroff = 0; oerror = TIFFSetErrorHandler(NULL); owarning = TIFFSetWarningHandler(NULL); @@ -223,11 +221,11 @@ cleanup_and_exit(int code) static int initImage(void) { - uint32 w, h; + uint32_t w, h; if (order) TIFFSetField(tif, TIFFTAG_FILLORDER, order); - if (photo != (uint16) -1) + if (photo != (uint16_t) -1) TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo); if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) { TIFFError(filelist[fileindex], "%s", title); @@ -251,12 +249,12 @@ initImage(void) } if (w != width || h != height) { - uint32 rastersize = + uint32_t rastersize = _TIFFMultiply32(tif, img.width, img.height, "allocating raster buffer"); if (raster != NULL) _TIFFfree(raster), raster = NULL; - raster = (uint32*) _TIFFCheckMalloc(tif, rastersize, sizeof (uint32), - "allocating raster buffer"); + raster = (uint32_t*) _TIFFCheckMalloc(tif, rastersize, sizeof (uint32_t), + "allocating raster buffer"); if (raster == NULL) { width = height = 0; TIFFError(filelist[fileindex], "No space for raster buffer"); @@ -461,7 +459,7 @@ usage(int code) exit(code); } -static uint16 +static uint16_t photoArg(const char* arg) { if (strcmp(arg, "miniswhite") == 0) @@ -485,7 +483,7 @@ photoArg(const char* arg) else if (strcmp(arg, "logluv") == 0) return (PHOTOMETRIC_LOGLUV); else - return ((uint16) -1); + return ((uint16_t) -1); } /* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/tiff/tools/tiffinfo.c b/tiff/tools/tiffinfo.c index 2271c9d1..6921a0c5 100644 --- a/tiff/tools/tiffinfo.c +++ b/tiff/tools/tiffinfo.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -36,10 +37,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffiop.h" #ifndef EXIT_SUCCESS @@ -58,7 +55,7 @@ static int readdata = 0; /* read data in file */ static int stoponerr = 1; /* stop on first read error */ static void usage(int); -static void tiffinfo(TIFF*, uint16, long, int); +static void tiffinfo(TIFF*, uint16_t, long, int); static void PrivateErrorHandler(const char* module, const char* fmt, va_list ap) @@ -72,14 +69,14 @@ int main(int argc, char* argv[]) { int dirnum = -1, multiplefiles, c; - uint16 order = 0; + uint16_t order = 0; TIFF* tif; #if !HAVE_DECL_OPTARG extern int optind; extern char* optarg; #endif long flags = 0; - uint64 diroff = 0; + uint64_t diroff = 0; int chopstrips = 0; /* disable strip chopping */ while ((c = getopt(argc, argv, "f:o:cdDSjilmrsvwz0123456789h")) != -1) @@ -131,10 +128,12 @@ main(int argc, char* argv[]) break; case 'h': usage(EXIT_SUCCESS); - /*NOTREACHED*/ + /*NOTREACHED*/ + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ + break; } if (optind >= argc) usage(EXIT_FAILURE); @@ -172,43 +171,41 @@ main(int argc, char* argv[]) return (status); } -static const char* stuff[] = { -"usage: tiffinfo [options] input...", -"where options are:", -" -D read data", -" -i ignore read errors", -" -c display data for grey/color response curve or colormap", -" -d display raw/decoded image data", -" -f lsb2msb force lsb-to-msb FillOrder for input", -" -f msb2lsb force msb-to-lsb FillOrder for input", -" -j show JPEG tables", -" -o offset set initial directory offset", -" -r read/display raw image data instead of decoded data", -" -s display strip offsets and byte counts", -" -w display raw data in words rather than bytes", -" -z enable strip chopping", -" -# set initial directory (first directory is # 0)", -NULL -}; +static const char usage_info[] = +"Display information about TIFF files\n\n" +"usage: tiffinfo [options] input...\n" +"where options are:\n" +" -D read data\n" +" -i ignore read errors\n" +" -c display data for grey/color response curve or colormap\n" +" -d display raw/decoded image data\n" +" -f lsb2msb force lsb-to-msb FillOrder for input\n" +" -f msb2lsb force msb-to-lsb FillOrder for input\n" +" -j show JPEG tables\n" +" -o offset set initial directory offset\n" +" -r read/display raw image data instead of decoded data\n" +" -s display strip offsets and byte counts\n" +" -w display raw data in words rather than bytes\n" +" -z enable strip chopping\n" +" -# set initial directory (first directory is # 0)\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } static void -ShowStrip(tstrip_t strip, unsigned char* pp, uint32 nrow, tsize_t scanline) +ShowStrip(tstrip_t strip, unsigned char* pp, uint32_t nrow, tsize_t scanline) { register tsize_t cc; - printf("Strip %lu:\n", (unsigned long) strip); + printf("Strip %"PRIu32":\n", strip); while (nrow-- > 0) { for (cc = 0; cc < scanline; cc++) { printf(" %02x", *pp++); @@ -227,13 +224,13 @@ TIFFReadContigStripData(TIFF* tif) buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); if (buf) { - uint32 row, h=0; - uint32 rowsperstrip = (uint32)-1; + uint32_t row, h=0; + uint32_t rowsperstrip = (uint32_t)-1; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); for (row = 0; row < h; row += rowsperstrip) { - uint32 nrow = (row+rowsperstrip > h ? + uint32_t nrow = (row + rowsperstrip > h ? h-row : rowsperstrip); tstrip_t strip = TIFFComputeStrip(tif, row, 0); if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) { @@ -254,8 +251,8 @@ TIFFReadSeparateStripData(TIFF* tif) buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); if (buf) { - uint32 row, h=0; - uint32 rowsperstrip = (uint32)-1; + uint32_t row, h=0; + uint32_t rowsperstrip = (uint32_t)-1; tsample_t s, samplesperpixel=0; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); @@ -263,7 +260,7 @@ TIFFReadSeparateStripData(TIFF* tif) TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); for (row = 0; row < h; row += rowsperstrip) { for (s = 0; s < samplesperpixel; s++) { - uint32 nrow = (row+rowsperstrip > h ? + uint32_t nrow = (row + rowsperstrip > h ? h-row : rowsperstrip); tstrip_t strip = TIFFComputeStrip(tif, row, s); if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) { @@ -278,17 +275,17 @@ TIFFReadSeparateStripData(TIFF* tif) } static void -ShowTile(uint32 row, uint32 col, tsample_t sample, - unsigned char* pp, uint32 nrow, tsize_t rowsize) +ShowTile(uint32_t row, uint32_t col, tsample_t sample, + unsigned char* pp, uint32_t nrow, tsize_t rowsize) { - uint32 cc; + uint32_t cc; - printf("Tile (%lu,%lu", (unsigned long) row, (unsigned long) col); + printf("Tile (%" PRIu32 ",%" PRIu32 "", row, col); if (sample != (tsample_t) -1) - printf(",%u", sample); + printf(",%" PRIu16, sample); printf("):\n"); while (nrow-- > 0) { - for (cc = 0; cc < (uint32) rowsize; cc++) { + for (cc = 0; cc < (uint32_t) rowsize; cc++) { printf(" %02x", *pp++); if (((cc+1) % 24) == 0) putchar('\n'); @@ -306,8 +303,8 @@ TIFFReadContigTileData(TIFF* tif) buf = (unsigned char *)_TIFFmalloc(tilesize); if (buf) { - uint32 tw=0, th=0, w=0, h=0; - uint32 row, col; + uint32_t tw=0, th=0, w=0, h=0; + uint32_t row, col; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); @@ -341,8 +338,8 @@ TIFFReadSeparateTileData(TIFF* tif) buf = (unsigned char *)_TIFFmalloc(tilesize); if (buf) { - uint32 tw=0, th=0, w=0, h=0; - uint32 row, col; + uint32_t tw=0, th=0, w=0, h=0; + uint32_t row, col; tsample_t s, samplesperpixel=0; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); @@ -374,7 +371,7 @@ TIFFReadSeparateTileData(TIFF* tif) void TIFFReadData(TIFF* tif) { - uint16 config = PLANARCONFIG_CONTIG; + uint16_t config = PLANARCONFIG_CONTIG; TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); if (TIFFIsTiled(tif)) { @@ -391,9 +388,9 @@ TIFFReadData(TIFF* tif) } static void -ShowRawBytes(unsigned char* pp, uint32 n) +ShowRawBytes(unsigned char* pp, uint32_t n) { - uint32 i; + uint32_t i; for (i = 0; i < n; i++) { printf(" %02x", *pp++); @@ -404,12 +401,12 @@ ShowRawBytes(unsigned char* pp, uint32 n) } static void -ShowRawWords(uint16* pp, uint32 n) +ShowRawWords(uint16_t* pp, uint32_t n) { - uint32 i; + uint32_t i; for (i = 0; i < n; i++) { - printf(" %04x", *pp++); + printf(" %04" PRIx16, *pp++); if (((i+1) % 15) == 0) printf("\n "); } @@ -421,42 +418,42 @@ TIFFReadRawDataStriped(TIFF* tif, int bitrev) { tstrip_t nstrips = TIFFNumberOfStrips(tif); const char* what = "Strip"; - uint64* stripbc=NULL; + uint64_t* stripbc=NULL; TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbc); if (stripbc != NULL && nstrips > 0) { - uint32 bufsize = (uint32) stripbc[0]; + uint32_t bufsize = (uint32_t) stripbc[0]; tdata_t buf = _TIFFmalloc(bufsize); tstrip_t s; for (s = 0; s < nstrips; s++) { if (stripbc[s] > bufsize) { buf = _TIFFrealloc(buf, (tmsize_t)stripbc[s]); - bufsize = (uint32) stripbc[s]; + bufsize = (uint32_t) stripbc[s]; } if (buf == NULL) { fprintf(stderr, - "Cannot allocate buffer to read strip %lu\n", - (unsigned long) s); + "Cannot allocate buffer to read strip %"PRIu32"\n", + s); break; } if (TIFFReadRawStrip(tif, s, buf, (tmsize_t) stripbc[s]) < 0) { - fprintf(stderr, "Error reading strip %lu\n", - (unsigned long) s); + fprintf(stderr, "Error reading strip %"PRIu32"\n", + s); if (stoponerr) break; } else if (showdata) { if (bitrev) { TIFFReverseBits(buf, (tmsize_t)stripbc[s]); - printf("%s %lu: (bit reversed)\n ", - what, (unsigned long) s); + printf("%s %"PRIu32": (bit reversed)\n ", + what, s); } else - printf("%s %lu:\n ", what, - (unsigned long) s); + printf("%s %"PRIu32":\n ", what, + s); if (showwords) - ShowRawWords((uint16*) buf, (uint32) stripbc[s]>>1); + ShowRawWords((uint16_t*) buf, (uint32_t) stripbc[s] >> 1); else - ShowRawBytes((unsigned char*) buf, (uint32) stripbc[s]); + ShowRawBytes((unsigned char*) buf, (uint32_t) stripbc[s]); } } if (buf != NULL) @@ -468,14 +465,14 @@ static void TIFFReadRawDataTiled(TIFF* tif, int bitrev) { const char* what = "Tile"; - uint32 ntiles = TIFFNumberOfTiles(tif); - uint64 *tilebc; + uint32_t ntiles = TIFFNumberOfTiles(tif); + uint64_t *tilebc; TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &tilebc); if (tilebc != NULL && ntiles > 0) { - uint64 bufsize = 0; + uint64_t bufsize = 0; tdata_t buf = NULL; - uint32 t; + uint32_t t; for (t = 0; t < ntiles; t++) { if (buf == NULL || tilebc[t] > bufsize) { @@ -484,28 +481,28 @@ TIFFReadRawDataTiled(TIFF* tif, int bitrev) } if (buf == NULL) { fprintf(stderr, - "Cannot allocate buffer to read tile %lu\n", - (unsigned long) t); + "Cannot allocate buffer to read tile %"PRIu32"\n", + t); break; } if (TIFFReadRawTile(tif, t, buf, (tmsize_t)tilebc[t]) < 0) { - fprintf(stderr, "Error reading tile %lu\n", - (unsigned long) t); + fprintf(stderr, "Error reading tile %"PRIu32"\n", + t); if (stoponerr) break; } else if (showdata) { if (bitrev) { TIFFReverseBits(buf, (tmsize_t)tilebc[t]); - printf("%s %lu: (bit reversed)\n ", - what, (unsigned long) t); + printf("%s %"PRIu32": (bit reversed)\n ", + what, t); } else { - printf("%s %lu:\n ", what, - (unsigned long) t); + printf("%s %"PRIu32":\n ", what, + t); } if (showwords) { - ShowRawWords((uint16*) buf, (uint32)(tilebc[t]>>1)); + ShowRawWords((uint16_t*) buf, (uint32_t)(tilebc[t] >> 1)); } else { - ShowRawBytes((unsigned char*) buf, (uint32) tilebc[t]); + ShowRawBytes((unsigned char*) buf, (uint32_t) tilebc[t]); } } } @@ -525,14 +522,14 @@ TIFFReadRawData(TIFF* tif, int bitrev) } static void -tiffinfo(TIFF* tif, uint16 order, long flags, int is_image) +tiffinfo(TIFF* tif, uint16_t order, long flags, int is_image) { TIFFPrintDirectory(tif, stdout, flags); if (!readdata || !is_image) return; if (rawdata) { if (order) { - uint16 o; + uint16_t o; TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &o); TIFFReadRawData(tif, o != order); diff --git a/tiff/tools/tiffmedian.c b/tiff/tools/tiffmedian.c index 6654cd6f..93a1741c 100644 --- a/tiff/tools/tiffmedian.c +++ b/tiff/tools/tiffmedian.c @@ -39,6 +39,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -48,10 +49,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" #ifndef EXIT_SUCCESS @@ -82,7 +79,7 @@ typedef struct colorbox { int rmin, rmax; int gmin, gmax; int bmin, bmax; - uint32 total; + uint32_t total; } Colorbox; typedef struct { @@ -90,20 +87,20 @@ typedef struct { int entries[MAX_CMAP_SIZE][2]; } C_cell; -uint16 rm[MAX_CMAP_SIZE], gm[MAX_CMAP_SIZE], bm[MAX_CMAP_SIZE]; -int num_colors; -uint32 histogram[B_LEN][B_LEN][B_LEN]; -Colorbox *freeboxes; -Colorbox *usedboxes; -C_cell **ColorCells; -TIFF *in, *out; -uint32 rowsperstrip = (uint32) -1; -uint16 compression = (uint16) -1; -uint16 bitspersample = 1; -uint16 samplesperpixel; -uint32 imagewidth; -uint32 imagelength; -uint16 predictor = 0; +static uint16_t rm[MAX_CMAP_SIZE], gm[MAX_CMAP_SIZE], bm[MAX_CMAP_SIZE]; +static int num_colors; +static uint32_t histogram[B_LEN][B_LEN][B_LEN]; +static Colorbox *freeboxes; +static Colorbox *usedboxes; +static C_cell **ColorCells; +static TIFF *in, *out; +static uint32_t rowsperstrip = (uint32_t) -1; +static uint16_t compression = (uint16_t) -1; +static uint16_t bitspersample = 1; +static uint16_t samplesperpixel; +static uint32_t imagewidth; +static uint32_t imagelength; +static uint16_t predictor = 0; static void get_histogram(TIFF*, Colorbox*); static void splitbox(Colorbox*); @@ -123,10 +120,10 @@ int main(int argc, char* argv[]) { int i, dither = 0; - uint16 shortv, config, photometric; + uint16_t shortv, config, photometric; Colorbox *box_list, *ptr; float floatv; - uint32 longv; + uint32_t longv; int c; #if !HAVE_DECL_OPTARG extern int optind; @@ -158,9 +155,11 @@ main(int argc, char* argv[]) case 'h': usage(EXIT_SUCCESS); /*NOTREACHED*/ + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ + break; } if (argc - optind != 2) usage(EXIT_FAILURE); @@ -260,7 +259,7 @@ main(int argc, char* argv[]) CopyField(TIFFTAG_SUBFILETYPE, longv); CopyField(TIFFTAG_IMAGEWIDTH, longv); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (short)COLOR_DEPTH); - if (compression != (uint16)-1) { + if (compression != (uint16_t)-1) { TIFFSetField(out, TIFFTAG_COMPRESSION, compression); switch (compression) { case COMPRESSION_LZW: @@ -325,32 +324,41 @@ processCompressOptions(char* opt) return (1); } -char* stuff[] = { -"usage: tiffmedian [options] input.tif output.tif", -"where options are:", -" -r # make each strip have no more than # rows", -" -C # create a colormap with # entries", -" -f use Floyd-Steinberg dithering", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c packbits compress output with packbits encoding", -" -c none use no compression algorithm on output", -"", -"LZW and deflate options:", -" # set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", -NULL -}; +static const char usage_info[] = +"Apply the median cut algorithm to an RGB TIFF file\n\n" +"usage: tiffmedian [options] input.tif output.tif\n" +"where options are:\n" +" -r # make each strip have no more than # rows\n" +" -C # create a colormap with # entries\n" +" -f use Floyd-Steinberg dithering\n" +"\n" +#ifdef LZW_SUPPORT +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" +/* " LZW options:" */ +" # set predictor value\n" +" For example, -c lzw:2 to get LZW-encoded data with horizontal differencing\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip[:opts] compress output with deflate encoding\n" +/* " Deflate (ZIP) options:" */ +" # set predictor value\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits compress output with packbits encoding\n" +#endif +#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) +" -c none use no compression algorithm on output\n" +#endif +"\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } @@ -359,7 +367,7 @@ get_histogram(TIFF* in, Colorbox* box) { register unsigned char *inptr; register int red, green, blue; - register uint32 j, i; + register uint32_t j, i; unsigned char *inputline; inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); @@ -371,7 +379,7 @@ get_histogram(TIFF* in, Colorbox* box) box->rmax = box->gmax = box->bmax = -1; box->total = imagewidth * imagelength; - { register uint32 *ptr = &histogram[0][0][0]; + { register uint32_t *ptr = &histogram[0][0][0]; for (i = B_LEN*B_LEN*B_LEN; i-- > 0;) *ptr++ = 0; } @@ -411,7 +419,7 @@ static Colorbox * largest_box(void) { register Colorbox *p, *b; - register uint32 size; + register uint32_t size; b = NULL; size = 0; @@ -425,13 +433,13 @@ largest_box(void) static void splitbox(Colorbox* ptr) { - uint32 hist2[B_LEN]; + uint32_t hist2[B_LEN]; int first=0, last=0; register Colorbox *new; - register uint32 *iptr, *histp; + register uint32_t *iptr, *histp; register int i, j; register int ir,ig,ib; - register uint32 sum, sum1, sum2; + register uint32_t sum, sum1, sum2; enum { RED, GREEN, BLUE } axis; /* @@ -547,7 +555,7 @@ splitbox(Colorbox* ptr) static void shrinkbox(Colorbox* box) { - register uint32 *histp; + register uint32_t *histp; register int ir, ig, ib; if (box->rmax > box->rmin) { @@ -720,7 +728,7 @@ create_colorcell(int red, int green, int blue) static void map_colortable(void) { - register uint32 *histp = &histogram[0][0][0]; + register uint32_t *histp = &histogram[0][0][0]; register C_cell *cell; register int j, tmp, d2, dist; int ir, ig, ib, i; @@ -769,7 +777,7 @@ quant(TIFF* in, TIFF* out) { unsigned char *outline, *inputline; register unsigned char *outptr, *inptr; - register uint32 i, j; + register uint32_t i, j; register int red, green, blue; inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); @@ -824,8 +832,8 @@ quant_fsdither(TIFF* in, TIFF* out) short *thisline, *nextline; register unsigned char *outptr; register short *thisptr, *nextptr; - register uint32 i, j; - uint32 imax, jmax; + register uint32_t i, j; + uint32_t imax, jmax; int lastline, lastpixel; imax = imagelength - 1; diff --git a/tiff/tools/tiffset.c b/tiff/tools/tiffset.c index 75cf45c0..8c9e23c5 100644 --- a/tiff/tools/tiffset.c +++ b/tiff/tools/tiffset.c @@ -46,27 +46,25 @@ #define EXIT_FAILURE 1 #endif -static const char* usageMsg[] = { -"usage: tiffset [options] filename", -"where options are:", -" -s <tagname> [count] <value>... set the tag value", -" -u <tagname> to unset the tag", -" -d <dirno> set the directory", -" -sd <diroff> set the subdirectory", -" -sf <tagname> <filename> read the tag value from file (for ASCII tags only)", -" -h this help screen", -NULL -}; +static const char usageMsg[] = +"Set the value of a TIFF header to a specified value\n\n" +"usage: tiffset [options] filename\n" +"where options are:\n" +" -s <tagname> [count] <value>... set the tag value\n" +" -u <tagname> to unset the tag\n" +" -d <dirno> set the directory\n" +" -sd <diroff> set the subdirectory\n" +" -sf <tagname> <filename> read the tag value from file (for ASCII tags only)\n" +" -h this help screen\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; usageMsg[i]; i++) - fprintf(out, "%s\n", usageMsg[i]); + fprintf(out, "%s", usageMsg); exit(code); } @@ -221,37 +219,37 @@ main(int argc, char* argv[]) switch (TIFFFieldDataType(fip)) { case TIFF_BYTE: for (i = 0; i < wc; i++) - ((uint8 *)array)[i] = atoi(argv[arg_index+i]); + ((uint8_t *)array)[i] = atoi(argv[arg_index + i]); break; case TIFF_SHORT: for (i = 0; i < wc; i++) - ((uint16 *)array)[i] = atoi(argv[arg_index+i]); + ((uint16_t *)array)[i] = atoi(argv[arg_index + i]); break; case TIFF_SBYTE: for (i = 0; i < wc; i++) - ((int8 *)array)[i] = atoi(argv[arg_index+i]); + ((int8_t *)array)[i] = atoi(argv[arg_index + i]); break; case TIFF_SSHORT: for (i = 0; i < wc; i++) - ((int16 *)array)[i] = atoi(argv[arg_index+i]); + ((int16_t *)array)[i] = atoi(argv[arg_index + i]); break; case TIFF_LONG: for (i = 0; i < wc; i++) - ((uint32 *)array)[i] = atol(argv[arg_index+i]); + ((uint32_t *)array)[i] = atol(argv[arg_index + i]); break; case TIFF_SLONG: case TIFF_IFD: for (i = 0; i < wc; i++) - ((int32 *)array)[i] = atol(argv[arg_index+i]); + ((int32_t *)array)[i] = atol(argv[arg_index + i]); break; case TIFF_LONG8: for (i = 0; i < wc; i++) - ((uint64 *)array)[i] = strtoll(argv[arg_index+i], (char **)NULL, 10); + ((uint64_t *)array)[i] = strtoll(argv[arg_index + i], (char **)NULL, 10); break; case TIFF_SLONG8: case TIFF_IFD8: for (i = 0; i < wc; i++) - ((int64 *)array)[i] = strtoll(argv[arg_index+i], (char **)NULL, 10); + ((int64_t *)array)[i] = strtoll(argv[arg_index + i], (char **)NULL, 10); break; case TIFF_DOUBLE: for (i = 0; i < wc; i++) @@ -276,10 +274,10 @@ main(int argc, char* argv[]) || TIFFFieldTag(fip) == TIFFTAG_DOTRANGE) { if (TIFFFieldDataType(fip) == TIFF_BYTE) { ret = TIFFSetField(tiff, TIFFFieldTag(fip), - ((uint8 *)array)[0], ((uint8 *)array)[1]); + ((uint8_t *)array)[0], ((uint8_t *)array)[1]); } else if (TIFFFieldDataType(fip) == TIFF_SHORT) { ret = TIFFSetField(tiff, TIFFFieldTag(fip), - ((uint16 *)array)[0], ((uint16 *)array)[1]); + ((uint16_t *)array)[0], ((uint16_t *)array)[1]); } } else { ret = TIFFSetField(tiff, TIFFFieldTag(fip), @@ -367,7 +365,7 @@ main(int argc, char* argv[]) fclose( fp ); if(TIFFFieldPassCount( fip )) { - ret = TIFFSetField( tiff, TIFFFieldTag(fip), (uint16)len, text ); + ret = TIFFSetField(tiff, TIFFFieldTag(fip), (uint16_t)len, text ); } else { ret = TIFFSetField( tiff, TIFFFieldTag(fip), text ); } diff --git a/tiff/tools/tiffsplit.c b/tiff/tools/tiffsplit.c index 43b6fdc1..296d6bf9 100644 --- a/tiff/tools/tiffsplit.c +++ b/tiff/tools/tiffsplit.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -37,10 +38,6 @@ #define EXIT_FAILURE 1 #endif -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #define CopyField2(tag, v1, v2) \ @@ -64,40 +61,46 @@ main(int argc, char* argv[]) { TIFF *in, *out; - if (argc < 2) { - fprintf(stderr, "%s\n\n", TIFFGetVersion()); - fprintf(stderr, "usage: tiffsplit input.tif [prefix]\n"); + if (argc < 2 || argc > 3) { + fprintf(stderr, "%s\n\n", TIFFGetVersion()); + fprintf(stderr, "Split a multi-image TIFF into single-image TIFF files\n\n"); + fprintf(stderr, "usage: tiffsplit input.tif [prefix]\n"); return (EXIT_FAILURE); } if (argc > 2) { strncpy(fname, argv[2], sizeof(fname)); fname[sizeof(fname) - 1] = '\0'; } + in = TIFFOpen(argv[1], "r"); - if (in != NULL) { - do { - size_t path_len; - char *path; - - newfilename(); + if (in == NULL) { + return EXIT_FAILURE; + } - path_len = strlen(fname) + sizeof(TIFF_SUFFIX); - path = (char *) _TIFFmalloc(path_len); - strncpy(path, fname, path_len); - path[path_len - 1] = '\0'; - strncat(path, TIFF_SUFFIX, path_len - strlen(path) - 1); - out = TIFFOpen(path, TIFFIsBigEndian(in)?"wb":"wl"); - _TIFFfree(path); + do { + size_t path_len; + char *path; - if (out == NULL) - return (EXIT_FAILURE); - if (!tiffcp(in, out)) - return (EXIT_FAILURE); - TIFFClose(out); - } while (TIFFReadDirectory(in)); - (void) TIFFClose(in); - } - return (EXIT_SUCCESS); + newfilename(); + + path_len = strlen(fname) + sizeof(TIFF_SUFFIX); + path = (char *) _TIFFmalloc(path_len); + strncpy(path, fname, path_len); + path[path_len - 1] = '\0'; + strncat(path, TIFF_SUFFIX, path_len - strlen(path) - 1); + out = TIFFOpen(path, TIFFIsBigEndian(in)?"wb":"wl"); + _TIFFfree(path); + + if (out == NULL) + return (EXIT_FAILURE); + if (!tiffcp(in, out)) + return (EXIT_FAILURE); + TIFFClose(out); + } while (TIFFReadDirectory(in)); + + (void) TIFFClose(in); + + return (EXIT_SUCCESS); } static void @@ -162,11 +165,11 @@ newfilename(void) static int tiffcp(TIFF* in, TIFF* out) { - uint16 bitspersample, samplesperpixel, compression, shortv, *shortav; - uint32 w, l; + uint16_t bitspersample, samplesperpixel, compression, shortv, *shortav; + uint32_t w, l; float floatv; char *stringv; - uint32 longv; + uint32_t longv; CopyField(TIFFTAG_SUBFILETYPE, longv); CopyField(TIFFTAG_TILEWIDTH, w); @@ -177,7 +180,7 @@ tiffcp(TIFF* in, TIFF* out) CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); CopyField(TIFFTAG_COMPRESSION, compression); if (compression == COMPRESSION_JPEG) { - uint32 count = 0; + uint32_t count = 0; void *table = NULL; if (TIFFGetField(in, TIFFTAG_JPEGTABLES, &count, &table) && count > 0 && table) { @@ -204,10 +207,10 @@ tiffcp(TIFF* in, TIFF* out) CopyField(TIFFTAG_TILEDEPTH, longv); CopyField(TIFFTAG_SAMPLEFORMAT, shortv); CopyField2(TIFFTAG_EXTRASAMPLES, shortv, shortav); - { uint16 *red, *green, *blue; + { uint16_t *red, *green, *blue; CopyField3(TIFFTAG_COLORMAP, red, green, blue); } - { uint16 shortv2; + { uint16_t shortv2; CopyField2(TIFFTAG_PAGENUMBER, shortv, shortv2); } CopyField(TIFFTAG_ARTIST, stringv); @@ -240,7 +243,7 @@ cpStrips(TIFF* in, TIFF* out) if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); - uint64 *bytecounts; + uint64_t *bytecounts; if (!TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts)) { fprintf(stderr, "tiffsplit: strip byte counts are missing\n"); @@ -248,7 +251,7 @@ cpStrips(TIFF* in, TIFF* out) return (0); } for (s = 0; s < ns; s++) { - if (bytecounts[s] > (uint64)bufsize) { + if (bytecounts[s] > (uint64_t)bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[s]); if (!buf) return (0); @@ -274,7 +277,7 @@ cpTiles(TIFF* in, TIFF* out) if (buf) { ttile_t t, nt = TIFFNumberOfTiles(in); - uint64 *bytecounts; + uint64_t *bytecounts; if (!TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts)) { fprintf(stderr, "tiffsplit: tile byte counts are missing\n"); @@ -282,7 +285,7 @@ cpTiles(TIFF* in, TIFF* out) return (0); } for (t = 0; t < nt; t++) { - if (bytecounts[t] > (uint64) bufsize) { + if (bytecounts[t] > (uint64_t) bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[t]); if (!buf) return (0); |