Link to home
Start Free TrialLog in
Avatar of core123
core123

asked on

zlib uncompression

In a program, I've imported the call "uncompress()" from zlib.dll using LoadLibrary(), then GetProcAddress() with the handle returned by LoadLibrary().  So now that I have support to call the function uncompress() from zlib.dll, how do I uncompress an entire file?  For 500 points, I wanna see code example that I can copy and paste (with relatively few modifications) :)

Thanks!
Chris O.
ASKER CERTIFIED SOLUTION
Avatar of PIG
PIG

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of core123
core123

ASKER

Arg, but how would I use that with a file? I want this spoon-fed to me!
FILE* fileIn =  fopen("YourFileIn.XXX", "r");
FILE* fileOut =  fopen("YourFileOut.XXX", "w");
while (TRUE){
  Byte bufferIn[1024];
  uLong readB = fread((void*)bufferIn, 1024, 1, fileIn);
  if (!readB) break;
  Byte bufferOt[1024];
  uLong writeB = 0;
  YourUnompressFunction(bufferIn, readB, bufferOut, writeB);
  uLong realWB = fwrite(bufferOut, writeB, 1, fileOut);
  if ((readB < 1024) || (realWB < writeB)) break;
}
fclose(fileIn);
fclose(fileOut);