mirror of
https://github.com/GerbilSoft/rom-properties.git
synced 2025-06-18 11:35:38 -04:00
[minizip] Update: v4.0.7 -> v4.0.9
[libromdata] J2ME, GcnFstTest: MiniZip's compat headers were moved in v4.0.8.
This commit is contained in:
parent
3367e4d6e6
commit
05055964a0
30
extlib/minizip-ng/CMakeLists.txt
vendored
30
extlib/minizip-ng/CMakeLists.txt
vendored
@ -8,7 +8,7 @@
|
||||
#cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
# Library version
|
||||
set(VERSION "4.0.7")
|
||||
set(VERSION "4.0.9")
|
||||
# API version
|
||||
set(SOVERSION "4")
|
||||
|
||||
@ -650,27 +650,18 @@ endif()
|
||||
if(MZ_COMPAT)
|
||||
set(SOVERSION "1")
|
||||
|
||||
set(FILE_H "ioapi.h")
|
||||
set(MZ_COMPAT_FILE "MZ_COMPAT_IOAPI")
|
||||
configure_file(mz_compat_shim.h.in ioapi.h)
|
||||
|
||||
set(FILE_H "zip.h")
|
||||
set(MZ_COMPAT_FILE "MZ_COMPAT_ZIP")
|
||||
configure_file(mz_compat_shim.h.in zip.h)
|
||||
|
||||
set(FILE_H "unzip.h")
|
||||
set(MZ_COMPAT_FILE "MZ_COMPAT_UNZIP")
|
||||
configure_file(mz_compat_shim.h.in unzip.h)
|
||||
list(APPEND MINIZIP_SRC
|
||||
compat/ioapi.c
|
||||
compat/unzip.c
|
||||
compat/zip.c)
|
||||
list(APPEND MINIZIP_HDR
|
||||
compat/ioapi.h
|
||||
compat/unzip.h
|
||||
compat/zip.h)
|
||||
|
||||
if(MZ_COMPAT_VERSION)
|
||||
list(APPEND MINIZIP_DEF -DMZ_COMPAT_VERSION=${MZ_COMPAT_VERSION})
|
||||
endif()
|
||||
|
||||
list(APPEND MINIZIP_SRC mz_compat.c)
|
||||
list(APPEND MINIZIP_HDR mz_compat.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/ioapi.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zip.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/unzip.h)
|
||||
endif()
|
||||
|
||||
# Detect available sanitizers
|
||||
@ -761,6 +752,7 @@ target_include_directories(${MINIZIP_TARGET} PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||
if(MZ_COMPAT)
|
||||
target_include_directories(${MINIZIP_TARGET} PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/compat/>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
||||
endif()
|
||||
|
||||
@ -822,7 +814,7 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
|
||||
if(MINIZIP_DEP_PKG)
|
||||
string(APPEND MINIZIP_CONFIG_CONTENT "include(CMakeFindDependencyMacro)\n")
|
||||
foreach(pkg_name ${MINIZIP_DEP_PKG})
|
||||
string(APPEND MINIZIP_CONFIG_CONTENT "find_dependency(${pkg_name} REQUIRED)\n")
|
||||
string(APPEND MINIZIP_CONFIG_CONTENT "find_dependency(${pkg_name})\n")
|
||||
endforeach()
|
||||
endif()
|
||||
string(APPEND MINIZIP_CONFIG_CONTENT "include(\"\${CMAKE_CURRENT_LIST_DIR}/${MINIZIP_TARGET}.cmake\")")
|
||||
|
15
extlib/minizip-ng/_MODIFIED_MINIZIP.txt
vendored
15
extlib/minizip-ng/_MODIFIED_MINIZIP.txt
vendored
@ -1,9 +1,9 @@
|
||||
This copy of minizip-ng 4.0.7 is a modified version of the original.
|
||||
This copy of minizip-ng 4.0.9 is a modified version of the original.
|
||||
|
||||
commit fe5fedc365f7824ada0cf9a84fb79b30d5fc97a8
|
||||
Version 4.0.7.
|
||||
commit 95ba7abdd24a956bde584db54d1d55e37d511e2f
|
||||
Version 4.0.9.
|
||||
|
||||
Tag: 4.0.7
|
||||
Tag: 4.0.9
|
||||
|
||||
The following changes have been made to the original:
|
||||
|
||||
@ -23,12 +23,7 @@ The following changes have been made to the original:
|
||||
- project(): Disabled DESCRIPTION and HOMEPAGE_URL due to requiring
|
||||
newer versions of CMake than what's available in Ubuntu 16.04.
|
||||
|
||||
- Commit e6eeb4ea520915a762d2c317d0a7ad552a89de04 has been cherry-picked
|
||||
from the develop branch. This commit slightly reduces memory usage on
|
||||
64-bit systems. (not including the mz_crypt_openssl.c change because
|
||||
it doesn't apply here)
|
||||
|
||||
To obtain the original minizip-ng 4.0.7, visit:
|
||||
To obtain the original minizip-ng 4.0.9, visit:
|
||||
https://github.com/zlib-ng/minizip-ng
|
||||
|
||||
To obtain the original minizip-1.1, visit:
|
||||
|
84
extlib/minizip-ng/compat/crypt.h
vendored
Normal file
84
extlib/minizip-ng/compat/crypt.h
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
Version 1.01e, February 12th, 2005
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
The encryption/decryption parts of this source code (as opposed to the
|
||||
non-echoing password parts) were originally written in Europe. The
|
||||
whole source package can be freely distributed, including from the USA.
|
||||
(Prior to January 2000, re-export from the US was a violation of US law.)
|
||||
|
||||
This encryption code is a direct transcription of the algorithm from
|
||||
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
|
||||
file (appnote.txt) is distributed with the PKZIP program (even in the
|
||||
version without encryption capabilities).
|
||||
|
||||
If you don't need crypting in your application, just define symbols
|
||||
NOCRYPT and NOUNCRYPT.
|
||||
|
||||
This code support the "Traditional PKWARE Encryption".
|
||||
|
||||
The new AES encryption added on Zip format by Winzip (see the page
|
||||
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
|
||||
Encryption is not supported.
|
||||
*/
|
||||
|
||||
#ifndef ZLIB_VERNUM
|
||||
/* No zlib */
|
||||
typedef uint32_t z_crc_t;
|
||||
#elif (ZLIB_VERNUM & 0xf != 0xf) && (ZLIB_VERNUM < 0x1270)
|
||||
/* Define z_crc_t in zlib 1.2.6 and less */
|
||||
typedef unsigned long z_crc_t;
|
||||
#elif (ZLIB_VERNUM & 0xf == 0xf) && (ZLIB_VERNUM < 0x12df)
|
||||
/* Define z_crc_t in zlib-ng 2.0.7 and less */
|
||||
typedef unsigned int z_crc_t;
|
||||
#endif
|
||||
|
||||
#define CRC32(c, b) ((*(pcrc_32_tab + (((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
|
||||
|
||||
/***************************************************************************/
|
||||
/* Return the next byte in the pseudo-random sequence */
|
||||
|
||||
static int decrypt_byte(unsigned long *pkeys, const z_crc_t *pcrc_32_tab) {
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
* with any known compiler so far, though */
|
||||
|
||||
(void)pcrc_32_tab;
|
||||
temp = ((unsigned)(*(pkeys + 2)) & 0xffff) | 2;
|
||||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* Update the encryption keys with the next byte of plain text */
|
||||
|
||||
static int update_keys(unsigned long *pkeys, const z_crc_t *pcrc_32_tab, int c) {
|
||||
(*(pkeys + 0)) = CRC32((*(pkeys + 0)), c);
|
||||
(*(pkeys + 1)) += (*(pkeys + 0)) & 0xff;
|
||||
(*(pkeys + 1)) = (*(pkeys + 1)) * 134775813L + 1;
|
||||
{
|
||||
int keyshift = (int)((*(pkeys + 1)) >> 24);
|
||||
(*(pkeys + 2)) = CRC32((*(pkeys + 2)), keyshift);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* Initialize the encryption keys and the random header according to the password. */
|
||||
|
||||
static void init_keys(const char *passwd, unsigned long *pkeys, const z_crc_t *pcrc_32_tab) {
|
||||
*(pkeys + 0) = 305419896L;
|
||||
*(pkeys + 1) = 591751049L;
|
||||
*(pkeys + 2) = 878082192L;
|
||||
while (*passwd != '\0') {
|
||||
update_keys(pkeys, pcrc_32_tab, (int)*passwd);
|
||||
passwd++;
|
||||
}
|
||||
}
|
||||
|
||||
#define zdecode(pkeys, pcrc_32_tab, c) (update_keys(pkeys, pcrc_32_tab, c ^= decrypt_byte(pkeys, pcrc_32_tab)))
|
||||
|
||||
#define zencode(pkeys, pcrc_32_tab, c, t) \
|
||||
(t = decrypt_byte(pkeys, pcrc_32_tab), update_keys(pkeys, pcrc_32_tab, c), (Byte)t ^ (c))
|
260
extlib/minizip-ng/compat/ioapi.c
vendored
Normal file
260
extlib/minizip-ng/compat/ioapi.c
vendored
Normal file
@ -0,0 +1,260 @@
|
||||
#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;
|
||||
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();
|
||||
}
|
||||
}
|
97
extlib/minizip-ng/compat/ioapi.h
vendored
Normal file
97
extlib/minizip-ng/compat/ioapi.h
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
|
||||
#ifndef ZLIBIOAPI64_H
|
||||
#define ZLIBIOAPI64_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
737
extlib/minizip-ng/compat/unzip.c
vendored
Normal file
737
extlib/minizip-ng/compat/unzip.c
vendored
Normal file
@ -0,0 +1,737 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "mz.h"
|
||||
#include "mz_os.h"
|
||||
#include "mz_strm.h"
|
||||
#include "mz_strm_os.h"
|
||||
#include "mz_zip.h"
|
||||
|
||||
#include <stdio.h> /* 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;
|
||||
|
||||
mz_zip_set_recover(handle, 1);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
238
extlib/minizip-ng/compat/unzip.h
vendored
Normal file
238
extlib/minizip-ng/compat/unzip.h
vendored
Normal file
@ -0,0 +1,238 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef _unz64_H
|
||||
#define _unz64_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(_ZLIB_H) && !defined(ZLIB_H) && !defined(ZLIB_H_)
|
||||
# if __has_include(<zlib-ng.h>)
|
||||
# include <zlib-ng.h>
|
||||
# elif __has_include(<zlib.h>)
|
||||
# include <zlib.h>
|
||||
# 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 (-1) /* 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;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#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;
|
||||
|
||||
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;
|
||||
|
||||
/* 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;
|
||||
|
||||
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 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 4 bytes */
|
||||
ZPOS64_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 */
|
||||
|
||||
tm_unz tmu_date;
|
||||
|
||||
/* minizip-ng fields */
|
||||
ZPOS64_T disk_offset;
|
||||
} unz_file_info;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#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 */
|
409
extlib/minizip-ng/compat/zip.c
vendored
Normal file
409
extlib/minizip-ng/compat/zip.c
vendored
Normal file
@ -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;
|
||||
}
|
180
extlib/minizip-ng/compat/zip.h
vendored
Normal file
180
extlib/minizip-ng/compat/zip.h
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef _zip64_H
|
||||
#define _zip64_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(_ZLIB_H) && !defined(ZLIB_H) && !defined(ZLIB_H_)
|
||||
# if __has_include(<zlib-ng.h>)
|
||||
# include <zlib-ng.h>
|
||||
# elif __has_include(<zlib.h>)
|
||||
# include <zlib.h>
|
||||
# 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 (-1) /* 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;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#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 */
|
2
extlib/minizip-ng/doc/mz_zip_file.md
vendored
2
extlib/minizip-ng/doc/mz_zip_file.md
vendored
@ -20,7 +20,7 @@ Zip entry information structure. The _mz_zip_file_ structure is populated when r
|
||||
|uint32_t|disk_number|Starting disk number|4.4.13|
|
||||
|int64_t|disk_offset|Starting disk offset|4.4.16|
|
||||
|uint16_t|internal_fa|Internal file attributes|4.4.14|
|
||||
|uint16_t|external_fa|External file attributes|4.4.15|
|
||||
|uint32_t|external_fa|External file attributes|4.4.15|
|
||||
|const char *|filename|Filename UTF-8 null-terminated string|4.4.17|
|
||||
|const uint8_t *|extrafield|Extrafield buffer array|4.4.28|
|
||||
|const char *|comment|Comment UTF-8 null-terminated string|4.4.18|
|
||||
|
13
extlib/minizip-ng/minigzip.c
vendored
13
extlib/minizip-ng/minigzip.c
vendored
@ -33,12 +33,13 @@ int32_t minigzip_banner(void) {
|
||||
}
|
||||
|
||||
int32_t minigzip_help(void) {
|
||||
printf("Usage: minigzip [-x] [-d] [-0 to -9] [files]\n\n" \
|
||||
" -x Extract file\n" \
|
||||
" -d Destination directory\n" \
|
||||
" -0 Store only\n" \
|
||||
" -1 Compress faster\n" \
|
||||
" -9 Compress better\n\n");
|
||||
printf(
|
||||
"Usage: minigzip [-x] [-d] [-0 to -9] [files]\n\n"
|
||||
" -x Extract file\n"
|
||||
" -d Destination directory\n"
|
||||
" -0 Store only\n"
|
||||
" -1 Compress faster\n"
|
||||
" -9 Compress better\n\n");
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
|
184
extlib/minizip-ng/minizip.c
vendored
184
extlib/minizip-ng/minizip.c
vendored
@ -18,23 +18,23 @@
|
||||
#include "mz_zip.h"
|
||||
#include "mz_zip_rw.h"
|
||||
|
||||
#include <stdio.h> /* printf */
|
||||
#include <stdio.h> /* printf */
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct minizip_opt_s {
|
||||
int64_t disk_size;
|
||||
int32_t encoding;
|
||||
uint8_t include_path;
|
||||
int16_t compress_level;
|
||||
uint8_t compress_method;
|
||||
uint8_t overwrite;
|
||||
uint8_t append;
|
||||
uint8_t follow_links;
|
||||
uint8_t store_links;
|
||||
uint8_t zip_cd;
|
||||
uint8_t verbose;
|
||||
uint8_t aes;
|
||||
int64_t disk_size;
|
||||
int32_t encoding;
|
||||
uint8_t include_path;
|
||||
int16_t compress_level;
|
||||
uint8_t compress_method;
|
||||
uint8_t overwrite;
|
||||
uint8_t append;
|
||||
uint8_t follow_links;
|
||||
uint8_t store_links;
|
||||
uint8_t zip_cd;
|
||||
uint8_t verbose;
|
||||
uint8_t aes;
|
||||
} minizip_opt;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -42,7 +42,7 @@ typedef struct minizip_opt_s {
|
||||
int32_t minizip_banner(void);
|
||||
int32_t minizip_help(void);
|
||||
|
||||
int32_t minizip_list(const char *path);
|
||||
int32_t minizip_list(const char *path, int32_t encoding);
|
||||
|
||||
int32_t minizip_add_entry_cb(void *handle, void *userdata, mz_zip_file *file_info);
|
||||
int32_t minizip_add_progress_cb(void *handle, void *userdata, mz_zip_file *file_info, int64_t position);
|
||||
@ -52,7 +52,8 @@ int32_t minizip_add(const char *path, const char *password, minizip_opt *options
|
||||
int32_t minizip_extract_entry_cb(void *handle, void *userdata, mz_zip_file *file_info, const char *path);
|
||||
int32_t minizip_extract_progress_cb(void *handle, void *userdata, mz_zip_file *file_info, int64_t position);
|
||||
int32_t minizip_extract_overwrite_cb(void *handle, void *userdata, mz_zip_file *file_info, const char *path);
|
||||
int32_t minizip_extract(const char *path, const char *pattern, const char *destination, const char *password, minizip_opt *options);
|
||||
int32_t minizip_extract(const char *path, const char *pattern, const char *destination, const char *password,
|
||||
minizip_opt *options);
|
||||
|
||||
int32_t minizip_erase(const char *src_path, const char *target_path, int32_t arg_count, const char **args);
|
||||
|
||||
@ -65,44 +66,46 @@ int32_t minizip_banner(void) {
|
||||
}
|
||||
|
||||
int32_t minizip_help(void) {
|
||||
printf("Usage: minizip [-x][-d dir|-l|-e][-o][-f][-y][-c cp][-a][-0 to -9][-b|-m|-t][-k 512][-p pwd][-s] file.zip [files]\n\n" \
|
||||
" -x Extract files\n" \
|
||||
" -l List files\n" \
|
||||
" -d Destination directory\n" \
|
||||
" -e Erase files\n" \
|
||||
" -o Overwrite existing files\n" \
|
||||
" -c File names use cp437 encoding (or specified codepage)\n" \
|
||||
" -a Append to existing zip file\n" \
|
||||
" -i Include full path of files\n" \
|
||||
" -f Follow symbolic links\n" \
|
||||
" -y Store symbolic links\n" \
|
||||
" -v Verbose info\n" \
|
||||
" -0 Store only\n" \
|
||||
" -1 Compress faster\n" \
|
||||
" -9 Compress better\n" \
|
||||
" -k Disk size in KB\n" \
|
||||
" -z Zip central directory\n" \
|
||||
" -p Encryption password\n" \
|
||||
" -s AES encryption\n" \
|
||||
" -b BZIP2 compression\n" \
|
||||
" -m LZMA compression\n" \
|
||||
" -n XZ compression\n" \
|
||||
" -t ZSTD compression\n\n");
|
||||
printf(
|
||||
"Usage: minizip [-x][-d dir|-l|-e][-o][-f][-y][-c cp][-a][-0 to -9][-b|-m|-t][-k 512][-p pwd][-s] file.zip "
|
||||
"[files]\n\n"
|
||||
" -x Extract files\n"
|
||||
" -l List files\n"
|
||||
" -d Destination directory\n"
|
||||
" -e Erase files\n"
|
||||
" -o Overwrite existing files\n"
|
||||
" -c File names use cp437 encoding (or specified codepage)\n"
|
||||
" -a Append to existing zip file\n"
|
||||
" -i Include full path of files\n"
|
||||
" -f Follow symbolic links\n"
|
||||
" -y Store symbolic links\n"
|
||||
" -v Verbose info\n"
|
||||
" -0 Store only\n"
|
||||
" -1 Compress faster\n"
|
||||
" -9 Compress better\n"
|
||||
" -k Disk size in KB\n"
|
||||
" -z Zip central directory\n"
|
||||
" -p Encryption password\n"
|
||||
" -s AES encryption\n"
|
||||
" -b BZIP2 compression\n"
|
||||
" -m LZMA compression\n"
|
||||
" -n XZ compression\n"
|
||||
" -t ZSTD compression\n\n");
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
int32_t minizip_list(const char *path) {
|
||||
int32_t minizip_list(const char *path, int32_t encoding) {
|
||||
mz_zip_file *file_info = NULL;
|
||||
uint32_t ratio = 0;
|
||||
int32_t err = MZ_OK;
|
||||
struct tm tmu_date;
|
||||
const char *method = NULL;
|
||||
char *utf8_string = NULL;
|
||||
char crypt = ' ';
|
||||
void *reader = NULL;
|
||||
|
||||
|
||||
reader = mz_zip_reader_create();
|
||||
if (!reader)
|
||||
return MZ_MEM_ERROR;
|
||||
@ -114,6 +117,8 @@ int32_t minizip_list(const char *path) {
|
||||
return err;
|
||||
}
|
||||
|
||||
mz_zip_reader_set_encoding(reader, encoding);
|
||||
|
||||
err = mz_zip_reader_goto_first_entry(reader);
|
||||
|
||||
if (err != MZ_OK && err != MZ_END_OF_LIST) {
|
||||
@ -147,15 +152,25 @@ int32_t minizip_list(const char *path) {
|
||||
method = mz_zip_get_compression_method_string(file_info->compression_method);
|
||||
mz_zip_time_t_to_tm(file_info->modified_date, &tmu_date);
|
||||
|
||||
if ((encoding > 0) && (file_info->flag & MZ_ZIP_FLAG_UTF8) == 0) {
|
||||
utf8_string = mz_os_utf8_string_create(file_info->filename, encoding);
|
||||
if (!utf8_string) {
|
||||
err = MZ_MEM_ERROR;
|
||||
printf("Error %" PRId32 " creating UTF-8 string\n", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Print entry information */
|
||||
printf("%12" PRId64 " %12" PRId64 " %3" PRIu32 "%% %6s%c %8" PRIx32 " %2.2" PRIu32 \
|
||||
"-%2.2" PRIu32 "-%2.2" PRIu32 " %2.2" PRIu32 ":%2.2" PRIu32 " %8.8" PRIx32 " %s\n",
|
||||
file_info->compressed_size, file_info->uncompressed_size, ratio,
|
||||
method, crypt, file_info->external_fa,
|
||||
(uint32_t)tmu_date.tm_mon + 1, (uint32_t)tmu_date.tm_mday,
|
||||
(uint32_t)tmu_date.tm_year % 100,
|
||||
(uint32_t)tmu_date.tm_hour, (uint32_t)tmu_date.tm_min,
|
||||
file_info->crc, file_info->filename);
|
||||
printf("%12" PRId64 " %12" PRId64 " %3" PRIu32 "%% %6s%c %8" PRIx32 " %2.2" PRIu32 "-%2.2" PRIu32
|
||||
"-%2.2" PRIu32 " %2.2" PRIu32 ":%2.2" PRIu32 " %8.8" PRIx32 " %s\n",
|
||||
file_info->compressed_size, file_info->uncompressed_size, ratio, method, crypt, file_info->external_fa,
|
||||
(uint32_t)tmu_date.tm_mon + 1, (uint32_t)tmu_date.tm_mday, (uint32_t)tmu_date.tm_year % 100,
|
||||
(uint32_t)tmu_date.tm_hour, (uint32_t)tmu_date.tm_min, file_info->crc,
|
||||
utf8_string ? utf8_string : file_info->filename);
|
||||
|
||||
if (utf8_string)
|
||||
mz_os_utf8_string_delete(&utf8_string);
|
||||
|
||||
err = mz_zip_reader_goto_next_entry(reader);
|
||||
|
||||
@ -199,9 +214,10 @@ int32_t minizip_add_progress_cb(void *handle, void *userdata, mz_zip_file *file_
|
||||
progress = ((double)position / file_info->uncompressed_size) * 100;
|
||||
|
||||
/* Print the progress of the current compress operation */
|
||||
if (options->verbose)
|
||||
if (options->verbose) {
|
||||
printf("%s - %" PRId64 " / %" PRId64 " (%.02f%%)\n", file_info->filename, position,
|
||||
file_info->uncompressed_size, progress);
|
||||
file_info->uncompressed_size, progress);
|
||||
}
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
@ -234,14 +250,14 @@ int32_t minizip_add_overwrite_cb(void *handle, void *userdata, const char *path)
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t minizip_add(const char *path, const char *password, minizip_opt *options, int32_t arg_count, const char **args) {
|
||||
int32_t minizip_add(const char *path, const char *password, minizip_opt *options, int32_t arg_count,
|
||||
const char **args) {
|
||||
void *writer = NULL;
|
||||
int32_t err = MZ_OK;
|
||||
int32_t err_close = MZ_OK;
|
||||
int32_t i = 0;
|
||||
const char *filename_in_zip = NULL;
|
||||
|
||||
|
||||
printf("Archive %s\n", path);
|
||||
|
||||
/* Create zip writer */
|
||||
@ -288,12 +304,24 @@ int32_t minizip_add(const char *path, const char *password, minizip_opt *options
|
||||
/***************************************************************************/
|
||||
|
||||
int32_t minizip_extract_entry_cb(void *handle, void *userdata, mz_zip_file *file_info, const char *path) {
|
||||
minizip_opt *options = (minizip_opt *)userdata;
|
||||
char *utf8_string = NULL;
|
||||
|
||||
MZ_UNUSED(handle);
|
||||
MZ_UNUSED(userdata);
|
||||
MZ_UNUSED(path);
|
||||
|
||||
if ((options->encoding > 0) && (file_info->flag & MZ_ZIP_FLAG_UTF8) == 0) {
|
||||
utf8_string = mz_os_utf8_string_create(file_info->filename, options->encoding);
|
||||
if (!utf8_string)
|
||||
return MZ_MEM_ERROR;
|
||||
}
|
||||
|
||||
/* Print the current entry extracting */
|
||||
printf("Extracting %s\n", file_info->filename);
|
||||
printf("Extracting %s\n", utf8_string ? utf8_string : file_info->filename);
|
||||
|
||||
if (utf8_string)
|
||||
mz_os_utf8_string_delete(&utf8_string);
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
@ -302,8 +330,6 @@ int32_t minizip_extract_progress_cb(void *handle, void *userdata, mz_zip_file *f
|
||||
double progress = 0;
|
||||
uint8_t raw = 0;
|
||||
|
||||
MZ_UNUSED(userdata);
|
||||
|
||||
mz_zip_reader_get_raw(handle, &raw);
|
||||
|
||||
if (raw && file_info->compressed_size > 0)
|
||||
@ -312,9 +338,10 @@ int32_t minizip_extract_progress_cb(void *handle, void *userdata, mz_zip_file *f
|
||||
progress = ((double)position / file_info->uncompressed_size) * 100;
|
||||
|
||||
/* Print the progress of the current extraction */
|
||||
if (options->verbose)
|
||||
if (options->verbose) {
|
||||
printf("%s - %" PRId64 " / %" PRId64 " (%.02f%%)\n", file_info->filename, position,
|
||||
file_info->uncompressed_size, progress);
|
||||
file_info->uncompressed_size, progress);
|
||||
}
|
||||
|
||||
return MZ_OK;
|
||||
}
|
||||
@ -347,7 +374,8 @@ int32_t minizip_extract_overwrite_cb(void *handle, void *userdata, mz_zip_file *
|
||||
return MZ_OK;
|
||||
}
|
||||
|
||||
int32_t minizip_extract(const char *path, const char *pattern, const char *destination, const char *password, minizip_opt *options) {
|
||||
int32_t minizip_extract(const char *path, const char *pattern, const char *destination, const char *password,
|
||||
minizip_opt *options) {
|
||||
void *reader = NULL;
|
||||
int32_t err = MZ_OK;
|
||||
int32_t err_close = MZ_OK;
|
||||
@ -573,35 +601,35 @@ int main(int argc, const char *argv[]) {
|
||||
if (options.compress_level == 0)
|
||||
options.compress_method = MZ_COMPRESS_METHOD_STORE;
|
||||
} else if ((c == 'b') || (c == 'B'))
|
||||
#ifdef HAVE_BZIP2
|
||||
# ifdef HAVE_BZIP2
|
||||
options.compress_method = MZ_COMPRESS_METHOD_BZIP2;
|
||||
#else
|
||||
# else
|
||||
err = MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
# endif
|
||||
else if ((c == 'm') || (c == 'M'))
|
||||
#ifdef HAVE_LZMA
|
||||
# ifdef HAVE_LZMA
|
||||
options.compress_method = MZ_COMPRESS_METHOD_LZMA;
|
||||
#else
|
||||
# else
|
||||
err = MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
# endif
|
||||
else if ((c == 'n') || (c == 'N'))
|
||||
#if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP)
|
||||
# if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP)
|
||||
options.compress_method = MZ_COMPRESS_METHOD_XZ;
|
||||
#else
|
||||
# else
|
||||
err = MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
# endif
|
||||
else if ((c == 't') || (c == 'T'))
|
||||
#ifdef HAVE_ZSTD
|
||||
# ifdef HAVE_ZSTD
|
||||
options.compress_method = MZ_COMPRESS_METHOD_ZSTD;
|
||||
#else
|
||||
# else
|
||||
err = MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
# endif
|
||||
else if ((c == 's') || (c == 'S'))
|
||||
#ifdef HAVE_WZAES
|
||||
# ifdef HAVE_WZAES
|
||||
options.aes = 1;
|
||||
#else
|
||||
# else
|
||||
err = MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
# endif
|
||||
else if (((c == 'c') || (c == 'C')) && (i + 1 < argc)) {
|
||||
options.encoding = (int32_t)atoi(argv[i + 1]);
|
||||
i += 1;
|
||||
@ -614,12 +642,12 @@ int main(int argc, const char *argv[]) {
|
||||
printf("%s ", argv[i + 1]);
|
||||
i += 1;
|
||||
} else if (((c == 'p') || (c == 'P')) && (i + 1 < argc)) {
|
||||
#ifndef MZ_ZIP_NO_ENCRYPTION
|
||||
# ifndef MZ_ZIP_NO_ENCRYPTION
|
||||
password = argv[i + 1];
|
||||
printf("*** ");
|
||||
#else
|
||||
# else
|
||||
err = MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
# endif
|
||||
i += 1;
|
||||
}
|
||||
} else if (path_arg == 0)
|
||||
@ -641,7 +669,7 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
if (do_list) {
|
||||
/* List archive contents */
|
||||
err = minizip_list(path);
|
||||
err = minizip_list(path, options.encoding);
|
||||
} else if (do_extract) {
|
||||
if (argc > path_arg + 1)
|
||||
filename_to_extract = argv[path_arg + 1];
|
||||
|
209
extlib/minizip-ng/mz.h
vendored
209
extlib/minizip-ng/mz.h
vendored
@ -14,143 +14,142 @@
|
||||
/***************************************************************************/
|
||||
|
||||
/* MZ_VERSION */
|
||||
#define MZ_VERSION ("4.0.7")
|
||||
#define MZ_VERSION_BUILD (0x040007)
|
||||
#define MZ_VERSION ("4.0.9")
|
||||
#define MZ_VERSION_BUILD (0x040009)
|
||||
|
||||
/* MZ_ERROR */
|
||||
#define MZ_OK (0) /* zlib */
|
||||
#define MZ_STREAM_ERROR (-1) /* zlib */
|
||||
#define MZ_DATA_ERROR (-3) /* zlib */
|
||||
#define MZ_MEM_ERROR (-4) /* zlib */
|
||||
#define MZ_BUF_ERROR (-5) /* zlib */
|
||||
#define MZ_VERSION_ERROR (-6) /* zlib */
|
||||
#define MZ_OK (0) /* zlib */
|
||||
#define MZ_STREAM_ERROR (-1) /* zlib */
|
||||
#define MZ_DATA_ERROR (-3) /* zlib */
|
||||
#define MZ_MEM_ERROR (-4) /* zlib */
|
||||
#define MZ_BUF_ERROR (-5) /* zlib */
|
||||
#define MZ_VERSION_ERROR (-6) /* zlib */
|
||||
|
||||
#define MZ_END_OF_LIST (-100)
|
||||
#define MZ_END_OF_STREAM (-101)
|
||||
#define MZ_END_OF_LIST (-100)
|
||||
#define MZ_END_OF_STREAM (-101)
|
||||
|
||||
#define MZ_PARAM_ERROR (-102)
|
||||
#define MZ_FORMAT_ERROR (-103)
|
||||
#define MZ_INTERNAL_ERROR (-104)
|
||||
#define MZ_CRC_ERROR (-105)
|
||||
#define MZ_CRYPT_ERROR (-106)
|
||||
#define MZ_EXIST_ERROR (-107)
|
||||
#define MZ_PASSWORD_ERROR (-108)
|
||||
#define MZ_SUPPORT_ERROR (-109)
|
||||
#define MZ_HASH_ERROR (-110)
|
||||
#define MZ_OPEN_ERROR (-111)
|
||||
#define MZ_CLOSE_ERROR (-112)
|
||||
#define MZ_SEEK_ERROR (-113)
|
||||
#define MZ_TELL_ERROR (-114)
|
||||
#define MZ_READ_ERROR (-115)
|
||||
#define MZ_WRITE_ERROR (-116)
|
||||
#define MZ_SIGN_ERROR (-117)
|
||||
#define MZ_SYMLINK_ERROR (-118)
|
||||
#define MZ_PARAM_ERROR (-102)
|
||||
#define MZ_FORMAT_ERROR (-103)
|
||||
#define MZ_INTERNAL_ERROR (-104)
|
||||
#define MZ_CRC_ERROR (-105)
|
||||
#define MZ_CRYPT_ERROR (-106)
|
||||
#define MZ_EXIST_ERROR (-107)
|
||||
#define MZ_PASSWORD_ERROR (-108)
|
||||
#define MZ_SUPPORT_ERROR (-109)
|
||||
#define MZ_HASH_ERROR (-110)
|
||||
#define MZ_OPEN_ERROR (-111)
|
||||
#define MZ_CLOSE_ERROR (-112)
|
||||
#define MZ_SEEK_ERROR (-113)
|
||||
#define MZ_TELL_ERROR (-114)
|
||||
#define MZ_READ_ERROR (-115)
|
||||
#define MZ_WRITE_ERROR (-116)
|
||||
#define MZ_SIGN_ERROR (-117)
|
||||
#define MZ_SYMLINK_ERROR (-118)
|
||||
|
||||
/* MZ_OPEN */
|
||||
#define MZ_OPEN_MODE_READ (0x01)
|
||||
#define MZ_OPEN_MODE_WRITE (0x02)
|
||||
#define MZ_OPEN_MODE_READWRITE (MZ_OPEN_MODE_READ | MZ_OPEN_MODE_WRITE)
|
||||
#define MZ_OPEN_MODE_APPEND (0x04)
|
||||
#define MZ_OPEN_MODE_CREATE (0x08)
|
||||
#define MZ_OPEN_MODE_EXISTING (0x10)
|
||||
#define MZ_OPEN_MODE_READ (0x01)
|
||||
#define MZ_OPEN_MODE_WRITE (0x02)
|
||||
#define MZ_OPEN_MODE_READWRITE (MZ_OPEN_MODE_READ | MZ_OPEN_MODE_WRITE)
|
||||
#define MZ_OPEN_MODE_APPEND (0x04)
|
||||
#define MZ_OPEN_MODE_CREATE (0x08)
|
||||
#define MZ_OPEN_MODE_EXISTING (0x10)
|
||||
|
||||
/* MZ_SEEK */
|
||||
#define MZ_SEEK_SET (0)
|
||||
#define MZ_SEEK_CUR (1)
|
||||
#define MZ_SEEK_END (2)
|
||||
#define MZ_SEEK_SET (0)
|
||||
#define MZ_SEEK_CUR (1)
|
||||
#define MZ_SEEK_END (2)
|
||||
|
||||
/* MZ_COMPRESS */
|
||||
#define MZ_COMPRESS_METHOD_STORE (0)
|
||||
#define MZ_COMPRESS_METHOD_DEFLATE (8)
|
||||
#define MZ_COMPRESS_METHOD_BZIP2 (12)
|
||||
#define MZ_COMPRESS_METHOD_LZMA (14)
|
||||
#define MZ_COMPRESS_METHOD_ZSTD (93)
|
||||
#define MZ_COMPRESS_METHOD_XZ (95)
|
||||
#define MZ_COMPRESS_METHOD_AES (99)
|
||||
#define MZ_COMPRESS_METHOD_STORE (0)
|
||||
#define MZ_COMPRESS_METHOD_DEFLATE (8)
|
||||
#define MZ_COMPRESS_METHOD_BZIP2 (12)
|
||||
#define MZ_COMPRESS_METHOD_LZMA (14)
|
||||
#define MZ_COMPRESS_METHOD_ZSTD (93)
|
||||
#define MZ_COMPRESS_METHOD_XZ (95)
|
||||
#define MZ_COMPRESS_METHOD_AES (99)
|
||||
|
||||
#define MZ_COMPRESS_LEVEL_DEFAULT (-1)
|
||||
#define MZ_COMPRESS_LEVEL_FAST (2)
|
||||
#define MZ_COMPRESS_LEVEL_NORMAL (6)
|
||||
#define MZ_COMPRESS_LEVEL_BEST (9)
|
||||
#define MZ_COMPRESS_LEVEL_DEFAULT (-1)
|
||||
#define MZ_COMPRESS_LEVEL_FAST (2)
|
||||
#define MZ_COMPRESS_LEVEL_NORMAL (6)
|
||||
#define MZ_COMPRESS_LEVEL_BEST (9)
|
||||
|
||||
/* MZ_ZIP_FLAG */
|
||||
#define MZ_ZIP_FLAG_ENCRYPTED (1 << 0)
|
||||
#define MZ_ZIP_FLAG_LZMA_EOS_MARKER (1 << 1)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_MAX (1 << 1)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_NORMAL (0)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_FAST (1 << 2)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST (MZ_ZIP_FLAG_DEFLATE_FAST | \
|
||||
MZ_ZIP_FLAG_DEFLATE_MAX)
|
||||
#define MZ_ZIP_FLAG_DATA_DESCRIPTOR (1 << 3)
|
||||
#define MZ_ZIP_FLAG_UTF8 (1 << 11)
|
||||
#define MZ_ZIP_FLAG_MASK_LOCAL_INFO (1 << 13)
|
||||
#define MZ_ZIP_FLAG_ENCRYPTED (1 << 0)
|
||||
#define MZ_ZIP_FLAG_LZMA_EOS_MARKER (1 << 1)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_MAX (1 << 1)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_NORMAL (0)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_FAST (1 << 2)
|
||||
#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST (MZ_ZIP_FLAG_DEFLATE_FAST | MZ_ZIP_FLAG_DEFLATE_MAX)
|
||||
#define MZ_ZIP_FLAG_DATA_DESCRIPTOR (1 << 3)
|
||||
#define MZ_ZIP_FLAG_UTF8 (1 << 11)
|
||||
#define MZ_ZIP_FLAG_MASK_LOCAL_INFO (1 << 13)
|
||||
|
||||
/* MZ_ZIP_EXTENSION */
|
||||
#define MZ_ZIP_EXTENSION_ZIP64 (0x0001)
|
||||
#define MZ_ZIP_EXTENSION_NTFS (0x000a)
|
||||
#define MZ_ZIP_EXTENSION_AES (0x9901)
|
||||
#define MZ_ZIP_EXTENSION_UNIX1 (0x000d)
|
||||
#define MZ_ZIP_EXTENSION_SIGN (0x10c5)
|
||||
#define MZ_ZIP_EXTENSION_HASH (0x1a51)
|
||||
#define MZ_ZIP_EXTENSION_CDCD (0xcdcd)
|
||||
#define MZ_ZIP_EXTENSION_ZIP64 (0x0001)
|
||||
#define MZ_ZIP_EXTENSION_NTFS (0x000a)
|
||||
#define MZ_ZIP_EXTENSION_AES (0x9901)
|
||||
#define MZ_ZIP_EXTENSION_UNIX1 (0x000d)
|
||||
#define MZ_ZIP_EXTENSION_SIGN (0x10c5)
|
||||
#define MZ_ZIP_EXTENSION_HASH (0x1a51)
|
||||
#define MZ_ZIP_EXTENSION_CDCD (0xcdcd)
|
||||
|
||||
/* MZ_ZIP64 */
|
||||
#define MZ_ZIP64_AUTO (0)
|
||||
#define MZ_ZIP64_FORCE (1)
|
||||
#define MZ_ZIP64_DISABLE (2)
|
||||
#define MZ_ZIP64_AUTO (0)
|
||||
#define MZ_ZIP64_FORCE (1)
|
||||
#define MZ_ZIP64_DISABLE (2)
|
||||
|
||||
/* MZ_HOST_SYSTEM */
|
||||
#define MZ_HOST_SYSTEM(VERSION_MADEBY) ((uint8_t)(VERSION_MADEBY >> 8))
|
||||
#define MZ_HOST_SYSTEM_MSDOS (0)
|
||||
#define MZ_HOST_SYSTEM_UNIX (3)
|
||||
#define MZ_HOST_SYSTEM_WINDOWS_NTFS (10)
|
||||
#define MZ_HOST_SYSTEM_RISCOS (13)
|
||||
#define MZ_HOST_SYSTEM_OSX_DARWIN (19)
|
||||
#define MZ_HOST_SYSTEM(VERSION_MADEBY) ((uint8_t)(VERSION_MADEBY >> 8))
|
||||
#define MZ_HOST_SYSTEM_MSDOS (0)
|
||||
#define MZ_HOST_SYSTEM_UNIX (3)
|
||||
#define MZ_HOST_SYSTEM_WINDOWS_NTFS (10)
|
||||
#define MZ_HOST_SYSTEM_RISCOS (13)
|
||||
#define MZ_HOST_SYSTEM_OSX_DARWIN (19)
|
||||
|
||||
/* MZ_PKCRYPT */
|
||||
#define MZ_PKCRYPT_HEADER_SIZE (12)
|
||||
#define MZ_PKCRYPT_HEADER_SIZE (12)
|
||||
|
||||
/* MZ_AES */
|
||||
#define MZ_AES_VERSION (1)
|
||||
#define MZ_AES_MODE_ECB (0)
|
||||
#define MZ_AES_MODE_CBC (1)
|
||||
#define MZ_AES_MODE_GCM (2)
|
||||
#define MZ_AES_STRENGTH_128 (1)
|
||||
#define MZ_AES_STRENGTH_192 (2)
|
||||
#define MZ_AES_STRENGTH_256 (3)
|
||||
#define MZ_AES_KEY_LENGTH_MAX (32)
|
||||
#define MZ_AES_BLOCK_SIZE (16)
|
||||
#define MZ_AES_FOOTER_SIZE (10)
|
||||
#define MZ_AES_VERSION (1)
|
||||
#define MZ_AES_MODE_ECB (0)
|
||||
#define MZ_AES_MODE_CBC (1)
|
||||
#define MZ_AES_MODE_GCM (2)
|
||||
#define MZ_AES_STRENGTH_128 (1)
|
||||
#define MZ_AES_STRENGTH_192 (2)
|
||||
#define MZ_AES_STRENGTH_256 (3)
|
||||
#define MZ_AES_KEY_LENGTH_MAX (32)
|
||||
#define MZ_AES_BLOCK_SIZE (16)
|
||||
#define MZ_AES_FOOTER_SIZE (10)
|
||||
|
||||
/* MZ_HASH */
|
||||
#define MZ_HASH_MD5 (10)
|
||||
#define MZ_HASH_MD5_SIZE (16)
|
||||
#define MZ_HASH_SHA1 (20)
|
||||
#define MZ_HASH_SHA1_SIZE (20)
|
||||
#define MZ_HASH_SHA224 (22)
|
||||
#define MZ_HASH_SHA224_SIZE (28)
|
||||
#define MZ_HASH_SHA256 (23)
|
||||
#define MZ_HASH_SHA256_SIZE (32)
|
||||
#define MZ_HASH_SHA384 (24)
|
||||
#define MZ_HASH_SHA384_SIZE (48)
|
||||
#define MZ_HASH_SHA512 (25)
|
||||
#define MZ_HASH_SHA512_SIZE (64)
|
||||
#define MZ_HASH_MAX_SIZE (256)
|
||||
#define MZ_HASH_MD5 (10)
|
||||
#define MZ_HASH_MD5_SIZE (16)
|
||||
#define MZ_HASH_SHA1 (20)
|
||||
#define MZ_HASH_SHA1_SIZE (20)
|
||||
#define MZ_HASH_SHA224 (22)
|
||||
#define MZ_HASH_SHA224_SIZE (28)
|
||||
#define MZ_HASH_SHA256 (23)
|
||||
#define MZ_HASH_SHA256_SIZE (32)
|
||||
#define MZ_HASH_SHA384 (24)
|
||||
#define MZ_HASH_SHA384_SIZE (48)
|
||||
#define MZ_HASH_SHA512 (25)
|
||||
#define MZ_HASH_SHA512_SIZE (64)
|
||||
#define MZ_HASH_MAX_SIZE (256)
|
||||
|
||||
/* MZ_ENCODING */
|
||||
#define MZ_ENCODING_CODEPAGE_437 (437)
|
||||
#define MZ_ENCODING_CODEPAGE_932 (932)
|
||||
#define MZ_ENCODING_CODEPAGE_936 (936)
|
||||
#define MZ_ENCODING_CODEPAGE_950 (950)
|
||||
#define MZ_ENCODING_UTF8 (65001)
|
||||
#define MZ_ENCODING_CODEPAGE_437 (437)
|
||||
#define MZ_ENCODING_CODEPAGE_932 (932)
|
||||
#define MZ_ENCODING_CODEPAGE_936 (936)
|
||||
#define MZ_ENCODING_CODEPAGE_950 (950)
|
||||
#define MZ_ENCODING_UTF8 (65001)
|
||||
|
||||
/* MZ_UTILITY */
|
||||
#define MZ_UNUSED(SYMBOL) ((void)SYMBOL)
|
||||
#define MZ_UNUSED(SYMBOL) ((void)SYMBOL)
|
||||
|
||||
#if defined(_WIN32) && defined(MZ_EXPORTS)
|
||||
#define MZ_EXPORT __declspec(dllexport)
|
||||
# define MZ_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define MZ_EXPORT
|
||||
# define MZ_EXPORT
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
1375
extlib/minizip-ng/mz_compat.c
vendored
1375
extlib/minizip-ng/mz_compat.c
vendored
File diff suppressed because it is too large
Load Diff
415
extlib/minizip-ng/mz_compat.h
vendored
415
extlib/minizip-ng/mz_compat.h
vendored
@ -1,415 +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.
|
||||
*/
|
||||
|
||||
#ifndef MZ_COMPAT_H
|
||||
#define MZ_COMPAT_H
|
||||
|
||||
#include "mz.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)
|
||||
#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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#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)
|
||||
#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, 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_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 */
|
||||
} unz_global_info;
|
||||
|
||||
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;
|
||||
|
||||
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 mz_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 */
|
||||
|
||||
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 */
|
||||
|
||||
struct tm tmu_date;
|
||||
|
||||
uint64_t disk_offset;
|
||||
} unz_file_info;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#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
|
12
extlib/minizip-ng/mz_compat_shim.h.in
vendored
12
extlib/minizip-ng/mz_compat_shim.h.in
vendored
@ -1,12 +0,0 @@
|
||||
/* @FILE_H@ -- Compatibility layer shim
|
||||
part of the minizip-ng project
|
||||
|
||||
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.
|
||||
*/
|
||||
#ifndef @MZ_COMPAT_FILE@
|
||||
#define @MZ_COMPAT_FILE@
|
||||
|
||||
#include "mz_compat.h"
|
||||
|
||||
#endif
|
89
extlib/minizip-ng/mz_crypt.c
vendored
89
extlib/minizip-ng/mz_crypt.c
vendored
@ -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;
|
||||
|
60
extlib/minizip-ng/mz_crypt.h
vendored
60
extlib/minizip-ng/mz_crypt.h
vendored
@ -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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
64
extlib/minizip-ng/mz_crypt_apple.c
vendored
64
extlib/minizip-ng/mz_crypt_apple.c
vendored
@ -20,8 +20,12 @@
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Avoid use of private API for iOS, Apple does not allow it on App Store. Zip format doesn't need GCM. */
|
||||
#if !TARGET_OS_IPHONE
|
||||
#ifndef MZ_TARGET_APPSTORE
|
||||
# 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. */
|
||||
#if !MZ_TARGET_APPSTORE
|
||||
enum {
|
||||
kCCModeGCM = 11,
|
||||
};
|
||||
@ -46,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};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -201,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;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -227,7 +229,7 @@ int32_t mz_crypt_aes_encrypt(void *handle, const void *aad, int32_t aad_size, ui
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
if (aes->mode == MZ_AES_MODE_GCM) {
|
||||
#if TARGET_OS_IPHONE
|
||||
#if MZ_TARGET_APPSTORE
|
||||
return MZ_SUPPORT_ERROR;
|
||||
#else
|
||||
if (aad && aad_size > 0) {
|
||||
@ -251,14 +253,14 @@ int32_t mz_crypt_aes_encrypt(void *handle, const void *aad, int32_t aad_size, ui
|
||||
|
||||
int32_t mz_crypt_aes_encrypt_final(void *handle, uint8_t *buf, int32_t size, uint8_t *tag, int32_t tag_size) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
#if !TARGET_OS_IPHONE
|
||||
#if !MZ_TARGET_APPSTORE
|
||||
size_t tag_outsize = tag_size;
|
||||
#endif
|
||||
|
||||
if (!aes || !tag || !tag_size || !aes->crypt || aes->mode != MZ_AES_MODE_GCM)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#if MZ_TARGET_APPSTORE
|
||||
return MZ_SUPPORT_ERROR;
|
||||
#else
|
||||
aes->error = CCCryptorGCMEncrypt(aes->crypt, buf, size, buf);
|
||||
@ -282,7 +284,7 @@ int32_t mz_crypt_aes_decrypt(void *handle, const void *aad, int32_t aad_size, ui
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
if (aes->mode == MZ_AES_MODE_GCM) {
|
||||
#if TARGET_OS_IPHONE
|
||||
#if MZ_TARGET_APPSTORE
|
||||
return MZ_SUPPORT_ERROR;
|
||||
#else
|
||||
if (aad && aad_size > 0) {
|
||||
@ -306,7 +308,7 @@ int32_t mz_crypt_aes_decrypt(void *handle, const void *aad, int32_t aad_size, ui
|
||||
|
||||
int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, const uint8_t *tag, int32_t tag_length) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
#if !TARGET_OS_IPHONE
|
||||
#if !MZ_TARGET_APPSTORE
|
||||
uint8_t tag_actual_buf[MZ_AES_BLOCK_SIZE];
|
||||
size_t tag_actual_len = sizeof(tag_actual_buf);
|
||||
uint8_t *tag_actual = tag_actual_buf;
|
||||
@ -317,7 +319,7 @@ int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, con
|
||||
if (!aes || !tag || !tag_length || !aes->crypt || aes->mode != MZ_AES_MODE_GCM)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#if MZ_TARGET_APPSTORE
|
||||
return MZ_SUPPORT_ERROR;
|
||||
#else
|
||||
aes->error = CCCryptorGCMDecrypt(aes->crypt, buf, size, buf);
|
||||
@ -343,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;
|
||||
|
||||
@ -353,7 +355,7 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
else if (aes->mode == MZ_AES_MODE_ECB)
|
||||
mode = kCCModeECB;
|
||||
else if (aes->mode == MZ_AES_MODE_GCM)
|
||||
#if !TARGET_OS_IPHONE
|
||||
#if !MZ_TARGET_APPSTORE
|
||||
mode = kCCModeGCM;
|
||||
#else
|
||||
return MZ_SUPPORT_ERROR;
|
||||
@ -363,13 +365,13 @@ 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;
|
||||
|
||||
#if !TARGET_OS_IPHONE
|
||||
#if !MZ_TARGET_APPSTORE
|
||||
if (aes->mode == MZ_AES_MODE_GCM) {
|
||||
aes->error = CCCryptorGCMAddIV(aes->crypt, iv, iv_length);
|
||||
|
||||
@ -381,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);
|
||||
}
|
||||
|
||||
@ -416,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;
|
||||
|
||||
/***************************************************************************/
|
||||
|
42
extlib/minizip-ng/mz_crypt_openssl.c
vendored
42
extlib/minizip-ng/mz_crypt_openssl.c
vendored
@ -59,22 +59,20 @@ typedef struct mz_crypt_sha_s {
|
||||
union {
|
||||
SHA512_CTX ctx512;
|
||||
SHA256_CTX ctx256;
|
||||
SHA_CTX ctx1;
|
||||
SHA_CTX ctx1;
|
||||
};
|
||||
#else
|
||||
EVP_MD_CTX *ctx;
|
||||
EVP_MD_CTX *ctx;
|
||||
#endif
|
||||
int32_t initialized;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
unsigned long 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};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -269,8 +267,8 @@ void mz_crypt_sha_delete(void **handle) {
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_crypt_aes_s {
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
int32_t mode;
|
||||
unsigned long error;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
} mz_crypt_aes;
|
||||
|
||||
@ -382,8 +380,8 @@ int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, con
|
||||
return size;
|
||||
}
|
||||
|
||||
static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_length,
|
||||
const void *iv, int32_t iv_length, int32_t encrypt) {
|
||||
static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_length, const void *iv,
|
||||
int32_t iv_length, int32_t encrypt) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
const EVP_CIPHER *type = NULL;
|
||||
|
||||
@ -430,8 +428,8 @@ 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) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
|
||||
if (!aes || !key || !key_length)
|
||||
@ -446,8 +444,8 @@ int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_
|
||||
return mz_crypt_aes_set_key(handle, key, key_length, iv, iv_length, 1);
|
||||
}
|
||||
|
||||
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) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
|
||||
if (!aes || !key || !key_length)
|
||||
@ -488,19 +486,19 @@ void mz_crypt_aes_delete(void **handle) {
|
||||
|
||||
typedef struct mz_crypt_hmac_s {
|
||||
#if OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||
HMAC_CTX *ctx;
|
||||
HMAC_CTX *ctx;
|
||||
#else
|
||||
EVP_MAC *mac;
|
||||
EVP_MAC *mac;
|
||||
EVP_MAC_CTX *ctx;
|
||||
#endif
|
||||
int32_t initialized;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
unsigned long error;
|
||||
int32_t initialized;
|
||||
uint16_t algorithm;
|
||||
} mz_crypt_hmac;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
|
||||
(defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x2070000fL))
|
||||
static HMAC_CTX *HMAC_CTX_new(void) {
|
||||
HMAC_CTX *ctx = OPENSSL_malloc(sizeof(HMAC_CTX));
|
||||
|
104
extlib/minizip-ng/mz_crypt_winvista.c
vendored
104
extlib/minizip-ng/mz_crypt_winvista.c
vendored
@ -19,11 +19,11 @@
|
||||
#endif
|
||||
|
||||
#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
#include <bcrypt.h>
|
||||
# include <bcrypt.h>
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define NT_SUCCESS(status) ((status) >= 0)
|
||||
# define NT_SUCCESS(status) ((status) >= 0)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -47,13 +47,13 @@ int32_t mz_crypt_rand(uint8_t *buf, int32_t size) {
|
||||
typedef struct mz_crypt_sha_s {
|
||||
union {
|
||||
struct {
|
||||
BCRYPT_ALG_HANDLE provider;
|
||||
BCRYPT_ALG_HANDLE provider;
|
||||
BCRYPT_HASH_HANDLE hash;
|
||||
uint8_t *buffer;
|
||||
uint8_t *buffer;
|
||||
};
|
||||
};
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
} mz_crypt_sha;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -104,8 +104,8 @@ int32_t mz_crypt_sha_begin(void *handle) {
|
||||
|
||||
status = BCryptOpenAlgorithmProvider(&sha->provider, alg_id, NULL, 0);
|
||||
if (NT_SUCCESS(status)) {
|
||||
status = BCryptGetProperty(sha->provider, BCRYPT_OBJECT_LENGTH, (PUCHAR)&buffer_size, result_size,
|
||||
&result_size, 0);
|
||||
status =
|
||||
BCryptGetProperty(sha->provider, BCRYPT_OBJECT_LENGTH, (PUCHAR)&buffer_size, result_size, &result_size, 0);
|
||||
}
|
||||
if (NT_SUCCESS(status)) {
|
||||
sha->buffer = malloc(buffer_size);
|
||||
@ -134,7 +134,7 @@ int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size) {
|
||||
if (sha->hash == 0)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
status = BCryptHashData(sha->hash, (uint8_t*)buf, size, 0);
|
||||
status = BCryptHashData(sha->hash, (uint8_t *)buf, size, 0);
|
||||
if (!NT_SUCCESS(status)) {
|
||||
sha->error = status;
|
||||
return MZ_HASH_ERROR;
|
||||
@ -199,22 +199,22 @@ void mz_crypt_sha_delete(void **handle) {
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define MZ_AES_MAX_TAG_SIZE (16)
|
||||
#define MZ_AES_MAX_NONCE_SIZE (12)
|
||||
# define MZ_AES_MAX_TAG_SIZE (16)
|
||||
# define MZ_AES_MAX_NONCE_SIZE (12)
|
||||
|
||||
typedef struct mz_crypt_aes_s {
|
||||
BCRYPT_ALG_HANDLE provider;
|
||||
BCRYPT_KEY_HANDLE key;
|
||||
uint8_t *key_buffer;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
uint8_t *iv;
|
||||
uint32_t iv_length;
|
||||
uint8_t nonce[MZ_AES_MAX_NONCE_SIZE];
|
||||
uint32_t nonce_length;
|
||||
uint8_t mac[MZ_AES_MAX_TAG_SIZE];
|
||||
uint8_t tag[MZ_AES_MAX_TAG_SIZE];
|
||||
uint32_t tag_size;
|
||||
uint8_t *key_buffer;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
uint8_t *iv;
|
||||
uint32_t iv_length;
|
||||
uint8_t nonce[MZ_AES_MAX_NONCE_SIZE];
|
||||
uint32_t nonce_length;
|
||||
uint8_t mac[MZ_AES_MAX_TAG_SIZE];
|
||||
uint8_t tag[MZ_AES_MAX_TAG_SIZE];
|
||||
uint32_t tag_size;
|
||||
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO *auth_info;
|
||||
} mz_crypt_aes;
|
||||
|
||||
@ -253,12 +253,11 @@ int32_t mz_crypt_aes_encrypt(void *handle, const void *aad, int32_t aad_size, ui
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
if (aad && aes->auth_info && !(aes->auth_info->dwFlags & BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG)) {
|
||||
aes->auth_info->pbAuthData = (uint8_t*)aad;
|
||||
aes->auth_info->pbAuthData = (uint8_t *)aad;
|
||||
aes->auth_info->cbAuthData = aad_size;
|
||||
}
|
||||
|
||||
status = BCryptEncrypt(aes->key, buf, size, aes->auth_info, aes->iv, aes->iv_length, buf, size,
|
||||
&output_size, 0);
|
||||
status = BCryptEncrypt(aes->key, buf, size, aes->auth_info, aes->iv, aes->iv_length, buf, size, &output_size, 0);
|
||||
|
||||
if (aad && aes->auth_info) {
|
||||
aes->auth_info->pbAuthData = NULL;
|
||||
@ -285,8 +284,7 @@ int32_t mz_crypt_aes_encrypt_final(void *handle, uint8_t *buf, int32_t size, uin
|
||||
|
||||
aes->auth_info->dwFlags &= ~BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG;
|
||||
|
||||
status = BCryptEncrypt(aes->key, buf, size, aes->auth_info, aes->iv, aes->iv_length, buf, size,
|
||||
&output_size, 0);
|
||||
status = BCryptEncrypt(aes->key, buf, size, aes->auth_info, aes->iv, aes->iv_length, buf, size, &output_size, 0);
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
aes->error = status;
|
||||
@ -309,12 +307,11 @@ int32_t mz_crypt_aes_decrypt(void *handle, const void *aad, int32_t aad_size, ui
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
if (aad && aes->auth_info && !(aes->auth_info->dwFlags & BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG)) {
|
||||
aes->auth_info->pbAuthData = (uint8_t*)aad;
|
||||
aes->auth_info->pbAuthData = (uint8_t *)aad;
|
||||
aes->auth_info->cbAuthData = aad_size;
|
||||
}
|
||||
|
||||
status = BCryptDecrypt(aes->key, buf, size, aes->auth_info, aes->iv, aes->iv_length, buf, size,
|
||||
&output_size, 0);
|
||||
status = BCryptDecrypt(aes->key, buf, size, aes->auth_info, aes->iv, aes->iv_length, buf, size, &output_size, 0);
|
||||
|
||||
if (aad && aes->auth_info) {
|
||||
aes->auth_info->pbAuthData = NULL;
|
||||
@ -341,8 +338,7 @@ int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, con
|
||||
|
||||
aes->auth_info->dwFlags &= ~BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG;
|
||||
|
||||
status = BCryptDecrypt(aes->key, buf, size, aes->auth_info, aes->iv, aes->iv_length, buf, size,
|
||||
&output_size, 0);
|
||||
status = BCryptDecrypt(aes->key, buf, size, aes->auth_info, aes->iv, aes->iv_length, buf, size, &output_size, 0);
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
aes->error = status;
|
||||
@ -352,8 +348,8 @@ int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, con
|
||||
return size;
|
||||
}
|
||||
|
||||
static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_length,
|
||||
const void *iv, int32_t iv_length) {
|
||||
static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_length, const void *iv,
|
||||
int32_t iv_length) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
BCRYPT_KEY_DATA_BLOB_HEADER *key_blob = NULL;
|
||||
int32_t key_blob_size = 0;
|
||||
@ -399,8 +395,8 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
ULONG result_size;
|
||||
status = BCryptGetProperty(aes->provider, BCRYPT_OBJECT_LENGTH, (PUCHAR)&key_size,
|
||||
sizeof(key_size), &result_size, 0);
|
||||
status = BCryptGetProperty(aes->provider, BCRYPT_OBJECT_LENGTH, (PUCHAR)&key_size, sizeof(key_size),
|
||||
&result_size, 0);
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
@ -414,10 +410,10 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
key_blob->dwVersion = BCRYPT_KEY_DATA_BLOB_VERSION1;
|
||||
key_blob->cbKeyData = key_length;
|
||||
|
||||
memcpy((uint8_t*)key_blob + sizeof(*key_blob), key, key_length);
|
||||
memcpy((uint8_t *)key_blob + sizeof(*key_blob), key, key_length);
|
||||
|
||||
status = BCryptImportKey(aes->provider, NULL, BCRYPT_KEY_DATA_BLOB, &aes->key, aes->key_buffer,
|
||||
key_size, (PUCHAR)key_blob, key_blob_size, 0);
|
||||
status = BCryptImportKey(aes->provider, NULL, BCRYPT_KEY_DATA_BLOB, &aes->key, aes->key_buffer, key_size,
|
||||
(PUCHAR)key_blob, key_blob_size, 0);
|
||||
SecureZeroMemory(key_blob, key_blob_size);
|
||||
free(key_blob);
|
||||
}
|
||||
@ -436,8 +432,8 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
if (NT_SUCCESS(status)) {
|
||||
BCRYPT_AUTH_TAG_LENGTHS_STRUCT tag_lengths;
|
||||
|
||||
status = BCryptGetProperty(aes->provider, BCRYPT_AUTH_TAG_LENGTH, (PUCHAR)&tag_lengths,
|
||||
sizeof(tag_lengths), &result_size, 0);
|
||||
status = BCryptGetProperty(aes->provider, BCRYPT_AUTH_TAG_LENGTH, (PUCHAR)&tag_lengths, sizeof(tag_lengths),
|
||||
&result_size, 0);
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
aes->tag_size = tag_lengths.dwMaxLength;
|
||||
@ -453,8 +449,8 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
if (NT_SUCCESS(status)) {
|
||||
ULONG block_length;
|
||||
|
||||
status = BCryptGetProperty(aes->provider, BCRYPT_BLOCK_LENGTH, (PUCHAR)&block_length,
|
||||
sizeof(block_length), &result_size, 0);
|
||||
status = BCryptGetProperty(aes->provider, BCRYPT_BLOCK_LENGTH, (PUCHAR)&block_length, sizeof(block_length),
|
||||
&result_size, 0);
|
||||
|
||||
if (NT_SUCCESS(status) && iv) {
|
||||
if (aes->iv_length > block_length)
|
||||
@ -479,13 +475,13 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
return err;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -514,12 +510,12 @@ void mz_crypt_aes_delete(void **handle) {
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_crypt_hmac_s {
|
||||
BCRYPT_ALG_HANDLE provider;
|
||||
BCRYPT_KEY_HANDLE key;
|
||||
BCRYPT_ALG_HANDLE provider;
|
||||
BCRYPT_KEY_HANDLE key;
|
||||
BCRYPT_HASH_HANDLE hash;
|
||||
uint8_t *buffer;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
uint8_t *buffer;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
} mz_crypt_hmac;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -561,8 +557,8 @@ int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length) {
|
||||
|
||||
status = BCryptOpenAlgorithmProvider(&hmac->provider, alg_id, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG);
|
||||
if (NT_SUCCESS(status)) {
|
||||
status = BCryptGetProperty(hmac->provider, BCRYPT_OBJECT_LENGTH, (PUCHAR)&buffer_size, result_size,
|
||||
&result_size, 0);
|
||||
status =
|
||||
BCryptGetProperty(hmac->provider, BCRYPT_OBJECT_LENGTH, (PUCHAR)&buffer_size, result_size, &result_size, 0);
|
||||
}
|
||||
if (NT_SUCCESS(status)) {
|
||||
hmac->buffer = malloc(buffer_size);
|
||||
@ -590,7 +586,7 @@ int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size) {
|
||||
if (!hmac || !buf || !hmac->hash)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
status = BCryptHashData(hmac->hash, (uint8_t*)buf, size, 0);
|
||||
status = BCryptHashData(hmac->hash, (uint8_t *)buf, size, 0);
|
||||
if (!NT_SUCCESS(status)) {
|
||||
hmac->error = status;
|
||||
return MZ_HASH_ERROR;
|
||||
|
61
extlib/minizip-ng/mz_crypt_winxp.c
vendored
61
extlib/minizip-ng/mz_crypt_winxp.c
vendored
@ -15,7 +15,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#if _WIN32_WINNT <= _WIN32_WINNT_WINXP
|
||||
#include <wincrypt.h>
|
||||
# include <wincrypt.h>
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -39,12 +39,12 @@ int32_t mz_crypt_rand(uint8_t *buf, int32_t size) {
|
||||
typedef struct mz_crypt_sha_s {
|
||||
union {
|
||||
struct {
|
||||
HCRYPTPROV provider;
|
||||
HCRYPTHASH hash;
|
||||
HCRYPTPROV provider;
|
||||
HCRYPTHASH hash;
|
||||
};
|
||||
};
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
} mz_crypt_sha;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -81,7 +81,7 @@ int32_t mz_crypt_sha_begin(void *handle) {
|
||||
case MZ_HASH_SHA1:
|
||||
alg_id = CALG_SHA1;
|
||||
break;
|
||||
#if NTDDI_VERSION > NTDDI_WINXPSP2
|
||||
# if NTDDI_VERSION > NTDDI_WINXPSP2
|
||||
case MZ_HASH_SHA256:
|
||||
alg_id = CALG_SHA_256;
|
||||
break;
|
||||
@ -91,12 +91,12 @@ int32_t mz_crypt_sha_begin(void *handle) {
|
||||
case MZ_HASH_SHA512:
|
||||
alg_id = CALG_SHA_512;
|
||||
break;
|
||||
#else
|
||||
# else
|
||||
case MZ_HASH_SHA256:
|
||||
case MZ_HASH_SHA384:
|
||||
case MZ_HASH_SHA512:
|
||||
return MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
# endif
|
||||
default:
|
||||
return MZ_PARAM_ERROR;
|
||||
}
|
||||
@ -197,9 +197,9 @@ void mz_crypt_sha_delete(void **handle) {
|
||||
|
||||
typedef struct mz_crypt_aes_s {
|
||||
HCRYPTPROV provider;
|
||||
HCRYPTKEY key;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
HCRYPTKEY key;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
} mz_crypt_aes;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -253,14 +253,14 @@ int32_t mz_crypt_aes_decrypt_final(void *handle, uint8_t *buf, int32_t size, con
|
||||
return MZ_SUPPORT_ERROR;
|
||||
}
|
||||
|
||||
static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_length,
|
||||
const void *iv, int32_t iv_length) {
|
||||
static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_length, const void *iv,
|
||||
int32_t iv_length) {
|
||||
mz_crypt_aes *aes = (mz_crypt_aes *)handle;
|
||||
HCRYPTHASH hash = 0;
|
||||
ALG_ID alg_id = 0;
|
||||
typedef struct key_blob_header_s {
|
||||
BLOBHEADER hdr;
|
||||
uint32_t key_length;
|
||||
uint32_t key_length;
|
||||
} key_blob_header_s;
|
||||
key_blob_header_s *key_blob_s = NULL;
|
||||
uint32_t mode;
|
||||
@ -295,7 +295,7 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
result = CryptAcquireContext(&aes->provider, NULL, MS_ENH_RSA_AES_PROV, PROV_RSA_AES,
|
||||
CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
|
||||
CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
|
||||
if (result) {
|
||||
key_blob_size = sizeof(key_blob_header_s) + key_length;
|
||||
key_blob = (uint8_t *)malloc(key_blob_size);
|
||||
@ -321,7 +321,6 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
if (result && err == MZ_OK)
|
||||
result = CryptSetKeyParam(aes->key, KP_MODE, (const uint8_t *)&mode, 0);
|
||||
|
||||
|
||||
if (!result && err == MZ_OK) {
|
||||
aes->error = GetLastError();
|
||||
err = MZ_CRYPT_ERROR;
|
||||
@ -345,13 +344,13 @@ static int32_t mz_crypt_aes_set_key(void *handle, const void *key, int32_t key_l
|
||||
return err;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -382,11 +381,11 @@ void mz_crypt_aes_delete(void **handle) {
|
||||
typedef struct mz_crypt_hmac_s {
|
||||
HCRYPTPROV provider;
|
||||
HCRYPTHASH hash;
|
||||
HCRYPTKEY key;
|
||||
HMAC_INFO info;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
HCRYPTKEY key;
|
||||
HMAC_INFO info;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
uint16_t algorithm;
|
||||
} mz_crypt_hmac;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -414,7 +413,7 @@ int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length) {
|
||||
ALG_ID alg_id = 0;
|
||||
typedef struct key_blob_header_s {
|
||||
BLOBHEADER hdr;
|
||||
uint32_t key_length;
|
||||
uint32_t key_length;
|
||||
} key_blob_header_s;
|
||||
key_blob_header_s *key_blob_s = NULL;
|
||||
uint8_t *key_blob = NULL;
|
||||
@ -431,16 +430,16 @@ int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length) {
|
||||
if (hmac->algorithm == MZ_HASH_SHA1)
|
||||
alg_id = CALG_SHA1;
|
||||
else
|
||||
#ifdef CALG_SHA_256
|
||||
# ifdef CALG_SHA_256
|
||||
alg_id = CALG_SHA_256;
|
||||
#else
|
||||
# else
|
||||
return MZ_SUPPORT_ERROR;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
hmac->info.HashAlgid = alg_id;
|
||||
|
||||
result = CryptAcquireContext(&hmac->provider, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL,
|
||||
CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
|
||||
result =
|
||||
CryptAcquireContext(&hmac->provider, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
|
||||
|
||||
if (!result) {
|
||||
hmac->error = GetLastError();
|
||||
|
18
extlib/minizip-ng/mz_os.c
vendored
18
extlib/minizip-ng/mz_os.c
vendored
@ -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;
|
||||
|
56
extlib/minizip-ng/mz_os.h
vendored
56
extlib/minizip-ng/mz_os.h
vendored
@ -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 <dirent.h>
|
||||
# include <dirent.h>
|
||||
#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);
|
||||
|
13
extlib/minizip-ng/mz_os_posix.c
vendored
13
extlib/minizip-ng/mz_os_posix.c
vendored
@ -15,7 +15,7 @@
|
||||
#include <stdio.h> /* rename */
|
||||
#include <errno.h>
|
||||
#if defined(HAVE_ICONV)
|
||||
#include <iconv.h>
|
||||
# include <iconv.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
@ -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);
|
||||
@ -90,7 +89,7 @@ char *mz_os_utf8_string_create(const char *string, int32_t encoding) {
|
||||
}
|
||||
#else
|
||||
char *mz_os_utf8_string_create(const char *string, int32_t encoding) {
|
||||
((void)encoding);
|
||||
MZ_UNUSED(encoding);
|
||||
return strdup(string);
|
||||
}
|
||||
#endif
|
||||
@ -148,7 +147,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));
|
||||
}
|
||||
|
||||
@ -273,11 +272,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);
|
||||
|
50
extlib/minizip-ng/mz_os_win32.c
vendored
50
extlib/minizip-ng/mz_os_win32.c
vendored
@ -34,10 +34,10 @@
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct DIR_int_s {
|
||||
void *find_handle;
|
||||
void *find_handle;
|
||||
WIN32_FIND_DATAW find_data;
|
||||
struct dirent entry;
|
||||
uint8_t end;
|
||||
struct dirent entry;
|
||||
uint8_t end;
|
||||
} DIR_int;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -240,8 +240,7 @@ static void mz_os_unix_to_file_time(time_t unix_time, FILETIME *file_time) {
|
||||
}
|
||||
|
||||
int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *accessed_date, time_t *creation_date) {
|
||||
WIN32_FIND_DATAW ff32;
|
||||
HANDLE handle = NULL;
|
||||
WIN32_FILE_ATTRIBUTE_DATA wfad;
|
||||
wchar_t *path_wide = NULL;
|
||||
int32_t err = MZ_INTERNAL_ERROR;
|
||||
|
||||
@ -251,21 +250,19 @@ int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *acc
|
||||
if (!path_wide)
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
handle = FindFirstFileW(path_wide, &ff32);
|
||||
free(path_wide);
|
||||
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
if (GetFileAttributesExW(path_wide, GetFileExInfoStandard, &wfad)) {
|
||||
if (modified_date)
|
||||
mz_os_file_to_unix_time(ff32.ftLastWriteTime, modified_date);
|
||||
mz_os_file_to_unix_time(wfad.ftLastWriteTime, modified_date);
|
||||
if (accessed_date)
|
||||
mz_os_file_to_unix_time(ff32.ftLastAccessTime, accessed_date);
|
||||
mz_os_file_to_unix_time(wfad.ftLastAccessTime, accessed_date);
|
||||
if (creation_date)
|
||||
mz_os_file_to_unix_time(ff32.ftCreationTime, creation_date);
|
||||
mz_os_file_to_unix_time(wfad.ftCreationTime, creation_date);
|
||||
|
||||
FindClose(handle);
|
||||
err = MZ_OK;
|
||||
}
|
||||
|
||||
free(path_wide);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -407,7 +404,7 @@ DIR *mz_os_open_dir(const char *path) {
|
||||
return (DIR *)dir_int;
|
||||
}
|
||||
|
||||
struct dirent* mz_os_read_dir(DIR *dir) {
|
||||
struct dirent *mz_os_read_dir(DIR *dir) {
|
||||
DIR_int *dir_int;
|
||||
|
||||
if (!dir)
|
||||
@ -417,8 +414,8 @@ struct dirent* mz_os_read_dir(DIR *dir) {
|
||||
if (dir_int->end)
|
||||
return NULL;
|
||||
|
||||
WideCharToMultiByte(CP_UTF8, 0, dir_int->find_data.cFileName, -1,
|
||||
dir_int->entry.d_name, sizeof(dir_int->entry.d_name), NULL, NULL);
|
||||
WideCharToMultiByte(CP_UTF8, 0, dir_int->find_data.cFileName, -1, dir_int->entry.d_name,
|
||||
sizeof(dir_int->entry.d_name), NULL, NULL);
|
||||
|
||||
if (FindNextFileW(dir_int->find_handle, &dir_int->find_data) == 0) {
|
||||
if (GetLastError() != ERROR_NO_MORE_FILES)
|
||||
@ -486,7 +483,7 @@ int32_t mz_os_is_symlink(const char *path) {
|
||||
}
|
||||
|
||||
int32_t mz_os_make_symlink(const char *path, const char *target_path) {
|
||||
typedef BOOLEAN (WINAPI *LPCREATESYMBOLICLINKW)(LPCWSTR, LPCWSTR, DWORD);
|
||||
typedef BOOLEAN(WINAPI * LPCREATESYMBOLICLINKW)(LPCWSTR, LPCWSTR, DWORD);
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
LPCREATESYMBOLICLINKW create_symbolic_link_w = NULL;
|
||||
HMODULE kernel32_mod = NULL;
|
||||
@ -536,7 +533,7 @@ int32_t mz_os_make_symlink(const char *path, const char *target_path) {
|
||||
|
||||
int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_target_path) {
|
||||
typedef struct _REPARSE_DATA_BUFFER {
|
||||
ULONG ReparseTag;
|
||||
ULONG ReparseTag;
|
||||
USHORT ReparseDataLength;
|
||||
USHORT Reserved;
|
||||
union {
|
||||
@ -545,18 +542,18 @@ int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_targ
|
||||
USHORT SubstituteNameLength;
|
||||
USHORT PrintNameOffset;
|
||||
USHORT PrintNameLength;
|
||||
ULONG Flags;
|
||||
WCHAR PathBuffer[1];
|
||||
ULONG Flags;
|
||||
WCHAR PathBuffer[1];
|
||||
} SymbolicLinkReparseBuffer;
|
||||
struct {
|
||||
USHORT SubstituteNameOffset;
|
||||
USHORT SubstituteNameLength;
|
||||
USHORT PrintNameOffset;
|
||||
USHORT PrintNameLength;
|
||||
WCHAR PathBuffer[1];
|
||||
WCHAR PathBuffer[1];
|
||||
} MountPointReparseBuffer;
|
||||
struct {
|
||||
UCHAR DataBuffer[1];
|
||||
UCHAR DataBuffer[1];
|
||||
} GenericReparseBuffer;
|
||||
};
|
||||
} REPARSE_DATA_BUFFER;
|
||||
@ -569,7 +566,7 @@ int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_targ
|
||||
int32_t target_path_len = 0;
|
||||
int32_t target_path_idx = 0;
|
||||
int32_t err = MZ_OK;
|
||||
char *target_path_utf8 = NULL;
|
||||
char *target_path_utf8 = NULL;
|
||||
|
||||
if (!path)
|
||||
return MZ_PARAM_ERROR;
|
||||
@ -589,7 +586,7 @@ int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_targ
|
||||
handle = CreateFile2(path_wide, FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, &extended_params);
|
||||
#else
|
||||
handle = CreateFileW(path_wide, FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
|
||||
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
|
||||
#endif
|
||||
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
@ -599,8 +596,7 @@ int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_targ
|
||||
|
||||
if (DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer, sizeof(buffer), &length, NULL) == TRUE) {
|
||||
reparse_data = (REPARSE_DATA_BUFFER *)buffer;
|
||||
if ((IsReparseTagMicrosoft(reparse_data->ReparseTag)) &&
|
||||
(reparse_data->ReparseTag == IO_REPARSE_TAG_SYMLINK)) {
|
||||
if ((IsReparseTagMicrosoft(reparse_data->ReparseTag)) && (reparse_data->ReparseTag == IO_REPARSE_TAG_SYMLINK)) {
|
||||
target_path_len = max_target_path * sizeof(wchar_t);
|
||||
if (target_path_len > reparse_data->SymbolicLinkReparseBuffer.PrintNameLength)
|
||||
target_path_len = reparse_data->SymbolicLinkReparseBuffer.PrintNameLength;
|
||||
@ -609,7 +605,7 @@ int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_targ
|
||||
if (target_path_wide) {
|
||||
target_path_idx = reparse_data->SymbolicLinkReparseBuffer.PrintNameOffset / sizeof(wchar_t);
|
||||
memcpy(target_path_wide, &reparse_data->SymbolicLinkReparseBuffer.PathBuffer[target_path_idx],
|
||||
target_path_len);
|
||||
target_path_len);
|
||||
|
||||
target_path_wide[target_path_len / sizeof(wchar_t)] = 0;
|
||||
target_path_utf8 = mz_os_utf8_string_create_from_unicode(target_path_wide, MZ_ENCODING_UTF8);
|
||||
|
39
extlib/minizip-ng/mz_strm.c
vendored
39
extlib/minizip-ng/mz_strm.c
vendored
@ -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};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -545,7 +537,6 @@ void mz_stream_raw_delete(void **stream) {
|
||||
if (!stream)
|
||||
return;
|
||||
raw = (mz_stream_raw *)*stream;
|
||||
if (raw)
|
||||
free(raw);
|
||||
free(raw);
|
||||
*stream = NULL;
|
||||
}
|
||||
|
90
extlib/minizip-ng/mz_strm.h
vendored
90
extlib/minizip-ng/mz_strm.h
vendored
@ -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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
103
extlib/minizip-ng/mz_strm_buf.c
vendored
103
extlib/minizip-ng/mz_strm_buf.c
vendored
@ -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);
|
||||
}
|
||||
|
||||
@ -368,8 +372,7 @@ void mz_stream_buffered_delete(void **stream) {
|
||||
if (!stream)
|
||||
return;
|
||||
buffered = (mz_stream_buffered *)*stream;
|
||||
if (buffered)
|
||||
free(buffered);
|
||||
free(buffered);
|
||||
*stream = NULL;
|
||||
}
|
||||
|
||||
|
6
extlib/minizip-ng/mz_strm_buf.h
vendored
6
extlib/minizip-ng/mz_strm_buf.h
vendored
@ -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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
55
extlib/minizip-ng/mz_strm_bzip.c
vendored
55
extlib/minizip-ng/mz_strm_bzip.c
vendored
@ -17,35 +17,25 @@
|
||||
/***************************************************************************/
|
||||
|
||||
static mz_stream_vtbl mz_stream_bzip_vtbl = {
|
||||
mz_stream_bzip_open,
|
||||
mz_stream_bzip_is_open,
|
||||
mz_stream_bzip_read,
|
||||
mz_stream_bzip_write,
|
||||
mz_stream_bzip_tell,
|
||||
mz_stream_bzip_seek,
|
||||
mz_stream_bzip_close,
|
||||
mz_stream_bzip_error,
|
||||
mz_stream_bzip_create,
|
||||
mz_stream_bzip_delete,
|
||||
mz_stream_bzip_get_prop_int64,
|
||||
mz_stream_bzip_set_prop_int64
|
||||
};
|
||||
mz_stream_bzip_open, mz_stream_bzip_is_open, mz_stream_bzip_read, mz_stream_bzip_write,
|
||||
mz_stream_bzip_tell, mz_stream_bzip_seek, mz_stream_bzip_close, mz_stream_bzip_error,
|
||||
mz_stream_bzip_create, mz_stream_bzip_delete, mz_stream_bzip_get_prop_int64, mz_stream_bzip_set_prop_int64};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_stream_bzip_s {
|
||||
mz_stream stream;
|
||||
bz_stream bzstream;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
uint8_t buffer[INT16_MAX];
|
||||
int32_t buffer_len;
|
||||
int16_t stream_end;
|
||||
int64_t total_in;
|
||||
int64_t total_out;
|
||||
int64_t max_total_in;
|
||||
int8_t initialized;
|
||||
int16_t level;
|
||||
mz_stream stream;
|
||||
bz_stream bzstream;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
uint8_t buffer[INT16_MAX];
|
||||
int32_t buffer_len;
|
||||
int16_t stream_end;
|
||||
int64_t total_in;
|
||||
int64_t total_out;
|
||||
int64_t max_total_in;
|
||||
int8_t initialized;
|
||||
int16_t level;
|
||||
} mz_stream_bzip;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -144,14 +134,12 @@ int32_t mz_stream_bzip_read(void *stream, void *buf, int32_t size) {
|
||||
}
|
||||
|
||||
total_in_before = bzip->bzstream.avail_in;
|
||||
total_out_before = bzip->bzstream.total_out_lo32 +
|
||||
(((uint64_t)bzip->bzstream.total_out_hi32) << 32);
|
||||
total_out_before = bzip->bzstream.total_out_lo32 + (((uint64_t)bzip->bzstream.total_out_hi32) << 32);
|
||||
|
||||
err = BZ2_bzDecompress(&bzip->bzstream);
|
||||
|
||||
total_in_after = bzip->bzstream.avail_in;
|
||||
total_out_after = bzip->bzstream.total_out_lo32 +
|
||||
(((uint64_t)bzip->bzstream.total_out_hi32) << 32);
|
||||
total_out_after = bzip->bzstream.total_out_lo32 + (((uint64_t)bzip->bzstream.total_out_hi32) << 32);
|
||||
|
||||
in_bytes = (int32_t)(total_in_before - total_in_after);
|
||||
out_bytes = (int32_t)(total_out_after - total_out_before);
|
||||
@ -205,13 +193,11 @@ static int32_t mz_stream_bzip_compress(void *stream, int flush) {
|
||||
bzip->buffer_len = 0;
|
||||
}
|
||||
|
||||
total_out_before = bzip->bzstream.total_out_lo32 +
|
||||
(((uint64_t)bzip->bzstream.total_out_hi32) << 32);
|
||||
total_out_before = bzip->bzstream.total_out_lo32 + (((uint64_t)bzip->bzstream.total_out_hi32) << 32);
|
||||
|
||||
err = BZ2_bzCompress(&bzip->bzstream, flush);
|
||||
|
||||
total_out_after = bzip->bzstream.total_out_lo32 +
|
||||
(((uint64_t)bzip->bzstream.total_out_hi32) << 32);
|
||||
total_out_after = bzip->bzstream.total_out_lo32 + (((uint64_t)bzip->bzstream.total_out_hi32) << 32);
|
||||
|
||||
out_bytes = (uint32_t)(total_out_after - total_out_before);
|
||||
|
||||
@ -350,8 +336,7 @@ void mz_stream_bzip_delete(void **stream) {
|
||||
if (!stream)
|
||||
return;
|
||||
bzip = (mz_stream_bzip *)*stream;
|
||||
if (bzip)
|
||||
free(bzip);
|
||||
free(bzip);
|
||||
*stream = NULL;
|
||||
}
|
||||
|
||||
|
8
extlib/minizip-ng/mz_strm_bzip.h
vendored
8
extlib/minizip-ng/mz_strm_bzip.h
vendored
@ -29,12 +29,12 @@ int32_t mz_stream_bzip_error(void *stream);
|
||||
int32_t mz_stream_bzip_get_prop_int64(void *stream, int32_t prop, int64_t *value);
|
||||
int32_t mz_stream_bzip_set_prop_int64(void *stream, int32_t prop, int64_t value);
|
||||
|
||||
void* mz_stream_bzip_create(void);
|
||||
void mz_stream_bzip_delete(void **stream);
|
||||
void *mz_stream_bzip_create(void);
|
||||
void mz_stream_bzip_delete(void **stream);
|
||||
|
||||
void* mz_stream_bzip_get_interface(void);
|
||||
void *mz_stream_bzip_get_interface(void);
|
||||
|
||||
void bz_internal_error(int errcode);
|
||||
void bz_internal_error(int errcode);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
42
extlib/minizip-ng/mz_strm_libcomp.c
vendored
42
extlib/minizip-ng/mz_strm_libcomp.c
vendored
@ -17,35 +17,25 @@
|
||||
/***************************************************************************/
|
||||
|
||||
static mz_stream_vtbl mz_stream_libcomp_vtbl = {
|
||||
mz_stream_libcomp_open,
|
||||
mz_stream_libcomp_is_open,
|
||||
mz_stream_libcomp_read,
|
||||
mz_stream_libcomp_write,
|
||||
mz_stream_libcomp_tell,
|
||||
mz_stream_libcomp_seek,
|
||||
mz_stream_libcomp_close,
|
||||
mz_stream_libcomp_error,
|
||||
mz_stream_libcomp_create,
|
||||
mz_stream_libcomp_delete,
|
||||
mz_stream_libcomp_get_prop_int64,
|
||||
mz_stream_libcomp_set_prop_int64
|
||||
};
|
||||
mz_stream_libcomp_open, mz_stream_libcomp_is_open, mz_stream_libcomp_read,
|
||||
mz_stream_libcomp_write, mz_stream_libcomp_tell, mz_stream_libcomp_seek,
|
||||
mz_stream_libcomp_close, mz_stream_libcomp_error, mz_stream_libcomp_create,
|
||||
mz_stream_libcomp_delete, mz_stream_libcomp_get_prop_int64, mz_stream_libcomp_set_prop_int64};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_stream_libcomp_s {
|
||||
mz_stream stream;
|
||||
compression_stream
|
||||
cstream;
|
||||
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;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
int16_t method;
|
||||
mz_stream stream;
|
||||
compression_stream cstream;
|
||||
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;
|
||||
int32_t mode;
|
||||
int32_t error;
|
||||
int16_t method;
|
||||
} mz_stream_libcomp;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -116,7 +106,6 @@ int32_t mz_stream_libcomp_read(void *stream, void *buf, int32_t size) {
|
||||
uint64_t total_in_after = 0;
|
||||
uint64_t total_out_before = 0;
|
||||
uint64_t total_out_after = 0;
|
||||
int32_t total_in = 0;
|
||||
int32_t total_out = 0;
|
||||
int32_t in_bytes = 0;
|
||||
int32_t out_bytes = 0;
|
||||
@ -161,7 +150,6 @@ int32_t mz_stream_libcomp_read(void *stream, void *buf, int32_t size) {
|
||||
in_bytes = (int32_t)(total_in_before - total_in_after);
|
||||
out_bytes = (int32_t)(total_out_before - total_out_after);
|
||||
|
||||
total_in += in_bytes;
|
||||
total_out += out_bytes;
|
||||
|
||||
libcomp->total_in += in_bytes;
|
||||
|
6
extlib/minizip-ng/mz_strm_libcomp.h
vendored
6
extlib/minizip-ng/mz_strm_libcomp.h
vendored
@ -31,10 +31,10 @@ int32_t mz_stream_libcomp_error(void *stream);
|
||||
int32_t mz_stream_libcomp_get_prop_int64(void *stream, int32_t prop, int64_t *value);
|
||||
int32_t mz_stream_libcomp_set_prop_int64(void *stream, int32_t prop, int64_t value);
|
||||
|
||||
void* mz_stream_libcomp_create(void);
|
||||
void mz_stream_libcomp_delete(void **stream);
|
||||
void *mz_stream_libcomp_create(void);
|
||||
void mz_stream_libcomp_delete(void **stream);
|
||||
|
||||
void* mz_stream_libcomp_get_interface(void);
|
||||
void *mz_stream_libcomp_get_interface(void);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
47
extlib/minizip-ng/mz_strm_lzma.c
vendored
47
extlib/minizip-ng/mz_strm_lzma.c
vendored
@ -23,38 +23,28 @@
|
||||
/***************************************************************************/
|
||||
|
||||
static mz_stream_vtbl mz_stream_lzma_vtbl = {
|
||||
mz_stream_lzma_open,
|
||||
mz_stream_lzma_is_open,
|
||||
mz_stream_lzma_read,
|
||||
mz_stream_lzma_write,
|
||||
mz_stream_lzma_tell,
|
||||
mz_stream_lzma_seek,
|
||||
mz_stream_lzma_close,
|
||||
mz_stream_lzma_error,
|
||||
mz_stream_lzma_create,
|
||||
mz_stream_lzma_delete,
|
||||
mz_stream_lzma_get_prop_int64,
|
||||
mz_stream_lzma_set_prop_int64
|
||||
};
|
||||
mz_stream_lzma_open, mz_stream_lzma_is_open, mz_stream_lzma_read, mz_stream_lzma_write,
|
||||
mz_stream_lzma_tell, mz_stream_lzma_seek, mz_stream_lzma_close, mz_stream_lzma_error,
|
||||
mz_stream_lzma_create, mz_stream_lzma_delete, mz_stream_lzma_get_prop_int64, mz_stream_lzma_set_prop_int64};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_stream_lzma_s {
|
||||
mz_stream stream;
|
||||
mz_stream stream;
|
||||
lzma_stream lstream;
|
||||
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;
|
||||
int64_t max_total_out;
|
||||
int8_t initialized;
|
||||
int8_t header;
|
||||
int32_t header_size;
|
||||
uint32_t preset;
|
||||
int16_t method;
|
||||
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;
|
||||
int64_t max_total_out;
|
||||
int8_t initialized;
|
||||
int8_t header;
|
||||
int32_t header_size;
|
||||
uint32_t preset;
|
||||
int16_t method;
|
||||
} mz_stream_lzma;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -453,8 +443,7 @@ void mz_stream_lzma_delete(void **stream) {
|
||||
if (!stream)
|
||||
return;
|
||||
lzma = (mz_stream_lzma *)*stream;
|
||||
if (lzma)
|
||||
free(lzma);
|
||||
free(lzma);
|
||||
*stream = NULL;
|
||||
}
|
||||
|
||||
|
6
extlib/minizip-ng/mz_strm_lzma.h
vendored
6
extlib/minizip-ng/mz_strm_lzma.h
vendored
@ -29,10 +29,10 @@ int32_t mz_stream_lzma_error(void *stream);
|
||||
int32_t mz_stream_lzma_get_prop_int64(void *stream, int32_t prop, int64_t *value);
|
||||
int32_t mz_stream_lzma_set_prop_int64(void *stream, int32_t prop, int64_t value);
|
||||
|
||||
void* mz_stream_lzma_create(void);
|
||||
void mz_stream_lzma_delete(void **stream);
|
||||
void *mz_stream_lzma_create(void);
|
||||
void mz_stream_lzma_delete(void **stream);
|
||||
|
||||
void* mz_stream_lzma_get_interface(void);
|
||||
void *mz_stream_lzma_get_interface(void);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
42
extlib/minizip-ng/mz_strm_mem.c
vendored
42
extlib/minizip-ng/mz_strm_mem.c
vendored
@ -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;
|
||||
|
14
extlib/minizip-ng/mz_strm_mem.h
vendored
14
extlib/minizip-ng/mz_strm_mem.h
vendored
@ -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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
6
extlib/minizip-ng/mz_strm_os.h
vendored
6
extlib/minizip-ng/mz_strm_os.h
vendored
@ -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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
35
extlib/minizip-ng/mz_strm_os_posix.c
vendored
35
extlib/minizip-ng/mz_strm_os_posix.c
vendored
@ -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;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -188,8 +186,7 @@ void mz_stream_os_delete(void **stream) {
|
||||
if (!stream)
|
||||
return;
|
||||
posix = (mz_stream_posix *)*stream;
|
||||
if (posix)
|
||||
free(posix);
|
||||
free(posix);
|
||||
*stream = NULL;
|
||||
}
|
||||
|
||||
|
44
extlib/minizip-ng/mz_strm_os_win32.c
vendored
44
extlib/minizip-ng/mz_strm_os_win32.c
vendored
@ -27,7 +27,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef INVALID_SET_FILE_POINTER
|
||||
# define INVALID_SET_FILE_POINTER (DWORD)-1
|
||||
# define INVALID_SET_FILE_POINTER (DWORD)(-1)
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT_WIN8
|
||||
@ -36,27 +36,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_win32_s {
|
||||
mz_stream stream;
|
||||
HANDLE handle;
|
||||
int32_t error;
|
||||
mz_stream stream;
|
||||
HANDLE handle;
|
||||
int32_t error;
|
||||
} mz_stream_win32;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -103,11 +101,9 @@ int32_t mz_stream_os_open(void *stream, const char *path, int32_t mode) {
|
||||
return MZ_PARAM_ERROR;
|
||||
|
||||
#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
|
||||
win32->handle = CreateFile2(path_wide, desired_access, share_mode,
|
||||
creation_disposition, NULL);
|
||||
win32->handle = CreateFile2(path_wide, desired_access, share_mode, creation_disposition, NULL);
|
||||
#else
|
||||
win32->handle = CreateFileW(path_wide, desired_access, share_mode, NULL,
|
||||
creation_disposition, flags_attribs, NULL);
|
||||
win32->handle = CreateFileW(path_wide, desired_access, share_mode, NULL, creation_disposition, flags_attribs, NULL);
|
||||
#endif
|
||||
|
||||
mz_os_unicode_string_delete(&path_wide);
|
||||
@ -166,8 +162,8 @@ int32_t mz_stream_os_write(void *stream, const void *buf, int32_t size) {
|
||||
return written;
|
||||
}
|
||||
|
||||
static int32_t mz_stream_os_seekinternal(HANDLE handle, LARGE_INTEGER large_pos,
|
||||
LARGE_INTEGER *new_pos, uint32_t move_method) {
|
||||
static int32_t mz_stream_os_seekinternal(HANDLE handle, LARGE_INTEGER large_pos, LARGE_INTEGER *new_pos,
|
||||
uint32_t move_method) {
|
||||
#if _WIN32_WINNT >= _WIN32_WINNT_WINXP
|
||||
BOOL success = FALSE;
|
||||
success = SetFilePointerEx(handle, large_pos, new_pos, move_method);
|
||||
|
69
extlib/minizip-ng/mz_strm_pkcrypt.c
vendored
69
extlib/minizip-ng/mz_strm_pkcrypt.c
vendored
@ -29,45 +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;
|
||||
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)))
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -161,10 +151,14 @@ 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++]);
|
||||
|
||||
/* Older versions used 2 byte check, newer versions use 1 byte check. */
|
||||
MZ_UNUSED(verify1);
|
||||
if ((verify2 != 0) && (verify2 != pkcrypt->verify2))
|
||||
/* 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;
|
||||
if (pkcrypt->verify_version < 2) {
|
||||
if (verify1 != pkcrypt->verify1)
|
||||
return MZ_PASSWORD_ERROR;
|
||||
}
|
||||
|
||||
pkcrypt->total_in += MZ_PKCRYPT_HEADER_SIZE;
|
||||
}
|
||||
@ -259,16 +253,18 @@ void mz_stream_pkcrypt_set_password(void *stream, const char *password) {
|
||||
pkcrypt->password = password;
|
||||
}
|
||||
|
||||
void mz_stream_pkcrypt_set_verify(void *stream, uint8_t verify1, uint8_t verify2) {
|
||||
void mz_stream_pkcrypt_set_verify(void *stream, uint8_t verify1, uint8_t verify2, uint16_t version) {
|
||||
mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream;
|
||||
pkcrypt->verify1 = verify1;
|
||||
pkcrypt->verify2 = verify2;
|
||||
pkcrypt->verify_version = version;
|
||||
}
|
||||
|
||||
void mz_stream_pkcrypt_get_verify(void *stream, uint8_t *verify1, uint8_t *verify2) {
|
||||
void mz_stream_pkcrypt_get_verify(void *stream, uint8_t *verify1, uint8_t *verify2, uint16_t *version) {
|
||||
mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream;
|
||||
*verify1 = pkcrypt->verify1;
|
||||
*verify2 = pkcrypt->verify2;
|
||||
*version = pkcrypt->verify_version;
|
||||
}
|
||||
|
||||
int32_t mz_stream_pkcrypt_get_prop_int64(void *stream, int32_t prop, int64_t *value) {
|
||||
@ -319,8 +315,7 @@ void mz_stream_pkcrypt_delete(void **stream) {
|
||||
if (!stream)
|
||||
return;
|
||||
pkcrypt = (mz_stream_pkcrypt *)*stream;
|
||||
if (pkcrypt)
|
||||
free(pkcrypt);
|
||||
free(pkcrypt);
|
||||
*stream = NULL;
|
||||
}
|
||||
|
||||
|
12
extlib/minizip-ng/mz_strm_pkcrypt.h
vendored
12
extlib/minizip-ng/mz_strm_pkcrypt.h
vendored
@ -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);
|
||||
void mz_stream_pkcrypt_get_verify(void *stream, uint8_t *verify1, uint8_t *verify2);
|
||||
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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
73
extlib/minizip-ng/mz_strm_split.c
vendored
73
extlib/minizip-ng/mz_strm_split.c
vendored
@ -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;
|
||||
int64_t disk_size;
|
||||
int64_t total_in;
|
||||
int64_t total_in_disk;
|
||||
int64_t total_out;
|
||||
int64_t total_out_disk;
|
||||
int32_t is_open;
|
||||
int32_t mode;
|
||||
char *path_cd;
|
||||
char *path_disk;
|
||||
uint32_t path_disk_size;
|
||||
int32_t number_disk;
|
||||
int64_t current_disk_size;
|
||||
int32_t current_disk;
|
||||
int32_t reached_end;
|
||||
mz_stream stream;
|
||||
int64_t disk_size;
|
||||
int64_t total_in;
|
||||
int64_t total_in_disk;
|
||||
int64_t total_out;
|
||||
int64_t total_out_disk;
|
||||
int32_t is_open;
|
||||
int32_t mode;
|
||||
char *path_cd;
|
||||
char *path_disk;
|
||||
uint32_t path_disk_size;
|
||||
int32_t number_disk;
|
||||
int64_t current_disk_size;
|
||||
int32_t current_disk;
|
||||
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 {
|
||||
@ -104,8 +93,13 @@ static int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk) {
|
||||
mz_stream_split_print("Split - Goto disk - %s (disk %" PRId32 ")\n", split->path_disk, number_disk);
|
||||
|
||||
/* If disk part doesn't exist during reading then return MZ_EXIST_ERROR */
|
||||
if (disk_part == MZ_OPEN_MODE_READ)
|
||||
err = mz_os_file_exists(split->path_disk);
|
||||
if (disk_part == MZ_OPEN_MODE_READ) {
|
||||
if (strcmp(split->path_disk, split->path_cd) == 0) {
|
||||
err = MZ_EXIST_ERROR;
|
||||
} else {
|
||||
err = mz_os_file_exists(split->path_disk);
|
||||
}
|
||||
}
|
||||
|
||||
if (err == MZ_OK)
|
||||
err = mz_stream_open(split->stream.base, split->path_disk, split->mode);
|
||||
@ -238,11 +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;
|
||||
err = mz_stream_split_goto_disk(stream, split->current_disk + 1);
|
||||
if (err == MZ_EXIST_ERROR) {
|
||||
split->current_disk = -1;
|
||||
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)
|
||||
split->current_disk = -1;
|
||||
if (err != MZ_OK)
|
||||
return err;
|
||||
}
|
||||
@ -410,11 +404,8 @@ void mz_stream_split_delete(void **stream) {
|
||||
return;
|
||||
split = (mz_stream_split *)*stream;
|
||||
if (split) {
|
||||
if (split->path_cd)
|
||||
free(split->path_cd);
|
||||
if (split->path_disk)
|
||||
free(split->path_disk);
|
||||
|
||||
free(split->path_cd);
|
||||
free(split->path_disk);
|
||||
free(split);
|
||||
}
|
||||
*stream = NULL;
|
||||
|
6
extlib/minizip-ng/mz_strm_split.h
vendored
6
extlib/minizip-ng/mz_strm_split.h
vendored
@ -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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
50
extlib/minizip-ng/mz_strm_wzaes.c
vendored
50
extlib/minizip-ng/mz_strm_wzaes.c
vendored
@ -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;
|
||||
|
10
extlib/minizip-ng/mz_strm_wzaes.h
vendored
10
extlib/minizip-ng/mz_strm_wzaes.h
vendored
@ -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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
55
extlib/minizip-ng/mz_strm_zlib.c
vendored
55
extlib/minizip-ng/mz_strm_zlib.c
vendored
@ -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;
|
||||
@ -379,8 +369,7 @@ void mz_stream_zlib_delete(void **stream) {
|
||||
if (!stream)
|
||||
return;
|
||||
zlib = (mz_stream_zlib *)*stream;
|
||||
if (zlib)
|
||||
free(zlib);
|
||||
free(zlib);
|
||||
*stream = NULL;
|
||||
}
|
||||
|
||||
|
6
extlib/minizip-ng/mz_strm_zlib.h
vendored
6
extlib/minizip-ng/mz_strm_zlib.h
vendored
@ -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);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
49
extlib/minizip-ng/mz_strm_zstd.c
vendored
49
extlib/minizip-ng/mz_strm_zstd.c
vendored
@ -19,38 +19,28 @@
|
||||
/***************************************************************************/
|
||||
|
||||
static mz_stream_vtbl mz_stream_zstd_vtbl = {
|
||||
mz_stream_zstd_open,
|
||||
mz_stream_zstd_is_open,
|
||||
mz_stream_zstd_read,
|
||||
mz_stream_zstd_write,
|
||||
mz_stream_zstd_tell,
|
||||
mz_stream_zstd_seek,
|
||||
mz_stream_zstd_close,
|
||||
mz_stream_zstd_error,
|
||||
mz_stream_zstd_create,
|
||||
mz_stream_zstd_delete,
|
||||
mz_stream_zstd_get_prop_int64,
|
||||
mz_stream_zstd_set_prop_int64
|
||||
};
|
||||
mz_stream_zstd_open, mz_stream_zstd_is_open, mz_stream_zstd_read, mz_stream_zstd_write,
|
||||
mz_stream_zstd_tell, mz_stream_zstd_seek, mz_stream_zstd_close, mz_stream_zstd_error,
|
||||
mz_stream_zstd_create, mz_stream_zstd_delete, mz_stream_zstd_get_prop_int64, mz_stream_zstd_set_prop_int64};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct mz_stream_zstd_s {
|
||||
mz_stream stream;
|
||||
ZSTD_CStream *zcstream;
|
||||
ZSTD_DStream *zdstream;
|
||||
ZSTD_outBuffer out;
|
||||
ZSTD_inBuffer in;
|
||||
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;
|
||||
int64_t max_total_out;
|
||||
int8_t initialized;
|
||||
int32_t preset;
|
||||
mz_stream stream;
|
||||
ZSTD_CStream *zcstream;
|
||||
ZSTD_DStream *zdstream;
|
||||
ZSTD_outBuffer out;
|
||||
ZSTD_inBuffer in;
|
||||
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;
|
||||
int64_t max_total_out;
|
||||
int8_t initialized;
|
||||
int32_t preset;
|
||||
} mz_stream_zstd;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -337,8 +327,7 @@ void mz_stream_zstd_delete(void **stream) {
|
||||
if (!stream)
|
||||
return;
|
||||
zstd = (mz_stream_zstd *)*stream;
|
||||
if (zstd)
|
||||
free(zstd);
|
||||
free(zstd);
|
||||
*stream = NULL;
|
||||
}
|
||||
|
||||
|
6
extlib/minizip-ng/mz_strm_zstd.h
vendored
6
extlib/minizip-ng/mz_strm_zstd.h
vendored
@ -30,10 +30,10 @@ int32_t mz_stream_zstd_error(void *stream);
|
||||
int32_t mz_stream_zstd_get_prop_int64(void *stream, int32_t prop, int64_t *value);
|
||||
int32_t mz_stream_zstd_set_prop_int64(void *stream, int32_t prop, int64_t value);
|
||||
|
||||
void* mz_stream_zstd_create(void);
|
||||
void mz_stream_zstd_delete(void **stream);
|
||||
void *mz_stream_zstd_create(void);
|
||||
void mz_stream_zstd_delete(void **stream);
|
||||
|
||||
void* mz_stream_zstd_get_interface(void);
|
||||
void *mz_stream_zstd_get_interface(void);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
289
extlib/minizip-ng/mz_zip.c
vendored
289
extlib/minizip-ng/mz_zip.c
vendored
@ -56,15 +56,15 @@
|
||||
/***************************************************************************/
|
||||
|
||||
#define MZ_ZIP_MAGIC_LOCALHEADER (0x04034b50)
|
||||
#define MZ_ZIP_MAGIC_LOCALHEADERU8 { 0x50, 0x4b, 0x03, 0x04 }
|
||||
#define MZ_ZIP_MAGIC_LOCALHEADERU8 {0x50, 0x4b, 0x03, 0x04}
|
||||
#define MZ_ZIP_MAGIC_CENTRALHEADER (0x02014b50)
|
||||
#define MZ_ZIP_MAGIC_CENTRALHEADERU8 { 0x50, 0x4b, 0x01, 0x02 }
|
||||
#define MZ_ZIP_MAGIC_CENTRALHEADERU8 {0x50, 0x4b, 0x01, 0x02}
|
||||
#define MZ_ZIP_MAGIC_ENDHEADER (0x06054b50)
|
||||
#define MZ_ZIP_MAGIC_ENDHEADERU8 { 0x50, 0x4b, 0x05, 0x06 }
|
||||
#define MZ_ZIP_MAGIC_ENDHEADERU8 {0x50, 0x4b, 0x05, 0x06}
|
||||
#define MZ_ZIP_MAGIC_ENDHEADER64 (0x06064b50)
|
||||
#define MZ_ZIP_MAGIC_ENDLOCHEADER64 (0x07064b50)
|
||||
#define MZ_ZIP_MAGIC_DATADESCRIPTOR (0x08074b50)
|
||||
#define MZ_ZIP_MAGIC_DATADESCRIPTORU8 { 0x50, 0x4b, 0x07, 0x08 }
|
||||
#define MZ_ZIP_MAGIC_DATADESCRIPTORU8 {0x50, 0x4b, 0x07, 0x08}
|
||||
|
||||
#define MZ_ZIP_SIZE_LD_ITEM (30)
|
||||
#define MZ_ZIP_SIZE_CD_ITEM (46)
|
||||
@ -75,7 +75,7 @@
|
||||
#define MZ_ZIP_UNCOMPR_SIZE64_CUSHION (2 * 1024 * 1024)
|
||||
|
||||
#ifndef MZ_ZIP_EOCD_MAX_BACK
|
||||
#define MZ_ZIP_EOCD_MAX_BACK (1 << 20)
|
||||
# define MZ_ZIP_EOCD_MAX_BACK (1 << 20)
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
@ -84,36 +84,36 @@ typedef struct mz_zip_s {
|
||||
mz_zip_file file_info;
|
||||
mz_zip_file local_file_info;
|
||||
|
||||
void *stream; /* main stream */
|
||||
void *cd_stream; /* pointer to the stream with the cd */
|
||||
void *cd_mem_stream; /* memory stream for central directory */
|
||||
void *compress_stream; /* compression stream */
|
||||
void *crypt_stream; /* encryption stream */
|
||||
void *file_info_stream; /* memory stream for storing file info */
|
||||
void *local_file_info_stream; /* memory stream for storing local file info */
|
||||
void *stream; /* main stream */
|
||||
void *cd_stream; /* pointer to the stream with the cd */
|
||||
void *cd_mem_stream; /* memory stream for central directory */
|
||||
void *compress_stream; /* compression stream */
|
||||
void *crypt_stream; /* encryption stream */
|
||||
void *file_info_stream; /* memory stream for storing file info */
|
||||
void *local_file_info_stream; /* memory stream for storing local file info */
|
||||
|
||||
int32_t open_mode;
|
||||
uint8_t recover;
|
||||
uint8_t data_descriptor;
|
||||
int32_t open_mode;
|
||||
uint8_t recover;
|
||||
uint8_t data_descriptor;
|
||||
|
||||
uint32_t disk_number_with_cd; /* number of the disk with the central dir */
|
||||
int64_t disk_offset_shift; /* correction for zips that have wrong offset start of cd */
|
||||
uint32_t disk_number_with_cd; /* number of the disk with the central dir */
|
||||
int64_t disk_offset_shift; /* correction for zips that have wrong offset start of cd */
|
||||
|
||||
int64_t cd_start_pos; /* pos of the first file in the central dir stream */
|
||||
int64_t cd_current_pos; /* pos of the current file in the central dir */
|
||||
int64_t cd_offset; /* offset of start of central directory */
|
||||
int64_t cd_size; /* size of the central directory */
|
||||
uint32_t cd_signature; /* signature of central directory */
|
||||
int64_t cd_start_pos; /* pos of the first file in the central dir stream */
|
||||
int64_t cd_current_pos; /* pos of the current file in the central dir */
|
||||
int64_t cd_offset; /* offset of start of central directory */
|
||||
int64_t cd_size; /* size of the central directory */
|
||||
uint32_t cd_signature; /* signature of central directory */
|
||||
|
||||
uint8_t entry_scanned; /* entry header information read ok */
|
||||
uint8_t entry_opened; /* entry is open for read/write */
|
||||
uint8_t entry_raw; /* entry opened with raw mode */
|
||||
uint32_t entry_crc32; /* entry crc32 */
|
||||
uint8_t entry_scanned; /* entry header information read ok */
|
||||
uint8_t entry_opened; /* entry is open for read/write */
|
||||
uint8_t entry_raw; /* entry opened with raw mode */
|
||||
uint32_t entry_crc32; /* entry crc32 */
|
||||
|
||||
uint64_t number_entry;
|
||||
|
||||
uint16_t version_madeby;
|
||||
char *comment;
|
||||
char *comment;
|
||||
} mz_zip;
|
||||
|
||||
/***************************************************************************/
|
||||
@ -188,8 +188,7 @@ static int32_t mz_zip_search_zip64_eocd(void *stream, const int64_t end_central_
|
||||
|
||||
#ifdef HAVE_PKCRYPT
|
||||
/* Get PKWARE traditional encryption verifier */
|
||||
static uint16_t mz_zip_get_pk_verify(uint32_t dos_date, uint64_t crc, uint16_t flag)
|
||||
{
|
||||
static uint16_t mz_zip_get_pk_verify(uint32_t dos_date, uint64_t crc, uint16_t flag) {
|
||||
/* Info-ZIP modification to ZipCrypto format: if bit 3 of the general
|
||||
* purpose bit flag is set, it uses high byte of 16-bit File Time. */
|
||||
if (flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR)
|
||||
@ -464,22 +463,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 +563,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 +643,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 +678,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;
|
||||
}
|
||||
@ -748,8 +743,8 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil
|
||||
|
||||
if (mask) {
|
||||
// rom-properties: PRIx64 requires uint64_t; file_info->disk_offset is int64_t.
|
||||
snprintf(masked_name, sizeof(masked_name), "%" PRIx32 "_%" PRIx64,
|
||||
file_info->disk_number, (uint64_t)file_info->disk_offset);
|
||||
snprintf(masked_name, sizeof(masked_name), "%" PRIx32 "_%" PRIx64, file_info->disk_number,
|
||||
(uint64_t)file_info->disk_offset);
|
||||
filename = masked_name;
|
||||
} else {
|
||||
filename = file_info->filename;
|
||||
@ -792,22 +787,22 @@ static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_fil
|
||||
}
|
||||
|
||||
if (err == MZ_OK) {
|
||||
const char *backslash = NULL;
|
||||
const char *next = filename;
|
||||
int32_t left = filename_length;
|
||||
#if defined(_WIN32)
|
||||
const char *backslash = NULL;
|
||||
|
||||
/* Ensure all slashes are written as forward slashes according to 4.4.17.1 */
|
||||
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;
|
||||
next = backslash + 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (err == MZ_OK && left > 0) {
|
||||
if (mz_stream_write(stream, next, left) != left)
|
||||
err = MZ_WRITE_ERROR;
|
||||
@ -923,7 +918,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);
|
||||
@ -985,7 +981,8 @@ static int32_t mz_zip_read_cd(void *handle) {
|
||||
if (err == MZ_OK)
|
||||
err = mz_stream_read_uint16(zip->stream, &value16);
|
||||
number_entry_cd = value16;
|
||||
if (number_entry_cd != zip->number_entry)
|
||||
/* When recover is enabled, we can ignore incorrect number of entries */
|
||||
if (number_entry_cd != zip->number_entry && !zip->recover)
|
||||
err = MZ_FORMAT_ERROR;
|
||||
/* Size of the central directory */
|
||||
if (err == MZ_OK)
|
||||
@ -1064,7 +1061,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);
|
||||
@ -1131,7 +1128,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 */
|
||||
@ -1281,8 +1278,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) {
|
||||
@ -1309,15 +1306,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 */
|
||||
@ -1329,16 +1326,17 @@ static int32_t mz_zip_recover_cd(void *handle) {
|
||||
}
|
||||
|
||||
if (local_file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR || local_file_info.compressed_size == 0) {
|
||||
/* Search backwards for the descriptor, seeking too far back will be incorrect if compressed size is small */
|
||||
/* Search backwards for the descriptor, seeking too far back will be incorrect if compressed size is
|
||||
* small */
|
||||
err = mz_stream_find_reverse(zip->stream, (const void *)descriptor_magic, sizeof(descriptor_magic),
|
||||
MZ_ZIP_SIZE_MAX_DATA_DESCRIPTOR, &descriptor_pos);
|
||||
MZ_ZIP_SIZE_MAX_DATA_DESCRIPTOR, &descriptor_pos);
|
||||
if (err == MZ_OK) {
|
||||
if (mz_zip_extrafield_contains(local_file_info.extrafield,
|
||||
local_file_info.extrafield_size, MZ_ZIP_EXTENSION_ZIP64, NULL) == MZ_OK)
|
||||
if (mz_zip_extrafield_contains(local_file_info.extrafield, local_file_info.extrafield_size,
|
||||
MZ_ZIP_EXTENSION_ZIP64, NULL) == MZ_OK)
|
||||
zip64 = 1;
|
||||
|
||||
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 (err == MZ_OK) {
|
||||
if (local_file_info.crc == 0)
|
||||
@ -1376,8 +1374,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);
|
||||
@ -1389,8 +1387,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;
|
||||
@ -1419,9 +1417,7 @@ void mz_zip_delete(void **handle) {
|
||||
if (!handle)
|
||||
return;
|
||||
zip = (mz_zip *)*handle;
|
||||
if (zip) {
|
||||
free(zip);
|
||||
}
|
||||
free(zip);
|
||||
*handle = NULL;
|
||||
}
|
||||
|
||||
@ -1563,8 +1559,7 @@ int32_t mz_zip_set_comment(void *handle, const char *comment) {
|
||||
int32_t comment_size = 0;
|
||||
if (!zip || !comment)
|
||||
return MZ_PARAM_ERROR;
|
||||
if (zip->comment)
|
||||
free(zip->comment);
|
||||
free(zip->comment);
|
||||
comment_size = (int32_t)strlen(comment);
|
||||
if (comment_size > UINT16_MAX)
|
||||
return MZ_PARAM_ERROR;
|
||||
@ -1754,7 +1749,7 @@ static int32_t mz_zip_entry_open_int(void *handle, uint8_t raw, int16_t compress
|
||||
if (!zip->crypt_stream)
|
||||
return MZ_MEM_ERROR;
|
||||
mz_stream_pkcrypt_set_password(zip->crypt_stream, password);
|
||||
mz_stream_pkcrypt_set_verify(zip->crypt_stream, verify1, verify2);
|
||||
mz_stream_pkcrypt_set_verify(zip->crypt_stream, verify1, verify2, zip->file_info.version_needed);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1785,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
|
||||
@ -1817,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
|
||||
{
|
||||
@ -1844,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1914,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;
|
||||
@ -1939,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));
|
||||
@ -2065,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;
|
||||
@ -2093,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 */
|
||||
@ -2124,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;
|
||||
}
|
||||
@ -2136,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;
|
||||
@ -2151,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)
|
||||
@ -2174,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;
|
||||
@ -2251,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);
|
||||
@ -2523,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;
|
||||
}
|
||||
@ -2549,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;
|
||||
}
|
||||
@ -2567,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;
|
||||
}
|
||||
@ -2616,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;
|
||||
|
||||
@ -2656,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
|
||||
}
|
||||
@ -2668,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;
|
||||
}
|
||||
|
||||
@ -2694,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) {
|
||||
@ -2737,7 +2735,8 @@ uint32_t mz_zip_tm_to_dosdate(const struct tm *ptm) {
|
||||
if (mz_zip_invalid_date(&fixed_tm))
|
||||
return 0;
|
||||
|
||||
return (((uint32_t)fixed_tm.tm_mday + (32 * ((uint32_t)fixed_tm.tm_mon + 1)) + (512 * (uint32_t)fixed_tm.tm_year)) << 16) |
|
||||
return (((uint32_t)fixed_tm.tm_mday + (32 * ((uint32_t)fixed_tm.tm_mon + 1)) + (512 * (uint32_t)fixed_tm.tm_year))
|
||||
<< 16) |
|
||||
(((uint32_t)fixed_tm.tm_sec / 2) + (32 * (uint32_t)fixed_tm.tm_min) + (2048 * (uint32_t)fixed_tm.tm_hour));
|
||||
}
|
||||
|
||||
@ -2755,8 +2754,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))
|
||||
@ -2777,8 +2775,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:
|
||||
|
91
extlib/minizip-ng/mz_zip.h
vendored
91
extlib/minizip-ng/mz_zip.h
vendored
@ -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 */
|
||||
|
||||
/***************************************************************************/
|
||||
|
218
extlib/minizip-ng/mz_zip_rw.c
vendored
218
extlib/minizip-ng/mz_zip_rw.c
vendored
@ -23,46 +23,42 @@
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define MZ_DEFAULT_PROGRESS_INTERVAL (1000u)
|
||||
#define MZ_DEFAULT_PROGRESS_INTERVAL (1000u)
|
||||
|
||||
#define MZ_ZIP_CD_FILENAME ("__cdcd__")
|
||||
#define MZ_ZIP_CD_FILENAME ("__cdcd__")
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
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;
|
||||
}
|
||||
@ -439,8 +435,8 @@ int32_t mz_zip_reader_entry_close(void *handle) {
|
||||
mz_crypt_sha_end(reader->hash, computed_hash, sizeof(computed_hash));
|
||||
mz_crypt_sha_delete(&reader->hash);
|
||||
|
||||
err_hash = mz_zip_reader_entry_get_hash(handle, reader->hash_algorithm, expected_hash,
|
||||
reader->hash_digest_size);
|
||||
err_hash =
|
||||
mz_zip_reader_entry_get_hash(handle, reader->hash_algorithm, expected_hash, reader->hash_digest_size);
|
||||
|
||||
if (err_hash == MZ_OK) {
|
||||
/* Verify expected hash against computed hash */
|
||||
@ -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,14 +748,15 @@ 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) {
|
||||
/* Set file attributes for the correct system */
|
||||
err_attrib = mz_zip_attrib_convert(MZ_HOST_SYSTEM(reader->file_info->version_madeby),
|
||||
reader->file_info->external_fa, MZ_VERSION_MADEBY_HOST_SYSTEM, &target_attrib);
|
||||
err_attrib =
|
||||
mz_zip_attrib_convert(MZ_HOST_SYSTEM(reader->file_info->version_madeby), reader->file_info->external_fa,
|
||||
MZ_VERSION_MADEBY_HOST_SYSTEM, &target_attrib);
|
||||
|
||||
if (err_attrib == MZ_OK)
|
||||
mz_os_set_file_attribs(pathwfs, target_attrib);
|
||||
@ -825,17 +815,21 @@ int32_t mz_zip_reader_save_all(void *handle, const char *destination_dir) {
|
||||
int32_t err = MZ_OK;
|
||||
int32_t utf8_name_size = 0;
|
||||
int32_t resolved_name_size = 0;
|
||||
int32_t destination_dir_len = 0;
|
||||
char *utf8_string = NULL;
|
||||
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);
|
||||
|
||||
if (err == MZ_END_OF_LIST)
|
||||
return err;
|
||||
|
||||
if (destination_dir)
|
||||
destination_dir_len = (int32_t)strlen(destination_dir) + 1;
|
||||
|
||||
while (err == MZ_OK) {
|
||||
/* Assume 4 bytes per character needed + 1 for terminating null */
|
||||
utf8_name_size = reader->file_info->filename_size * 4 + 1;
|
||||
@ -843,7 +837,7 @@ int32_t mz_zip_reader_save_all(void *handle, const char *destination_dir) {
|
||||
|
||||
if (destination_dir) {
|
||||
/* +1 is for the "/" separator */
|
||||
resolved_name_size += (int)strlen(destination_dir) + 1;
|
||||
resolved_name_size += destination_dir_len;
|
||||
}
|
||||
|
||||
new_alloc = (char *)realloc(path, resolved_name_size);
|
||||
@ -859,7 +853,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;
|
||||
}
|
||||
@ -874,7 +868,7 @@ int32_t mz_zip_reader_save_all(void *handle, const char *destination_dir) {
|
||||
if ((reader->encoding > 0) && (reader->file_info->flag & MZ_ZIP_FLAG_UTF8) == 0) {
|
||||
utf8_string = mz_os_utf8_string_create(reader->file_info->filename, reader->encoding);
|
||||
if (utf8_string) {
|
||||
strncpy(utf8_name, (char *)utf8_string, utf8_name_size - 1);
|
||||
strncpy(utf8_name, utf8_string, utf8_name_size - 1);
|
||||
utf8_name[utf8_name_size - 1] = 0;
|
||||
mz_os_utf8_string_delete(&utf8_string);
|
||||
}
|
||||
@ -1028,38 +1022,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 +1098,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 +1315,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 +1337,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 +1358,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 +1390,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);
|
||||
@ -1414,8 +1405,8 @@ int32_t mz_zip_writer_entry_close(void *handle) {
|
||||
|
||||
if (err == MZ_OK) {
|
||||
if (writer->raw)
|
||||
err = mz_zip_entry_close_raw(writer->zip_handle, writer->file_info.uncompressed_size,
|
||||
writer->file_info.crc);
|
||||
err =
|
||||
mz_zip_entry_close_raw(writer->zip_handle, writer->file_info.uncompressed_size, writer->file_info.crc);
|
||||
else
|
||||
err = mz_zip_entry_close(writer->zip_handle);
|
||||
}
|
||||
@ -1602,8 +1593,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 +1629,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;
|
||||
|
62
extlib/minizip-ng/mz_zip_rw.h
vendored
62
extlib/minizip-ng/mz_zip_rw.h
vendored
@ -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 */
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -12,7 +12,8 @@
|
||||
// MiniZip
|
||||
#include <zlib.h>
|
||||
#include "mz_zip.h"
|
||||
#include "mz_compat.h"
|
||||
#include "compat/ioapi.h"
|
||||
#include "compat/unzip.h"
|
||||
|
||||
// Other rom-properties libraries
|
||||
#include "librpbase/img/RpPng.hpp"
|
||||
|
@ -6,7 +6,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later *
|
||||
***************************************************************************/
|
||||
|
||||
// for HAVE_ZLIB for mz_compat.h
|
||||
// for HAVE_ZLIB for MiniZip
|
||||
#include "config.librpbase.h"
|
||||
|
||||
// Google Test
|
||||
@ -16,7 +16,8 @@
|
||||
// MiniZip
|
||||
#include <zlib.h>
|
||||
#include "mz_zip.h"
|
||||
#include "mz_compat.h"
|
||||
#include "compat/ioapi.h"
|
||||
#include "compat/unzip.h"
|
||||
|
||||
// Other rom-properties libraries
|
||||
#include "librpfile/FileSystem.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user