Lzma2Dec.h 2.1 KB

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