|Linux Standard Base Core Specification 4.0|
|<<< Previous||Next >>>|
The deflate() function shall attempt to compress data until either the input buffer is empty or the output buffer is full. The stream references a z_stream structure. Before the first call to deflate(), this structure should have been initialized by a call to deflateInit2_().
Note: deflateInit2_() is only in the binary standard; source level applications should initialize stream via a call to deflateInit() or deflateInit2().
should point to the data to be compressed.
should contain the number of bytes of data in the
buffer referenced by
should point to a buffer where compressed data may be placed.
should contain the size in bytes of the
buffer referenced by
The deflate() function shall perform one or both of the following actions:
Compress input data from
total_in to reflect the data that has been
Fill the output buffer referenced by
total_out to reflect the compressed data that
has been placed there. If flush is not
avail_out indicates that there is still space in
output buffer, this action shall always occur (see below for further details).
The deflate() function shall return when either
avail_in reaches zero (indicating that all the input
data has been compressed), or
zero (indicating that the output buffer is full).
On success, the deflate() function shall set the
adler field of the stream
to the adler32() checksum of all the input data compressed
so far (represented by
If the deflate() function shall attempt to determine
the type of input data, and set field
in stream to
Z_ASCII if the
majority of the data bytes fall within the ASCII (ISO 646) printable
character range. Otherwise, it shall set
This data type is informational only, and does not affect the compression
Note: Future versions of the LSB may remove this requirement, since it is based on an outdated character set that does not support Internationalization, and does not affect the algorithm. It is included for information only at this release. Applications should not depend on this field.
The parameter flush determines when compressed bits
are added to the output buffer in
If flush is
may return with some data pending output, and not yet added to the
If flush is
deflate() shall flush all pending output to
next_out and align the output to a byte
boundary. A synchronization point is generated in the output.
If flush is
all output shall be flushed, as for
and the compression state shall be reset.
A synchronization point is generated in the output.
Z_SYNC_FLUSHis intended to ensure that the compressed data contains all the data compressed so far, and allows a decompressor to reconstruct all of the input data.
Z_FULL_FLUSHallows decompression to restart from this point if the previous compressed data has been lost or damaged. Flushing is likely to degrade the performance of the compression system, and should only be used where necessary.
If flush is set to
all pending input shall be processed and deflate()
shall return with Z_STREAM_END if there is
sufficient space in the output buffer at
as indicated by
deflate() is called with flush
Z_FINISH and there is insufficient space to store
the compressed data, and no other error has occurred during compression,
deflate() shall return Z_OK,
and the application should call deflate() again with
flush unchanged, and having updated
If all the compression is to be done in a single step,
may be called with flush set to
Z_FINISH immediately after the stream
has been initialized if
is set to at least the value returned by deflateBound().
On success, deflate() shall return
Z_OK, unless flush was set
Z_FINISH and there was sufficient space in the output buffer
to compress all of the input data. In this case, deflate()
shall return Z_STREAM_END.
On error, deflate() shall return a value to indicate
Note: If deflate() returns Z_OK and has set
avail_outto zero, the function should be called again with the same value for flush, and with updated
avail_outuntil deflate() returns with Z_OK (or Z_STREAM_END if flush is set to
Z_FINISH) and a non-zero
On error, deflate() shall return a value as described
below, and set the
msg field of
stream to point to a string describing the error:
No progress is possible; either
The state (as represented in stream) is inconsistent, or
|<<< Previous||Home||Next >>>|