Article View: news.software.nntp
Article #56775Re: [yEnc] Survey time! (Compression or not?)
From: Curt Welch
Date: Fri, 22 Feb 2002 03:40
Date: Fri, 22 Feb 2002 03:40
73 lines
5132 bytes
5132 bytes
Russ Allbery <rra@stanford.edu> wrote: > I don't think you realize what zlib is. zlib is the compression portions > of gzip under a wide-open license. The output of zlib *is* a gzip file. > There is no difference. > > I have no idea how to get zlib to generate a file that gzip *can't* read. > I'm not sure it's possible. I knew they were closely related, but scanning a lot of stuff on the site I didn't see anything that made it clear they were identical. But I'm beginning to catch on. :) Reading some more, I now think I see the confusion I was running into. One comment from the site is what made me think they were not byte for byte compatible. It read: "The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio." It turns out I read that correctly. zlib and zip are NOT the same. zlib and gzip are bascially all the same, but, zlib compression format is NOT the same as gzip _file_ format. The gzip file format is the zlib compressed data format wrapped with extra headers and a CRC-32. The zlib format is documented in rfc1950. It is a standard for wrapping a compressed data stream with some headers and an Adler-32 crc. The default compression method is the "deflate" method described in rfc1951. The zlib in-core compression routines I believe generate a stream which has the rfc1950 headers and uses the rfc1951 deflate compression algorithm. The gzip _file_ format is documented in rfc1952. It acts like a simple file archive format and is a wrapper for the zlib data format. It adds headers which includes a 2 byte magic number, and the file size, and can include a file name, a date, and a comment field, and then adds a CRC32 checksum at the end. This allows you to combine multiple compressed .gz files together simply be concatenation. This is explained on the man page but I never noticed it. So, if you take the zlib compression routines, and use them to compress a file, and write it disk, gzip WILL NOT be able to read it. You have to add the standard gzip headers in front of that and the CRC to the end before it will become a zgip file. The zlib library includes a set of routines for reading and writing gzip files, however, at first glance, there seems to be no way to create a gzip format file in memory with those routines or with any other routines which are part of zlib. So, if one were to use the zlib compression routines in an yEnc encodor/decoder the simple way would be to use only the zlib format data stream. That however is not the same as a gzip format data stream so to make it gzip compatiable, we would have to add the correct headers and the trailing CRC-32 which gzip uses. So, as far as I can tell, most of what you guys were saying is both right and wrong. zlib and gzip are all the same, but, the zlib _compression_ routines do not produce a gzip compatible data stream. You do have to work a bit harder than that if you wanted to make the yEnc data stream gzip compatible as well as zlib compatible. But of course, gzip is simply adding meta information which yenc is already including in it's headers, so there would be a bit of redundancy there anyway. Now that I understand that zlib and gzip are really just the same thing, the best way to do this is simply be to let clients do it if they want and the format and effect would end up being exactly the same as gziping the file and then yencoding it. Which of course is what all of you have been saying was the obviously correct way to do it. :) -- Curt Welch http://CurtWelch.Com/ curt@kcwc.com Webmaster for http://NewsReader.Com/
Technical Details
Message-ID:
<20020221224023.453$bg@newsreader.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!logbridge.uoregon.edu!feed2.news.rcn.net!rcn!dca6-feed2.news.digex.net!intermedia!newsfeed1.cidera.com!Cidera!feed1.newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mailReferences:
<a504os$736$6@pegasus.csx.cam.ac.uk> <200220022141483852%planb@newsreaders.com> <20020220230116.405$a3@newsreader.com> <1014270020.729921@ok-corral.gunslinger.net> <20020221152617.647$FV@newsreader.com> <a53ut8$7i4$4@pegasus.csx.cam.ac.uk> <20020221183904.819$lz@newsreader.com> <yleljecpr8.fsf@windlord.stanford.edu>Show Full Headers
Complete Article Headers
Message-ID: <20020221224023.453$bg@newsreader.com>
Subject: Re: [yEnc] Survey time! (Compression or not?)
Date: Fri, 22 Feb 2002 03:40:23 +0000
From: curt@kcwc.com (Curt Welch)
References: <a504os$736$6@pegasus.csx.cam.ac.uk> <200220022141483852%planb@newsreaders.com> <20020220230116.405$a3@newsreader.com> <1014270020.729921@ok-corral.gunslinger.net> <20020221152617.647$FV@newsreader.com> <a53ut8$7i4$4@pegasus.csx.cam.ac.uk> <20020221183904.819$lz@newsreader.com> <yleljecpr8.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-03!supernews.com!logbridge.uoregon.edu!feed2.news.rcn.net!rcn!dca6-feed2.news.digex.net!intermedia!newsfeed1.cidera.com!Cidera!feed1.newsreader.com!news2.newsreader.com!ellis.newsreader.com!not-for-mail
Organization: NewsReader.Com
Newsgroups: news.software.nntp
X-Trace: NewsReader.Com p@,f2FIUJ7=jtkV,o74mEQ,7s0Vp@q-9B./_w8_qXDq+=rh
X-Face: "p}G*1KH{+F7EYGKLb>ogDguabZ+%,?^epeFB!nzu`)`$=QcvL1KF6<0GH!Tbc!Sqo[|tV5
%IW48mQf3K=Ci&gZ7]]aazx@]Y-nq!r5{yH/#,?@lDdUDvOfByB2hVW0.@OM%{l/{cT'{w
X-Url: http://CurtWelch.Com/
User-Agent: NewsReader.Com
Lines: 72