User:Monster Iestyn/Source Code Documentation/lzf.h

From SRB2 Wiki
Jump to navigation Jump to search
Online link GitHub entry
File type C header file
#include guard LZF_H

This header file contains the function prototypes for the LZF compression/decompression routines.

Includes

Macros

Macro Defined as Description
LZF_VERSION 0x0105 LZF API version number, represented by a hexadecimal integer. The first two digits indicate the major version number, and the last two digits indicate the minor version number.

This value overall indicates the API version is 1.5

Function prototypes

Function name Return type Params Defined in Description
lzf_compress size_t const void *const in_data,
size_t in_len,
void *out_data,
size_t out_len
lzf.c Compress in_len bytes stored at the memory block starting at in_data and write the result to out_data, up to a maximum length of out_len bytes.

If the output buffer is not large enough or any error occurs return 0, otherwise return the number of bytes used, to ensure some compression, and store the data uncompressed otherwise.

lzf_decompress size_t const void *const in_data,
size_t in_len,
void *out_data,
size_t out_len
lzf.c Decompress data compressed with some version of the lzf_compress function and stored at location in_data and length in_len. The result will be stored at out_data up to a maximum of out_len characters.

If the output buffer is not large enough to hold the decompressed data, a 0 is returned and errno is set to E2BIG (Argument list too long). Otherwise the number of decompressed bytes (i.e. the original length of the data) is returned.

If an error in the compressed data is detected, a 0 is returned and errno is set to EINVAL (Invalid argument).