X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/17c7b6c3fdc48301e50d22cc6138ede16bd1be24..ab75a04099826e4f96c1a9323b2bee3ebb336854:/target/linux/adm5120/image/lzma-loader/src/LzmaDecode.h?ds=sidebyside diff --git a/target/linux/adm5120/image/lzma-loader/src/LzmaDecode.h b/target/linux/adm5120/image/lzma-loader/src/LzmaDecode.h index 53677350a..2870eeb9c 100644 --- a/target/linux/adm5120/image/lzma-loader/src/LzmaDecode.h +++ b/target/linux/adm5120/image/lzma-loader/src/LzmaDecode.h @@ -2,7 +2,7 @@ LzmaDecode.h LZMA Decoder interface - LZMA SDK 4.16 Copyright (c) 1999-2005 Igor Pavlov (2005-03-18) + LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) http://www.7-zip.org/ LZMA SDK is licensed under two licenses: @@ -22,6 +22,8 @@ #ifndef __LZMADECODE_H #define __LZMADECODE_H +#include "LzmaTypes.h" + /* #define _LZMA_IN_CB */ /* Use callback for input data */ @@ -35,66 +37,77 @@ /* #define _LZMA_LOC_OPT */ /* Enable local speed optimizations inside code */ -#ifndef UInt32 -#ifdef _LZMA_UINT32_IS_ULONG -#define UInt32 unsigned long -#else -#define UInt32 unsigned int -#endif -#endif - #ifdef _LZMA_PROB32 #define CProb UInt32 #else -#define CProb unsigned short +#define CProb UInt16 #endif #define LZMA_RESULT_OK 0 #define LZMA_RESULT_DATA_ERROR 1 -#define LZMA_RESULT_NOT_ENOUGH_MEM 2 #ifdef _LZMA_IN_CB typedef struct _ILzmaInCallback { - int (*Read)(void *object, unsigned char **buffer, UInt32 *bufferSize); + int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize); } ILzmaInCallback; #endif #define LZMA_BASE_SIZE 1846 #define LZMA_LIT_SIZE 768 -/* -bufferSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)))* sizeof(CProb) -bufferSize += 100 in case of _LZMA_OUT_READ -by default CProb is unsigned short, -but if specify _LZMA_PROB_32, CProb will be UInt32(unsigned int) -*/ +#define LZMA_PROPERTIES_SIZE 5 -#ifdef _LZMA_OUT_READ -int LzmaDecoderInit( - unsigned char *buffer, UInt32 bufferSize, - int lc, int lp, int pb, - unsigned char *dictionary, UInt32 dictionarySize, - #ifdef _LZMA_IN_CB - ILzmaInCallback *inCallback - #else - unsigned char *inStream, UInt32 inSize +typedef struct _CLzmaProperties +{ + int lc; + int lp; + int pb; + #ifdef _LZMA_OUT_READ + UInt32 DictionarySize; #endif -); -#endif +}CLzmaProperties; + +int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size); + +#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp))) + +#define kLzmaNeedInitId (-2) + +typedef struct _CLzmaDecoderState +{ + CLzmaProperties Properties; + CProb *Probs; -int LzmaDecode( - unsigned char *buffer, - #ifndef _LZMA_OUT_READ - UInt32 bufferSize, - int lc, int lp, int pb, #ifdef _LZMA_IN_CB - ILzmaInCallback *inCallback, - #else - unsigned char *inStream, UInt32 inSize, + const unsigned char *Buffer; + const unsigned char *BufferLim; #endif + + #ifdef _LZMA_OUT_READ + unsigned char *Dictionary; + UInt32 Range; + UInt32 Code; + UInt32 DictionaryPos; + UInt32 GlobalPos; + UInt32 DistanceLimit; + UInt32 Reps[4]; + int State; + int RemainLen; + unsigned char TempDictionary[4]; #endif - unsigned char *outStream, UInt32 outSize, - UInt32 *outSizeProcessed); +} CLzmaDecoderState; + +#ifdef _LZMA_OUT_READ +#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; } +#endif + +int LzmaDecode(CLzmaDecoderState *vs, + #ifdef _LZMA_IN_CB + ILzmaInCallback *inCallback, + #else + const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, + #endif + unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed); #endif