tags:

views:

263

answers:

2

Hi guys!

I'm trying since several hours to implement the behaviour of PHP gzinflate() in C. In PHP it's just: gzinflate($str); In Python it's: import zlib ... return zlib.decompress( decoded_data , -15) ... But I just don't manage to implement it in C. Can anybody help me with that? I'm really stuck.. I tried to do something with Zlib but it didn't work.. Anybody got a point?

Thanks in advance,

nemo

A: 

http://www.zlib.net/manual.html#uncompress

Can't manage to do it with uncompress.. Could you may paste a sample which works like deflate?
+2  A: 

This zlib usage example is very thorough.

Note that you are closer to the bare metal here than in Python or PHP, so the usage isn't as simple.

Addendum:

The PHP gzinflate and gzdeflate functions perform input and output raw DEFLATE format. The zlib functions, on the other hand, work by default with zlib streams, which are the same with the addition of a 2 byte header and a 4 byte trailer.

You can either switch to using the PHP gzcompress and gzuncompress functions, which produce ZLIB format, or (if you have a recent version of zlib) use the deflateInit2 function instead of deflateInit and specify a negative value for windowBits, which requests raw DEFLATE format.

caf
Yes, I took a look at that but I'm just not able to create something that works. I can compress and uncompress things, but I don't manage to uncompress a string which was deflated with gzdeflate.