![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to compress .zlib file | wrapster | UNIX for Advanced & Expert Users | 1 | 05-04-2008 11:52 PM |
| problem about using zlib to uncompress gzip in memory | iwishfine | High Level Programming | 0 | 03-24-2007 10:56 PM |
| uncompress | big123456 | UNIX for Advanced & Expert Users | 3 | 11-20-2006 09:42 PM |
| rsh and uncompress and tar | big123456 | Shell Programming and Scripting | 4 | 05-27-2005 06:44 AM |
| Uncompress... me!!!!!! :) | gussiglo21 | UNIX for Dummies Questions & Answers | 3 | 12-10-2003 07:43 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
uncompress of zlib
When I gzopen & gzread from a gzip file, it works OK. But I when I try to uncompress the same data from memory (either by reading to memory with fread or mmap()ing) using decompress, I get Z_DATA_ERROR. Is it because gzip file has some kind of headers that uncompress doesn't want?
How can I get around this? Code:
fp = fopen("file.gz", "r");
buf = mmap(0,len,PROT_READ,MAP_SHARED,fileno(fp),0);
assert(buf);
if(uncompress(out,&outsize,buf,len) == Z_DATA_ERROR) fprintf(stderr,"boh\n");
Code:
uncompress(out,&outsize,buf+8,len-8) Last edited by rayne; 08-28-2006 at 03:27 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
OK, I figured it out.
zlib function uncompress uses inflateInit(), which accepts zlib format, not gzip. I've changed inflateInit() to inflateInit2() and it worked. However, for 2nd argument of inflateInit2(), I've tried various numbers but it worked for only 24,30,47. Which means at least 16MB of buffer! How can I get around this now? |
|
#3
|
|||
|
|||
|
That is strange, since it's only supposed to accept values of 8...15. What error do you get when you use other values?
|
|
#4
|
|||
|
|||
|
mmh,
some time ago i used a library call libfz (?) it supports fzopen() that let you read or write any compressed file without much problems. just my 2 cents, happy hacking |
|||
| Google The UNIX and Linux Forums |