mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Add MINIZ_NO_DEFLATE_APIS and MINIZ_NO_INFLATE_APIS
This commit is contained in:
		| @@ -18,7 +18,7 @@ then | |||||||
| 		echo "Test compile with clang..." | 		echo "Test compile with clang..." | ||||||
|         clang -Wall -Wpedantic -fsanitize=unsigned-integer-overflow -I$OUTPUT_PREFIX main.c $OUTPUT_PREFIX/miniz.c -o test.out |         clang -Wall -Wpedantic -fsanitize=unsigned-integer-overflow -I$OUTPUT_PREFIX main.c $OUTPUT_PREFIX/miniz.c -o test.out | ||||||
| fi | fi | ||||||
| for def in MINIZ_NO_STDIO MINIZ_NO_TIME MINIZ_NO_ARCHIVE_APIS MINIZ_NO_ARCHIVE_WRITING_APIS MINIZ_NO_ZLIB_APIS MINIZ_NO_ZLIB_COMPATIBLE_NAMES MINIZ_NO_MALLOC | for def in MINIZ_NO_STDIO MINIZ_NO_TIME MINIZ_NO_DEFLATE_APIS MINIZ_NO_INFLATE_APIS MINIZ_NO_ARCHIVE_APIS MINIZ_NO_ARCHIVE_WRITING_APIS MINIZ_NO_ZLIB_APIS MINIZ_NO_ZLIB_COMPATIBLE_NAMES MINIZ_NO_MALLOC | ||||||
| do | do | ||||||
| 	echo "Test compile with GCC and define $def..." | 	echo "Test compile with GCC and define $def..." | ||||||
| 	gcc -ansi -pedantic -Wall -I$OUTPUT_PREFIX main.c $OUTPUT_PREFIX/miniz.c -o test.out -D${def} | 	gcc -ansi -pedantic -Wall -I$OUTPUT_PREFIX main.c $OUTPUT_PREFIX/miniz.c -o test.out -D${def} | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								miniz.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								miniz.c
									
									
									
									
									
								
							| @@ -186,6 +186,8 @@ const char *mz_version(void) | |||||||
|  |  | ||||||
| #ifndef MINIZ_NO_ZLIB_APIS | #ifndef MINIZ_NO_ZLIB_APIS | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_DEFLATE_APIS | ||||||
|  |  | ||||||
| int mz_deflateInit(mz_streamp pStream, int level) | int mz_deflateInit(mz_streamp pStream, int level) | ||||||
| { | { | ||||||
|     return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); |     return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY); | ||||||
| @@ -353,6 +355,10 @@ mz_ulong mz_compressBound(mz_ulong source_len) | |||||||
|     return mz_deflateBound(NULL, source_len); |     return mz_deflateBound(NULL, source_len); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_INFLATE_APIS | ||||||
|  |  | ||||||
| typedef struct | typedef struct | ||||||
| { | { | ||||||
|     tinfl_decompressor m_decomp; |     tinfl_decompressor m_decomp; | ||||||
| @@ -588,6 +594,8 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char | |||||||
|     return mz_uncompress2(pDest, pDest_len, pSource, &source_len); |     return mz_uncompress2(pDest, pDest_len, pSource, &source_len); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ | ||||||
|  |  | ||||||
| const char *mz_error(int err) | const char *mz_error(int err) | ||||||
| { | { | ||||||
|     static struct |     static struct | ||||||
|   | |||||||
							
								
								
									
										30
									
								
								miniz.h
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								miniz.h
									
									
									
									
									
								
							| @@ -115,7 +115,7 @@ | |||||||
| #include "miniz_export.h" | #include "miniz_export.h" | ||||||
|  |  | ||||||
| /* Defines to completely disable specific portions of miniz.c:  | /* Defines to completely disable specific portions of miniz.c:  | ||||||
|    If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. */ |    If all macros here are defined the only functionality remaining will be CRC-32 and adler-32. */ | ||||||
|  |  | ||||||
| /* Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. */ | /* Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. */ | ||||||
| /*#define MINIZ_NO_STDIO */ | /*#define MINIZ_NO_STDIO */ | ||||||
| @@ -125,6 +125,12 @@ | |||||||
| /* The current downside is the times written to your archives will be from 1979. */ | /* The current downside is the times written to your archives will be from 1979. */ | ||||||
| /*#define MINIZ_NO_TIME */ | /*#define MINIZ_NO_TIME */ | ||||||
|  |  | ||||||
|  | /* Define MINIZ_NO_DEFLATE_APIS to disable all compression API's. */ | ||||||
|  | /*#define MINIZ_NO_DEFLATE_APIS */ | ||||||
|  |  | ||||||
|  | /* Define MINIZ_NO_INFLATE_APIS to disable all decompression API's. */ | ||||||
|  | /*#define MINIZ_NO_INFLATE_APIS */ | ||||||
|  |  | ||||||
| /* Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. */ | /* Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's. */ | ||||||
| /*#define MINIZ_NO_ARCHIVE_APIS */ | /*#define MINIZ_NO_ARCHIVE_APIS */ | ||||||
|  |  | ||||||
| @@ -143,6 +149,14 @@ | |||||||
|    functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. */ |    functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. */ | ||||||
| /*#define MINIZ_NO_MALLOC */ | /*#define MINIZ_NO_MALLOC */ | ||||||
|  |  | ||||||
|  | #ifdef MINIZ_NO_INFLATE_APIS | ||||||
|  | #define MINIZ_NO_ARCHIVE_APIS | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #ifdef MINIZ_NO_DEFLATE_APIS | ||||||
|  | #define MINIZ_NO_ARCHIVE_WRITING_APIS | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) | #if defined(__TINYC__) && (defined(__linux) || defined(__linux__)) | ||||||
| /* TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux */ | /* TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux */ | ||||||
| #define MINIZ_NO_TIME | #define MINIZ_NO_TIME | ||||||
| @@ -304,6 +318,8 @@ typedef mz_stream *mz_streamp; | |||||||
| /* Returns the version string of miniz.c. */ | /* Returns the version string of miniz.c. */ | ||||||
| MINIZ_EXPORT const char *mz_version(void); | MINIZ_EXPORT const char *mz_version(void); | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_DEFLATE_APIS | ||||||
|  |  | ||||||
| /* mz_deflateInit() initializes a compressor with default options: */ | /* mz_deflateInit() initializes a compressor with default options: */ | ||||||
| /* Parameters: */ | /* Parameters: */ | ||||||
| /*  pStream must point to an initialized mz_stream struct. */ | /*  pStream must point to an initialized mz_stream struct. */ | ||||||
| @@ -356,6 +372,10 @@ MINIZ_EXPORT int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const u | |||||||
| /* mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). */ | /* mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). */ | ||||||
| MINIZ_EXPORT mz_ulong mz_compressBound(mz_ulong source_len); | MINIZ_EXPORT mz_ulong mz_compressBound(mz_ulong source_len); | ||||||
|  |  | ||||||
|  | #endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_INFLATE_APIS | ||||||
|  |  | ||||||
| /* Initializes a decompressor. */ | /* Initializes a decompressor. */ | ||||||
| MINIZ_EXPORT int mz_inflateInit(mz_streamp pStream); | MINIZ_EXPORT int mz_inflateInit(mz_streamp pStream); | ||||||
|  |  | ||||||
| @@ -389,6 +409,7 @@ MINIZ_EXPORT int mz_inflateEnd(mz_streamp pStream); | |||||||
| /* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */ | /* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */ | ||||||
| MINIZ_EXPORT int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); | MINIZ_EXPORT int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); | ||||||
| MINIZ_EXPORT int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len); | MINIZ_EXPORT int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len); | ||||||
|  | #endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ | ||||||
|  |  | ||||||
| /* Returns a string description of the specified error code, or NULL if the error code is invalid. */ | /* Returns a string description of the specified error code, or NULL if the error code is invalid. */ | ||||||
| MINIZ_EXPORT const char *mz_error(int err); | MINIZ_EXPORT const char *mz_error(int err); | ||||||
| @@ -439,6 +460,8 @@ typedef void *const voidpc; | |||||||
| #define free_func mz_free_func | #define free_func mz_free_func | ||||||
| #define internal_state mz_internal_state | #define internal_state mz_internal_state | ||||||
| #define z_stream mz_stream | #define z_stream mz_stream | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_DEFLATE_APIS | ||||||
| #define deflateInit mz_deflateInit | #define deflateInit mz_deflateInit | ||||||
| #define deflateInit2 mz_deflateInit2 | #define deflateInit2 mz_deflateInit2 | ||||||
| #define deflateReset mz_deflateReset | #define deflateReset mz_deflateReset | ||||||
| @@ -448,6 +471,9 @@ typedef void *const voidpc; | |||||||
| #define compress mz_compress | #define compress mz_compress | ||||||
| #define compress2 mz_compress2 | #define compress2 mz_compress2 | ||||||
| #define compressBound mz_compressBound | #define compressBound mz_compressBound | ||||||
|  | #endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_INFLATE_APIS | ||||||
| #define inflateInit mz_inflateInit | #define inflateInit mz_inflateInit | ||||||
| #define inflateInit2 mz_inflateInit2 | #define inflateInit2 mz_inflateInit2 | ||||||
| #define inflateReset mz_inflateReset | #define inflateReset mz_inflateReset | ||||||
| @@ -455,6 +481,8 @@ typedef void *const voidpc; | |||||||
| #define inflateEnd mz_inflateEnd | #define inflateEnd mz_inflateEnd | ||||||
| #define uncompress mz_uncompress | #define uncompress mz_uncompress | ||||||
| #define uncompress2 mz_uncompress2 | #define uncompress2 mz_uncompress2 | ||||||
|  | #endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ | ||||||
|  |  | ||||||
| #define crc32 mz_crc32 | #define crc32 mz_crc32 | ||||||
| #define adler32 mz_adler32 | #define adler32 mz_adler32 | ||||||
| #define MAX_WBITS 15 | #define MAX_WBITS 15 | ||||||
|   | |||||||
| @@ -26,6 +26,8 @@ | |||||||
|  |  | ||||||
| #include "miniz.h" | #include "miniz.h" | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_DEFLATE_APIS | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| @@ -1575,3 +1577,5 @@ void tdefl_compressor_free(tdefl_compressor *pComp) | |||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #include "miniz_common.h" | #include "miniz_common.h" | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_DEFLATE_APIS | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| @@ -188,3 +190,5 @@ MINIZ_EXPORT void tdefl_compressor_free(tdefl_compressor *pComp); | |||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #endif /*#ifndef MINIZ_NO_DEFLATE_APIS*/ | ||||||
|   | |||||||
| @@ -26,6 +26,8 @@ | |||||||
|  |  | ||||||
| #include "miniz.h" | #include "miniz.h" | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_INFLATE_APIS | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| @@ -738,3 +740,5 @@ void tinfl_decompressor_free(tinfl_decompressor *pDecomp) | |||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ | ||||||
|   | |||||||
| @@ -2,6 +2,8 @@ | |||||||
| #include "miniz_common.h" | #include "miniz_common.h" | ||||||
| /* ------------------- Low-level Decompression API Definitions */ | /* ------------------- Low-level Decompression API Definitions */ | ||||||
|  |  | ||||||
|  | #ifndef MINIZ_NO_INFLATE_APIS | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
| @@ -142,3 +144,5 @@ struct tinfl_decompressor_tag | |||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #endif /*#ifndef MINIZ_NO_INFLATE_APIS*/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user