Lhasa
|
Raw LHA data decoder. More...
Typedefs | |
typedef struct _LHADecoderType | LHADecoderType |
Opaque type representing a type of decoder. More... | |
typedef struct _LHADecoder | LHADecoder |
Opaque type representing an instance of a decoder. More... | |
typedef size_t(* | LHADecoderCallback )(void *buf, size_t buf_len, void *user_data) |
Callback function invoked when a decoder wants to read more compressed data. More... | |
typedef void(* | LHADecoderProgressCallback )(unsigned int num_blocks, unsigned int total_blocks, void *callback_data) |
Callback function used for monitoring decode progress. More... | |
Functions | |
LHADecoderType * | lha_decoder_for_name (char *name) |
Get the decoder type for the specified name. More... | |
LHADecoder * | lha_decoder_new (LHADecoderType *dtype, LHADecoderCallback callback, void *callback_data, size_t stream_length) |
Allocate a new decoder for the specified type. More... | |
void | lha_decoder_free (LHADecoder *decoder) |
Free a decoder. More... | |
void | lha_decoder_monitor (LHADecoder *decoder, LHADecoderProgressCallback callback, void *callback_data) |
Set a callback function to monitor decode progress. More... | |
size_t | lha_decoder_read (LHADecoder *decoder, uint8_t *buf, size_t buf_len) |
Decode (decompress) more data. More... | |
uint16_t | lha_decoder_get_crc (LHADecoder *decoder) |
Get the current 16-bit CRC of the decompressed data. More... | |
size_t | lha_decoder_get_length (LHADecoder *decoder) |
Get the count of the number of bytes decoded. More... | |
Raw LHA data decoder.
This file defines the interface to the decompression code, which can be used to decompress the raw compressed data from an LZH file.
Implementations of the various compression algorithms used in LZH archives are provided - these are represented by the LHADecoderType structure, and can be retrieved using the lha_decoder_for_name function. One of these can then be passed to the lha_decoder_new function to create a LHADecoder structure and decompress the data.
typedef struct _LHADecoder LHADecoder |
Opaque type representing an instance of a decoder.
This is a decoder structure being used to decompress a stream of compressed data. Instantiated using the lha_decoder_new function and freed using the lha_decoder_free function.
typedef size_t(* LHADecoderCallback)(void *buf, size_t buf_len, void *user_data) |
Callback function invoked when a decoder wants to read more compressed data.
buf | Pointer to the buffer in which to store the data. |
buf_len | Size of the buffer, in bytes. |
user_data | Extra pointer to pass to the decoder. |
typedef void(* LHADecoderProgressCallback)(unsigned int num_blocks, unsigned int total_blocks, void *callback_data) |
Callback function used for monitoring decode progress.
The callback is invoked for every block processed (block size depends on decode algorithm).
num_blocks | Number of blocks processed so far. |
total_blocks | Total number of blocks to process. callback_data Extra user-specified data passed to the callback. |
typedef struct _LHADecoderType LHADecoderType |
Opaque type representing a type of decoder.
This is an implementation of the decompression code for one of the algorithms used in LZH archive files. Pointers to these structures are retrieved by using the lha_decoder_for_name function.
LHADecoderType* lha_decoder_for_name | ( | char * | name | ) |
Get the decoder type for the specified name.
name | String identifying the decoder type, for example, "-lh1-". |
void lha_decoder_free | ( | LHADecoder * | decoder | ) |
Free a decoder.
decoder | The decoder to free. |
uint16_t lha_decoder_get_crc | ( | LHADecoder * | decoder | ) |
Get the current 16-bit CRC of the decompressed data.
This should be called at the end of decompression to check that the data was extracted correctly, and the value compared against the CRC from the file header.
decoder | The decoder. |
size_t lha_decoder_get_length | ( | LHADecoder * | decoder | ) |
Get the count of the number of bytes decoded.
This should be called at the end of decompression, and the value compared against the file length from the file header.
decoder | The decoder. |
void lha_decoder_monitor | ( | LHADecoder * | decoder, |
LHADecoderProgressCallback | callback, | ||
void * | callback_data | ||
) |
Set a callback function to monitor decode progress.
decoder | The decoder. |
callback | Callback function to monitor decode progress. |
callback_data | Extra data to pass to the decoder. |
LHADecoder* lha_decoder_new | ( | LHADecoderType * | dtype, |
LHADecoderCallback | callback, | ||
void * | callback_data, | ||
size_t | stream_length | ||
) |
Allocate a new decoder for the specified type.
dtype | The decoder type. |
callback | Callback function for the decoder to call to read more compressed data. |
callback_data | Extra data to pass to the callback function. |
stream_length | Length of the uncompressed data, in bytes. When this point is reached, decompression will stop. |
size_t lha_decoder_read | ( | LHADecoder * | decoder, |
uint8_t * | buf, | ||
size_t | buf_len | ||
) |
Decode (decompress) more data.
decoder | The decoder. |
buf | Pointer to buffer to store decompressed data. |
buf_len | Size of the buffer, in bytes. |