2 * GRUB -- GRand Unified Bootloader
3 * Copyright (c) 1999-2008 Igor Pavlov
4 * Copyright (C) 2008 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21 * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
22 * to adapt it to GRUB's requirement.
24 * See <http://www.7-zip.org>, for more information about LZMA.
32 #define SZ_ERROR_DATA 1
33 #define SZ_ERROR_MEM 2
34 #define SZ_ERROR_CRC 3
35 #define SZ_ERROR_UNSUPPORTED 4
36 #define SZ_ERROR_PARAM 5
37 #define SZ_ERROR_INPUT_EOF 6
38 #define SZ_ERROR_OUTPUT_EOF 7
39 #define SZ_ERROR_READ 8
40 #define SZ_ERROR_WRITE 9
41 #define SZ_ERROR_PROGRESS 10
42 #define SZ_ERROR_FAIL 11
43 #define SZ_ERROR_THREAD 12
45 #define SZ_ERROR_ARCHIVE 16
46 #define SZ_ERROR_NO_ARCHIVE 17
51 #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
54 typedef unsigned char Byte
;
56 typedef unsigned short UInt16
;
58 #ifdef _LZMA_UINT32_IS_ULONG
60 typedef unsigned long UInt32
;
63 typedef unsigned int UInt32
;
66 /* #define _SZ_NO_INT_64 */
67 /* define it if your compiler doesn't support 64-bit integers */
72 typedef unsigned long UInt64
;
76 #if defined(_MSC_VER) || defined(__BORLANDC__)
77 typedef __int64 Int64
;
78 typedef unsigned __int64 UInt64
;
80 typedef long long int Int64
;
81 typedef unsigned long long int UInt64
;
86 #ifdef _LZMA_NO_SYSTEM_SIZE_T
101 #define MY_NO_INLINE __declspec(noinline)
106 #define MY_CDECL __cdecl
107 #define MY_STD_CALL __stdcall
108 #define MY_FAST_CALL MY_NO_INLINE __fastcall
119 /* The following interfaces use first parameter as pointer to structure */
123 SRes (*Read
)(void *p
, void *buf
, size_t *size
);
124 /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
125 (output(*size) < input(*size)) is allowed */
130 size_t (*Write
)(void *p
, const void *buf
, size_t size
);
131 /* Returns: result - the number of actually written bytes.
132 (result < size) means error */
137 SRes (*Progress
)(void *p
, UInt64 inSize
, UInt64 outSize
);
138 /* Returns: result. (result != SZ_OK) means break.
139 Value (UInt64)(Int64)-1 for size means unknown value. */
144 void *(*Alloc
)(void *p
, size_t size
);
145 void (*Free
)(void *p
, void *address
); /* address can be 0 */
148 #define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
149 #define IAlloc_Free(p, a) (p)->Free((p), a)