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