libdragon
Loading...
Searching...
No Matches
Macros | Functions
lzh5_internal.h File Reference

Go to the source code of this file.

Macros

#define DECOMPRESS_LZH5_STATE_SIZE   (6096+16)
 Size of the LZH5 decompression state.
 
#define DECOMPRESS_LZH5_DEFAULT_WINDOW_SIZE   (8192)
 Default window size for LZH5 decompression.
 

Functions

void decompress_lzh5_init (void *state, FILE *fp, int winsize)
 Initialize the LZH5 decompressor state.
 
ssize_t decompress_lzh5_read (void *state, void *buf, size_t len)
 Read decompressed data from the LZH5 stream.
 
int decompress_lzh5_pos (void *state)
 Get the current position in the decompressed stream.
 
void * decompress_lzh5_full (const char *fn, FILE *fp, size_t cmp_size, size_t size)
 Decompress a full LZH5 file into a buffer.
 

Detailed Description

Author
Giovanni Bajo giova.nosp@m.nnib.nosp@m.ajo@g.nosp@m.mail.nosp@m..com

Macro Definition Documentation

◆ DECOMPRESS_LZH5_STATE_SIZE

#define DECOMPRESS_LZH5_STATE_SIZE   (6096+16)

Size of the LZH5 decompression state.

Note that this can still be allocated on the stack, as the stack size configured by libdragon is 64KB.

Function Documentation

◆ decompress_lzh5_init()

void decompress_lzh5_init ( void *  state,
FILE *  fp,
int  winsize 
)

Initialize the LZH5 decompressor state.

Parameters
statePointer to the decompressor state buffer.
fpFILE pointer to read compressed data from.
winsizeWindow size for the decompressor.

◆ decompress_lzh5_read()

ssize_t decompress_lzh5_read ( void *  state,
void *  buf,
size_t  len 
)

Read decompressed data from the LZH5 stream.

Parameters
statePointer to the decompressor state buffer.
bufBuffer to store decompressed data.
lenNumber of bytes to read.
Returns
Number of bytes read, or -1 on error.

◆ decompress_lzh5_pos()

int decompress_lzh5_pos ( void *  state)

Get the current position in the decompressed stream.

Parameters
statePointer to the decompressor state buffer.
Returns
Current position in the decompressed stream.

◆ decompress_lzh5_full()

void * decompress_lzh5_full ( const char *  fn,
FILE *  fp,
size_t  cmp_size,
size_t  size 
)

Decompress a full LZH5 file into a buffer.

This function decompresses a full LZH5 file into a memory buffer. The caller should provide a buffer large enough to hold the entire file, or the function will fail.

This function is about 50% faster than using decompress_lzh5_read, as it can assume that the whole decoded file will always be available during decoding.

Parameters
fnFilename of the file being decompressed, if known
fpFile pointer to the compressed file
cmp_sizeLength of the compressed file
sizeLength of the file after decompression
Returns
Buffer that contains the decompressed file