diff --git a/Example/ObjectiveCExampleTests/SSZipArchiveTests.m b/Example/ObjectiveCExampleTests/SSZipArchiveTests.m index c5a6bb3..40cf537 100644 --- a/Example/ObjectiveCExampleTests/SSZipArchiveTests.m +++ b/Example/ObjectiveCExampleTests/SSZipArchiveTests.m @@ -768,7 +768,7 @@ int twentyMB = 20 * 1024 * 1024; /* Test our implementation is equivalent to `[NSDate dateWithTimeIntervalSince1970:mz_zip_dosdate_to_time_t(msdosDateTime)]` */ - // fixed mz_zip_dosdate_to_time_t implementation (https://github.com/zlib-ng/minizip-ng/pull/820) + // copy of mz_zip_dosdate_to_time_t implementation uint64_t date_min = (uint64_t)(dos_date_min >> 16); ptm.tm_mday = (int16_t)(date_min & 0x1f); ptm.tm_mon = (int16_t)(((date_min & 0x1E0) / 0x20) - 1); @@ -795,7 +795,7 @@ int twentyMB = 20 * 1024 * 1024; /* Test our implementation is equivalent to `[NSDate dateWithTimeIntervalSince1970:mz_zip_dosdate_to_time_t(msdosDateTime)]` */ - // fixed mz_zip_dosdate_to_time_t implementation (https://github.com/zlib-ng/minizip-ng/pull/820) + // copy of mz_zip_dosdate_to_time_t implementation uint64_t date_max = (uint64_t)(dos_date_max >> 16); ptm.tm_mday = (int16_t)(date_max & 0x1f); ptm.tm_mon = (int16_t)(((date_max & 0x1E0) / 0x20) - 1); diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 5c8cc64..0f37450 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: ".." SPEC CHECKSUMS: - SSZipArchive: 9aa2d1327379f342c3ec700147b40387c1d8bd21 + SSZipArchive: b8432bff6eda5ebcdda3c66b43cd73c407212abf PODFILE CHECKSUM: f72aa12c216b9028a1e05f38d3c62c3f6f602c06 diff --git a/Package.swift b/Package.swift index e461c3d..6b6b5a3 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( .macOS(.v10_15), .visionOS("1.0"), .watchOS("8.4"), - .macCatalyst("13.0") + .macCatalyst("13.0"), ], products: [ .library(name: "ZipArchive", targets: ["ZipArchive"]), @@ -30,7 +30,8 @@ let package = Package( .define("HAVE_STDINT_H"), .define("HAVE_WZAES"), .define("HAVE_ZLIB"), - .define("ZLIB_COMPAT") + .define("ZLIB_COMPAT"), + .headerSearchPath("minizip"), ], linkerSettings: [ .linkedLibrary("z"), diff --git a/Release-Instructions.md b/Release-Instructions.md index dd30114..ad2ac1b 100644 --- a/Release-Instructions.md +++ b/Release-Instructions.md @@ -43,6 +43,6 @@ Ignoring the ones starting with an underscore, like: "_BSD_SOURCE" "_DARWIN_C_SO 6. Set those flags in SSZipArchive.podspec (for CocoaPods) and in ZipArchive.xcodeproj (for Carthage) -7. Replace the .h and .c files with the latest ones, except for `mz_compat.h`, which is customized to expose some struct in SSZipCommon.h and to provide support for optional aes. +7. Replace the .h and .c files with the latest ones, except for `compat/*.{c,h}`, which are customized to expose some struct in SSZipCommon.h. -Note: we can also use `cmake -G Xcode . -DMZ_BZIP2=OFF -DMZ_LIBCOMP=OFF -DMZ_LZMA=OFF -DMZ_OPENSSL=OFF -DMZ_ZLIB=ON -DMZ_ZSTD=OFF` to get the list of files to include in an xcodeproj of its own, from where we can remove unneeded `zip.h` and `unzip.h`. +Note: we can also use `cmake -G Xcode . -DMZ_BZIP2=OFF -DMZ_LIBCOMP=OFF -DMZ_LZMA=OFF -DMZ_OPENSSL=OFF -DMZ_ZLIB=ON -DMZ_ZSTD=OFF` to get the list of files to include in an xcodeproj of its own. diff --git a/SSZipArchive.podspec b/SSZipArchive.podspec index e52ef24..083313c 100644 --- a/SSZipArchive.podspec +++ b/SSZipArchive.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.tvos.deployment_target = '15.4' s.visionos.deployment_target = '1.0' s.watchos.deployment_target = '8.4' - s.source_files = 'SSZipArchive/*.{m,h}', 'SSZipArchive/include/*.{m,h}', 'SSZipArchive/minizip/*.{c,h}' + s.source_files = 'SSZipArchive/*.{m,h}', 'SSZipArchive/include/*.{m,h}', 'SSZipArchive/minizip/*.{c,h}', 'SSZipArchive/minizip/compat/*.{c,h}' s.resource_bundles = {'SSZipArchive' => ['SSZipArchive/Supporting Files/Privacyinfo.xcprivacy']} s.public_header_files = 'SSZipArchive/*.h' s.libraries = 'z', 'iconv' diff --git a/SSZipArchive/SSZipArchive.m b/SSZipArchive/SSZipArchive.m index 5e5bf4f..3be361c 100644 --- a/SSZipArchive/SSZipArchive.m +++ b/SSZipArchive/SSZipArchive.m @@ -6,10 +6,12 @@ // #import "SSZipArchive.h" -#include "minizip/mz_compat.h" +#include "minizip/compat/ioapi.h" +#include "minizip/compat/unzip.h" +#include "minizip/compat/zip.h" +#include "minizip/mz.h" #include "minizip/mz_zip.h" #include "minizip/mz_os.h" -#include #include NSString *const SSZipArchiveErrorDomain = @"SSZipArchiveErrorDomain"; @@ -1270,7 +1272,7 @@ static bool filenameIsDirectory(const char *filename, uint16_t size) } NSNumber *fileSize = (NSNumber *)[attr objectForKey:NSFileSize]; - if (fileSize) + if (fileSize != nil) { zipInfo->uncompressed_size = fileSize.longLongValue; } diff --git a/SSZipArchive/SSZipCommon.h b/SSZipArchive/SSZipCommon.h index c3bc247..974cfc7 100644 --- a/SSZipArchive/SSZipCommon.h +++ b/SSZipArchive/SSZipCommon.h @@ -1,39 +1,42 @@ #ifndef SSZipCommon #define SSZipCommon -// typedefs moved from mz_compat.h to here for public access +// typedefs moved from unzip.h to here for public access /* unz_global_info structure contain global data about the ZIPfile These data comes from the end of central dir */ -typedef struct unz_global_info_s -{ - unsigned long number_entry; /* total number of entries in the central dir on this disk */ - unsigned long size_comment; /* size of the global comment of the zipfile */ - uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */ +typedef struct unz_global_info_s { + unsigned long number_entry; /* total number of entries in the central dir on this disk */ + unsigned long size_comment; /* size of the global comment of the zipfile */ + /* minizip-ng fields */ + uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */ } unz_global_info; /* unz_file_info contain information about a file in the zipfile */ /* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT */ -typedef struct unz_file_info_s -{ - unsigned long version; /* version made by 2 bytes */ - unsigned long version_needed; /* version needed to extract 2 bytes */ - unsigned long flag; /* general purpose bit flag 2 bytes */ - unsigned long compression_method; /* compression method 2 bytes */ - unsigned long dos_date; /* last mod file date in Dos fmt 4 bytes */ - unsigned long crc; /* crc-32 4 bytes */ - unsigned long compressed_size; /* compressed size 4 bytes */ - unsigned long uncompressed_size; /* uncompressed size 4 bytes */ - unsigned long size_filename; /* filename length 2 bytes */ - unsigned long size_file_extra; /* extra field length 2 bytes */ - unsigned long size_file_comment; /* file comment length 2 bytes */ +typedef struct unz_file_info_s { + unsigned long version; /* version made by 2 bytes */ + unsigned long version_needed; /* version needed to extract 2 bytes */ + unsigned long flag; /* general purpose bit flag 2 bytes */ + unsigned long compression_method; /* compression method 2 bytes */ + unsigned long dos_date; /* last mod file date in Dos fmt 4 bytes */ + unsigned long crc; /* crc-32 4 bytes */ + uint64_t compressed_size; /* compressed size 4 bytes */ + uint64_t uncompressed_size; /* uncompressed size 4 bytes */ + unsigned long size_filename; /* filename length 2 bytes */ + unsigned long size_file_extra; /* extra field length 2 bytes */ + unsigned long size_file_comment; /* file comment length 2 bytes */ - unsigned long disk_num_start; /* disk number start 2 bytes */ - unsigned long internal_fa; /* internal file attributes 2 bytes */ - unsigned long external_fa; /* external file attributes 4 bytes */ + unsigned long disk_num_start; /* disk number start 2 bytes */ + unsigned long internal_fa; /* internal file attributes 2 bytes */ + unsigned long external_fa; /* external file attributes 4 bytes */ + // [ZipArchive] disabled: we don't need the tmu_date field because we already set the dos_date field + // tm_unz tmu_date; + + /* minizip-ng fields */ uint64_t disk_offset; } unz_file_info; diff --git a/SSZipArchive/minizip/compat/ioapi.c b/SSZipArchive/minizip/compat/ioapi.c new file mode 100644 index 0000000..b0571ac --- /dev/null +++ b/SSZipArchive/minizip/compat/ioapi.c @@ -0,0 +1,261 @@ +#include "mz.h" +#include "mz_strm.h" +#include "mz_strm_mem.h" + +#include "ioapi.h" + +typedef struct mz_stream_ioapi_s { + mz_stream stream; + void *handle; + zlib_filefunc_def filefunc; + zlib_filefunc64_def filefunc64; +} mz_stream_ioapi; + +/***************************************************************************/ + +static int32_t mz_stream_ioapi_open(void *stream, const char *path, int32_t mode); +static int32_t mz_stream_ioapi_is_open(void *stream); +static int32_t mz_stream_ioapi_read(void *stream, void *buf, int32_t size); +static int32_t mz_stream_ioapi_write(void *stream, const void *buf, int32_t size); +static int64_t mz_stream_ioapi_tell(void *stream); +static int32_t mz_stream_ioapi_seek(void *stream, int64_t offset, int32_t origin); +static int32_t mz_stream_ioapi_close(void *stream); +static int32_t mz_stream_ioapi_error(void *stream); + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_ioapi_vtbl = {mz_stream_ioapi_open, + mz_stream_ioapi_is_open, + mz_stream_ioapi_read, + mz_stream_ioapi_write, + mz_stream_ioapi_tell, + mz_stream_ioapi_seek, + mz_stream_ioapi_close, + mz_stream_ioapi_error, + mz_stream_ioapi_create, + mz_stream_ioapi_delete, + NULL, + NULL}; + +/***************************************************************************/ + +static int32_t mz_stream_ioapi_open(void *stream, const char *path, int32_t mode) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + int32_t ioapi_mode = 0; + + if ((mode & MZ_OPEN_MODE_READWRITE) == MZ_OPEN_MODE_READ) + ioapi_mode = ZLIB_FILEFUNC_MODE_READ; + else if (mode & MZ_OPEN_MODE_APPEND) + ioapi_mode = ZLIB_FILEFUNC_MODE_EXISTING; + else if (mode & MZ_OPEN_MODE_CREATE) + ioapi_mode = ZLIB_FILEFUNC_MODE_CREATE; + else + return MZ_OPEN_ERROR; + + if (ioapi->filefunc64.zopen64_file) + ioapi->handle = ioapi->filefunc64.zopen64_file(ioapi->filefunc64.opaque, path, ioapi_mode); + else if (ioapi->filefunc.zopen_file) + ioapi->handle = ioapi->filefunc.zopen_file(ioapi->filefunc.opaque, path, ioapi_mode); + + if (!ioapi->handle) + return MZ_PARAM_ERROR; + + return MZ_OK; +} + +static int32_t mz_stream_ioapi_is_open(void *stream) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + if (!ioapi->handle) + return MZ_OPEN_ERROR; + return MZ_OK; +} + +static int32_t mz_stream_ioapi_read(void *stream, void *buf, int32_t size) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + read_file_func zread = NULL; + void *opaque = NULL; + + if (mz_stream_ioapi_is_open(stream) != MZ_OK) + return MZ_OPEN_ERROR; + + if (ioapi->filefunc64.zread_file) { + zread = ioapi->filefunc64.zread_file; + opaque = ioapi->filefunc64.opaque; + } else if (ioapi->filefunc.zread_file) { + zread = ioapi->filefunc.zread_file; + opaque = ioapi->filefunc.opaque; + } else + return MZ_PARAM_ERROR; + + return (int32_t)zread(opaque, ioapi->handle, buf, size); +} + +static int32_t mz_stream_ioapi_write(void *stream, const void *buf, int32_t size) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + write_file_func zwrite = NULL; + int32_t written = 0; + void *opaque = NULL; + + if (mz_stream_ioapi_is_open(stream) != MZ_OK) + return MZ_OPEN_ERROR; + + if (ioapi->filefunc64.zwrite_file) { + zwrite = ioapi->filefunc64.zwrite_file; + opaque = ioapi->filefunc64.opaque; + } else if (ioapi->filefunc.zwrite_file) { + zwrite = ioapi->filefunc.zwrite_file; + opaque = ioapi->filefunc.opaque; + } else + return MZ_PARAM_ERROR; + + written = (int32_t)zwrite(opaque, ioapi->handle, buf, size); + return written; +} + +static int64_t mz_stream_ioapi_tell(void *stream) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + + if (mz_stream_ioapi_is_open(stream) != MZ_OK) + return MZ_OPEN_ERROR; + + if (ioapi->filefunc64.ztell64_file) + return ioapi->filefunc64.ztell64_file(ioapi->filefunc64.opaque, ioapi->handle); + else if (ioapi->filefunc.ztell_file) + return ioapi->filefunc.ztell_file(ioapi->filefunc.opaque, ioapi->handle); + + return MZ_INTERNAL_ERROR; +} + +static int32_t mz_stream_ioapi_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + + if (mz_stream_ioapi_is_open(stream) != MZ_OK) + return MZ_OPEN_ERROR; + + if (ioapi->filefunc64.zseek64_file) { + if (ioapi->filefunc64.zseek64_file(ioapi->filefunc64.opaque, ioapi->handle, offset, origin) != 0) + return MZ_INTERNAL_ERROR; + } else if (ioapi->filefunc.zseek_file) { + if (ioapi->filefunc.zseek_file(ioapi->filefunc.opaque, ioapi->handle, (int32_t)offset, origin) != 0) + return MZ_INTERNAL_ERROR; + } else + return MZ_PARAM_ERROR; + + return MZ_OK; +} + +static int32_t mz_stream_ioapi_close(void *stream) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + close_file_func zclose = NULL; + void *opaque = NULL; + + if (mz_stream_ioapi_is_open(stream) != MZ_OK) + return MZ_OPEN_ERROR; + + if (ioapi->filefunc.zclose_file) { + zclose = ioapi->filefunc.zclose_file; + opaque = ioapi->filefunc.opaque; + } else if (ioapi->filefunc64.zclose_file) { + zclose = ioapi->filefunc64.zclose_file; + opaque = ioapi->filefunc64.opaque; + } else + return MZ_PARAM_ERROR; + + if (zclose(opaque, ioapi->handle) != 0) + return MZ_CLOSE_ERROR; + ioapi->handle = NULL; + return MZ_OK; +} + +static int32_t mz_stream_ioapi_error(void *stream) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + testerror_file_func zerror = NULL; + void *opaque = NULL; + + if (mz_stream_ioapi_is_open(stream) != MZ_OK) + return MZ_OPEN_ERROR; + + if (ioapi->filefunc.zerror_file) { + zerror = ioapi->filefunc.zerror_file; + opaque = ioapi->filefunc.opaque; + } else if (ioapi->filefunc64.zerror_file) { + zerror = ioapi->filefunc64.zerror_file; + opaque = ioapi->filefunc64.opaque; + } else + return MZ_PARAM_ERROR; + + return zerror(opaque, ioapi->handle); +} + +int32_t mz_stream_ioapi_set_filefunc(void *stream, zlib_filefunc_def *filefunc) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + memcpy(&ioapi->filefunc, filefunc, sizeof(zlib_filefunc_def)); + return MZ_OK; +} + +int32_t mz_stream_ioapi_set_filefunc64(void *stream, zlib_filefunc64_def *filefunc) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; + memcpy(&ioapi->filefunc64, filefunc, sizeof(zlib_filefunc64_def)); + return MZ_OK; +} + +void *mz_stream_ioapi_create(void) { + mz_stream_ioapi *ioapi = (mz_stream_ioapi *)calloc(1, sizeof(mz_stream_ioapi)); + if (ioapi) + ioapi->stream.vtbl = &mz_stream_ioapi_vtbl; + return ioapi; +} + +void mz_stream_ioapi_delete(void **stream) { + mz_stream_ioapi *ioapi = NULL; + if (!stream) + return; + ioapi = (mz_stream_ioapi *)*stream; + if (ioapi) + free(ioapi); + *stream = NULL; +} + +/***************************************************************************/ + +void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def) { + /* For 32-bit file support only, compile with MZ_FILE32_API */ + if (pzlib_filefunc_def) + memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc_def)); +} + +void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def) { + /* All mz_stream_os_* support large files if compilation supports it */ + if (pzlib_filefunc_def) + memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc64_def)); +} + +void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def) { + /* Handled by mz_stream_os_win32 */ + if (pzlib_filefunc_def) + memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc_def)); +} + +void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def) { + /* Automatically supported in mz_stream_os_win32 */ + if (pzlib_filefunc_def) + memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc64_def)); +} + +void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def) { + /* Automatically supported in mz_stream_os_win32 */ + if (pzlib_filefunc_def) + memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc64_def)); +} + +/* NOTE: fill_win32_filefunc64W is no longer necessary since wide-character + support is automatically handled by the underlying os stream. Do not + pass wide-characters to zipOpen or unzOpen. */ + +void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def) { + /* Use opaque to indicate which stream interface to create */ + if (pzlib_filefunc_def) { + memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc_def)); + pzlib_filefunc_def->opaque = mz_stream_mem_get_interface(); + } +} diff --git a/SSZipArchive/minizip/compat/ioapi.h b/SSZipArchive/minizip/compat/ioapi.h new file mode 100644 index 0000000..3f9c654 --- /dev/null +++ b/SSZipArchive/minizip/compat/ioapi.h @@ -0,0 +1,97 @@ + +#ifndef ZLIBIOAPI64_H +#define ZLIBIOAPI64_H + +#include + +typedef uint64_t ZPOS64_T; + +#ifndef ZEXPORT +# define ZEXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +#define ZLIB_FILEFUNC_SEEK_SET (0) +#define ZLIB_FILEFUNC_SEEK_CUR (1) +#define ZLIB_FILEFUNC_SEEK_END (2) + +#define ZLIB_FILEFUNC_MODE_READ (1) +#define ZLIB_FILEFUNC_MODE_WRITE (2) +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) + +#define ZLIB_FILEFUNC_MODE_EXISTING (4) +#define ZLIB_FILEFUNC_MODE_CREATE (8) + +#ifndef ZCALLBACK +# define ZCALLBACK +#endif + +/***************************************************************************/ + +typedef void *(ZCALLBACK *open_file_func)(void *opaque, const char *filename, int mode); +typedef void *(ZCALLBACK *open64_file_func)(void *opaque, const void *filename, int mode); +typedef unsigned long(ZCALLBACK *read_file_func)(void *opaque, void *stream, void *buf, unsigned long size); +typedef unsigned long(ZCALLBACK *write_file_func)(void *opaque, void *stream, const void *buf, unsigned long size); +typedef int(ZCALLBACK *close_file_func)(void *opaque, void *stream); +typedef int(ZCALLBACK *testerror_file_func)(void *opaque, void *stream); +typedef long(ZCALLBACK *tell_file_func)(void *opaque, void *stream); +typedef ZPOS64_T(ZCALLBACK *tell64_file_func)(void *opaque, void *stream); +typedef long(ZCALLBACK *seek_file_func)(void *opaque, void *stream, unsigned long offset, int origin); +typedef long(ZCALLBACK *seek64_file_func)(void *opaque, void *stream, ZPOS64_T offset, int origin); + +/***************************************************************************/ + +typedef struct zlib_filefunc_def_s { + open_file_func zopen_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell_file_func ztell_file; + seek_file_func zseek_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + void *opaque; +} zlib_filefunc_def; + +typedef struct zlib_filefunc64_def_s { + open64_file_func zopen64_file; + read_file_func zread_file; + write_file_func zwrite_file; + tell64_file_func ztell64_file; + seek64_file_func zseek64_file; + close_file_func zclose_file; + testerror_file_func zerror_file; + void *opaque; +} zlib_filefunc64_def; + +/***************************************************************************/ + +/* Compatibility layer with the original minizip library (ioapi.h and iowin32.h). */ +ZEXPORT void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def); +ZEXPORT void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def); +ZEXPORT void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def); +ZEXPORT void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def); +ZEXPORT void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def); + +/* Compatibility layer with older minizip-ng (ioapi_mem.h). */ +ZEXPORT void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def); + +/***************************************************************************/ + +int32_t mz_stream_ioapi_set_filefunc(void *stream, zlib_filefunc_def *filefunc); +int32_t mz_stream_ioapi_set_filefunc64(void *stream, zlib_filefunc64_def *filefunc); + +void *mz_stream_ioapi_create(void); +void mz_stream_ioapi_delete(void **stream); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/SSZipArchive/minizip/compat/unzip.c b/SSZipArchive/minizip/compat/unzip.c new file mode 100644 index 0000000..3d49c0c --- /dev/null +++ b/SSZipArchive/minizip/compat/unzip.c @@ -0,0 +1,742 @@ +/* zip.c -- Backwards compatible unzip interface + part of the minizip-ng project + + Copyright (C) Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. + + WARNING: Be very careful updating/overwriting this file. + It has specific changes for ZipArchive support, notably removing tmu_date. +*/ + +#include "mz.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_os.h" +#include "mz_zip.h" + +#include /* SEEK */ + +#include "unzip.h" + +/***************************************************************************/ + +typedef struct mz_unzip_compat_s { + void *stream; + void *handle; + uint64_t entry_index; + int64_t entry_pos; + int64_t total_out; +} mz_unzip_compat; + +/***************************************************************************/ + +unzFile unzOpen(const char *path) { + return unzOpen64(path); +} + +unzFile unzOpen64(const void *path) { + return unzOpen2(path, NULL); +} + +unzFile unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def) { + unzFile unz = NULL; + void *stream = NULL; + + if (pzlib_filefunc_def) { + if (pzlib_filefunc_def->zopen_file) { + stream = mz_stream_ioapi_create(); + if (!stream) + return NULL; + mz_stream_ioapi_set_filefunc(stream, pzlib_filefunc_def); + } else if (pzlib_filefunc_def->opaque) { + stream = mz_stream_create((mz_stream_vtbl *)pzlib_filefunc_def->opaque); + if (!stream) + return NULL; + } + } + + if (!stream) { + stream = mz_stream_os_create(); + if (!stream) + return NULL; + } + + if (mz_stream_open(stream, path, MZ_OPEN_MODE_READ) != MZ_OK) { + mz_stream_delete(&stream); + return NULL; + } + + unz = unzOpen_MZ(stream); + if (!unz) { + mz_stream_close(stream); + mz_stream_delete(&stream); + return NULL; + } + return unz; +} + +unzFile unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def) { + unzFile unz = NULL; + void *stream = NULL; + + if (pzlib_filefunc_def) { + if (pzlib_filefunc_def->zopen64_file) { + stream = mz_stream_ioapi_create(); + if (!stream) + return NULL; + mz_stream_ioapi_set_filefunc64(stream, pzlib_filefunc_def); + } else if (pzlib_filefunc_def->opaque) { + stream = mz_stream_create((mz_stream_vtbl *)pzlib_filefunc_def->opaque); + if (!stream) + return NULL; + } + } + + if (!stream) { + stream = mz_stream_os_create(); + if (!stream) + return NULL; + } + + if (mz_stream_open(stream, path, MZ_OPEN_MODE_READ) != MZ_OK) { + mz_stream_delete(&stream); + return NULL; + } + + unz = unzOpen_MZ(stream); + if (!unz) { + mz_stream_close(stream); + mz_stream_delete(&stream); + return NULL; + } + return unz; +} + +void *unzGetHandle_MZ(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + if (!compat) + return NULL; + return compat->handle; +} + +void *unzGetStream_MZ(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + if (!compat) + return NULL; + return compat->stream; +} + +unzFile unzOpen_MZ(void *stream) { + mz_unzip_compat *compat = NULL; + int32_t err = MZ_OK; + void *handle = NULL; + + handle = mz_zip_create(); + if (!handle) + return NULL; + + err = mz_zip_open(handle, stream, MZ_OPEN_MODE_READ); + if (err != MZ_OK) { + mz_zip_delete(&handle); + return NULL; + } + + compat = (mz_unzip_compat *)calloc(1, sizeof(mz_unzip_compat)); + if (compat) { + compat->handle = handle; + compat->stream = stream; + + mz_zip_goto_first_entry(compat->handle); + } else { + mz_zip_delete(&handle); + } + + return (unzFile)compat; +} + +int unzClose(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + int32_t err = MZ_OK; + + if (!compat) + return UNZ_PARAMERROR; + + if (compat->handle) + err = unzClose_MZ(file); + + if (compat->stream) { + mz_stream_close(compat->stream); + mz_stream_delete(&compat->stream); + } + + free(compat); + + return err; +} + +/* Only closes the zip handle, does not close the stream */ +int unzClose_MZ(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + int32_t err = MZ_OK; + + if (!compat) + return UNZ_PARAMERROR; + + err = mz_zip_close(compat->handle); + mz_zip_delete(&compat->handle); + + return err; +} + +int unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info32) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + unz_global_info64 global_info64; + int32_t err = MZ_OK; + + memset(pglobal_info32, 0, sizeof(unz_global_info)); + if (!compat) + return UNZ_PARAMERROR; + + err = unzGetGlobalInfo64(file, &global_info64); + if (err == MZ_OK) { + pglobal_info32->number_entry = (uint32_t)global_info64.number_entry; + pglobal_info32->size_comment = global_info64.size_comment; + pglobal_info32->number_disk_with_CD = global_info64.number_disk_with_CD; + } + return err; +} + +int unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + const char *comment_ptr = NULL; + int32_t err = MZ_OK; + + memset(pglobal_info, 0, sizeof(unz_global_info64)); + if (!compat) + return UNZ_PARAMERROR; + err = mz_zip_get_comment(compat->handle, &comment_ptr); + if (err == MZ_OK) + pglobal_info->size_comment = (uint16_t)strlen(comment_ptr); + if ((err == MZ_OK) || (err == MZ_EXIST_ERROR)) + err = mz_zip_get_number_entry(compat->handle, &pglobal_info->number_entry); + if (err == MZ_OK) + err = mz_zip_get_disk_number_with_cd(compat->handle, &pglobal_info->number_disk_with_CD); + return err; +} + +int unzGetGlobalComment(unzFile file, char *comment, unsigned long comment_size) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + const char *comment_ptr = NULL; + int32_t err = MZ_OK; + + if (!comment || !comment_size) + return UNZ_PARAMERROR; + err = mz_zip_get_comment(compat->handle, &comment_ptr); + if (err == MZ_OK) { + strncpy(comment, comment_ptr, comment_size - 1); + comment[comment_size - 1] = 0; + } + return err; +} + +int unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + mz_zip_file *file_info = NULL; + int32_t err = MZ_OK; + void *stream = NULL; + + if (!compat) + return UNZ_PARAMERROR; + if (method) + *method = 0; + if (level) + *level = 0; + + if (mz_zip_entry_is_open(compat->handle) == MZ_OK) { + /* zlib minizip does not error out here if close returns errors */ + unzCloseCurrentFile(file); + } + + compat->total_out = 0; + err = mz_zip_entry_read_open(compat->handle, (uint8_t)raw, password); + if (err == MZ_OK) + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err == MZ_OK) { + if (method) { + *method = file_info->compression_method; + } + + if (level) { + *level = 6; + switch (file_info->flag & 0x06) { + case MZ_ZIP_FLAG_DEFLATE_SUPER_FAST: + *level = 1; + break; + case MZ_ZIP_FLAG_DEFLATE_FAST: + *level = 2; + break; + case MZ_ZIP_FLAG_DEFLATE_MAX: + *level = 9; + break; + } + } + } + if (err == MZ_OK) + err = mz_zip_get_stream(compat->handle, &stream); + if (err == MZ_OK) + compat->entry_pos = mz_stream_tell(stream); + return err; +} + +int unzOpenCurrentFile(unzFile file) { + return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); +} + +int unzOpenCurrentFilePassword(unzFile file, const char *password) { + return unzOpenCurrentFile3(file, NULL, NULL, 0, password); +} + +int unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw) { + return unzOpenCurrentFile3(file, method, level, raw, NULL); +} + +int unzReadCurrentFile(unzFile file, void *buf, uint32_t len) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + int32_t err = MZ_OK; + if (!compat || len >= INT32_MAX) + return UNZ_PARAMERROR; + err = mz_zip_entry_read(compat->handle, buf, (int32_t)len); + if (err > 0) + compat->total_out += (uint32_t)err; + return err; +} + +int unzCloseCurrentFile(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + int32_t err = MZ_OK; + if (!compat) + return UNZ_PARAMERROR; + err = mz_zip_entry_close(compat->handle); + return err; +} + +// [ZipArchive] disabled for performances: we don't need the tmu_date field because we already set the mz_dos_date field: +// https://github.com/madler/zlib/blob/643e17b7498d12ab8d15565662880579692f769d/contrib/minizip/zip.h#L102 +//static void unzConvertTimeToUnzTime(time_t time, tm_unz *tmu_date) { +// struct tm tm_date; +// memset(&tm_date, 0, sizeof(struct tm)); +// mz_zip_time_t_to_tm(time, &tm_date); +// memcpy(tmu_date, &tm_date, sizeof(tm_unz)); +// tmu_date->tm_year += 1900; +//} + +int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename, unsigned long filename_size, + void *extrafield, unsigned long extrafield_size, char *comment, unsigned long comment_size) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + mz_zip_file *file_info = NULL; + uint16_t bytes_to_copy = 0; + int32_t err = MZ_OK; + + if (!compat) + return UNZ_PARAMERROR; + + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + return err; + + if (pfile_info) { + pfile_info->version = file_info->version_madeby; + pfile_info->version_needed = file_info->version_needed; + pfile_info->flag = file_info->flag; + pfile_info->compression_method = file_info->compression_method; + pfile_info->mz_dos_date = mz_zip_time_t_to_dos_date(file_info->modified_date); + // [ZipArchive] disabled for performances: we don't need the tmu_date field because we already set the mz_dos_date field + // unzConvertTimeToUnzTime(file_info->modified_date, &pfile_info->tmu_date); + pfile_info->crc = file_info->crc; + + pfile_info->size_filename = file_info->filename_size; + pfile_info->size_file_extra = file_info->extrafield_size; + pfile_info->size_file_comment = file_info->comment_size; + + pfile_info->disk_num_start = (uint16_t)file_info->disk_number; + pfile_info->internal_fa = file_info->internal_fa; + pfile_info->external_fa = file_info->external_fa; + + pfile_info->compressed_size = (uint32_t)file_info->compressed_size; + pfile_info->uncompressed_size = (uint32_t)file_info->uncompressed_size; + } + if (filename_size > 0 && filename && file_info->filename) { + bytes_to_copy = (uint16_t)filename_size; + if (bytes_to_copy > file_info->filename_size) + bytes_to_copy = file_info->filename_size; + memcpy(filename, file_info->filename, bytes_to_copy); + if (bytes_to_copy < filename_size) + filename[bytes_to_copy] = 0; + } + if (extrafield_size > 0 && extrafield) { + bytes_to_copy = (uint16_t)extrafield_size; + if (bytes_to_copy > file_info->extrafield_size) + bytes_to_copy = file_info->extrafield_size; + memcpy(extrafield, file_info->extrafield, bytes_to_copy); + } + if (comment_size > 0 && comment && file_info->comment) { + bytes_to_copy = (uint16_t)comment_size; + if (bytes_to_copy > file_info->comment_size) + bytes_to_copy = file_info->comment_size; + memcpy(comment, file_info->comment, bytes_to_copy); + if (bytes_to_copy < comment_size) + comment[bytes_to_copy] = 0; + } + return err; +} + +int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *filename, unsigned long filename_size, + void *extrafield, unsigned long extrafield_size, char *comment, + unsigned long comment_size) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + mz_zip_file *file_info = NULL; + uint16_t bytes_to_copy = 0; + int32_t err = MZ_OK; + + if (!compat) + return UNZ_PARAMERROR; + + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + return err; + + if (pfile_info) { + pfile_info->version = file_info->version_madeby; + pfile_info->version_needed = file_info->version_needed; + pfile_info->flag = file_info->flag; + pfile_info->compression_method = file_info->compression_method; + pfile_info->mz_dos_date = mz_zip_time_t_to_dos_date(file_info->modified_date); + // [ZipArchive] disabled for performances: we don't need the tmu_date field because we already set the mz_dos_date field + // unzConvertTimeToUnzTime(file_info->modified_date, &pfile_info->tmu_date); + pfile_info->crc = file_info->crc; + + pfile_info->size_filename = file_info->filename_size; + pfile_info->size_file_extra = file_info->extrafield_size; + pfile_info->size_file_comment = file_info->comment_size; + + pfile_info->disk_num_start = file_info->disk_number; + pfile_info->internal_fa = file_info->internal_fa; + pfile_info->external_fa = file_info->external_fa; + + pfile_info->compressed_size = (uint64_t)file_info->compressed_size; + pfile_info->uncompressed_size = (uint64_t)file_info->uncompressed_size; + } + if (filename_size > 0 && filename && file_info->filename) { + bytes_to_copy = (uint16_t)filename_size; + if (bytes_to_copy > file_info->filename_size) + bytes_to_copy = file_info->filename_size; + memcpy(filename, file_info->filename, bytes_to_copy); + if (bytes_to_copy < filename_size) + filename[bytes_to_copy] = 0; + } + if (extrafield_size > 0 && extrafield) { + bytes_to_copy = (uint16_t)extrafield_size; + if (bytes_to_copy > file_info->extrafield_size) + bytes_to_copy = file_info->extrafield_size; + memcpy(extrafield, file_info->extrafield, bytes_to_copy); + } + if (comment_size > 0 && comment && file_info->comment) { + bytes_to_copy = (uint16_t)comment_size; + if (bytes_to_copy > file_info->comment_size) + bytes_to_copy = file_info->comment_size; + memcpy(comment, file_info->comment, bytes_to_copy); + if (bytes_to_copy < comment_size) + comment[bytes_to_copy] = 0; + } + return err; +} + +int unzGoToFirstFile(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + if (!compat) + return UNZ_PARAMERROR; + compat->entry_index = 0; + return mz_zip_goto_first_entry(compat->handle); +} + +int unzGoToNextFile(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + int32_t err = MZ_OK; + if (!compat) + return UNZ_PARAMERROR; + err = mz_zip_goto_next_entry(compat->handle); + if (err != MZ_END_OF_LIST) + compat->entry_index += 1; + return err; +} + +#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION < 110 +# ifdef WIN32 +# define UNZ_DEFAULT_IGNORE_CASE 1 +# else +# define UNZ_DEFAULT_IGNORE_CASE 0 +# endif + +int unzLocateFile(unzFile file, const char *filename, unzFileNameCase filename_case) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + mz_zip_file *file_info = NULL; + uint64_t preserve_index = 0; + int32_t err = MZ_OK; + int32_t result = 0; + uint8_t ignore_case = UNZ_DEFAULT_IGNORE_CASE; + + if (!compat) + return UNZ_PARAMERROR; + + if (filename_case == 1) { + ignore_case = 0; + } else if (filename_case > 1) { + ignore_case = 1; + } + + preserve_index = compat->entry_index; + + err = mz_zip_goto_first_entry(compat->handle); + while (err == MZ_OK) { + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + break; + + result = mz_path_compare_wc(filename, file_info->filename, !ignore_case); + + if (result == 0) + return MZ_OK; + + err = mz_zip_goto_next_entry(compat->handle); + } + + compat->entry_index = preserve_index; + return err; +} +#else +int unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + mz_zip_file *file_info = NULL; + uint64_t preserve_index = 0; + int32_t err = MZ_OK; + int32_t result = 0; + + if (!compat) + return UNZ_PARAMERROR; + + preserve_index = compat->entry_index; + + err = mz_zip_goto_first_entry(compat->handle); + while (err == MZ_OK) { + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + break; + + if ((intptr_t)filename_compare_func > 2) { + result = filename_compare_func(file, filename, file_info->filename); + } else { + int32_t case_sensitive = (int32_t)(intptr_t)filename_compare_func; + result = mz_path_compare_wc(filename, file_info->filename, !case_sensitive); + } + + if (result == 0) + return MZ_OK; + + err = mz_zip_goto_next_entry(compat->handle); + } + + compat->entry_index = preserve_index; + return err; +} +#endif + +/***************************************************************************/ + +int unzGetFilePos(unzFile file, unz_file_pos *file_pos) { + unz64_file_pos file_pos64; + int32_t err = 0; + + err = unzGetFilePos64(file, &file_pos64); + if (err < 0) + return err; + + file_pos->pos_in_zip_directory = (uint32_t)file_pos64.pos_in_zip_directory; + file_pos->num_of_file = (uint32_t)file_pos64.num_of_file; + return err; +} + +int unzGoToFilePos(unzFile file, unz_file_pos *file_pos) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + unz64_file_pos file_pos64; + + if (!compat || !file_pos) + return UNZ_PARAMERROR; + + file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; + file_pos64.num_of_file = file_pos->num_of_file; + + return unzGoToFilePos64(file, &file_pos64); +} + +int unzGetFilePos64(unzFile file, unz64_file_pos *file_pos) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + int64_t offset = 0; + + if (!compat || !file_pos) + return UNZ_PARAMERROR; + + offset = unzGetOffset64(file); + if (offset < 0) + return (int)offset; + + file_pos->pos_in_zip_directory = offset; + file_pos->num_of_file = compat->entry_index; + return UNZ_OK; +} + +int unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + int32_t err = MZ_OK; + + if (!compat || !file_pos) + return UNZ_PARAMERROR; + + err = mz_zip_goto_entry(compat->handle, file_pos->pos_in_zip_directory); + if (err == MZ_OK) + compat->entry_index = file_pos->num_of_file; + return err; +} + +unsigned long unzGetOffset(unzFile file) { + return (uint32_t)unzGetOffset64(file); +} + +int64_t unzGetOffset64(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + if (!compat) + return UNZ_PARAMERROR; + return mz_zip_get_entry(compat->handle); +} + +int unzSetOffset(unzFile file, unsigned long pos) { + return unzSetOffset64(file, pos); +} + +int unzSetOffset64(unzFile file, int64_t pos) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + if (!compat) + return UNZ_PARAMERROR; + return (int)mz_zip_goto_entry(compat->handle, pos); +} + +int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + mz_zip_file *file_info = NULL; + int32_t err = MZ_OK; + int32_t bytes_to_copy = 0; + + if (!compat || !buf || len >= INT32_MAX) + return UNZ_PARAMERROR; + + err = mz_zip_entry_get_local_info(compat->handle, &file_info); + if (err != MZ_OK) + return err; + + bytes_to_copy = (int32_t)len; + if (bytes_to_copy > file_info->extrafield_size) + bytes_to_copy = file_info->extrafield_size; + + memcpy(buf, file_info->extrafield, bytes_to_copy); + return MZ_OK; +} + +int32_t unzTell(unzFile file) { + return unztell(file); +} + +int32_t unztell(unzFile file) { + return (int32_t)unztell64(file); +} + +uint64_t unzTell64(unzFile file) { + return unztell64(file); +} + +uint64_t unztell64(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + if (!compat) + return UNZ_PARAMERROR; + return compat->total_out; +} + +int unzSeek(unzFile file, int32_t offset, int origin) { + return unzSeek64(file, offset, origin); +} + +int unzSeek64(unzFile file, int64_t offset, int origin) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + mz_zip_file *file_info = NULL; + int64_t position = 0; + int32_t err = MZ_OK; + void *stream = NULL; + + if (!compat) + return UNZ_PARAMERROR; + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + return err; + if (file_info->compression_method != MZ_COMPRESS_METHOD_STORE) + return UNZ_ERRNO; + + if (origin == SEEK_SET) + position = offset; + else if (origin == SEEK_CUR) + position = compat->total_out + offset; + else if (origin == SEEK_END) + position = (int64_t)file_info->compressed_size + offset; + else + return UNZ_PARAMERROR; + + if (position > (int64_t)file_info->compressed_size) + return UNZ_PARAMERROR; + + err = mz_zip_get_stream(compat->handle, &stream); + if (err == MZ_OK) + err = mz_stream_seek(stream, compat->entry_pos + position, MZ_SEEK_SET); + if (err == MZ_OK) + compat->total_out = position; + return err; +} + +int unzEndOfFile(unzFile file) { + return unzeof(file); +} + +int unzeof(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + mz_zip_file *file_info = NULL; + int32_t err = MZ_OK; + + if (!compat) + return UNZ_PARAMERROR; + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + return err; + if (compat->total_out == (int64_t)file_info->uncompressed_size) + return 1; + return 0; +} + +void *unzGetStream(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + if (!compat) + return NULL; + return (void *)compat->stream; +} + +/***************************************************************************/ diff --git a/SSZipArchive/minizip/compat/unzip.h b/SSZipArchive/minizip/compat/unzip.h new file mode 100644 index 0000000..3dc9669 --- /dev/null +++ b/SSZipArchive/minizip/compat/unzip.h @@ -0,0 +1,228 @@ +/* unzip.h -- Backwards compatible unzip interface + part of the minizip-ng project + + Copyright (C) Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. + + WARNING: Be very careful updating/overwriting this file. + It has specific changes for ZipArchive support with some structs moved to SSZipCommon for public access. +*/ + +#ifndef _unz64_H +#define _unz64_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../../SSZipCommon.h" + +#include + +#if !defined(_ZLIB_H) && !defined(ZLIB_H) && !defined(ZLIB_H_) +# if __has_include() +# include +# elif __has_include() +# include +# endif +#endif + +#ifndef _ZLIBIOAPI_H +# include "ioapi.h" +#endif + +#if !defined(_ZLIB_H) && !defined(ZLIB_H) && !defined(ZLIB_H_) +# if __has_include() +# include +# elif __has_include() +# include +# endif +#endif + +#ifndef _ZLIBIOAPI_H +# include "ioapi.h" +#endif + +/***************************************************************************/ + +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagunzFile__ { + int unused; +} unzFile__; +typedef unzFile__ *unzFile; +#else +typedef void *unzFile; +#endif + +/***************************************************************************/ + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (Z_ERRNO) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) +#define UNZ_BADPASSWORD (-106) /* minizip-ng */ + +/***************************************************************************/ +/* tm_unz contain date/time info */ +typedef struct tm_unz_s { + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years - [1980..2044] */ +} tm_unz; + +/***************************************************************************/ + +// ZipArchive 2.x+ uses dos_date +#define MZ_COMPAT_VERSION 120 + +#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION <= 110 +# define mz_dos_date dosDate +#else +# define mz_dos_date dos_date +#endif + +/* Global data about the zip from end of central dir */ +typedef struct unz_global_info64_s { + uint64_t number_entry; /* total number of entries in the central dir on this disk */ + unsigned long size_comment; /* size of the global comment of the zipfile */ + /* minizip-ng fields */ + uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */ +} unz_global_info64; + +/* Information about a file in the zip */ +typedef struct unz_file_info64_s { + unsigned long version; /* version made by 2 bytes */ + unsigned long version_needed; /* version needed to extract 2 bytes */ + unsigned long flag; /* general purpose bit flag 2 bytes */ + unsigned long compression_method; /* compression method 2 bytes */ + unsigned long mz_dos_date; /* last mod file date in Dos fmt 4 bytes */ + unsigned long crc; /* crc-32 4 bytes */ + ZPOS64_T compressed_size; /* compressed size 8 bytes */ + ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */ + unsigned long size_filename; /* filename length 2 bytes */ + unsigned long size_file_extra; /* extra field length 2 bytes */ + unsigned long size_file_comment; /* file comment length 2 bytes */ + + unsigned long disk_num_start; /* disk number start 4 bytes */ + unsigned long internal_fa; /* internal file attributes 2 bytes */ + unsigned long external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; + + /* minizip-ng fields */ + ZPOS64_T disk_offset; + uint16_t size_file_extra_internal; +} unz_file_info64; + +/***************************************************************************/ + +#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION < 110 +/* Possible values: + 0 - Uses OS default, e.g. Windows ignores case. + 1 - Is case sensitive. + >= 2 - Ignore case. +*/ +typedef int unzFileNameCase; +#else +typedef int (*unzFileNameComparer)(unzFile file, const char *filename1, const char *filename2); +#endif +typedef int (*unzIteratorFunction)(unzFile file); +typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename, uint16_t filename_size, + void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size); + +/***************************************************************************/ +/* Reading a zip file */ + +/* Compatibility layer with the original minizip library (unzip.h). */ +ZEXPORT unzFile unzOpen(const char *path); +ZEXPORT unzFile unzOpen64(const void *path); +ZEXPORT unzFile unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def); +ZEXPORT unzFile unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def); +ZEXPORT int unzClose(unzFile file); + +ZEXPORT int unzGetGlobalInfo(unzFile file, unz_global_info *pglobal_info32); +ZEXPORT int unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info); +ZEXPORT int unzGetGlobalComment(unzFile file, char *comment, unsigned long comment_size); +ZEXPORT int unzOpenCurrentFile(unzFile file); +ZEXPORT int unzOpenCurrentFilePassword(unzFile file, const char *password); +ZEXPORT int unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw); +ZEXPORT int unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password); +ZEXPORT int unzReadCurrentFile(unzFile file, void *buf, uint32_t len); +ZEXPORT int unzCloseCurrentFile(unzFile file); +ZEXPORT int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename, unsigned long filename_size, + void *extrafield, unsigned long extrafield_size, char *comment, + unsigned long comment_size); +ZEXPORT int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 *pfile_info, char *filename, + unsigned long filename_size, void *extrafield, unsigned long extrafield_size, + char *comment, unsigned long comment_size); +ZEXPORT int unzGoToFirstFile(unzFile file); +ZEXPORT int unzGoToNextFile(unzFile file); +#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION < 110 +ZEXPORT int unzLocateFile(unzFile file, const char *filename, unzFileNameCase filename_case); +#else +ZEXPORT int unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func); +#endif +/* unzStringFileNameCompare is too new */ +ZEXPORT int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len); + +/* Compatibility layer with older minizip-ng (mz_unzip.h). */ +unzFile unzOpen_MZ(void *stream); +ZEXPORT int unzClose_MZ(unzFile file); +ZEXPORT void *unzGetHandle_MZ(unzFile file); +ZEXPORT void *unzGetStream_MZ(unzFile file); + +/***************************************************************************/ +/* Raw access to zip file */ + +typedef struct unz_file_pos_s { + uint32_t pos_in_zip_directory; /* offset in zip file directory */ + uint32_t num_of_file; /* # of file */ +} unz_file_pos; + +typedef struct unz64_file_pos_s { + int64_t pos_in_zip_directory; /* offset in zip file directory */ + uint64_t num_of_file; /* # of file */ +} unz64_file_pos; + +/* Compatibility layer with the original minizip library (unzip.h). */ +ZEXPORT int unzGetFilePos(unzFile file, unz_file_pos *file_pos); +ZEXPORT int unzGoToFilePos(unzFile file, unz_file_pos *file_pos); +ZEXPORT int unzGetFilePos64(unzFile file, unz64_file_pos *file_pos); +ZEXPORT int unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos); +ZEXPORT int64_t unzGetOffset64(unzFile file); +ZEXPORT unsigned long unzGetOffset(unzFile file); +ZEXPORT int unzSetOffset64(unzFile file, int64_t pos); +ZEXPORT int unzSetOffset(unzFile file, unsigned long pos); +ZEXPORT int32_t unztell(unzFile file); +ZEXPORT uint64_t unztell64(unzFile file); +ZEXPORT int unzeof(unzFile file); + +/* Compatibility layer with older minizip-ng (mz_unzip.h). */ +ZEXPORT int32_t unzTell(unzFile file); +ZEXPORT uint64_t unzTell64(unzFile file); +ZEXPORT int unzSeek(unzFile file, int32_t offset, int origin); +ZEXPORT int unzSeek64(unzFile file, int64_t offset, int origin); +ZEXPORT int unzEndOfFile(unzFile file); +ZEXPORT void *unzGetStream(unzFile file); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif /* _unz64_H */ diff --git a/SSZipArchive/minizip/compat/zip.c b/SSZipArchive/minizip/compat/zip.c new file mode 100644 index 0000000..1c78d50 --- /dev/null +++ b/SSZipArchive/minizip/compat/zip.c @@ -0,0 +1,409 @@ +/* zip.c -- Backwards compatible zip interface + part of the minizip-ng project + + Copyright (C) Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#include "mz.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_os.h" +#include "mz_zip.h" + +#include "zip.h" + +/***************************************************************************/ + +typedef struct mz_zip_compat_s { + void *stream; + void *handle; +} mz_zip_compat; + +/***************************************************************************/ + +static int32_t zipConvertAppendToStreamMode(int append) { + int32_t mode = MZ_OPEN_MODE_WRITE; + switch (append) { + case APPEND_STATUS_CREATE: + mode |= MZ_OPEN_MODE_CREATE; + break; + case APPEND_STATUS_CREATEAFTER: + mode |= MZ_OPEN_MODE_CREATE | MZ_OPEN_MODE_APPEND; + break; + case APPEND_STATUS_ADDINZIP: + mode |= MZ_OPEN_MODE_READ | MZ_OPEN_MODE_APPEND; + break; + } + return mode; +} + +zipFile zipOpen(const char *path, int append) { + return zipOpen2(path, append, NULL, NULL); +} + +zipFile zipOpen64(const void *path, int append) { + return zipOpen2(path, append, NULL, NULL); +} + +zipFile zipOpen2(const char *path, int append, zipcharpc *globalcomment, zlib_filefunc_def *pzlib_filefunc_def) { + zipFile zip = NULL; + int32_t mode = zipConvertAppendToStreamMode(append); + void *stream = NULL; + + if (pzlib_filefunc_def) { + if (pzlib_filefunc_def->zopen_file) { + stream = mz_stream_ioapi_create(); + if (!stream) + return NULL; + mz_stream_ioapi_set_filefunc(stream, pzlib_filefunc_def); + } else if (pzlib_filefunc_def->opaque) { + stream = mz_stream_create((mz_stream_vtbl *)pzlib_filefunc_def->opaque); + if (!stream) + return NULL; + } + } + + if (!stream) { + stream = mz_stream_os_create(); + if (!stream) + return NULL; + } + + if (mz_stream_open(stream, path, mode) != MZ_OK) { + mz_stream_delete(&stream); + return NULL; + } + + zip = zipOpen_MZ(stream, append, globalcomment); + + if (!zip) { + mz_stream_delete(&stream); + return NULL; + } + + return zip; +} + +zipFile zipOpen2_64(const void *path, int append, zipcharpc *globalcomment, zlib_filefunc64_def *pzlib_filefunc_def) { + zipFile zip = NULL; + int32_t mode = zipConvertAppendToStreamMode(append); + void *stream = NULL; + + if (pzlib_filefunc_def) { + if (pzlib_filefunc_def->zopen64_file) { + stream = mz_stream_ioapi_create(); + if (!stream) + return NULL; + mz_stream_ioapi_set_filefunc64(stream, pzlib_filefunc_def); + } else if (pzlib_filefunc_def->opaque) { + stream = mz_stream_create((mz_stream_vtbl *)pzlib_filefunc_def->opaque); + if (!stream) + return NULL; + } + } + + if (!stream) { + stream = mz_stream_os_create(); + if (!stream) + return NULL; + } + + if (mz_stream_open(stream, path, mode) != MZ_OK) { + mz_stream_delete(&stream); + return NULL; + } + + zip = zipOpen_MZ(stream, append, globalcomment); + + if (!zip) { + mz_stream_delete(&stream); + return NULL; + } + + return zip; +} + +zipFile zipOpen_MZ(void *stream, int append, zipcharpc *globalcomment) { + mz_zip_compat *compat = NULL; + int32_t err = MZ_OK; + int32_t mode = zipConvertAppendToStreamMode(append); + void *handle = NULL; + + handle = mz_zip_create(); + if (!handle) + return NULL; + + err = mz_zip_open(handle, stream, mode); + + if (err != MZ_OK) { + mz_zip_delete(&handle); + return NULL; + } + + if (globalcomment) + mz_zip_get_comment(handle, globalcomment); + + compat = (mz_zip_compat *)calloc(1, sizeof(mz_zip_compat)); + if (compat) { + compat->handle = handle; + compat->stream = stream; + } else { + mz_zip_delete(&handle); + } + + return (zipFile)compat; +} + +void *zipGetHandle_MZ(zipFile file) { + mz_zip_compat *compat = (mz_zip_compat *)file; + if (!compat) + return NULL; + return compat->handle; +} + +void *zipGetStream_MZ(zipFile file) { + mz_zip_compat *compat = (mz_zip_compat *)file; + if (!compat) + return NULL; + return (void *)compat->stream; +} + +static time_t zipConvertZipDateToTime(tm_zip tmz_date) { + struct tm tm_date; + memset(&tm_date, 0, sizeof(struct tm)); + memcpy(&tm_date, &tmz_date, sizeof(tm_zip)); + tm_date.tm_year -= 1900; + tm_date.tm_isdst = -1; + return mz_zip_tm_to_time_t(&tm_date); +} + +int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, + const char *comment, int compression_method, int level, int raw, int windowBits, int memLevel, + int strategy, const char *password, unsigned long crc_for_crypting, + unsigned long version_madeby, unsigned long flag_base, int zip64) { + mz_zip_compat *compat = (mz_zip_compat *)file; + mz_zip_file file_info; + + MZ_UNUSED(strategy); + MZ_UNUSED(memLevel); + MZ_UNUSED(windowBits); + MZ_UNUSED(size_extrafield_local); + MZ_UNUSED(extrafield_local); + MZ_UNUSED(crc_for_crypting); + + if (!compat) + return ZIP_PARAMERROR; + + /* The filename and comment length must fit in 16 bits. */ + if (filename && strlen(filename) > 0xffff) + return ZIP_PARAMERROR; + if (comment && strlen(comment) > 0xffff) + return ZIP_PARAMERROR; + + memset(&file_info, 0, sizeof(file_info)); + + if (zipfi) { + if (zipfi->mz_dos_date != 0) + file_info.modified_date = mz_zip_dosdate_to_time_t(zipfi->mz_dos_date); + else + file_info.modified_date = zipConvertZipDateToTime(zipfi->tmz_date); + + file_info.external_fa = (uint32_t)zipfi->external_fa; + file_info.internal_fa = (uint16_t)zipfi->internal_fa; + } + + if (!filename) + filename = "-"; + + file_info.compression_method = (uint16_t)compression_method; + file_info.filename = filename; + /* file_info.extrafield_local = extrafield_local; */ + /* file_info.extrafield_local_size = size_extrafield_local; */ + file_info.extrafield = extrafield_global; + file_info.extrafield_size = size_extrafield_global; + file_info.version_madeby = (uint16_t)version_madeby; + file_info.comment = comment; + if (file_info.comment) + file_info.comment_size = (uint16_t)strlen(file_info.comment); + file_info.flag = (uint16_t)flag_base; + if (zip64) + file_info.zip64 = MZ_ZIP64_FORCE; + else + file_info.zip64 = MZ_ZIP64_DISABLE; +#ifdef HAVE_WZAES + if (password || (raw && (file_info.flag & MZ_ZIP_FLAG_ENCRYPTED))) + file_info.aes_version = MZ_AES_VERSION; +#endif + + return mz_zip_entry_write_open(compat->handle, &file_info, (int16_t)level, (uint8_t)raw, password); +} + +int zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, + uint16_t size_extrafield_global, const char *comment, int compression_method, int level, + int raw, int windowBits, int memLevel, int strategy, const char *password, + unsigned long crc_for_crypting, unsigned long version_madeby, unsigned long flag_base, + int zip64) { + return zipOpenNewFileInZip5(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, raw, windowBits, memLevel, + strategy, password, crc_for_crypting, version_madeby, flag_base, zip64); +} + +int zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, + const char *comment, int compression_method, int level, int raw, int windowBits, int memLevel, + int strategy, const char *password, unsigned long crc_for_crypting, + unsigned long version_madeby, unsigned long flag_base) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, raw, windowBits, + memLevel, strategy, password, crc_for_crypting, version_madeby, flag_base, 0); +} + +int zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, + const char *comment, int compression_method, int level, int raw, int windowBits, int memLevel, + int strategy, const char *password, unsigned long crc_for_crypting) { + return zipOpenNewFileInZip3_64(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, raw, windowBits, + memLevel, strategy, password, crc_for_crypting, 0); +} + +int zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, + uint16_t size_extrafield_global, const char *comment, int compression_method, int level, + int raw, int windowBits, int memLevel, int strategy, const char *password, + unsigned long crc_for_crypting, int zip64) { + return zipOpenNewFileInZip4_64(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, raw, windowBits, + memLevel, strategy, password, crc_for_crypting, MZ_VERSION_MADEBY, 0, zip64); +} + +int zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, + const char *comment, int compression_method, int level, int raw) { + return zipOpenNewFileInZip3_64(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, raw, 0, 0, 0, NULL, 0, + 0); +} + +int zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, + uint16_t size_extrafield_global, const char *comment, int compression_method, int level, + int raw, int zip64) { + return zipOpenNewFileInZip3_64(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, raw, 0, 0, 0, NULL, 0, + zip64); +} + +int zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, + const char *comment, int compression_method, int level) { + return zipOpenNewFileInZip_64(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, 0); +} + +int zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, + uint16_t size_extrafield_global, const char *comment, int compression_method, int level, + int zip64) { + return zipOpenNewFileInZip2_64(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, 0, zip64); +} + +int zipOpenNewFileInZip_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, + uint16_t size_extrafield_local, const void *extrafield_global, + uint16_t size_extrafield_global, const char *comment, int compression_method, int level, + int zip64) { + return zipOpenNewFileInZip2_64(file, filename, zipfi, extrafield_local, size_extrafield_local, extrafield_global, + size_extrafield_global, comment, compression_method, level, 0, zip64); +} + +int zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len) { + mz_zip_compat *compat = (mz_zip_compat *)file; + int32_t written = 0; + if (!compat || len >= INT32_MAX) + return ZIP_PARAMERROR; + written = mz_zip_entry_write(compat->handle, buf, (int32_t)len); + if ((written < 0) || ((uint32_t)written != len)) + return ZIP_ERRNO; + return ZIP_OK; +} + +int zipCloseFileInZipRaw(zipFile file, unsigned long uncompressed_size, unsigned long crc32) { + return zipCloseFileInZipRaw64(file, uncompressed_size, crc32); +} + +int zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, unsigned long crc32) { + mz_zip_compat *compat = (mz_zip_compat *)file; + if (!compat) + return ZIP_PARAMERROR; + return mz_zip_entry_close_raw(compat->handle, (int64_t)uncompressed_size, (uint32_t)crc32); +} + +int zipCloseFileInZip(zipFile file) { + return zipCloseFileInZip64(file); +} + +int zipCloseFileInZip64(zipFile file) { + mz_zip_compat *compat = (mz_zip_compat *)file; + if (!compat) + return ZIP_PARAMERROR; + return mz_zip_entry_close(compat->handle); +} + +int zipClose(zipFile file, const char *global_comment) { + return zipClose_64(file, global_comment); +} + +int zipClose_64(zipFile file, const char *global_comment) { + return zipClose2_64(file, global_comment, MZ_VERSION_MADEBY); +} + +int zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby) { + mz_zip_compat *compat = (mz_zip_compat *)file; + int32_t err = MZ_OK; + + if (compat->handle) + err = zipClose2_MZ(file, global_comment, version_madeby); + + if (compat->stream) { + mz_stream_close(compat->stream); + mz_stream_delete(&compat->stream); + } + + free(compat); + + return err; +} + +/* Only closes the zip handle, does not close the stream */ +int zipClose_MZ(zipFile file, const char *global_comment) { + return zipClose2_MZ(file, global_comment, MZ_VERSION_MADEBY); +} + +/* Only closes the zip handle, does not close the stream */ +int zipClose2_MZ(zipFile file, const char *global_comment, uint16_t version_madeby) { + mz_zip_compat *compat = (mz_zip_compat *)file; + int32_t err = MZ_OK; + + if (!compat) + return ZIP_PARAMERROR; + if (!compat->handle) + return err; + + if (global_comment) + mz_zip_set_comment(compat->handle, global_comment); + + mz_zip_set_version_madeby(compat->handle, version_madeby); + err = mz_zip_close(compat->handle); + mz_zip_delete(&compat->handle); + + return err; +} diff --git a/SSZipArchive/minizip/compat/zip.h b/SSZipArchive/minizip/compat/zip.h new file mode 100644 index 0000000..9a78cfd --- /dev/null +++ b/SSZipArchive/minizip/compat/zip.h @@ -0,0 +1,186 @@ +/* zip.h -- Backwards compatible zip interface + part of the minizip-ng project + + Copyright (C) Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. + + WARNING: Be very careful updating/overwriting this file. + It has specific changes for ZipArchive support, notably MZ_COMPAT_VERSION. +*/ + +#ifndef _zip64_H +#define _zip64_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if !defined(_ZLIB_H) && !defined(ZLIB_H) && !defined(ZLIB_H_) +# if __has_include() +# include +# elif __has_include() +# include +# endif +#endif + +#ifndef _ZLIBIOAPI_H +# include "ioapi.h" +#endif + +/***************************************************************************/ + +#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagzipFile__ { + int unused; +} zipFile__; +typedef zipFile__ *zipFile; +#else +typedef void *zipFile; +#endif + +/***************************************************************************/ + +#define ZIP_OK (0) +#define ZIP_EOF (0) +#define ZIP_ERRNO (Z_ERRNO) +#define ZIP_PARAMERROR (-102) +#define ZIP_BADZIPFILE (-103) +#define ZIP_INTERNALERROR (-104) + +/***************************************************************************/ +/* default memLevel */ +#ifndef DEF_MEM_LEVEL +# if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +# else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +# endif +#endif + +/***************************************************************************/ +/* tm_zip contain date/time info */ +typedef struct tm_zip_s { + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years - [1980..2044] */ +} tm_zip; + +/***************************************************************************/ + +// ZipArchive 2.x+ uses dos_date +#define MZ_COMPAT_VERSION 120 + +#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION <= 110 +# define mz_dos_date dosDate +#else +# define mz_dos_date dos_date +#endif + +typedef struct { + tm_zip tmz_date; /* date in understandable format */ + unsigned long mz_dos_date; /* if dos_date == 0, tmz_date is used */ + unsigned long internal_fa; /* internal file attributes 2 bytes */ + unsigned long external_fa; /* external file attributes 4 bytes */ +} zip_fileinfo; + +typedef const char *zipcharpc; + +#define APPEND_STATUS_CREATE (0) +#define APPEND_STATUS_CREATEAFTER (1) +#define APPEND_STATUS_ADDINZIP (2) + +/***************************************************************************/ +/* Writing a zip file */ + +/* Compatibility layer with the original minizip library (zip.h). */ +ZEXPORT zipFile zipOpen(const char *path, int append); +ZEXPORT zipFile zipOpen64(const void *path, int append); + +ZEXPORT zipFile zipOpen2(const char *path, int append, zipcharpc *globalcomment, zlib_filefunc_def *pzlib_filefunc_def); +ZEXPORT zipFile zipOpen2_64(const void *path, int append, zipcharpc *globalcomment, + zlib_filefunc64_def *pzlib_filefunc_def); +/* zipOpen3 is not supported */ + +ZEXPORT int zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level); +ZEXPORT int zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int zip64); +ZEXPORT int zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int raw); +ZEXPORT int zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int raw, int zip64); +ZEXPORT int zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int raw, int windowBits, int memLevel, int strategy, + const char *password, unsigned long crc_for_crypting); +ZEXPORT int zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int raw, int windowBits, int memLevel, + int strategy, const char *password, unsigned long crc_for_crypting, int zip64); +ZEXPORT int zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int raw, int windowBits, int memLevel, int strategy, + const char *password, unsigned long crc_for_crypting, unsigned long version_madeby, + unsigned long flag_base); +ZEXPORT int zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int raw, int windowBits, int memLevel, + int strategy, const char *password, unsigned long crc_for_crypting, + unsigned long version_madeby, unsigned long flag_base, int zip64); +ZEXPORT int zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len); +ZEXPORT int zipCloseFileInZipRaw(zipFile file, unsigned long uncompressed_size, unsigned long crc32); +ZEXPORT int zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, unsigned long crc32); +ZEXPORT int zipCloseFileInZip(zipFile file); +/* zipAlreadyThere is too new */ +ZEXPORT int zipClose(zipFile file, const char *global_comment); +/* zipRemoveExtraInfoBlock is not supported */ + +/* Compatibility layer with older minizip-ng (mz_zip.h). */ +ZEXPORT zipFile zipOpen_MZ(void *stream, int append, zipcharpc *globalcomment); +ZEXPORT void *zipGetHandle_MZ(zipFile); +ZEXPORT void *zipGetStream_MZ(zipFile file); +ZEXPORT int zipOpenNewFileInZip_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int zip64); +ZEXPORT int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, + const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, + int compression_method, int level, int raw, int windowBits, int memLevel, int strategy, + const char *password, unsigned long crc_for_crypting, unsigned long version_madeby, + unsigned long flag_base, int zip64); +ZEXPORT int zipCloseFileInZip64(zipFile file); +ZEXPORT int zipClose_64(zipFile file, const char *global_comment); +ZEXPORT int zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby); +int zipClose_MZ(zipFile file, const char *global_comment); +int zipClose2_MZ(zipFile file, const char *global_comment, uint16_t version_madeby); + +#ifdef __cplusplus +} +#endif + +#endif /* _zip64_H */ diff --git a/SSZipArchive/minizip/mz_compat.c b/SSZipArchive/minizip/mz_compat.c deleted file mode 100644 index 334dd51..0000000 --- a/SSZipArchive/minizip/mz_compat.c +++ /dev/null @@ -1,1382 +0,0 @@ -/* mz_compat.c -- Backwards compatible interface for older versions - part of the minizip-ng project - - Copyright (C) Nathan Moinvaziri - https://github.com/zlib-ng/minizip-ng - Copyright (C) 1998-2010 Gilles Vollant - https://www.winimage.com/zLibDll/minizip.html - - This program is distributed under the terms of the same license as zlib. - See the accompanying LICENSE file for the full text of the license. - - WARNING: Be very careful updating/overwriting this file. - It has specific changes for SSZipArchive support with some structs moved to SSZipCommon for public access -*/ - -#include "mz.h" -#include "mz_os.h" -#include "mz_strm.h" -#include "mz_strm_mem.h" -#include "mz_strm_os.h" -#include "mz_strm_zlib.h" -#include "mz_zip.h" - -#include /* SEEK */ - -#include "mz_compat.h" - -/***************************************************************************/ - -typedef struct mz_compat_s { - void *stream; - void *handle; - uint64_t entry_index; - int64_t entry_pos; - int64_t total_out; -} mz_compat; - -/***************************************************************************/ - -typedef struct mz_stream_ioapi_s { - mz_stream stream; - void *handle; - zlib_filefunc_def filefunc; - zlib_filefunc64_def filefunc64; -} mz_stream_ioapi; - -/***************************************************************************/ - -static int32_t mz_stream_ioapi_open(void *stream, const char *path, int32_t mode); -static int32_t mz_stream_ioapi_is_open(void *stream); -static int32_t mz_stream_ioapi_read(void *stream, void *buf, int32_t size); -static int32_t mz_stream_ioapi_write(void *stream, const void *buf, int32_t size); -static int64_t mz_stream_ioapi_tell(void *stream); -static int32_t mz_stream_ioapi_seek(void *stream, int64_t offset, int32_t origin); -static int32_t mz_stream_ioapi_close(void *stream); -static int32_t mz_stream_ioapi_error(void *stream); -static void *mz_stream_ioapi_create(void); -static void mz_stream_ioapi_delete(void **stream); - -/***************************************************************************/ - -static mz_stream_vtbl mz_stream_ioapi_vtbl = { - mz_stream_ioapi_open, - mz_stream_ioapi_is_open, - mz_stream_ioapi_read, - mz_stream_ioapi_write, - mz_stream_ioapi_tell, - mz_stream_ioapi_seek, - mz_stream_ioapi_close, - mz_stream_ioapi_error, - mz_stream_ioapi_create, - mz_stream_ioapi_delete, - NULL, - NULL -}; - -/***************************************************************************/ - -static int32_t mz_stream_ioapi_open(void *stream, const char *path, int32_t mode) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - int32_t ioapi_mode = 0; - - if ((mode & MZ_OPEN_MODE_READWRITE) == MZ_OPEN_MODE_READ) - ioapi_mode = ZLIB_FILEFUNC_MODE_READ; - else if (mode & MZ_OPEN_MODE_APPEND) - ioapi_mode = ZLIB_FILEFUNC_MODE_EXISTING; - else if (mode & MZ_OPEN_MODE_CREATE) - ioapi_mode = ZLIB_FILEFUNC_MODE_CREATE; - else - return MZ_OPEN_ERROR; - - if (ioapi->filefunc64.zopen64_file) - ioapi->handle = ioapi->filefunc64.zopen64_file(ioapi->filefunc64.opaque, path, ioapi_mode); - else if (ioapi->filefunc.zopen_file) - ioapi->handle = ioapi->filefunc.zopen_file(ioapi->filefunc.opaque, path, ioapi_mode); - - if (!ioapi->handle) - return MZ_PARAM_ERROR; - - return MZ_OK; -} - -static int32_t mz_stream_ioapi_is_open(void *stream) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - if (!ioapi->handle) - return MZ_OPEN_ERROR; - return MZ_OK; -} - -static int32_t mz_stream_ioapi_read(void *stream, void *buf, int32_t size) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - read_file_func zread = NULL; - void *opaque = NULL; - - if (mz_stream_ioapi_is_open(stream) != MZ_OK) - return MZ_OPEN_ERROR; - - if (ioapi->filefunc64.zread_file) { - zread = ioapi->filefunc64.zread_file; - opaque = ioapi->filefunc64.opaque; - } else if (ioapi->filefunc.zread_file) { - zread = ioapi->filefunc.zread_file; - opaque = ioapi->filefunc.opaque; - } else - return MZ_PARAM_ERROR; - - return (int32_t)zread(opaque, ioapi->handle, buf, size); -} - -static int32_t mz_stream_ioapi_write(void *stream, const void *buf, int32_t size) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - write_file_func zwrite = NULL; - int32_t written = 0; - void *opaque = NULL; - - if (mz_stream_ioapi_is_open(stream) != MZ_OK) - return MZ_OPEN_ERROR; - - if (ioapi->filefunc64.zwrite_file) { - zwrite = ioapi->filefunc64.zwrite_file; - opaque = ioapi->filefunc64.opaque; - } else if (ioapi->filefunc.zwrite_file) { - zwrite = ioapi->filefunc.zwrite_file; - opaque = ioapi->filefunc.opaque; - } else - return MZ_PARAM_ERROR; - - written = (int32_t)zwrite(opaque, ioapi->handle, buf, size); - return written; -} - -static int64_t mz_stream_ioapi_tell(void *stream) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - - if (mz_stream_ioapi_is_open(stream) != MZ_OK) - return MZ_OPEN_ERROR; - - if (ioapi->filefunc64.ztell64_file) - return ioapi->filefunc64.ztell64_file(ioapi->filefunc64.opaque, ioapi->handle); - else if (ioapi->filefunc.ztell_file) - return ioapi->filefunc.ztell_file(ioapi->filefunc.opaque, ioapi->handle); - - return MZ_INTERNAL_ERROR; -} - -static int32_t mz_stream_ioapi_seek(void *stream, int64_t offset, int32_t origin) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - - if (mz_stream_ioapi_is_open(stream) != MZ_OK) - return MZ_OPEN_ERROR; - - if (ioapi->filefunc64.zseek64_file) { - if (ioapi->filefunc64.zseek64_file(ioapi->filefunc64.opaque, ioapi->handle, offset, origin) != 0) - return MZ_INTERNAL_ERROR; - } else if (ioapi->filefunc.zseek_file) { - if (ioapi->filefunc.zseek_file(ioapi->filefunc.opaque, ioapi->handle, (int32_t)offset, origin) != 0) - return MZ_INTERNAL_ERROR; - } else - return MZ_PARAM_ERROR; - - return MZ_OK; -} - -static int32_t mz_stream_ioapi_close(void *stream) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - close_file_func zclose = NULL; - void *opaque = NULL; - - if (mz_stream_ioapi_is_open(stream) != MZ_OK) - return MZ_OPEN_ERROR; - - if (ioapi->filefunc.zclose_file) { - zclose = ioapi->filefunc.zclose_file; - opaque = ioapi->filefunc.opaque; - } else if (ioapi->filefunc64.zclose_file) { - zclose = ioapi->filefunc64.zclose_file; - opaque = ioapi->filefunc64.opaque; - } else - return MZ_PARAM_ERROR; - - if (zclose(opaque, ioapi->handle) != 0) - return MZ_CLOSE_ERROR; - ioapi->handle = NULL; - return MZ_OK; -} - -static int32_t mz_stream_ioapi_error(void *stream) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - testerror_file_func zerror = NULL; - void *opaque = NULL; - - if (mz_stream_ioapi_is_open(stream) != MZ_OK) - return MZ_OPEN_ERROR; - - if (ioapi->filefunc.zerror_file) { - zerror = ioapi->filefunc.zerror_file; - opaque = ioapi->filefunc.opaque; - } else if (ioapi->filefunc64.zerror_file) { - zerror = ioapi->filefunc64.zerror_file; - opaque = ioapi->filefunc64.opaque; - } else - return MZ_PARAM_ERROR; - - return zerror(opaque, ioapi->handle); -} - -static int32_t mz_stream_ioapi_set_filefunc(void *stream, zlib_filefunc_def *filefunc) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - memcpy(&ioapi->filefunc, filefunc, sizeof(zlib_filefunc_def)); - return MZ_OK; -} - -static int32_t mz_stream_ioapi_set_filefunc64(void *stream, zlib_filefunc64_def *filefunc) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)stream; - memcpy(&ioapi->filefunc64, filefunc, sizeof(zlib_filefunc64_def)); - return MZ_OK; -} - -static void *mz_stream_ioapi_create(void) { - mz_stream_ioapi *ioapi = (mz_stream_ioapi *)calloc(1, sizeof(mz_stream_ioapi)); - if (ioapi) - ioapi->stream.vtbl = &mz_stream_ioapi_vtbl; - return ioapi; -} - -static void mz_stream_ioapi_delete(void **stream) { - mz_stream_ioapi *ioapi = NULL; - if (!stream) - return; - ioapi = (mz_stream_ioapi *)*stream; - if (ioapi) - free(ioapi); - *stream = NULL; -} - -/***************************************************************************/ - -void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def) { - /* For 32-bit file support only, compile with MZ_FILE32_API */ - if (pzlib_filefunc_def) - memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc_def)); -} - -void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def) { - /* All mz_stream_os_* support large files if compilation supports it */ - if (pzlib_filefunc_def) - memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc64_def)); -} - -void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def) { - /* Handled by mz_stream_os_win32 */ - if (pzlib_filefunc_def) - memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc_def)); -} - -void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def) { - /* Automatically supported in mz_stream_os_win32 */ - if (pzlib_filefunc_def) - memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc64_def)); -} - -void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def) { - /* Automatically supported in mz_stream_os_win32 */ - if (pzlib_filefunc_def) - memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc64_def)); -} - -/* NOTE: fill_win32_filefunc64W is no longer necessary since wide-character - support is automatically handled by the underlying os stream. Do not - pass wide-characters to zipOpen or unzOpen. */ - -void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def) { - /* Use opaque to indicate which stream interface to create */ - if (pzlib_filefunc_def) { - memset(pzlib_filefunc_def, 0, sizeof(zlib_filefunc_def)); - pzlib_filefunc_def->opaque = mz_stream_mem_get_interface(); - } -} - -/***************************************************************************/ - -static int32_t zipConvertAppendToStreamMode(int append) { - int32_t mode = MZ_OPEN_MODE_WRITE; - switch (append) { - case APPEND_STATUS_CREATE: - mode |= MZ_OPEN_MODE_CREATE; - break; - case APPEND_STATUS_CREATEAFTER: - mode |= MZ_OPEN_MODE_CREATE | MZ_OPEN_MODE_APPEND; - break; - case APPEND_STATUS_ADDINZIP: - mode |= MZ_OPEN_MODE_READ | MZ_OPEN_MODE_APPEND; - break; - } - return mode; -} - -zipFile zipOpen(const char *path, int append) { - return zipOpen2(path, append, NULL, NULL); -} - -zipFile zipOpen64(const void *path, int append) { - return zipOpen2(path, append, NULL, NULL); -} - -zipFile zipOpen2(const char *path, int append, const char **globalcomment, - zlib_filefunc_def *pzlib_filefunc_def) { - zipFile zip = NULL; - int32_t mode = zipConvertAppendToStreamMode(append); - void *stream = NULL; - - if (pzlib_filefunc_def) { - if (pzlib_filefunc_def->zopen_file) { - stream = mz_stream_ioapi_create(); - if (!stream) - return NULL; - mz_stream_ioapi_set_filefunc(stream, pzlib_filefunc_def); - } else if (pzlib_filefunc_def->opaque) { - stream = mz_stream_create((mz_stream_vtbl *)pzlib_filefunc_def->opaque); - if (!stream) - return NULL; - } - } - - if (!stream) { - stream = mz_stream_os_create(); - if (!stream) - return NULL; - } - - if (mz_stream_open(stream, path, mode) != MZ_OK) { - mz_stream_delete(&stream); - return NULL; - } - - zip = zipOpen_MZ(stream, append, globalcomment); - - if (!zip) { - mz_stream_delete(&stream); - return NULL; - } - - return zip; -} - -zipFile zipOpen2_64(const void *path, int append, const char **globalcomment, - zlib_filefunc64_def *pzlib_filefunc_def) { - zipFile zip = NULL; - int32_t mode = zipConvertAppendToStreamMode(append); - void *stream = NULL; - - if (pzlib_filefunc_def) { - if (pzlib_filefunc_def->zopen64_file) { - stream = mz_stream_ioapi_create(); - if (!stream) - return NULL; - mz_stream_ioapi_set_filefunc64(stream, pzlib_filefunc_def); - } else if (pzlib_filefunc_def->opaque) { - stream = mz_stream_create((mz_stream_vtbl *)pzlib_filefunc_def->opaque); - if (!stream) - return NULL; - } - } - - if (!stream) { - stream = mz_stream_os_create(); - if (!stream) - return NULL; - } - - if (mz_stream_open(stream, path, mode) != MZ_OK) { - mz_stream_delete(&stream); - return NULL; - } - - zip = zipOpen_MZ(stream, append, globalcomment); - - if (!zip) { - mz_stream_delete(&stream); - return NULL; - } - - return zip; -} - -zipFile zipOpen_MZ(void *stream, int append, const char **globalcomment) { - mz_compat *compat = NULL; - int32_t err = MZ_OK; - int32_t mode = zipConvertAppendToStreamMode(append); - void *handle = NULL; - - handle = mz_zip_create(); - if (!handle) - return NULL; - - err = mz_zip_open(handle, stream, mode); - - if (err != MZ_OK) { - mz_zip_delete(&handle); - return NULL; - } - - if (globalcomment) - mz_zip_get_comment(handle, globalcomment); - - compat = (mz_compat *)calloc(1, sizeof(mz_compat)); - if (compat) { - compat->handle = handle; - compat->stream = stream; - } else { - mz_zip_delete(&handle); - } - - return (zipFile)compat; -} - -void* zipGetHandle_MZ(zipFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return NULL; - return compat->handle; -} - -void* zipGetStream_MZ(zipFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return NULL; - return (void *)compat->stream; -} - -int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting, signed char aes, unsigned long version_madeby, unsigned long flag_base, int zip64) { - mz_compat *compat = (mz_compat *)file; - mz_zip_file file_info; - - MZ_UNUSED(strategy); - MZ_UNUSED(memLevel); - MZ_UNUSED(windowBits); - MZ_UNUSED(size_extrafield_local); - MZ_UNUSED(extrafield_local); - MZ_UNUSED(crc_for_crypting); - - if (!compat) - return ZIP_PARAMERROR; - - /* The filename and comment length must fit in 16 bits. */ - if (filename && strlen(filename) > 0xffff) - return ZIP_PARAMERROR; - if (comment && strlen(comment) > 0xffff) - return ZIP_PARAMERROR; - - memset(&file_info, 0, sizeof(file_info)); - - if (zipfi) { - uint64_t dos_date = 0; - - if (zipfi->mz_dos_date != 0) - dos_date = zipfi->mz_dos_date; - else - dos_date = mz_zip_tm_to_dosdate(&zipfi->tmz_date); - - file_info.modified_date = mz_zip_dosdate_to_time_t(dos_date); - file_info.external_fa = (uint32_t)zipfi->external_fa; - file_info.internal_fa = (uint16_t)zipfi->internal_fa; - } - - if (!filename) - filename = "-"; - - file_info.compression_method = (uint16_t)compression_method; - file_info.filename = filename; - /* file_info.extrafield_local = extrafield_local; */ - /* file_info.extrafield_local_size = size_extrafield_local; */ - file_info.extrafield = extrafield_global; - file_info.extrafield_size = size_extrafield_global; - file_info.version_madeby = (uint16_t)version_madeby; - file_info.comment = comment; - if (file_info.comment) - file_info.comment_size = (uint16_t)strlen(file_info.comment); - file_info.flag = (uint16_t)flag_base; - if (zip64) - file_info.zip64 = MZ_ZIP64_FORCE; - else - file_info.zip64 = MZ_ZIP64_DISABLE; -#ifdef HAVE_WZAES - if ((aes && password) || (raw && (file_info.flag & MZ_ZIP_FLAG_ENCRYPTED))) - file_info.aes_version = MZ_AES_VERSION; -#endif - - return mz_zip_entry_write_open(compat->handle, &file_info, (int16_t)level, (uint8_t)raw, password); -} - -int zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting, unsigned long version_madeby, unsigned long flag_base, int zip64) { - return zipOpenNewFileInZip5(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, raw, windowBits, - memLevel, strategy, password, crc_for_crypting, 0, version_madeby, flag_base, zip64); -} - -int zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting, unsigned long version_madeby, unsigned long flag_base) { - return zipOpenNewFileInZip4_64(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, raw, windowBits, - memLevel, strategy, password, crc_for_crypting, version_madeby, flag_base, 0); -} - -int zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting) { - return zipOpenNewFileInZip3_64(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, raw, windowBits, - memLevel, strategy, password, crc_for_crypting, 0); -} - -int zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting, int zip64) { - return zipOpenNewFileInZip4_64(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, raw, windowBits, - memLevel, strategy, password, crc_for_crypting, MZ_VERSION_MADEBY, 0, zip64); -} - -int zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw) { - return zipOpenNewFileInZip3_64(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, raw, - 0, 0, 0, NULL, 0, 0); -} - -int zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int zip64) { - return zipOpenNewFileInZip3_64(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, raw, 0, - 0, 0, NULL, 0, zip64); -} - -int zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level) { - return zipOpenNewFileInZip_64(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, 0); -} - -int zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int zip64) { - return zipOpenNewFileInZip2_64(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, 0, zip64); -} - -int zipOpenNewFileInZip_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int zip64) { - return zipOpenNewFileInZip2_64(file, filename, zipfi, extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, comment, compression_method, level, 0, zip64); -} - -int zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len) { - mz_compat *compat = (mz_compat *)file; - int32_t written = 0; - if (!compat || len >= INT32_MAX) - return ZIP_PARAMERROR; - written = mz_zip_entry_write(compat->handle, buf, (int32_t)len); - if ((written < 0) || ((uint32_t)written != len)) - return ZIP_ERRNO; - return ZIP_OK; -} - -int zipCloseFileInZipRaw(zipFile file, unsigned long uncompressed_size, unsigned long crc32) { - return zipCloseFileInZipRaw64(file, uncompressed_size, crc32); -} - -int zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, unsigned long crc32) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return ZIP_PARAMERROR; - return mz_zip_entry_close_raw(compat->handle, (int64_t)uncompressed_size, (uint32_t)crc32); -} - -int zipCloseFileInZip(zipFile file) { - return zipCloseFileInZip64(file); -} - -int zipCloseFileInZip64(zipFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return ZIP_PARAMERROR; - return mz_zip_entry_close(compat->handle); -} - -int zipClose(zipFile file, const char *global_comment) { - return zipClose_64(file, global_comment); -} - -int zipClose_64(zipFile file, const char *global_comment) { - return zipClose2_64(file, global_comment, MZ_VERSION_MADEBY); -} - -int zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby) { - mz_compat *compat = (mz_compat *)file; - int32_t err = MZ_OK; - - if (compat->handle) - err = zipClose2_MZ(file, global_comment, version_madeby); - - if (compat->stream) { - mz_stream_close(compat->stream); - mz_stream_delete(&compat->stream); - } - - free(compat); - - return err; -} - -/* Only closes the zip handle, does not close the stream */ -int zipClose_MZ(zipFile file, const char *global_comment) { - return zipClose2_MZ(file, global_comment, MZ_VERSION_MADEBY); -} - -/* Only closes the zip handle, does not close the stream */ -int zipClose2_MZ(zipFile file, const char *global_comment, uint16_t version_madeby) { - mz_compat *compat = (mz_compat *)file; - int32_t err = MZ_OK; - - if (!compat) - return ZIP_PARAMERROR; - if (!compat->handle) - return err; - - if (global_comment) - mz_zip_set_comment(compat->handle, global_comment); - - mz_zip_set_version_madeby(compat->handle, version_madeby); - err = mz_zip_close(compat->handle); - mz_zip_delete(&compat->handle); - - return err; -} - -/***************************************************************************/ - -unzFile unzOpen(const char *path) { - return unzOpen64(path); -} - -unzFile unzOpen64(const void *path) { - return unzOpen2(path, NULL); -} - -unzFile unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def) { - unzFile unz = NULL; - void *stream = NULL; - - if (pzlib_filefunc_def) { - if (pzlib_filefunc_def->zopen_file) { - stream = mz_stream_ioapi_create(); - if (!stream) - return NULL; - mz_stream_ioapi_set_filefunc(stream, pzlib_filefunc_def); - } else if (pzlib_filefunc_def->opaque) { - stream = mz_stream_create((mz_stream_vtbl *)pzlib_filefunc_def->opaque); - if (!stream) - return NULL; - } - } - - if (!stream) { - stream = mz_stream_os_create(); - if (!stream) - return NULL; - } - - if (mz_stream_open(stream, path, MZ_OPEN_MODE_READ) != MZ_OK) { - mz_stream_delete(&stream); - return NULL; - } - - unz = unzOpen_MZ(stream); - if (!unz) { - mz_stream_close(stream); - mz_stream_delete(&stream); - return NULL; - } - return unz; -} - -unzFile unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def) { - unzFile unz = NULL; - void *stream = NULL; - - if (pzlib_filefunc_def) { - if (pzlib_filefunc_def->zopen64_file) { - stream = mz_stream_ioapi_create(); - if (!stream) - return NULL; - mz_stream_ioapi_set_filefunc64(stream, pzlib_filefunc_def); - } else if (pzlib_filefunc_def->opaque) { - stream = mz_stream_create((mz_stream_vtbl *)pzlib_filefunc_def->opaque); - if (!stream) - return NULL; - } - } - - if (!stream) { - stream = mz_stream_os_create(); - if (!stream) - return NULL; - } - - if (mz_stream_open(stream, path, MZ_OPEN_MODE_READ) != MZ_OK) { - mz_stream_delete(&stream); - return NULL; - } - - unz = unzOpen_MZ(stream); - if (!unz) { - mz_stream_close(stream); - mz_stream_delete(&stream); - return NULL; - } - return unz; -} - -void* unzGetHandle_MZ(unzFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return NULL; - return compat->handle; -} - -void* unzGetStream_MZ(unzFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return NULL; - return compat->stream; -} - -unzFile unzOpen_MZ(void *stream) { - mz_compat *compat = NULL; - int32_t err = MZ_OK; - void *handle = NULL; - - handle = mz_zip_create(); - if (!handle) - return NULL; - - err = mz_zip_open(handle, stream, MZ_OPEN_MODE_READ); - if (err != MZ_OK) { - mz_zip_delete(&handle); - return NULL; - } - - compat = (mz_compat *)calloc(1, sizeof(mz_compat)); - if (compat) { - compat->handle = handle; - compat->stream = stream; - - mz_zip_goto_first_entry(compat->handle); - } else { - mz_zip_delete(&handle); - } - - return (unzFile)compat; -} - -int unzClose(unzFile file) { - mz_compat *compat = (mz_compat *)file; - int32_t err = MZ_OK; - - if (!compat) - return UNZ_PARAMERROR; - - if (compat->handle) - err = unzClose_MZ(file); - - if (compat->stream) { - mz_stream_close(compat->stream); - mz_stream_delete(&compat->stream); - } - - free(compat); - - return err; -} - -/* Only closes the zip handle, does not close the stream */ -int unzClose_MZ(unzFile file) { - mz_compat *compat = (mz_compat *)file; - int32_t err = MZ_OK; - - if (!compat) - return UNZ_PARAMERROR; - - err = mz_zip_close(compat->handle); - mz_zip_delete(&compat->handle); - - return err; -} - -int unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32) { - mz_compat *compat = (mz_compat *)file; - unz_global_info64 global_info64; - int32_t err = MZ_OK; - - memset(pglobal_info32, 0, sizeof(unz_global_info)); - if (!compat) - return UNZ_PARAMERROR; - - err = unzGetGlobalInfo64(file, &global_info64); - if (err == MZ_OK) { - pglobal_info32->number_entry = (uint32_t)global_info64.number_entry; - pglobal_info32->size_comment = global_info64.size_comment; - pglobal_info32->number_disk_with_CD = global_info64.number_disk_with_CD; - } - return err; -} - -int unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info) { - mz_compat *compat = (mz_compat *)file; - const char *comment_ptr = NULL; - int32_t err = MZ_OK; - - memset(pglobal_info, 0, sizeof(unz_global_info64)); - if (!compat) - return UNZ_PARAMERROR; - err = mz_zip_get_comment(compat->handle, &comment_ptr); - if (err == MZ_OK) - pglobal_info->size_comment = (uint16_t)strlen(comment_ptr); - if ((err == MZ_OK) || (err == MZ_EXIST_ERROR)) - err = mz_zip_get_number_entry(compat->handle, &pglobal_info->number_entry); - if (err == MZ_OK) - err = mz_zip_get_disk_number_with_cd(compat->handle, &pglobal_info->number_disk_with_CD); - return err; -} - -int unzGetGlobalComment(unzFile file, char *comment, unsigned long comment_size) { - mz_compat *compat = (mz_compat *)file; - const char *comment_ptr = NULL; - int32_t err = MZ_OK; - - if (!comment || !comment_size) - return UNZ_PARAMERROR; - err = mz_zip_get_comment(compat->handle, &comment_ptr); - if (err == MZ_OK) { - strncpy(comment, comment_ptr, comment_size - 1); - comment[comment_size - 1] = 0; - } - return err; -} - -int unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password) { - mz_compat *compat = (mz_compat *)file; - mz_zip_file *file_info = NULL; - int32_t err = MZ_OK; - void *stream = NULL; - - if (!compat) - return UNZ_PARAMERROR; - if (method) - *method = 0; - if (level) - *level = 0; - - if (mz_zip_entry_is_open(compat->handle) == MZ_OK) { - /* zlib minizip does not error out here if close returns errors */ - unzCloseCurrentFile(file); - } - - compat->total_out = 0; - err = mz_zip_entry_read_open(compat->handle, (uint8_t)raw, password); - if (err == MZ_OK) - err = mz_zip_entry_get_info(compat->handle, &file_info); - if (err == MZ_OK) { - if (method) { - *method = file_info->compression_method; - } - - if (level) { - *level = 6; - switch (file_info->flag & 0x06) { - case MZ_ZIP_FLAG_DEFLATE_SUPER_FAST: - *level = 1; - break; - case MZ_ZIP_FLAG_DEFLATE_FAST: - *level = 2; - break; - case MZ_ZIP_FLAG_DEFLATE_MAX: - *level = 9; - break; - } - } - } - if (err == MZ_OK) - err = mz_zip_get_stream(compat->handle, &stream); - if (err == MZ_OK) - compat->entry_pos = mz_stream_tell(stream); - return err; -} - -int unzOpenCurrentFile(unzFile file) { - return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); -} - -int unzOpenCurrentFilePassword(unzFile file, const char *password) { - return unzOpenCurrentFile3(file, NULL, NULL, 0, password); -} - -int unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw) { - return unzOpenCurrentFile3(file, method, level, raw, NULL); -} - -int unzReadCurrentFile(unzFile file, void *buf, uint32_t len) { - mz_compat *compat = (mz_compat *)file; - int32_t err = MZ_OK; - if (!compat || len >= INT32_MAX) - return UNZ_PARAMERROR; - err = mz_zip_entry_read(compat->handle, buf, (int32_t)len); - if (err > 0) - compat->total_out += (uint32_t)err; - return err; -} - -int unzCloseCurrentFile(unzFile file) { - mz_compat *compat = (mz_compat *)file; - int32_t err = MZ_OK; - if (!compat) - return UNZ_PARAMERROR; - err = mz_zip_entry_close(compat->handle); - return err; -} - -int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename, - unsigned long filename_size, void *extrafield, unsigned long extrafield_size, char *comment, - unsigned long comment_size) { - mz_compat *compat = (mz_compat *)file; - mz_zip_file *file_info = NULL; - uint16_t bytes_to_copy = 0; - int32_t err = MZ_OK; - - if (!compat) - return UNZ_PARAMERROR; - - err = mz_zip_entry_get_info(compat->handle, &file_info); - if (err != MZ_OK) - return err; - - if (pfile_info) { - pfile_info->version = file_info->version_madeby; - pfile_info->version_needed = file_info->version_needed; - pfile_info->flag = file_info->flag; - pfile_info->compression_method = file_info->compression_method; - pfile_info->mz_dos_date = mz_zip_time_t_to_dos_date(file_info->modified_date); - // [ZipArchive] disabled for performances: we don't need the tmu_date field because we already set the mz_dos_date field: - // https://github.com/madler/zlib/blob/643e17b7498d12ab8d15565662880579692f769d/contrib/minizip/zip.h#L102 - //mz_zip_time_t_to_tm(file_info->modified_date, &pfile_info->tmu_date); - //pfile_info->tmu_date.tm_year += 1900; - pfile_info->crc = file_info->crc; - - pfile_info->size_filename = file_info->filename_size; - pfile_info->size_file_extra = file_info->extrafield_size; - pfile_info->size_file_comment = file_info->comment_size; - - pfile_info->disk_num_start = (uint16_t)file_info->disk_number; - pfile_info->internal_fa = file_info->internal_fa; - pfile_info->external_fa = file_info->external_fa; - - pfile_info->compressed_size = (uint32_t)file_info->compressed_size; - pfile_info->uncompressed_size = (uint32_t)file_info->uncompressed_size; - } - if (filename_size > 0 && filename && file_info->filename) { - bytes_to_copy = (uint16_t)filename_size; - if (bytes_to_copy > file_info->filename_size) - bytes_to_copy = file_info->filename_size; - memcpy(filename, file_info->filename, bytes_to_copy); - if (bytes_to_copy < filename_size) - filename[bytes_to_copy] = 0; - } - if (extrafield_size > 0 && extrafield) { - bytes_to_copy = (uint16_t)extrafield_size; - if (bytes_to_copy > file_info->extrafield_size) - bytes_to_copy = file_info->extrafield_size; - memcpy(extrafield, file_info->extrafield, bytes_to_copy); - } - if (comment_size > 0 && comment && file_info->comment) { - bytes_to_copy = (uint16_t)comment_size; - if (bytes_to_copy > file_info->comment_size) - bytes_to_copy = file_info->comment_size; - memcpy(comment, file_info->comment, bytes_to_copy); - if (bytes_to_copy < comment_size) - comment[bytes_to_copy] = 0; - } - return err; -} - -int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile_info, char *filename, - unsigned long filename_size, void *extrafield, unsigned long extrafield_size, char *comment, - unsigned long comment_size) { - mz_compat *compat = (mz_compat *)file; - mz_zip_file *file_info = NULL; - uint16_t bytes_to_copy = 0; - int32_t err = MZ_OK; - - if (!compat) - return UNZ_PARAMERROR; - - err = mz_zip_entry_get_info(compat->handle, &file_info); - if (err != MZ_OK) - return err; - - if (pfile_info) { - pfile_info->version = file_info->version_madeby; - pfile_info->version_needed = file_info->version_needed; - pfile_info->flag = file_info->flag; - pfile_info->compression_method = file_info->compression_method; - pfile_info->mz_dos_date = mz_zip_time_t_to_dos_date(file_info->modified_date); - // [ZipArchive] disabled for performances: we don't need the tmu_date field because we already set the mz_dos_date field: - // https://github.com/madler/zlib/blob/643e17b7498d12ab8d15565662880579692f769d/contrib/minizip/zip.h#L102 - //mz_zip_time_t_to_tm(file_info->modified_date, &pfile_info->tmu_date); - //pfile_info->tmu_date.tm_year += 1900; - pfile_info->crc = file_info->crc; - - pfile_info->size_filename = file_info->filename_size; - pfile_info->size_file_extra = file_info->extrafield_size; - pfile_info->size_file_comment = file_info->comment_size; - - pfile_info->disk_num_start = file_info->disk_number; - pfile_info->internal_fa = file_info->internal_fa; - pfile_info->external_fa = file_info->external_fa; - - pfile_info->compressed_size = (uint64_t)file_info->compressed_size; - pfile_info->uncompressed_size = (uint64_t)file_info->uncompressed_size; - } - if (filename_size > 0 && filename && file_info->filename) { - bytes_to_copy = (uint16_t)filename_size; - if (bytes_to_copy > file_info->filename_size) - bytes_to_copy = file_info->filename_size; - memcpy(filename, file_info->filename, bytes_to_copy); - if (bytes_to_copy < filename_size) - filename[bytes_to_copy] = 0; - } - if (extrafield_size > 0 && extrafield) { - bytes_to_copy = (uint16_t)extrafield_size; - if (bytes_to_copy > file_info->extrafield_size) - bytes_to_copy = file_info->extrafield_size; - memcpy(extrafield, file_info->extrafield, bytes_to_copy); - } - if (comment_size > 0 && comment && file_info->comment) { - bytes_to_copy = (uint16_t)comment_size; - if (bytes_to_copy > file_info->comment_size) - bytes_to_copy = file_info->comment_size; - memcpy(comment, file_info->comment, bytes_to_copy); - if (bytes_to_copy < comment_size) - comment[bytes_to_copy] = 0; - } - return err; -} - -int unzGoToFirstFile(unzFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return UNZ_PARAMERROR; - compat->entry_index = 0; - return mz_zip_goto_first_entry(compat->handle); -} - -int unzGoToNextFile(unzFile file) { - mz_compat *compat = (mz_compat *)file; - int32_t err = MZ_OK; - if (!compat) - return UNZ_PARAMERROR; - err = mz_zip_goto_next_entry(compat->handle); - if (err != MZ_END_OF_LIST) - compat->entry_index += 1; - return err; -} - -#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION < 110 -#ifdef WIN32 -# define UNZ_DEFAULT_IGNORE_CASE 1 -#else -# define UNZ_DEFAULT_IGNORE_CASE 0 -#endif - -int unzLocateFile(unzFile file, const char *filename, unzFileNameCase filename_case) { - mz_compat *compat = (mz_compat *)file; - mz_zip_file *file_info = NULL; - uint64_t preserve_index = 0; - int32_t err = MZ_OK; - int32_t result = 0; - uint8_t ignore_case = UNZ_DEFAULT_IGNORE_CASE; - - if (!compat) - return UNZ_PARAMERROR; - - if (filename_case == 1) { - ignore_case = 0; - } else if (filename_case > 1) { - ignore_case = 1; - } - - preserve_index = compat->entry_index; - - err = mz_zip_goto_first_entry(compat->handle); - while (err == MZ_OK) { - err = mz_zip_entry_get_info(compat->handle, &file_info); - if (err != MZ_OK) - break; - - result = mz_path_compare_wc(filename, file_info->filename, !ignore_case); - - if (result == 0) - return MZ_OK; - - err = mz_zip_goto_next_entry(compat->handle); - } - - compat->entry_index = preserve_index; - return err; -} -#else -int unzLocateFile(unzFile file, const char* filename, unzFileNameComparer filename_compare_func) { - mz_compat* compat = (mz_compat*)file; - mz_zip_file* file_info = NULL; - uint64_t preserve_index = 0; - int32_t err = MZ_OK; - int32_t result = 0; - - if (!compat) - return UNZ_PARAMERROR; - - preserve_index = compat->entry_index; - - err = mz_zip_goto_first_entry(compat->handle); - while (err == MZ_OK) { - err = mz_zip_entry_get_info(compat->handle, &file_info); - if (err != MZ_OK) - break; - - if ((intptr_t)filename_compare_func > 2) { - result = filename_compare_func(file, filename, file_info->filename); - } - else { - int32_t case_sensitive = (int32_t)(intptr_t)filename_compare_func; - result = mz_path_compare_wc(filename, file_info->filename, !case_sensitive); - } - - if (result == 0) - return MZ_OK; - - err = mz_zip_goto_next_entry(compat->handle); - } - - compat->entry_index = preserve_index; - return err; -} -#endif - -/***************************************************************************/ - -int unzGetFilePos(unzFile file, unz_file_pos *file_pos) { - unz64_file_pos file_pos64; - int32_t err = 0; - - err = unzGetFilePos64(file, &file_pos64); - if (err < 0) - return err; - - file_pos->pos_in_zip_directory = (uint32_t)file_pos64.pos_in_zip_directory; - file_pos->num_of_file = (uint32_t)file_pos64.num_of_file; - return err; -} - -int unzGoToFilePos(unzFile file, unz_file_pos *file_pos) { - mz_compat *compat = (mz_compat *)file; - unz64_file_pos file_pos64; - - if (!compat || !file_pos) - return UNZ_PARAMERROR; - - file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; - file_pos64.num_of_file = file_pos->num_of_file; - - return unzGoToFilePos64(file, &file_pos64); -} - -int unzGetFilePos64(unzFile file, unz64_file_pos *file_pos) { - mz_compat *compat = (mz_compat *)file; - int64_t offset = 0; - - if (!compat || !file_pos) - return UNZ_PARAMERROR; - - offset = unzGetOffset64(file); - if (offset < 0) - return (int)offset; - - file_pos->pos_in_zip_directory = offset; - file_pos->num_of_file = compat->entry_index; - return UNZ_OK; -} - -int unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos) { - mz_compat *compat = (mz_compat *)file; - int32_t err = MZ_OK; - - if (!compat || !file_pos) - return UNZ_PARAMERROR; - - err = mz_zip_goto_entry(compat->handle, file_pos->pos_in_zip_directory); - if (err == MZ_OK) - compat->entry_index = file_pos->num_of_file; - return err; -} - -unsigned long unzGetOffset(unzFile file) { - return (uint32_t)unzGetOffset64(file); -} - -int64_t unzGetOffset64(unzFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return UNZ_PARAMERROR; - return mz_zip_get_entry(compat->handle); -} - -int unzSetOffset(unzFile file, unsigned long pos) { - return unzSetOffset64(file, pos); -} - -int unzSetOffset64(unzFile file, int64_t pos) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return UNZ_PARAMERROR; - return (int)mz_zip_goto_entry(compat->handle, pos); -} - -int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len) { - mz_compat *compat = (mz_compat *)file; - mz_zip_file *file_info = NULL; - int32_t err = MZ_OK; - int32_t bytes_to_copy = 0; - - if (!compat || !buf || len >= INT32_MAX) - return UNZ_PARAMERROR; - - err = mz_zip_entry_get_local_info(compat->handle, &file_info); - if (err != MZ_OK) - return err; - - bytes_to_copy = (int32_t)len; - if (bytes_to_copy > file_info->extrafield_size) - bytes_to_copy = file_info->extrafield_size; - - memcpy(buf, file_info->extrafield, bytes_to_copy); - return MZ_OK; -} - -int32_t unzTell(unzFile file) { - return unztell(file); -} - -int32_t unztell(unzFile file) { - return (int32_t)unztell64(file); -} - -uint64_t unzTell64(unzFile file) { - return unztell64(file); -} - -uint64_t unztell64(unzFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return UNZ_PARAMERROR; - return compat->total_out; -} - -int unzSeek(unzFile file, int32_t offset, int origin) { - return unzSeek64(file, offset, origin); -} - -int unzSeek64(unzFile file, int64_t offset, int origin) { - mz_compat *compat = (mz_compat *)file; - mz_zip_file *file_info = NULL; - int64_t position = 0; - int32_t err = MZ_OK; - void *stream = NULL; - - if (!compat) - return UNZ_PARAMERROR; - err = mz_zip_entry_get_info(compat->handle, &file_info); - if (err != MZ_OK) - return err; - if (file_info->compression_method != MZ_COMPRESS_METHOD_STORE) - return UNZ_ERRNO; - - if (origin == SEEK_SET) - position = offset; - else if (origin == SEEK_CUR) - position = compat->total_out + offset; - else if (origin == SEEK_END) - position = (int64_t)file_info->compressed_size + offset; - else - return UNZ_PARAMERROR; - - if (position > (int64_t)file_info->compressed_size) - return UNZ_PARAMERROR; - - err = mz_zip_get_stream(compat->handle, &stream); - if (err == MZ_OK) - err = mz_stream_seek(stream, compat->entry_pos + position, MZ_SEEK_SET); - if (err == MZ_OK) - compat->total_out = position; - return err; -} - -int unzEndOfFile(unzFile file) { - return unzeof(file); -} - -int unzeof(unzFile file) { - mz_compat *compat = (mz_compat *)file; - mz_zip_file *file_info = NULL; - int32_t err = MZ_OK; - - if (!compat) - return UNZ_PARAMERROR; - err = mz_zip_entry_get_info(compat->handle, &file_info); - if (err != MZ_OK) - return err; - if (compat->total_out == (int64_t)file_info->uncompressed_size) - return 1; - return 0; -} - -void* unzGetStream(unzFile file) { - mz_compat *compat = (mz_compat *)file; - if (!compat) - return NULL; - return (void *)compat->stream; -} - -/***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_compat.h b/SSZipArchive/minizip/mz_compat.h deleted file mode 100644 index 824949d..0000000 --- a/SSZipArchive/minizip/mz_compat.h +++ /dev/null @@ -1,395 +0,0 @@ -/* mz_compat.h -- Backwards compatible interface for older versions - part of the minizip-ng project - - Copyright (C) Nathan Moinvaziri - https://github.com/zlib-ng/minizip-ng - Copyright (C) 1998-2010 Gilles Vollant - https://www.winimage.com/zLibDll/minizip.html - - This program is distributed under the terms of the same license as zlib. - See the accompanying LICENSE file for the full text of the license. - - WARNING: Be very careful updating/overwriting this file. - It has specific changes for SSZipArchive support with some structs moved to SSZipCommon for public access -*/ - -#ifndef MZ_COMPAT_H -#define MZ_COMPAT_H - -#include "mz.h" -#include "../SSZipCommon.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/***************************************************************************/ - -#if defined(HAVE_ZLIB) && defined(MAX_MEM_LEVEL) -#ifndef DEF_MEM_LEVEL -# if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -# else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -# endif -#endif -#endif -#ifndef MAX_WBITS -#define MAX_WBITS 15 //removed () to suppress warning about ambiguous expansion of macro -SSZipArchive -#endif -#ifndef DEF_MEM_LEVEL -#define DEF_MEM_LEVEL (8) -#endif - -#ifndef ZEXPORT -# define ZEXPORT MZ_EXPORT -#endif - -/***************************************************************************/ - -#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagzipFile__ { int unused; } zip_file__; -typedef zip_file__ *zipFile; -#else -typedef void *zipFile; -#endif - -/***************************************************************************/ - -typedef uint64_t ZPOS64_T; - -#ifndef ZCALLBACK -#define ZCALLBACK -#endif - -typedef void* (ZCALLBACK *open_file_func) (void *opaque, const char *filename, int mode); -typedef void* (ZCALLBACK *open64_file_func) (void *opaque, const void *filename, int mode); -typedef unsigned long (ZCALLBACK *read_file_func) (void *opaque, void *stream, void* buf, unsigned long size); -typedef unsigned long (ZCALLBACK *write_file_func) (void *opaque, void *stream, const void* buf, - unsigned long size); -typedef int (ZCALLBACK *close_file_func) (void *opaque, void *stream); -typedef int (ZCALLBACK *testerror_file_func)(void *opaque, void *stream); -typedef long (ZCALLBACK *tell_file_func) (void *opaque, void *stream); -typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (void *opaque, void *stream); -typedef long (ZCALLBACK *seek_file_func) (void *opaque, void *stream, unsigned long offset, int origin); -typedef long (ZCALLBACK *seek64_file_func) (void *opaque, void *stream, ZPOS64_T offset, int origin); - -typedef struct zlib_filefunc_def_s -{ - open_file_func zopen_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell_file_func ztell_file; - seek_file_func zseek_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - void* opaque; -} zlib_filefunc_def; - -typedef struct zlib_filefunc64_def_s -{ - open64_file_func zopen64_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell64_file_func ztell64_file; - seek64_file_func zseek64_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - void* opaque; -} zlib_filefunc64_def; - -/***************************************************************************/ - -#define ZLIB_FILEFUNC_SEEK_SET (0) -#define ZLIB_FILEFUNC_SEEK_CUR (1) -#define ZLIB_FILEFUNC_SEEK_END (2) - -#define ZLIB_FILEFUNC_MODE_READ (1) -#define ZLIB_FILEFUNC_MODE_WRITE (2) -#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) - -#define ZLIB_FILEFUNC_MODE_EXISTING (4) -#define ZLIB_FILEFUNC_MODE_CREATE (8) - -/***************************************************************************/ - -ZEXPORT void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def); -ZEXPORT void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def); -ZEXPORT void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def); -ZEXPORT void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def); -ZEXPORT void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def); -ZEXPORT void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def); - -/***************************************************************************/ - - -// SSZipArchive 2.x+ uses dos_date -#define MZ_COMPAT_VERSION 120 - -#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION <= 110 -#define mz_dos_date dosDate -#else -#define mz_dos_date dos_date -#endif - -typedef struct tm tm_unz; -typedef struct tm tm_zip; - -typedef struct { - struct tm tmz_date; /* date in understandable format */ - unsigned long mz_dos_date; /* if dos_date == 0, tmz_date is used */ - unsigned long internal_fa; /* internal file attributes 2 bytes */ - unsigned long external_fa; /* external file attributes 4 bytes */ -} zip_fileinfo; - -typedef const char *zipcharpc; - -/***************************************************************************/ - -#define ZIP_OK (0) -#define ZIP_EOF (0) -#define ZIP_ERRNO (-1) -#define ZIP_PARAMERROR (-102) -#define ZIP_BADZIPFILE (-103) -#define ZIP_INTERNALERROR (-104) - -#ifndef Z_DEFLATED -#define Z_DEFLATED 8 //removed () to suppress warning about ambiguous expansion of macro -SSZipArchive -#endif -#define Z_BZIP2ED (12) - -#define APPEND_STATUS_CREATE (0) -#define APPEND_STATUS_CREATEAFTER (1) -#define APPEND_STATUS_ADDINZIP (2) - -/***************************************************************************/ -/* Writing a zip file */ - -ZEXPORT zipFile zipOpen(const char *path, int append); -ZEXPORT zipFile zipOpen64(const void *path, int append); -ZEXPORT zipFile zipOpen2(const char *path, int append, const char **globalcomment, - zlib_filefunc_def *pzlib_filefunc_def); - -ZEXPORT zipFile zipOpen2_64(const void *path, int append, const char **globalcomment, - zlib_filefunc64_def *pzlib_filefunc_def); -ZEXPORT zipFile zipOpen_MZ(void *stream, int append, const char **globalcomment); - -ZEXPORT void* zipGetHandle_MZ(zipFile); -ZEXPORT void* zipGetStream_MZ(zipFile file); - -ZEXPORT int zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level); -ZEXPORT int zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int zip64); -ZEXPORT int zipOpenNewFileInZip_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int zip64); -ZEXPORT int zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw); -ZEXPORT int zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int zip64); -ZEXPORT int zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting); -ZEXPORT int zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting, int zip64); -ZEXPORT int zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting, unsigned long version_madeby, unsigned long flag_base); -ZEXPORT int zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting, unsigned long version_madeby, unsigned long flag_base, int zip64); -ZEXPORT int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo *zipfi, - const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, - uint16_t size_extrafield_global, const char *comment, int compression_method, int level, - int raw, int windowBits, int memLevel, int strategy, const char *password, - unsigned long crc_for_crypting, signed char aes, unsigned long version_madeby, unsigned long flag_base, int zip64); - -ZEXPORT int zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len); - -ZEXPORT int zipCloseFileInZipRaw(zipFile file, unsigned long uncompressed_size, unsigned long crc32); -ZEXPORT int zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, unsigned long crc32); -ZEXPORT int zipCloseFileInZip(zipFile file); -ZEXPORT int zipCloseFileInZip64(zipFile file); - -ZEXPORT int zipClose(zipFile file, const char *global_comment); -ZEXPORT int zipClose_64(zipFile file, const char *global_comment); -ZEXPORT int zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby); - int zipClose_MZ(zipFile file, const char *global_comment); - int zipClose2_MZ(zipFile file, const char *global_comment, uint16_t version_madeby); - -/***************************************************************************/ - -#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagunzFile__ { int unused; } unz_file__; -typedef unz_file__ *unzFile; -#else -typedef void *unzFile; -#endif - -/***************************************************************************/ - -#define UNZ_OK (0) -#define UNZ_END_OF_LIST_OF_FILE (-100) -#define UNZ_ERRNO (-1) -#define UNZ_EOF (0) -#define UNZ_PARAMERROR (-102) -#define UNZ_BADZIPFILE (-103) -#define UNZ_INTERNALERROR (-104) -#define UNZ_CRCERROR (-105) -#define UNZ_BADPASSWORD (-106) - -/***************************************************************************/ - -typedef struct unz_global_info64_s { - uint64_t number_entry; /* total number of entries in the central dir on this disk */ - unsigned long size_comment; /* size of the global comment of the zipfile */ - uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */ -} unz_global_info64; - -typedef struct unz_file_info64_s { - unsigned long version; /* version made by 2 bytes */ - unsigned long version_needed; /* version needed to extract 2 bytes */ - unsigned long flag; /* general purpose bit flag 2 bytes */ - unsigned long compression_method; /* compression method 2 bytes */ - unsigned long mz_dos_date; /* last mod file date in Dos fmt 4 bytes */ - unsigned long crc; /* crc-32 4 bytes */ - uint64_t compressed_size; /* compressed size 8 bytes */ - uint64_t uncompressed_size; /* uncompressed size 8 bytes */ - unsigned long size_filename; /* filename length 2 bytes */ - unsigned long size_file_extra; /* extra field length 2 bytes */ - unsigned long size_file_comment; /* file comment length 2 bytes */ - - unsigned long disk_num_start; /* disk number start 4 bytes */ - unsigned long internal_fa; /* internal file attributes 2 bytes */ - unsigned long external_fa; /* external file attributes 4 bytes */ - - struct tm tmu_date; - - uint64_t disk_offset; - - uint16_t size_file_extra_internal; -} unz_file_info64; - -/***************************************************************************/ - -#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION < 110 -/* Possible values: - 0 - Uses OS default, e.g. Windows ignores case. - 1 - Is case sensitive. - >= 2 - Ignore case. -*/ -typedef int unzFileNameCase; -#else -typedef int (*unzFileNameComparer)(unzFile file, const char* filename1, const char* filename2); -#endif -typedef int (*unzIteratorFunction)(unzFile file); -typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename, - uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, - uint16_t comment_size); - -/***************************************************************************/ -/* Reading a zip file */ - -ZEXPORT unzFile unzOpen(const char *path); -ZEXPORT unzFile unzOpen64(const void *path); -ZEXPORT unzFile unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def); -ZEXPORT unzFile unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def); - unzFile unzOpen_MZ(void *stream); - -ZEXPORT int unzClose(unzFile file); -ZEXPORT int unzClose_MZ(unzFile file); - -ZEXPORT void* unzGetHandle_MZ(unzFile file); -ZEXPORT void* unzGetStream_MZ(zipFile file); - -ZEXPORT int unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32); -ZEXPORT int unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info); -ZEXPORT int unzGetGlobalComment(unzFile file, char *comment, unsigned long comment_size); - -ZEXPORT int unzOpenCurrentFile(unzFile file); -ZEXPORT int unzOpenCurrentFilePassword(unzFile file, const char *password); -ZEXPORT int unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw); -ZEXPORT int unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password); -ZEXPORT int unzReadCurrentFile(unzFile file, void *buf, uint32_t len); -ZEXPORT int unzCloseCurrentFile(unzFile file); - -ZEXPORT int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename, - unsigned long filename_size, void *extrafield, unsigned long extrafield_size, char *comment, - unsigned long comment_size); -ZEXPORT int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile_info, char *filename, - unsigned long filename_size, void *extrafield, unsigned long extrafield_size, char *comment, - unsigned long comment_size); - -ZEXPORT int unzGoToFirstFile(unzFile file); -ZEXPORT int unzGoToNextFile(unzFile file); -#if !defined(MZ_COMPAT_VERSION) || MZ_COMPAT_VERSION < 110 -ZEXPORT int unzLocateFile(unzFile file, const char *filename, unzFileNameCase filename_case); -#else -ZEXPORT int unzLocateFile(unzFile file, const char* filename, unzFileNameComparer filename_compare_func); -#endif - -ZEXPORT int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len); - -/***************************************************************************/ -/* Raw access to zip file */ - -typedef struct unz_file_pos_s { - uint32_t pos_in_zip_directory; /* offset in zip file directory */ - uint32_t num_of_file; /* # of file */ -} unz_file_pos; - -ZEXPORT int unzGetFilePos(unzFile file, unz_file_pos *file_pos); -ZEXPORT int unzGoToFilePos(unzFile file, unz_file_pos *file_pos); - -typedef struct unz64_file_pos_s { - int64_t pos_in_zip_directory; /* offset in zip file directory */ - uint64_t num_of_file; /* # of file */ -} unz64_file_pos; - -ZEXPORT int unzGetFilePos64(unzFile file, unz64_file_pos *file_pos); -ZEXPORT int unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos); - -ZEXPORT int64_t unzGetOffset64(unzFile file); -ZEXPORT unsigned long - unzGetOffset(unzFile file); -ZEXPORT int unzSetOffset64(unzFile file, int64_t pos); -ZEXPORT int unzSetOffset(unzFile file, unsigned long pos); -ZEXPORT int32_t unztell(unzFile file); -ZEXPORT int32_t unzTell(unzFile file); -ZEXPORT uint64_t unztell64(unzFile file); -ZEXPORT uint64_t unzTell64(unzFile file); -ZEXPORT int unzSeek(unzFile file, int32_t offset, int origin); -ZEXPORT int unzSeek64(unzFile file, int64_t offset, int origin); -ZEXPORT int unzEndOfFile(unzFile file); -ZEXPORT int unzeof(unzFile file); -ZEXPORT void* unzGetStream(unzFile file); - -/***************************************************************************/ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/SSZipArchive/minizip/mz_crypt.c b/SSZipArchive/minizip/mz_crypt.c index 4c8d659..7a47ff2 100644 --- a/SSZipArchive/minizip/mz_crypt.c +++ b/SSZipArchive/minizip/mz_crypt.c @@ -34,61 +34,50 @@ 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) return (uint32_t)lzma_crc32(buf, (size_t)size, (uint32_t)value); #else static uint32_t crc32_table[256] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d - }; + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, + 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, + 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, + 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, + 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, + 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, + 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, + 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, + 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, + 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, + 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, + 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; value = ~value; while (size > 0) { @@ -103,8 +92,8 @@ uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size) } #if defined(HAVE_WZAES) -int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt, - int32_t salt_length, uint32_t iteration_count, uint8_t *key, uint16_t key_length) { +int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt, int32_t salt_length, + uint32_t iteration_count, uint8_t *key, uint16_t key_length) { void *hmac1 = NULL; void *hmac2 = NULL; void *hmac3 = NULL; diff --git a/SSZipArchive/minizip/mz_crypt.h b/SSZipArchive/minizip/mz_crypt.h index 1837af8..743cc3a 100644 --- a/SSZipArchive/minizip/mz_crypt.h +++ b/SSZipArchive/minizip/mz_crypt.h @@ -19,42 +19,42 @@ extern "C" { uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size); -int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt, - int32_t salt_length, uint32_t iteration_count, uint8_t *key, uint16_t key_length); +int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt, int32_t salt_length, + uint32_t iteration_count, uint8_t *key, uint16_t key_length); /***************************************************************************/ -int32_t mz_crypt_rand(uint8_t *buf, int32_t size); +int32_t mz_crypt_rand(uint8_t *buf, int32_t size); -void mz_crypt_sha_reset(void *handle); -int32_t mz_crypt_sha_begin(void *handle); -int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size); -int32_t mz_crypt_sha_end(void *handle, uint8_t *digest, int32_t digest_size); -int32_t mz_crypt_sha_set_algorithm(void *handle, uint16_t algorithm); -void* mz_crypt_sha_create(void); -void mz_crypt_sha_delete(void **handle); +void mz_crypt_sha_reset(void *handle); +int32_t mz_crypt_sha_begin(void *handle); +int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size); +int32_t mz_crypt_sha_end(void *handle, uint8_t *digest, int32_t digest_size); +int32_t mz_crypt_sha_set_algorithm(void *handle, uint16_t algorithm); +void *mz_crypt_sha_create(void); +void mz_crypt_sha_delete(void **handle); -void mz_crypt_aes_reset(void *handle); -int32_t mz_crypt_aes_encrypt(void *handle, const void *aad, int32_t aad_size, uint8_t *buf, int32_t size); -int32_t mz_crypt_aes_encrypt_final(void *handle, uint8_t *buf, int32_t size, uint8_t *tag, int32_t tag_size); -int32_t mz_crypt_aes_decrypt(void *handle, const void *aad, int32_t aad_size, uint8_t *buf, int32_t size); -int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, const uint8_t *tag, int32_t tag_size); -int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length, - const void *iv, int32_t iv_length); -int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length, - const void *iv, int32_t iv_length); -void mz_crypt_aes_set_mode(void *handle, int32_t mode); -void* mz_crypt_aes_create(void); -void mz_crypt_aes_delete(void **handle); +void mz_crypt_aes_reset(void *handle); +int32_t mz_crypt_aes_encrypt(void *handle, const void *aad, int32_t aad_size, uint8_t *buf, int32_t size); +int32_t mz_crypt_aes_encrypt_final(void *handle, uint8_t *buf, int32_t size, uint8_t *tag, int32_t tag_size); +int32_t mz_crypt_aes_decrypt(void *handle, const void *aad, int32_t aad_size, uint8_t *buf, int32_t size); +int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, const uint8_t *tag, int32_t tag_size); +int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length, const void *iv, + int32_t iv_length); +int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length, const void *iv, + int32_t iv_length); +void mz_crypt_aes_set_mode(void *handle, int32_t mode); +void *mz_crypt_aes_create(void); +void mz_crypt_aes_delete(void **handle); -void mz_crypt_hmac_reset(void *handle); -int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length); -int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size); -int32_t mz_crypt_hmac_end(void *handle, uint8_t *digest, int32_t digest_size); -int32_t mz_crypt_hmac_copy(void *src_handle, void *target_handle); -void mz_crypt_hmac_set_algorithm(void *handle, uint16_t algorithm); -void* mz_crypt_hmac_create(void); -void mz_crypt_hmac_delete(void **handle); +void mz_crypt_hmac_reset(void *handle); +int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length); +int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size); +int32_t mz_crypt_hmac_end(void *handle, uint8_t *digest, int32_t digest_size); +int32_t mz_crypt_hmac_copy(void *src_handle, void *target_handle); +void mz_crypt_hmac_set_algorithm(void *handle, uint16_t algorithm); +void *mz_crypt_hmac_create(void); +void mz_crypt_hmac_delete(void **handle); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_crypt_apple.c b/SSZipArchive/minizip/mz_crypt_apple.c index 8485c6a..e3a9c67 100644 --- a/SSZipArchive/minizip/mz_crypt_apple.c +++ b/SSZipArchive/minizip/mz_crypt_apple.c @@ -21,7 +21,7 @@ /***************************************************************************/ #ifndef MZ_TARGET_APPSTORE -#define MZ_TARGET_APPSTORE 1 +# define MZ_TARGET_APPSTORE 1 #endif /* Avoid use of private API for App Store as Apple does not allow it. Zip format doesn't need GCM. */ @@ -50,21 +50,19 @@ int32_t mz_crypt_rand(uint8_t *buf, int32_t size) { typedef struct mz_crypt_sha_s { union { - CC_SHA1_CTX ctx1; + CC_SHA1_CTX ctx1; CC_SHA256_CTX ctx256; CC_SHA512_CTX ctx512; }; - int32_t error; - int32_t initialized; - uint16_t algorithm; + int32_t error; + int32_t initialized; + uint16_t algorithm; } mz_crypt_sha; /***************************************************************************/ static const uint8_t mz_crypt_sha_digest_size[] = { - MZ_HASH_SHA1_SIZE, 0, MZ_HASH_SHA224_SIZE, - MZ_HASH_SHA256_SIZE, MZ_HASH_SHA384_SIZE, MZ_HASH_SHA512_SIZE -}; + MZ_HASH_SHA1_SIZE, 0, MZ_HASH_SHA224_SIZE, MZ_HASH_SHA256_SIZE, MZ_HASH_SHA384_SIZE, MZ_HASH_SHA512_SIZE}; /***************************************************************************/ @@ -205,8 +203,8 @@ void mz_crypt_sha_delete(void **handle) { typedef struct mz_crypt_aes_s { CCCryptorRef crypt; - int32_t mode; - int32_t error; + int32_t mode; + int32_t error; } mz_crypt_aes; /***************************************************************************/ @@ -347,8 +345,8 @@ int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, con #endif } -static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_length, - const void *iv, int32_t iv_length, CCOperation op) { +static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_length, const void *iv, + int32_t iv_length, CCOperation op) { mz_crypt_aes *aes = (mz_crypt_aes *)handle; CCMode mode; @@ -367,8 +365,8 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l mz_crypt_aes_reset(handle); - aes->error = CCCryptorCreateWithMode(op, mode, kCCAlgorithmAES, ccNoPadding, iv, key, key_length, - NULL, 0, 0, 0, &aes->crypt); + aes->error = CCCryptorCreateWithMode(op, mode, kCCAlgorithmAES, ccNoPadding, iv, key, key_length, NULL, 0, 0, 0, + &aes->crypt); if (aes->error != kCCSuccess) return MZ_HASH_ERROR; @@ -385,13 +383,13 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l return MZ_OK; } -int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length, - const void *iv, int32_t iv_length) { +int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length, const void *iv, + int32_t iv_length) { return mz_crypt_aes_set_key(handle, key, key_length, iv, iv_length, kCCEncrypt); } -int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length, - const void *iv, int32_t iv_length) { +int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length, const void *iv, + int32_t iv_length) { return mz_crypt_aes_set_key(handle, key, key_length, iv, iv_length, kCCDecrypt); } @@ -420,10 +418,10 @@ void mz_crypt_aes_delete(void **handle) { /***************************************************************************/ typedef struct mz_crypt_hmac_s { - CCHmacContext ctx; - int32_t initialized; - int32_t error; - uint16_t algorithm; + CCHmacContext ctx; + int32_t initialized; + int32_t error; + uint16_t algorithm; } mz_crypt_hmac; /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_os.c b/SSZipArchive/minizip/mz_os.c index 57b1722..d8dcbf9 100644 --- a/SSZipArchive/minizip/mz_os.c +++ b/SSZipArchive/minizip/mz_os.c @@ -136,12 +136,12 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) { while (*source != 0 && max_output > 1) { check = source; - if ((*check == '\\') || (*check == '/')) + if (*check == '\\' || *check == '/') check += 1; - if ((source == path) || (target == output) || (check != source)) { + if (source == path || target == output || check != source) { /* Skip double paths */ - if ((*check == '\\') || (*check == '/')) { + if (*check == '\\' || *check == '/') { source += 1; continue; } @@ -149,7 +149,7 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) { check += 1; /* Remove . if at end of string and not at the beginning */ - if ((*check == 0) && (source != path && target != output)) { + if (*check == 0 && source != path && target != output) { /* Copy last slash */ *target = *source; target += 1; @@ -158,7 +158,7 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) { continue; } /* Remove . if not at end of string */ - else if ((*check == '\\') || (*check == '/')) { + else if (*check == '\\' || *check == '/') { source += (check - source); /* Skip slash if at beginning of string */ if (target == output && *source != 0) @@ -168,14 +168,14 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) { /* Go to parent directory .. */ else if (*check == '.') { check += 1; - if ((*check == 0) || (*check == '\\' || *check == '/')) { + if (*check == 0 || (*check == '\\' || *check == '/')) { source += (check - source); /* Search backwards for previous slash or the start of the output string */ if (target != output) { target -= 1; do { - if ((target == output) ||(*target == '\\') || (*target == '/')) + if (target == output || *target == '\\' || *target == '/') break; target -= 1; @@ -183,9 +183,9 @@ int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) { } while (target > output); } - if ((target == output) && (*source != 0)) + if ((target == output) && *source != 0) source += 1; - if ((*target == '\\' || *target == '/') && (*source == 0)) + if ((*target == '\\' || *target == '/') && *source == 0) target += 1; *target = 0; diff --git a/SSZipArchive/minizip/mz_os.h b/SSZipArchive/minizip/mz_os.h index ad6ea4f..4db0550 100644 --- a/SSZipArchive/minizip/mz_os.h +++ b/SSZipArchive/minizip/mz_os.h @@ -37,15 +37,14 @@ extern "C" { # define MZ_VERSION_MADEBY_ZIP_VERSION (45) #endif -#define MZ_VERSION_MADEBY ((MZ_VERSION_MADEBY_HOST_SYSTEM << 8) | \ - (MZ_VERSION_MADEBY_ZIP_VERSION)) +#define MZ_VERSION_MADEBY ((MZ_VERSION_MADEBY_HOST_SYSTEM << 8) | (MZ_VERSION_MADEBY_ZIP_VERSION)) -#define MZ_PATH_SLASH_UNIX ('/') -#define MZ_PATH_SLASH_WINDOWS ('\\') +#define MZ_PATH_SLASH_UNIX ('/') +#define MZ_PATH_SLASH_WINDOWS ('\\') #if defined(_WIN32) -# define MZ_PATH_SLASH_PLATFORM (MZ_PATH_SLASH_WINDOWS) +# define MZ_PATH_SLASH_PLATFORM (MZ_PATH_SLASH_WINDOWS) #else -# define MZ_PATH_SLASH_PLATFORM (MZ_PATH_SLASH_UNIX) +# define MZ_PATH_SLASH_PLATFORM (MZ_PATH_SLASH_UNIX) #endif /***************************************************************************/ @@ -54,9 +53,9 @@ extern "C" { struct dirent { char d_name[256]; }; -typedef void* DIR; +typedef void *DIR; #else -#include +# include #endif /***************************************************************************/ @@ -104,64 +103,63 @@ int32_t mz_file_get_crc(const char *path, uint32_t *result_crc); wchar_t *mz_os_unicode_string_create(const char *string, int32_t encoding); /* Create unicode string from a utf8 string */ -void mz_os_unicode_string_delete(wchar_t **string); +void mz_os_unicode_string_delete(wchar_t **string); /* Delete a unicode string that was created */ -char *mz_os_utf8_string_create(const char *string, int32_t encoding); +char *mz_os_utf8_string_create(const char *string, int32_t encoding); /* Create a utf8 string from a string with another encoding */ -void mz_os_utf8_string_delete(char **string); +void mz_os_utf8_string_delete(char **string); /* Delete a utf8 string that was created */ -int32_t mz_os_rand(uint8_t *buf, int32_t size); +int32_t mz_os_rand(uint8_t *buf, int32_t size); /* Random number generator (not cryptographically secure) */ -int32_t mz_os_rename(const char *source_path, const char *target_path); +int32_t mz_os_rename(const char *source_path, const char *target_path); /* Rename a file */ -int32_t mz_os_unlink(const char *path); +int32_t mz_os_unlink(const char *path); /* Delete an existing file */ -int32_t mz_os_file_exists(const char *path); +int32_t mz_os_file_exists(const char *path); /* Check to see if a file exists */ -int64_t mz_os_get_file_size(const char *path); +int64_t mz_os_get_file_size(const char *path); /* Gets the length of a file */ -int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *accessed_date, time_t *creation_date); +int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *accessed_date, time_t *creation_date); /* Gets a file's modified, access, and creation dates if supported */ -int32_t mz_os_set_file_date(const char *path, time_t modified_date, time_t accessed_date, time_t creation_date); +int32_t mz_os_set_file_date(const char *path, time_t modified_date, time_t accessed_date, time_t creation_date); /* Sets a file's modified, access, and creation dates if supported */ -int32_t mz_os_get_file_attribs(const char *path, uint32_t *attributes); +int32_t mz_os_get_file_attribs(const char *path, uint32_t *attributes); /* Gets a file's attributes */ -int32_t mz_os_set_file_attribs(const char *path, uint32_t attributes); +int32_t mz_os_set_file_attribs(const char *path, uint32_t attributes); /* Sets a file's attributes */ -int32_t mz_os_make_dir(const char *path); +int32_t mz_os_make_dir(const char *path); /* Recursively creates a directory */ -DIR* mz_os_open_dir(const char *path); +DIR *mz_os_open_dir(const char *path); /* Opens a directory for listing */ -struct -dirent* mz_os_read_dir(DIR *dir); +struct dirent *mz_os_read_dir(DIR *dir); /* Reads a directory listing entry */ -int32_t mz_os_close_dir(DIR *dir); +int32_t mz_os_close_dir(DIR *dir); /* Closes a directory that has been opened for listing */ -int32_t mz_os_is_dir(const char *path); +int32_t mz_os_is_dir(const char *path); /* Checks to see if path is a directory */ -int32_t mz_os_is_symlink(const char *path); +int32_t mz_os_is_symlink(const char *path); /* Checks to see if path is a symbolic link */ -int32_t mz_os_make_symlink(const char *path, const char *target_path); +int32_t mz_os_make_symlink(const char *path, const char *target_path); /* Creates a symbolic link pointing to a target */ -int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_target_path); +int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_target_path); /* Gets the target path for a symbolic link */ uint64_t mz_os_ms_time(void); diff --git a/SSZipArchive/minizip/mz_os_posix.c b/SSZipArchive/minizip/mz_os_posix.c index 6736d09..6cbc434 100644 --- a/SSZipArchive/minizip/mz_os_posix.c +++ b/SSZipArchive/minizip/mz_os_posix.c @@ -15,7 +15,7 @@ #include /* rename */ #include #if defined(HAVE_ICONV) -#include +# include #endif #include #include @@ -75,8 +75,7 @@ char *mz_os_utf8_string_create(const char *string, int32_t encoding) { string_utf8_ptr = string_utf8; if (string_utf8) { - result = iconv(cd, (char **)&string, &string_length, - (char **)&string_utf8_ptr, &string_utf8_size); + result = iconv(cd, (char **)&string, &string_length, (char **)&string_utf8_ptr, &string_utf8_size); } iconv_close(cd); @@ -147,7 +146,7 @@ int32_t mz_os_rand(uint8_t *buf, int32_t size) { /* Ensure different random header each time */ if (++calls == 1) { - #define PI_SEED 3141592654UL +# define PI_SEED 3141592654UL srand((unsigned)(time(NULL) ^ PI_SEED)); } @@ -272,11 +271,11 @@ int32_t mz_os_make_dir(const char *path) { return MZ_OK; } -DIR* mz_os_open_dir(const char *path) { +DIR *mz_os_open_dir(const char *path) { return opendir(path); } -struct dirent* mz_os_read_dir(DIR *dir) { +struct dirent *mz_os_read_dir(DIR *dir) { if (!dir) return NULL; return readdir(dir); diff --git a/SSZipArchive/minizip/mz_strm.c b/SSZipArchive/minizip/mz_strm.c index edcbafa..f93198b 100644 --- a/SSZipArchive/minizip/mz_strm.c +++ b/SSZipArchive/minizip/mz_strm.c @@ -158,8 +158,8 @@ int32_t mz_stream_copy_to_end(void *target, void *source) { return mz_stream_copy_stream_to_end(target, NULL, source, NULL); } -int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source, - mz_stream_read_cb read_cb, int32_t len) { +int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source, mz_stream_read_cb read_cb, + int32_t len) { uint8_t buf[16384]; int32_t bytes_to_copy = 0; int32_t read = 0; @@ -187,7 +187,7 @@ int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *s } int32_t mz_stream_copy_stream_to_end(void *target, mz_stream_write_cb write_cb, void *source, - mz_stream_read_cb read_cb) { + mz_stream_read_cb read_cb) { uint8_t buf[16384]; int32_t read = 0; int32_t written = 0; @@ -253,8 +253,10 @@ int32_t mz_stream_find(void *stream, const void *find, int32_t find_size, int64_ start_pos = mz_stream_tell(stream); while (read_pos < max_seek) { - if (read_size > (int32_t)(max_seek - read_pos - buf_pos) && (max_seek - read_pos - buf_pos) < (int64_t)sizeof(buf)) + if (read_size > (int32_t)(max_seek - read_pos - buf_pos) && + (max_seek - read_pos - buf_pos) < (int64_t)sizeof(buf)) { read_size = (int32_t)(max_seek - read_pos - buf_pos); + } read = mz_stream_read(stream, buf + buf_pos, read_size); if ((read <= 0) || (read + buf_pos < find_size)) @@ -376,7 +378,7 @@ int32_t mz_stream_set_base(void *stream, void *base) { return MZ_OK; } -void* mz_stream_get_interface(void *stream) { +void *mz_stream_get_interface(void *stream) { mz_stream *strm = (mz_stream *)stream; if (!strm || !strm->vtbl) return NULL; @@ -416,10 +418,10 @@ void mz_stream_delete(void **stream) { /***************************************************************************/ typedef struct mz_stream_raw_s { - mz_stream stream; - int64_t total_in; - int64_t total_out; - int64_t max_total_in; + mz_stream stream; + int64_t total_in; + int64_t total_out; + int64_t max_total_in; } mz_stream_raw; /***************************************************************************/ @@ -517,19 +519,9 @@ int32_t mz_stream_raw_set_prop_int64(void *stream, int32_t prop, int64_t value) /***************************************************************************/ static mz_stream_vtbl mz_stream_raw_vtbl = { - mz_stream_raw_open, - mz_stream_raw_is_open, - mz_stream_raw_read, - mz_stream_raw_write, - mz_stream_raw_tell, - mz_stream_raw_seek, - mz_stream_raw_close, - mz_stream_raw_error, - mz_stream_raw_create, - mz_stream_raw_delete, - mz_stream_raw_get_prop_int64, - mz_stream_raw_set_prop_int64 -}; + mz_stream_raw_open, mz_stream_raw_is_open, mz_stream_raw_read, mz_stream_raw_write, + mz_stream_raw_tell, mz_stream_raw_seek, mz_stream_raw_close, mz_stream_raw_error, + mz_stream_raw_create, mz_stream_raw_delete, mz_stream_raw_get_prop_int64, mz_stream_raw_set_prop_int64}; /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm.h b/SSZipArchive/minizip/mz_strm.h index f65baab..5d09b7c 100644 --- a/SSZipArchive/minizip/mz_strm.h +++ b/SSZipArchive/minizip/mz_strm.h @@ -17,58 +17,58 @@ extern "C" { /***************************************************************************/ -#define MZ_STREAM_PROP_TOTAL_IN (1) -#define MZ_STREAM_PROP_TOTAL_IN_MAX (2) -#define MZ_STREAM_PROP_TOTAL_OUT (3) -#define MZ_STREAM_PROP_TOTAL_OUT_MAX (4) -#define MZ_STREAM_PROP_HEADER_SIZE (5) -#define MZ_STREAM_PROP_FOOTER_SIZE (6) -#define MZ_STREAM_PROP_DISK_SIZE (7) -#define MZ_STREAM_PROP_DISK_NUMBER (8) -#define MZ_STREAM_PROP_COMPRESS_LEVEL (9) -#define MZ_STREAM_PROP_COMPRESS_METHOD (10) -#define MZ_STREAM_PROP_COMPRESS_WINDOW (11) +#define MZ_STREAM_PROP_TOTAL_IN (1) +#define MZ_STREAM_PROP_TOTAL_IN_MAX (2) +#define MZ_STREAM_PROP_TOTAL_OUT (3) +#define MZ_STREAM_PROP_TOTAL_OUT_MAX (4) +#define MZ_STREAM_PROP_HEADER_SIZE (5) +#define MZ_STREAM_PROP_FOOTER_SIZE (6) +#define MZ_STREAM_PROP_DISK_SIZE (7) +#define MZ_STREAM_PROP_DISK_NUMBER (8) +#define MZ_STREAM_PROP_COMPRESS_LEVEL (9) +#define MZ_STREAM_PROP_COMPRESS_METHOD (10) +#define MZ_STREAM_PROP_COMPRESS_WINDOW (11) /***************************************************************************/ -typedef int32_t (*mz_stream_open_cb) (void *stream, const char *path, int32_t mode); -typedef int32_t (*mz_stream_is_open_cb) (void *stream); -typedef int32_t (*mz_stream_read_cb) (void *stream, void *buf, int32_t size); -typedef int32_t (*mz_stream_write_cb) (void *stream, const void *buf, int32_t size); -typedef int64_t (*mz_stream_tell_cb) (void *stream); -typedef int32_t (*mz_stream_seek_cb) (void *stream, int64_t offset, int32_t origin); -typedef int32_t (*mz_stream_close_cb) (void *stream); -typedef int32_t (*mz_stream_error_cb) (void *stream); -typedef void* (*mz_stream_create_cb) (void); -typedef void (*mz_stream_destroy_cb) (void **stream); +typedef int32_t (*mz_stream_open_cb)(void *stream, const char *path, int32_t mode); +typedef int32_t (*mz_stream_is_open_cb)(void *stream); +typedef int32_t (*mz_stream_read_cb)(void *stream, void *buf, int32_t size); +typedef int32_t (*mz_stream_write_cb)(void *stream, const void *buf, int32_t size); +typedef int64_t (*mz_stream_tell_cb)(void *stream); +typedef int32_t (*mz_stream_seek_cb)(void *stream, int64_t offset, int32_t origin); +typedef int32_t (*mz_stream_close_cb)(void *stream); +typedef int32_t (*mz_stream_error_cb)(void *stream); +typedef void *(*mz_stream_create_cb)(void); +typedef void (*mz_stream_destroy_cb)(void **stream); -typedef int32_t (*mz_stream_get_prop_int64_cb) (void *stream, int32_t prop, int64_t *value); -typedef int32_t (*mz_stream_set_prop_int64_cb) (void *stream, int32_t prop, int64_t value); +typedef int32_t (*mz_stream_get_prop_int64_cb)(void *stream, int32_t prop, int64_t *value); +typedef int32_t (*mz_stream_set_prop_int64_cb)(void *stream, int32_t prop, int64_t value); -typedef int32_t (*mz_stream_find_cb) (void *stream, const void *find, int32_t find_size, - int64_t max_seek, int64_t *position); +typedef int32_t (*mz_stream_find_cb)(void *stream, const void *find, int32_t find_size, int64_t max_seek, + int64_t *position); /***************************************************************************/ typedef struct mz_stream_vtbl_s { - mz_stream_open_cb open; - mz_stream_is_open_cb is_open; - mz_stream_read_cb read; - mz_stream_write_cb write; - mz_stream_tell_cb tell; - mz_stream_seek_cb seek; - mz_stream_close_cb close; - mz_stream_error_cb error; - mz_stream_create_cb create; - mz_stream_destroy_cb destroy; + mz_stream_open_cb open; + mz_stream_is_open_cb is_open; + mz_stream_read_cb read; + mz_stream_write_cb write; + mz_stream_tell_cb tell; + mz_stream_seek_cb seek; + mz_stream_close_cb close; + mz_stream_error_cb error; + mz_stream_create_cb create; + mz_stream_destroy_cb destroy; mz_stream_get_prop_int64_cb get_prop_int64; mz_stream_set_prop_int64_cb set_prop_int64; } mz_stream_vtbl; typedef struct mz_stream_s { - mz_stream_vtbl *vtbl; - struct mz_stream_s *base; + mz_stream_vtbl *vtbl; + struct mz_stream_s *base; } mz_stream; /***************************************************************************/ @@ -89,8 +89,10 @@ int32_t mz_stream_write_int64(void *stream, int64_t value); int32_t mz_stream_write_uint64(void *stream, uint64_t value); int32_t mz_stream_copy(void *target, void *source, int32_t len); int32_t mz_stream_copy_to_end(void *target, void *source); -int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source, mz_stream_read_cb read_cb, int32_t len); -int32_t mz_stream_copy_stream_to_end(void *target, mz_stream_write_cb write_cb, void *source, mz_stream_read_cb read_cb); +int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source, mz_stream_read_cb read_cb, + int32_t len); +int32_t mz_stream_copy_stream_to_end(void *target, mz_stream_write_cb write_cb, void *source, + mz_stream_read_cb read_cb); int64_t mz_stream_tell(void *stream); int32_t mz_stream_seek(void *stream, int64_t offset, int32_t origin); int32_t mz_stream_find(void *stream, const void *find, int32_t find_size, int64_t max_seek, int64_t *position); @@ -99,12 +101,12 @@ int32_t mz_stream_close(void *stream); int32_t mz_stream_error(void *stream); int32_t mz_stream_set_base(void *stream, void *base); -void* mz_stream_get_interface(void *stream); +void *mz_stream_get_interface(void *stream); int32_t mz_stream_get_prop_int64(void *stream, int32_t prop, int64_t *value); int32_t mz_stream_set_prop_int64(void *stream, int32_t prop, int64_t value); -void* mz_stream_create(mz_stream_vtbl *vtbl); -void mz_stream_delete(void **stream); +void *mz_stream_create(mz_stream_vtbl *vtbl); +void mz_stream_delete(void **stream); /***************************************************************************/ @@ -120,8 +122,8 @@ int32_t mz_stream_raw_error(void *stream); int32_t mz_stream_raw_get_prop_int64(void *stream, int32_t prop, int64_t *value); int32_t mz_stream_raw_set_prop_int64(void *stream, int32_t prop, int64_t value); -void* mz_stream_raw_create(void); -void mz_stream_raw_delete(void **stream); +void *mz_stream_raw_create(void); +void mz_stream_raw_delete(void **stream); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm_buf.c b/SSZipArchive/minizip/mz_strm_buf.c index 441b6f7..c844459 100644 --- a/SSZipArchive/minizip/mz_strm_buf.c +++ b/SSZipArchive/minizip/mz_strm_buf.c @@ -16,37 +16,35 @@ /***************************************************************************/ -static mz_stream_vtbl mz_stream_buffered_vtbl = { - mz_stream_buffered_open, - mz_stream_buffered_is_open, - mz_stream_buffered_read, - mz_stream_buffered_write, - mz_stream_buffered_tell, - mz_stream_buffered_seek, - mz_stream_buffered_close, - mz_stream_buffered_error, - mz_stream_buffered_create, - mz_stream_buffered_delete, - NULL, - NULL -}; +static mz_stream_vtbl mz_stream_buffered_vtbl = {mz_stream_buffered_open, + mz_stream_buffered_is_open, + mz_stream_buffered_read, + mz_stream_buffered_write, + mz_stream_buffered_tell, + mz_stream_buffered_seek, + mz_stream_buffered_close, + mz_stream_buffered_error, + mz_stream_buffered_create, + mz_stream_buffered_delete, + NULL, + NULL}; /***************************************************************************/ typedef struct mz_stream_buffered_s { mz_stream stream; - int32_t error; - char readbuf[INT16_MAX]; - int32_t readbuf_len; - int32_t readbuf_pos; - int32_t readbuf_hits; - int32_t readbuf_misses; - char writebuf[INT16_MAX]; - int32_t writebuf_len; - int32_t writebuf_pos; - int32_t writebuf_hits; - int32_t writebuf_misses; - int64_t position; + int32_t error; + char readbuf[INT16_MAX]; + int32_t readbuf_len; + int32_t readbuf_pos; + int32_t readbuf_hits; + int32_t readbuf_misses; + char writebuf[INT16_MAX]; + int32_t writebuf_len; + int32_t writebuf_pos; + int32_t writebuf_hits; + int32_t writebuf_misses; + int64_t position; } mz_stream_buffered; /***************************************************************************/ @@ -54,7 +52,7 @@ typedef struct mz_stream_buffered_s { #if 0 # define mz_stream_buffered_print printf #else -# define mz_stream_buffered_print(fmt,...) +# define mz_stream_buffered_print(fmt, ...) #endif /***************************************************************************/ @@ -93,16 +91,16 @@ static int32_t mz_stream_buffered_flush(void *stream, int32_t *written) { *written = 0; while (bytes_left_to_write > 0) { - bytes_written = mz_stream_write(buffered->stream.base, - buffered->writebuf + (bytes_to_write - bytes_left_to_write), bytes_left_to_write); + bytes_written = mz_stream_write( + buffered->stream.base, buffered->writebuf + (bytes_to_write - bytes_left_to_write), bytes_left_to_write); if (bytes_written != bytes_left_to_write) return MZ_WRITE_ERROR; buffered->writebuf_misses += 1; - mz_stream_buffered_print("Buffered - Write flush (%" PRId32 ":%" PRId32 " len %" PRId32 ")\n", - bytes_to_write, bytes_left_to_write, buffered->writebuf_len); + mz_stream_buffered_print("Buffered - Write flush (%" PRId32 ":%" PRId32 " len %" PRId32 ")\n", bytes_to_write, + bytes_left_to_write, buffered->writebuf_len); total_bytes_written += bytes_written; bytes_left_to_write -= bytes_written; @@ -128,7 +126,7 @@ int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size) { mz_stream_buffered_print("Buffered - Read (size %" PRId32 " pos %" PRId64 ")\n", size, buffered->position); if (buffered->writebuf_len > 0) { - int64_t position = buffered->position + buffered->writebuf_pos + int64_t position = buffered->position + buffered->writebuf_pos; mz_stream_buffered_print("Buffered - Switch from write to read, flushing (pos %" PRId64 ")\n", position); @@ -144,7 +142,8 @@ int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size) { } bytes_to_read = (int32_t)sizeof(buffered->readbuf) - (buffered->readbuf_len - buffered->readbuf_pos); - bytes_read = mz_stream_read(buffered->stream.base, buffered->readbuf + buffered->readbuf_pos, bytes_to_read); + bytes_read = + mz_stream_read(buffered->stream.base, buffered->readbuf + buffered->readbuf_pos, bytes_to_read); if (bytes_read < 0) return bytes_read; @@ -152,7 +151,8 @@ int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size) { buffered->readbuf_len += bytes_read; buffered->position += bytes_read; - mz_stream_buffered_print("Buffered - Filled (read %" PRId32 "/%" PRId32 " buf %" PRId32 ":%" PRId32 " pos %" PRId64 ")\n", + mz_stream_buffered_print( + "Buffered - Filled (read %" PRId32 "/%" PRId32 " buf %" PRId32 ":%" PRId32 " pos %" PRId64 ")\n", bytes_read, bytes_to_read, buffered->readbuf_pos, buffered->readbuf_len, buffered->position); if (bytes_read == 0) @@ -172,8 +172,10 @@ int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size) { buffered->readbuf_hits += 1; buffered->readbuf_pos += bytes_to_copy; - mz_stream_buffered_print("Buffered - Emptied (copied %" PRId32 " remaining %" PRId32 " buf %" PRId32 ":%" PRId32 " pos %" PRId64 ")\n", - bytes_to_copy, bytes_left_to_read, buffered->readbuf_pos, buffered->readbuf_len, buffered->position); + mz_stream_buffered_print("Buffered - Emptied (copied %" PRId32 " remaining %" PRId32 " buf %" PRId32 + ":%" PRId32 " pos %" PRId64 ")\n", + bytes_to_copy, bytes_left_to_read, buffered->readbuf_pos, buffered->readbuf_len, + buffered->position); } } @@ -189,9 +191,8 @@ int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size) { int32_t bytes_flushed = 0; int32_t err = MZ_OK; - - mz_stream_buffered_print("Buffered - Write (size %" PRId32 " len %" PRId32 " pos %" PRId64 ")\n", - size, buffered->writebuf_len, buffered->position); + mz_stream_buffered_print("Buffered - Write (size %" PRId32 " len %" PRId32 " pos %" PRId64 ")\n", size, + buffered->writebuf_len, buffered->position); if (buffered->readbuf_len > 0) { buffered->position -= buffered->readbuf_len; @@ -225,11 +226,12 @@ int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size) { continue; } - memcpy(buffered->writebuf + buffered->writebuf_pos, - (const char *)buf + (bytes_to_write - bytes_left_to_write), bytes_to_copy); + memcpy(buffered->writebuf + buffered->writebuf_pos, (const char *)buf + (bytes_to_write - bytes_left_to_write), + bytes_to_copy); - mz_stream_buffered_print("Buffered - Write copy (remaining %" PRId32 " write %" PRId32 ":%" PRId32 " len %" PRId32 ")\n", - bytes_to_copy, bytes_to_write, bytes_left_to_write, buffered->writebuf_len); + mz_stream_buffered_print("Buffered - Write copy (remaining %" PRId32 " write %" PRId32 ":%" PRId32 + " len %" PRId32 ")\n", + bytes_to_copy, bytes_to_write, bytes_left_to_write, buffered->writebuf_len); bytes_left_to_write -= bytes_to_copy; @@ -249,7 +251,7 @@ int64_t mz_stream_buffered_tell(void *stream) { buffered->position = position; mz_stream_buffered_print("Buffered - Tell (pos %" PRId64 " readpos %" PRId32 " writepos %" PRId32 ")\n", - buffered->position, buffered->readbuf_pos, buffered->writebuf_pos); + buffered->position, buffered->readbuf_pos, buffered->writebuf_pos); if (buffered->readbuf_len > 0) position -= ((int64_t)buffered->readbuf_len - buffered->readbuf_pos); @@ -263,8 +265,8 @@ int32_t mz_stream_buffered_seek(void *stream, int64_t offset, int32_t origin) { int32_t bytes_flushed = 0; int32_t err = MZ_OK; - mz_stream_buffered_print("Buffered - Seek (origin %" PRId32 " offset %" PRId64 " pos %" PRId64 ")\n", - origin, offset, buffered->position); + mz_stream_buffered_print("Buffered - Seek (origin %" PRId32 " offset %" PRId64 " pos %" PRId64 ")\n", origin, + offset, buffered->position); switch (origin) { case MZ_SEEK_SET: @@ -337,12 +339,14 @@ int32_t mz_stream_buffered_close(void *stream) { mz_stream_buffered_print("Buffered - Close (flushed %" PRId32 ")\n", bytes_flushed); if (buffered->readbuf_hits + buffered->readbuf_misses > 0) { - mz_stream_buffered_print("Buffered - Read efficiency %.02f%%\n", + mz_stream_buffered_print( + "Buffered - Read efficiency %.02f%%\n", (buffered->readbuf_hits / ((float)buffered->readbuf_hits + buffered->readbuf_misses)) * 100); } if (buffered->writebuf_hits + buffered->writebuf_misses > 0) { - mz_stream_buffered_print("Buffered - Write efficiency %.02f%%\n", + mz_stream_buffered_print( + "Buffered - Write efficiency %.02f%%\n", (buffered->writebuf_hits / ((float)buffered->writebuf_hits + buffered->writebuf_misses)) * 100); } diff --git a/SSZipArchive/minizip/mz_strm_buf.h b/SSZipArchive/minizip/mz_strm_buf.h index 9850090..61b382f 100644 --- a/SSZipArchive/minizip/mz_strm_buf.h +++ b/SSZipArchive/minizip/mz_strm_buf.h @@ -28,10 +28,10 @@ int32_t mz_stream_buffered_seek(void *stream, int64_t offset, int32_t origin); int32_t mz_stream_buffered_close(void *stream); int32_t mz_stream_buffered_error(void *stream); -void* mz_stream_buffered_create(void); -void mz_stream_buffered_delete(void **stream); +void *mz_stream_buffered_create(void); +void mz_stream_buffered_delete(void **stream); -void* mz_stream_buffered_get_interface(void); +void *mz_stream_buffered_get_interface(void); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm_mem.c b/SSZipArchive/minizip/mz_strm_mem.c index 45881b2..7ef07d5 100644 --- a/SSZipArchive/minizip/mz_strm_mem.c +++ b/SSZipArchive/minizip/mz_strm_mem.c @@ -22,31 +22,29 @@ /***************************************************************************/ -static mz_stream_vtbl mz_stream_mem_vtbl = { - mz_stream_mem_open, - mz_stream_mem_is_open, - mz_stream_mem_read, - mz_stream_mem_write, - mz_stream_mem_tell, - mz_stream_mem_seek, - mz_stream_mem_close, - mz_stream_mem_error, - mz_stream_mem_create, - mz_stream_mem_delete, - NULL, - NULL -}; +static mz_stream_vtbl mz_stream_mem_vtbl = {mz_stream_mem_open, + mz_stream_mem_is_open, + mz_stream_mem_read, + mz_stream_mem_write, + mz_stream_mem_tell, + mz_stream_mem_seek, + mz_stream_mem_close, + mz_stream_mem_error, + mz_stream_mem_create, + mz_stream_mem_delete, + NULL, + NULL}; /***************************************************************************/ typedef struct mz_stream_mem_s { - mz_stream stream; - int32_t mode; - uint8_t *buffer; /* Memory buffer pointer */ - int32_t size; /* Size of the memory buffer */ - int32_t limit; /* Furthest we've written */ - int32_t position; /* Current position in the memory */ - int32_t grow_size; /* Size to grow when full */ + mz_stream stream; + int32_t mode; + uint8_t *buffer; /* Memory buffer pointer */ + int32_t size; /* Size of the memory buffer */ + int32_t limit; /* Furthest we've written */ + int32_t position; /* Current position in the memory */ + int32_t grow_size; /* Size to grow when full */ } mz_stream_mem; /***************************************************************************/ @@ -211,7 +209,7 @@ int32_t mz_stream_mem_get_buffer(void *stream, const void **buf) { int32_t mz_stream_mem_get_buffer_at(void *stream, int64_t position, const void **buf) { mz_stream_mem *mem = (mz_stream_mem *)stream; - if (!buf || position < 0 || !mem->buffer|| mem->size < position) + if (!buf || position < 0 || !mem->buffer || mem->size < position) return MZ_SEEK_ERROR; *buf = mem->buffer + position; return MZ_OK; diff --git a/SSZipArchive/minizip/mz_strm_mem.h b/SSZipArchive/minizip/mz_strm_mem.h index ed6f957..1055634 100644 --- a/SSZipArchive/minizip/mz_strm_mem.h +++ b/SSZipArchive/minizip/mz_strm_mem.h @@ -26,18 +26,18 @@ int32_t mz_stream_mem_seek(void *stream, int64_t offset, int32_t origin); int32_t mz_stream_mem_close(void *stream); int32_t mz_stream_mem_error(void *stream); -void mz_stream_mem_set_buffer(void *stream, void *buf, int32_t size); +void mz_stream_mem_set_buffer(void *stream, void *buf, int32_t size); int32_t mz_stream_mem_get_buffer(void *stream, const void **buf); int32_t mz_stream_mem_get_buffer_at(void *stream, int64_t position, const void **buf); int32_t mz_stream_mem_get_buffer_at_current(void *stream, const void **buf); -void mz_stream_mem_get_buffer_length(void *stream, int32_t *length); -void mz_stream_mem_set_buffer_limit(void *stream, int32_t limit); -void mz_stream_mem_set_grow_size(void *stream, int32_t grow_size); +void mz_stream_mem_get_buffer_length(void *stream, int32_t *length); +void mz_stream_mem_set_buffer_limit(void *stream, int32_t limit); +void mz_stream_mem_set_grow_size(void *stream, int32_t grow_size); -void* mz_stream_mem_create(void); -void mz_stream_mem_delete(void **stream); +void *mz_stream_mem_create(void); +void mz_stream_mem_delete(void **stream); -void* mz_stream_mem_get_interface(void); +void *mz_stream_mem_get_interface(void); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm_os.h b/SSZipArchive/minizip/mz_strm_os.h index 0ed279f..d6846d8 100644 --- a/SSZipArchive/minizip/mz_strm_os.h +++ b/SSZipArchive/minizip/mz_strm_os.h @@ -26,10 +26,10 @@ int32_t mz_stream_os_seek(void *stream, int64_t offset, int32_t origin); int32_t mz_stream_os_close(void *stream); int32_t mz_stream_os_error(void *stream); -void* mz_stream_os_create(void); -void mz_stream_os_delete(void **stream); +void *mz_stream_os_create(void); +void mz_stream_os_delete(void **stream); -void* mz_stream_os_get_interface(void); +void *mz_stream_os_get_interface(void); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm_os_posix.c b/SSZipArchive/minizip/mz_strm_os_posix.c index b351ebb..f76b878 100644 --- a/SSZipArchive/minizip/mz_strm_os_posix.c +++ b/SSZipArchive/minizip/mz_strm_os_posix.c @@ -41,27 +41,25 @@ /***************************************************************************/ -static mz_stream_vtbl mz_stream_os_vtbl = { - mz_stream_os_open, - mz_stream_os_is_open, - mz_stream_os_read, - mz_stream_os_write, - mz_stream_os_tell, - mz_stream_os_seek, - mz_stream_os_close, - mz_stream_os_error, - mz_stream_os_create, - mz_stream_os_delete, - NULL, - NULL -}; +static mz_stream_vtbl mz_stream_os_vtbl = {mz_stream_os_open, + mz_stream_os_is_open, + mz_stream_os_read, + mz_stream_os_write, + mz_stream_os_tell, + mz_stream_os_seek, + mz_stream_os_close, + mz_stream_os_error, + mz_stream_os_create, + mz_stream_os_delete, + NULL, + NULL}; /***************************************************************************/ typedef struct mz_stream_posix_s { - mz_stream stream; - int32_t error; - FILE *handle; + mz_stream stream; + int32_t error; + FILE *handle; } mz_stream_posix; /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm_pkcrypt.c b/SSZipArchive/minizip/mz_strm_pkcrypt.c index 4116329..04fcb60 100644 --- a/SSZipArchive/minizip/mz_strm_pkcrypt.c +++ b/SSZipArchive/minizip/mz_strm_pkcrypt.c @@ -29,46 +29,35 @@ /***************************************************************************/ static mz_stream_vtbl mz_stream_pkcrypt_vtbl = { - mz_stream_pkcrypt_open, - mz_stream_pkcrypt_is_open, - mz_stream_pkcrypt_read, - mz_stream_pkcrypt_write, - mz_stream_pkcrypt_tell, - mz_stream_pkcrypt_seek, - mz_stream_pkcrypt_close, - mz_stream_pkcrypt_error, - mz_stream_pkcrypt_create, - mz_stream_pkcrypt_delete, - mz_stream_pkcrypt_get_prop_int64, - mz_stream_pkcrypt_set_prop_int64 -}; + mz_stream_pkcrypt_open, mz_stream_pkcrypt_is_open, mz_stream_pkcrypt_read, + mz_stream_pkcrypt_write, mz_stream_pkcrypt_tell, mz_stream_pkcrypt_seek, + mz_stream_pkcrypt_close, mz_stream_pkcrypt_error, mz_stream_pkcrypt_create, + mz_stream_pkcrypt_delete, mz_stream_pkcrypt_get_prop_int64, mz_stream_pkcrypt_set_prop_int64}; /***************************************************************************/ typedef struct mz_stream_pkcrypt_s { - mz_stream stream; - int32_t error; - int16_t initialized; - uint8_t buffer[UINT16_MAX]; - int64_t total_in; - int64_t max_total_in; - int64_t total_out; - uint32_t keys[3]; /* keys defining the pseudo-random sequence */ - uint8_t verify1; - uint8_t verify2; - uint16_t verify_version; - const char *password; + mz_stream stream; + int32_t error; + int16_t initialized; + uint8_t buffer[UINT16_MAX]; + int64_t total_in; + int64_t max_total_in; + int64_t total_out; + uint32_t keys[3]; /* keys defining the pseudo-random sequence */ + uint8_t verify1; + uint8_t verify2; + uint16_t verify_version; + const char *password; } mz_stream_pkcrypt; /***************************************************************************/ -#define mz_stream_pkcrypt_decode(strm, c) \ - (mz_stream_pkcrypt_update_keys(strm, \ - c ^= mz_stream_pkcrypt_decrypt_byte(strm))) +#define mz_stream_pkcrypt_decode(strm, c) \ + (mz_stream_pkcrypt_update_keys(strm, c ^= mz_stream_pkcrypt_decrypt_byte(strm))) -#define mz_stream_pkcrypt_encode(strm, c, t) \ - (t = mz_stream_pkcrypt_decrypt_byte(strm), \ - mz_stream_pkcrypt_update_keys(strm, (uint8_t)c), (uint8_t)(t^(c))) +#define mz_stream_pkcrypt_encode(strm, c, t) \ + (t = mz_stream_pkcrypt_decrypt_byte(strm), mz_stream_pkcrypt_update_keys(strm, (uint8_t)c), (uint8_t)(t ^ (c))) /***************************************************************************/ @@ -162,7 +151,7 @@ int32_t mz_stream_pkcrypt_open(void *stream, const char *path, int32_t mode) { verify1 = mz_stream_pkcrypt_decode(stream, header[i++]); verify2 = mz_stream_pkcrypt_decode(stream, header[i++]); - /* PKZIP 2.0 and higher use 1 byte check, older versions used 2 byte check. + /* PKZIP 2.0 and higher use 1 byte check, older versions used 2 byte check. See app note section 6.1.6. */ if (verify2 != pkcrypt->verify2) return MZ_PASSWORD_ERROR; diff --git a/SSZipArchive/minizip/mz_strm_pkcrypt.h b/SSZipArchive/minizip/mz_strm_pkcrypt.h index d9bdbaa..5c4f8d0 100644 --- a/SSZipArchive/minizip/mz_strm_pkcrypt.h +++ b/SSZipArchive/minizip/mz_strm_pkcrypt.h @@ -26,16 +26,16 @@ int32_t mz_stream_pkcrypt_seek(void *stream, int64_t offset, int32_t origin); int32_t mz_stream_pkcrypt_close(void *stream); int32_t mz_stream_pkcrypt_error(void *stream); -void mz_stream_pkcrypt_set_password(void *stream, const char *password); -void mz_stream_pkcrypt_set_verify(void *stream, uint8_t verify1, uint8_t verify2, uint16_t version); -void mz_stream_pkcrypt_get_verify(void *stream, uint8_t *verify1, uint8_t *verify2, uint16_t *version); +void mz_stream_pkcrypt_set_password(void *stream, const char *password); +void mz_stream_pkcrypt_set_verify(void *stream, uint8_t verify1, uint8_t verify2, uint16_t version); +void mz_stream_pkcrypt_get_verify(void *stream, uint8_t *verify1, uint8_t *verify2, uint16_t *version); int32_t mz_stream_pkcrypt_get_prop_int64(void *stream, int32_t prop, int64_t *value); int32_t mz_stream_pkcrypt_set_prop_int64(void *stream, int32_t prop, int64_t value); -void* mz_stream_pkcrypt_create(void); -void mz_stream_pkcrypt_delete(void **stream); +void *mz_stream_pkcrypt_create(void); +void mz_stream_pkcrypt_delete(void **stream); -void* mz_stream_pkcrypt_get_interface(void); +void *mz_stream_pkcrypt_get_interface(void); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm_split.c b/SSZipArchive/minizip/mz_strm_split.c index a50392c..b960f17 100644 --- a/SSZipArchive/minizip/mz_strm_split.c +++ b/SSZipArchive/minizip/mz_strm_split.c @@ -27,38 +27,28 @@ /***************************************************************************/ static mz_stream_vtbl mz_stream_split_vtbl = { - mz_stream_split_open, - mz_stream_split_is_open, - mz_stream_split_read, - mz_stream_split_write, - mz_stream_split_tell, - mz_stream_split_seek, - mz_stream_split_close, - mz_stream_split_error, - mz_stream_split_create, - mz_stream_split_delete, - mz_stream_split_get_prop_int64, - mz_stream_split_set_prop_int64 -}; + mz_stream_split_open, mz_stream_split_is_open, mz_stream_split_read, mz_stream_split_write, + mz_stream_split_tell, mz_stream_split_seek, mz_stream_split_close, mz_stream_split_error, + mz_stream_split_create, mz_stream_split_delete, mz_stream_split_get_prop_int64, mz_stream_split_set_prop_int64}; /***************************************************************************/ typedef struct mz_stream_split_s { - mz_stream stream; - int32_t is_open; - int64_t disk_size; - int64_t total_in; - int64_t total_in_disk; - int64_t total_out; - int64_t total_out_disk; - int32_t mode; - char *path_cd; - char *path_disk; - uint32_t path_disk_size; - int32_t number_disk; - int32_t current_disk; - int64_t current_disk_size; - int32_t reached_end; + mz_stream stream; + int32_t is_open; + int64_t disk_size; + int64_t total_in; + int64_t total_in_disk; + int64_t total_out; + int64_t total_out_disk; + int32_t mode; + char *path_cd; + char *path_disk; + uint32_t path_disk_size; + int32_t number_disk; + int32_t current_disk; + int64_t current_disk_size; + int32_t reached_end; } mz_stream_split; /***************************************************************************/ @@ -92,8 +82,7 @@ static int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk) { for (i = (int32_t)strlen(split->path_disk) - 1; i >= 0; i -= 1) { if (split->path_disk[i] != '.') continue; - snprintf(&split->path_disk[i], split->path_disk_size - (uint32_t)i, - ".z%02" PRId32, number_disk + 1); + snprintf(&split->path_disk[i], split->path_disk_size - (uint32_t)i, ".z%02" PRId32, number_disk + 1); break; } } else { @@ -243,10 +232,11 @@ int32_t mz_stream_split_read(void *stream, void *buf, int32_t size) { if (read == 0) { if (split->current_disk < 0) /* No more disks to goto */ break; + if (size != bytes_left) /* Report read from previous disk before switching */ + break; err = mz_stream_split_goto_disk(stream, split->current_disk + 1); - if (err == MZ_EXIST_ERROR) { + if (err == MZ_EXIST_ERROR) split->current_disk = -1; - } if (err != MZ_OK) return err; } diff --git a/SSZipArchive/minizip/mz_strm_split.h b/SSZipArchive/minizip/mz_strm_split.h index a5b74ed..2877f25 100644 --- a/SSZipArchive/minizip/mz_strm_split.h +++ b/SSZipArchive/minizip/mz_strm_split.h @@ -29,10 +29,10 @@ int32_t mz_stream_split_error(void *stream); int32_t mz_stream_split_get_prop_int64(void *stream, int32_t prop, int64_t *value); int32_t mz_stream_split_set_prop_int64(void *stream, int32_t prop, int64_t value); -void* mz_stream_split_create(void); -void mz_stream_split_delete(void **stream); +void *mz_stream_split_create(void); +void mz_stream_split_delete(void **stream); -void* mz_stream_split_get_interface(void); +void *mz_stream_split_get_interface(void); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm_wzaes.c b/SSZipArchive/minizip/mz_strm_wzaes.c index f1299c8..a0c9fac 100644 --- a/SSZipArchive/minizip/mz_strm_wzaes.c +++ b/SSZipArchive/minizip/mz_strm_wzaes.c @@ -27,38 +27,28 @@ /***************************************************************************/ static mz_stream_vtbl mz_stream_wzaes_vtbl = { - mz_stream_wzaes_open, - mz_stream_wzaes_is_open, - mz_stream_wzaes_read, - mz_stream_wzaes_write, - mz_stream_wzaes_tell, - mz_stream_wzaes_seek, - mz_stream_wzaes_close, - mz_stream_wzaes_error, - mz_stream_wzaes_create, - mz_stream_wzaes_delete, - mz_stream_wzaes_get_prop_int64, - mz_stream_wzaes_set_prop_int64 -}; + mz_stream_wzaes_open, mz_stream_wzaes_is_open, mz_stream_wzaes_read, mz_stream_wzaes_write, + mz_stream_wzaes_tell, mz_stream_wzaes_seek, mz_stream_wzaes_close, mz_stream_wzaes_error, + mz_stream_wzaes_create, mz_stream_wzaes_delete, mz_stream_wzaes_get_prop_int64, mz_stream_wzaes_set_prop_int64}; /***************************************************************************/ typedef struct mz_stream_wzaes_s { - mz_stream stream; - int32_t mode; - int32_t error; - int16_t initialized; - uint8_t buffer[UINT16_MAX]; - int64_t total_in; - int64_t max_total_in; - int64_t total_out; - uint8_t strength; - const char *password; - void *aes; - uint32_t crypt_pos; - uint8_t crypt_block[MZ_AES_BLOCK_SIZE]; - void *hmac; - uint8_t nonce[MZ_AES_BLOCK_SIZE]; + mz_stream stream; + int32_t mode; + int32_t error; + int16_t initialized; + uint8_t buffer[UINT16_MAX]; + int64_t total_in; + int64_t max_total_in; + int64_t total_out; + uint8_t strength; + const char *password; + void *aes; + uint32_t crypt_pos; + uint8_t crypt_block[MZ_AES_BLOCK_SIZE]; + void *hmac; + uint8_t nonce[MZ_AES_BLOCK_SIZE]; } mz_stream_wzaes; /***************************************************************************/ @@ -103,8 +93,8 @@ int32_t mz_stream_wzaes_open(void *stream, const char *path, int32_t mode) { } /* Derive the encryption and authentication keys and the password verifier */ - mz_crypt_pbkdf2((uint8_t *)password, password_length, salt_value, salt_length, - MZ_AES_KEYING_ITERATIONS, kbuf, 2 * key_length + MZ_AES_PW_VERIFY_SIZE); + mz_crypt_pbkdf2((uint8_t *)password, password_length, salt_value, salt_length, MZ_AES_KEYING_ITERATIONS, kbuf, + 2 * key_length + MZ_AES_PW_VERIFY_SIZE); /* Initialize the buffer pos */ wzaes->crypt_pos = MZ_AES_BLOCK_SIZE; diff --git a/SSZipArchive/minizip/mz_strm_wzaes.h b/SSZipArchive/minizip/mz_strm_wzaes.h index 788166e..ac20655 100644 --- a/SSZipArchive/minizip/mz_strm_wzaes.h +++ b/SSZipArchive/minizip/mz_strm_wzaes.h @@ -26,16 +26,16 @@ int32_t mz_stream_wzaes_seek(void *stream, int64_t offset, int32_t origin); int32_t mz_stream_wzaes_close(void *stream); int32_t mz_stream_wzaes_error(void *stream); -void mz_stream_wzaes_set_password(void *stream, const char *password); -void mz_stream_wzaes_set_strength(void *stream, uint8_t strength); +void mz_stream_wzaes_set_password(void *stream, const char *password); +void mz_stream_wzaes_set_strength(void *stream, uint8_t strength); int32_t mz_stream_wzaes_get_prop_int64(void *stream, int32_t prop, int64_t *value); int32_t mz_stream_wzaes_set_prop_int64(void *stream, int32_t prop, int64_t value); -void* mz_stream_wzaes_create(void); -void mz_stream_wzaes_delete(void **stream); +void *mz_stream_wzaes_create(void); +void mz_stream_wzaes_delete(void **stream); -void* mz_stream_wzaes_get_interface(void); +void *mz_stream_wzaes_get_interface(void); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_strm_zlib.c b/SSZipArchive/minizip/mz_strm_zlib.c index cba63fb..c6557de 100644 --- a/SSZipArchive/minizip/mz_strm_zlib.c +++ b/SSZipArchive/minizip/mz_strm_zlib.c @@ -21,53 +21,43 @@ /***************************************************************************/ #if !defined(ZLIB_COMPAT) -# define ZLIB_PREFIX(x) zng_ ## x - typedef zng_stream zlib_stream; +# define ZLIB_PREFIX(x) zng_##x +typedef zng_stream zlib_stream; #else # define ZLIB_PREFIX(x) x - typedef z_stream zlib_stream; +typedef z_stream zlib_stream; #endif #if !defined(DEF_MEM_LEVEL) # if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 # else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL +# define DEF_MEM_LEVEL MAX_MEM_LEVEL # endif #endif /***************************************************************************/ static mz_stream_vtbl mz_stream_zlib_vtbl = { - mz_stream_zlib_open, - mz_stream_zlib_is_open, - mz_stream_zlib_read, - mz_stream_zlib_write, - mz_stream_zlib_tell, - mz_stream_zlib_seek, - mz_stream_zlib_close, - mz_stream_zlib_error, - mz_stream_zlib_create, - mz_stream_zlib_delete, - mz_stream_zlib_get_prop_int64, - mz_stream_zlib_set_prop_int64 -}; + mz_stream_zlib_open, mz_stream_zlib_is_open, mz_stream_zlib_read, mz_stream_zlib_write, + mz_stream_zlib_tell, mz_stream_zlib_seek, mz_stream_zlib_close, mz_stream_zlib_error, + mz_stream_zlib_create, mz_stream_zlib_delete, mz_stream_zlib_get_prop_int64, mz_stream_zlib_set_prop_int64}; /***************************************************************************/ typedef struct mz_stream_zlib_s { - mz_stream stream; + mz_stream stream; zlib_stream zstream; - uint8_t buffer[INT16_MAX]; - int32_t buffer_len; - int64_t total_in; - int64_t total_out; - int64_t max_total_in; - int8_t initialized; - int16_t level; - int32_t window_bits; - int32_t mode; - int32_t error; + uint8_t buffer[INT16_MAX]; + int32_t buffer_len; + int64_t total_in; + int64_t total_out; + int64_t max_total_in; + int8_t initialized; + int16_t level; + int32_t window_bits; + int32_t mode; + int32_t error; } mz_stream_zlib; /***************************************************************************/ @@ -94,8 +84,8 @@ int32_t mz_stream_zlib_open(void *stream, const char *path, int32_t mode) { zlib->zstream.next_out = zlib->buffer; zlib->zstream.avail_out = sizeof(zlib->buffer); - zlib->error = ZLIB_PREFIX(deflateInit2)(&zlib->zstream, (int8_t)zlib->level, Z_DEFLATED, - zlib->window_bits, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); + zlib->error = ZLIB_PREFIX(deflateInit2)(&zlib->zstream, (int8_t)zlib->level, Z_DEFLATED, zlib->window_bits, + DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); #endif } else if (mode & MZ_OPEN_MODE_READ) { #ifdef MZ_ZIP_NO_DECOMPRESSION @@ -365,7 +355,7 @@ int32_t mz_stream_zlib_set_prop_int64(void *stream, int32_t prop, int64_t value) } void *mz_stream_zlib_create(void) { - mz_stream_zlib *zlib = zlib = (mz_stream_zlib *)calloc(1, sizeof(mz_stream_zlib)); + mz_stream_zlib *zlib = (mz_stream_zlib *)calloc(1, sizeof(mz_stream_zlib)); if (zlib) { zlib->stream.vtbl = &mz_stream_zlib_vtbl; zlib->level = Z_DEFAULT_COMPRESSION; diff --git a/SSZipArchive/minizip/mz_strm_zlib.h b/SSZipArchive/minizip/mz_strm_zlib.h index bba0991..89f10f2 100644 --- a/SSZipArchive/minizip/mz_strm_zlib.h +++ b/SSZipArchive/minizip/mz_strm_zlib.h @@ -29,10 +29,10 @@ int32_t mz_stream_zlib_error(void *stream); int32_t mz_stream_zlib_get_prop_int64(void *stream, int32_t prop, int64_t *value); int32_t mz_stream_zlib_set_prop_int64(void *stream, int32_t prop, int64_t value); -void* mz_stream_zlib_create(void); -void mz_stream_zlib_delete(void **stream); +void *mz_stream_zlib_create(void); +void mz_stream_zlib_delete(void **stream); -void* mz_stream_zlib_get_interface(void); +void *mz_stream_zlib_get_interface(void); /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_zip.c b/SSZipArchive/minizip/mz_zip.c index ba0307b..f232d2e 100644 --- a/SSZipArchive/minizip/mz_zip.c +++ b/SSZipArchive/minizip/mz_zip.c @@ -464,22 +464,22 @@ static int32_t mz_zip_entry_read_header(void *stream, uint8_t local, mz_zip_file file_info->linkname = ""; if (err == MZ_OK) { - mz_zip_print("Zip - Entry - Read header - %s (local %" PRId8 ")\n", - file_info->filename, local); + mz_zip_print("Zip - Entry - Read header - %s (local %" PRId8 ")\n", file_info->filename, local); mz_zip_print("Zip - Entry - Read header compress (ucs %" PRId64 " cs %" PRId64 " crc 0x%08" PRIx32 ")\n", - file_info->uncompressed_size, file_info->compressed_size, file_info->crc); + file_info->uncompressed_size, file_info->compressed_size, file_info->crc); if (!local) { mz_zip_print("Zip - Entry - Read header disk (disk %" PRIu32 " offset %" PRId64 ")\n", - file_info->disk_number, file_info->disk_offset); + file_info->disk_number, file_info->disk_offset); } mz_zip_print("Zip - Entry - Read header variable (fnl %" PRId32 " efs %" PRId32 " cms %" PRId32 ")\n", - file_info->filename_size, file_info->extrafield_size, file_info->comment_size); + file_info->filename_size, file_info->extrafield_size, file_info->comment_size); } return err; } -static int32_t mz_zip_entry_read_descriptor(void *stream, uint8_t zip64, uint32_t *crc32, int64_t *compressed_size, int64_t *uncompressed_size) { +static int32_t mz_zip_entry_read_descriptor(void *stream, uint8_t zip64, uint32_t *crc32, int64_t *compressed_size, + int64_t *uncompressed_size) { uint32_t value32 = 0; int64_t value64 = 0; int32_t err = MZ_OK; @@ -564,13 +564,11 @@ static int32_t mz_zip_entry_needs_zip64(mz_zip_file *file_info, uint8_t local, u max_uncompressed_size -= MZ_ZIP_UNCOMPR_SIZE64_CUSHION; } - needs_zip64 = (file_info->uncompressed_size >= max_uncompressed_size) || - (file_info->compressed_size >= UINT32_MAX); + needs_zip64 = (file_info->uncompressed_size >= max_uncompressed_size) || (file_info->compressed_size >= UINT32_MAX); if (!local) { /* Disk offset and number only used in central directory header */ - needs_zip64 |= (file_info->disk_offset >= UINT32_MAX) || - (file_info->disk_number >= UINT16_MAX); + needs_zip64 |= (file_info->disk_offset >= UINT32_MAX) || (file_info->disk_number >= UINT16_MAX); } if (file_info->zip64 == MZ_ZIP64_AUTO) { @@ -646,8 +644,7 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil file_extra_stream = mz_stream_mem_create(); if (!file_extra_stream) return MZ_MEM_ERROR; - mz_stream_mem_set_buffer(file_extra_stream, (void *)file_info->extrafield, - file_info->extrafield_size); + mz_stream_mem_set_buffer(file_extra_stream, (void *)file_info->extrafield, file_info->extrafield_size); do { err_mem = mz_stream_read_uint16(file_extra_stream, &field_type); @@ -682,9 +679,8 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil MZ_UNUSED(skip_aes); #endif /* NTFS timestamps */ - if ((file_info->modified_date != 0) && - (file_info->accessed_date != 0) && - (file_info->creation_date != 0) && (!mask)) { + if ((file_info->modified_date != 0) && (file_info->accessed_date != 0) && (file_info->creation_date != 0) && + (!mask)) { field_length_ntfs = 8 + 8 + 8 + 4 + 2 + 2; extrafield_size += 4 + field_length_ntfs; } @@ -747,8 +743,8 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil err = mz_zip_entry_write_crc_sizes(stream, zip64, mask, file_info); if (mask) { - snprintf(masked_name, sizeof(masked_name), "%" PRIx32 "_%" PRIx64, - file_info->disk_number, file_info->disk_offset); + snprintf(masked_name, sizeof(masked_name), "%" PRIx32 "_%" PRIx64, file_info->disk_number, + file_info->disk_offset); filename = masked_name; } else { filename = file_info->filename; @@ -799,8 +795,7 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil while ((err == MZ_OK) && (backslash = strchr(next, '\\'))) { int32_t part_length = (int32_t)(backslash - next); - if (mz_stream_write(stream, next, part_length) != part_length || - mz_stream_write(stream, "/", 1) != 1) + if (mz_stream_write(stream, next, part_length) != part_length || mz_stream_write(stream, "/", 1) != 1) err = MZ_WRITE_ERROR; left -= part_length + 1; @@ -922,7 +917,8 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil return err; } -static int32_t mz_zip_entry_write_descriptor(void *stream, uint8_t zip64, uint32_t crc32, int64_t compressed_size, int64_t uncompressed_size) { +static int32_t mz_zip_entry_write_descriptor(void *stream, uint8_t zip64, uint32_t crc32, int64_t compressed_size, + int64_t uncompressed_size) { int32_t err = MZ_OK; err = mz_stream_write_uint32(stream, MZ_ZIP_MAGIC_DATADESCRIPTOR); @@ -1063,7 +1059,7 @@ static int32_t mz_zip_read_cd(void *handle) { if (err == MZ_OK) { mz_zip_print("Zip - Read cd (disk %" PRId32 " entries %" PRId64 " offset %" PRId64 " size %" PRId64 ")\n", - zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size); + zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size); /* Verify central directory signature exists at offset */ err = mz_stream_seek(zip->stream, zip->cd_offset, MZ_SEEK_SET); @@ -1130,7 +1126,7 @@ static int32_t mz_zip_write_cd(void *handle) { err = mz_stream_copy(zip->stream, zip->cd_mem_stream, (int32_t)zip->cd_size); mz_zip_print("Zip - Write cd (disk %" PRId32 " entries %" PRId64 " offset %" PRId64 " size %" PRId64 ")\n", - zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size); + zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size); if (zip->cd_size == 0 && zip->number_entry > 0) { /* Zip does not contain central directory, open with recovery option */ @@ -1280,8 +1276,8 @@ static int32_t mz_zip_recover_cd(void *handle) { mz_stream_mem_open(local_file_info_stream, NULL, MZ_OPEN_MODE_CREATE); if (err == MZ_OK) { - err = mz_stream_find(zip->stream, (const void *)local_header_magic, sizeof(local_header_magic), - INT64_MAX, &next_header_pos); + err = mz_stream_find(zip->stream, (const void *)local_header_magic, sizeof(local_header_magic), INT64_MAX, + &next_header_pos); } while (err == MZ_OK && !eof) { @@ -1308,15 +1304,15 @@ static int32_t mz_zip_recover_cd(void *handle) { for (;;) { /* Search for the next local header */ - err = mz_stream_find(zip->stream, (const void *)local_header_magic, sizeof(local_header_magic), - INT64_MAX, &next_header_pos); + err = mz_stream_find(zip->stream, (const void *)local_header_magic, sizeof(local_header_magic), INT64_MAX, + &next_header_pos); if (err == MZ_EXIST_ERROR) { mz_stream_seek(zip->stream, compressed_pos, MZ_SEEK_SET); /* Search for central dir if no local header found */ err = mz_stream_find(zip->stream, (const void *)central_header_magic, sizeof(central_header_magic), - INT64_MAX, &next_header_pos); + INT64_MAX, &next_header_pos); if (err == MZ_EXIST_ERROR) { /* Get end of stream if no central header found */ @@ -1375,8 +1371,8 @@ static int32_t mz_zip_recover_cd(void *handle) { } mz_zip_print("Zip - Recover - Entry %s (csize %" PRId64 " usize %" PRId64 " flags 0x%" PRIx16 ")\n", - local_file_info.filename, local_file_info.compressed_size, local_file_info.uncompressed_size, - local_file_info.flag); + local_file_info.filename, local_file_info.compressed_size, local_file_info.uncompressed_size, + local_file_info.flag); /* Rewrite central dir with local headers and offsets */ err = mz_zip_entry_write_header(cd_mem_stream, 0, &local_file_info); @@ -1388,8 +1384,8 @@ static int32_t mz_zip_recover_cd(void *handle) { mz_stream_mem_delete(&local_file_info_stream); - mz_zip_print("Zip - Recover - Complete (cddisk %" PRId32 " entries %" PRId64 ")\n", - disk_number_with_cd, number_entry); + mz_zip_print("Zip - Recover - Complete (cddisk %" PRId32 " entries %" PRId64 ")\n", disk_number_with_cd, + number_entry); if (number_entry == 0) return err; @@ -1784,18 +1780,20 @@ static int32_t mz_zip_entry_open_int(void *handle, uint8_t raw, int16_t compress else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_DEFLATE || zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ) { zip->compress_stream = mz_stream_libcomp_create(); - if (zip->compress_stream) + if (zip->compress_stream) { mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_COMPRESS_METHOD, - zip->file_info.compression_method); + zip->file_info.compression_method); + } } #endif #ifdef HAVE_LZMA else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_LZMA || zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ) { zip->compress_stream = mz_stream_lzma_create(); - if (zip->compress_stream) + if (zip->compress_stream) { mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_COMPRESS_METHOD, - zip->file_info.compression_method); + zip->file_info.compression_method); + } } #endif #ifdef HAVE_ZSTD @@ -1816,8 +1814,7 @@ static int32_t mz_zip_entry_open_int(void *handle, uint8_t raw, int16_t compress int32_t set_end_of_stream = 0; #ifndef HAVE_LIBCOMP - if (zip->entry_raw || - zip->file_info.compression_method == MZ_COMPRESS_METHOD_STORE || + if (zip->entry_raw || zip->file_info.compression_method == MZ_COMPRESS_METHOD_STORE || zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) #endif { @@ -1843,8 +1840,10 @@ static int32_t mz_zip_entry_open_int(void *handle, uint8_t raw, int16_t compress } if (set_end_of_stream) { - mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, zip->file_info.compressed_size); - mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_OUT_MAX, zip->file_info.uncompressed_size); + mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, + zip->file_info.compressed_size); + mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_OUT_MAX, + zip->file_info.uncompressed_size); } } @@ -1913,7 +1912,8 @@ int32_t mz_zip_entry_read_open(void *handle, uint8_t raw, const char *password) return err; } -int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int16_t compress_level, uint8_t raw, const char *password) { +int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int16_t compress_level, uint8_t raw, + const char *password) { mz_zip *zip = (mz_zip *)handle; int64_t filename_pos = -1; int64_t extrafield_pos = 0; @@ -1938,8 +1938,8 @@ int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int1 memcpy(&zip->file_info, file_info, sizeof(mz_zip_file)); - mz_zip_print("Zip - Entry - Write open - %s (level %" PRId16 " raw %" PRId8 ")\n", - zip->file_info.filename, compress_level, raw); + mz_zip_print("Zip - Entry - Write open - %s (level %" PRId16 " raw %" PRId8 ")\n", zip->file_info.filename, + compress_level, raw); mz_stream_seek(zip->file_info_stream, 0, MZ_SEEK_SET); mz_stream_write(zip->file_info_stream, file_info, sizeof(mz_zip_file)); @@ -2064,12 +2064,10 @@ int32_t mz_zip_entry_write(void *handle, const void *buf, int32_t len) { zip->entry_crc32 = mz_crypt_crc32_update(zip->entry_crc32, buf, written); mz_zip_print("Zip - Entry - Write - %" PRId32 " (max %" PRId32 ")\n", written, len); - return written; } -int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size, - int64_t *uncompressed_size) { +int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size, int64_t *uncompressed_size) { mz_zip *zip = (mz_zip *)handle; int64_t total_in = 0; int32_t err = MZ_OK; @@ -2092,26 +2090,26 @@ int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compress mz_stream_get_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN, &total_in); if ((zip->file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR) && - ((zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO) == 0) && - (crc32 || compressed_size || uncompressed_size)) { + ((zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO) == 0) && (crc32 || compressed_size || uncompressed_size)) { /* Check to see if data descriptor is zip64 bit format or not */ - if (mz_zip_extrafield_contains(zip->local_file_info.extrafield, - zip->local_file_info.extrafield_size, MZ_ZIP_EXTENSION_ZIP64, NULL) == MZ_OK) + if (mz_zip_extrafield_contains(zip->local_file_info.extrafield, zip->local_file_info.extrafield_size, + MZ_ZIP_EXTENSION_ZIP64, NULL) == MZ_OK) { zip64 = 1; + } err = mz_zip_entry_seek_local_header(handle); /* Seek to end of compressed stream since we might have over-read during compression */ - if (err == MZ_OK) - err = mz_stream_seek(zip->stream, MZ_ZIP_SIZE_LD_ITEM + - (int64_t)zip->local_file_info.filename_size + - (int64_t)zip->local_file_info.extrafield_size + - total_in, MZ_SEEK_CUR); + if (err == MZ_OK) { + err = mz_stream_seek(zip->stream, + MZ_ZIP_SIZE_LD_ITEM + (int64_t)zip->local_file_info.filename_size + + (int64_t)zip->local_file_info.extrafield_size + total_in, + MZ_SEEK_CUR); + } /* Read data descriptor */ if (err == MZ_OK) - err = mz_zip_entry_read_descriptor(zip->stream, zip64, - crc32, compressed_size, uncompressed_size); + err = mz_zip_entry_read_descriptor(zip->stream, zip64, crc32, compressed_size, uncompressed_size); } /* If entire entry was not read verification will fail */ @@ -2123,7 +2121,7 @@ int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compress { if (zip->entry_crc32 != zip->file_info.crc) { mz_zip_print("Zip - Entry - Crc failed (actual 0x%08" PRIx32 " expected 0x%08" PRIx32 ")\n", - zip->entry_crc32, zip->file_info.crc); + zip->entry_crc32, zip->file_info.crc); err = MZ_CRC_ERROR; } @@ -2135,8 +2133,7 @@ int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compress return err; } -int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size, - int64_t uncompressed_size) { +int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size, int64_t uncompressed_size) { mz_zip *zip = (mz_zip *)handle; int64_t end_disk_number = 0; int32_t err = MZ_OK; @@ -2150,8 +2147,8 @@ int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compresse if (!zip->entry_raw) crc32 = zip->entry_crc32; - mz_zip_print("Zip - Entry - Write Close (crc 0x%08" PRIx32 " cs %" PRId64 " ucs %" PRId64 ")\n", - crc32, compressed_size, uncompressed_size); + mz_zip_print("Zip - Entry - Write Close (crc 0x%08" PRIx32 " cs %" PRId64 " ucs %" PRId64 ")\n", crc32, + compressed_size, uncompressed_size); /* If sizes are not set, then read them from the compression stream */ if (compressed_size < 0) @@ -2173,17 +2170,15 @@ int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compresse if local extrafield was saved with zip64 extrafield */ if (zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO) - err = mz_zip_entry_write_descriptor(zip->stream, - zip64, 0, compressed_size, 0); + err = mz_zip_entry_write_descriptor(zip->stream, zip64, 0, compressed_size, 0); else - err = mz_zip_entry_write_descriptor(zip->stream, - zip64, crc32, compressed_size, uncompressed_size); + err = mz_zip_entry_write_descriptor(zip->stream, zip64, crc32, compressed_size, uncompressed_size); } /* Write file info to central directory */ - mz_zip_print("Zip - Entry - Write cd (ucs %" PRId64 " cs %" PRId64 " crc 0x%08" PRIx32 ")\n", - uncompressed_size, compressed_size, crc32); + mz_zip_print("Zip - Entry - Write cd (ucs %" PRId64 " cs %" PRId64 " crc 0x%08" PRIx32 ")\n", uncompressed_size, + compressed_size, crc32); zip->file_info.crc = crc32; zip->file_info.compressed_size = compressed_size; @@ -2250,12 +2245,11 @@ int32_t mz_zip_entry_seek_local_header(void *handle) { mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, disk_number); - mz_zip_print("Zip - Entry - Seek local (disk %" PRId32 " offset %" PRId64 ")\n", - disk_number, zip->file_info.disk_offset); + mz_zip_print("Zip - Entry - Seek local (disk %" PRId32 " offset %" PRId64 ")\n", disk_number, + zip->file_info.disk_offset); /* Guard against seek overflows */ - if ((zip->disk_offset_shift > 0) && - (zip->file_info.disk_offset > (INT64_MAX - zip->disk_offset_shift))) + if ((zip->disk_offset_shift > 0) && (zip->file_info.disk_offset > (INT64_MAX - zip->disk_offset_shift))) return MZ_FORMAT_ERROR; return mz_stream_seek(zip->stream, zip->file_info.disk_offset + zip->disk_offset_shift, MZ_SEEK_SET); @@ -2522,14 +2516,17 @@ int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t targ *target_attrib = src_attrib; return MZ_OK; } - if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) + if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || + (target_sys == MZ_HOST_SYSTEM_RISCOS)) return mz_zip_attrib_win32_to_posix(src_attrib, target_attrib); - } else if ((src_sys == MZ_HOST_SYSTEM_UNIX) || (src_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (src_sys == MZ_HOST_SYSTEM_RISCOS)) { + } else if ((src_sys == MZ_HOST_SYSTEM_UNIX) || (src_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || + (src_sys == MZ_HOST_SYSTEM_RISCOS)) { /* If high bytes are set, it contains unix specific attributes */ if ((src_attrib >> 16) != 0) src_attrib >>= 16; - if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) { + if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || + (target_sys == MZ_HOST_SYSTEM_RISCOS)) { *target_attrib = src_attrib; return MZ_OK; } @@ -2548,16 +2545,16 @@ int32_t mz_zip_attrib_posix_to_win32(uint32_t posix_attrib, uint32_t *win32_attr /* S_IWUSR | S_IWGRP | S_IWOTH | S_IXUSR | S_IXGRP | S_IXOTH */ if ((posix_attrib & 0000333) == 0 && (posix_attrib & 0000444) != 0) - *win32_attrib |= 0x01; /* FILE_ATTRIBUTE_READONLY */ + *win32_attrib |= 0x01; /* FILE_ATTRIBUTE_READONLY */ /* S_IFLNK */ if ((posix_attrib & 0170000) == 0120000) - *win32_attrib |= 0x400; /* FILE_ATTRIBUTE_REPARSE_POINT */ + *win32_attrib |= 0x400; /* FILE_ATTRIBUTE_REPARSE_POINT */ /* S_IFDIR */ else if ((posix_attrib & 0170000) == 0040000) - *win32_attrib |= 0x10; /* FILE_ATTRIBUTE_DIRECTORY */ + *win32_attrib |= 0x10; /* FILE_ATTRIBUTE_DIRECTORY */ /* S_IFREG */ else - *win32_attrib |= 0x80; /* FILE_ATTRIBUTE_NORMAL */ + *win32_attrib |= 0x80; /* FILE_ATTRIBUTE_NORMAL */ return MZ_OK; } @@ -2566,18 +2563,18 @@ int32_t mz_zip_attrib_win32_to_posix(uint32_t win32_attrib, uint32_t *posix_attr if (!posix_attrib) return MZ_PARAM_ERROR; - *posix_attrib = 0000444; /* S_IRUSR | S_IRGRP | S_IROTH */ + *posix_attrib = 0000444; /* S_IRUSR | S_IRGRP | S_IROTH */ /* FILE_ATTRIBUTE_READONLY */ if ((win32_attrib & 0x01) == 0) - *posix_attrib |= 0000222; /* S_IWUSR | S_IWGRP | S_IWOTH */ + *posix_attrib |= 0000222; /* S_IWUSR | S_IWGRP | S_IWOTH */ /* FILE_ATTRIBUTE_REPARSE_POINT */ if ((win32_attrib & 0x400) == 0x400) - *posix_attrib |= 0120000; /* S_IFLNK */ + *posix_attrib |= 0120000; /* S_IFLNK */ /* FILE_ATTRIBUTE_DIRECTORY */ else if ((win32_attrib & 0x10) == 0x10) - *posix_attrib |= 0040111; /* S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH */ + *posix_attrib |= 0040111; /* S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH */ else - *posix_attrib |= 0100000; /* S_IFREG */ + *posix_attrib |= 0100000; /* S_IFREG */ return MZ_OK; } @@ -2615,8 +2612,8 @@ int32_t mz_zip_extrafield_find(void *stream, uint16_t type, int32_t max_seek, ui return MZ_EXIST_ERROR; } -int32_t mz_zip_extrafield_contains(const uint8_t *extrafield, int32_t extrafield_size, - uint16_t type, uint16_t *length) { +int32_t mz_zip_extrafield_contains(const uint8_t *extrafield, int32_t extrafield_size, uint16_t type, + uint16_t *length) { void *file_extra_stream = NULL; int32_t err = MZ_OK; @@ -2655,11 +2652,9 @@ int32_t mz_zip_extrafield_write(void *stream, uint16_t type, uint16_t length) { static int32_t mz_zip_invalid_date(const struct tm *ptm) { #define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max)) - return (!datevalue_in_range(0, 127 + 80, ptm->tm_year) || /* 1980-based year, allow 80 extra */ - !datevalue_in_range(0, 11, ptm->tm_mon) || - !datevalue_in_range(1, 31, ptm->tm_mday) || - !datevalue_in_range(0, 23, ptm->tm_hour) || - !datevalue_in_range(0, 59, ptm->tm_min) || + return (!datevalue_in_range(0, 127 + 80, ptm->tm_year) || /* 1980-based year, allow 80 extra */ + !datevalue_in_range(0, 11, ptm->tm_mon) || !datevalue_in_range(1, 31, ptm->tm_mday) || + !datevalue_in_range(0, 23, ptm->tm_hour) || !datevalue_in_range(0, 59, ptm->tm_min) || !datevalue_in_range(0, 59, ptm->tm_sec)); #undef datevalue_in_range } @@ -2667,12 +2662,12 @@ static int32_t mz_zip_invalid_date(const struct tm *ptm) { static void mz_zip_dosdate_to_raw_tm(uint64_t dos_date, struct tm *ptm) { uint64_t date = (uint64_t)(dos_date >> 16); - ptm->tm_mday = (uint16_t)(date & 0x1f); - ptm->tm_mon = (uint16_t)(((date & 0x1E0) / 0x20) - 1); - ptm->tm_year = (uint16_t)(((date & 0x0FE00) / 0x0200) + 80); - ptm->tm_hour = (uint16_t)((dos_date & 0xF800) / 0x800); - ptm->tm_min = (uint16_t)((dos_date & 0x7E0) / 0x20); - ptm->tm_sec = (uint16_t)(2 * (dos_date & 0x1f)); + ptm->tm_mday = (int16_t)(date & 0x1f); + ptm->tm_mon = (int16_t)(((date & 0x1E0) / 0x20) - 1); + ptm->tm_year = (int16_t)(((date & 0x0FE00) / 0x0200) + 80); + ptm->tm_hour = (int16_t)((dos_date & 0xF800) / 0x800); + ptm->tm_min = (int16_t)((dos_date & 0x7E0) / 0x20); + ptm->tm_sec = (int16_t)(2 * (dos_date & 0x1f)); ptm->tm_isdst = -1; } @@ -2693,7 +2688,11 @@ int32_t mz_zip_dosdate_to_tm(uint64_t dos_date, struct tm *ptm) { time_t mz_zip_dosdate_to_time_t(uint64_t dos_date) { struct tm ptm; mz_zip_dosdate_to_raw_tm(dos_date, &ptm); - return mktime(&ptm); + return mz_zip_tm_to_time_t(&ptm); +} + +time_t mz_zip_tm_to_time_t(struct tm *ptm) { + return mktime(ptm); } int32_t mz_zip_time_t_to_tm(time_t unix_time, struct tm *ptm) { @@ -2754,8 +2753,7 @@ int32_t mz_zip_unix_to_ntfs_time(time_t unix_time, uint64_t *ntfs_time) { int32_t mz_zip_path_compare(const char *path1, const char *path2, uint8_t ignore_case) { do { - if ((*path1 == '\\' && *path2 == '/') || - (*path2 == '\\' && *path1 == '/')) { + if ((*path1 == '\\' && *path2 == '/') || (*path2 == '\\' && *path1 == '/')) { /* Ignore comparison of path slashes */ } else if (ignore_case) { if (tolower(*path1) != tolower(*path2)) @@ -2776,8 +2774,7 @@ int32_t mz_zip_path_compare(const char *path1, const char *path2, uint8_t ignore /***************************************************************************/ -const char* mz_zip_get_compression_method_string(int32_t compression_method) -{ +const char *mz_zip_get_compression_method_string(int32_t compression_method) { const char *method = "?"; switch (compression_method) { case MZ_COMPRESS_METHOD_STORE: diff --git a/SSZipArchive/minizip/mz_zip.h b/SSZipArchive/minizip/mz_zip.h index cc01ee5..6f1ddec 100644 --- a/SSZipArchive/minizip/mz_zip.h +++ b/SSZipArchive/minizip/mz_zip.h @@ -23,34 +23,31 @@ extern "C" { /***************************************************************************/ typedef struct mz_zip_file_s { - uint16_t version_madeby; /* version made by */ - uint16_t version_needed; /* version needed to extract */ - uint16_t flag; /* general purpose bit flag */ - uint16_t compression_method; /* compression method */ - time_t modified_date; /* last modified date in unix time */ - time_t accessed_date; /* last accessed date in unix time */ - time_t creation_date; /* creation date in unix time */ - uint32_t crc; /* crc-32 */ - int64_t compressed_size; /* compressed size */ - int64_t uncompressed_size; /* uncompressed size */ - uint16_t filename_size; /* filename length */ - uint16_t extrafield_size; /* extra field length */ - uint16_t comment_size; /* file comment length */ - uint32_t disk_number; /* disk number start */ - int64_t disk_offset; /* relative offset of local header */ - uint16_t internal_fa; /* internal file attributes */ - uint32_t external_fa; /* external file attributes */ - - const char *filename; /* filename utf8 null-terminated string */ - const uint8_t *extrafield; /* extrafield data */ - const char *comment; /* comment utf8 null-terminated string */ - const char *linkname; /* sym-link filename utf8 null-terminated string */ - - uint16_t zip64; /* zip64 extension mode */ - uint16_t aes_version; /* winzip aes extension if not 0 */ - uint8_t aes_strength; /* winzip aes encryption strength */ - uint16_t pk_verify; /* pkware encryption verifier */ - + uint16_t version_madeby; /* version made by */ + uint16_t version_needed; /* version needed to extract */ + uint16_t flag; /* general purpose bit flag */ + uint16_t compression_method; /* compression method */ + time_t modified_date; /* last modified date in unix time */ + time_t accessed_date; /* last accessed date in unix time */ + time_t creation_date; /* creation date in unix time */ + uint32_t crc; /* crc-32 */ + int64_t compressed_size; /* compressed size */ + int64_t uncompressed_size; /* uncompressed size */ + uint16_t filename_size; /* filename length */ + uint16_t extrafield_size; /* extra field length */ + uint16_t comment_size; /* file comment length */ + uint32_t disk_number; /* disk number start */ + int64_t disk_offset; /* relative offset of local header */ + uint16_t internal_fa; /* internal file attributes */ + uint32_t external_fa; /* external file attributes */ + const char *filename; /* filename utf8 null-terminated string */ + const uint8_t *extrafield; /* extrafield data */ + const char *comment; /* comment utf8 null-terminated string */ + const char *linkname; /* sym-link filename utf8 null-terminated string */ + uint16_t zip64; /* zip64 extension mode */ + uint16_t aes_version; /* winzip aes extension if not 0 */ + uint8_t aes_strength; /* winzip aes encryption strength */ + uint16_t pk_verify; /* pkware encryption verifier */ } mz_zip_file, mz_zip_entry; /***************************************************************************/ @@ -59,10 +56,10 @@ typedef int32_t (*mz_zip_locate_entry_cb)(void *handle, void *userdata, mz_zip_f /***************************************************************************/ -void * mz_zip_create(void); +void *mz_zip_create(void); /* Create zip instance for opening */ -void mz_zip_delete(void **handle); +void mz_zip_delete(void **handle); /* Delete zip object */ int32_t mz_zip_open(void *handle, void *stream, int32_t mode); @@ -121,19 +118,17 @@ int32_t mz_zip_entry_read_open(void *handle, uint8_t raw, const char *password); int32_t mz_zip_entry_read(void *handle, void *buf, int32_t len); /* Read bytes from the current file in the zip file */ -int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size, - int64_t *uncompressed_size); +int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size, int64_t *uncompressed_size); /* Close the current file for reading and get data descriptor values */ -int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, - int16_t compress_level, uint8_t raw, const char *password); +int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int16_t compress_level, uint8_t raw, + const char *password); /* Open for writing the current file in the zip file */ int32_t mz_zip_entry_write(void *handle, const void *buf, int32_t len); /* Write bytes from the current file in the zip file */ -int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size, - int64_t uncompressed_size); +int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size, int64_t uncompressed_size); /* Close the current file for writing and set data descriptor values */ int32_t mz_zip_entry_seek_local_header(void *handle); @@ -194,8 +189,7 @@ int32_t mz_zip_attrib_is_dir(uint32_t attrib, int32_t version_madeby); int32_t mz_zip_attrib_is_symlink(uint32_t attrib, int32_t version_madeby); /* Checks to see if the attribute is a symbolic link based on platform */ -int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys, - uint32_t *target_attrib); +int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys, uint32_t *target_attrib); /* Converts file attributes from one host system to another */ int32_t mz_zip_attrib_posix_to_win32(uint32_t posix_attrib, uint32_t *win32_attrib); @@ -209,8 +203,7 @@ int32_t mz_zip_attrib_win32_to_posix(uint32_t win32_attrib, uint32_t *posix_attr int32_t mz_zip_extrafield_find(void *stream, uint16_t type, int32_t max_seek, uint16_t *length); /* Seeks to extra field by its type and returns its length */ -int32_t mz_zip_extrafield_contains(const uint8_t *extrafield, int32_t extrafield_size, - uint16_t type, uint16_t *length); +int32_t mz_zip_extrafield_contains(const uint8_t *extrafield, int32_t extrafield_size, uint16_t type, uint16_t *length); /* Gets whether an extrafield exists and its size */ int32_t mz_zip_extrafield_read(void *stream, uint16_t *type, uint16_t *length); @@ -221,13 +214,16 @@ int32_t mz_zip_extrafield_write(void *stream, uint16_t type, uint16_t length); /***************************************************************************/ -int32_t mz_zip_dosdate_to_tm(uint64_t dos_date, struct tm *ptm); +int32_t mz_zip_dosdate_to_tm(uint64_t dos_date, struct tm *ptm); /* Convert dos date/time format to struct tm */ -time_t mz_zip_dosdate_to_time_t(uint64_t dos_date); +time_t mz_zip_dosdate_to_time_t(uint64_t dos_date); /* Convert dos date/time format to time_t */ -int32_t mz_zip_time_t_to_tm(time_t unix_time, struct tm *ptm); +time_t mz_zip_tm_to_time_t(struct tm *ptm); +/* Convert time struct to time_t */ + +int32_t mz_zip_time_t_to_tm(time_t unix_time, struct tm *ptm); /* Convert time_t to time struct */ uint32_t mz_zip_time_t_to_dos_date(time_t unix_time); @@ -236,21 +232,20 @@ uint32_t mz_zip_time_t_to_dos_date(time_t unix_time); uint32_t mz_zip_tm_to_dosdate(const struct tm *ptm); /* Convert struct tm to dos date/time format */ -int32_t mz_zip_ntfs_to_unix_time(uint64_t ntfs_time, time_t *unix_time); +int32_t mz_zip_ntfs_to_unix_time(uint64_t ntfs_time, time_t *unix_time); /* Convert ntfs time to unix time */ -int32_t mz_zip_unix_to_ntfs_time(time_t unix_time, uint64_t *ntfs_time); +int32_t mz_zip_unix_to_ntfs_time(time_t unix_time, uint64_t *ntfs_time); /* Convert unix time to ntfs time */ /***************************************************************************/ -int32_t mz_zip_path_compare(const char *path1, const char *path2, uint8_t ignore_case); +int32_t mz_zip_path_compare(const char *path1, const char *path2, uint8_t ignore_case); /* Compare two paths without regard to slashes */ /***************************************************************************/ -const -char* mz_zip_get_compression_method_string(int32_t compression_method); +const char *mz_zip_get_compression_method_string(int32_t compression_method); /* Gets a string representing the compression method */ /***************************************************************************/ diff --git a/SSZipArchive/minizip/mz_zip_rw.c b/SSZipArchive/minizip/mz_zip_rw.c index d7c60b5..7b7654a 100644 --- a/SSZipArchive/minizip/mz_zip_rw.c +++ b/SSZipArchive/minizip/mz_zip_rw.c @@ -30,39 +30,35 @@ /***************************************************************************/ typedef struct mz_zip_reader_s { - void *zip_handle; - void *file_stream; - void *buffered_stream; - void *split_stream; - void *mem_stream; - void *hash; - uint16_t hash_algorithm; - uint16_t hash_digest_size; + void *zip_handle; + void *file_stream; + void *buffered_stream; + void *split_stream; + void *mem_stream; + void *hash; + uint16_t hash_algorithm; + uint16_t hash_digest_size; mz_zip_file *file_info; - const char *pattern; - uint8_t pattern_ignore_case; - const char *password; - void *overwrite_userdata; - mz_zip_reader_overwrite_cb - overwrite_cb; - void *password_userdata; - mz_zip_reader_password_cb - password_cb; - void *progress_userdata; - mz_zip_reader_progress_cb - progress_cb; - uint32_t progress_cb_interval_ms; - void *entry_userdata; - mz_zip_reader_entry_cb - entry_cb; - uint8_t raw; - uint8_t buffer[UINT16_MAX]; - int32_t encoding; - uint8_t sign_required; - uint8_t cd_verified; - uint8_t cd_zipped; - uint8_t entry_verified; - uint8_t recover; + const char *pattern; + uint8_t pattern_ignore_case; + const char *password; + void *overwrite_userdata; + mz_zip_reader_overwrite_cb overwrite_cb; + void *password_userdata; + mz_zip_reader_password_cb password_cb; + void *progress_userdata; + mz_zip_reader_progress_cb progress_cb; + uint32_t progress_cb_interval_ms; + void *entry_userdata; + mz_zip_reader_entry_cb entry_cb; + uint8_t raw; + uint8_t buffer[UINT16_MAX]; + int32_t encoding; + uint8_t sign_required; + uint8_t cd_verified; + uint8_t cd_zipped; + uint8_t entry_verified; + uint8_t recover; } mz_zip_reader; /***************************************************************************/ @@ -282,9 +278,10 @@ int32_t mz_zip_reader_unzip_cd(void *handle) { mz_stream_mem_open(cd_mem_stream, NULL, MZ_OPEN_MODE_CREATE); err = mz_stream_seek(cd_mem_stream, 0, MZ_SEEK_SET); - if (err == MZ_OK) + if (err == MZ_OK) { err = mz_stream_copy_stream(cd_mem_stream, NULL, handle, mz_zip_reader_entry_read, - (int32_t)cd_info->uncompressed_size); + (int32_t)cd_info->uncompressed_size); + } if (err == MZ_OK) { reader->cd_zipped = 1; @@ -394,8 +391,7 @@ int32_t mz_zip_reader_entry_open(void *handle) { /* Check if we need a password and ask for it if we need to */ if (!password && reader->password_cb && (reader->file_info->flag & MZ_ZIP_FLAG_ENCRYPTED)) { - reader->password_cb(handle, reader->password_userdata, reader->file_info, - password_buf, sizeof(password_buf)); + reader->password_cb(handle, reader->password_userdata, reader->file_info, password_buf, sizeof(password_buf)); password = password_buf; } @@ -480,7 +476,7 @@ int32_t mz_zip_reader_entry_get_hash(void *handle, uint16_t algorithm, uint8_t * return MZ_MEM_ERROR; mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield, - reader->file_info->extrafield_size); + reader->file_info->extrafield_size); do { err = mz_zip_extrafield_find(file_extra_stream, MZ_ZIP_EXTENSION_HASH, INT32_MAX, NULL); @@ -521,7 +517,7 @@ int32_t mz_zip_reader_entry_get_first_hash(void *handle, uint16_t *algorithm, ui return MZ_MEM_ERROR; mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield, - reader->file_info->extrafield_size); + reader->file_info->extrafield_size); err = mz_zip_extrafield_find(file_extra_stream, MZ_ZIP_EXTENSION_HASH, INT32_MAX, NULL); if (err == MZ_OK) @@ -650,7 +646,6 @@ int32_t mz_zip_reader_entry_save_file(void *handle, const char *path) { int32_t err_attrib = 0; int32_t err = MZ_OK; int32_t err_cb = MZ_OK; - size_t path_length = 0; char *pathwfs = NULL; char *directory = NULL; @@ -659,27 +654,22 @@ int32_t mz_zip_reader_entry_save_file(void *handle, const char *path) { if (!reader->file_info || !path) return MZ_PARAM_ERROR; - path_length = strlen(path); - /* Convert to forward slashes for unix which doesn't like backslashes */ - pathwfs = (char *)calloc(path_length + 1, sizeof(char)); + pathwfs = (char *)strdup(path); if (!pathwfs) return MZ_MEM_ERROR; - strncat(pathwfs, path, path_length); mz_path_convert_slashes(pathwfs, MZ_PATH_SLASH_UNIX); if (reader->entry_cb) reader->entry_cb(handle, reader->entry_userdata, reader->file_info, pathwfs); - directory = (char *)calloc(path_length + 1, sizeof(char)); + directory = (char *)strdup(pathwfs); if (!directory) return MZ_MEM_ERROR; - strncat(directory, pathwfs, path_length); mz_path_remove_filename(directory); /* If it is a directory entry then create a directory instead of writing file */ - if ((mz_zip_entry_is_dir(reader->zip_handle) == MZ_OK) && - (mz_zip_entry_is_symlink(reader->zip_handle) != MZ_OK)) { + if ((mz_zip_entry_is_dir(reader->zip_handle) == MZ_OK) && (mz_zip_entry_is_symlink(reader->zip_handle) != MZ_OK)) { err = mz_dir_make(directory); goto save_cleanup; } @@ -694,8 +684,7 @@ int32_t mz_zip_reader_entry_save_file(void *handle, const char *path) { } /* If symbolic link then properly construct destination path and link path */ - if ((mz_zip_entry_is_symlink(reader->zip_handle) == MZ_OK) && - (mz_path_has_slash(pathwfs) == MZ_OK)) { + if ((mz_zip_entry_is_symlink(reader->zip_handle) == MZ_OK) && (mz_path_has_slash(pathwfs) == MZ_OK)) { mz_path_remove_slash(pathwfs); mz_path_remove_filename(directory); } @@ -759,8 +748,8 @@ int32_t mz_zip_reader_entry_save_file(void *handle, const char *path) { if (err == MZ_OK) { /* Set the time of the file that has been created */ - mz_os_set_file_date(pathwfs, reader->file_info->modified_date, - reader->file_info->accessed_date, reader->file_info->creation_date); + mz_os_set_file_date(pathwfs, reader->file_info->modified_date, reader->file_info->accessed_date, + reader->file_info->creation_date); } if (err == MZ_OK) { @@ -829,7 +818,7 @@ int32_t mz_zip_reader_save_all(void *handle, const char *destination_dir) { char *path = NULL; char *utf8_name = NULL; char *resolved_name = NULL; - char* new_alloc = NULL; + char *new_alloc = NULL; err = mz_zip_reader_goto_first_entry(handle); @@ -859,7 +848,7 @@ int32_t mz_zip_reader_save_all(void *handle, const char *destination_dir) { } utf8_name = new_alloc; new_alloc = (char *)realloc(resolved_name, resolved_name_size); - if ( !new_alloc) { + if (!new_alloc) { err = MZ_MEM_ERROR; goto save_all_cleanup; } @@ -1028,38 +1017,34 @@ void mz_zip_reader_delete(void **handle) { /***************************************************************************/ typedef struct mz_zip_writer_s { - void *zip_handle; - void *file_stream; - void *buffered_stream; - void *split_stream; - void *hash; - uint16_t hash_algorithm; - void *mem_stream; - void *file_extra_stream; + void *zip_handle; + void *file_stream; + void *buffered_stream; + void *split_stream; + void *hash; + uint16_t hash_algorithm; + void *mem_stream; + void *file_extra_stream; mz_zip_file file_info; - void *overwrite_userdata; - mz_zip_writer_overwrite_cb - overwrite_cb; - void *password_userdata; - mz_zip_writer_password_cb - password_cb; - void *progress_userdata; - mz_zip_writer_progress_cb - progress_cb; - uint32_t progress_cb_interval_ms; - void *entry_userdata; - mz_zip_writer_entry_cb - entry_cb; - const char *password; - const char *comment; - uint16_t compress_method; - int16_t compress_level; - uint8_t follow_links; - uint8_t store_links; - uint8_t zip_cd; - uint8_t aes; - uint8_t raw; - uint8_t buffer[UINT16_MAX]; + void *overwrite_userdata; + mz_zip_writer_overwrite_cb overwrite_cb; + void *password_userdata; + mz_zip_writer_password_cb password_cb; + void *progress_userdata; + mz_zip_writer_progress_cb progress_cb; + uint32_t progress_cb_interval_ms; + void *entry_userdata; + mz_zip_writer_entry_cb entry_cb; + const char *password; + const char *comment; + uint16_t compress_method; + int16_t compress_level; + uint8_t follow_links; + uint8_t store_links; + uint8_t zip_cd; + uint8_t aes; + uint8_t raw; + uint8_t buffer[UINT16_MAX]; } mz_zip_writer; /***************************************************************************/ @@ -1108,8 +1093,7 @@ int32_t mz_zip_writer_zip_cd(void *handle) { err = mz_zip_writer_entry_open(handle, &cd_file); if (err == MZ_OK) { - mz_stream_copy_stream(handle, mz_zip_writer_entry_write, cd_mem_stream, - NULL, (int32_t)cd_mem_length); + mz_stream_copy_stream(handle, mz_zip_writer_entry_write, cd_mem_stream, NULL, (int32_t)cd_mem_length); mz_stream_seek(cd_mem_stream, 0, MZ_SEEK_SET); mz_stream_mem_set_buffer_limit(cd_mem_stream, 0); @@ -1326,8 +1310,7 @@ int32_t mz_zip_writer_entry_open(void *handle, mz_zip_file *file_info) { /* Check if we need a password and ask for it if we need to */ if (!password && writer->password_cb && (writer->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED)) { - writer->password_cb(handle, writer->password_userdata, &writer->file_info, - password_buf, sizeof(password_buf)); + writer->password_cb(handle, writer->password_userdata, &writer->file_info, password_buf, sizeof(password_buf)); password = password_buf; } @@ -1349,8 +1332,10 @@ int32_t mz_zip_writer_entry_open(void *handle, mz_zip_file *file_info) { #endif /* Open entry in zip */ - err = mz_zip_entry_write_open(writer->zip_handle, &writer->file_info, writer->compress_level, - writer->raw, password); + if (err == MZ_OK) { + err = mz_zip_entry_write_open(writer->zip_handle, &writer->file_info, writer->compress_level, writer->raw, + password); + } return err; } @@ -1368,14 +1353,14 @@ int32_t mz_zip_writer_entry_close(void *handle) { uint16_t hash_digest_size = 0; switch (writer->hash_algorithm) { - case MZ_HASH_SHA1: - hash_digest_size = MZ_HASH_SHA1_SIZE; - break; - case MZ_HASH_SHA256: - hash_digest_size = MZ_HASH_SHA256_SIZE; - break; - default: - return MZ_PARAM_ERROR; + case MZ_HASH_SHA1: + hash_digest_size = MZ_HASH_SHA1_SIZE; + break; + case MZ_HASH_SHA256: + hash_digest_size = MZ_HASH_SHA256_SIZE; + break; + default: + return MZ_PARAM_ERROR; } mz_crypt_sha_end(writer->hash, hash_digest, hash_digest_size); @@ -1400,9 +1385,10 @@ int32_t mz_zip_writer_entry_close(void *handle) { err = MZ_WRITE_ERROR; } - if ((writer->file_info.extrafield) && (writer->file_info.extrafield_size > 0)) + if (writer->file_info.extrafield && writer->file_info.extrafield_size > 0) { mz_stream_mem_write(writer->file_extra_stream, writer->file_info.extrafield, - writer->file_info.extrafield_size); + writer->file_info.extrafield_size); + } /* Update extra field for central directory after adding extra fields */ mz_stream_mem_get_buffer(writer->file_extra_stream, (const void **)&extrafield); @@ -1602,8 +1588,7 @@ int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filen if (writer->aes) file_info.aes_version = MZ_AES_VERSION; - mz_os_get_file_date(path, &file_info.modified_date, &file_info.accessed_date, - &file_info.creation_date); + mz_os_get_file_date(path, &file_info.modified_date, &file_info.accessed_date, &file_info.creation_date); mz_os_get_file_attribs(path, &src_attrib); src_sys = MZ_HOST_SYSTEM(file_info.version_madeby); @@ -1639,8 +1624,8 @@ int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filen return err; } -int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path, - uint8_t include_path, uint8_t recursive) { +int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path, uint8_t include_path, + uint8_t recursive) { mz_zip_writer *writer = (mz_zip_writer *)handle; DIR *dir = NULL; struct dirent *entry = NULL; diff --git a/SSZipArchive/minizip/mz_zip_rw.h b/SSZipArchive/minizip/mz_zip_rw.h index 71f267e..39bb34a 100644 --- a/SSZipArchive/minizip/mz_zip_rw.h +++ b/SSZipArchive/minizip/mz_zip_rw.h @@ -18,7 +18,8 @@ extern "C" { /***************************************************************************/ typedef int32_t (*mz_zip_reader_overwrite_cb)(void *handle, void *userdata, mz_zip_file *file_info, const char *path); -typedef int32_t (*mz_zip_reader_password_cb)(void *handle, void *userdata, mz_zip_file *file_info, char *password, int32_t max_password); +typedef int32_t (*mz_zip_reader_password_cb)(void *handle, void *userdata, mz_zip_file *file_info, char *password, + int32_t max_password); typedef int32_t (*mz_zip_reader_progress_cb)(void *handle, void *userdata, mz_zip_file *file_info, int64_t position); typedef int32_t (*mz_zip_reader_entry_cb)(void *handle, void *userdata, mz_zip_file *file_info, const char *path); @@ -101,13 +102,13 @@ int32_t mz_zip_reader_save_all(void *handle, const char *destination_dir); /***************************************************************************/ -void mz_zip_reader_set_pattern(void *handle, const char *pattern, uint8_t ignore_case); +void mz_zip_reader_set_pattern(void *handle, const char *pattern, uint8_t ignore_case); /* Sets the match pattern for entries in the zip file, if null all entries are matched */ -void mz_zip_reader_set_password(void *handle, const char *password); +void mz_zip_reader_set_password(void *handle, const char *password); /* Sets the password required for extraction */ -void mz_zip_reader_set_raw(void *handle, uint8_t raw); +void mz_zip_reader_set_raw(void *handle, uint8_t raw); /* Sets whether or not it should save the entry raw */ int32_t mz_zip_reader_get_raw(void *handle, uint8_t *raw); @@ -122,37 +123,38 @@ int32_t mz_zip_reader_get_comment(void *handle, const char **comment); int32_t mz_zip_reader_set_recover(void *handle, uint8_t recover); /* Sets the ability to recover the central dir by reading local file headers */ -void mz_zip_reader_set_encoding(void *handle, int32_t encoding); +void mz_zip_reader_set_encoding(void *handle, int32_t encoding); /* Sets whether or not it should support a special character encoding in zip file names. */ -void mz_zip_reader_set_overwrite_cb(void *handle, void *userdata, mz_zip_reader_overwrite_cb cb); +void mz_zip_reader_set_overwrite_cb(void *handle, void *userdata, mz_zip_reader_overwrite_cb cb); /* Callback for what to do when a file is being overwritten */ -void mz_zip_reader_set_password_cb(void *handle, void *userdata, mz_zip_reader_password_cb cb); +void mz_zip_reader_set_password_cb(void *handle, void *userdata, mz_zip_reader_password_cb cb); /* Callback for when a password is required and hasn't been set */ -void mz_zip_reader_set_progress_cb(void *handle, void *userdata, mz_zip_reader_progress_cb cb); +void mz_zip_reader_set_progress_cb(void *handle, void *userdata, mz_zip_reader_progress_cb cb); /* Callback for extraction progress */ -void mz_zip_reader_set_progress_interval(void *handle, uint32_t milliseconds); +void mz_zip_reader_set_progress_interval(void *handle, uint32_t milliseconds); /* Let at least milliseconds pass between calls to progress callback */ -void mz_zip_reader_set_entry_cb(void *handle, void *userdata, mz_zip_reader_entry_cb cb); +void mz_zip_reader_set_entry_cb(void *handle, void *userdata, mz_zip_reader_entry_cb cb); /* Callback for zip file entries */ int32_t mz_zip_reader_get_zip_handle(void *handle, void **zip_handle); /* Gets the underlying zip instance handle */ -void* mz_zip_reader_create(void); +void *mz_zip_reader_create(void); /* Create new instance of zip reader */ -void mz_zip_reader_delete(void **handle); +void mz_zip_reader_delete(void **handle); /* Delete instance of zip reader */ /***************************************************************************/ typedef int32_t (*mz_zip_writer_overwrite_cb)(void *handle, void *userdata, const char *path); -typedef int32_t (*mz_zip_writer_password_cb)(void *handle, void *userdata, mz_zip_file *file_info, char *password, int32_t max_password); +typedef int32_t (*mz_zip_writer_password_cb)(void *handle, void *userdata, mz_zip_file *file_info, char *password, + int32_t max_password); typedef int32_t (*mz_zip_writer_progress_cb)(void *handle, void *userdata, mz_zip_file *file_info, int64_t position); typedef int32_t (*mz_zip_writer_entry_cb)(void *handle, void *userdata, mz_zip_file *file_info); @@ -202,7 +204,7 @@ int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filen /* Adds an entry to the zip from a file */ int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path, uint8_t include_path, - uint8_t recursive); + uint8_t recursive); /* Enumerates a directory or pattern and adds entries to the zip */ int32_t mz_zip_writer_copy_from_reader(void *handle, void *reader); @@ -210,61 +212,61 @@ int32_t mz_zip_writer_copy_from_reader(void *handle, void *reader); /***************************************************************************/ -void mz_zip_writer_set_password(void *handle, const char *password); +void mz_zip_writer_set_password(void *handle, const char *password); /* Password to use for encrypting files in the zip */ -void mz_zip_writer_set_comment(void *handle, const char *comment); +void mz_zip_writer_set_comment(void *handle, const char *comment); /* Comment to use for the archive */ -void mz_zip_writer_set_raw(void *handle, uint8_t raw); +void mz_zip_writer_set_raw(void *handle, uint8_t raw); /* Sets whether or not we should write the entry raw */ int32_t mz_zip_writer_get_raw(void *handle, uint8_t *raw); /* Gets whether or not we should write the entry raw */ -void mz_zip_writer_set_aes(void *handle, uint8_t aes); +void mz_zip_writer_set_aes(void *handle, uint8_t aes); /* Use aes encryption when adding files in zip */ -void mz_zip_writer_set_compress_method(void *handle, uint16_t compress_method); +void mz_zip_writer_set_compress_method(void *handle, uint16_t compress_method); /* Sets the compression method when adding files in zip */ -void mz_zip_writer_set_compress_level(void *handle, int16_t compress_level); +void mz_zip_writer_set_compress_level(void *handle, int16_t compress_level); /* Sets the compression level when adding files in zip */ -void mz_zip_writer_set_follow_links(void *handle, uint8_t follow_links); +void mz_zip_writer_set_follow_links(void *handle, uint8_t follow_links); /* Follow symbolic links when traversing directories and files to add */ -void mz_zip_writer_set_store_links(void *handle, uint8_t store_links); +void mz_zip_writer_set_store_links(void *handle, uint8_t store_links); /* Store symbolic links in zip file */ -void mz_zip_writer_set_zip_cd(void *handle, uint8_t zip_cd); +void mz_zip_writer_set_zip_cd(void *handle, uint8_t zip_cd); /* Sets whether or not central directory should be zipped */ int32_t mz_zip_writer_set_certificate(void *handle, const char *cert_path, const char *cert_pwd); /* Sets the certificate and timestamp url to use for signing when adding files in zip */ -void mz_zip_writer_set_overwrite_cb(void *handle, void *userdata, mz_zip_writer_overwrite_cb cb); +void mz_zip_writer_set_overwrite_cb(void *handle, void *userdata, mz_zip_writer_overwrite_cb cb); /* Callback for what to do when zip file already exists */ -void mz_zip_writer_set_password_cb(void *handle, void *userdata, mz_zip_writer_password_cb cb); +void mz_zip_writer_set_password_cb(void *handle, void *userdata, mz_zip_writer_password_cb cb); /* Callback for ask if a password is required for adding */ -void mz_zip_writer_set_progress_cb(void *handle, void *userdata, mz_zip_writer_progress_cb cb); +void mz_zip_writer_set_progress_cb(void *handle, void *userdata, mz_zip_writer_progress_cb cb); /* Callback for compression progress */ -void mz_zip_writer_set_progress_interval(void *handle, uint32_t milliseconds); +void mz_zip_writer_set_progress_interval(void *handle, uint32_t milliseconds); /* Let at least milliseconds pass between calls to progress callback */ -void mz_zip_writer_set_entry_cb(void *handle, void *userdata, mz_zip_writer_entry_cb cb); +void mz_zip_writer_set_entry_cb(void *handle, void *userdata, mz_zip_writer_entry_cb cb); /* Callback for zip file entries */ int32_t mz_zip_writer_get_zip_handle(void *handle, void **zip_handle); /* Gets the underlying zip handle */ -void* mz_zip_writer_create(void); +void *mz_zip_writer_create(void); /* Create new instance of zip writer */ -void mz_zip_writer_delete(void **handle); +void mz_zip_writer_delete(void **handle); /* Delete instance of zip writer */ /***************************************************************************/ diff --git a/ZipArchive.xcodeproj/project.pbxproj b/ZipArchive.xcodeproj/project.pbxproj index 1aafa1c..da096f8 100644 --- a/ZipArchive.xcodeproj/project.pbxproj +++ b/ZipArchive.xcodeproj/project.pbxproj @@ -15,10 +15,6 @@ 3775F34A2276B14400A1840B /* mz_strm_pkcrypt.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3252276B14100A1840B /* mz_strm_pkcrypt.c */; }; 3775F34B2276B14400A1840B /* mz_strm_pkcrypt.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3252276B14100A1840B /* mz_strm_pkcrypt.c */; }; 3775F34C2276B14400A1840B /* mz_strm_pkcrypt.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3252276B14100A1840B /* mz_strm_pkcrypt.c */; }; - 3775F3552276B14400A1840B /* mz_compat.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3282276B14100A1840B /* mz_compat.c */; }; - 3775F3562276B14400A1840B /* mz_compat.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3282276B14100A1840B /* mz_compat.c */; }; - 3775F3572276B14400A1840B /* mz_compat.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3282276B14100A1840B /* mz_compat.c */; }; - 3775F3582276B14400A1840B /* mz_compat.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3282276B14100A1840B /* mz_compat.c */; }; 3775F35D2276B14400A1840B /* mz_strm_os.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F32A2276B14100A1840B /* mz_strm_os.h */; }; 3775F35E2276B14400A1840B /* mz_strm_os.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F32A2276B14100A1840B /* mz_strm_os.h */; }; 3775F35F2276B14400A1840B /* mz_strm_os.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F32A2276B14100A1840B /* mz_strm_os.h */; }; @@ -63,10 +59,6 @@ 3775F38E2276B14400A1840B /* mz_strm_split.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3362276B14200A1840B /* mz_strm_split.c */; }; 3775F38F2276B14400A1840B /* mz_strm_split.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3362276B14200A1840B /* mz_strm_split.c */; }; 3775F3902276B14400A1840B /* mz_strm_split.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3362276B14200A1840B /* mz_strm_split.c */; }; - 3775F3912276B14400A1840B /* mz_compat.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3372276B14200A1840B /* mz_compat.h */; }; - 3775F3922276B14400A1840B /* mz_compat.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3372276B14200A1840B /* mz_compat.h */; }; - 3775F3932276B14400A1840B /* mz_compat.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3372276B14200A1840B /* mz_compat.h */; }; - 3775F3942276B14400A1840B /* mz_compat.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3372276B14200A1840B /* mz_compat.h */; }; 3775F3952276B14400A1840B /* mz_zip_rw.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3382276B14200A1840B /* mz_zip_rw.h */; }; 3775F3962276B14400A1840B /* mz_zip_rw.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3382276B14200A1840B /* mz_zip_rw.h */; }; 3775F3972276B14400A1840B /* mz_zip_rw.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3382276B14200A1840B /* mz_zip_rw.h */; }; @@ -155,6 +147,36 @@ B423AE6B1C0DF7950004A2F1 /* SSZipArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = B423AE481C0DF7950004A2F1 /* SSZipArchive.h */; settings = {ATTRIBUTES = (Public, ); }; }; B423AE6C1C0DF7950004A2F1 /* SSZipArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = B423AE491C0DF7950004A2F1 /* SSZipArchive.m */; }; B423AE6D1C0DF7950004A2F1 /* ZipArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = B423AE4A1C0DF7950004A2F1 /* ZipArchive.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C8BD22DD2CE2B27B00843A77 /* zip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22DA2CE2B27B00843A77 /* zip.h */; }; + C8BD22DE2CE2B27B00843A77 /* ioapi.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D62CE2B27B00843A77 /* ioapi.h */; }; + C8BD22DF2CE2B27B00843A77 /* unzip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D82CE2B27B00843A77 /* unzip.h */; }; + C8BD22E02CE2B27B00843A77 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D92CE2B27B00843A77 /* unzip.c */; }; + C8BD22E12CE2B27B00843A77 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22DB2CE2B27B00843A77 /* zip.c */; }; + C8BD22E22CE2B27B00843A77 /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D72CE2B27B00843A77 /* ioapi.c */; }; + C8BD22E32CE2B27B00843A77 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D92CE2B27B00843A77 /* unzip.c */; }; + C8BD22E42CE2B27B00843A77 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22DB2CE2B27B00843A77 /* zip.c */; }; + C8BD22E52CE2B27B00843A77 /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D72CE2B27B00843A77 /* ioapi.c */; }; + C8BD22E62CE2B27B00843A77 /* zip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22DA2CE2B27B00843A77 /* zip.h */; }; + C8BD22E72CE2B27B00843A77 /* ioapi.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D62CE2B27B00843A77 /* ioapi.h */; }; + C8BD22E82CE2B27B00843A77 /* unzip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D82CE2B27B00843A77 /* unzip.h */; }; + C8BD22E92CE2B27B00843A77 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D92CE2B27B00843A77 /* unzip.c */; }; + C8BD22EA2CE2B27B00843A77 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22DB2CE2B27B00843A77 /* zip.c */; }; + C8BD22EB2CE2B27B00843A77 /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D72CE2B27B00843A77 /* ioapi.c */; }; + C8BD22EC2CE2B27B00843A77 /* zip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22DA2CE2B27B00843A77 /* zip.h */; }; + C8BD22ED2CE2B27B00843A77 /* ioapi.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D62CE2B27B00843A77 /* ioapi.h */; }; + C8BD22EE2CE2B27B00843A77 /* unzip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D82CE2B27B00843A77 /* unzip.h */; }; + C8BD22EF2CE2B27B00843A77 /* zip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22DA2CE2B27B00843A77 /* zip.h */; }; + C8BD22F02CE2B27B00843A77 /* ioapi.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D62CE2B27B00843A77 /* ioapi.h */; }; + C8BD22F12CE2B27B00843A77 /* unzip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D82CE2B27B00843A77 /* unzip.h */; }; + C8BD22F22CE2B27B00843A77 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D92CE2B27B00843A77 /* unzip.c */; }; + C8BD22F32CE2B27B00843A77 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22DB2CE2B27B00843A77 /* zip.c */; }; + C8BD22F42CE2B27B00843A77 /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D72CE2B27B00843A77 /* ioapi.c */; }; + C8BD22F52CE2B27B00843A77 /* zip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22DA2CE2B27B00843A77 /* zip.h */; }; + C8BD22F62CE2B27B00843A77 /* ioapi.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D62CE2B27B00843A77 /* ioapi.h */; }; + C8BD22F72CE2B27B00843A77 /* unzip.h in Headers */ = {isa = PBXBuildFile; fileRef = C8BD22D82CE2B27B00843A77 /* unzip.h */; }; + C8BD22F82CE2B27B00843A77 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D92CE2B27B00843A77 /* unzip.c */; }; + C8BD22F92CE2B27B00843A77 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22DB2CE2B27B00843A77 /* zip.c */; }; + C8BD22FA2CE2B27B00843A77 /* ioapi.c in Sources */ = {isa = PBXBuildFile; fileRef = C8BD22D72CE2B27B00843A77 /* ioapi.c */; }; C8DEE3662BE59172005150F4 /* mz_os_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F33E2276B14300A1840B /* mz_os_posix.c */; }; C8DEE3672BE59172005150F4 /* mz_strm_mem.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3342276B14200A1840B /* mz_strm_mem.c */; }; C8DEE3682BE59172005150F4 /* mz_strm_wzaes.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3482276B14400A1840B /* mz_strm_wzaes.c */; }; @@ -164,7 +186,6 @@ C8DEE36C2BE59172005150F4 /* mz_strm_split.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3362276B14200A1840B /* mz_strm_split.c */; }; C8DEE36D2BE59172005150F4 /* mz_strm_pkcrypt.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3252276B14100A1840B /* mz_strm_pkcrypt.c */; }; C8DEE36E2BE59172005150F4 /* mz_strm.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3462276B14300A1840B /* mz_strm.c */; }; - C8DEE36F2BE59172005150F4 /* mz_compat.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3282276B14100A1840B /* mz_compat.c */; }; C8DEE3702BE59172005150F4 /* mz_crypt_apple.c in Sources */ = {isa = PBXBuildFile; fileRef = 378439B1227ABC7B000BC165 /* mz_crypt_apple.c */; }; C8DEE3712BE59172005150F4 /* mz_strm_zlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F33A2276B14200A1840B /* mz_strm_zlib.c */; }; C8DEE3722BE59172005150F4 /* mz_zip_rw.c in Sources */ = {isa = PBXBuildFile; fileRef = 3775F3332276B14200A1840B /* mz_zip_rw.c */; }; @@ -189,7 +210,6 @@ C8DEE3872BE59172005150F4 /* mz_strm_os.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F32A2276B14100A1840B /* mz_strm_os.h */; }; C8DEE3882BE59172005150F4 /* mz_zip_rw.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3382276B14200A1840B /* mz_zip_rw.h */; }; C8DEE3892BE59172005150F4 /* SSZipCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 93CE5D5D227FE5C50003464F /* SSZipCommon.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C8DEE38A2BE59172005150F4 /* mz_compat.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3372276B14200A1840B /* mz_compat.h */; }; C8DEE38B2BE59172005150F4 /* mz_strm_wzaes.h in Headers */ = {isa = PBXBuildFile; fileRef = 3775F3322276B14200A1840B /* mz_strm_wzaes.h */; }; C8DEE38D2BE59172005150F4 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 330100222AC89AA8001431B0 /* PrivacyInfo.xcprivacy */; }; /* End PBXBuildFile section */ @@ -197,7 +217,6 @@ /* Begin PBXFileReference section */ 330100222AC89AA8001431B0 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; 3775F3252276B14100A1840B /* mz_strm_pkcrypt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mz_strm_pkcrypt.c; sourceTree = ""; }; - 3775F3282276B14100A1840B /* mz_compat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mz_compat.c; sourceTree = ""; }; 3775F32A2276B14100A1840B /* mz_strm_os.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mz_strm_os.h; sourceTree = ""; }; 3775F32B2276B14200A1840B /* mz_os.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mz_os.c; sourceTree = ""; }; 3775F32C2276B14200A1840B /* mz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mz.h; sourceTree = ""; }; @@ -209,7 +228,6 @@ 3775F3342276B14200A1840B /* mz_strm_mem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mz_strm_mem.c; sourceTree = ""; }; 3775F3352276B14200A1840B /* mz_strm_pkcrypt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mz_strm_pkcrypt.h; sourceTree = ""; }; 3775F3362276B14200A1840B /* mz_strm_split.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mz_strm_split.c; sourceTree = ""; }; - 3775F3372276B14200A1840B /* mz_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mz_compat.h; sourceTree = ""; }; 3775F3382276B14200A1840B /* mz_zip_rw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mz_zip_rw.h; sourceTree = ""; }; 3775F3392276B14200A1840B /* mz_strm_buf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mz_strm_buf.c; sourceTree = ""; }; 3775F33A2276B14200A1840B /* mz_strm_zlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mz_strm_zlib.c; sourceTree = ""; }; @@ -246,6 +264,12 @@ B423AE481C0DF7950004A2F1 /* SSZipArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSZipArchive.h; sourceTree = ""; }; B423AE491C0DF7950004A2F1 /* SSZipArchive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSZipArchive.m; sourceTree = ""; }; B423AE4A1C0DF7950004A2F1 /* ZipArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZipArchive.h; sourceTree = ""; }; + C8BD22D62CE2B27B00843A77 /* ioapi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ioapi.h; sourceTree = ""; }; + C8BD22D72CE2B27B00843A77 /* ioapi.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ioapi.c; sourceTree = ""; }; + C8BD22D82CE2B27B00843A77 /* unzip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = unzip.h; sourceTree = ""; }; + C8BD22D92CE2B27B00843A77 /* unzip.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = unzip.c; sourceTree = ""; }; + C8BD22DA2CE2B27B00843A77 /* zip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = zip.h; sourceTree = ""; }; + C8BD22DB2CE2B27B00843A77 /* zip.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = zip.c; sourceTree = ""; }; C8DEE3912BE59172005150F4 /* ZipArchive.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZipArchive.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -376,39 +400,51 @@ B423AE3E1C0DF7950004A2F1 /* minizip */ = { isa = PBXGroup; children = ( - 3775F3282276B14100A1840B /* mz_compat.c */, - 3775F3372276B14200A1840B /* mz_compat.h */, - 378439B1227ABC7B000BC165 /* mz_crypt_apple.c */, - 3775F32E2276B14200A1840B /* mz_crypt.c */, - 3775F33F2276B14300A1840B /* mz_crypt.h */, - 3775F33E2276B14300A1840B /* mz_os_posix.c */, - 3775F32B2276B14200A1840B /* mz_os.c */, - 3775F32F2276B14200A1840B /* mz_os.h */, - 3775F3392276B14200A1840B /* mz_strm_buf.c */, - 3775F33D2276B14300A1840B /* mz_strm_buf.h */, - 3775F3342276B14200A1840B /* mz_strm_mem.c */, - 3775F3422276B14300A1840B /* mz_strm_mem.h */, - 3775F3432276B14300A1840B /* mz_strm_os_posix.c */, - 3775F32A2276B14100A1840B /* mz_strm_os.h */, - 3775F3252276B14100A1840B /* mz_strm_pkcrypt.c */, - 3775F3352276B14200A1840B /* mz_strm_pkcrypt.h */, - 3775F3362276B14200A1840B /* mz_strm_split.c */, - 3775F3312276B14200A1840B /* mz_strm_split.h */, - 3775F3482276B14400A1840B /* mz_strm_wzaes.c */, - 3775F3322276B14200A1840B /* mz_strm_wzaes.h */, - 3775F33A2276B14200A1840B /* mz_strm_zlib.c */, - 3775F3452276B14300A1840B /* mz_strm_zlib.h */, - 3775F3462276B14300A1840B /* mz_strm.c */, - 3775F33B2276B14200A1840B /* mz_strm.h */, - 3775F3332276B14200A1840B /* mz_zip_rw.c */, - 3775F3382276B14200A1840B /* mz_zip_rw.h */, - 3775F33C2276B14300A1840B /* mz_zip.c */, - 3775F3412276B14300A1840B /* mz_zip.h */, + C8BD22DC2CE2B27B00843A77 /* compat */, 3775F32C2276B14200A1840B /* mz.h */, + 3775F33F2276B14300A1840B /* mz_crypt.h */, + 3775F32E2276B14200A1840B /* mz_crypt.c */, + 378439B1227ABC7B000BC165 /* mz_crypt_apple.c */, + 3775F32F2276B14200A1840B /* mz_os.h */, + 3775F32B2276B14200A1840B /* mz_os.c */, + 3775F33E2276B14300A1840B /* mz_os_posix.c */, + 3775F33B2276B14200A1840B /* mz_strm.h */, + 3775F3462276B14300A1840B /* mz_strm.c */, + 3775F33D2276B14300A1840B /* mz_strm_buf.h */, + 3775F3392276B14200A1840B /* mz_strm_buf.c */, + 3775F3422276B14300A1840B /* mz_strm_mem.h */, + 3775F3342276B14200A1840B /* mz_strm_mem.c */, + 3775F32A2276B14100A1840B /* mz_strm_os.h */, + 3775F3432276B14300A1840B /* mz_strm_os_posix.c */, + 3775F3352276B14200A1840B /* mz_strm_pkcrypt.h */, + 3775F3252276B14100A1840B /* mz_strm_pkcrypt.c */, + 3775F3312276B14200A1840B /* mz_strm_split.h */, + 3775F3362276B14200A1840B /* mz_strm_split.c */, + 3775F3322276B14200A1840B /* mz_strm_wzaes.h */, + 3775F3482276B14400A1840B /* mz_strm_wzaes.c */, + 3775F3452276B14300A1840B /* mz_strm_zlib.h */, + 3775F33A2276B14200A1840B /* mz_strm_zlib.c */, + 3775F3412276B14300A1840B /* mz_zip.h */, + 3775F33C2276B14300A1840B /* mz_zip.c */, + 3775F3382276B14200A1840B /* mz_zip_rw.h */, + 3775F3332276B14200A1840B /* mz_zip_rw.c */, ); path = minizip; sourceTree = ""; }; + C8BD22DC2CE2B27B00843A77 /* compat */ = { + isa = PBXGroup; + children = ( + C8BD22D62CE2B27B00843A77 /* ioapi.h */, + C8BD22D72CE2B27B00843A77 /* ioapi.c */, + C8BD22D82CE2B27B00843A77 /* unzip.h */, + C8BD22D92CE2B27B00843A77 /* unzip.c */, + C8BD22DA2CE2B27B00843A77 /* zip.h */, + C8BD22DB2CE2B27B00843A77 /* zip.c */, + ); + path = compat; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -422,6 +458,9 @@ 3775F3732276B14400A1840B /* mz_os.h in Headers */, 3775F3672276B14400A1840B /* mz.h in Headers */, 3775F3B32276B14400A1840B /* mz_crypt.h in Headers */, + C8BD22F52CE2B27B00843A77 /* zip.h in Headers */, + C8BD22F62CE2B27B00843A77 /* ioapi.h in Headers */, + C8BD22F72CE2B27B00843A77 /* unzip.h in Headers */, 3775F37B2276B14400A1840B /* mz_strm_split.h in Headers */, 3775F3BB2276B14400A1840B /* mz_zip.h in Headers */, 3775F3BF2276B14400A1840B /* mz_strm_mem.h in Headers */, @@ -429,7 +468,6 @@ 3775F38B2276B14400A1840B /* mz_strm_pkcrypt.h in Headers */, 3775F35F2276B14400A1840B /* mz_strm_os.h in Headers */, 3775F3972276B14400A1840B /* mz_zip_rw.h in Headers */, - 3775F3932276B14400A1840B /* mz_compat.h in Headers */, 93CE5D60227FE5C50003464F /* SSZipCommon.h in Headers */, 3775F37F2276B14400A1840B /* mz_strm_wzaes.h in Headers */, 37952C341F63B71400DD6677 /* ZipArchive.h in Headers */, @@ -446,6 +484,9 @@ 3775F3742276B14400A1840B /* mz_os.h in Headers */, 3775F3682276B14400A1840B /* mz.h in Headers */, 3775F3B42276B14400A1840B /* mz_crypt.h in Headers */, + C8BD22DD2CE2B27B00843A77 /* zip.h in Headers */, + C8BD22DE2CE2B27B00843A77 /* ioapi.h in Headers */, + C8BD22DF2CE2B27B00843A77 /* unzip.h in Headers */, 3775F37C2276B14400A1840B /* mz_strm_split.h in Headers */, 3775F3BC2276B14400A1840B /* mz_zip.h in Headers */, 3775F3C02276B14400A1840B /* mz_strm_mem.h in Headers */, @@ -455,7 +496,6 @@ 3775F3602276B14400A1840B /* mz_strm_os.h in Headers */, 3775F3982276B14400A1840B /* mz_zip_rw.h in Headers */, 93CE5D61227FE5C50003464F /* SSZipCommon.h in Headers */, - 3775F3942276B14400A1840B /* mz_compat.h in Headers */, 3775F3802276B14400A1840B /* mz_strm_wzaes.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -470,6 +510,9 @@ 3775F3722276B14400A1840B /* mz_os.h in Headers */, 3775F3662276B14400A1840B /* mz.h in Headers */, 3775F3B22276B14400A1840B /* mz_crypt.h in Headers */, + C8BD22EF2CE2B27B00843A77 /* zip.h in Headers */, + C8BD22F02CE2B27B00843A77 /* ioapi.h in Headers */, + C8BD22F12CE2B27B00843A77 /* unzip.h in Headers */, 3775F37A2276B14400A1840B /* mz_strm_split.h in Headers */, 3775F3BA2276B14400A1840B /* mz_zip.h in Headers */, 3775F3BE2276B14400A1840B /* mz_strm_mem.h in Headers */, @@ -479,7 +522,6 @@ 3775F35E2276B14400A1840B /* mz_strm_os.h in Headers */, 3775F3962276B14400A1840B /* mz_zip_rw.h in Headers */, 93CE5D5F227FE5C50003464F /* SSZipCommon.h in Headers */, - 3775F3922276B14400A1840B /* mz_compat.h in Headers */, 3775F37E2276B14400A1840B /* mz_strm_wzaes.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -494,6 +536,9 @@ 3775F3A92276B14400A1840B /* mz_strm_buf.h in Headers */, 3775F3712276B14400A1840B /* mz_os.h in Headers */, 3775F3652276B14400A1840B /* mz.h in Headers */, + C8BD22E62CE2B27B00843A77 /* zip.h in Headers */, + C8BD22E72CE2B27B00843A77 /* ioapi.h in Headers */, + C8BD22E82CE2B27B00843A77 /* unzip.h in Headers */, 3775F3B12276B14400A1840B /* mz_crypt.h in Headers */, 3775F3792276B14400A1840B /* mz_strm_split.h in Headers */, 3775F3B92276B14400A1840B /* mz_zip.h in Headers */, @@ -503,7 +548,6 @@ 3775F3892276B14400A1840B /* mz_strm_pkcrypt.h in Headers */, 3775F35D2276B14400A1840B /* mz_strm_os.h in Headers */, 3775F3952276B14400A1840B /* mz_zip_rw.h in Headers */, - 3775F3912276B14400A1840B /* mz_compat.h in Headers */, 3775F37D2276B14400A1840B /* mz_strm_wzaes.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -518,6 +562,9 @@ C8DEE37E2BE59172005150F4 /* mz_os.h in Headers */, C8DEE37F2BE59172005150F4 /* mz.h in Headers */, C8DEE3802BE59172005150F4 /* mz_crypt.h in Headers */, + C8BD22EC2CE2B27B00843A77 /* zip.h in Headers */, + C8BD22ED2CE2B27B00843A77 /* ioapi.h in Headers */, + C8BD22EE2CE2B27B00843A77 /* unzip.h in Headers */, C8DEE3812BE59172005150F4 /* mz_strm_split.h in Headers */, C8DEE3822BE59172005150F4 /* mz_zip.h in Headers */, C8DEE3832BE59172005150F4 /* mz_strm_mem.h in Headers */, @@ -527,7 +574,6 @@ C8DEE3872BE59172005150F4 /* mz_strm_os.h in Headers */, C8DEE3882BE59172005150F4 /* mz_zip_rw.h in Headers */, C8DEE3892BE59172005150F4 /* SSZipCommon.h in Headers */, - C8DEE38A2BE59172005150F4 /* mz_compat.h in Headers */, C8DEE38B2BE59172005150F4 /* mz_strm_wzaes.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -727,9 +773,11 @@ 3775F36F2276B14400A1840B /* mz_crypt.c in Sources */, 3775F38F2276B14400A1840B /* mz_strm_split.c in Sources */, 37952C331F63B70000DD6677 /* SSZipArchive.m in Sources */, + C8BD22F82CE2B27B00843A77 /* unzip.c in Sources */, + C8BD22F92CE2B27B00843A77 /* zip.c in Sources */, + C8BD22FA2CE2B27B00843A77 /* ioapi.c in Sources */, 3775F34B2276B14400A1840B /* mz_strm_pkcrypt.c in Sources */, 3775F3CF2276B14400A1840B /* mz_strm.c in Sources */, - 3775F3572276B14400A1840B /* mz_compat.c in Sources */, 378439B4227ABC7B000BC165 /* mz_crypt_apple.c in Sources */, 3775F39F2276B14400A1840B /* mz_strm_zlib.c in Sources */, 3775F3832276B14400A1840B /* mz_zip_rw.c in Sources */, @@ -750,9 +798,11 @@ 3775F3A82276B14400A1840B /* mz_zip.c in Sources */, 3775F3702276B14400A1840B /* mz_crypt.c in Sources */, 3775F3902276B14400A1840B /* mz_strm_split.c in Sources */, + C8BD22E02CE2B27B00843A77 /* unzip.c in Sources */, + C8BD22E12CE2B27B00843A77 /* zip.c in Sources */, + C8BD22E22CE2B27B00843A77 /* ioapi.c in Sources */, 3775F34C2276B14400A1840B /* mz_strm_pkcrypt.c in Sources */, 3775F3D02276B14400A1840B /* mz_strm.c in Sources */, - 3775F3582276B14400A1840B /* mz_compat.c in Sources */, 378439B5227ABC7B000BC165 /* mz_crypt_apple.c in Sources */, 3775F3A02276B14400A1840B /* mz_strm_zlib.c in Sources */, 3775F3842276B14400A1840B /* mz_zip_rw.c in Sources */, @@ -773,9 +823,11 @@ 3775F36E2276B14400A1840B /* mz_crypt.c in Sources */, 3775F38E2276B14400A1840B /* mz_strm_split.c in Sources */, AFF75A2F1C37280200F450AC /* SSZipArchive.m in Sources */, + C8BD22F22CE2B27B00843A77 /* unzip.c in Sources */, + C8BD22F32CE2B27B00843A77 /* zip.c in Sources */, + C8BD22F42CE2B27B00843A77 /* ioapi.c in Sources */, 3775F34A2276B14400A1840B /* mz_strm_pkcrypt.c in Sources */, 3775F3CE2276B14400A1840B /* mz_strm.c in Sources */, - 3775F3562276B14400A1840B /* mz_compat.c in Sources */, 378439B3227ABC7B000BC165 /* mz_crypt_apple.c in Sources */, 3775F39E2276B14400A1840B /* mz_strm_zlib.c in Sources */, 3775F3822276B14400A1840B /* mz_zip_rw.c in Sources */, @@ -796,8 +848,10 @@ 3775F36D2276B14400A1840B /* mz_crypt.c in Sources */, 3775F38D2276B14400A1840B /* mz_strm_split.c in Sources */, 3775F3492276B14400A1840B /* mz_strm_pkcrypt.c in Sources */, + C8BD22E32CE2B27B00843A77 /* unzip.c in Sources */, + C8BD22E42CE2B27B00843A77 /* zip.c in Sources */, + C8BD22E52CE2B27B00843A77 /* ioapi.c in Sources */, 3775F3CD2276B14400A1840B /* mz_strm.c in Sources */, - 3775F3552276B14400A1840B /* mz_compat.c in Sources */, 3775F39D2276B14400A1840B /* mz_strm_zlib.c in Sources */, 378439B2227ABC7B000BC165 /* mz_crypt_apple.c in Sources */, 3775F3812276B14400A1840B /* mz_zip_rw.c in Sources */, @@ -819,9 +873,11 @@ C8DEE36A2BE59172005150F4 /* mz_zip.c in Sources */, C8DEE36B2BE59172005150F4 /* mz_crypt.c in Sources */, C8DEE36C2BE59172005150F4 /* mz_strm_split.c in Sources */, + C8BD22E92CE2B27B00843A77 /* unzip.c in Sources */, + C8BD22EA2CE2B27B00843A77 /* zip.c in Sources */, + C8BD22EB2CE2B27B00843A77 /* ioapi.c in Sources */, C8DEE36D2BE59172005150F4 /* mz_strm_pkcrypt.c in Sources */, C8DEE36E2BE59172005150F4 /* mz_strm.c in Sources */, - C8DEE36F2BE59172005150F4 /* mz_compat.c in Sources */, C8DEE3702BE59172005150F4 /* mz_crypt_apple.c in Sources */, C8DEE3712BE59172005150F4 /* mz_strm_zlib.c in Sources */, C8DEE3722BE59172005150F4 /* mz_zip_rw.c in Sources */,