00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __LZMADECODE_H
00023 #define __LZMADECODE_H
00024
00025 #define _LZMA_IN_CB
00026
00027
00028 #define _LZMA_OUT_READ
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef UInt32
00042 #ifdef _LZMA_UINT32_IS_ULONG
00043 #define UInt32 unsigned long
00044 #else
00045 #define UInt32 unsigned int
00046 #endif
00047 #endif
00048
00049 #ifndef SizeT
00050 #ifdef _LZMA_SYSTEM_SIZE_T
00051 #include <stddef.h>
00052 #define SizeT size_t
00053 #else
00054 #define SizeT UInt32
00055 #endif
00056 #endif
00057
00058 #ifdef _LZMA_PROB32
00059 #define CProb UInt32
00060 #else
00061 #define CProb unsigned short
00062 #endif
00063
00064 #define LZMA_RESULT_OK 0
00065 #define LZMA_RESULT_DATA_ERROR 1
00066
00067 #ifdef _LZMA_IN_CB
00068 typedef struct _ILzmaInCallback
00069 {
00070 int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
00071 } ILzmaInCallback;
00072 #endif
00073
00074 #define LZMA_BASE_SIZE 1846
00075 #define LZMA_LIT_SIZE 768
00076
00077 #define LZMA_PROPERTIES_SIZE 5
00078
00079 typedef struct _CLzmaProperties
00080 {
00081 int lc;
00082 int lp;
00083 int pb;
00084 #ifdef _LZMA_OUT_READ
00085 UInt32 DictionarySize;
00086 #endif
00087 }CLzmaProperties;
00088
00089 int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
00090
00091 #define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
00092
00093 #define kLzmaNeedInitId (-2)
00094
00095 typedef struct _CLzmaDecoderState
00096 {
00097 CLzmaProperties Properties;
00098 CProb *Probs;
00099
00100 #ifdef _LZMA_IN_CB
00101 const unsigned char *Buffer;
00102 const unsigned char *BufferLim;
00103 #endif
00104
00105 #ifdef _LZMA_OUT_READ
00106 unsigned char *Dictionary;
00107 UInt32 Range;
00108 UInt32 Code;
00109 UInt32 DictionaryPos;
00110 UInt32 GlobalPos;
00111 UInt32 DistanceLimit;
00112 UInt32 Reps[4];
00113 int State;
00114 int RemainLen;
00115 unsigned char TempDictionary[4];
00116 #endif
00117 } CLzmaDecoderState;
00118
00119 #ifdef _LZMA_OUT_READ
00120 #define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
00121 #endif
00122
00123 int LzmaDecode(CLzmaDecoderState *vs,
00124 #ifdef _LZMA_IN_CB
00125 ILzmaInCallback *inCallback,
00126 #else
00127 const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
00128 #endif
00129 unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
00130
00131 #endif