Squash
0.7.0
|
A compression/decompression codec. More...
Data Structures | |
struct | SquashCodec |
A compression/decompression codec. More... | |
Macros | |
#define | SQUASH_CODEC_INFO_INVALID ((SquashCodecInfo) 0) |
Invalid codec. | |
Typedefs | |
typedef void(* | SquashCodecForeachFunc) (SquashCodec *codec, void *data) |
Squashlback to be invoked on each SquashCodec in a set. More... | |
Enumerations | |
enum | SquashCodecInfo { SQUASH_CODEC_INFO_CAN_FLUSH = 1 << 0, SQUASH_CODEC_INFO_RUN_IN_THREAD = 1 << 1, SQUASH_CODEC_INFO_DECOMPRESS_SAFE = 1 << 2, SQUASH_CODEC_INFO_AUTO_MASK = 0x00ff0000, SQUASH_CODEC_INFO_VALID = 1 << 16, SQUASH_CODEC_INFO_KNOWS_UNCOMPRESSED_SIZE = 1 << 17, SQUASH_CODEC_INFO_NATIVE_STREAMING = 1 << 18, SQUASH_CODEC_INFO_MASK = 0xffffffff } |
Information about the codec. More... | |
Functions | |
const char * | squash_codec_get_name (SquashCodec *codec) |
Get the name of a SquashCodec. More... | |
unsigned int | squash_codec_get_priority (SquashCodec *codec) |
Get the priority of a SquashCodec. More... | |
SquashPlugin * | squash_codec_get_plugin (SquashCodec *codec) |
Get the plugin associated with a codec. More... | |
SquashStatus | squash_codec_init (SquashCodec *codec) |
Initialize a codec. More... | |
SquashCodecImpl * | squash_codec_get_impl (SquashCodec *codec) |
Get the codec's function table. More... | |
size_t | squash_codec_get_uncompressed_size (SquashCodec *codec, size_t compressed_length, const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)]) |
Get the uncompressed size of the compressed buffer. More... | |
size_t | squash_get_uncompressed_size (const char *codec, size_t compressed_length, const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)]) |
size_t | squash_codec_get_max_compressed_size (SquashCodec *codec, size_t uncompressed_length) |
Get the maximum buffer size necessary to store compressed data. More... | |
size_t | squash_get_max_compressed_size (const char *codec, size_t uncompressed_length) |
Get the maximum buffer size necessary to store compressed data. More... | |
SquashStream * | squash_codec_create_stream_with_options (SquashCodec *codec, SquashStreamType stream_type, SquashOptions *options) |
Create a new stream with existing SquashOptions. More... | |
SquashStream * | squash_codec_create_stream (SquashCodec *codec, SquashStreamType stream_type,...) |
Create a new stream with existing SquashOptions. More... | |
SquashStatus | squash_codec_compress_with_options (SquashCodec *codec, size_t *compressed_length, uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_length)], size_t uncompressed_length, const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)], SquashOptions *options) |
Compress a buffer with an existing SquashOptions. More... | |
SquashStatus | squash_codec_compress (SquashCodec *codec, size_t *compressed_length, uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_length)], size_t uncompressed_length, const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)],...) |
Compress a buffer. More... | |
SquashStatus | squash_codec_decompress_with_options (SquashCodec *codec, size_t *decompressed_length, uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], size_t compressed_length, const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)], SquashOptions *options) |
Decompress a buffer with an existing SquashOptions. More... | |
SquashStatus | squash_codec_decompress (SquashCodec *codec, size_t *decompressed_length, uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], size_t compressed_length, const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)],...) |
Decompress a buffer. More... | |
SquashStatus | squash_compress (const char *codec, size_t *compressed_length, uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_length)], size_t uncompressed_length, const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)],...) |
Compress a buffer. More... | |
SquashStatus | squash_compress_with_options (const char *codec, size_t *compressed_length, uint8_t compressed[SQUASH_ARRAY_PARAM(*compressed_length)], size_t uncompressed_length, const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)], SquashOptions *options) |
Compress a buffer with an existing SquashOptions. More... | |
SquashStatus | squash_decompress (const char *codec, size_t *decompressed_length, uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], size_t compressed_length, const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)],...) |
Decompress a buffer with an existing SquashOptions. More... | |
SquashStatus | squash_decompress_with_options (const char *codec, size_t *decompressed_length, uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], size_t compressed_length, const uint8_t compressed[SQUASH_ARRAY_PARAM(compressed_length)], SquashOptions *options) |
Decompress a buffer. More... | |
const char * | squash_codec_get_extension (SquashCodec *codec) |
Get the codec's extension. More... | |
SquashCodecInfo | squash_codec_get_info (SquashCodec *codec) |
Get a bitmask of information about the codec. More... | |
SquashCodecInfo | squash_get_info (const char *codec) |
Get a bitmask of information about the codec. More... | |
const SquashOptionInfo * | squash_codec_get_option_info (SquashCodec *codec) |
Get a list of options applicable to the codec. More... | |
const SquashOptionInfo * | squash_get_option_info (const char *codec) |
Get a list of options applicable to the codec. More... | |
const char * | squash_codec_get_option_string (SquashCodec *codec, SquashOptions *options, const char *key) |
Get the string value for an option. More... | |
const char * | squash_codec_get_option_string_index (SquashCodec *codec, SquashOptions *options, size_t index) |
Get the string value for an option by index. More... | |
bool | squash_codec_get_option_bool (SquashCodec *codec, SquashOptions *options, const char *key) |
Get the boolean value for an option. More... | |
bool | squash_codec_get_option_bool_index (SquashCodec *codec, SquashOptions *options, size_t index) |
Get the boolean value for an option by index. More... | |
int | squash_codec_get_option_int (SquashCodec *codec, SquashOptions *options, const char *key) |
Get the integer value for an option. More... | |
int | squash_codec_get_option_int_index (SquashCodec *codec, SquashOptions *options, size_t index) |
Get the integer value for an option by index. More... | |
size_t | squash_codec_get_option_size (SquashCodec *codec, SquashOptions *options, const char *key) |
Get the size value for an option. More... | |
size_t | squash_codec_get_option_size_index (SquashCodec *codec, SquashOptions *options, size_t index) |
Get the size value for an option by index. More... | |
A compression/decompression codec.
SquashCodecForeachFunc |
Squashlback to be invoked on each SquashCodec in a set.
codec | A codec |
data | User-supplied data |
enum SquashCodecInfo |
Information about the codec.
This is a bitmask describing characteristics and features of the codec.
SquashStatus squash_codec_compress | ( | SquashCodec * | codec, |
size_t * | compressed_length, | ||
uint8_t | compressed[SQUASH_ARRAY_PARAM(*compressed_length)], | ||
size_t | uncompressed_length, | ||
const uint8_t | uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)], | ||
... | |||
) |
Compress a buffer.
codec | The codec to use | |
[out] | compressed | Location to store the compressed data |
[in,out] | compressed_length | Location storing the size of the compressed buffer on input, replaced with the actual size of the compressed data |
uncompressed | The uncompressed data | |
uncompressed_length | Length of the uncompressed data (in bytes) | |
... | A variadic list of key/value option pairs, followed by NULL |
SquashStatus squash_codec_compress_with_options | ( | SquashCodec * | codec, |
size_t * | compressed_length, | ||
uint8_t | compressed[SQUASH_ARRAY_PARAM(*compressed_length)], | ||
size_t | uncompressed_length, | ||
const uint8_t | uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)], | ||
SquashOptions * | options | ||
) |
Compress a buffer with an existing SquashOptions.
codec | The codec to use | |
[out] | compressed | Location to store the compressed data |
[in,out] | compressed_length | Location storing the size of the compressed buffer on input, replaced with the actual size of the compressed data |
uncompressed | The uncompressed data | |
uncompressed_length | Length of the uncompressed data (in bytes) | |
options | Compression options |
SquashStream* squash_codec_create_stream | ( | SquashCodec * | codec, |
SquashStreamType | stream_type, | ||
... | |||
) |
Create a new stream with existing SquashOptions.
codec | The codec |
stream_type | The direction of the stream |
... | A variadic list of key/value option pairs, followed by NULL |
SquashStream* squash_codec_create_stream_with_options | ( | SquashCodec * | codec, |
SquashStreamType | stream_type, | ||
SquashOptions * | options | ||
) |
Create a new stream with existing SquashOptions.
codec | The codec |
stream_type | The direction of the stream |
options | The options for the stream, or NULL to use the defaults |
SquashStatus squash_codec_decompress | ( | SquashCodec * | codec, |
size_t * | decompressed_length, | ||
uint8_t | decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], | ||
size_t | compressed_length, | ||
const uint8_t | compressed[SQUASH_ARRAY_PARAM(compressed_length)], | ||
... | |||
) |
Decompress a buffer.
codec | The codec to use | |
[out] | decompressed | The decompressed data |
[in,out] | decompressed_length | Length of the decompressed data (in bytes) |
compressed | Location to store the compressed data | |
[in,out] | compressed_length | Location storing the size of the compressed buffer on input, replaced with the actual size of the compressed data |
... | A variadic list of key/value option pairs, followed by NULL |
SquashStatus squash_codec_decompress_with_options | ( | SquashCodec * | codec, |
size_t * | decompressed_length, | ||
uint8_t | decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], | ||
size_t | compressed_length, | ||
const uint8_t | compressed[SQUASH_ARRAY_PARAM(compressed_length)], | ||
SquashOptions * | options | ||
) |
Decompress a buffer with an existing SquashOptions.
codec | The codec to use | |
[out] | decompressed | Location to store the decompressed data |
[in,out] | decompressed_length | Location storing the size of the decompressed buffer on input, replaced with the actual size of the decompressed data |
compressed | The compressed data | |
compressed_length | Length of the compressed data (in bytes) | |
options | Compression options |
const char* squash_codec_get_extension | ( | SquashCodec * | codec | ) |
SquashCodecImpl* squash_codec_get_impl | ( | SquashCodec * | codec | ) |
SquashCodecInfo squash_codec_get_info | ( | SquashCodec * | codec | ) |
size_t squash_codec_get_max_compressed_size | ( | SquashCodec * | codec, |
size_t | uncompressed_length | ||
) |
Get the maximum buffer size necessary to store compressed data.
Typically the return value will be some percentage larger than the uncompressed length, plus a few bytes. For example, for bzip2 it is the uncompressed length plus 1%, plus an additional 600 bytes.
codec | The codec |
uncompressed_length | Size of the uncompressed data in bytes |
const char* squash_codec_get_name | ( | SquashCodec * | codec | ) |
bool squash_codec_get_option_bool | ( | SquashCodec * | codec, |
SquashOptions * | options, | ||
const char * | key | ||
) |
Get the boolean value for an option.
Note that this function will not perform a conversion—if you use it to request the value of an option which is not a boolean the result is undefined.
codec | the relevant codec |
options | the options instance to retrieve the value from |
key | the name of the option to retrieve the value of |
bool squash_codec_get_option_bool_index | ( | SquashCodec * | codec, |
SquashOptions * | options, | ||
size_t | index | ||
) |
Get the boolean value for an option by index.
Note that this function will not perform a conversion—if you use it to request the value of an option which is not a boolean the result is undefined.
codec | the relevant codec |
options | the options instance to retrieve the value from |
index | the index of the option to retrieve the value of |
const SquashOptionInfo* squash_codec_get_option_info | ( | SquashCodec * | codec | ) |
int squash_codec_get_option_int | ( | SquashCodec * | codec, |
SquashOptions * | options, | ||
const char * | key | ||
) |
Get the integer value for an option.
Note that this function will not perform a conversion—if you use it to request the value of an option which is not an integer the result is undefined.
codec | the relevant codec |
options | the options instance to retrieve the value from |
key | the name of the option to retrieve the value of |
int squash_codec_get_option_int_index | ( | SquashCodec * | codec, |
SquashOptions * | options, | ||
size_t | index | ||
) |
Get the integer value for an option by index.
Note that this function will not perform a conversion—if you use it to request the value of an option which is not an integer the result is undefined.
codec | the relevant codec |
options | the options instance to retrieve the value from |
index | the index of the option to retrieve the value of |
size_t squash_codec_get_option_size | ( | SquashCodec * | codec, |
SquashOptions * | options, | ||
const char * | key | ||
) |
Get the size value for an option.
Note that this function will not perform a conversion—if you use it to request the value of an option which is not a size the result is undefined.
codec | the relevant codec |
options | the options instance to retrieve the value from |
key | the name of the option to retrieve the value of |
size_t squash_codec_get_option_size_index | ( | SquashCodec * | codec, |
SquashOptions * | options, | ||
size_t | index | ||
) |
Get the size value for an option by index.
Note that this function will not perform a conversion—if you use it to request the value of an option which is not a size the result is undefined.
codec | the relevant codec |
options | the options instance to retrieve the value from |
index | the index of the option to retrieve the value of |
const char* squash_codec_get_option_string | ( | SquashCodec * | codec, |
SquashOptions * | options, | ||
const char * | key | ||
) |
Get the string value for an option.
Note that this function will not perform a conversion—if you use it to request the value of an option which is not a string the result is undefined.
codec | the relevant codec |
options | the options instance to retrieve the value from |
key | the name of the option to retrieve the value of |
const char* squash_codec_get_option_string_index | ( | SquashCodec * | codec, |
SquashOptions * | options, | ||
size_t | index | ||
) |
Get the string value for an option by index.
Note that this function will not perform a conversion—if you use it to request the value of an option which is not a string the result is undefined.
codec | the relevant codec |
options | the options instance to retrieve the value from |
index | the index of the option to retrieve the value of |
SquashPlugin* squash_codec_get_plugin | ( | SquashCodec * | codec | ) |
unsigned int squash_codec_get_priority | ( | SquashCodec * | codec | ) |
size_t squash_codec_get_uncompressed_size | ( | SquashCodec * | codec, |
size_t | compressed_length, | ||
const uint8_t | compressed[SQUASH_ARRAY_PARAM(compressed_length)] | ||
) |
Get the uncompressed size of the compressed buffer.
This function is only useful for codecs with the SQUASH_CODEC_INFO_KNOWS_UNCOMPRESSED_SIZE flag set. For situations where the codec does not know the uncompressed size, 0 will be returned.
codec | The codec |
compressed | The compressed data |
compressed_length | The length of the compressed data |
SquashStatus squash_codec_init | ( | SquashCodec * | codec | ) |
Initialize a codec.
codec | The codec. |
SQUASH_OK | Codec successfully initialized. |
SQUASH_UNABLE_TO_LOAD | Failed to load the codec. |
SquashStatus squash_compress | ( | const char * | codec, |
size_t * | compressed_length, | ||
uint8_t | compressed[SQUASH_ARRAY_PARAM(*compressed_length)], | ||
size_t | uncompressed_length, | ||
const uint8_t | uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)], | ||
... | |||
) |
Compress a buffer.
codec | The name of the codec to use | |
[out] | compressed | Location to store the compressed data |
[in,out] | compressed_length | Location storing the size of the compressed buffer on input, replaced with the actual size of the compressed data |
uncompressed | The uncompressed data | |
uncompressed_length | Length of the uncompressed data (in bytes) | |
... | A variadic list of key/value option pairs, followed by NULL |
SquashStatus squash_compress_with_options | ( | const char * | codec, |
size_t * | compressed_length, | ||
uint8_t | compressed[SQUASH_ARRAY_PARAM(*compressed_length)], | ||
size_t | uncompressed_length, | ||
const uint8_t | uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)], | ||
SquashOptions * | options | ||
) |
Compress a buffer with an existing SquashOptions.
codec | The name of the codec to use | |
[out] | compressed | Location to store the compressed data |
[in,out] | compressed_length | Location storing the size of the compressed buffer on input, replaced with the actual size of the compressed data |
uncompressed | The uncompressed data | |
uncompressed_length | Length of the uncompressed data (in bytes) | |
options | Compression options, or NULL to use the defaults |
SquashStatus squash_decompress | ( | const char * | codec, |
size_t * | decompressed_length, | ||
uint8_t | decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], | ||
size_t | compressed_length, | ||
const uint8_t | compressed[SQUASH_ARRAY_PARAM(compressed_length)], | ||
... | |||
) |
Decompress a buffer with an existing SquashOptions.
codec | The name of the codec to use | |
[out] | decompressed | Location to store the decompressed data |
[in,out] | decompressed_length | Location storing the size of the decompressed buffer on input, replaced with the actual size of the decompressed data |
compressed | The compressed data | |
compressed_length | Length of the compressed data (in bytes) | |
... | A variadic list of key/value option pairs, followed by NULL |
SquashStatus squash_decompress_with_options | ( | const char * | codec, |
size_t * | decompressed_length, | ||
uint8_t | decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)], | ||
size_t | compressed_length, | ||
const uint8_t | compressed[SQUASH_ARRAY_PARAM(compressed_length)], | ||
SquashOptions * | options | ||
) |
Decompress a buffer.
codec | The name of the codec to use | |
[out] | decompressed | Location to store the decompressed data |
[in,out] | decompressed_length | Location storing the size of the decompressed buffer on input, replaced with the actual size of the decompressed data |
compressed | The compressed data | |
compressed_length | Length of the compressed data (in bytes) | |
options | Decompression options, or NULL to use the defaults |
SquashCodecInfo squash_get_info | ( | const char * | codec | ) |
Get a bitmask of information about the codec.
codec | The codec |
size_t squash_get_max_compressed_size | ( | const char * | codec, |
size_t | uncompressed_length | ||
) |
Get the maximum buffer size necessary to store compressed data.
Typically the return value will be some percentage larger than the uncompressed length, plus a few bytes. For example, for bzip2 it is the uncompressed length plus 1%, plus an additional 600 bytes.
codec | The name of the codec |
uncompressed_length | Size of the uncompressed data in bytes |