ddn.compressor.zlib
ddn.compressor.zlib
A pure D implementation of the zlib compression library interface. This module provides a drop-in replacement for etc.c.zlib with identical API, implementing the DEFLATE compression algorithm (RFC 1951), zlib format (RFC 1950), and GZIP format (RFC 1952) entirely in D.
Features:
- Complete DEFLATE compression and decompression
- Support for raw DEFLATE, zlib, and GZIP container formats
- Dictionary support for improved compression
- Streaming API compatible with zlib's z_stream interface
- Adler-32 and CRC-32 checksum implementations
The implementation follows the zlib API conventions for maximum compatibility with existing code that uses etc.c.zlib.
Copyright
Module Initializers 1
()Types 5
Callback type for custom memory allocation
Callback type for custom memory deallocation
The z_stream structure is used to pass information between the application and the compression/decompression library functions.
This structure mirrors the zlib z_stream_s struct for API compatibility.
ubyte * next_inInput buffer pointeruint avail_inNumber of bytes available at next_inc_ulong total_inTotal number of input bytes read so farubyte * next_outOutput buffer pointeruint avail_outRemaining free space at next_outc_ulong total_outTotal number of bytes output so farconst(char) * msgLast error message, null if no errorvoid * internalInternal state (opaque to application)alloc_func zallocCustom allocator function (not used in pure D implementation)free_func zfreeCustom deallocator function (not used in pure D implementation)void * opaquePrivate data for custom allocatorint data_typeBest guess about the data type: Z_BINARY or Z_TEXTc_ulong adlerAdler-32 or CRC-32 checksum valuec_ulong reservedReserved for future usePointer to z_stream
C unsigned long type alias for cross-platform compatibility
Functions 22
c_ulong adler32(c_ulong adler, const(ubyte) * buf, uint len) nothrow @trustedCompute the Adler-32 checksum of a data buffer.c_ulong crc32(c_ulong crc, const(ubyte) * buf, uint len) nothrow @trustedCompute the CRC-32 checksum of a data buffer.int deflateInit2_(z_stream * strm, int level, int method, int windowBits, int memLevel, int strategy,
const(char) * ver, int streamSize) nothrowInitialize a deflate stream with full parameters.int deflateInit2(z_stream * strm, int level, int method, int windowBits, int memLevel, int strategy) nothrowSimplified deflate initialization.int deflateInit(z_stream * strm, int level) nothrowBasic deflate initialization with default parameters.int deflateSetDictionary(z_stream * strm, const(ubyte) * dictionary, uint dictLength) nothrowSet compression dictionary.int inflateInit2_(z_stream * strm, int windowBits, const(char) * ver, int streamSize) nothrowInitialize an inflate stream with full parameters.int inflateSetDictionary(z_stream * strm, const(ubyte) * dictionary, uint dictLength) nothrowSet decompression dictionary.int compress(ubyte * dest, c_ulong * destLen, const(ubyte) * source, c_ulong sourceLen) nothrowCompress source buffer to destination buffer.int compress2(ubyte * dest, c_ulong * destLen, const(ubyte) * source, c_ulong sourceLen, int level) nothrowCompress source buffer to destination buffer with specified level.int uncompress(ubyte * dest, c_ulong * destLen, const(ubyte) * source, c_ulong sourceLen) nothrowDecompress source buffer to destination buffer.Variables 32
ZLIB_VERSION = "1.3.1-ddn"zlib version string for compatibility
Z_NO_FLUSH = 0Flush modes for compression/decompression No flush, accumulate output
Z_PARTIAL_FLUSH = 1Partial flush (obsolete, use Z_SYNC_FLUSH)
Z_SYNC_FLUSH = 2Flush to byte boundary, sync point
Z_FULL_FLUSH = 3Flush and reset compression state
Z_FINISH = 4Finish the stream
Z_BLOCK = 5Stop at next block boundary
Z_TREES = 6Request deflate header/trees
Z_OK = 0Return codes Success
Z_STREAM_END = 1End of stream reached
Z_NEED_DICT = 2Dictionary required for decompression
Z_ERRNO = - 1File system error
Z_STREAM_ERROR = - 2Stream state error
Z_DATA_ERROR = - 3Data corrupted
Z_MEM_ERROR = - 4Memory allocation failed
Z_BUF_ERROR = - 5Buffer too small or no progress possible
Z_VERSION_ERROR = - 6zlib version mismatch
Z_NO_COMPRESSION = 0Compression levels Store only, no compression
Z_BEST_SPEED = 1Fastest compression
Z_BEST_COMPRESSION = 9Best compression ratio
Z_DEFAULT_COMPRESSION = - 1Default compression level (typically 6)
Z_DEFAULT_STRATEGY = 0Compression strategies Normal compression for general data
Z_FILTERED = 1Data with random distribution
Z_HUFFMAN_ONLY = 2Huffman coding only (no LZ77)
Z_RLE = 3Run-length encoding
Z_FIXED = 4Use fixed Huffman codes
Z_DEFLATED = 8Compression method The deflate compression method
MAX_WBITS = 15Window bits range Maximum window bits (32K window)
MAX_MEM_LEVEL = 9Memory level range Maximum memory level
SEEK_SET = 0Seek modes (for gzip)
SEEK_CUR = 1SEEK_END = 2