A couple years ago (4?) I hacked miniz 1.19 to get it to run under Pelles C. It still works under Pelles V12 even with the abundant warnings...
Now I see miniz 3.0.2 is out there. Tried some quick changes as I made in 1.19 but getting:
fatal error: Internal error: 'Access violation' at 0x00007ff7f5333e99 when compiling with Pelles C 12
https://github.com/kuba--/zip
Would be nice if someone has already got it working :) ?? hope hope hope --
John Z
Can't help :(
internal error comes with x64
Pelles C: with C11
struct tm * localtime_s(const time_t * restrict timer, struct tm * restrict dst);
msvc:
errno_t localtime_s(struct tm* const tmDest, time_t const* const sourceTime);
so have to define _POSIX_C_SOURCE
My test defines for x86 was: _POSIX_C_SOURCE _wstat64=_wstat _stat64=_stat __stat64=_stat _chsize_s=chsize
x64 have stat64 and wstat64 in crt64
low interest to split source for testing :(
EDIT:
test with:
//#define MINIZ_HEADER_FILE_ONLY // OK
#define MINIZ_NO_ARCHIVE_APIS
#define MINIZ_NO_ARCHIVE_WRITING_APIS
#define MINIZ_NO_STDIO
#define MINIZ_NO_TIME
#define MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
#define MINIZ_NO_INFLATE_APIS
#define MINIZ_NO_MALLOC
#define MINIZ_UNALIGNED_USE_MEMCPY
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES
//#define MINIZ_NO_DEFLATE_APIS // fatal error inside this code
#include "miniz.h"
errorsBuilding test_1.obj.
C:\code\PellesC\MiniZ\zip-v3.0.2\src\miniz.h(689): error #1021: Invalid operand '&&' in preprocessor expression.
C:\code\PellesC\MiniZ\zip-v3.0.2\src\miniz.h(689): error #1019: Syntax error in preprocessor expression.
C:\code\PellesC\MiniZ\zip-v3.0.2\src\miniz.h(2957): error #1021: Invalid operand '&&' in preprocessor expression.
C:\code\PellesC\MiniZ\zip-v3.0.2\src\miniz.h(2957): error #1019: Syntax error in preprocessor expression.
C:\code\PellesC\MiniZ\zip-v3.0.2\src\miniz.h(3261): error #1019: Syntax error in preprocessor expression.
C:\code\PellesC\MiniZ\zip-v3.0.2\src\miniz.h(3385): error #1021: Invalid operand '&&' in preprocessor expression.
C:\code\PellesC\MiniZ\zip-v3.0.2\src\miniz.h(3385): error #1019: Syntax error in preprocessor expression.
fatal error: Internal error: 'Access violation' at 0x000000013f703e99.
*** Error code: 1 ***
Done.
so split code to header miniz.h miniz_tdef.c and miniz_tinfl.c for using it
split code from
MINIZ_NO_ARCHIVE_APIS
MINIZ_NO_ARCHIVE_WRITING_APIS
this was one problem, that need modification#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
static void mz_zip_time_t_to_dos_time(MZ_TIME_T time, mz_uint16 *pDOS_time,
mz_uint16 *pDOS_date) {
#ifdef __POCC__
struct tm *tm = localtime(&time);
#elif_MSC_VER
struct tm tm_struct;
struct tm *tm = &tm_struct;
errno_t err = localtime_s(tm, &time);
if (err) {
*pDOS_date = 0;
*pDOS_time = 0;
return;
}
#else
struct tm *tm = localtime(&time);
#endif /* #ifdef _MSC_VER */
EDIT:
compiler crash in function static mz_bool tdefl_compress_normal(
Thanks Timo, appreciate the look see.
Not urgent anyway so I'll keep looking as time and interest permits.
Appreciate the defines tip.
There are certainly a lot more interesting things these days :)
John Z
Msys2 can compile the code. It creates a library named libzip.a
Quote from: Vortex on October 22, 2024, 09:50:38 AM
Msys2 can compile the code. It creates a library named libzip.a
Thanks Vortex - interesting I've not heard of Msys2 but looking at it now, it is interesting. I've used Cygwin in the past when working with X-windows on MS-Windows.
Quote from: TimoVJL on October 21, 2024, 08:33:03 PM
this was one problem, that need modification mz_zip_time_t_to_dos_time
Thanks TimoVJL - this one I recall from before. Also thanks for the added info for the best split-outs.
I'm thinking about the several approaches ... and the time involved.
John Z
I also now recall from last year that statements like
d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c;
were identified by frankie as causing some access violations in the PrjZipWSDirMz add-in so I'll fix those first and see where to go from there.
Passed the access crash!
changed
if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))
d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c;
into
if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))
{
int appo = TDEFL_LZ_DICT_SIZE + dst_pos;
d->m_dict[appo] = c;
}
Now no access violation crash :)
Now 'only' a couple 100 errors fatal error #2210: More than 100 errors, please improve yourself.
and
an equal number of warnings..... :( But I've not set the correct defines yet . . .progress though.
John Z
It is working - compiles w/o error and within the program using it it creates the zip file with my 5 files included.
Could be cleaner as there are a lot of warnings just like the 1.19 version.
While the ZIP is usable there seems to be some subtle difference to trace down. 7z opens and displays ok, but seems something different within 1 file compared to 1.19. Maybe a file length issue or padding as one of the 5 files in the new zip shows to be 1 byte shorter - this causes (I think) Libreoffice to say the archive is corrupt, but it easily fixes it and all data is there.
In any case it is close to working - - - x64 and w/o _POSIX_C_SOURCE (at least so far)
John Z
richgel999's miniz (https://github.com/richgel999/miniz) updates frequently and perhaps better for Pelles C
It is his but with an additional wrapper to make it easier to use. :)
https://github.com/kuba--/zip
"A portable (OSX/Linux/Windows/Android/iOS), simple zip library written in C"
"This is done by hacking awesome miniz library and layering functions on top of the miniz v3.0.2 API."
John Z
Hi Timo,
Thanks for your suggestion. Using Msys2, I can compile richgel999's miniz code :
user@computer MINGW64 ~
# gcc -c miniz.c -o miniz.o
user@computer MINGW64 ~
# gcc example3.c miniz.o -o example3.exe
user@computer MINGW64 ~
Hi Vortex,
Glad you have Msys2 working, I have not tried it yet.
If possible using your Msys2 compile can you ZIP the attached file and re-post? It would be a big help to see if the 3.0.2 itself has an issue or if the wrapper around it has an issue. Using the wrapper version the packed file is 311 bytes but using my older 1.19 version it is 312 bytes. With the missing 1 byte LibreOffice indicates the file is corrupt. However it repairs it easily, and if I open the file and compare to the original it is identical so the issue is not the source but the compression/packing. Interestingly only 1 file out of the five in the zip has the issue, so I'm think it may be a padding problem.
If possible - if not I appreciate your input too.
Thanks,
John Z
Hi John,
Here is the attached file :
# ./example3.exe c meta.xml meta.zip
miniz.c version: 11.0.2
Mode: c, Level: 9
Input File: "meta.xml"
Output File: "meta.zip"
Input file size: 642
Total input bytes: 642
Total output bytes: 317
Success.
Thanks very much Vortex! Appreciate the help.
Wow this is even a different size too.
I'll check it out and see how LibreOffice likes it.
Thanks again!
John Z
example3.c with modified richgel999's miniz code
test_meta_xml is kuba zip version
32-bit version miss first char from filename :(
Hi Timo,
Your example3 built and mine are producing the same zip file, no problem. As you said, test_meta_xml.exe is omitting the first character of the filename.
Thanks TimoVJL,
I have grabbed your work and will see how - appreciate the test, and the help, and your time!
Vortex, sorry to report that the zip file created with Msys2 version of zip, turns out to not be a valid zip file.
Even the header characters are wrong. 7z, Zip, etc nothing can open it. Not sure what went wrong - - Thanks
for trying it though! I might still try Msys2 later.
John Z
A that example3.c don't make zip, only pack file.
Test Zip files online for free (https://www.luxa.org/archive)
Oh - did not know that - Sorry
Thanks,
John Z
Hi Timo,
QuoteA that example3.c don't make zip, only pack file
If not zip, what should be the correct file extension?
Quote from: TimoVJL on October 23, 2024, 06:41:20 AM
example3.c with modified richgel999's miniz code
test_meta_xml is kuba zip version
32-bit version miss first char from filename :(
Great work TimoVJL the 64 bit version created a meta.xml zip that was accepted by LibreOffice ! I'll look to see what I missed. I'll incorporate your version first and see if I successfully make a completed spreadsheet .ods with the new 64 bit version.
John Z