Skip to content

Commit

Permalink
Update minizip to 1.2.13, preserving local changes
Browse files Browse the repository at this point in the history
Changes taken from https://github.com/madler/zlib/tree/master/contrib/minizip
Commit: 04f42ceca40f73e2978b50e93806c2a18c1281fc (v1.2.13)
Excluding build related files, as it will be built directly into fmi4c
Preserving local modifications
  • Loading branch information
peterNordin committed Nov 16, 2022
1 parent 8d10c2d commit 2f85b82
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/minizip/crypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr
#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654L /* use PI as default pattern */
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif

static unsigned crypthead(const char* passwd, /* password string */
Expand Down
22 changes: 11 additions & 11 deletions 3rdparty/minizip/ioapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));

static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
{
(void)opaque;
FILE* file = NULL;
const char* mode_fopen = NULL;
(void)opaque;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
mode_fopen = "rb";
else
Expand All @@ -113,9 +113,9 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in

static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
{
(void)opaque;
FILE* file = NULL;
const char* mode_fopen = NULL;
(void)opaque;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
mode_fopen = "rb";
else
Expand All @@ -133,42 +133,42 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,

static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
{
(void)opaque;
uLong ret;
(void)opaque;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}

static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size)
{
(void)opaque;
uLong ret;
(void)opaque;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}

static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
{
(void)opaque;
long ret;
(void)opaque;
ret = ftell((FILE *)stream);
return ret;
}


static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
{
(void)opaque;
ZPOS64_T ret;
(void)opaque;
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
return ret;
}

static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
{
(void)opaque;
int fseek_origin=0;
long ret;
(void)opaque;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
Expand All @@ -190,9 +190,9 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs

static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
{
(void)opaque;
int fseek_origin=0;
long ret;
(void)opaque;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
Expand All @@ -208,7 +208,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
}
ret = 0;

if(FSEEKO_FUNC((FILE *)stream, (long)offset, fseek_origin) != 0)
if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0)
ret = -1;

return ret;
Expand All @@ -217,16 +217,16 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T

static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
{
(void)opaque;
int ret;
(void)opaque;
ret = fclose((FILE *)stream);
return ret;
}

static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
{
(void)opaque;
int ret;
(void)opaque;
ret = ferror((FILE *)stream);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/minizip/ioapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#define ftello64 ftell
#define fseeko64 fseek
#else
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define fopen64 fopen
#define ftello64 ftello
#define fseeko64 fseeko
Expand Down
5 changes: 5 additions & 0 deletions 3rdparty/minizip/iowin32.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@

// see Include/shared/winapifamily.h in the Windows Kit
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))

#if !defined(WINAPI_FAMILY_ONE_PARTITION)
#define WINAPI_FAMILY_ONE_PARTITION(PartitionSet, Partition) ((WINAPI_FAMILY & PartitionSet) == Partition)
#endif

#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP)
#define IOWIN32_USING_WINRT_API 1
#endif
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/minizip/miniunz.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ int miniunz(argc,argv)

while ((*p)!='\0')
{
char c=*(p++);;
char c=*(p++);
if ((c=='l') || (c=='L'))
opt_do_list = 1;
if ((c=='v') || (c=='V'))
Expand Down
6 changes: 3 additions & 3 deletions 3rdparty/minizip/minizip.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,
FILE * fin = FOPEN_FUNC(filenameinzip,"rb");

unsigned long size_read = 0;
unsigned long total_read = 0;
/* unsigned long total_read = 0; */
if (fin==NULL)
{
err = ZIP_ERRNO;
Expand All @@ -220,7 +220,7 @@ static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,

if (size_read>0)
calculate_crc = crc32_z(calculate_crc,buf,size_read);
total_read += size_read;
/* total_read += size_read; */

} while ((err == ZIP_OK) && (size_read>0));

Expand Down Expand Up @@ -287,7 +287,7 @@ int minizip(argc,argv)

while ((*p)!='\0')
{
char c=*(p++);;
char c=*(p++);
if ((c=='o') || (c=='O'))
opt_overwrite = 1;
if ((c=='a') || (c=='A'))
Expand Down
4 changes: 3 additions & 1 deletion 3rdparty/minizip/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
# define ALLOC(size) (malloc(size))
#endif
#ifndef TRYFREE
# define TRYFREE(p) {if (p) free(p);}
# define TRYFREE(p) { free(p);}
#endif

#define SIZECENTRALDIRITEM (0x2e)
Expand Down Expand Up @@ -1566,6 +1566,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
else
{
TRYFREE(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info);
return err;
}
Expand All @@ -1586,6 +1587,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
else
{
TRYFREE(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info);
return err;
}
Expand Down
7 changes: 1 addition & 6 deletions 3rdparty/minizip/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,11 +1471,6 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
{
uLong uTotalOutBefore = zi->ci.stream.total_out;
err=deflate(&zi->ci.stream, Z_NO_FLUSH);
if(uTotalOutBefore > zi->ci.stream.total_out)
{
int bBreak = 0;
bBreak++;
}

zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
}
Expand Down Expand Up @@ -1959,7 +1954,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe

int retVal = ZIP_OK;

if(pData == NULL || *dataLen < 4)
if(pData == NULL || dataLen == NULL || *dataLen < 4)
return ZIP_PARAMERROR;

pNewHeader = (char*)ALLOC((unsigned)*dataLen);
Expand Down

0 comments on commit 2f85b82

Please sign in to comment.