.. include:: ../global.rst .. idio:currentmodule:: zlib zlib Functions -------------- In the following functions `windowBits` is tri-state and multi-valued. For the ``deflate`` and ``inflate`` functions you can use the full variance: * if `windowBits` is between 9 and 15, inclusive, a *zlib* header and trailer will be added/expected * further, if `windowBits` has 16 added to it, then add/expect a *gzip* header and trailer * if `windowBits` is between -15 and -9, inclusive, a *raw* deflate stream will be created/expected for programs that want to use the raw stream (eg. :program:`zip`) * for ``inflate``, if `windowBits` is 0 (zero), then the window size in the header will be used The ``gzip-*`` and ``zlib-*`` functions enforce *gzip* and *zlib* header and trailer respectively meaning: * for ``gzip-compress`` and ``gzip-decompress``, `windowBits` defaults to 15 and is range limited from 9 to 15 inclusive and the 16 for a *gzip* header is added implicitly For ``gzip-decompress`` a `windowBits` of 0 (use the window size in the header) is still possible. * for ``zlib-compress`` and ``zlib-decompress``, `windowBits` defaults to 15 and is range limited from 9 to 15 inclusive For ``zlib-decompress`` a `windowBits` of 0 (use the window size in the header) is still possible. .. _`zlib/gzip-compress`: .. idio:function:: zlib/gzip-compress handle (:level Z_DEFAULT_COMPRESSION) (:windowBits 15) (:strategy Z_DEFAULT_STRATEGY) Return gzip compression of the UTF-8 encoded data stream in `handle`. :param handle: handle :type handle: input handle :keyword :level: compression level, defaults to ``Z_DEFAULT_COMPRESSION`` :type level: C/int|fixnum, optional :keyword :windowBits: base two logarithm of the window size, defaults to 15 :type windowBits: C/int|fixnum, optional :keyword :strategy: strategy, defaults to ``Z_DEFAULT_STRATEGY`` :type strategy: C/int|fixnum, optional :return: compressed data :rtype: octet string :raises ^rt-zlib-error: .. _`zlib/gzip-decompress`: .. idio:function:: zlib/gzip-decompress handle (:windowBits 15) Return gzip decompression of the bytes in `handle`. :param handle: handle :type handle: input handle :keyword :windowBits: base two logarithm of the window size, defaults to 15 :type windowBits: C/int|fixnum, optional :return: compressed data :rtype: octet string :raises ^rt-zlib-error: .. _`zlib/zlib-compress`: .. idio:function:: zlib/zlib-compress handle (:level Z_DEFAULT_COMPRESSION) (:windowBits 15) (:strategy Z_DEFAULT_STRATEGY) Return zlib compression of the UTF-8 encoded data stream in `handle`. :param handle: handle :type handle: input handle :keyword :level: compression level, defaults to ``Z_DEFAULT_COMPRESSION`` :type level: C/int|fixnum, optional :keyword :windowBits: base two logarithm of the window size, defaults to 15 :type windowBits: C/int|fixnum, optional :keyword :strategy: strategy, defaults to ``Z_DEFAULT_STRATEGY`` :type strategy: C/int|fixnum, optional :return: compressed data :rtype: octet string :raises ^rt-zlib-error: .. _`zlib/zlib-decompress`: .. idio:function:: zlib/zlib-decompress handle (:windowBits 15) Return zlib decompression of the bytes in `handle`. :param handle: handle :type handle: input handle :keyword :windowBits: base two logarithm of the window size, defaults to 15 :type windowBits: C/int|fixnum, optional :return: compressed data :rtype: octet string :raises ^rt-zlib-error: .. _`zlib/deflate`: .. idio:function:: zlib/deflate handle (:level Z_DEFAULT_COMPRESSION) (:windowBits 15) (:strategy Z_DEFAULT_STRATEGY) Return zlib compression of the UTF-8 encoded data stream in `handle`. :param handle: handle :type handle: input handle :keyword :level: compression level, defaults to ``Z_DEFAULT_COMPRESSION`` :type level: C/int|fixnum, optional :keyword :windowBits: base two logarithm of the window size, defaults to 15 :type windowBits: C/int|fixnum, optional :keyword :strategy: strategy, defaults to ``Z_DEFAULT_STRATEGY`` :type strategy: C/int|fixnum, optional :return: compressed data :rtype: octet string :raises ^rt-zlib-error: .. _`zlib/inflate`: .. idio:function:: zlib/inflate handle (:windowBits 15) Return zlib decompression of the bytes in `handle`. :param handle: handle :type handle: input handle :keyword :windowBits: base two logarithm of the window size, defaults to 15 :type windowBits: C/int|fixnum, optional :return: compressed data :rtype: octet string :raises ^rt-zlib-error: .. _`zlib/zlib-version`: .. idio:function:: zlib/zlib-version Return the zlib version :return: zlib version :rtype: string .. include:: ../commit.rst