nemo
nemo

Reputation:

PHP gzinflate() in C?

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

Upvotes: 2

Views: 1755

Answers (1)

caf
caf

Reputation: 239171

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.

Upvotes: 5

Related Questions