Make inttypes.h optional. #345

This commit is contained in:
Nathan Moinvaziri 2018-11-19 21:34:35 -08:00
parent 0ecfd22443
commit 1ee609b759
24 changed files with 88 additions and 141 deletions

View File

@ -172,10 +172,6 @@ endif()
# Check for system includes
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(limits.h HAVE_LIMITS_H)
if(HAVE_STDINT_H)
add_definitions(-DHAVE_STDINT_H)
@ -183,18 +179,7 @@ endif()
if(HAVE_INTTYPES_H)
add_definitions(-DHAVE_INTTYPES_H)
endif()
if(HAVE_STRING_H)
add_definitions(-DHAVE_STRING_H)
endif()
if(HAVE_STRINGS_H)
add_definitions(-DHAVE_STRINGS_H)
endif()
if(HAVE_MEMORY_H)
add_definitions(-DHAVE_MEMORY_H)
endif()
if(HAVE_LIMITS)
add_definitions(-DHAVE_LIMITS_H)
endif()
# Check for large file support
check_type_size(off64_t OFF64_T)
if(HAVE_OFF64_T)
@ -289,8 +274,8 @@ if(USE_COMPAT)
See the accompanying LICENSE file for the full text of the license.\n\
*/\n\n\
#ifndef MZ_COMPAT_FILE\n\
#define MZ_COMPAT_FILE\n\
#include \"mz_compat.h\"\n\
#define MZ_COMPAT_FILE\n\n\
#include \"mz_compat.h\"\n\n\
#endif\n")
string(REPLACE "file.h" "zip.h" ZIP_COMPAT_HEADER ${COMPAT_HEADER})
@ -413,8 +398,25 @@ if(USE_LZMA)
add_definitions(-DLZMA_API_STATIC)
add_definitions(-DHAVE_CONFIG_H)
check_include_file(limits.h HAVE_LIMITS_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(stdbool.h HAVE_STDBOOL_H)
check_include_file(immintrin.h HAVE_IMMINTRIN_H)
if(HAVE_LIMITS_H)
add_definitions(-DHAVE_LIMITS_H)
endif()
if(HAVE_STRING_H)
add_definitions(-DHAVE_STRING_H)
endif()
if(HAVE_STRINGS_H)
add_definitions(-DHAVE_STRINGS_H)
endif()
if(HAVE_MEMORY_H)
add_definitions(-DHAVE_MEMORY_H)
endif()
if(HAVE_STDBOOL_H)
add_definitions(-DHAVE_STDBOOL_H)
endif()

45
mz.h
View File

@ -12,10 +12,6 @@
#ifndef MZ_H
#define MZ_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************/
// MZ_VERSION
@ -149,8 +145,45 @@ extern "C" {
/***************************************************************************/
#ifdef __cplusplus
}
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h> // size_t and NULL
#include <time.h> // time_t and time()
#include <string.h>
#include <limits.h>
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#else
# define PRId8 "hhd"
# define PRId16 "hd"
# define PRId32 "d"
# define PRIu32 "u"
# define PRIx32 "x"
# if ULONG_MAX == 4294967295UL
# define PRId64 "lld"
# define PRIu64 "llu"
# define PRIx64 "llx"
# else
# define PRId64 "ld"
# define PRIu64 "lu"
# define PRIx64 "lx"
# endif
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#else
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
#endif
/***************************************************************************/
#endif

View File

@ -14,8 +14,7 @@
#ifndef MZ_COMPAT_H
#define MZ_COMPAT_H
#include <stdint.h>
#include <time.h>
#include "mz.h"
#ifdef __cplusplus
extern "C" {

View File

@ -10,8 +10,8 @@
*/
#include <stdint.h>
#include <string.h>
#include "mz.h"
#include "mz_crypt.h"
#if defined(HAVE_ZLIB)
#include "zlib.h"
@ -19,9 +19,6 @@
#include "lzma.h"
#endif
#include "mz.h"
#include "mz_crypt.h"
/***************************************************************************/
uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size)

View File

@ -12,8 +12,6 @@
#ifndef MZ_CRYPT_H
#define MZ_CRYPT_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -9,9 +9,6 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CommonCrypto/CommonCryptor.h>

View File

@ -9,9 +9,7 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>

View File

@ -9,9 +9,6 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <openssl/err.h>
#include <openssl/rand.h>

View File

@ -11,18 +11,12 @@
#pragma comment(lib, "crypt32.lib")
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "mz.h"
#include "mz_os.h"
#include <windows.h>
#include <wincrypt.h>
#include "mz.h"
#include "mz_os.h"
/***************************************************************************/
int32_t mz_crypt_rand(uint8_t *buf, int32_t size)

View File

@ -11,18 +11,14 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "mz.h"
#include "mz_crypt.h"
#include "mz_os.h"
#include "mz_strm.h"
#include "mz_strm_os.h"
#include <ctype.h> // tolower
/***************************************************************************/
int32_t mz_path_combine(char *path, const char *join, int32_t max_path)

View File

@ -9,20 +9,15 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <direct.h>
#include <errno.h>
#include <windows.h>
#include "mz.h"
#include "mz_os.h"
#include "mz_strm_os.h"
#include <direct.h>
#include <errno.h>
#include <windows.h>
/***************************************************************************/
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(MZ_WINRT_API)))

View File

@ -9,10 +9,6 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "mz.h"
#include "mz_strm.h"

View File

@ -11,13 +11,6 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <errno.h>
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_buf.h"
@ -267,8 +260,8 @@ int64_t mz_stream_buffered_tell(void *stream)
buffered->position = position;
mz_stream_buffered_print("Buffered - Tell (pos %"PRId64" readpos %"PRId32" writepos %"PRId32" err %"PRId32")\n",
buffered->position, buffered->readbuf_pos, buffered->writebuf_pos, errno);
mz_stream_buffered_print("Buffered - Tell (pos %"PRId64" readpos %"PRId32" writepos %"PRId32")\n",
buffered->position, buffered->readbuf_pos, buffered->writebuf_pos);
if (buffered->readbuf_len > 0)
position -= ((int64_t)buffered->readbuf_len - buffered->readbuf_pos);

View File

@ -10,16 +10,12 @@
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "bzlib.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_bzip.h"
#include "bzlib.h"
/***************************************************************************/
static mz_stream_vtbl mz_stream_bzip_vtbl = {

View File

@ -10,18 +10,14 @@
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_libcomp.h"
#include <compression.h>
#include "zlib.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_libcomp.h"
/***************************************************************************/
static mz_stream_vtbl mz_stream_libcomp_vtbl = {

View File

@ -10,17 +10,12 @@
*/
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "lzma.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_lzma.h"
#include "lzma.h"
/***************************************************************************/
#define MZ_LZMA_HEADER_SIZE (4)

View File

@ -18,10 +18,6 @@
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_mem.h"

View File

@ -14,16 +14,13 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_os.h"
#include <errno.h>
/***************************************************************************/
#define fopen64 fopen

View File

@ -14,17 +14,14 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <windows.h>
#include "mz.h"
#include "mz_os.h"
#include "mz_strm.h"
#include "mz_strm_os.h"
#include <windows.h>
/***************************************************************************/
#ifndef INVALID_HANDLE_VALUE

View File

@ -9,12 +9,6 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <time.h>
#include "mz.h"
#include "mz_os.h"

View File

@ -11,10 +11,6 @@
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "mz.h"
#include "mz_crypt.h"
#include "mz_strm.h"

View File

@ -10,16 +10,12 @@
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "zlib.h"
#include "mz.h"
#include "mz_strm.h"
#include "mz_strm_zlib.h"
#include "zlib.h"
/***************************************************************************/
#ifndef DEF_MEM_LEVEL

View File

@ -16,14 +16,6 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <ctype.h>
#include <time.h>
#include <limits.h>
#include "mz.h"
#include "mz_crypt.h"
@ -47,6 +39,8 @@
#include "mz_zip.h"
#include <ctype.h> // tolower
#if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
#endif

View File

@ -9,11 +9,6 @@
See the accompanying LICENSE file for the full text of the license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "mz.h"
#include "mz_crypt.h"
#include "mz_os.h"