2009-11-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
[grub2.git] / include / grub / lib / LzmaEnc.h
blobfc156a448068f69cfc5e6bf00c41f090232d16f5
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 __LZMAENC_H
28 #define __LZMAENC_H
30 #include "LzmaTypes.h"
32 #define LZMA_PROPS_SIZE 5
34 typedef struct _CLzmaEncProps
36 int level; /* 0 <= level <= 9 */
37 UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
38 (1 << 12) <= dictSize <= (1 << 30) for 64-bit version
39 default = (1 << 24) */
40 int lc; /* 0 <= lc <= 8, default = 3 */
41 int lp; /* 0 <= lp <= 4, default = 0 */
42 int pb; /* 0 <= pb <= 4, default = 2 */
43 int algo; /* 0 - fast, 1 - normal, default = 1 */
44 int fb; /* 5 <= fb <= 273, default = 32 */
45 int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
46 int numHashBytes; /* 2, 3 or 4, default = 4 */
47 UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
48 unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
49 int numThreads; /* 1 or 2, default = 2 */
50 } CLzmaEncProps;
52 void LzmaEncProps_Init(CLzmaEncProps *p);
53 void LzmaEncProps_Normalize(CLzmaEncProps *p);
54 UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
57 /* ---------- CLzmaEncHandle Interface ---------- */
59 /* LzmaEnc_* functions can return the following exit codes:
60 Returns:
61 SZ_OK - OK
62 SZ_ERROR_MEM - Memory allocation error
63 SZ_ERROR_PARAM - Incorrect parameter in props
64 SZ_ERROR_WRITE - Write callback error.
65 SZ_ERROR_PROGRESS - some break from progress callback
66 SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
69 typedef void * CLzmaEncHandle;
71 CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
72 void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
73 SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
74 SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
75 SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
76 ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
77 SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
78 int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
80 /* ---------- One Call Interface ---------- */
82 /* LzmaEncode
83 Return code:
84 SZ_OK - OK
85 SZ_ERROR_MEM - Memory allocation error
86 SZ_ERROR_PARAM - Incorrect parameter
87 SZ_ERROR_OUTPUT_EOF - output buffer overflow
88 SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
91 SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
92 const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
93 ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
95 #endif