decompress.h File Reference

Decompression functions. More...

`#include <stdbool.h>`
`#include <stdint.h>`
`#include <sys/types.h>`

Go to the source code of this file.

## Data Structures

struct | decompressIOVec
| I/O vector. More...

## Typedefs

typedef ssize_t(* | decompressCallback) (void *userdata, void *buffer, size_t size)
| Data callback.

## Enumerations

enum | decompressType { DECOMPRESS_DUMMY = 0x00 , DECOMPRESS_LZSS = 0x10 , DECOMPRESS_LZ10 = 0x10 , DECOMPRESS_LZ11 = 0x11 , DECOMPRESS_HUFF1 = 0x21 , DECOMPRESS_HUFF2 = 0x22 , DECOMPRESS_HUFF3 = 0x23 , DECOMPRESS_HUFF4 = 0x24 , DECOMPRESS_HUFF5 = 0x25 , DECOMPRESS_HUFF6 = 0x26 , DECOMPRESS_HUFF7 = 0x27 , DECOMPRESS_HUFF8 = 0x28 , DECOMPRESS_HUFF = 0x28 , DECOMPRESS_RLE = 0x30 }
| Compression types. More...

## Functions

ssize_t | decompressCallback_FD (void *userdata, void *buffer, size_t size)
| Decompression callback for file descriptors. More...
ssize_t | decompressCallback_Stdio (void *userdata, void *buffer, size_t size)
| Decompression callback for stdio FILE*. More...
ssize_t | decompressHeader (decompressType *type, size_t *size, decompressCallback callback, void *userdata, size_t insize)
| Decode decompression header. More...
bool | decompressV (const decompressIOVec *iov, size_t iovcnt, decompressCallback callback, void *userdata, size_t insize)
| Decompress data. More...
static bool | decompress (void *output, size_t size, decompressCallback callback, void *userdata, size_t insize)
| Decompress data. More...
bool | decompressV_LZSS (const decompressIOVec *iov, size_t iovcnt, decompressCallback callback, void *userdata, size_t insize)
| Decompress LZSS/LZ10. More...
static bool | decompress_LZSS (void *output, size_t size, decompressCallback callback, void *userdata, size_t insize)
| Decompress LZSS/LZ10. More...
bool | decompressV_LZ11 (const decompressIOVec *iov, size_t iovcnt, decompressCallback callback, void *userdata, size_t insize)
| Decompress LZ11. More...
static bool | decompress_LZ11 (void *output, size_t size, decompressCallback callback, void *userdata, size_t insize)
| Decompress LZ11. More...
bool | decompressV_Huff (size_t bits, const decompressIOVec *iov, size_t iovcnt, decompressCallback callback, void *userdata, size_t insize)
| Decompress Huffman. More...
static bool | decompress_Huff (size_t bits, void *output, size_t size, decompressCallback callback, void *userdata, size_t insize)
| Decompress Huffman. More...
bool | decompressV_RLE (const decompressIOVec *iov, size_t iovcnt, decompressCallback callback, void *userdata, size_t insize)
| Decompress run-length encoding. More...
static bool | decompress_RLE (void *output, size_t size, decompressCallback callback, void *userdata, size_t insize)
| Decompress run-length encoding. More...

## Detailed Description

Decompression functions.

## Enumeration Type Documentation

## decompressType

enum decompressType

Compression types.

Enumerator
DECOMPRESS_DUMMY | Dummy compression.
DECOMPRESS_LZSS | LZSS/LZ10 compression.
DECOMPRESS_LZ10 | LZSS/LZ10 compression.
DECOMPRESS_LZ11 | LZ11 compression.
DECOMPRESS_HUFF1 | Huffman compression with 1-bit data.
DECOMPRESS_HUFF2 | Huffman compression with 2-bit data.
DECOMPRESS_HUFF3 | Huffman compression with 3-bit data.
DECOMPRESS_HUFF4 | Huffman compression with 4-bit data.
DECOMPRESS_HUFF5 | Huffman compression with 5-bit data.
DECOMPRESS_HUFF6 | Huffman compression with 6-bit data.
DECOMPRESS_HUFF7 | Huffman compression with 7-bit data.
DECOMPRESS_HUFF8 | Huffman compression with 8-bit data.
DECOMPRESS_HUFF | Huffman compression with 8-bit data.
DECOMPRESS_RLE | Run-length encoding compression.

## Function Documentation

## decompress()

static bool decompress | ( | void * | output,
|  | size_t | size,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

inlinestatic

Decompress data.

Parameters

  [in] | output | Output buffer
  [in] | size | Output size limit
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded

## decompress_Huff()

static bool decompress_Huff | ( | size_t | bits,
|  | void * | output,
|  | size_t | size,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

inlinestatic

Decompress Huffman.

Parameters

  [in] | bits | Data size in bits (usually 4 or 8)
  [in] | output | Output buffer
  [in] | size | Output size limit
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded

## decompress_LZ11()

static bool decompress_LZ11 | ( | void * | output,
|  | size_t | size,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

inlinestatic

Decompress LZ11.

Parameters

  [in] | output | Output buffer
  [in] | size | Output size limit
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded

## decompress_LZSS()

static bool decompress_LZSS | ( | void * | output,
|  | size_t | size,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

inlinestatic

Decompress LZSS/LZ10.

Parameters

  [in] | output | Output buffer
  [in] | size | Output size limit
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded

## decompress_RLE()

static bool decompress_RLE | ( | void * | output,
|  | size_t | size,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

inlinestatic

Decompress run-length encoding.

Parameters

  [in] | output | Output buffer
  [in] | size | Output size limit
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded

## decompressCallback_FD()

ssize_t decompressCallback_FD | ( | void * | userdata,
|  | void * | buffer,
|  | size_t | size
| ) |  |

Decompression callback for file descriptors.

Parameters

  [in] | userdata | Address of file descriptor
  [in] | buffer | Buffer to write into
  [in] | size | Size to read from file descriptor

Returns
  Number of bytes read

## decompressCallback_Stdio()

ssize_t decompressCallback_Stdio | ( | void * | userdata,
|  | void * | buffer,
|  | size_t | size
| ) |  |

Decompression callback for stdio FILE*.

Parameters

  [in] | userdata | FILE*
  [in] | buffer | Buffer to write into
  [in] | size | Size to read from file descriptor

Returns
  Number of bytes read

## decompressHeader()

ssize_t decompressHeader | ( | decompressType * | type,
|  | size_t * | size,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

Decode decompression header.

Parameters

  [out] | type | Decompression type
  [out] | size | Decompressed size
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Bytes consumed

Return values

  -1 | error

## decompressV()

bool decompressV | ( | const decompressIOVec * | iov,
|  | size_t | iovcnt,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

Decompress data.

Parameters

  [in] | iov | Output vector
  [in] | iovcnt | Number of buffers
  [in] | callback | Data callback (see note)
  [in] | userdata | User data passed to callback (see note)
  [in] | insize | Size of userdata (see note)

Returns
  Whether succeeded

Note
  If callback is null, userdata is a pointer to memory to read from, and insize is the size of that data. If callback is not null, userdata is passed to callback to fetch more data, and insize is unused.

## decompressV_Huff()

bool decompressV_Huff | ( | size_t | bits,
|  | const decompressIOVec * | iov,
|  | size_t | iovcnt,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

Decompress Huffman.

Parameters

  [in] | bits | Data size in bits (usually 4 or 8)
  [in] | iov | Output vector
  [in] | iovcnt | Number of buffers
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded

## decompressV_LZ11()

bool decompressV_LZ11 | ( | const decompressIOVec * | iov,
|  | size_t | iovcnt,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

Decompress LZ11.

Parameters

  [in] | iov | Output vector
  [in] | iovcnt | Number of buffers
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded

## decompressV_LZSS()

bool decompressV_LZSS | ( | const decompressIOVec * | iov,
|  | size_t | iovcnt,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

Decompress LZSS/LZ10.

Parameters

  [in] | iov | Output vector
  [in] | iovcnt | Number of buffers
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded

## decompressV_RLE()

bool decompressV_RLE | ( | const decompressIOVec * | iov,
|  | size_t | iovcnt,
|  | decompressCallback | callback,
|  | void * | userdata,
|  | size_t | insize
| ) |  |

Decompress run-length encoding.

Parameters

  [in] | iov | Output vector
  [in] | iovcnt | Number of buffers
  [in] | callback | Data callback (see decompressV())
  [in] | userdata | User data passed to callback (see decompressV())
  [in] | insize | Size of userdata (see decompressV())

Returns
  Whether succeeded