fa9e4066f08beec538e775443c5be79dd423fcabahrens * GRUB -- GRand Unified Bootloader
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Copyright (c) 1999-2008 Igor Pavlov
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Copyright (C) 2008 Free Software Foundation, Inc.
441d80aa4f613b6298fc8bd3151f4be02dbf84fclling * GRUB is free software: you can redistribute it and/or modify
fa9e4066f08beec538e775443c5be79dd423fcabahrens * it under the terms of the GNU General Public License as published by
fa9e4066f08beec538e775443c5be79dd423fcabahrens * the Free Software Foundation, either version 3 of the License, or
fa9e4066f08beec538e775443c5be79dd423fcabahrens * (at your option) any later version.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * GRUB is distributed in the hope that it will be useful,
fa9e4066f08beec538e775443c5be79dd423fcabahrens * but WITHOUT ANY WARRANTY; without even the implied warranty of
fa9e4066f08beec538e775443c5be79dd423fcabahrens * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * GNU General Public License for more details.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You should have received a copy of the GNU General Public License
fa9e4066f08beec538e775443c5be79dd423fcabahrens * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
47cb52daa729f19e298c85a84e8df069365c5232Jeff Bonwick * to adapt it to GRUB's requirement.
e9103aaee0c546d4644791198c54abb03c89969eGarrett D'Amore * See <http://www.7-zip.org>, for more information about LZMA.
fa9e4066f08beec538e775443c5be79dd423fcabahrens UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* int skipModeBits; */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
420dfc9585ff67e83ee7800a7ad2ebe1a9145983Chris Siden#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
420dfc9585ff67e83ee7800a7ad2ebe1a9145983Chris SidenByte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
420dfc9585ff67e83ee7800a7ad2ebe1a9145983Chris Sidenvoid MatchFinder_ReadIfRequired(CMatchFinder *p);
fa9e4066f08beec538e775443c5be79dd423fcabahrens/* Conditions:
fa9e4066f08beec538e775443c5be79dd423fcabahrens historySize <= 3 GB
fa9e4066f08beec538e775443c5be79dd423fcabahrens keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
fa9e4066f08beec538e775443c5be79dd423fcabahrensint MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
fa9e4066f08beec538e775443c5be79dd423fcabahrens UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
fa9e4066f08beec538e775443c5be79dd423fcabahrensUInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
fa9e4066f08beec538e775443c5be79dd423fcabahrens UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
fa9e4066f08beec538e775443c5be79dd423fcabahrens Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
4f5064b73b1cc9de1d0f1a2ae700d519d4d565dfMark J Musantetypedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrenstypedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingtypedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
cde58dbc6a23d4d38db7c8866312be83221c765fMatthew Ahrenstypedef void (*Mf_Skip_Func)(void *object, UInt32);
fa9e4066f08beec538e775443c5be79dd423fcabahrens Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
fa9e4066f08beec538e775443c5be79dd423fcabahrensUInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
741652b0d7a641dcc9c966750c26e41bcc641863Etienne DechampsUInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
741652b0d7a641dcc9c966750c26e41bcc641863Etienne Dechampsvoid Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);