| 1 | /* |
| 2 | LzmaDecode.h |
| 3 | LZMA Decoder interface |
| 4 | |
| 5 | LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25) |
| 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 | /* #define _LZMA_IN_CB */ |
| 26 | /* Use callback for input data */ |
| 27 | |
| 28 | /* #define _LZMA_OUT_READ */ |
| 29 | /* Use read function for output data */ |
| 30 | |
| 31 | /* #define _LZMA_PROB32 */ |
| 32 | /* It can increase speed on some 32-bit CPUs, |
| 33 | but memory usage will be doubled in that case */ |
| 34 | |
| 35 | /* #define _LZMA_LOC_OPT */ |
| 36 | /* Enable local speed optimizations inside code */ |
| 37 | |
| 38 | #ifndef UInt32 |
| 39 | #ifdef _LZMA_UINT32_IS_ULONG |
| 40 | #define UInt32 unsigned long |
| 41 | #else |
| 42 | #define UInt32 unsigned int |
| 43 | #endif |
| 44 | #endif |
| 45 | |
| 46 | #ifdef _LZMA_PROB32 |
| 47 | #define CProb UInt32 |
| 48 | #else |
| 49 | #define CProb unsigned short |
| 50 | #endif |
| 51 | |
| 52 | #define LZMA_RESULT_OK 0 |
| 53 | #define LZMA_RESULT_DATA_ERROR 1 |
| 54 | #define LZMA_RESULT_NOT_ENOUGH_MEM 2 |
| 55 | |
| 56 | #ifdef _LZMA_IN_CB |
| 57 | typedef struct _ILzmaInCallback |
| 58 | { |
| 59 | int (*Read)(void *object, unsigned char **buffer, UInt32 *bufferSize); |
| 60 | } ILzmaInCallback; |
| 61 | #endif |
| 62 | |
| 63 | #define LZMA_BASE_SIZE 1846 |
| 64 | #define LZMA_LIT_SIZE 768 |
| 65 | |
| 66 | /* |
| 67 | bufferSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)))* sizeof(CProb) |
| 68 | bufferSize += 100 in case of _LZMA_OUT_READ |
| 69 | by default CProb is unsigned short, |
| 70 | but if specify _LZMA_PROB_32, CProb will be UInt32(unsigned int) |
| 71 | */ |
| 72 | |
| 73 | #ifdef _LZMA_OUT_READ |
| 74 | int LzmaDecoderInit( |
| 75 | unsigned char *buffer, UInt32 bufferSize, |
| 76 | int lc, int lp, int pb, |
| 77 | unsigned char *dictionary, UInt32 dictionarySize, |
| 78 | #ifdef _LZMA_IN_CB |
| 79 | ILzmaInCallback *inCallback |
| 80 | #else |
| 81 | unsigned char *inStream, UInt32 inSize |
| 82 | #endif |
| 83 | ); |
| 84 | #endif |
| 85 | |
| 86 | int LzmaDecode( |
| 87 | unsigned char *buffer, |
| 88 | #ifndef _LZMA_OUT_READ |
| 89 | UInt32 bufferSize, |
| 90 | int lc, int lp, int pb, |
| 91 | #ifdef _LZMA_IN_CB |
| 92 | ILzmaInCallback *inCallback, |
| 93 | #else |
| 94 | unsigned char *inStream, UInt32 inSize, |
| 95 | #endif |
| 96 | #endif |
| 97 | unsigned char *outStream, UInt32 outSize, |
| 98 | UInt32 *outSizeProcessed); |
| 99 | |
| 100 | #endif |
| 101 | |