2009-11-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
[grub2.git] / include / grub / lib / LzmaTypes.h
blob1e783a2c75ab7d03e75d2159ca1eb98bd6fa6018
1 /*
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.
27 #ifndef __7Z_TYPES_H
28 #define __7Z_TYPES_H
30 #define SZ_OK 0
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
48 typedef int SRes;
50 #ifndef RINOK
51 #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
52 #endif
54 typedef unsigned char Byte;
55 typedef short Int16;
56 typedef unsigned short UInt16;
58 #ifdef _LZMA_UINT32_IS_ULONG
59 typedef long Int32;
60 typedef unsigned long UInt32;
61 #else
62 typedef int Int32;
63 typedef unsigned int UInt32;
64 #endif
66 /* #define _SZ_NO_INT_64 */
67 /* define it if your compiler doesn't support 64-bit integers */
69 #ifdef _SZ_NO_INT_64
71 typedef long Int64;
72 typedef unsigned long UInt64;
74 #else
76 #if defined(_MSC_VER) || defined(__BORLANDC__)
77 typedef __int64 Int64;
78 typedef unsigned __int64 UInt64;
79 #else
80 typedef long long int Int64;
81 typedef unsigned long long int UInt64;
82 #endif
84 #endif
86 #ifdef _LZMA_NO_SYSTEM_SIZE_T
87 typedef UInt32 SizeT;
88 #else
89 #include <stddef.h>
90 typedef size_t SizeT;
91 #endif
93 typedef int Bool;
94 #define True 1
95 #define False 0
98 #ifdef _MSC_VER
100 #if _MSC_VER >= 1300
101 #define MY_NO_INLINE __declspec(noinline)
102 #else
103 #define MY_NO_INLINE
104 #endif
106 #define MY_CDECL __cdecl
107 #define MY_STD_CALL __stdcall
108 #define MY_FAST_CALL MY_NO_INLINE __fastcall
110 #else
112 #define MY_CDECL
113 #define MY_STD_CALL
114 #define MY_FAST_CALL
116 #endif
119 /* The following interfaces use first parameter as pointer to structure */
121 typedef struct
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 */
126 } ISeqInStream;
128 typedef struct
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 */
133 } ISeqOutStream;
135 typedef struct
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. */
140 } ICompressProgress;
142 typedef struct
144 void *(*Alloc)(void *p, size_t size);
145 void (*Free)(void *p, void *address); /* address can be 0 */
146 } ISzAlloc;
148 #define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
149 #define IAlloc_Free(p, a) (p)->Free((p), a)
151 #endif