Hello:
Sorry but I spent many hours to detect why doesn't work this
program, and I dont make anything. I'm using Zlib and compiling with
DJGPP MSDOS compiler.
This is the simple program:
#include <stdio.h>
#include <fcntl.h>
#include "zlib.h"
#include "zutil.h"
main()
{
#define SIZE 4000
unsigned char buf[SIZE];
unsigned char *ubuf;
int fp,fp2;
long uncomprLen=200000;
long comprLen=SIZE;
int err;
z_stream d_stream; /* decompression stream */
z_verbose=10;
ubuf=(unsigned char *)malloc(200000);
fp=open("prueba.gz",O_RDONLY|O_BINARY);
comprLen=read(fp,buf,SIZE);
memset(ubuf,0x00,200000);
d_stream.zalloc = (alloc_func)0;
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = &buf[0];
d_stream.avail_in = 0;
d_stream.next_out = ubuf;
err = inflateInit(&d_stream);
printf("%d %s\n",err, "inflateInit");
while (d_stream.total_out < uncomprLen && d_stream.total_in <
comprLen) {
d_stream.avail_in = d_stream.avail_out = 1; /* force small
buffers */
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
printf("%d %s\n",err, "inflate");
if (err == Z_DATA_ERROR) break;
}
What's happen ? Always return with Z_DATA_ERRORQuote:}
Many thanks.
Juanjo Erauskin