aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2023-01-24 20:43:19 -0800
committerMark Adler <madler@alumni.caltech.edu>2023-01-24 20:43:19 -0800
commita9b4c1de37bb1962048a6a83658479c3902ca9f8 (patch)
treead3da3a7f59a95dc13ca7bea72e762429279dc0f /examples
parent02a6049eb3884c430268bb0fe3296d597a03174c (diff)
downloadzlib-a9b4c1de37bb1962048a6a83658479c3902ca9f8.tar.gz
zlib-a9b4c1de37bb1962048a6a83658479c3902ca9f8.tar.bz2
zlib-a9b4c1de37bb1962048a6a83658479c3902ca9f8.zip
Update zlib_how.html to match the web page, and add a license.
Diffstat (limited to 'examples')
-rw-r--r--examples/zlib_how.html26
1 files changed, 15 insertions, 11 deletions
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 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/REC-html40/loose.dtd"> 2 "http://www.w3.org/TR/html4/loose.dtd">
3<html> 3<html>
4<head> 4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>zlib Usage Example</title> 6<title>zlib Usage Example</title>
7<!-- Copyright (c) 2004, 2005 Mark Adler. --> 7<!-- Copyright (c) 2004-2023 Mark Adler. -->
8</head> 8</head>
9<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000"> 9<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000">
10<h2 align="center"> zlib Usage Example </h2> 10<h2 align="center"> zlib Usage Example </h2>
@@ -17,7 +17,7 @@ from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()<
17annotations are interspersed between lines of the code. So please read between the lines. 17annotations are interspersed between lines of the code. So please read between the lines.
18We hope this helps explain some of the intricacies of <em>zlib</em>. 18We hope this helps explain some of the intricacies of <em>zlib</em>.
19<p> 19<p>
20Without further adieu, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>: 20Without further ado, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>:
21<pre><b> 21<pre><b>
22/* zpipe.c: example of proper use of zlib's inflate() and deflate() 22/* zpipe.c: example of proper use of zlib's inflate() and deflate()
23 Not copyrighted -- provided to the public domain 23 Not copyrighted -- provided to the public domain
@@ -155,13 +155,11 @@ before we fall out of the loop at the bottom.
155</b></pre> 155</b></pre>
156We start off by reading data from the input file. The number of bytes read is put directly 156We start off by reading data from the input file. The number of bytes read is put directly
157into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also 157into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also
158check to see if end-of-file on the input has been reached. If we are at the end of file, then <tt>flush</tt> is set to the 158check to see if end-of-file on the input has been reached using feof().
159If we are at the end of file, then <tt>flush</tt> is set to the
159<em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to 160<em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to
160indicate that this is the last chunk of input data to compress. We need to use <tt>feof()</tt> 161indicate that this is the last chunk of input data to compress.
161to check for end-of-file as opposed to seeing if fewer than <tt>CHUNK</tt> bytes have been read. The 162If we are not yet at the end of the input, then the <em>zlib</em>
162reason is that if the input file length is an exact multiple of <tt>CHUNK</tt>, we will miss
163the fact that we got to the end-of-file, and not know to tell <tt>deflate()</tt> to finish
164up the compressed stream. If we are not yet at the end of the input, then the <em>zlib</em>
165constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still 163constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still
166in the middle of the uncompressed data. 164in the middle of the uncompressed data.
167<p> 165<p>
@@ -540,6 +538,12 @@ int main(int argc, char **argv)
540} 538}
541</b></pre> 539</b></pre>
542<hr> 540<hr>
543<i>Copyright (c) 2004, 2005 by Mark Adler<br>Last modified 11 December 2005</i> 541<i>Last modified 24 January 2023<br>
542Copyright &#169; 2004-2023 Mark Adler</i><br>
543<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">
544<img alt="Creative Commons License" style="border-width:0"
545src="https://i.creativecommons.org/l/by-nd/4.0/88x31.png"></a>
546<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">
547Creative Commons Attribution-NoDerivatives 4.0 International License</a>.
544</body> 548</body>
545</html> 549</html>