aboutsummaryrefslogtreecommitdiff
path: root/C/Lzma86Dec.c
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2021-12-27 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2022-03-18 15:35:13 +0500
commitf19f813537c7aea1c20749c914e756b54a9c3cf5 (patch)
tree816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /C/Lzma86Dec.c
parent98e06a519b63b81986abe76d28887f6984a7732b (diff)
download7zip-21.07.tar.gz
7zip-21.07.tar.bz2
7zip-21.07.zip
'21.07'21.07
Diffstat (limited to '')
-rw-r--r--C/Lzma86Dec.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/C/Lzma86Dec.c b/C/Lzma86Dec.c
new file mode 100644
index 0000000..2103174
--- /dev/null
+++ b/C/Lzma86Dec.c
@@ -0,0 +1,54 @@
1/* Lzma86Dec.c -- LZMA + x86 (BCJ) Filter Decoder
22016-05-16 : Igor Pavlov : Public domain */
3
4#include "Precomp.h"
5
6#include "Lzma86.h"
7
8#include "Alloc.h"
9#include "Bra.h"
10#include "LzmaDec.h"
11
12SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize)
13{
14 unsigned i;
15 if (srcLen < LZMA86_HEADER_SIZE)
16 return SZ_ERROR_INPUT_EOF;
17 *unpackSize = 0;
18 for (i = 0; i < sizeof(UInt64); i++)
19 *unpackSize += ((UInt64)src[LZMA86_SIZE_OFFSET + i]) << (8 * i);
20 return SZ_OK;
21}
22
23SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
24{
25 SRes res;
26 int useFilter;
27 SizeT inSizePure;
28 ELzmaStatus status;
29
30 if (*srcLen < LZMA86_HEADER_SIZE)
31 return SZ_ERROR_INPUT_EOF;
32
33 useFilter = src[0];
34
35 if (useFilter > 1)
36 {
37 *destLen = 0;
38 return SZ_ERROR_UNSUPPORTED;
39 }
40
41 inSizePure = *srcLen - LZMA86_HEADER_SIZE;
42 res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure,
43 src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc);
44 *srcLen = inSizePure + LZMA86_HEADER_SIZE;
45 if (res != SZ_OK)
46 return res;
47 if (useFilter == 1)
48 {
49 UInt32 x86State;
50 x86_Convert_Init(x86State);
51 x86_Convert(dest, *destLen, 0, &x86State, 0);
52 }
53 return SZ_OK;
54}