Extern :
- aggiunta libreria libzip.
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
#ifndef _HAD_LIBZIP_COMPAT_H
|
||||
#define _HAD_LIBZIP_COMPAT_H
|
||||
|
||||
/*
|
||||
compat.h -- compatibility defines.
|
||||
Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "zipconf.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/* to have *_MAX definitions for all types when compiling with g++ */
|
||||
#define __STDC_LIMIT_MACROS
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef ZIP_EXTERN
|
||||
#ifndef ZIP_STATIC
|
||||
#define ZIP_EXTERN __declspec(dllexport)
|
||||
#endif
|
||||
#endif
|
||||
/* for dup(), close(), etc. */
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#else
|
||||
typedef char bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* at least MinGW does not provide EOPNOTSUPP, see
|
||||
* http://sourceforge.net/p/mingw/bugs/263/
|
||||
*/
|
||||
#ifndef EOPNOTSUPP
|
||||
#define EOPNOTSUPP EINVAL
|
||||
#endif
|
||||
|
||||
/* at least MinGW does not provide EOVERFLOW, see
|
||||
* http://sourceforge.net/p/mingw/bugs/242/
|
||||
*/
|
||||
#ifndef EOVERFLOW
|
||||
#define EOVERFLOW EFBIG
|
||||
#endif
|
||||
|
||||
/* not supported on at least Windows */
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(HAVE__CLOSE)
|
||||
#define close _close
|
||||
#endif
|
||||
#if defined(HAVE__DUP)
|
||||
#define dup _dup
|
||||
#endif
|
||||
/* crashes reported when using fdopen instead of _fdopen on Windows/Visual Studio 10/Win64 */
|
||||
#if defined(HAVE__FDOPEN)
|
||||
#define fdopen _fdopen
|
||||
#endif
|
||||
#if !defined(HAVE_FILENO) && defined(HAVE__FILENO)
|
||||
#define fileno _fileno
|
||||
#endif
|
||||
#if defined(HAVE__SNPRINTF)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#if defined(HAVE__STRDUP)
|
||||
#if !defined(HAVE_STRDUP) || defined(_WIN32)
|
||||
#undef strdup
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(HAVE__SETMODE) && defined(HAVE_SETMODE)
|
||||
#define _setmode setmode
|
||||
#endif
|
||||
#if !defined(HAVE_STRTOLL) && defined(HAVE__STRTOI64)
|
||||
#define strtoll _strtoi64
|
||||
#endif
|
||||
#if !defined(HAVE_STRTOULL) && defined(HAVE__STRTOUI64)
|
||||
#define strtoull _strtoui64
|
||||
#endif
|
||||
#if defined(HAVE__UNLINK)
|
||||
#define unlink _unlink
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FSEEKO
|
||||
#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FTELLO
|
||||
#define ftello(s) ((long)ftell((s)))
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_STRCASECMP)
|
||||
#if defined(HAVE__STRICMP)
|
||||
#define strcasecmp _stricmp
|
||||
#elif defined(HAVE_STRICMP)
|
||||
#define strcasecmp stricmp
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SIZEOF_OFF_T == 8
|
||||
#define ZIP_OFF_MAX ZIP_INT64_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT64_MIN
|
||||
#elif SIZEOF_OFF_T == 4
|
||||
#define ZIP_OFF_MAX ZIP_INT32_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT32_MIN
|
||||
#elif SIZEOF_OFF_T == 2
|
||||
#define ZIP_OFF_MAX ZIP_INT16_MAX
|
||||
#define ZIP_OFF_MIN ZIP_INT16_MIN
|
||||
#else
|
||||
#error unsupported size of off_t
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)
|
||||
#define ZIP_FSEEK_MAX ZIP_OFF_MAX
|
||||
#define ZIP_FSEEK_MIN ZIP_OFF_MIN
|
||||
#else
|
||||
#include <limits.h>
|
||||
#define ZIP_FSEEK_MAX LONG_MAX
|
||||
#define ZIP_FSEEK_MIN LONG_MIN
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#if SIZEOF_SIZE_T == 8
|
||||
#define SIZE_MAX ZIP_INT64_MAX
|
||||
#elif SIZEOF_SIZE_T == 4
|
||||
#define SIZE_MAX ZIP_INT32_MAX
|
||||
#elif SIZEOF_SIZE_T == 2
|
||||
#define SIZE_MAX ZIP_INT16_MAX
|
||||
#else
|
||||
#error unsupported size of size_t
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PRId64
|
||||
#ifdef _MSC_VER
|
||||
#define PRId64 "I64d"
|
||||
#else
|
||||
#define PRId64 "lld"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PRIu64
|
||||
#ifdef _MSC_VER
|
||||
#define PRIu64 "I64u"
|
||||
#else
|
||||
#define PRIu64 "llu"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
#endif /* compat.h */
|
||||
@@ -0,0 +1,479 @@
|
||||
#ifndef _HAD_ZIP_H
|
||||
#define _HAD_ZIP_H
|
||||
|
||||
/*
|
||||
zip.h -- exported declarations.
|
||||
Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#if 0
|
||||
} /* fix autoindent */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <zipconf.h>
|
||||
|
||||
#ifndef ZIP_EXTERN
|
||||
#ifndef ZIP_STATIC
|
||||
#ifdef _WIN32
|
||||
#define ZIP_EXTERN __declspec(dllimport)
|
||||
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define ZIP_EXTERN __attribute__((visibility("default")))
|
||||
#else
|
||||
#define ZIP_EXTERN
|
||||
#endif
|
||||
#else
|
||||
#define ZIP_EXTERN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
/* flags for zip_open */
|
||||
|
||||
#define ZIP_CREATE 1
|
||||
#define ZIP_EXCL 2
|
||||
#define ZIP_CHECKCONS 4
|
||||
#define ZIP_TRUNCATE 8
|
||||
#define ZIP_RDONLY 16
|
||||
|
||||
|
||||
/* flags for zip_name_locate, zip_fopen, zip_stat, ... */
|
||||
|
||||
#define ZIP_FL_NOCASE 1u /* ignore case on name lookup */
|
||||
#define ZIP_FL_NODIR 2u /* ignore directory component */
|
||||
#define ZIP_FL_COMPRESSED 4u /* read compressed data */
|
||||
#define ZIP_FL_UNCHANGED 8u /* use original data, ignoring changes */
|
||||
#define ZIP_FL_RECOMPRESS 16u /* force recompression of data */
|
||||
#define ZIP_FL_ENCRYPTED 32u /* read encrypted data (implies ZIP_FL_COMPRESSED) */
|
||||
#define ZIP_FL_ENC_GUESS 0u /* guess string encoding (is default) */
|
||||
#define ZIP_FL_ENC_RAW 64u /* get unmodified string */
|
||||
#define ZIP_FL_ENC_STRICT 128u /* follow specification strictly */
|
||||
#define ZIP_FL_LOCAL 256u /* in local header */
|
||||
#define ZIP_FL_CENTRAL 512u /* in central directory */
|
||||
/* 1024u reserved for internal use */
|
||||
#define ZIP_FL_ENC_UTF_8 2048u /* string is UTF-8 encoded */
|
||||
#define ZIP_FL_ENC_CP437 4096u /* string is CP437 encoded */
|
||||
#define ZIP_FL_OVERWRITE 8192u /* zip_file_add: if file with name exists, overwrite (replace) it */
|
||||
|
||||
/* archive global flags flags */
|
||||
|
||||
#define ZIP_AFL_RDONLY 2u /* read only -- cannot be cleared */
|
||||
|
||||
|
||||
/* create a new extra field */
|
||||
|
||||
#define ZIP_EXTRA_FIELD_ALL ZIP_UINT16_MAX
|
||||
#define ZIP_EXTRA_FIELD_NEW ZIP_UINT16_MAX
|
||||
|
||||
|
||||
/* libzip error codes */
|
||||
|
||||
#define ZIP_ER_OK 0 /* N No error */
|
||||
#define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */
|
||||
#define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */
|
||||
#define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */
|
||||
#define ZIP_ER_SEEK 4 /* S Seek error */
|
||||
#define ZIP_ER_READ 5 /* S Read error */
|
||||
#define ZIP_ER_WRITE 6 /* S Write error */
|
||||
#define ZIP_ER_CRC 7 /* N CRC error */
|
||||
#define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */
|
||||
#define ZIP_ER_NOENT 9 /* N No such file */
|
||||
#define ZIP_ER_EXISTS 10 /* N File already exists */
|
||||
#define ZIP_ER_OPEN 11 /* S Can't open file */
|
||||
#define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */
|
||||
#define ZIP_ER_ZLIB 13 /* Z Zlib error */
|
||||
#define ZIP_ER_MEMORY 14 /* N Malloc failure */
|
||||
#define ZIP_ER_CHANGED 15 /* N Entry has been changed */
|
||||
#define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */
|
||||
#define ZIP_ER_EOF 17 /* N Premature end of file */
|
||||
#define ZIP_ER_INVAL 18 /* N Invalid argument */
|
||||
#define ZIP_ER_NOZIP 19 /* N Not a zip archive */
|
||||
#define ZIP_ER_INTERNAL 20 /* N Internal error */
|
||||
#define ZIP_ER_INCONS 21 /* N Zip archive inconsistent */
|
||||
#define ZIP_ER_REMOVE 22 /* S Can't remove file */
|
||||
#define ZIP_ER_DELETED 23 /* N Entry has been deleted */
|
||||
#define ZIP_ER_ENCRNOTSUPP 24 /* N Encryption method not supported */
|
||||
#define ZIP_ER_RDONLY 25 /* N Read-only archive */
|
||||
#define ZIP_ER_NOPASSWD 26 /* N No password provided */
|
||||
#define ZIP_ER_WRONGPASSWD 27 /* N Wrong password provided */
|
||||
#define ZIP_ER_OPNOTSUPP 28 /* N Operation not supported */
|
||||
#define ZIP_ER_INUSE 29 /* N Resource still in use */
|
||||
#define ZIP_ER_TELL 30 /* S Tell error */
|
||||
#define ZIP_ER_COMPRESSED_DATA 31 /* N Compressed data invalid */
|
||||
#define ZIP_ER_CANCELLED 32 /* N Operation cancelled */
|
||||
|
||||
/* type of system error value */
|
||||
|
||||
#define ZIP_ET_NONE 0 /* sys_err unused */
|
||||
#define ZIP_ET_SYS 1 /* sys_err is errno */
|
||||
#define ZIP_ET_ZLIB 2 /* sys_err is zlib error code */
|
||||
|
||||
/* compression methods */
|
||||
|
||||
#define ZIP_CM_DEFAULT -1 /* better of deflate or store */
|
||||
#define ZIP_CM_STORE 0 /* stored (uncompressed) */
|
||||
#define ZIP_CM_SHRINK 1 /* shrunk */
|
||||
#define ZIP_CM_REDUCE_1 2 /* reduced with factor 1 */
|
||||
#define ZIP_CM_REDUCE_2 3 /* reduced with factor 2 */
|
||||
#define ZIP_CM_REDUCE_3 4 /* reduced with factor 3 */
|
||||
#define ZIP_CM_REDUCE_4 5 /* reduced with factor 4 */
|
||||
#define ZIP_CM_IMPLODE 6 /* imploded */
|
||||
/* 7 - Reserved for Tokenizing compression algorithm */
|
||||
#define ZIP_CM_DEFLATE 8 /* deflated */
|
||||
#define ZIP_CM_DEFLATE64 9 /* deflate64 */
|
||||
#define ZIP_CM_PKWARE_IMPLODE 10 /* PKWARE imploding */
|
||||
/* 11 - Reserved by PKWARE */
|
||||
#define ZIP_CM_BZIP2 12 /* compressed using BZIP2 algorithm */
|
||||
/* 13 - Reserved by PKWARE */
|
||||
#define ZIP_CM_LZMA 14 /* LZMA (EFS) */
|
||||
/* 15-17 - Reserved by PKWARE */
|
||||
#define ZIP_CM_TERSE 18 /* compressed using IBM TERSE (new) */
|
||||
#define ZIP_CM_LZ77 19 /* IBM LZ77 z Architecture (PFS) */
|
||||
#define ZIP_CM_LZMA2 33
|
||||
#define ZIP_CM_XZ 95 /* XZ compressed data */
|
||||
#define ZIP_CM_JPEG 96 /* Compressed Jpeg data */
|
||||
#define ZIP_CM_WAVPACK 97 /* WavPack compressed data */
|
||||
#define ZIP_CM_PPMD 98 /* PPMd version I, Rev 1 */
|
||||
|
||||
/* encryption methods */
|
||||
|
||||
#define ZIP_EM_NONE 0 /* not encrypted */
|
||||
#define ZIP_EM_TRAD_PKWARE 1 /* traditional PKWARE encryption */
|
||||
#if 0 /* Strong Encryption Header not parsed yet */
|
||||
#define ZIP_EM_DES 0x6601 /* strong encryption: DES */
|
||||
#define ZIP_EM_RC2_OLD 0x6602 /* strong encryption: RC2, version < 5.2 */
|
||||
#define ZIP_EM_3DES_168 0x6603
|
||||
#define ZIP_EM_3DES_112 0x6609
|
||||
#define ZIP_EM_PKZIP_AES_128 0x660e
|
||||
#define ZIP_EM_PKZIP_AES_192 0x660f
|
||||
#define ZIP_EM_PKZIP_AES_256 0x6610
|
||||
#define ZIP_EM_RC2 0x6702 /* strong encryption: RC2, version >= 5.2 */
|
||||
#define ZIP_EM_RC4 0x6801
|
||||
#endif
|
||||
#define ZIP_EM_AES_128 0x0101 /* Winzip AES encryption */
|
||||
#define ZIP_EM_AES_192 0x0102
|
||||
#define ZIP_EM_AES_256 0x0103
|
||||
#define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */
|
||||
|
||||
#define ZIP_OPSYS_DOS 0x00u
|
||||
#define ZIP_OPSYS_AMIGA 0x01u
|
||||
#define ZIP_OPSYS_OPENVMS 0x02u
|
||||
#define ZIP_OPSYS_UNIX 0x03u
|
||||
#define ZIP_OPSYS_VM_CMS 0x04u
|
||||
#define ZIP_OPSYS_ATARI_ST 0x05u
|
||||
#define ZIP_OPSYS_OS_2 0x06u
|
||||
#define ZIP_OPSYS_MACINTOSH 0x07u
|
||||
#define ZIP_OPSYS_Z_SYSTEM 0x08u
|
||||
#define ZIP_OPSYS_CPM 0x09u
|
||||
#define ZIP_OPSYS_WINDOWS_NTFS 0x0au
|
||||
#define ZIP_OPSYS_MVS 0x0bu
|
||||
#define ZIP_OPSYS_VSE 0x0cu
|
||||
#define ZIP_OPSYS_ACORN_RISC 0x0du
|
||||
#define ZIP_OPSYS_VFAT 0x0eu
|
||||
#define ZIP_OPSYS_ALTERNATE_MVS 0x0fu
|
||||
#define ZIP_OPSYS_BEOS 0x10u
|
||||
#define ZIP_OPSYS_TANDEM 0x11u
|
||||
#define ZIP_OPSYS_OS_400 0x12u
|
||||
#define ZIP_OPSYS_OS_X 0x13u
|
||||
|
||||
#define ZIP_OPSYS_DEFAULT ZIP_OPSYS_UNIX
|
||||
|
||||
|
||||
enum zip_source_cmd {
|
||||
ZIP_SOURCE_OPEN, /* prepare for reading */
|
||||
ZIP_SOURCE_READ, /* read data */
|
||||
ZIP_SOURCE_CLOSE, /* reading is done */
|
||||
ZIP_SOURCE_STAT, /* get meta information */
|
||||
ZIP_SOURCE_ERROR, /* get error information */
|
||||
ZIP_SOURCE_FREE, /* cleanup and free resources */
|
||||
ZIP_SOURCE_SEEK, /* set position for reading */
|
||||
ZIP_SOURCE_TELL, /* get read position */
|
||||
ZIP_SOURCE_BEGIN_WRITE, /* prepare for writing */
|
||||
ZIP_SOURCE_COMMIT_WRITE, /* writing is done */
|
||||
ZIP_SOURCE_ROLLBACK_WRITE, /* discard written changes */
|
||||
ZIP_SOURCE_WRITE, /* write data */
|
||||
ZIP_SOURCE_SEEK_WRITE, /* set position for writing */
|
||||
ZIP_SOURCE_TELL_WRITE, /* get write position */
|
||||
ZIP_SOURCE_SUPPORTS, /* check whether source supports command */
|
||||
ZIP_SOURCE_REMOVE, /* remove file */
|
||||
ZIP_SOURCE_RESERVED_1, /* previously used internally */
|
||||
ZIP_SOURCE_BEGIN_WRITE_CLONING, /* like ZIP_SOURCE_BEGIN_WRITE, but keep part of original file */
|
||||
ZIP_SOURCE_ACCEPT_EMPTY, /* whether empty files are valid archives */
|
||||
ZIP_SOURCE_GET_FILE_ATTRIBUTES /* get additional file attributes */
|
||||
};
|
||||
typedef enum zip_source_cmd zip_source_cmd_t;
|
||||
|
||||
#define ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd) (((zip_int64_t)1) << (cmd))
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
#define ZIP_SOURCE_SUPPORTS_READABLE (ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_OPEN) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_READ) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_CLOSE) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_STAT) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ERROR) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_FREE))
|
||||
|
||||
#define ZIP_SOURCE_SUPPORTS_SEEKABLE (ZIP_SOURCE_SUPPORTS_READABLE \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SUPPORTS))
|
||||
|
||||
#define ZIP_SOURCE_SUPPORTS_WRITABLE (ZIP_SOURCE_SUPPORTS_SEEKABLE \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_COMMIT_WRITE) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ROLLBACK_WRITE) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_WRITE) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK_WRITE) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL_WRITE) \
|
||||
| ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_REMOVE))
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
/* for use by sources */
|
||||
struct zip_source_args_seek {
|
||||
zip_int64_t offset;
|
||||
int whence;
|
||||
};
|
||||
|
||||
typedef struct zip_source_args_seek zip_source_args_seek_t;
|
||||
#define ZIP_SOURCE_GET_ARGS(type, data, len, error) ((len) < sizeof(type) ? zip_error_set((error), ZIP_ER_INVAL, 0), (type *)NULL : (type *)(data))
|
||||
|
||||
|
||||
/* error information */
|
||||
/* use zip_error_*() to access */
|
||||
struct zip_error {
|
||||
int zip_err; /* libzip error code (ZIP_ER_*) */
|
||||
int sys_err; /* copy of errno (E*) or zlib error code */
|
||||
char *_Nullable str; /* string representation or NULL */
|
||||
};
|
||||
|
||||
#define ZIP_STAT_NAME 0x0001u
|
||||
#define ZIP_STAT_INDEX 0x0002u
|
||||
#define ZIP_STAT_SIZE 0x0004u
|
||||
#define ZIP_STAT_COMP_SIZE 0x0008u
|
||||
#define ZIP_STAT_MTIME 0x0010u
|
||||
#define ZIP_STAT_CRC 0x0020u
|
||||
#define ZIP_STAT_COMP_METHOD 0x0040u
|
||||
#define ZIP_STAT_ENCRYPTION_METHOD 0x0080u
|
||||
#define ZIP_STAT_FLAGS 0x0100u
|
||||
|
||||
struct zip_stat {
|
||||
zip_uint64_t valid; /* which fields have valid values */
|
||||
const char *_Nullable name; /* name of the file */
|
||||
zip_uint64_t index; /* index within archive */
|
||||
zip_uint64_t size; /* size of file (uncompressed) */
|
||||
zip_uint64_t comp_size; /* size of file (compressed) */
|
||||
time_t mtime; /* modification time */
|
||||
zip_uint32_t crc; /* crc of file data */
|
||||
zip_uint16_t comp_method; /* compression method used */
|
||||
zip_uint16_t encryption_method; /* encryption method used */
|
||||
zip_uint32_t flags; /* reserved for future use */
|
||||
};
|
||||
|
||||
struct zip_buffer_fragment {
|
||||
zip_uint8_t *_Nonnull data;
|
||||
zip_uint64_t length;
|
||||
};
|
||||
|
||||
struct zip_file_attributes {
|
||||
zip_uint64_t valid; /* which fields have valid values */
|
||||
zip_uint8_t version; /* version of this struct, currently 1 */
|
||||
zip_uint8_t host_system; /* host system on which file was created */
|
||||
zip_uint8_t ascii; /* flag whether file is ASCII text */
|
||||
zip_uint8_t version_needed; /* minimum version needed to extract file */
|
||||
zip_uint32_t external_file_attributes; /* external file attributes (host-system specific) */
|
||||
zip_uint16_t general_purpose_bit_flags; /* general purpose big flags, only some bits are honored */
|
||||
zip_uint16_t general_purpose_bit_mask; /* which bits in general_purpose_bit_flags are valid */
|
||||
};
|
||||
|
||||
#define ZIP_FILE_ATTRIBUTES_HOST_SYSTEM 0x0001u
|
||||
#define ZIP_FILE_ATTRIBUTES_ASCII 0x0002u
|
||||
#define ZIP_FILE_ATTRIBUTES_VERSION_NEEDED 0x0004u
|
||||
#define ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES 0x0008u
|
||||
#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS 0x0010u
|
||||
|
||||
struct zip;
|
||||
struct zip_file;
|
||||
struct zip_source;
|
||||
|
||||
typedef struct zip zip_t;
|
||||
typedef struct zip_error zip_error_t;
|
||||
typedef struct zip_file zip_file_t;
|
||||
typedef struct zip_file_attributes zip_file_attributes_t;
|
||||
typedef struct zip_source zip_source_t;
|
||||
typedef struct zip_stat zip_stat_t;
|
||||
typedef struct zip_buffer_fragment zip_buffer_fragment_t;
|
||||
|
||||
typedef zip_uint32_t zip_flags_t;
|
||||
|
||||
typedef zip_int64_t (*zip_source_callback)(void *_Nullable, void *_Nullable, zip_uint64_t, zip_source_cmd_t);
|
||||
typedef void (*zip_progress_callback)(zip_t *_Nonnull, double, void *_Nullable);
|
||||
typedef int (*zip_cancel_callback)(zip_t *_Nonnull, void *_Nullable);
|
||||
|
||||
#ifndef ZIP_DISABLE_DEPRECATED
|
||||
typedef void (*zip_progress_callback_t)(double);
|
||||
ZIP_EXTERN void zip_register_progress_callback(zip_t *_Nonnull, zip_progress_callback_t _Nullable); /* use zip_register_progress_callback_with_state */
|
||||
|
||||
ZIP_EXTERN zip_int64_t zip_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull); /* use zip_file_add */
|
||||
ZIP_EXTERN zip_int64_t zip_add_dir(zip_t *_Nonnull, const char *_Nonnull); /* use zip_dir_add */
|
||||
ZIP_EXTERN const char *_Nullable zip_get_file_comment(zip_t *_Nonnull, zip_uint64_t, int *_Nullable, int); /* use zip_file_get_comment */
|
||||
ZIP_EXTERN int zip_get_num_files(zip_t *_Nonnull); /* use zip_get_num_entries instead */
|
||||
ZIP_EXTERN int zip_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull); /* use zip_file_rename */
|
||||
ZIP_EXTERN int zip_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull); /* use zip_file_replace */
|
||||
ZIP_EXTERN int zip_set_file_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, int); /* use zip_file_set_comment */
|
||||
ZIP_EXTERN int zip_error_get_sys_type(int); /* use zip_error_system_type */
|
||||
ZIP_EXTERN void zip_error_get(zip_t *_Nonnull, int *_Nullable, int *_Nullable); /* use zip_get_error, zip_error_code_zip / zip_error_code_system */
|
||||
ZIP_EXTERN int zip_error_to_str(char *_Nonnull, zip_uint64_t, int, int); /* use zip_error_init_with_code / zip_error_strerror */
|
||||
ZIP_EXTERN void zip_file_error_get(zip_file_t *_Nonnull, int *_Nullable, int *_Nullable); /* use zip_file_get_error, zip_error_code_zip / zip_error_code_system */
|
||||
#endif
|
||||
|
||||
ZIP_EXTERN int zip_close(zip_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_delete(zip_t *_Nonnull, zip_uint64_t);
|
||||
ZIP_EXTERN zip_int64_t zip_dir_add(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t);
|
||||
ZIP_EXTERN void zip_discard(zip_t *_Nonnull);
|
||||
|
||||
ZIP_EXTERN zip_error_t *_Nonnull zip_get_error(zip_t *_Nonnull);
|
||||
ZIP_EXTERN void zip_error_clear(zip_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_error_code_zip(const zip_error_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_error_code_system(const zip_error_t *_Nonnull);
|
||||
ZIP_EXTERN void zip_error_fini(zip_error_t *_Nonnull);
|
||||
ZIP_EXTERN void zip_error_init(zip_error_t *_Nonnull);
|
||||
ZIP_EXTERN void zip_error_init_with_code(zip_error_t *_Nonnull, int);
|
||||
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int);
|
||||
ZIP_EXTERN const char *_Nonnull zip_error_strerror(zip_error_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_error_system_type(const zip_error_t *_Nonnull);
|
||||
ZIP_EXTERN zip_int64_t zip_error_to_data(const zip_error_t *_Nonnull, void *_Nonnull, zip_uint64_t);
|
||||
|
||||
ZIP_EXTERN int zip_fclose(zip_file_t *_Nonnull);
|
||||
ZIP_EXTERN zip_t *_Nullable zip_fdopen(int, int, int *_Nullable);
|
||||
ZIP_EXTERN zip_int64_t zip_file_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull, zip_flags_t);
|
||||
ZIP_EXTERN void zip_file_attributes_init(zip_file_attributes_t *_Nonnull);
|
||||
ZIP_EXTERN void zip_file_error_clear(zip_file_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_file_extra_field_delete(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_extra_field_delete_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_extra_field_set(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *_Nullable, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(zip_t *_Nonnull, zip_uint64_t, zip_flags_t);
|
||||
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_uint16_t *_Nullable, zip_flags_t);
|
||||
ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_flags_t);
|
||||
ZIP_EXTERN const char *_Nullable zip_file_get_comment(zip_t *_Nonnull, zip_uint64_t, zip_uint32_t *_Nullable, zip_flags_t);
|
||||
ZIP_EXTERN zip_error_t *_Nonnull zip_file_get_error(zip_file_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_file_get_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t *_Nullable, zip_uint32_t *_Nullable);
|
||||
ZIP_EXTERN int zip_file_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_set_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_set_dostime(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t);
|
||||
ZIP_EXTERN int zip_file_set_encryption(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, const char *_Nullable);
|
||||
ZIP_EXTERN int zip_file_set_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t);
|
||||
ZIP_EXTERN int zip_file_set_mtime(zip_t *_Nonnull, zip_uint64_t, time_t, zip_flags_t);
|
||||
ZIP_EXTERN const char *_Nonnull zip_file_strerror(zip_file_t *_Nonnull);
|
||||
ZIP_EXTERN zip_file_t *_Nullable zip_fopen(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t);
|
||||
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_encrypted(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, const char *_Nullable);
|
||||
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t);
|
||||
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index_encrypted(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, const char *_Nullable);
|
||||
ZIP_EXTERN zip_int64_t zip_fread(zip_file_t *_Nonnull, void *_Nonnull, zip_uint64_t);
|
||||
ZIP_EXTERN zip_int8_t zip_fseek(zip_file_t *_Nonnull, zip_int64_t, int);
|
||||
ZIP_EXTERN zip_int64_t zip_ftell(zip_file_t *_Nonnull);
|
||||
ZIP_EXTERN const char *_Nullable zip_get_archive_comment(zip_t *_Nonnull, int *_Nullable, zip_flags_t);
|
||||
ZIP_EXTERN int zip_get_archive_flag(zip_t *_Nonnull, zip_flags_t, zip_flags_t);
|
||||
ZIP_EXTERN const char *_Nullable zip_get_name(zip_t *_Nonnull, zip_uint64_t, zip_flags_t);
|
||||
ZIP_EXTERN zip_int64_t zip_get_num_entries(zip_t *_Nonnull, zip_flags_t);
|
||||
ZIP_EXTERN const char *_Nonnull zip_libzip_version(void);
|
||||
ZIP_EXTERN zip_int64_t zip_name_locate(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t);
|
||||
ZIP_EXTERN zip_t *_Nullable zip_open(const char *_Nonnull, int, int *_Nullable);
|
||||
ZIP_EXTERN zip_t *_Nullable zip_open_from_source(zip_source_t *_Nonnull, int, zip_error_t *_Nullable);
|
||||
ZIP_EXTERN int zip_register_progress_callback_with_state(zip_t *_Nonnull, double, zip_progress_callback _Nullable, void (*_Nullable)(void *_Nullable), void *_Nullable);
|
||||
ZIP_EXTERN int zip_register_cancel_callback_with_state(zip_t *_Nonnull, zip_cancel_callback _Nullable, void (*_Nullable)(void *_Nullable), void *_Nullable);
|
||||
ZIP_EXTERN int zip_set_archive_comment(zip_t *_Nonnull, const char *_Nullable, zip_uint16_t);
|
||||
ZIP_EXTERN int zip_set_archive_flag(zip_t *_Nonnull, zip_flags_t, int);
|
||||
ZIP_EXTERN int zip_set_default_password(zip_t *_Nonnull, const char *_Nullable);
|
||||
ZIP_EXTERN int zip_set_file_compression(zip_t *_Nonnull, zip_uint64_t, zip_int32_t, zip_uint32_t);
|
||||
ZIP_EXTERN int zip_source_begin_write(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_source_begin_write_cloning(zip_source_t *_Nonnull, zip_uint64_t);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer(zip_t *_Nonnull, const void *_Nullable, zip_uint64_t, int);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_create(const void *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment(zip_t *_Nonnull, const zip_buffer_fragment_t *_Nonnull, zip_uint64_t, int);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment_create(const zip_buffer_fragment_t *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable);
|
||||
ZIP_EXTERN int zip_source_close(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_source_commit_write(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN zip_error_t *_Nonnull zip_source_error(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_file(zip_t *_Nonnull, const char *_Nonnull, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_file_create(const char *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_filep(zip_t *_Nonnull, FILE *_Nonnull, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_filep_create(FILE *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable);
|
||||
ZIP_EXTERN void zip_source_free(zip_source_t *_Nullable);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_function(zip_t *_Nonnull, zip_source_callback _Nonnull, void *_Nullable);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_function_create(zip_source_callback _Nonnull, void *_Nullable, zip_error_t *_Nullable);
|
||||
ZIP_EXTERN int zip_source_get_file_attributes(zip_source_t *_Nonnull, zip_file_attributes_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_source_is_deleted(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN void zip_source_keep(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap(zip_source_cmd_t, ...);
|
||||
ZIP_EXTERN int zip_source_open(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN zip_int64_t zip_source_read(zip_source_t *_Nonnull, void *_Nonnull, zip_uint64_t);
|
||||
ZIP_EXTERN void zip_source_rollback_write(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_source_seek(zip_source_t *_Nonnull, zip_int64_t, int);
|
||||
ZIP_EXTERN zip_int64_t zip_source_seek_compute_offset(zip_uint64_t, zip_uint64_t, void *_Nonnull, zip_uint64_t, zip_error_t *_Nullable);
|
||||
ZIP_EXTERN int zip_source_seek_write(zip_source_t *_Nonnull, zip_int64_t, int);
|
||||
ZIP_EXTERN int zip_source_stat(zip_source_t *_Nonnull, zip_stat_t *_Nonnull);
|
||||
ZIP_EXTERN zip_int64_t zip_source_tell(zip_source_t *_Nonnull);
|
||||
ZIP_EXTERN zip_int64_t zip_source_tell_write(zip_source_t *_Nonnull);
|
||||
#ifdef _WIN32
|
||||
ZIP_EXTERN zip_source_t *zip_source_win32a(zip_t *, const char *, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN zip_source_t *zip_source_win32a_create(const char *, zip_uint64_t, zip_int64_t, zip_error_t *);
|
||||
ZIP_EXTERN zip_source_t *zip_source_win32handle(zip_t *, void *, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN zip_source_t *zip_source_win32handle_create(void *, zip_uint64_t, zip_int64_t, zip_error_t *);
|
||||
ZIP_EXTERN zip_source_t *zip_source_win32w(zip_t *, const wchar_t *, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN zip_source_t *zip_source_win32w_create(const wchar_t *, zip_uint64_t, zip_int64_t, zip_error_t *);
|
||||
#endif
|
||||
ZIP_EXTERN zip_int64_t zip_source_write(zip_source_t *_Nonnull, const void *_Nullable, zip_uint64_t);
|
||||
ZIP_EXTERN zip_source_t *_Nullable zip_source_zip(zip_t *_Nonnull, zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t);
|
||||
ZIP_EXTERN int zip_stat(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, zip_stat_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_stat_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_stat_t *_Nonnull);
|
||||
ZIP_EXTERN void zip_stat_init(zip_stat_t *_Nonnull);
|
||||
ZIP_EXTERN const char *_Nonnull zip_strerror(zip_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_unchange(zip_t *_Nonnull, zip_uint64_t);
|
||||
ZIP_EXTERN int zip_unchange_all(zip_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_unchange_archive(zip_t *_Nonnull);
|
||||
ZIP_EXTERN int zip_compression_method_supported(zip_int32_t method, int compress);
|
||||
ZIP_EXTERN int zip_encryption_method_supported(zip_uint16_t method, int encode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HAD_ZIP_H */
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
zip_crypto.h -- crypto definitions
|
||||
Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef HAD_ZIP_CRYPTO_H
|
||||
#define HAD_ZIP_CRYPTO_H
|
||||
|
||||
#define ZIP_CRYPTO_SHA1_LENGTH 20
|
||||
#define ZIP_CRYPTO_AES_BLOCK_LENGTH 16
|
||||
|
||||
#if defined(HAVE_WINDOWS_CRYPTO)
|
||||
#include "zip_crypto_win.h"
|
||||
#elif defined(HAVE_COMMONCRYPTO)
|
||||
#include "zip_crypto_commoncrypto.h"
|
||||
#elif defined(HAVE_GNUTLS)
|
||||
#include "zip_crypto_gnutls.h"
|
||||
#elif defined(HAVE_OPENSSL)
|
||||
#include "zip_crypto_openssl.h"
|
||||
#elif defined(HAVE_MBEDTLS)
|
||||
#include "zip_crypto_mbedtls.h"
|
||||
#else
|
||||
#error "no crypto backend found"
|
||||
#endif
|
||||
|
||||
#endif /* HAD_ZIP_CRYPTO_H */
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
zip_crypto_commoncrypto.h -- definitions for CommonCrypto wrapper.
|
||||
Copyright (C) 2018 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef HAD_ZIP_CRYPTO_COMMONCRYPTO_H
|
||||
#define HAD_ZIP_CRYPTO_COMMONCRYPTO_H
|
||||
|
||||
#include <CommonCrypto/CommonCrypto.h>
|
||||
|
||||
#define _zip_crypto_aes_t struct _CCCryptor
|
||||
#define _zip_crypto_hmac_t CCHmacContext
|
||||
|
||||
void _zip_crypto_aes_free(_zip_crypto_aes_t *aes);
|
||||
bool _zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out);
|
||||
_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error);
|
||||
|
||||
#define _zip_crypto_hmac(hmac, data, length) (CCHmacUpdate((hmac), (data), (length)), true)
|
||||
void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac);
|
||||
_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error);
|
||||
#define _zip_crypto_hmac_output(hmac, data) (CCHmacFinal((hmac), (data)), true)
|
||||
|
||||
#define _zip_crypto_pbkdf2(key, key_length, salt, salt_length, iterations, output, output_length) (CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)(key), (key_length), (salt), (salt_length), kCCPRFHmacAlgSHA1, (iterations), (output), (output_length)) == kCCSuccess)
|
||||
|
||||
#endif /* HAD_ZIP_CRYPTO_COMMONCRYPTO_H */
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
zip_crypto_gnutls.h -- definitions for GnuTLS wrapper.
|
||||
Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef HAD_ZIP_CRYPTO_GNUTLS_H
|
||||
#define HAD_ZIP_CRYPTO_GNUTLS_H
|
||||
|
||||
#define HAVE_SECURE_RANDOM
|
||||
|
||||
#include <nettle/aes.h>
|
||||
#include <nettle/pbkdf2.h>
|
||||
|
||||
#include <gnutls/gnutls.h>
|
||||
|
||||
#include <gnutls/crypto.h>
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct aes128_ctx ctx_128;
|
||||
struct aes192_ctx ctx_192;
|
||||
struct aes256_ctx ctx_256;
|
||||
} ctx;
|
||||
zip_uint16_t key_size;
|
||||
} _zip_crypto_aes_t;
|
||||
|
||||
#define _zip_crypto_hmac_t gnutls_hmac_hd_t
|
||||
|
||||
void _zip_crypto_aes_free(_zip_crypto_aes_t *aes);
|
||||
bool _zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out);
|
||||
_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error);
|
||||
|
||||
#define _zip_crypto_hmac(hmac, data, length) (gnutls_hmac(*(hmac), (data), (length)) == 0)
|
||||
void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac);
|
||||
_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error);
|
||||
#define _zip_crypto_hmac_output(hmac, data) (gnutls_hmac_output(*(hmac), (data)), true)
|
||||
|
||||
#define _zip_crypto_pbkdf2(key, key_length, salt, salt_length, iterations, output, output_length) (pbkdf2_hmac_sha1((key_length), (key), (iterations), (salt_length), (salt), (output_length), (output)), true)
|
||||
|
||||
#endif /* HAD_ZIP_CRYPTO_GNUTLS_H */
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
zip_crypto_mbedtls.h -- definitions for mbedtls wrapper
|
||||
Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef HAD_ZIP_CRYPTO_MBEDTLS_H
|
||||
#define HAD_ZIP_CRYPTO_MBEDTLS_H
|
||||
|
||||
#define HAVE_SECURE_RANDOM
|
||||
|
||||
#include <mbedtls/aes.h>
|
||||
#include <mbedtls/md.h>
|
||||
|
||||
#define _zip_crypto_aes_t mbedtls_aes_context
|
||||
#define _zip_crypto_hmac_t mbedtls_md_context_t
|
||||
|
||||
_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error);
|
||||
#define _zip_crypto_aes_encrypt_block(aes, in, out) (mbedtls_aes_crypt_ecb((aes), MBEDTLS_AES_ENCRYPT, (in), (out)) == 0)
|
||||
void _zip_crypto_aes_free(_zip_crypto_aes_t *aes);
|
||||
|
||||
_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error);
|
||||
#define _zip_crypto_hmac(hmac, data, length) (mbedtls_md_hmac_update((hmac), (data), (length)) == 0)
|
||||
#define _zip_crypto_hmac_output(hmac, data) (mbedtls_md_hmac_finish((hmac), (data)) == 0)
|
||||
void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac);
|
||||
|
||||
bool _zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, int iterations, zip_uint8_t *output, zip_uint64_t output_length);
|
||||
|
||||
#endif /* HAD_ZIP_CRYPTO_MBEDTLS_H */
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
zip_crypto_openssl.h -- definitions for OpenSSL wrapper.
|
||||
Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef HAD_ZIP_CRYPTO_OPENSSL_H
|
||||
#define HAD_ZIP_CRYPTO_OPENSSL_H
|
||||
|
||||
#define HAVE_SECURE_RANDOM
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
#define _zip_crypto_aes_t AES_KEY
|
||||
#define _zip_crypto_hmac_t HMAC_CTX
|
||||
|
||||
void _zip_crypto_aes_free(_zip_crypto_aes_t *aes);
|
||||
#define _zip_crypto_aes_encrypt_block(aes, in, out) (AES_encrypt((in), (out), (aes)), true)
|
||||
_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error);
|
||||
|
||||
#define _zip_crypto_hmac(hmac, data, length) (HMAC_Update((hmac), (data), (length)) == 1)
|
||||
void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac);
|
||||
_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error);
|
||||
bool _zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data);
|
||||
|
||||
#define _zip_crypto_pbkdf2(key, key_length, salt, salt_length, iterations, output, output_length) (PKCS5_PBKDF2_HMAC_SHA1((const char *)(key), (key_length), (salt), (salt_length), (iterations), (output_length), (output)))
|
||||
|
||||
#endif /* HAD_ZIP_CRYPTO_OPENSSL_H */
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
zip_crypto_win.h -- Windows Crypto API wrapper.
|
||||
Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef HAD_ZIP_CRYPTO_WIN_H
|
||||
#define HAD_ZIP_CRYPTO_WIN_H
|
||||
|
||||
#define HAVE_SECURE_RANDOM
|
||||
|
||||
typedef struct _zip_crypto_aes_s _zip_crypto_aes_t;
|
||||
typedef struct _zip_crypto_hmac_s _zip_crypto_hmac_t;
|
||||
|
||||
void _zip_crypto_aes_free(_zip_crypto_aes_t *aes);
|
||||
_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error);
|
||||
bool _zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out);
|
||||
|
||||
bool _zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, zip_uint16_t iterations, zip_uint8_t *output, zip_uint16_t output_length);
|
||||
|
||||
_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error);
|
||||
void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac);
|
||||
bool _zip_crypto_hmac(_zip_crypto_hmac_t *hmac, zip_uint8_t *data, zip_uint64_t length);
|
||||
bool _zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data);
|
||||
|
||||
#endif /* HAD_ZIP_CRYPTO_WIN_H */
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
zip_source_file.h -- header for common file operations
|
||||
Copyright (C) 2020 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
struct zip_source_file_stat {
|
||||
zip_uint64_t size; /* must be valid for regular files */
|
||||
time_t mtime; /* must always be valid, is initialized to current time */
|
||||
bool exists; /* must always be vaild */
|
||||
bool regular_file; /* must always be valid */
|
||||
};
|
||||
|
||||
typedef struct zip_source_file_context zip_source_file_context_t;
|
||||
typedef struct zip_source_file_operations zip_source_file_operations_t;
|
||||
typedef struct zip_source_file_stat zip_source_file_stat_t;
|
||||
|
||||
struct zip_source_file_context {
|
||||
zip_error_t error; /* last error information */
|
||||
zip_int64_t supports;
|
||||
|
||||
/* reading */
|
||||
char *fname; /* name of file to read from */
|
||||
void *f; /* file to read from */
|
||||
zip_stat_t st; /* stat information passed in */
|
||||
zip_file_attributes_t attributes; /* additional file attributes */
|
||||
zip_error_t stat_error; /* error returned for stat */
|
||||
zip_uint64_t start; /* start offset of data to read */
|
||||
zip_uint64_t len; /* length of the file, 0 for up to EOF */
|
||||
zip_uint64_t offset; /* current offset relative to start (0 is beginning of part we read) */
|
||||
|
||||
/* writing */
|
||||
char *tmpname;
|
||||
void *fout;
|
||||
|
||||
zip_source_file_operations_t *ops;
|
||||
void *ops_userdata;
|
||||
};
|
||||
|
||||
|
||||
/* The following methods must be implemented to support each feature:
|
||||
- close, read, seek, and stat must always be implemented.
|
||||
- To support specifying the file by name, open, and strdup must be implemented.
|
||||
- For write support, the file must be specified by name and close, commit_write, create_temp_output, remove, rollback_write, and tell must be implemented.
|
||||
- create_temp_output_cloning is always optional. */
|
||||
|
||||
struct zip_source_file_operations {
|
||||
void (*close)(zip_source_file_context_t *ctx);
|
||||
zip_int64_t (*commit_write)(zip_source_file_context_t *ctx);
|
||||
zip_int64_t (*create_temp_output)(zip_source_file_context_t *ctx);
|
||||
zip_int64_t (*create_temp_output_cloning)(zip_source_file_context_t *ctx, zip_uint64_t len);
|
||||
bool (*open)(zip_source_file_context_t *ctx);
|
||||
zip_int64_t (*read)(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len);
|
||||
zip_int64_t (*remove)(zip_source_file_context_t *ctx);
|
||||
void (*rollback_write)(zip_source_file_context_t *ctx);
|
||||
bool (*seek)(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence);
|
||||
bool (*stat)(zip_source_file_context_t *ctx, zip_source_file_stat_t *st);
|
||||
char *(*string_duplicate)(zip_source_file_context_t *ctx, const char *);
|
||||
zip_int64_t (*tell)(zip_source_file_context_t *ctx, void *f);
|
||||
zip_int64_t (*write)(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len);
|
||||
};
|
||||
|
||||
zip_source_t *zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error);
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef _HAD_ZIP_SOURCE_FILE_STDIO_H
|
||||
#define _HAD_ZIP_SOURCE_FILE_STDIO_H
|
||||
|
||||
/*
|
||||
zip_source_file_stdio.h -- common header for stdio file implementation
|
||||
Copyright (C) 2020 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void _zip_stdio_op_close(zip_source_file_context_t *ctx);
|
||||
zip_int64_t _zip_stdio_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len);
|
||||
bool _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence);
|
||||
bool _zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st);
|
||||
zip_int64_t _zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f);
|
||||
|
||||
FILE *_zip_fopen_close_on_exec(const char *name, bool writeable);
|
||||
|
||||
#endif /* _HAD_ZIP_SOURCE_FILE_STDIO_H */
|
||||
@@ -0,0 +1,74 @@
|
||||
#ifndef _HAD_ZIP_SOURCE_FILE_WIN32_H
|
||||
#define _HAD_ZIP_SOURCE_FILE_WIN32_H
|
||||
|
||||
/*
|
||||
zip_source_file_win32.h -- common header for Windows file implementation
|
||||
Copyright (C) 2020 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* 0x0501 => Windows XP; needs to be at least this value because of GetFileSizeEx */
|
||||
#if !defined(MS_UWP) && !defined(_WIN32_WINNT)
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <aclapi.h>
|
||||
|
||||
#include "zipint.h"
|
||||
|
||||
#include "zip_source_file.h"
|
||||
|
||||
struct zip_win32_file_operations {
|
||||
char *(*allocate_tempname)(const char *name, size_t extra_chars, size_t *lengthp);
|
||||
HANDLE (__stdcall *create_file)(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file);
|
||||
BOOL (__stdcall *delete_file)(const void *name);
|
||||
DWORD (__stdcall *get_file_attributes)(const void *name);
|
||||
BOOL (__stdcall *get_file_attributes_ex)(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information);
|
||||
void (*make_tempname)(char *buf, size_t len, const char *name, zip_uint32_t i);
|
||||
BOOL (__stdcall *move_file)(const void *from, const void *to, DWORD flags);
|
||||
BOOL (__stdcall *set_file_attributes)(const void *name, DWORD attributes);
|
||||
char *(*string_duplicate)(const char *string);
|
||||
};
|
||||
|
||||
typedef struct zip_win32_file_operations zip_win32_file_operations_t;
|
||||
|
||||
extern zip_source_file_operations_t _zip_source_file_win32_named_ops;
|
||||
|
||||
void _zip_win32_op_close(zip_source_file_context_t *ctx);
|
||||
zip_int64_t _zip_win32_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len);
|
||||
bool _zip_win32_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence);
|
||||
zip_int64_t _zip_win32_op_tell(zip_source_file_context_t *ctx, void *f);
|
||||
|
||||
bool _zip_filetime_to_time_t(FILETIME ft, time_t *t);
|
||||
int _zip_win32_error_to_errno(DWORD win32err);
|
||||
|
||||
#endif /* _HAD_ZIP_SOURCE_FILE_WIN32_H */
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef _HAD_ZIPCONF_H
|
||||
#define _HAD_ZIPCONF_H
|
||||
|
||||
/*
|
||||
zipconf.h -- platform specific include file
|
||||
|
||||
This file was generated automatically by CMake
|
||||
based on ../cmake-zipconf.h.in.
|
||||
*/
|
||||
|
||||
#define LIBZIP_VERSION "1.7.3"
|
||||
#define LIBZIP_VERSION_MAJOR 1
|
||||
#define LIBZIP_VERSION_MINOR 7
|
||||
#define LIBZIP_VERSION_MICRO 3
|
||||
|
||||
/* #undef ZIP_STATIC */
|
||||
|
||||
#define _Nullable
|
||||
#define _Nonnull
|
||||
|
||||
#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS 1
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
|
||||
typedef int8_t zip_int8_t;
|
||||
typedef uint8_t zip_uint8_t;
|
||||
typedef int16_t zip_int16_t;
|
||||
typedef uint16_t zip_uint16_t;
|
||||
typedef int32_t zip_int32_t;
|
||||
typedef uint32_t zip_uint32_t;
|
||||
typedef int64_t zip_int64_t;
|
||||
typedef uint64_t zip_uint64_t;
|
||||
|
||||
#define ZIP_INT8_MIN (-ZIP_INT8_MAX-1)
|
||||
#define ZIP_INT8_MAX 0x7f
|
||||
#define ZIP_UINT8_MAX 0xff
|
||||
|
||||
#define ZIP_INT16_MIN (-ZIP_INT16_MAX-1)
|
||||
#define ZIP_INT16_MAX 0x7fff
|
||||
#define ZIP_UINT16_MAX 0xffff
|
||||
|
||||
#define ZIP_INT32_MIN (-ZIP_INT32_MAX-1L)
|
||||
#define ZIP_INT32_MAX 0x7fffffffL
|
||||
#define ZIP_UINT32_MAX 0xffffffffLU
|
||||
|
||||
#define ZIP_INT64_MIN (-ZIP_INT64_MAX-1LL)
|
||||
#define ZIP_INT64_MAX 0x7fffffffffffffffLL
|
||||
#define ZIP_UINT64_MAX 0xffffffffffffffffULL
|
||||
|
||||
#endif /* zipconf.h */
|
||||
@@ -0,0 +1,601 @@
|
||||
#ifndef _HAD_ZIPINT_H
|
||||
#define _HAD_ZIPINT_H
|
||||
|
||||
/*
|
||||
zipint.h -- internal declarations.
|
||||
Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "compat.h"
|
||||
|
||||
#ifdef ZIP_ALLOCATE_BUFFER
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef _ZIP_COMPILING_DEPRECATED
|
||||
#define ZIP_DISABLE_DEPRECATED
|
||||
#endif
|
||||
|
||||
#include "zip.h"
|
||||
|
||||
#define CENTRAL_MAGIC "PK\1\2"
|
||||
#define LOCAL_MAGIC "PK\3\4"
|
||||
#define EOCD_MAGIC "PK\5\6"
|
||||
#define DATADES_MAGIC "PK\7\10"
|
||||
#define EOCD64LOC_MAGIC "PK\6\7"
|
||||
#define EOCD64_MAGIC "PK\6\6"
|
||||
#define CDENTRYSIZE 46u
|
||||
#define LENTRYSIZE 30
|
||||
#define MAXCOMLEN 65536
|
||||
#define MAXEXTLEN 65536
|
||||
#define EOCDLEN 22
|
||||
#define EOCD64LOCLEN 20
|
||||
#define EOCD64LEN 56
|
||||
#define CDBUFSIZE (MAXCOMLEN + EOCDLEN + EOCD64LOCLEN)
|
||||
#define BUFSIZE 8192
|
||||
#define EFZIP64SIZE 28
|
||||
#define EF_WINZIP_AES_SIZE 7
|
||||
#define MAX_DATA_DESCRIPTOR_LENGTH 24
|
||||
|
||||
#define ZIP_CRYPTO_PKWARE_HEADERLEN 12
|
||||
|
||||
#define ZIP_CM_REPLACED_DEFAULT (-2)
|
||||
#define ZIP_CM_WINZIP_AES 99 /* Winzip AES encrypted */
|
||||
|
||||
#define WINZIP_AES_PASSWORD_VERIFY_LENGTH 2
|
||||
#define WINZIP_AES_MAX_HEADER_LENGTH (16 + WINZIP_AES_PASSWORD_VERIFY_LENGTH)
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define HMAC_LENGTH 10
|
||||
#define SHA1_LENGTH 20
|
||||
#define SALT_LENGTH(method) ((method) == ZIP_EM_AES_128 ? 8 : ((method) == ZIP_EM_AES_192 ? 12 : 16))
|
||||
|
||||
#define ZIP_CM_IS_DEFAULT(x) ((x) == ZIP_CM_DEFAULT || (x) == ZIP_CM_REPLACED_DEFAULT)
|
||||
#define ZIP_CM_ACTUAL(x) ((zip_uint16_t)(ZIP_CM_IS_DEFAULT(x) ? ZIP_CM_DEFLATE : (x)))
|
||||
|
||||
#define ZIP_EF_UTF_8_COMMENT 0x6375
|
||||
#define ZIP_EF_UTF_8_NAME 0x7075
|
||||
#define ZIP_EF_WINZIP_AES 0x9901
|
||||
#define ZIP_EF_ZIP64 0x0001
|
||||
|
||||
#define ZIP_EF_IS_INTERNAL(id) ((id) == ZIP_EF_UTF_8_COMMENT || (id) == ZIP_EF_UTF_8_NAME || (id) == ZIP_EF_WINZIP_AES || (id) == ZIP_EF_ZIP64)
|
||||
|
||||
/* according to unzip-6.0's zipinfo.c, this corresponds to a regular file with rw permissions for everyone */
|
||||
#define ZIP_EXT_ATTRIB_DEFAULT (0100666u << 16)
|
||||
/* according to unzip-6.0's zipinfo.c, this corresponds to a directory with rwx permissions for everyone */
|
||||
#define ZIP_EXT_ATTRIB_DEFAULT_DIR (0040777u << 16)
|
||||
|
||||
#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK 0x0836
|
||||
|
||||
#define ZIP_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
/* This section contains API that won't materialize like this. It's
|
||||
placed in the internal section, pending cleanup. */
|
||||
|
||||
/* flags for compression and encryption sources */
|
||||
|
||||
#define ZIP_CODEC_DECODE 0 /* decompress/decrypt (encode flag not set) */
|
||||
#define ZIP_CODEC_ENCODE 1 /* compress/encrypt */
|
||||
|
||||
typedef zip_source_t *(*zip_encryption_implementation)(zip_t *, zip_source_t *, zip_uint16_t, int, const char *);
|
||||
|
||||
zip_encryption_implementation _zip_get_encryption_implementation(zip_uint16_t method, int operation);
|
||||
|
||||
/* clang-format off */
|
||||
enum zip_compression_status {
|
||||
ZIP_COMPRESSION_OK,
|
||||
ZIP_COMPRESSION_END,
|
||||
ZIP_COMPRESSION_ERROR,
|
||||
ZIP_COMPRESSION_NEED_DATA
|
||||
};
|
||||
/* clang-format on */
|
||||
typedef enum zip_compression_status zip_compression_status_t;
|
||||
|
||||
struct zip_compression_algorithm {
|
||||
/* called once to create new context */
|
||||
void *(*allocate)(zip_uint16_t method, int compression_flags, zip_error_t *error);
|
||||
/* called once to free context */
|
||||
void (*deallocate)(void *ctx);
|
||||
|
||||
/* get compression specific general purpose bitflags */
|
||||
zip_uint16_t (*general_purpose_bit_flags)(void *ctx);
|
||||
/* minimum version needed when using this algorithm */
|
||||
zip_uint8_t version_needed;
|
||||
|
||||
/* start processing */
|
||||
bool (*start)(void *ctx);
|
||||
/* stop processing */
|
||||
bool (*end)(void *ctx);
|
||||
|
||||
/* provide new input data, remains valid until next call to input or end */
|
||||
bool (*input)(void *ctx, zip_uint8_t *data, zip_uint64_t length);
|
||||
|
||||
/* all input data has been provided */
|
||||
void (*end_of_input)(void *ctx);
|
||||
|
||||
/* process input data, writing to data, which has room for length bytes, update length to number of bytes written */
|
||||
zip_compression_status_t (*process)(void *ctx, zip_uint8_t *data, zip_uint64_t *length);
|
||||
};
|
||||
typedef struct zip_compression_algorithm zip_compression_algorithm_t;
|
||||
|
||||
extern zip_compression_algorithm_t zip_algorithm_bzip2_compress;
|
||||
extern zip_compression_algorithm_t zip_algorithm_bzip2_decompress;
|
||||
extern zip_compression_algorithm_t zip_algorithm_deflate_compress;
|
||||
extern zip_compression_algorithm_t zip_algorithm_deflate_decompress;
|
||||
extern zip_compression_algorithm_t zip_algorithm_xz_compress;
|
||||
extern zip_compression_algorithm_t zip_algorithm_xz_decompress;
|
||||
|
||||
|
||||
/* This API is not final yet, but we need it internally, so it's private for now. */
|
||||
|
||||
const zip_uint8_t *zip_get_extra_field_by_id(zip_t *, int, int, zip_uint16_t, int, zip_uint16_t *);
|
||||
|
||||
/* This section contains API that is of limited use until support for
|
||||
user-supplied compression/encryption implementation is finished.
|
||||
Thus we will keep it private for now. */
|
||||
|
||||
typedef zip_int64_t (*zip_source_layered_callback)(zip_source_t *, void *, void *, zip_uint64_t, enum zip_source_cmd);
|
||||
zip_source_t *zip_source_compress(zip_t *za, zip_source_t *src, zip_int32_t cm, int compression_flags);
|
||||
zip_source_t *zip_source_crc(zip_t *, zip_source_t *, int);
|
||||
zip_source_t *zip_source_decompress(zip_t *za, zip_source_t *src, zip_int32_t cm);
|
||||
zip_source_t *zip_source_layered(zip_t *, zip_source_t *, zip_source_layered_callback, void *);
|
||||
zip_source_t *zip_source_layered_create(zip_source_t *src, zip_source_layered_callback cb, void *ud, zip_error_t *error);
|
||||
zip_source_t *zip_source_pkware_decode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *);
|
||||
zip_source_t *zip_source_pkware_encode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *);
|
||||
int zip_source_remove(zip_source_t *);
|
||||
zip_int64_t zip_source_supports(zip_source_t *src);
|
||||
zip_source_t *zip_source_window(zip_t *, zip_source_t *, zip_uint64_t, zip_uint64_t);
|
||||
zip_source_t *zip_source_winzip_aes_decode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *);
|
||||
zip_source_t *zip_source_winzip_aes_encode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *);
|
||||
zip_source_t *zip_source_buffer_with_attributes(zip_t *za, const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes);
|
||||
|
||||
/* error source for layered sources */
|
||||
|
||||
enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL };
|
||||
|
||||
/* directory entry: general purpose bit flags */
|
||||
|
||||
#define ZIP_GPBF_ENCRYPTED 0x0001u /* is encrypted */
|
||||
#define ZIP_GPBF_DATA_DESCRIPTOR 0x0008u /* crc/size after file data */
|
||||
#define ZIP_GPBF_STRONG_ENCRYPTION 0x0040u /* uses strong encryption */
|
||||
#define ZIP_GPBF_ENCODING_UTF_8 0x0800u /* file name encoding is UTF-8 */
|
||||
|
||||
|
||||
/* extra fields */
|
||||
#define ZIP_EF_LOCAL ZIP_FL_LOCAL /* include in local header */
|
||||
#define ZIP_EF_CENTRAL ZIP_FL_CENTRAL /* include in central directory */
|
||||
#define ZIP_EF_BOTH (ZIP_EF_LOCAL | ZIP_EF_CENTRAL) /* include in both */
|
||||
|
||||
#define ZIP_FL_FORCE_ZIP64 1024 /* force zip64 extra field (_zip_dirent_write) */
|
||||
|
||||
#define ZIP_FL_ENCODING_ALL (ZIP_FL_ENC_GUESS | ZIP_FL_ENC_CP437 | ZIP_FL_ENC_UTF_8)
|
||||
|
||||
|
||||
/* encoding type */
|
||||
enum zip_encoding_type {
|
||||
ZIP_ENCODING_UNKNOWN, /* not yet analyzed */
|
||||
ZIP_ENCODING_ASCII, /* plain ASCII */
|
||||
ZIP_ENCODING_UTF8_KNOWN, /* is UTF-8 */
|
||||
ZIP_ENCODING_UTF8_GUESSED, /* possibly UTF-8 */
|
||||
ZIP_ENCODING_CP437, /* Code Page 437 */
|
||||
ZIP_ENCODING_ERROR /* should be UTF-8 but isn't */
|
||||
};
|
||||
|
||||
typedef enum zip_encoding_type zip_encoding_type_t;
|
||||
|
||||
struct zip_hash;
|
||||
struct zip_progress;
|
||||
|
||||
typedef struct zip_cdir zip_cdir_t;
|
||||
typedef struct zip_dirent zip_dirent_t;
|
||||
typedef struct zip_entry zip_entry_t;
|
||||
typedef struct zip_extra_field zip_extra_field_t;
|
||||
typedef struct zip_string zip_string_t;
|
||||
typedef struct zip_buffer zip_buffer_t;
|
||||
typedef struct zip_hash zip_hash_t;
|
||||
typedef struct zip_progress zip_progress_t;
|
||||
|
||||
/* zip archive, part of API */
|
||||
|
||||
struct zip {
|
||||
zip_source_t *src; /* data source for archive */
|
||||
unsigned int open_flags; /* flags passed to zip_open */
|
||||
zip_error_t error; /* error information */
|
||||
|
||||
unsigned int flags; /* archive global flags */
|
||||
unsigned int ch_flags; /* changed archive global flags */
|
||||
|
||||
char *default_password; /* password used when no other supplied */
|
||||
|
||||
zip_string_t *comment_orig; /* archive comment */
|
||||
zip_string_t *comment_changes; /* changed archive comment */
|
||||
bool comment_changed; /* whether archive comment was changed */
|
||||
|
||||
zip_uint64_t nentry; /* number of entries */
|
||||
zip_uint64_t nentry_alloc; /* number of entries allocated */
|
||||
zip_entry_t *entry; /* entries */
|
||||
|
||||
unsigned int nopen_source; /* number of open sources using archive */
|
||||
unsigned int nopen_source_alloc; /* number of sources allocated */
|
||||
zip_source_t **open_source; /* open sources using archive */
|
||||
|
||||
zip_hash_t *names; /* hash table for name lookup */
|
||||
|
||||
zip_progress_t *progress; /* progress callback for zip_close() */
|
||||
};
|
||||
|
||||
/* file in zip archive, part of API */
|
||||
|
||||
struct zip_file {
|
||||
zip_t *za; /* zip archive containing this file */
|
||||
zip_error_t error; /* error information */
|
||||
bool eof;
|
||||
zip_source_t *src; /* data source */
|
||||
};
|
||||
|
||||
/* zip archive directory entry (central or local) */
|
||||
|
||||
#define ZIP_DIRENT_COMP_METHOD 0x0001u
|
||||
#define ZIP_DIRENT_FILENAME 0x0002u
|
||||
#define ZIP_DIRENT_COMMENT 0x0004u
|
||||
#define ZIP_DIRENT_EXTRA_FIELD 0x0008u
|
||||
#define ZIP_DIRENT_ATTRIBUTES 0x0010u
|
||||
#define ZIP_DIRENT_LAST_MOD 0x0020u
|
||||
#define ZIP_DIRENT_ENCRYPTION_METHOD 0x0040u
|
||||
#define ZIP_DIRENT_PASSWORD 0x0080u
|
||||
#define ZIP_DIRENT_ALL ZIP_UINT32_MAX
|
||||
|
||||
struct zip_dirent {
|
||||
zip_uint32_t changed;
|
||||
bool local_extra_fields_read; /* whether we already read in local header extra fields */
|
||||
bool cloned; /* whether this instance is cloned, and thus shares non-changed strings */
|
||||
|
||||
bool crc_valid; /* if CRC is valid (sometimes not for encrypted archives) */
|
||||
|
||||
zip_uint16_t version_madeby; /* (c) version of creator */
|
||||
zip_uint16_t version_needed; /* (cl) version needed to extract */
|
||||
zip_uint16_t bitflags; /* (cl) general purpose bit flag */
|
||||
zip_int32_t comp_method; /* (cl) compression method used (uint16 and ZIP_CM_DEFAULT (-1)) */
|
||||
time_t last_mod; /* (cl) time of last modification */
|
||||
zip_uint32_t crc; /* (cl) CRC-32 of uncompressed data */
|
||||
zip_uint64_t comp_size; /* (cl) size of compressed data */
|
||||
zip_uint64_t uncomp_size; /* (cl) size of uncompressed data */
|
||||
zip_string_t *filename; /* (cl) file name (NUL-terminated) */
|
||||
zip_extra_field_t *extra_fields; /* (cl) extra fields, parsed */
|
||||
zip_string_t *comment; /* (c) file comment */
|
||||
zip_uint32_t disk_number; /* (c) disk number start */
|
||||
zip_uint16_t int_attrib; /* (c) internal file attributes */
|
||||
zip_uint32_t ext_attrib; /* (c) external file attributes */
|
||||
zip_uint64_t offset; /* (c) offset of local header */
|
||||
|
||||
zip_uint16_t compression_level; /* level of compression to use (never valid in orig) */
|
||||
zip_uint16_t encryption_method; /* encryption method, computed from other fields */
|
||||
char *password; /* file specific encryption password */
|
||||
};
|
||||
|
||||
/* zip archive central directory */
|
||||
|
||||
struct zip_cdir {
|
||||
zip_entry_t *entry; /* directory entries */
|
||||
zip_uint64_t nentry; /* number of entries */
|
||||
zip_uint64_t nentry_alloc; /* number of entries allocated */
|
||||
|
||||
zip_uint64_t size; /* size of central directory */
|
||||
zip_uint64_t offset; /* offset of central directory in file */
|
||||
zip_string_t *comment; /* zip archive comment */
|
||||
bool is_zip64; /* central directory in zip64 format */
|
||||
};
|
||||
|
||||
struct zip_extra_field {
|
||||
zip_extra_field_t *next;
|
||||
zip_flags_t flags; /* in local/central header */
|
||||
zip_uint16_t id; /* header id */
|
||||
zip_uint16_t size; /* data size */
|
||||
zip_uint8_t *data;
|
||||
};
|
||||
|
||||
enum zip_source_write_state {
|
||||
ZIP_SOURCE_WRITE_CLOSED, /* write is not in progress */
|
||||
ZIP_SOURCE_WRITE_OPEN, /* write is in progress */
|
||||
ZIP_SOURCE_WRITE_FAILED, /* commit failed, only rollback allowed */
|
||||
ZIP_SOURCE_WRITE_REMOVED /* file was removed */
|
||||
};
|
||||
typedef enum zip_source_write_state zip_source_write_state_t;
|
||||
|
||||
struct zip_source {
|
||||
zip_source_t *src;
|
||||
union {
|
||||
zip_source_callback f;
|
||||
zip_source_layered_callback l;
|
||||
} cb;
|
||||
void *ud;
|
||||
zip_error_t error;
|
||||
zip_int64_t supports; /* supported commands */
|
||||
unsigned int open_count; /* number of times source was opened (directly or as lower layer) */
|
||||
zip_source_write_state_t write_state; /* whether source is open for writing */
|
||||
bool source_closed; /* set if source archive is closed */
|
||||
zip_t *source_archive; /* zip archive we're reading from, NULL if not from archive */
|
||||
unsigned int refcount;
|
||||
bool eof; /* EOF reached */
|
||||
bool had_read_error; /* a previous ZIP_SOURCE_READ reported an error */
|
||||
};
|
||||
|
||||
#define ZIP_SOURCE_IS_OPEN_READING(src) ((src)->open_count > 0)
|
||||
#define ZIP_SOURCE_IS_OPEN_WRITING(src) ((src)->write_state == ZIP_SOURCE_WRITE_OPEN)
|
||||
#define ZIP_SOURCE_IS_LAYERED(src) ((src)->src != NULL)
|
||||
|
||||
/* entry in zip archive directory */
|
||||
|
||||
struct zip_entry {
|
||||
zip_dirent_t *orig;
|
||||
zip_dirent_t *changes;
|
||||
zip_source_t *source;
|
||||
bool deleted;
|
||||
};
|
||||
|
||||
|
||||
/* file or archive comment, or filename */
|
||||
|
||||
struct zip_string {
|
||||
zip_uint8_t *raw; /* raw string */
|
||||
zip_uint16_t length; /* length of raw string */
|
||||
enum zip_encoding_type encoding; /* autorecognized encoding */
|
||||
zip_uint8_t *converted; /* autoconverted string */
|
||||
zip_uint32_t converted_length; /* length of converted */
|
||||
};
|
||||
|
||||
|
||||
/* byte array */
|
||||
|
||||
/* For performance, we usually keep 8k byte arrays on the stack.
|
||||
However, there are (embedded) systems with a stack size of 12k;
|
||||
for those, use malloc()/free() */
|
||||
|
||||
#ifdef ZIP_ALLOCATE_BUFFER
|
||||
#define DEFINE_BYTE_ARRAY(buf, size) zip_uint8_t *buf
|
||||
#define byte_array_init(buf, size) (((buf) = (zip_uint8_t *)malloc(size)) != NULL)
|
||||
#define byte_array_fini(buf) (free(buf))
|
||||
#else
|
||||
#define DEFINE_BYTE_ARRAY(buf, size) zip_uint8_t buf[size]
|
||||
#define byte_array_init(buf, size) (1)
|
||||
#define byte_array_fini(buf) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
/* bounds checked access to memory buffer */
|
||||
|
||||
struct zip_buffer {
|
||||
bool ok;
|
||||
bool free_data;
|
||||
|
||||
zip_uint8_t *data;
|
||||
zip_uint64_t size;
|
||||
zip_uint64_t offset;
|
||||
};
|
||||
|
||||
/* which files to write in which order */
|
||||
|
||||
struct zip_filelist {
|
||||
zip_uint64_t idx;
|
||||
/* TODO const char *name; */
|
||||
};
|
||||
|
||||
typedef struct zip_filelist zip_filelist_t;
|
||||
|
||||
struct _zip_winzip_aes;
|
||||
typedef struct _zip_winzip_aes zip_winzip_aes_t;
|
||||
|
||||
struct _zip_pkware_keys {
|
||||
zip_uint32_t key[3];
|
||||
};
|
||||
typedef struct _zip_pkware_keys zip_pkware_keys_t;
|
||||
|
||||
extern const char *const _zip_err_str[];
|
||||
extern const int _zip_nerr_str;
|
||||
extern const int _zip_err_type[];
|
||||
|
||||
#define ZIP_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#define ZIP_ENTRY_CHANGED(e, f) ((e)->changes && ((e)->changes->changed & (f)))
|
||||
#define ZIP_ENTRY_DATA_CHANGED(x) ((x)->source != NULL)
|
||||
#define ZIP_ENTRY_HAS_CHANGES(e) (ZIP_ENTRY_DATA_CHANGED(e) || (e)->deleted || ZIP_ENTRY_CHANGED((e), ZIP_DIRENT_ALL))
|
||||
|
||||
#define ZIP_IS_RDONLY(za) ((za)->ch_flags & ZIP_AFL_RDONLY)
|
||||
|
||||
|
||||
#ifdef HAVE_EXPLICIT_MEMSET
|
||||
#define _zip_crypto_clear(b, l) explicit_memset((b), 0, (l))
|
||||
#else
|
||||
#ifdef HAVE_EXPLICIT_BZERO
|
||||
#define _zip_crypto_clear(b, l) explicit_bzero((b), (l))
|
||||
#else
|
||||
#include <string.h>
|
||||
#define _zip_crypto_clear(b, l) memset((b), 0, (l))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
zip_int64_t _zip_add_entry(zip_t *);
|
||||
|
||||
zip_uint8_t *_zip_buffer_data(zip_buffer_t *buffer);
|
||||
bool _zip_buffer_eof(zip_buffer_t *buffer);
|
||||
void _zip_buffer_free(zip_buffer_t *buffer);
|
||||
zip_uint8_t *_zip_buffer_get(zip_buffer_t *buffer, zip_uint64_t length);
|
||||
zip_uint16_t _zip_buffer_get_16(zip_buffer_t *buffer);
|
||||
zip_uint32_t _zip_buffer_get_32(zip_buffer_t *buffer);
|
||||
zip_uint64_t _zip_buffer_get_64(zip_buffer_t *buffer);
|
||||
zip_uint8_t _zip_buffer_get_8(zip_buffer_t *buffer);
|
||||
zip_uint64_t _zip_buffer_left(zip_buffer_t *buffer);
|
||||
zip_buffer_t *_zip_buffer_new(zip_uint8_t *data, zip_uint64_t size);
|
||||
zip_buffer_t *_zip_buffer_new_from_source(zip_source_t *src, zip_uint64_t size, zip_uint8_t *buf, zip_error_t *error);
|
||||
zip_uint64_t _zip_buffer_offset(zip_buffer_t *buffer);
|
||||
bool _zip_buffer_ok(zip_buffer_t *buffer);
|
||||
zip_uint8_t *_zip_buffer_peek(zip_buffer_t *buffer, zip_uint64_t length);
|
||||
int _zip_buffer_put(zip_buffer_t *buffer, const void *src, size_t length);
|
||||
int _zip_buffer_put_16(zip_buffer_t *buffer, zip_uint16_t i);
|
||||
int _zip_buffer_put_32(zip_buffer_t *buffer, zip_uint32_t i);
|
||||
int _zip_buffer_put_64(zip_buffer_t *buffer, zip_uint64_t i);
|
||||
int _zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i);
|
||||
zip_uint64_t _zip_buffer_read(zip_buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length);
|
||||
int _zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length);
|
||||
int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset);
|
||||
zip_uint64_t _zip_buffer_size(zip_buffer_t *buffer);
|
||||
|
||||
void _zip_cdir_free(zip_cdir_t *);
|
||||
bool _zip_cdir_grow(zip_cdir_t *cd, zip_uint64_t additional_entries, zip_error_t *error);
|
||||
zip_cdir_t *_zip_cdir_new(zip_uint64_t, zip_error_t *);
|
||||
zip_int64_t _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors);
|
||||
time_t _zip_d2u_time(zip_uint16_t, zip_uint16_t);
|
||||
void _zip_deregister_source(zip_t *za, zip_source_t *src);
|
||||
|
||||
void _zip_dirent_apply_attributes(zip_dirent_t *, zip_file_attributes_t *, bool, zip_uint32_t);
|
||||
zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *);
|
||||
void _zip_dirent_free(zip_dirent_t *);
|
||||
void _zip_dirent_finalize(zip_dirent_t *);
|
||||
void _zip_dirent_init(zip_dirent_t *);
|
||||
bool _zip_dirent_needs_zip64(const zip_dirent_t *, zip_flags_t);
|
||||
zip_dirent_t *_zip_dirent_new(void);
|
||||
zip_int64_t _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_error_t *error);
|
||||
void _zip_dirent_set_version_needed(zip_dirent_t *de, bool force_zip64);
|
||||
zip_int32_t _zip_dirent_size(zip_source_t *src, zip_uint16_t, zip_error_t *);
|
||||
int _zip_dirent_write(zip_t *za, zip_dirent_t *dirent, zip_flags_t flags);
|
||||
|
||||
zip_extra_field_t *_zip_ef_clone(const zip_extra_field_t *, zip_error_t *);
|
||||
zip_extra_field_t *_zip_ef_delete_by_id(zip_extra_field_t *, zip_uint16_t, zip_uint16_t, zip_flags_t);
|
||||
void _zip_ef_free(zip_extra_field_t *);
|
||||
const zip_uint8_t *_zip_ef_get_by_id(const zip_extra_field_t *, zip_uint16_t *, zip_uint16_t, zip_uint16_t, zip_flags_t, zip_error_t *);
|
||||
zip_extra_field_t *_zip_ef_merge(zip_extra_field_t *, zip_extra_field_t *);
|
||||
zip_extra_field_t *_zip_ef_new(zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_flags_t);
|
||||
bool _zip_ef_parse(const zip_uint8_t *, zip_uint16_t, zip_flags_t, zip_extra_field_t **, zip_error_t *);
|
||||
zip_extra_field_t *_zip_ef_remove_internal(zip_extra_field_t *);
|
||||
zip_uint16_t _zip_ef_size(const zip_extra_field_t *, zip_flags_t);
|
||||
int _zip_ef_write(zip_t *za, const zip_extra_field_t *ef, zip_flags_t flags);
|
||||
|
||||
void _zip_entry_finalize(zip_entry_t *);
|
||||
void _zip_entry_init(zip_entry_t *);
|
||||
|
||||
void _zip_error_clear(zip_error_t *);
|
||||
void _zip_error_get(const zip_error_t *, int *, int *);
|
||||
|
||||
void _zip_error_copy(zip_error_t *dst, const zip_error_t *src);
|
||||
void _zip_error_set_from_source(zip_error_t *, zip_source_t *);
|
||||
|
||||
const zip_uint8_t *_zip_extract_extra_field_by_id(zip_error_t *, zip_uint16_t, int, const zip_uint8_t *, zip_uint16_t, zip_uint16_t *);
|
||||
|
||||
int _zip_file_extra_field_prepare_for_change(zip_t *, zip_uint64_t);
|
||||
int _zip_file_fillbuf(void *, size_t, zip_file_t *);
|
||||
zip_uint64_t _zip_file_get_end(const zip_t *za, zip_uint64_t index, zip_error_t *error);
|
||||
zip_uint64_t _zip_file_get_offset(const zip_t *, zip_uint64_t, zip_error_t *);
|
||||
|
||||
zip_dirent_t *_zip_get_dirent(zip_t *, zip_uint64_t, zip_flags_t, zip_error_t *);
|
||||
|
||||
enum zip_encoding_type _zip_guess_encoding(zip_string_t *, enum zip_encoding_type);
|
||||
zip_uint8_t *_zip_cp437_to_utf8(const zip_uint8_t *const, zip_uint32_t, zip_uint32_t *, zip_error_t *);
|
||||
|
||||
bool _zip_hash_add(zip_hash_t *hash, const zip_uint8_t *name, zip_uint64_t index, zip_flags_t flags, zip_error_t *error);
|
||||
bool _zip_hash_delete(zip_hash_t *hash, const zip_uint8_t *key, zip_error_t *error);
|
||||
void _zip_hash_free(zip_hash_t *hash);
|
||||
zip_int64_t _zip_hash_lookup(zip_hash_t *hash, const zip_uint8_t *name, zip_flags_t flags, zip_error_t *error);
|
||||
zip_hash_t *_zip_hash_new(zip_error_t *error);
|
||||
bool _zip_hash_reserve_capacity(zip_hash_t *hash, zip_uint64_t capacity, zip_error_t *error);
|
||||
bool _zip_hash_revert(zip_hash_t *hash, zip_error_t *error);
|
||||
|
||||
int _zip_mkstempm(char *path, int mode);
|
||||
|
||||
zip_t *_zip_open(zip_source_t *, unsigned int, zip_error_t *);
|
||||
|
||||
void _zip_progress_end(zip_progress_t *progress);
|
||||
void _zip_progress_free(zip_progress_t *progress);
|
||||
int _zip_progress_start(zip_progress_t *progress);
|
||||
int _zip_progress_subrange(zip_progress_t *progress, double start, double end);
|
||||
int _zip_progress_update(zip_progress_t *progress, double value);
|
||||
|
||||
/* this symbol is extern so it can be overridden for regression testing */
|
||||
ZIP_EXTERN bool zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length);
|
||||
zip_uint32_t zip_random_uint32(void);
|
||||
|
||||
int _zip_read(zip_source_t *src, zip_uint8_t *data, zip_uint64_t length, zip_error_t *error);
|
||||
int _zip_read_at_offset(zip_source_t *src, zip_uint64_t offset, unsigned char *b, size_t length, zip_error_t *error);
|
||||
zip_uint8_t *_zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp, zip_error_t *error);
|
||||
int _zip_read_local_ef(zip_t *, zip_uint64_t);
|
||||
zip_string_t *_zip_read_string(zip_buffer_t *buffer, zip_source_t *src, zip_uint16_t length, bool nulp, zip_error_t *error);
|
||||
int _zip_register_source(zip_t *za, zip_source_t *src);
|
||||
|
||||
void _zip_set_open_error(int *zep, const zip_error_t *err, int ze);
|
||||
|
||||
bool zip_source_accept_empty(zip_source_t *src);
|
||||
zip_int64_t _zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command);
|
||||
bool _zip_source_eof(zip_source_t *);
|
||||
zip_source_t *_zip_source_file_or_p(const char *, FILE *, zip_uint64_t, zip_int64_t, const zip_stat_t *, zip_error_t *error);
|
||||
bool _zip_source_had_error(zip_source_t *);
|
||||
void _zip_source_invalidate(zip_source_t *src);
|
||||
zip_source_t *_zip_source_new(zip_error_t *error);
|
||||
int _zip_source_set_source_archive(zip_source_t *, zip_t *);
|
||||
zip_source_t *_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_uint64_t length, zip_stat_t *st, zip_file_attributes_t *attributes, zip_t *source_archive, zip_uint64_t source_index, zip_error_t *error);
|
||||
zip_source_t *_zip_source_zip_new(zip_t *, zip_t *, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_uint64_t, const char *);
|
||||
|
||||
int _zip_stat_merge(zip_stat_t *dst, const zip_stat_t *src, zip_error_t *error);
|
||||
int _zip_string_equal(const zip_string_t *, const zip_string_t *);
|
||||
void _zip_string_free(zip_string_t *);
|
||||
zip_uint32_t _zip_string_crc32(const zip_string_t *);
|
||||
const zip_uint8_t *_zip_string_get(zip_string_t *, zip_uint32_t *, zip_flags_t, zip_error_t *);
|
||||
zip_uint16_t _zip_string_length(const zip_string_t *);
|
||||
zip_string_t *_zip_string_new(const zip_uint8_t *, zip_uint16_t, zip_flags_t, zip_error_t *);
|
||||
int _zip_string_write(zip_t *za, const zip_string_t *string);
|
||||
bool _zip_winzip_aes_decrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length);
|
||||
bool _zip_winzip_aes_encrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length);
|
||||
bool _zip_winzip_aes_finish(zip_winzip_aes_t *ctx, zip_uint8_t *hmac);
|
||||
void _zip_winzip_aes_free(zip_winzip_aes_t *ctx);
|
||||
zip_winzip_aes_t *_zip_winzip_aes_new(const zip_uint8_t *password, zip_uint64_t password_length, const zip_uint8_t *salt, zip_uint16_t key_size, zip_uint8_t *password_verify, zip_error_t *error);
|
||||
|
||||
void _zip_pkware_encrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len);
|
||||
void _zip_pkware_decrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len);
|
||||
zip_pkware_keys_t *_zip_pkware_keys_new(zip_error_t *error);
|
||||
void _zip_pkware_keys_free(zip_pkware_keys_t *keys);
|
||||
void _zip_pkware_keys_reset(zip_pkware_keys_t *keys);
|
||||
|
||||
int _zip_changed(const zip_t *, zip_uint64_t *);
|
||||
const char *_zip_get_name(zip_t *, zip_uint64_t, zip_flags_t, zip_error_t *);
|
||||
int _zip_local_header_read(zip_t *, int);
|
||||
void *_zip_memdup(const void *, size_t, zip_error_t *);
|
||||
zip_int64_t _zip_name_locate(zip_t *, const char *, zip_flags_t, zip_error_t *);
|
||||
zip_t *_zip_new(zip_error_t *);
|
||||
|
||||
zip_int64_t _zip_file_replace(zip_t *, zip_uint64_t, const char *, zip_source_t *, zip_flags_t);
|
||||
int _zip_set_name(zip_t *, zip_uint64_t, const char *, zip_flags_t);
|
||||
void _zip_u2d_time(time_t, zip_uint16_t *, zip_uint16_t *);
|
||||
int _zip_unchange(zip_t *, zip_uint64_t, int);
|
||||
void _zip_unchange_data(zip_entry_t *);
|
||||
int _zip_write(zip_t *za, const void *data, zip_uint64_t length);
|
||||
|
||||
#endif /* zipint.h */
|
||||
Reference in New Issue
Block a user