Guido van Rossum | 04bc9d6 | 1997-04-30 18:12:27 +0000 | [diff] [blame^] | 1 | % zlib compression module version A.01.02 |
| 2 | % Alpha test release. |
| 3 | % Written by A.M. Kuchling (amk@magnet.com) |
| 4 | % Comments are welcomed. |
| 5 | % |
| 6 | % Can you think of a better name than zlib? (The module's purpose isn't |
| 7 | % really obvious from the name) |
| 8 | |
| 9 | \section{Built-in Module \sectcode{zlib}} |
| 10 | \bimodindex{zlib} |
| 11 | |
| 12 | For applications that require data compression, the functions in this |
| 13 | module allow compression and decompression, using a library based on |
| 14 | GNU zip. The library is available at |
| 15 | \code{ftp://godzilli.cs.sunysb.edu/pub/ngf/zlib-1.00.tar.gz}, |
| 16 | and is mirrored at |
| 17 | \code{ftp://ftp.uu.net/graphics/png/src/zlib-1.00.tar.gz}. Version |
| 18 | 1.00 is the most recent version as of March 18, 1996; use a later |
| 19 | version if one is available. |
| 20 | |
| 21 | The available functions in this module are: |
| 22 | |
| 23 | \renewcommand{\indexsubitem}{(in module zlib)} |
| 24 | \begin{funcdesc}{adler32}{string\optional{\, value}} |
| 25 | Computes a Adler-32 checksum of \var{string}. (An Adler-32 |
| 26 | checksum is almost as reliable as a CRC32 but can be computed much |
| 27 | more quickly.) If \var{value} is present, it is used as the |
| 28 | starting value of the checksum; otherwise, a fixed default value is |
| 29 | used. This allows computing a running checksum over the |
| 30 | concatenation of several input strings. The algorithm is not |
| 31 | cryptographically strong, and should not be used for |
| 32 | authentication or digital signatures. |
| 33 | \end{funcdesc} |
| 34 | |
| 35 | \begin{funcdesc}{compress}{string\optional{\, level}} |
| 36 | Compresses the data in \var{string}, returning a string contained |
| 37 | compressed data. \var{level} is an integer from 1 to 9 controlling |
| 38 | the level of compression; 1 is fastest and produces the least |
| 39 | compression, 9 is slowest and produces the most. The default value is |
| 40 | 6, which . Raises the \code{zlib.error} exception if any error occurs. |
| 41 | \end{funcdesc} |
| 42 | |
| 43 | \begin{funcdesc}{compressobj}{\optional{level}} |
| 44 | Returns a compression object, to be used for compressing data streams |
| 45 | that won't fit into memory at once. \var{level} is an integer from |
| 46 | 1 to 9 controlling the level of compression; 1 is fastest and |
| 47 | produces the least compression, 9 is slowest and produces the most. |
| 48 | The default value is 6. |
| 49 | \end{funcdesc} |
| 50 | |
| 51 | \begin{funcdesc}{crc32}{string\optional{\, value}} |
| 52 | Computes a CRC (Cyclic Redundancy Check) sum of \var{string}. If |
| 53 | \var{value} is present, it is used as the starting value of the |
| 54 | checksum; otherwise, a fixed default value is used. This allows |
| 55 | computing a running checksum over the concatenation of several |
| 56 | input strings. The algorithm is not cryptographically strong, and |
| 57 | should not be used for authentication or digital signatures. |
| 58 | \end{funcdesc} |
| 59 | |
| 60 | \begin{funcdesc}{decompress}{string} |
| 61 | Decompresses the data in \var{string}, returning a string containing |
| 62 | the uncompressed data. Raises the \code{zlib.error} exception if any |
| 63 | error occurs. |
| 64 | \end{funcdesc} |
| 65 | |
| 66 | \begin{funcdesc}{decompressobj}{\optional{wbits}} |
| 67 | Returns a compression object, to be used for decompressing data streams |
| 68 | that won't fit into memory at once. The \var{wbits} parameter controls the size of the window buffer; usually this can be left alone. |
| 69 | \end{funcdesc} |
| 70 | |
| 71 | Compression objects support the following methods: |
| 72 | |
| 73 | \begin{funcdesc}{compress}{string} |
| 74 | Compress \var{string}, returning a string containing compressed data |
| 75 | for at least part of the data in \var{string}. This data should be |
| 76 | concatenated to the output produced by any preceding calls to the |
| 77 | \code{compress()} method. Some input may be kept in internal buffers |
| 78 | for later processing. |
| 79 | \end{funcdesc} |
| 80 | |
| 81 | \begin{funcdesc}{flush}{} |
| 82 | All pending input is processed, and an string containing the remaining |
| 83 | compressed output is returned. After calling \code{flush()}, the |
| 84 | \code{compress()} method cannot be called again; the only realistic |
| 85 | action is to delete the object. |
| 86 | \end{funcdesc} |
| 87 | |
| 88 | Decompression objects support the following methods: |
| 89 | |
| 90 | \begin{funcdesc}{decompress}{string} |
| 91 | Decompress \var{string}, returning a string containing the |
| 92 | uncompressed data corresponding to at least part of the data in |
| 93 | \var{string}. This data should be concatenated to the output produced |
| 94 | by any preceding calls to the |
| 95 | \code{decompress()} method. Some of the input data may be preserved in internal buffers |
| 96 | for later processing. |
| 97 | \end{funcdesc} |
| 98 | |
| 99 | \begin{funcdesc}{flush}{} |
| 100 | All pending input is processed, and a string containing the remaining |
| 101 | uncompressed output is returned. After calling \code{flush()}, the |
| 102 | \code{decompress()} method cannot be called again; the only realistic |
| 103 | action is to delete the object. |
| 104 | \end{funcdesc} |
| 105 | |
| 106 | |
| 107 | |