rpmio/LzmaDecode.h

Go to the documentation of this file.
00001 /* 
00002   LzmaDecode.h
00003   LZMA Decoder interface
00004 
00005   LZMA SDK 4.21 Copyright (c) 1999-2005 Igor Pavlov (2005-06-08)
00006   http://www.7-zip.org/
00007 
00008   LZMA SDK is licensed under two licenses:
00009   1) GNU Lesser General Public License (GNU LGPL)
00010   2) Common Public License (CPL)
00011   It means that you can select one of these two licenses and 
00012   follow rules of that license.
00013 
00014   SPECIAL EXCEPTION:
00015   Igor Pavlov, as the author of this code, expressly permits you to 
00016   statically or dynamically link your code (or bind by name) to the 
00017   interfaces of this file without subjecting your linked code to the 
00018   terms of the CPL or GNU LGPL. Any modifications or additions 
00019   to this file, however, are subject to the LGPL or CPL terms.
00020 */
00021 
00022 #ifndef __LZMADECODE_H
00023 #define __LZMADECODE_H
00024 
00025 #define _LZMA_IN_CB
00026 /* Use callback for input data */
00027 
00028 #define _LZMA_OUT_READ
00029 /* Use read function for output data */
00030 
00031 /* #define _LZMA_PROB32 */
00032 /* It can increase speed on some 32-bit CPUs, 
00033    but memory usage will be doubled in that case */
00034 
00035 /* #define _LZMA_LOC_OPT */
00036 /* Enable local speed optimizations inside code */
00037 
00038 /* #define _LZMA_SYSTEM_SIZE_T */
00039 /* Use system's size_t. You can use it to enable 64-bit sizes supporting*/
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

Generated on Tue Feb 19 23:28:19 2008 for rpm by  doxygen 1.5.1