src/utility/tinflate.c
long tinflate(const void *compressed_data, long compressed_size,
              void *output_buffer, long output_size,
              unsigned long *crc_ret)
{
    /* state: Decompression state buffer to pass to tinflate_block(). */
    DecompressionState state;

    /* size: Size of uncompressed data. */
    unsigned long size;

    /* result: Result of tinflate_partial(). */
    int result;

    /*-------------------------------------------------------------------*/

    /**** Check parameter validity. ****/

    if (compressed_data == NULL || compressed_size < 0 || output_size < 0
     || (output_size > 0 && output_buffer == NULL)) {
        return -1;
    }

    /**** Clear decompression state buffer. ****/

    state.state     = INITIAL;
    state.out_ofs   = 0;
    state.crc       = 0;
    state.bit_accum = 0;
    state.num_bits  = 0;
    state.final     = 0;
    /* No other fields need to be cleared. */

    /**** Call tinflate_partial() to do the actual decompression. ****/

    result = tinflate_partial(compressed_data, compressed_size,
                              output_buffer, output_size,
                              &size, crc_ret,
                              &state, sizeof(state));
    if (result != 0) {
        /* A positive result (out of compressed data) is also an error here. */
        return -1;
    }

    /**** Return the size of the uncompressed data.  tinflate_partial() ****
     **** ensures that the size does not roll over to a negative value. ****/

    return (long)size;
}
/**
 * tinflate:  Decompress a complete stream of data compressed with the
 * "deflate" algorithm.
 *
 * Parameters:
 *     compressed_data: Pointer to the compressed data.
 *     compressed_size: Number of bytes of compressed data.
 *       output_buffer: Pointer to the buffer to receive uncompressed data.
 *         output_size: Size of the output buffer, in bytes.
 *             crc_ret: Pointer to variable to receive the CRC-32 of the
 *                         uncompressed data, or NULL if the CRC is not
 *                         needed.
 * Return value:
 *     The number of bytes occupied by the decompressed data (a nonnegative
 *     value), regardless of the size of the output buffer, or an
 *     unspecified negative value if an error occurs.  (A full output
 *     buffer is not considered an error.)
 * Notes:
 *     The returned CRC value is only valid when the entire stream of
 *     decompressed data fits within the output buffer, i.e. when the
 *     function's return value is no greater than "output_size".
 */
Decompress a complete stream of data compressed with the
"deflate" algorithm.

Pointer to the compressed data.
compressed_size: Number of bytes of compressed data.
output_buffer: Pointer to the buffer to receive uncompressed data.
output_size: Size of the output buffer, in bytes.
crc_ret: Pointer to variable to receive the CRC-32 of the
uncompressed data, or NULL if the CRC is not
needed.
Return value:
The number of bytes occupied by the decompressed data (a nonnegative
value), regardless of the size of the output buffer, or an
unspecified negative value if an error occurs.  (A full output
buffer is not considered an error.)
Notes:
The returned CRC value is only valid when the entire stream of
decompressed data fits within the output buffer, i.e. when the
function's return value is no greater than "output_size".
Decompress a complete stream of data compressed with the " deflate " algorithm . Pointer to the compressed data . compressed_size : Number of bytes of compressed data . output_buffer : Pointer to the buffer to receive uncompressed data . output_size : Size of the output buffer in bytes . crc_ret : Pointer to variable to receive the CRC - 32 of the uncompressed data or NULL if the CRC is not needed . Return value : The number of bytes occupied by the decompressed data ( a nonnegative value ) regardless of the size of the output buffer or an unspecified negative value if an error occurs . ( A full output buffer is not considered an error . ) Notes : The returned CRC value is only valid when the entire stream of decompressed data fits within the output buffer i . e . when the function ' s return value is no greater than " output_size " .
long tinflate(const void *compressed_data, long compressed_size,
              void *output_buffer, long output_size,
              unsigned long *crc_ret)
{
    DecompressionState state;
    unsigned long size;
    int result;
    if (compressed_data == NULL || compressed_size < 0 || output_size < 0
     || (output_size > 0 && output_buffer == NULL)) {
        return -1;
    }
    state.state     = INITIAL;
    state.out_ofs   = 0;
    state.crc       = 0;
    state.bit_accum = 0;
    state.num_bits  = 0;
    state.final     = 0;
    result = tinflate_partial(compressed_data, compressed_size,
                              output_buffer, output_size,
                              &size, crc_ret,
                              &state, sizeof(state));
    if (result != 0) {
        return -1;
    }
    return (long)size;
}
long tinflate ( const void * compressed_data , long compressed_size , void * output_buffer , long output_size , unsigned long * crc_ret ) { DecompressionState state ; unsigned long size ; int result ; if ( compressed_data == NULL || compressed_size < 0 || output_size < 0 || ( output_size > 0 && output_buffer == NULL ) ) { return -1 ; } state . state = INITIAL ; state . out_ofs = 0 ; state . crc = 0 ; state . bit_accum = 0 ; state . num_bits = 0 ; state . final = 0 ; result = tinflate_partial ( compressed_data , compressed_size , output_buffer , output_size , & size , crc_ret , & state , sizeof ( state ) ) ; if ( result != 0 ) { return -1 ; } return ( long ) size ; }
tinflate:  Decompress a complete stream of data compressed with the
 "deflate" algorithm.
tinflate : Decompress a complete stream of data compressed with the " deflate " algorithm .
/* state: Decompression state buffer to pass to tinflate_block(). */ /* size: Size of uncompressed data. */ /* result: Result of tinflate_partial(). */ /*-------------------------------------------------------------------*/ /**** Check parameter validity. ****/ /**** Clear decompression state buffer. ****/ /* No other fields need to be cleared. */ /**** Call tinflate_partial() to do the actual decompression. ****/ /* A positive result (out of compressed data) is also an error here. */ /**** Return the size of the uncompressed data.  tinflate_partial() ****
     **** ensures that the size does not roll over to a negative value. ****/