News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

zlib problem

Started by jj2007, November 29, 2010, 12:14:51 AM

Previous topic - Next topic

jj2007

zlib comes along with a simple example on how to deflate/inflate from file to file. I have translated the C source to Masm syntax, and the code does apparently compress files, but after a few hundred (625 ... 1725) correct characters the re-extracted file contains garbage.

Since I am a noob at C, there may be errors in my translation. Otherwise the zlib1.dll is buggy, or WinZip has problems with the format ...

Any ideas? Can somebody test the C version to see if it works correctly?

Antariy

Quote from: jj2007 on November 29, 2010, 12:14:51 AM
zlib comes along with a simple example on how to deflate/inflate from file to file. I have translated the C source to Masm syntax, and the code does apparently compress files, but after a few hundred (625 ... 1725) correct characters the re-extracted file contains garbage.

Since I am a noob at C, there may be errors in my translation. Otherwise the zlib1.dll is buggy, or WinZip has problems with the format ...

Any ideas? Can somebody test the C version to see if it works correctly?

In all file-opening functions use "x+b" where x is r or w.
I.e.

invoke crt_fopen, chr$("windows.gz"), chr$("w+b")


Otherwice you write in text-mode, and LF was translated to CRLF, and tabs to spaces probably (depend on runtime).



Alex

frktons

The C source needs a #include "zlib.h" that is not included in your zip,
I can't compile it.
Mind is like a parachute. You know what to do in order to use it :-)

jj2007

Quote from: Antariy on November 29, 2010, 12:19:58 AMIn all file-opening functions use "x+b" where x is r or w.

You are a genius, Alex :U

(and I finally know why I never used the sh*tty crt file io)

Antariy

Quote from: jj2007 on November 29, 2010, 12:40:51 AM
(and I finally know why I never used the sh*tty crt file io)

I has not used zlib yet, too.

jj2007

I wonder why (using code posted here) the results obtained with the IIS and the zlib versions of gzip differ so dramatically, in terms of compression ratio (using \masm32\include\Windows.inc as source):

Quote163165  C:\WINDOWS\system32\inetsrv\gzip.dll with MichaelW's code
172001  zlib1.dll with my code, maximum compression level

What bothers me in both versions is that the gzip format apparently does not allow to include a directory tree...

ToutEnMasm

#6
This one seem of real interest
http://www.xstandard.com/en/documentation/xzip/
include file for masm in the zip

Help files is in the typelib of the ocx and I have got something more
Those can be useful
Quote
sLIBID_XZip   TEXTEQU   <{07E380ED9h,0C7ECh,046F7h,{099h,071h,0CCh,012h,0EEh,0D1h,0F3h,07Fh}}>
sIID_IZip   TEXTEQU   <{00B2D411Bh,07A91h,0483Ah,{095h,0C4h,053h,0DDh,0C6h,0B1h,078h,095h}}>
sIID_IItems   TEXTEQU   <{01054B56Dh,0FB5Fh,04CA0h,{09Eh,066h,002h,074h,077h,017h,09Fh,0BBh}}>
sIID_IItem   TEXTEQU   <{00842A022h,02D96h,0470Dh,{084h,018h,020h,0E2h,083h,0EFh,017h,0DCh}}>
sCLSID_Zip   TEXTEQU   <{013D6BDE3h,046AAh,04FF2h,{0A6h,022h,0EBh,0C4h,031h,010h,0D9h,05Ch}}>
sCLSID_Items   TEXTEQU   <{012925CF7h,003E6h,04FFAh,{0ADh,08Ch,09Bh,0F6h,019h,055h,061h,04Fh}}>
sCLSID_Item   TEXTEQU   <{04379C5C3h,0D457h,04D61h,{086h,09Eh,0C2h,0E5h,0F8h,082h,099h,023h}}>


ToutEnMasm

This one work well for me
Here is a sample who work with the windows.inc
I have not tested all the functions.
You need to modify the path in the source file

jj2007

Not included:
E:\xzip\XZip.dll

ToutEnMasm



You can have it at this link
http://www.xstandard.com/en/documentation/xzip/

It isn't mine.There is also sample of use in script on the site.Things are really well done.

ToutEnMasm


To add a relative path added to the compress file (testb here)
Quote
      invoke GetInterfaceFromProgId,SADR("XStandard.Zip"),addr IID_IZip
      .if eax != 0
         mov ppvIZip,eax
         ;IZip UnPack,SADR("E:\xzip\test.zip"),SADR("E:\xzip"),BSTR("chaineNull")
         mov truc.n1.n2.vt,VT_BSTR ;<<<<<<<<<<<<<<<<
         mov truc.n1.n2.n3.bstrVal,0 ;FUNC(CreateBstr,SADR("rien"))         
         invoke CreateBstr,SADR("E:\xzip\test\Xzip.IDL")
         mov bstrfile,eax
         invoke CreateBstr,SADR("E:\xzip\essai.zip")
         mov bstrarch,eax         
         IZip Pack,bstrfile,bstrarch,addr truc,BSTR("testb"),6         

         IZip Release
         invoke FreeBSTR
      .endif

jj2007

#11
Xzip works but with 177,584 bytes for Windows.inc it is less efficient than gzip.dll (163,186). And MasmBasic will soon zip Windows.inc to a mere 133,149 bytes :bg

hutch--

Just to throw a spanner in the works, JIBZ has released his aPlib as freeware last I heard and from memory it outperforms zip compression on most files.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

oex

:lol meh roll your own.... I only use these tools because it is a web standard.... If I need to compress something I prefer to do it properly :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

ToutEnMasm

As free compressor there is also the zipitfree who haven't  advertisement as JIBZ.
What I search is just something that is compatible with others compressor and can be used by an another program.The xzip do that.To compress some source code it's largely enough.No need of big compression level.