PHP gzinflate () in C?

I've been trying for several hours to implement PHP's gzinflate () behavior in C. In PHP, it's simple: gzinflate ($ string); In Python it is: import zlib ... return zlib.decompress (decoded_data, -15) ... But I just can't implement it in C. Can anyone help me with this? I'm really stuck .. I tried to do something with Zlib, but it didn't work. Anyone got a point?

Thanks in advance,

Nemo

+2


source to share


1 answer


This example using zlib is very detailed.

Note that you are closer to the bare metal here than in Python or PHP, so the usage is not that easy.

Adding:



PHP functions gzinflate

and gzdeflate

execute input and output DEFLATE source format. On the other hand, zlib functions work by default with zlib streams, which is the same as adding a 2 byte header and a 4 byte trailer.

You can switch to using PHP gzcompress

and functions gzuncompress

that produce the ZLIB format, or (if you have the latest version of zlib installed) use the function deflateInit2

instead of deflateInit

and supply a negative value for windowBits

which prompts for the DEFLATE format.

+5


source







All Articles