diff --git a/compat/crypt.h b/compat/crypt.h index 46f2b670..41c6454c 100644 --- a/compat/crypt.h +++ b/compat/crypt.h @@ -25,12 +25,15 @@ Encryption is not supported. */ -#ifndef _ZLIB_H -# if (ZLIB_VERNUM < 0x1270) - typedef unsigned long z_crc_t; -# else - typedef uint32_t z_crc_t; -# endif +#ifndef ZLIB_VERNUM +/* No zlib */ +typedef uint32_t z_crc_t; +#elif (ZLIB_VERNUM & 0xf != 0xf) && (ZLIB_VERNUM < 0x1270) +/* Define z_crc_t in zlib 1.2.6 and less */ +typedef unsigned long z_crc_t; +#elif (ZLIB_VERNUM & 0xf == 0xf) && (ZLIB_VERNUM < 0x12df) +/* Define z_crc_t in zlib-ng 2.0.7 and less */ +typedef unsigned int z_crc_t; #endif #define CRC32(c, b) ((*(pcrc_32_tab + (((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) diff --git a/compat/ioapi.h b/compat/ioapi.h index 79cffc85..82507460 100644 --- a/compat/ioapi.h +++ b/compat/ioapi.h @@ -4,8 +4,12 @@ #include -#ifndef _ZLIB_H -//#include "zlib.h" +#if !defined(_ZLIB_H) && !defined(ZLIB_H) && !defined(ZLIB_H_) +# if __has_include() +# include +# elif __has_include() +# include +# endif #endif typedef uint64_t ZPOS64_T; diff --git a/compat/unzip.h b/compat/unzip.h index 7c24b60a..0c081542 100644 --- a/compat/unzip.h +++ b/compat/unzip.h @@ -38,18 +38,6 @@ typedef void *unzFile; /***************************************************************************/ -#ifndef Z_ERRNO -#define Z_ERRNO (-1) -#endif -#ifndef Z_DEFLATED -#define Z_DEFLATED (8) -#endif -#ifndef Z_BZIP2ED -#define Z_BZIP2ED (12) -#endif - -/***************************************************************************/ - #define UNZ_OK (0) #define UNZ_END_OF_LIST_OF_FILE (-100) #define UNZ_ERRNO (Z_ERRNO) diff --git a/compat/zip.h b/compat/zip.h index 5c1f1258..67f5a5b1 100644 --- a/compat/zip.h +++ b/compat/zip.h @@ -38,16 +38,6 @@ typedef void *zipFile; /***************************************************************************/ -#ifndef Z_ERRNO -#define Z_ERRNO (-1) -#endif -#ifndef Z_DEFLATED -#define Z_DEFLATED (8) -#endif -#ifndef Z_BZIP2ED -#define Z_BZIP2ED (12) -#endif - #define ZIP_OK (0) #define ZIP_EOF (0) #define ZIP_ERRNO (Z_ERRNO) diff --git a/mz_crypt.c b/mz_crypt.c index 0b068e0b..7a47ff20 100644 --- a/mz_crypt.c +++ b/mz_crypt.c @@ -34,11 +34,15 @@ int32_t mz_crypt_rand(uint8_t *buf, int32_t size) { uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size) { #if defined(HAVE_ZLIB) - /* Define z_crc_t in zlib 1.2.5 and less or if using zlib-ng */ -# if (ZLIB_VERNUM < 0x1270) - typedef unsigned long z_crc_t; -# else +# ifndef ZLIB_VERNUM + /* HAVE_ZLIB but no ZLIB_VERNUM? */ typedef uint32_t z_crc_t; +# elif (ZLIB_VERNUM & 0xf != 0xf) && (ZLIB_VERNUM < 0x1270) + /* Define z_crc_t in zlib 1.2.6 and less */ + typedef unsigned long z_crc_t; +# elif (ZLIB_VERNUM & 0xf == 0xf) && (ZLIB_VERNUM < 0x12df) + /* Define z_crc_t in zlib-ng 2.0.7 and less */ + typedef unsigned int z_crc_t; # endif return (uint32_t)ZLIB_PREFIX(crc32)((z_crc_t)value, buf, (uInt)size); #elif defined(HAVE_LZMA)