2015-03-17 00:50:30 -07:00
|
|
|
#ifndef EMILE_COMPRESSION_H_
|
|
|
|
#define EMILE_COMPRESSION_H_
|
|
|
|
|
2015-03-17 00:50:33 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Emile_Group_Compression Non destructive general purpose compression functions.
|
|
|
|
* @ingroup Emile
|
|
|
|
* Function that allow the compression and expansion of Eina_Binbuf with
|
|
|
|
* non destructive algorithm.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Supported type of compression algorithm.
|
2015-03-17 00:50:40 -07:00
|
|
|
* @since 1.14
|
2015-03-17 00:50:33 -07:00
|
|
|
*
|
|
|
|
* @see emile_binbuf_compress()
|
|
|
|
* @see emile_binbuf_uncompress()
|
|
|
|
* @see emile_binbuf_expand()
|
|
|
|
*/
|
2015-03-17 00:50:30 -07:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
EMILE_ZLIB,
|
|
|
|
EMILE_LZ4,
|
|
|
|
EMILE_LZ4HC
|
|
|
|
} Emile_Compressor_Type;
|
|
|
|
|
2015-03-17 00:50:33 -07:00
|
|
|
/**
|
|
|
|
* Compression level to apply.
|
2015-03-17 00:50:40 -07:00
|
|
|
* @since 1.14
|
2015-03-17 00:50:33 -07:00
|
|
|
*
|
|
|
|
* @see emile_binbuf_compress();
|
|
|
|
*/
|
2015-03-17 00:50:30 -07:00
|
|
|
typedef enum
|
|
|
|
{
|
2015-03-17 00:50:42 -07:00
|
|
|
EMILE_COMPRESSOR_DEFAULT = -1,
|
|
|
|
EMILE_COMPRESSOR_NONE = 0,
|
|
|
|
EMILE_COMPRESSOR_FAST = 1,
|
|
|
|
EMILE_COMPRESSOR_BEST = 9
|
2015-03-17 00:50:30 -07:00
|
|
|
} Emile_Compressor_Level;
|
|
|
|
|
2015-03-17 00:50:33 -07:00
|
|
|
/**
|
|
|
|
* @brief Compress an Eina_Binbuf into a new Eina_Binbuf
|
|
|
|
*
|
|
|
|
* @param in Buffer to compress.
|
|
|
|
* @param t Type of compression logic to use.
|
|
|
|
* @param level Level of compression to apply.
|
|
|
|
*
|
|
|
|
* @return On success it will return a buffer that contains
|
|
|
|
* the compressed data, @c NULL otherwise.
|
|
|
|
*
|
2015-03-17 00:50:40 -07:00
|
|
|
* @since 1.14
|
2015-03-17 00:50:33 -07:00
|
|
|
*/
|
2015-03-17 00:51:01 -07:00
|
|
|
EAPI Eina_Binbuf *emile_compress(const Eina_Binbuf * in, Emile_Compressor_Type t, Emile_Compressor_Level level);
|
2015-03-17 00:50:33 -07:00
|
|
|
/**
|
|
|
|
* @brief Uncompress a buffer into a newly allocated buffer.
|
|
|
|
*
|
|
|
|
* @param in Buffer to uncompress.
|
|
|
|
* @param t Type of compression logic to use.
|
|
|
|
* @param dest_length Expected length of the decompressed data.
|
|
|
|
*
|
|
|
|
* @return a newly allocated buffer with the uncompressed data,
|
|
|
|
* @c NULL if it failed.
|
|
|
|
*
|
2015-03-17 00:50:40 -07:00
|
|
|
* @since 1.14
|
2015-03-17 00:50:33 -07:00
|
|
|
*
|
|
|
|
* @note That if dest_length doesn't match the expanded data, it will
|
|
|
|
* just fail and return @c NULL.
|
|
|
|
*/
|
2015-03-17 00:51:01 -07:00
|
|
|
EAPI Eina_Binbuf *emile_decompress(const Eina_Binbuf * in, Emile_Compressor_Type t, unsigned int dest_length);
|
2015-03-17 00:50:33 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Uncompress a buffer into an existing buffer.
|
|
|
|
*
|
|
|
|
* @param in Buffer to uncompress.
|
|
|
|
* @param out Buffer to expand data into.
|
|
|
|
* @param t Type of compression logic to use.
|
|
|
|
*
|
|
|
|
* @return EINA_TRUE if it succeed, EINA_FALSE if it failed.
|
2015-03-17 00:50:40 -07:00
|
|
|
* @since 1.14
|
2015-03-17 00:50:33 -07:00
|
|
|
*
|
|
|
|
* @note The out buffer should have the necessary size to hold the
|
|
|
|
* expanded data or it will fail. In case of failure, random garbage
|
|
|
|
* could fill the out buffer.
|
|
|
|
*/
|
2015-03-17 00:51:01 -07:00
|
|
|
EAPI Eina_Bool emile_expand(const Eina_Binbuf * in, Eina_Binbuf * out, Emile_Compressor_Type t);
|
2015-03-17 00:50:33 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2015-03-17 00:50:30 -07:00
|
|
|
#endif
|