1/* Lzma2Dec.h -- LZMA2 Decoder
22013-01-18 : Igor Pavlov : Public domain */
3
4#ifndef __LZMA2_DEC_H
5#define __LZMA2_DEC_H
6
7#include "LzmaDec.h"
8
9EXTERN_C_BEGIN
10
11/* ---------- State Interface ---------- */
12
13typedef struct
14{
15  CLzmaDec decoder;
16  UInt32 packSize;
17  UInt32 unpackSize;
18  int state;
19  Byte control;
20  Bool needInitDic;
21  Bool needInitState;
22  Bool needInitProp;
23} CLzma2Dec;
24
25#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder)
26#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc);
27#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc);
28
29SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc);
30SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc);
31void Lzma2Dec_Init(CLzma2Dec *p);
32
33
34/*
35finishMode:
36  It has meaning only if the decoding reaches output limit (*destLen or dicLimit).
37  LZMA_FINISH_ANY - use smallest number of input bytes
38  LZMA_FINISH_END - read EndOfStream marker after decoding
39
40Returns:
41  SZ_OK
42    status:
43      LZMA_STATUS_FINISHED_WITH_MARK
44      LZMA_STATUS_NOT_FINISHED
45      LZMA_STATUS_NEEDS_MORE_INPUT
46  SZ_ERROR_DATA - Data error
47*/
48
49SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
50    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
51
52SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen,
53    const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
54
55
56/* ---------- One Call Interface ---------- */
57
58/*
59finishMode:
60  It has meaning only if the decoding reaches output limit (*destLen).
61  LZMA_FINISH_ANY - use smallest number of input bytes
62  LZMA_FINISH_END - read EndOfStream marker after decoding
63
64Returns:
65  SZ_OK
66    status:
67      LZMA_STATUS_FINISHED_WITH_MARK
68      LZMA_STATUS_NOT_FINISHED
69  SZ_ERROR_DATA - Data error
70  SZ_ERROR_MEM  - Memory allocation error
71  SZ_ERROR_UNSUPPORTED - Unsupported properties
72  SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
73*/
74
75SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
76    Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc);
77
78EXTERN_C_END
79
80#endif
81