Can someone tell me which function I need to use in order to decompress a byte array that has been compressed with vb.net's gzipstream. I would like to use zlib.
I've included the zlib.h but I haven't been able to figure out what function(s) I should use.
You can take a look at The Boost Iostreams Library:
And then to decompress line by line:
Or entire file into an array:
Have a look at the zlib usage example. http://www.zlib.net/zpipe.c
The function that does the real work is inflate(), but you need inflateInit() etc.
You need to use
inflateInit2()
to request gzip decoding. Read the documentation in zlib.h.There is a lot of sample code in the zlib distribution. Also take a look at this heavily documented example of zlib usage. You can modify that one to use
inflateInit2()
instead ofinflateInit()
.Here is a C function that does the job with zlib:
The uncompressed string is returned in uncompr. It's a null-terminated C string so you can do puts(uncompr). The function above only works if the output is text. I have tested it and it works.