zlib

package
v0.9.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

LLGo wrapper of madler/zlib

How to install

on macOS (Homebrew)
brew install zlib
on Linux (Debian/Ubuntu)
TODO

Demos

The _demo directory contains our demos (it start with _ to prevent the go command from compiling it):

How to run demos

To run the demos in directory _demo:

cd <demo-directory>  # eg. cd _demo/normal
llgo run .

Documentation

Index

Constants

View Source
const (
	OK            = 0
	STREAM_END    = 1
	NEED_DICT     = 2
	ERRNO         = -1
	STREAM_ERROR  = -2
	DATA_ERROR    = -3
	MEM_ERROR     = -4
	BUF_ERROR     = -5
	VERSION_ERROR = -6
)

errno

View Source
const (
	NO_COMPRESSION      = 0
	BEST_SPEED          = 1
	BEST_COMPRESSION    = 9
	DEFAULT_COMPRESSION = -1
)

compression levels

View Source
const (
	NO_FLUSH      = 0
	PARTIAL_FLUSH = 1
	SYNC_FLUSH    = 2
	FULL_FLUSH    = 3
	FINISH        = 4
	BLOCK         = 5
	TREES         = 6
)
View Source
const (
	FILTERED         = 1
	HUFFMAN_ONLY     = 2
	RLE              = 3
	FIXED            = 4
	DEFAULT_STRATEGY = 0
)
View Source
const (
	BINARY  = 0
	TEXT    = 1
	ASCII   = TEXT
	UNKNOWN = 2
)
View Source
const (
	DEFLATED = 8
)
View Source
const (
	LLGoPackage = "link: $(pkg-config --libs zlib); -lz"
)

Variables

This section is empty.

Functions

func Adler32 added in v0.9.4

func Adler32(adler c.Ulong, buf *byte, len c.Uint) c.Ulong

ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));

Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is Z_NULL, this function returns the required initial value for the checksum.

An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed much faster.

Usage example:

uLong adler = adler32(0L, Z_NULL, 0);

while (read_buffer(buffer, length) != EOF) {
adler = adler32(adler, buffer, length);
}
if (adler != original_adler) error();

func Adler32Combine added in v0.9.4

func Adler32Combine(adler1 c.Ulong, adler2 c.Ulong, len2 int64) c.Ulong

ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, z_off_t len2));

Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note that the z_off_t type (like off_t) is a signed integer. If len2 is negative, the result has no meaning or utility.

func Adler32Z added in v0.9.4

func Adler32Z(adler c.Ulong, buf *byte, len uintptr) c.Ulong

ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, z_size_t len));

Same as adler32(), but with a size_t length.

func Adler32ZBytes added in v0.9.4

func Adler32ZBytes(adler c.Ulong, buf []byte) c.Ulong

func Adler32ZString added in v0.9.4

func Adler32ZString(adler c.Ulong, buf string) c.Ulong

func Compress

func Compress(dest *byte, destLen *c.Ulong, source *byte, sourceLen c.Ulong) c.Int

ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,

const Bytef *source, uLong sourceLen));

Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed data. compress() is equivalent to compress2() with a level parameter of Z_DEFAULT_COMPRESSION.

compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer.

func Compress2

func Compress2(dest *byte, destLen *c.Ulong, source *byte, sourceLen c.Ulong, level c.Int) c.Int

ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,

const Bytef *source, uLong sourceLen, int level));

Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed data.

compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid.

func CompressBound

func CompressBound(sourceLen c.Ulong) c.Ulong

ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));

compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer.

func Crc32 added in v0.9.4

func Crc32(crc c.Ulong, buf *byte, len c.Uint) c.Ulong

ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));

Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is Z_NULL, this function returns the required initial value for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application.

Usage example:

uLong crc = crc32(0L, Z_NULL, 0);

while (read_buffer(buffer, length) != EOF) {
crc = crc32(crc, buffer, length);
}
if (crc != original_crc) error();

func Crc32Combine added in v0.9.4

func Crc32Combine(crc1 c.Ulong, crc2 c.Ulong, len2 int64) c.Ulong

ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));

Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and len2.

func Crc32Z added in v0.9.4

func Crc32Z(crc c.Ulong, buf *byte, len uintptr) c.Ulong

ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf, z_size_t len));

Same as crc32(), but with a size_t length.

func Crc32ZBytes added in v0.9.4

func Crc32ZBytes(crc c.Ulong, buf []byte) c.Ulong

func Crc32ZString added in v0.9.4

func Crc32ZString(crc c.Ulong, buf string) c.Ulong

func Uncompress

func Uncompress(dest *byte, destLen *c.Ulong, source *byte, sourceLen c.Ulong) c.Int

ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,

const Bytef *source, uLong sourceLen));

Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the uncompressed data.

uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In the case where there is not enough room, uncompress() will fill the output buffer with the uncompressed data up to that point.

func Uncompress2

func Uncompress2(dest *byte, destLen *c.Ulong, source *byte, sourceLen *c.Ulong) c.Int

ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen,

const Bytef *source, uLong *sourceLen));

Same as uncompress, except that sourceLen is a pointer, where the length of the source is *sourceLen. On return, *sourceLen is the number of source bytes consumed.

Types

This section is empty.

Directories

Path Synopsis
_demo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL