Skip to content

Commit

Permalink
Clean up defines
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed Mar 5, 2022
1 parent f280f1b commit 2d10201
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions mz_crypt.c
Expand Up @@ -15,34 +15,16 @@

#if defined(HAVE_ZLIB)
# if !defined(ZLIB_COMPAT)
# include <zlib-ng.h>
# define ZPREFIX(x) zng_ ## x
typedef zng_stream zlib_stream;
# include "zlib-ng.h"
# define ZLIB_PREFIX(x) zng_ ## x
# else
# include <zlib.h>
typedef z_stream zlib_stream;
# include "zlib.h"
# define ZLIB_PREFIX(x) x
# endif
#elif defined(HAVE_LZMA)
# include "lzma.h"
#endif

/***************************************************************************/
/* Define z_crc_t in zlib 1.2.5 and less or if using zlib-ng */

#if defined(HAVE_ZLIB) && defined(ZLIBNG_VERNUM)
# if defined(ZLIB_COMPAT)
# define ZLIB_PREFIX(x) x
# else
# define ZLIB_PREFIX(x) zng_ ## x
# endif
typedef uint32_t z_crc_t;
#elif defined(HAVE_ZLIB)
# define ZLIB_PREFIX(x) x
# if (ZLIB_VERNUM < 0x1270)
typedef unsigned long z_crc_t;
# endif
#endif

/***************************************************************************/

#if defined(MZ_ZIP_NO_CRYPTO)
Expand All @@ -53,6 +35,12 @@ 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
typedef uint32_t z_crc_t;
# endif
return (uint32_t)ZLIB_PREFIX(crc32)((z_crc_t)value, buf, (uInt)size);
#elif defined(HAVE_LZMA)
return (uint32_t)lzma_crc32(buf, (size_t)size, (uint32_t)value);
Expand Down

0 comments on commit 2d10201

Please sign in to comment.