2017-01-24 09:28:35 +00:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "ext_lzma.h"
|
|
|
|
|
2017-11-07 11:27:27 +00:00
|
|
|
void *hc_lzma_alloc (MAYBE_UNUSED ISzAllocPtr p, size_t size)
|
2017-01-24 09:28:35 +00:00
|
|
|
{
|
|
|
|
return hcmalloc (size);
|
|
|
|
}
|
|
|
|
|
2017-11-07 11:27:27 +00:00
|
|
|
void hc_lzma_free (MAYBE_UNUSED ISzAllocPtr p, void *address)
|
2017-01-24 09:28:35 +00:00
|
|
|
{
|
|
|
|
hcfree (address);
|
|
|
|
}
|
|
|
|
|
|
|
|
int hc_lzma1_decompress (const unsigned char *in, SizeT *in_len, unsigned char *out, SizeT *out_len, const char *props)
|
2017-11-07 11:27:27 +00:00
|
|
|
{
|
2017-01-24 09:28:35 +00:00
|
|
|
ISzAlloc hc_lzma_mem_alloc = {hc_lzma_alloc, hc_lzma_free};
|
|
|
|
|
|
|
|
ELzmaStatus status;
|
|
|
|
|
|
|
|
// parameters to LzmaDecode (): unsigned char *dest, size_t *destLen, const unsigned char *src,
|
|
|
|
// size_t *srcLen, const unsigned char *props, size_t propsSize, ELzmaFinishMode finishMode, ELzmaStatus status, ISzAlloc *alloc
|
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
return LzmaDecode (out, out_len, in, in_len, (const Byte *) props, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &hc_lzma_mem_alloc);
|
2017-01-24 09:28:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int hc_lzma2_decompress (const unsigned char *in, SizeT *in_len, unsigned char *out, SizeT *out_len, const char *props)
|
2017-11-07 11:27:27 +00:00
|
|
|
{
|
2017-01-24 09:28:35 +00:00
|
|
|
ISzAlloc hc_lzma_mem_alloc = {hc_lzma_alloc, hc_lzma_free};
|
|
|
|
|
|
|
|
ELzmaStatus status;
|
|
|
|
|
|
|
|
// parameters to Lzma2Decode (): unsigned char *dest, size_t *destLen, const unsigned char *src,
|
|
|
|
// size_t *srcLen, const unsigned char props, ELzmaFinishMode finishMode, ELzmaStatus status, ISzAlloc *alloc
|
|
|
|
|
|
|
|
return Lzma2Decode (out, out_len, in, in_len, (Byte) props[0], LZMA_FINISH_ANY, &status, &hc_lzma_mem_alloc);
|
|
|
|
}
|