diff --git a/examples/zlib_how.html b/examples/zlib_how.html index 444ff1c..43271b9 100644 --- a/examples/zlib_how.html +++ b/examples/zlib_how.html @@ -1,10 +1,10 @@ - +
-Without further adieu, here is the program zpipe.c: +Without further ado, here is the program zpipe.c:
/* zpipe.c: example of proper use of zlib's inflate() and deflate() Not copyrighted -- provided to the public domain @@ -155,13 +155,11 @@ before we fall out of the loop at the bottom.We start off by reading data from the input file. The number of bytes read is put directly into avail_in, and a pointer to those bytes is put into next_in. We also -check to see if end-of-file on the input has been reached. If we are at the end of file, then flush is set to the +check to see if end-of-file on the input has been reached using feof(). +If we are at the end of file, then flush is set to the zlib constant Z_FINISH, which is later passed to deflate() to -indicate that this is the last chunk of input data to compress. We need to use feof() -to check for end-of-file as opposed to seeing if fewer than CHUNK bytes have been read. The -reason is that if the input file length is an exact multiple of CHUNK, we will miss -the fact that we got to the end-of-file, and not know to tell deflate() to finish -up the compressed stream. If we are not yet at the end of the input, then the zlib +indicate that this is the last chunk of input data to compress. +If we are not yet at the end of the input, then the zlib constant Z_NO_FLUSH will be passed to deflate to indicate that we are still in the middle of the uncompressed data.
@@ -540,6 +538,12 @@ int main(int argc, char **argv) }