1 /* 2 LzmaDecode.h 3 LZMA Decoder interface 4 LZMA SDK 4.01 Copyright (c) 1999-2004 Igor Pavlov (2004-02-15) 5 6 Converted to a state machine by Amir Szekely 7 */ 8 9 #ifndef __LZMADECODE_H 10 #define __LZMADECODE_H 11 12 #include "../sdk/C/7zTypes.h" 13 14 /*********************** 15 * Configuration * 16 ***********************/ 17 18 /* #define _LZMA_PROB32 */ 19 /* It can increase speed on some 32-bit CPUs, 20 but memory usage will be doubled in that case */ 21 22 /*********************** 23 * Configuration End * 24 ***********************/ 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 #ifndef lzmaalloc 31 #define lzmaalloc malloc 32 #endif 33 34 #ifndef lzmafree 35 #define lzmafree free 36 #endif 37 38 #ifndef LZMACALL 39 # define LZMACALL 40 #endif 41 42 #ifndef UInt32 43 #ifdef _LZMA_UINT32_IS_ULONG 44 #define UInt32 unsigned long 45 #else 46 #define UInt32 unsigned int 47 #endif 48 #endif 49 50 #ifndef SizeT 51 #ifdef _LZMA_SYSTEM_SIZE_T 52 #include <stddef.h> 53 #define SizeT size_t 54 #else 55 #define SizeT UInt32 56 #endif 57 #endif 58 59 #ifndef CProb 60 #ifdef _LZMA_PROB32 61 #define CProb UInt32 62 #else 63 #define CProb unsigned short 64 #endif 65 #endif 66 67 #define LZMA_STREAM_END 1 68 #define LZMA_OK 0 69 #define LZMA_DATA_ERROR -1 70 #define LZMA_NOT_ENOUGH_MEM -2 71 72 typedef struct 73 { 74 /* mode control */ 75 int mode; 76 int last; 77 int last2; 78 int last3; 79 80 /* properties */ 81 UInt32 dynamicDataSize; 82 UInt32 dictionarySize; 83 84 /* io */ 85 Byte *next_in; /* next input byte */ 86 UInt32 avail_in; /* number of bytes available at next_in */ 87 88 Byte *next_out; /* next output byte should be put there */ 89 UInt32 avail_out; /* remaining free space at next_out */ 90 91 UInt32 totalOut; /* total output */ 92 93 /* saved state */ 94 Byte previousByte; 95 Byte matchByte; 96 CProb *probs; 97 CProb *prob; 98 int mi; 99 int posState; 100 int temp1; 101 int temp2; 102 int temp3; 103 int lc; 104 int state; 105 int isPreviousMatch; 106 int len; 107 UInt32 rep0; 108 UInt32 rep1; 109 UInt32 rep2; 110 UInt32 rep3; 111 UInt32 posStateMask; 112 UInt32 literalPosMask; 113 UInt32 dictionaryPos; 114 115 /* range coder */ 116 UInt32 range; 117 UInt32 code; 118 119 /* allocated buffers */ 120 Byte *dictionary; 121 Byte *dynamicData; 122 } lzma_stream; 123 124 void LZMACALL lzmaCompatInit(lzma_stream *); 125 int LZMACALL lzmaCompatDecode(lzma_stream *); 126 127 #ifdef __cplusplus 128 } 129 #endif 130 131 #endif 132