| 1 | cycrow | 1 | /* 
 | 
        
           |  |  | 2 |   LzmaDecode.h
 | 
        
           |  |  | 3 |   LZMA Decoder interface
 | 
        
           |  |  | 4 |   | 
        
           |  |  | 5 |   LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
 | 
        
           |  |  | 6 |   http://www.7-zip.org/
 | 
        
           |  |  | 7 |   | 
        
           |  |  | 8 |   LZMA SDK is licensed under two licenses:
 | 
        
           |  |  | 9 |   1) GNU Lesser General Public License (GNU LGPL)
 | 
        
           |  |  | 10 |   2) Common Public License (CPL)
 | 
        
           |  |  | 11 |   It means that you can select one of these two licenses and 
 | 
        
           |  |  | 12 |   follow rules of that license.
 | 
        
           |  |  | 13 |   | 
        
           |  |  | 14 |   SPECIAL EXCEPTION:
 | 
        
           |  |  | 15 |   Igor Pavlov, as the author of this code, expressly permits you to 
 | 
        
           |  |  | 16 |   statically or dynamically link your code (or bind by name) to the 
 | 
        
           |  |  | 17 |   interfaces of this file without subjecting your linked code to the 
 | 
        
           |  |  | 18 |   terms of the CPL or GNU LGPL. Any modifications or additions 
 | 
        
           |  |  | 19 |   to this file, however, are subject to the LGPL or CPL terms.
 | 
        
           |  |  | 20 | */
 | 
        
           |  |  | 21 |   | 
        
           |  |  | 22 | #ifndef __LZMADECODE_H
 | 
        
           |  |  | 23 | #define __LZMADECODE_H
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 | #include "LzmaTypes.h"
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 | /* #define _LZMA_IN_CB */
 | 
        
           |  |  | 28 | /* Use callback for input data */
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 | /* #define _LZMA_OUT_READ */
 | 
        
           |  |  | 31 | /* Use read function for output data */
 | 
        
           |  |  | 32 |   | 
        
           |  |  | 33 | /* #define _LZMA_PROB32 */
 | 
        
           |  |  | 34 | /* It can increase speed on some 32-bit CPUs, 
 | 
        
           |  |  | 35 |    but memory usage will be doubled in that case */
 | 
        
           |  |  | 36 |   | 
        
           |  |  | 37 | /* #define _LZMA_LOC_OPT */
 | 
        
           |  |  | 38 | /* Enable local speed optimizations inside code */
 | 
        
           |  |  | 39 |   | 
        
           |  |  | 40 | #include <string.h>
 | 
        
           |  |  | 41 | #include <stdio.h>
 | 
        
           |  |  | 42 | #include <stdlib.h>
 | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 | #ifdef _LZMA_PROB32
 | 
        
           |  |  | 45 | #define CProb UInt32
 | 
        
           |  |  | 46 | #else
 | 
        
           |  |  | 47 | #define CProb UInt16
 | 
        
           |  |  | 48 | #endif
 | 
        
           |  |  | 49 |   | 
        
           |  |  | 50 | #define LZMA_RESULT_OK 0
 | 
        
           |  |  | 51 | #define LZMA_RESULT_DATA_ERROR 1
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 | #ifdef _LZMA_IN_CB
 | 
        
           |  |  | 54 | typedef struct _ILzmaInCallback
 | 
        
           |  |  | 55 | {
 | 
        
           |  |  | 56 |   int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
 | 
        
           |  |  | 57 | } ILzmaInCallback;
 | 
        
           |  |  | 58 | #endif
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 | #define LZMA_BASE_SIZE 1846
 | 
        
           |  |  | 61 | #define LZMA_LIT_SIZE 768
 | 
        
           |  |  | 62 |   | 
        
           |  |  | 63 | #define LZMA_PROPERTIES_SIZE 5
 | 
        
           |  |  | 64 |   | 
        
           |  |  | 65 | typedef struct _CLzmaProperties
 | 
        
           |  |  | 66 | {
 | 
        
           |  |  | 67 |   int lc;
 | 
        
           |  |  | 68 |   int lp;
 | 
        
           |  |  | 69 |   int pb;
 | 
        
           |  |  | 70 |   #ifdef _LZMA_OUT_READ
 | 
        
           |  |  | 71 |   UInt32 DictionarySize;
 | 
        
           |  |  | 72 |   #endif
 | 
        
           |  |  | 73 | }CLzmaProperties;
 | 
        
           |  |  | 74 |   | 
        
           |  |  | 75 | int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
 | 
        
           |  |  | 76 |   | 
        
           |  |  | 77 | #define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
 | 
        
           |  |  | 78 |   | 
        
           |  |  | 79 | #define kLzmaNeedInitId (-2)
 | 
        
           |  |  | 80 |   | 
        
           |  |  | 81 | typedef struct _CLzmaDecoderState
 | 
        
           |  |  | 82 | {
 | 
        
           |  |  | 83 |   CLzmaProperties Properties;
 | 
        
           |  |  | 84 |   CProb *Probs;
 | 
        
           |  |  | 85 |   | 
        
           |  |  | 86 |   #ifdef _LZMA_IN_CB
 | 
        
           |  |  | 87 |   const unsigned char *Buffer;
 | 
        
           |  |  | 88 |   const unsigned char *BufferLim;
 | 
        
           |  |  | 89 |   #endif
 | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 |   #ifdef _LZMA_OUT_READ
 | 
        
           |  |  | 92 |   unsigned char *Dictionary;
 | 
        
           |  |  | 93 |   UInt32 Range;
 | 
        
           |  |  | 94 |   UInt32 Code;
 | 
        
           |  |  | 95 |   UInt32 DictionaryPos;
 | 
        
           |  |  | 96 |   UInt32 GlobalPos;
 | 
        
           |  |  | 97 |   UInt32 DistanceLimit;
 | 
        
           |  |  | 98 |   UInt32 Reps[4];
 | 
        
           |  |  | 99 |   int State;
 | 
        
           |  |  | 100 |   int RemainLen;
 | 
        
           |  |  | 101 |   unsigned char TempDictionary[4];
 | 
        
           |  |  | 102 |   #endif
 | 
        
           |  |  | 103 | } CLzmaDecoderState;
 | 
        
           |  |  | 104 |   | 
        
           |  |  | 105 | #ifdef _LZMA_OUT_READ
 | 
        
           |  |  | 106 | #define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
 | 
        
           |  |  | 107 | #endif
 | 
        
           |  |  | 108 |   | 
        
           |  |  | 109 | int LzmaDecode(CLzmaDecoderState *vs, const unsigned char *inStream, size_t inSize, size_t *inSizeProcessed, unsigned char *outStream, size_t outSize, size_t *outSizeProcessed);
 | 
        
           |  |  | 110 |   | 
        
           |  |  | 111 | #endif
 |