4
0
mirror of https://github.com/QuasarApp/zip.git synced 2025-05-11 11:19:34 +00:00

Upgrade miniz dependency to version 2.2.0 ()

This commit is contained in:
Kuba Podgórski 2021-07-29 10:56:20 +02:00 committed by GitHub
parent b7193d815a
commit 5b3f3877ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 5771 additions and 2629 deletions

@ -10,7 +10,8 @@ jobs:
- name: Tools
run: sudo apt-get -y install tree
- name: Configure
run: cmake -DSANITIZE_ADDRESS=On .
run: |
cmake -DSANITIZE_ADDRESS=On .
- name: Build
run: |
cmake --build .
@ -26,11 +27,10 @@ jobs:
run: brew install tree
- name: Configure
run: |
pip3 install scan-build
scan-build cmake -DCMAKE_AR=/usr/bin/ar -DSANITIZE_ADDRESS=On .
cmake -DSANITIZE_ADDRESS=On .
- name: Build
run: |
scan-build -v --exclude test -enable-checker security.FloatLoopCounter -enable-checker security.insecureAPI.UncheckedReturn --status-bugs cmake --build .
cmake --build .
tree -sha .
- name: Test
run: ctest -VV

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4)
project(zip
LANGUAGES C
VERSION "0.1.32")
VERSION "0.2.0")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_VERBOSE_MAKEFILE ON)

@ -1,5 +1,5 @@
### A portable (OSX/Linux/Windows), simple zip library written in C
This is done by hacking awesome [miniz](https://code.google.com/p/miniz) library and layering functions on top of the miniz v1.15 API.
This is done by hacking awesome [miniz](https://code.google.com/p/miniz) library and layering functions on top of the miniz v2.2.0 API.
[![Build](https://github.com/kuba--/zip/workflows/build/badge.svg)](https://github.com/kuba--/zip/actions?query=workflow%3Abuild)
@ -256,18 +256,6 @@ struct zip_t *zip = zip_open("foo.zip", 0, 'd');
zip_close(zip);
```
* Use custom CRC-32 function.
```c
unsigned long my_crc32(unsigned long crc, const void *buf, size_t bufsize) {
uint32_t c = crc32_16bytes_prefetch(buf, bufsize, (uint32_t)crc);
return (unsigned long)c;
}
//...
zip_crc32_func(my_crc32);
zip_extract("foo.zip", "/tmp", NULL, NULL);
```
# Bindings
Compile zip library as a dynamic library.

File diff suppressed because it is too large Load Diff

@ -1150,7 +1150,7 @@ int zip_entry_close(struct zip_t *zip) {
pzip, zip->entry.name, entrylen, NULL, 0, "", 0,
zip->entry.uncomp_size, zip->entry.comp_size, zip->entry.uncomp_crc32,
zip->entry.method, 0, dos_time, dos_date, zip->entry.header_offset,
zip->entry.external_attr)) {
zip->entry.external_attr, NULL, 0)) {
// Cannot write to zip central dir
err = ZIP_EWRTDIR;
goto cleanup;
@ -1221,8 +1221,8 @@ int zip_entry_write(struct zip_t *zip, const void *buf, size_t bufsize) {
pzip = &(zip->archive);
if (buf && bufsize > 0) {
zip->entry.uncomp_size += bufsize;
zip->entry.uncomp_crc32 =
(mz_uint32)def_crc32_func(zip->entry.uncomp_crc32, buf, bufsize);
zip->entry.uncomp_crc32 = (mz_uint32)mz_crc32(
zip->entry.uncomp_crc32, (const mz_uint8 *)buf, bufsize);
level = zip->level & 0xF;
if (!level) {
@ -1388,7 +1388,7 @@ int zip_entry_fread(struct zip_t *zip, const char *filename) {
}
int zip_entry_extract(struct zip_t *zip,
size_t (*on_extract)(void *arg, unsigned long long offset,
size_t (*on_extract)(void *arg, uint64_t offset,
const void *buf, size_t bufsize),
void *arg) {
mz_zip_archive *pzip = NULL;
@ -1620,11 +1620,3 @@ int zip_extract(const char *zipname, const char *dir,
return zip_archive_extract(&zip_archive, dir, on_extract, arg);
}
void zip_crc32_func(unsigned long (*crc32_func)(unsigned long crc,
const void *buf,
size_t bufsize)) {
if (crc32_func) {
def_crc32_func = crc32_func;
}
}

@ -12,6 +12,7 @@
#ifndef ZIP_H
#define ZIP_H
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
@ -314,7 +315,7 @@ extern ZIP_EXPORT int zip_entry_fread(struct zip_t *zip, const char *filename);
*/
extern ZIP_EXPORT int
zip_entry_extract(struct zip_t *zip,
size_t (*on_extract)(void *arg, unsigned long long offset,
size_t (*on_extract)(void *arg, uint64_t offset,
const void *data, size_t size),
void *arg);
@ -425,16 +426,6 @@ extern ZIP_EXPORT int zip_extract(const char *zipname, const char *dir,
int (*on_extract_entry)(const char *filename,
void *arg),
void *arg);
/**
* Sets global CRC-32 checksum function.
*
* @param crc32_func crc32 function (init value, buffer, buffer size)
*/
extern ZIP_EXPORT void
zip_crc32_func(unsigned long (*crc32_func)(unsigned long crc, const void *buf,
size_t bufsize));
/** @} */
#ifdef __cplusplus
}

@ -5,13 +5,14 @@
#include "minunit.h"
static char *ZIPNAME = NULL;
static char ZIPNAME[L_tmpnam + 1] = {0};
static int total_entries = 0;
#define TESTDATA1 "Some test data 1...\0"
void test_setup(void) {
ZIPNAME = tempnam(NULL, "z-");
strncpy(ZIPNAME, "z-XXXXXX\0", L_tmpnam);
mktemp(ZIPNAME);
struct zip_t *zip = zip_open(ZIPNAME, ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
@ -23,10 +24,7 @@ void test_setup(void) {
zip_close(zip);
}
void test_teardown(void) {
remove(ZIPNAME);
free(ZIPNAME);
}
void test_teardown(void) { remove(ZIPNAME); }
#define TESTDATA2 "Some test data 2...\0"
#define CRC32DATA2 2532008468

@ -5,7 +5,7 @@
#include "minunit.h"
static char *ZIPNAME = NULL;
static char ZIPNAME[L_tmpnam + 1] = {0};
#define CRC32DATA1 2220805626
#define TESTDATA1 "Some test data 1...\0"
@ -16,7 +16,8 @@ static char *ZIPNAME = NULL;
static int total_entries = 0;
void test_setup(void) {
ZIPNAME = tempnam(NULL, "z-");
strncpy(ZIPNAME, "z-XXXXXX\0", L_tmpnam);
mktemp(ZIPNAME);
struct zip_t *zip = zip_open(ZIPNAME, ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
@ -80,7 +81,6 @@ void test_teardown(void) {
total_entries = 0;
remove(ZIPNAME);
free(ZIPNAME);
}
MU_TEST(test_entry_name) {

@ -5,13 +5,14 @@
#include "minunit.h"
static char *ZIPNAME = NULL;
static char ZIPNAME[L_tmpnam + 1] = {0};
#define TESTDATA1 "Some test data 1...\0"
#define TESTDATA2 "Some test data 2...\0"
void test_setup(void) {
ZIPNAME = tempnam(".", "z-");
strncpy(ZIPNAME, "z-XXXXXX\0", L_tmpnam);
mktemp(ZIPNAME);
struct zip_t *zip = zip_open(ZIPNAME, ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
@ -45,7 +46,6 @@ void test_teardown(void) {
remove("dotfiles/.test");
remove("dotfiles");
remove(ZIPNAME);
free(ZIPNAME);
}
#define UNUSED(x) (void)x

@ -6,33 +6,31 @@
#include "minunit.h"
static char *ZIPNAME = NULL;
static char *XFILE = NULL;
static char *RFILE = NULL;
static char *WFILE = NULL;
static char ZIPNAME[L_tmpnam + 1] = {0};
static char XFILE[L_tmpnam + 1] = {0};
static char RFILE[L_tmpnam + 1] = {0};
static char WFILE[L_tmpnam + 1] = {0};
void test_setup(void) {
ZIPNAME = tempnam(".", "z-");
XFILE = tempnam(".", "x-");
RFILE = tempnam(".", "r-");
WFILE = tempnam(".", "w-");
strncpy(ZIPNAME, "z-XXXXXX\0", L_tmpnam);
strncpy(XFILE, "x-XXXXXX\0", L_tmpnam);
strncpy(RFILE, "r-XXXXXX\0", L_tmpnam);
strncpy(WFILE, "w-XXXXXX\0", L_tmpnam);
mktemp(ZIPNAME);
mktemp(XFILE);
mktemp(RFILE);
mktemp(WFILE);
}
void test_teardown(void) {
remove(WFILE);
free(WFILE);
remove(RFILE);
free(RFILE);
remove(XFILE);
free(XFILE);
remove(ZIPNAME);
free(ZIPNAME);
}
#if defined(_MSC_VER) || defined(__MINGW64__) || defined(__MINGW32__)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define MZ_FILE_STAT_STRUCT _stat
#define MZ_FILE_STAT _stat
#else

@ -5,7 +5,7 @@
#include "minunit.h"
static char *ZIPNAME = NULL;
static char ZIPNAME[L_tmpnam + 1] = {0};
#define CRC32DATA1 2220805626
#define TESTDATA1 "Some test data 1...\0"
@ -14,7 +14,8 @@ static char *ZIPNAME = NULL;
#define CRC32DATA2 2532008468
void test_setup(void) {
ZIPNAME = tempnam(NULL, "z-");
strncpy(ZIPNAME, "z-XXXXXX\0", L_tmpnam);
mktemp(ZIPNAME);
struct zip_t *zip = zip_open(ZIPNAME, ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
@ -39,10 +40,7 @@ void test_setup(void) {
zip_close(zip);
}
void test_teardown(void) {
remove(ZIPNAME);
free(ZIPNAME);
}
void test_teardown(void) { remove(ZIPNAME); }
MU_TEST(test_read) {
char *buf = NULL;

@ -5,20 +5,20 @@
#include "minunit.h"
static char *ZIPNAME = NULL;
static char *WFILE = NULL;
static char ZIPNAME[L_tmpnam + 1] = {0};
static char WFILE[L_tmpnam + 1] = {0};
void test_setup(void) {
ZIPNAME = tempnam(NULL, "z-");
WFILE = tempnam(NULL, "w-");
strncpy(ZIPNAME, "z-XXXXXX\0", L_tmpnam);
strncpy(WFILE, "w-XXXXXX\0", L_tmpnam);
mktemp(ZIPNAME);
mktemp(WFILE);
}
void test_teardown(void) {
remove(WFILE);
free(WFILE);
remove(ZIPNAME);
free(ZIPNAME);
}
#define CRC32DATA1 2220805626