GZ-decompression?

Just starting out? Need help? Post your questions and find answers here.
hss
User
User
Posts: 69
Joined: Thu Mar 08, 2007 6:02 pm

GZ-decompression?

Post by hss »

hello;

how to decompress gzipped *data? --
some proc / lib / lightweight-dll-without-fancy-stuff out there?


must be something, since 2005 ...

love,
-H
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Do a search for zlib on the forum.
hss
User
User
Posts: 69
Joined: Thu Mar 08, 2007 6:02 pm

Post by hss »

yes - i did

http://www.purebasic.fr/english/viewtop ... 098#202098
gnozal's PBLIB_ZLIB_Static_Classic_GZip.zip ...

added:

Code: Select all

compress(*out,*out_len,*in,in_len)  As "_compress@16" 
uncompress(*out,*out_len,*in,in_len) As "_uncompress@16"
tried to strip GZ-headers as described in RFC 1952 to obtain DEFLATE body/data
and uncompress, but failed: #Z_DATA_ERROR

#### checksum-issue

-hss
Last edited by hss on Fri Jul 03, 2009 3:28 pm, edited 1 time in total.
hss
User
User
Posts: 69
Joined: Thu Mar 08, 2007 6:02 pm

Post by hss »

yay.

recommended for Content-Encoding:
gzip (HTTP 1.1);

Code: Select all

Structure z_stream
next_in.l:avail_in.l:total_in.l:next_out.l:avail_out.l:total_out.l
msg.l:state.l:zalloc.l:zfree.l:opaque.l:data_type.l:adler.l:reserved.l
EndStructure


Import "c:\z.lib"
inflateInit2(s,wb,v,ss) As "_inflateInit2_@16"
inflate(s,f) As "_inflate@8"
inflateEnd(s) As "_inflateEnd@4"
EndImport





Procedure.s gz(gz) ; returns uncompressed-GZIP string; (!) no error-checking

 Protected un,s.z_stream

 un=AllocateMemory(30000) ;adjust

 s\next_in=gz:s\next_out=un
 s\avail_in=MemorySize(gz):s\avail_out=MemorySize(un)
 s\zalloc=#Null:s\zfree=#Null:s\opaque=#Null:s\data_type=1

 inflateInit2(@s,15+32,@"1.2.3",SizeOf(s))
 inflate(@s,4):inflateEnd(@s)

 ProcedureReturn(PeekS(un))

 ;-------If(s\msg):Debug "z/err: "+PeekS(s\msg):EndIf

EndProcedure

...


Code: Select all


GZ_sample=AllocateMemory(?GZ_end-?GZ_beg)
CopyMemory(?GZ_beg,GZ_sample,MemorySize(GZ_sample))

Debug gz(GZ_Sample)

End


DataSection

GZ_beg:
Data.b $1F,$8B,$08,$00,$00,$00,$00,$00,$00,$0B,$CB,$48,$CD,$C9,$C9,$57,$28,$CF,$2F,$CA,$49
Data.b $51,$D0,$55,$48,$CF,$CF,$4F,$D1,$4D,$AA,$4C,$05,$00,$D2,$1D,$C4,$23,$16,$00,$00,$00
GZ_end:

EndDataSection
Post Reply