diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | deflate.3 | 173 | ||||
-rw-r--r--[l---------] | deflateEnd.3 | 41 | ||||
-rw-r--r--[l---------] | deflateInit.3 | 164 |
4 files changed, 211 insertions, 171 deletions
diff --git a/Makefile b/Makefile index 549ba86..69a73c8 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,9 @@ MAN += crc32_combine.3 MAN += deflate.3 MAN += deflateBound.3 MAN += deflateCopy.3 +MAN += deflateEnd.3 MAN += deflateGetDictionary.3 +MAN += deflateInit.3 MAN += deflateInit2.3 MAN += deflateParams.3 MAN += deflatePending.3 @@ -22,8 +24,6 @@ MAN += zlibVersion.3 MLINKS += adler32.3 adler32_z.3 MLINKS += compress.3 compress2.3 MLINKS += crc32.3 crc32_z.3 -MLINKS += deflate.3 deflateEnd.3 -MLINKS += deflate.3 deflateInit.3 MLINKS += inflate.3 inflateEnd.3 MLINKS += inflate.3 inflateInit.3 MLINKS += uncompress.3 uncompress2.3 diff --git a/deflate.3 b/deflate.3 index 96b2921..2195cdf 100644 --- a/deflate.3 +++ b/deflate.3 @@ -3,9 +3,7 @@ .Os . .Sh NAME -.Nm deflate , -.Nm deflateInit , -.Nm deflateEnd +.Nm deflate .Nd deflate compression . .Sh LIBRARY @@ -14,129 +12,9 @@ .Sh SYNOPSIS .In zlib.h .Ft int -.Fn deflateInit "z_streamp strm" "int level" -.Ft int .Fn deflate "z_streamp strm" "int flush" -.Ft int -.Fn deflateEnd "z_streamp strm" . .Sh DESCRIPTION -The -.Vt z_streamp -type is defined as follows: -. -.Bd -literal -offset indent -typedef voidpf (*alloc_func) (voidpf opaque, uInt items, uInt size); -typedef void (*free_func) (voidpf opaque, voidpf address); - -typedef struct z_stream_s { - z_const Bytef *next_in; - uInt avail_in; - uLong total_in; - - Bytef *next_out; - uInt avail_out; - uLong total_out; - - z_const char *msg; - struct internal_state FAR *state; - - alloc_func zalloc; - free_func zfree; - voidpf opaque; - - int data_type; - uLong adler; - uLong reserved; -} z_stream; - -typedef z_stream FAR *z_streamp; -.Ed -. -.Pp -The fields of -.Vt z_stream -are as follows: -. -.Bl -tag -width "data_type" -.It Fa next_in -next input byte -.It Fa avail_in -number of bytes available at -.Fa next_in -.It Fa total_in -total number of input bytes read so far -.It Fa next_out -next output byte will go here -.It Fa avail_out -remaining free space at -.Fa next_out -.It Fa total_out -total number of bytes output so far -.It Fa msg -last error message, -.Dv NULL -if no error -.It Fa state -not visible by applications -.It Fa zalloc -used to allocate the internal state -.It Fa zfree -used to free the internal state -.It Fa opaque -private data object passed to -.Fa zalloc -and -.Fa zfree -.It data_type -best guess about the data type: -binary or text for -.Fn deflate , -or the decoding state for -.Xr inflate 3 -.It adler -Adler-32 or CRC-32 value of the uncompressed data -.It reserved -reserved for future use -.El -. -.Pp -.Fn deflateInit -initializes the internal stream state for compression. -The fields -.Fa zalloc , -.Fa zfree -and -.Fa opaque -must be initialized before by the caller. -If -.Fa zalloc -and -.Fa zfree -are set to -.Dv Z_NULL , -.Fn deflateInit -updates them to use default allocation functions. -.Fn deflateInit -does not perform any compression: -this will be done by -.Fn deflate . -. -.Pp -The compression -.Fa level -must be -.Dv Z_DEFAULT_COMPRESSION , -or between 0 and 9: -1 gives best speed, -9 gives best compression, -0 gives no compression at all -(the input data is simply copied a block at a time). -.Dv Z_DEFAULT_COMPRESSION -requests a default compromise between speed and compression -(currently equivalent to level 6). -. -.Pp .Fn deflate compresses as much data as possible, and stops when the input buffer becomes empty @@ -373,14 +251,14 @@ has returned the only possible operations on the stream are .Xr deflateReset 3 or -.Fn deflateEnd . +.Xr deflateEnd 3 . . .Pp .Dv Z_FINISH can be used in the first .Fn deflate call after -.Fn deflateInit +.Xr deflateInit 3 if all the compression is to be done in a single step. In order to complete in one call, .Fa avail_out @@ -430,35 +308,7 @@ the date is considered binary. This field is only for information purposes and does not affect the compression algorithm in any manner. . -.Pp -.Fn deflateEnd -causes all dynamically allocated data structures -for this stream to be freed. -This function discards any unprocessed input -and does not flush any pending output. -. .Sh RETURN VALUES -.Fn deflateInit -returns -.Dv Z_OK -if success, -.Dv Z_MEM_ERROR -if there was not enough memory, -.Dv Z_STREAM_ERROR -if -.Fa level -is not a valid compression level, -or -.Dv Z_VERSION_ERROR -if the zlib library version -.Pq Xr zlibVersion 3 -is incompatible with the version assumed by the caller -.Pq Dv ZLIB_VERSION . -.Fa msg -is set to null -if there is no error message. -. -.Pp .Fn deflate returns .Dv Z_OK @@ -503,17 +353,6 @@ and can be called again with more input and more output space to continue compressing. . -.Pp -.Fn deflateEnd -returns -.Dv Z_OK -if success, -.Dv Z_STREAM_ERROR -if the stream state was inconsistent, -.Dv Z_DATA_ERROR -if the stream was freed prematurely -(some input or output was discarded). -In the error case, -.Fa msg -may be set but then points to a static string -(which must not be deallocated). +.Sh SEE ALSO +.Xr deflateEnd 3 , +.Xr deflateInit 3 diff --git a/deflateEnd.3 b/deflateEnd.3 index 7d7a5e2..8818c91 120000..100644 --- a/deflateEnd.3 +++ b/deflateEnd.3 @@ -1 +1,40 @@ -deflate.3 \ No newline at end of file +.Dd November 9, 2018 +.Dt DEFLATEEND 3 +.Os +. +.Sh NAME +.Nm deflateEnd +.Nd free deflate stream +. +.Sh LIBRARY +.Lb libz +. +.Sh SYNOPSIS +.In zlib.h +.Ft int +.Fn deflateEnd "z_streamp strm" +. +.Sh DESCRIPTION +All dynamically allocated data structures +for this stream are freed. +This function discards any unprocessed input +and does not flush any pending output. +. +.Sh RETURN VALUES +.Fn deflateEnd +returns +.Dv Z_OK +if success, +.Dv Z_STREAM_ERROR +if the stream state was inconsistent, +.Dv Z_DATA_ERROR +if the stream was freed prematurely +(some input or output was discarded). +In the error case, +.Fa msg +may be set but then points to a static string +(which must not be deallocated). +. +.Sh SEE ALSO +.Xr deflate 3 , +.Xr deflateInit 3 diff --git a/deflateInit.3 b/deflateInit.3 index 7d7a5e2..477e05a 120000..100644 --- a/deflateInit.3 +++ b/deflateInit.3 @@ -1 +1,163 @@ -deflate.3 \ No newline at end of file +.Dd November 9, 2018 +.Dt DEFLATEINIT 3 +.Os +. +.Sh NAME +.Nm deflateInit +.Nd initialize deflate stream +. +.Sh LIBRARY +.Lb libz +. +.Sh SYNOPSIS +.In zlib.h +. +.Ft typedef voidpf +.Fo (*alloc_func) +.Fa "voidpf opaque" +.Fa "uInt items" +.Fa "uInt size" +.Fc +. +.Ft typedef void +.Fo (*free_func) +.Fa "voidpf opaque" +.Fa "voidpf address" +.Fc +. +.Bd -literal +typedef struct z_stream_s { + z_const Bytef *next_in; + uInt avail_in; + uLong total_in; + + Bytef *next_out; + uInt avail_out; + uLong total_out; + + z_const char *msg; + struct internal_state FAR *state; + + alloc_func zalloc; + free_func zfree; + voidpf opaque; + + int data_type; + uLong adler; + uLong reserved; +} z_stream; +.Ed +. +.Pp +.Vt typedef z_stream FAR *z_streamp; +. +.Ft int +.Fn deflateInit "z_streamp strm" "int level" +. +.Sh DESCRIPTION +Initializes the internal stream state for compression. +The fields +.Fa zalloc , +.Fa zfree +and +.Fa opaque +must be initialized before by the caller. +If +.Fa zalloc +and +.Fa zfree +are set to +.Dv Z_NULL , +.Fn deflateInit +updates them to use default allocation functions. +.Fn deflateInit +does not perform any compression: +this will be done by +.Xr deflate 3 . +. +.Pp +The compression +.Fa level +must be +.Dv Z_DEFAULT_COMPRESSION , +or between 0 and 9: +1 gives best speed, +9 gives best compression, +0 gives no compression at all +(the input data is simply copied a block at a time). +.Dv Z_DEFAULT_COMPRESSION +requests a default compromise between speed and compression +(currently equivalent to level 6). +. +.Pp +The fields of +.Vt z_stream +are as follows: +. +.Bl -tag -width "data_type" +.It Fa next_in +next input byte +.It Fa avail_in +number of bytes available at +.Fa next_in +.It Fa total_in +total number of input bytes read so far +.It Fa next_out +next output byte will go here +.It Fa avail_out +remaining free space at +.Fa next_out +.It Fa total_out +total number of bytes output so far +.It Fa msg +last error message, +.Dv NULL +if no error +.It Fa state +not visible by applications +.It Fa zalloc +used to allocate the internal state +.It Fa zfree +used to free the internal state +.It Fa opaque +private data object passed to +.Fa zalloc +and +.Fa zfree +.It data_type +best guess about the data type: +binary or text for +.Xr deflate 3 , +or the decoding state for +.Xr inflate 3 +.It adler +Adler-32 or CRC-32 value of the uncompressed data +.It reserved +reserved for future use +.El +. +.Sh RETURN VALUES +.Fn deflateInit +returns +.Dv Z_OK +if success, +.Dv Z_MEM_ERROR +if there was not enough memory, +.Dv Z_STREAM_ERROR +if +.Fa level +is not a valid compression level, +or +.Dv Z_VERSION_ERROR +if the zlib library version +.Pq Xr zlibVersion 3 +is incompatible with the version assumed by the caller +.Pq Dv ZLIB_VERSION . +.Fa msg +is set to null +if there is no error message. +. +.Sh SEE ALSO +.Xr deflate 3 , +.Xr deflateEnd 3 , +.Xr deflateInit2 3 |