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