1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-08-20 17:54:38 +03:00

try to re-add the lzma patch

git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@2115 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2005-10-17 09:34:58 +00:00
parent 12fffaca64
commit a943543df0

View File

@ -2,404 +2,404 @@ diff -BurN lzma406/SRC/7zip/Compress/LZMA/LZMADecoder.cpp lzma/SRC/7zip/Compress
--- lzma406/SRC/7zip/Compress/LZMA/LZMADecoder.cpp 2004-08-25 01:40:48.000000000 +0400 --- lzma406/SRC/7zip/Compress/LZMA/LZMADecoder.cpp 2004-08-25 01:40:48.000000000 +0400
+++ lzma/SRC/7zip/Compress/LZMA/LZMADecoder.cpp 2005-01-20 14:47:45.789801629 +0300 +++ lzma/SRC/7zip/Compress/LZMA/LZMADecoder.cpp 2005-01-20 14:47:45.789801629 +0300
@@ -288,12 +288,17 @@ @@ -288,12 +288,17 @@
Byte remainder = (Byte)(properties[0] / 9); Byte remainder = (Byte)(properties[0] / 9);
int lp = remainder % 5; int lp = remainder % 5;
int pb = remainder / 5; int pb = remainder / 5;
- if (pb > NLength::kNumPosStatesBitsMax) - if (pb > NLength::kNumPosStatesBitsMax)
- return E_INVALIDARG; - return E_INVALIDARG;
- _posStateMask = (1 << pb) - 1; - _posStateMask = (1 << pb) - 1;
UInt32 dictionarySize = 0; UInt32 dictionarySize = 0;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8); dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8);
+ return SetDecoderPropertiesRaw(lc, lp, pb, dictionarySize); + return SetDecoderPropertiesRaw(lc, lp, pb, dictionarySize);
+} +}
+ +
+STDMETHODIMP CDecoder::SetDecoderPropertiesRaw(int lc, int lp, int pb, UInt32 dictionarySize) +STDMETHODIMP CDecoder::SetDecoderPropertiesRaw(int lc, int lp, int pb, UInt32 dictionarySize)
+{ +{
+ if (pb > NLength::kNumPosStatesBitsMax) + if (pb > NLength::kNumPosStatesBitsMax)
+ return E_INVALIDARG; + return E_INVALIDARG;
+ _posStateMask = (1 << pb) - 1; + _posStateMask = (1 << pb) - 1;
_dictionarySizeCheck = MyMax(dictionarySize, UInt32(1)); _dictionarySizeCheck = MyMax(dictionarySize, UInt32(1));
UInt32 blockSize = MyMax(_dictionarySizeCheck, UInt32(1 << 12)); UInt32 blockSize = MyMax(_dictionarySizeCheck, UInt32(1 << 12));
if (!_outWindowStream.Create(blockSize)) if (!_outWindowStream.Create(blockSize))
diff -BurN lzma406/SRC/7zip/Compress/LZMA/LZMADecoder.h lzma/SRC/7zip/Compress/LZMA/LZMADecoder.h diff -BurN lzma406/SRC/7zip/Compress/LZMA/LZMADecoder.h lzma/SRC/7zip/Compress/LZMA/LZMADecoder.h
--- lzma406/SRC/7zip/Compress/LZMA/LZMADecoder.h 2004-08-25 01:40:08.000000000 +0400 --- lzma406/SRC/7zip/Compress/LZMA/LZMADecoder.h 2004-08-25 01:40:08.000000000 +0400
+++ lzma/SRC/7zip/Compress/LZMA/LZMADecoder.h 2005-01-20 13:06:59.081297916 +0300 +++ lzma/SRC/7zip/Compress/LZMA/LZMADecoder.h 2005-01-20 13:06:59.081297916 +0300
@@ -234,6 +234,8 @@ @@ -234,6 +234,8 @@
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(SetDecoderPropertiesRaw)(int lc, int lp, int pb, UInt32 dictionarySize); + STDMETHOD(SetDecoderPropertiesRaw)(int lc, int lp, int pb, UInt32 dictionarySize);
+ +
virtual ~CDecoder() {} virtual ~CDecoder() {}
}; };
diff -BurN lzma406/SRC/7zip/Compress/LZMA_Lib/makefile lzma/SRC/7zip/Compress/LZMA_Lib/makefile diff -BurN lzma406/SRC/7zip/Compress/LZMA_Lib/makefile lzma/SRC/7zip/Compress/LZMA_Lib/makefile
--- lzma406/SRC/7zip/Compress/LZMA_Lib/makefile 1970-01-01 03:00:00.000000000 +0300 --- lzma406/SRC/7zip/Compress/LZMA_Lib/makefile 1970-01-01 03:00:00.000000000 +0300
+++ lzma/SRC/7zip/Compress/LZMA_Lib/makefile 2005-01-19 13:49:20.000000000 +0300 +++ lzma/SRC/7zip/Compress/LZMA_Lib/makefile 2005-01-19 13:49:20.000000000 +0300
@@ -0,0 +1,88 @@ @@ -0,0 +1,88 @@
+PROG = liblzma.a +PROG = liblzma.a
+CXX = g++ -O3 -Wall +CXX = g++ -O3 -Wall
+AR = ar +AR = ar
+RM = rm -f +RM = rm -f
+CFLAGS = -c +CFLAGS = -c
+ +
+OBJS = \ +OBJS = \
+ ZLib.o \ + ZLib.o \
+ LZMADecoder.o \ + LZMADecoder.o \
+ LZMAEncoder.o \ + LZMAEncoder.o \
+ LZInWindow.o \ + LZInWindow.o \
+ LZOutWindow.o \ + LZOutWindow.o \
+ RangeCoderBit.o \ + RangeCoderBit.o \
+ InBuffer.o \ + InBuffer.o \
+ OutBuffer.o \ + OutBuffer.o \
+ FileStreams.o \ + FileStreams.o \
+ Alloc.o \ + Alloc.o \
+ C_FileIO.o \ + C_FileIO.o \
+ CommandLineParser.o \ + CommandLineParser.o \
+ CRC.o \ + CRC.o \
+ String.o \ + String.o \
+ StringConvert.o \ + StringConvert.o \
+ StringToInt.o \ + StringToInt.o \
+ Vector.o \ + Vector.o \
+ +
+ +
+all: $(PROG) +all: $(PROG)
+ +
+$(PROG): $(OBJS) +$(PROG): $(OBJS)
+ $(AR) r $(PROG) $(OBJS) + $(AR) r $(PROG) $(OBJS)
+ +
+ZLib.o: ZLib.cpp +ZLib.o: ZLib.cpp
+ $(CXX) $(CFLAGS) ZLib.cpp + $(CXX) $(CFLAGS) ZLib.cpp
+ +
+LZMADecoder.o: ../LZMA/LZMADecoder.cpp +LZMADecoder.o: ../LZMA/LZMADecoder.cpp
+ $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp + $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
+ +
+LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp +LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
+ $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp + $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
+ +
+LZInWindow.o: ../LZ/LZInWindow.cpp +LZInWindow.o: ../LZ/LZInWindow.cpp
+ $(CXX) $(CFLAGS) ../LZ/LZInWindow.cpp + $(CXX) $(CFLAGS) ../LZ/LZInWindow.cpp
+ +
+LZOutWindow.o: ../LZ/LZOutWindow.cpp +LZOutWindow.o: ../LZ/LZOutWindow.cpp
+ $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp + $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
+ +
+RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp +RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
+ $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp + $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp
+ +
+InBuffer.o: ../../Common/InBuffer.cpp +InBuffer.o: ../../Common/InBuffer.cpp
+ $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp + $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
+ +
+OutBuffer.o: ../../Common/OutBuffer.cpp +OutBuffer.o: ../../Common/OutBuffer.cpp
+ $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp + $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
+ +
+FileStreams.o: ../../Common/FileStreams.cpp +FileStreams.o: ../../Common/FileStreams.cpp
+ $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp + $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
+ +
+Alloc.o: ../../../Common/Alloc.cpp +Alloc.o: ../../../Common/Alloc.cpp
+ $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp + $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp
+ +
+C_FileIO.o: ../../../Common/C_FileIO.cpp +C_FileIO.o: ../../../Common/C_FileIO.cpp
+ $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp + $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp
+ +
+CommandLineParser.o: ../../../Common/CommandLineParser.cpp +CommandLineParser.o: ../../../Common/CommandLineParser.cpp
+ $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp + $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp
+ +
+CRC.o: ../../../Common/CRC.cpp +CRC.o: ../../../Common/CRC.cpp
+ $(CXX) $(CFLAGS) ../../../Common/CRC.cpp + $(CXX) $(CFLAGS) ../../../Common/CRC.cpp
+ +
+MyWindows.o: ../../../Common/MyWindows.cpp +MyWindows.o: ../../../Common/MyWindows.cpp
+ $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp + $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
+ +
+String.o: ../../../Common/String.cpp +String.o: ../../../Common/String.cpp
+ $(CXX) $(CFLAGS) ../../../Common/String.cpp + $(CXX) $(CFLAGS) ../../../Common/String.cpp
+ +
+StringConvert.o: ../../../Common/StringConvert.cpp +StringConvert.o: ../../../Common/StringConvert.cpp
+ $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp + $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp
+ +
+StringToInt.o: ../../../Common/StringToInt.cpp +StringToInt.o: ../../../Common/StringToInt.cpp
+ $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp + $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp
+ +
+Vector.o: ../../../Common/Vector.cpp +Vector.o: ../../../Common/Vector.cpp
+ $(CXX) $(CFLAGS) ../../../Common/Vector.cpp + $(CXX) $(CFLAGS) ../../../Common/Vector.cpp
+ +
+clean: +clean:
+ -$(RM) $(PROG) $(OBJS) + -$(RM) $(PROG) $(OBJS)
+ +
diff -BurN lzma406/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp diff -BurN lzma406/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp
--- lzma406/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp 1970-01-01 03:00:00.000000000 +0300 --- lzma406/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp 1970-01-01 03:00:00.000000000 +0300
+++ lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp 2005-01-20 15:01:18.439221129 +0300 +++ lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp 2005-01-20 15:01:18.439221129 +0300
@@ -0,0 +1,273 @@ @@ -0,0 +1,273 @@
+/* +/*
+ * lzma zlib simplified wrapper + * lzma zlib simplified wrapper
+ * + *
+ * Copyright (c) 2005 Oleg I. Vdovikin <oleg@cs.msu.su> + * Copyright (c) 2005 Oleg I. Vdovikin <oleg@cs.msu.su>
+ * + *
+ * This library is free software; you can redistribute + * This library is free software; you can redistribute
+ * it and/or modify it under the terms of the GNU Lesser + * it and/or modify it under the terms of the GNU Lesser
+ * General Public License as published by the Free Software + * General Public License as published by the Free Software
+ * Foundation; either version 2.1 of the License, or + * Foundation; either version 2.1 of the License, or
+ * (at your option) any later version. + * (at your option) any later version.
+ * + *
+ * This library is distributed in the hope that it will be + * This library is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied + * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU Lesser General Public License + * PURPOSE. See the GNU Lesser General Public License
+ * for more details. + * for more details.
+ * + *
+ * You should have received a copy of the GNU Lesser General + * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to + * Public License along with this library; if not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place, + * the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA + * Suite 330, Boston, MA 02111-1307 USA
+ */ + */
+ +
+/* +/*
+ * default values for encoder/decoder used by wrapper + * default values for encoder/decoder used by wrapper
+ */ + */
+ +
+#include <zlib.h> +#include <zlib.h>
+ +
+#define ZLIB_LC 3 +#define ZLIB_LC 3
+#define ZLIB_LP 0 +#define ZLIB_LP 0
+#define ZLIB_PB 2 +#define ZLIB_PB 2
+ +
+#ifdef WIN32 +#ifdef WIN32
+#include <initguid.h> +#include <initguid.h>
+#else +#else
+#define INITGUID +#define INITGUID
+#endif +#endif
+ +
+#include "../../../Common/MyWindows.h" +#include "../../../Common/MyWindows.h"
+#include "../LZMA/LZMADecoder.h" +#include "../LZMA/LZMADecoder.h"
+#include "../LZMA/LZMAEncoder.h" +#include "../LZMA/LZMAEncoder.h"
+ +
+#define STG_E_SEEKERROR ((HRESULT)0x80030019L) +#define STG_E_SEEKERROR ((HRESULT)0x80030019L)
+#define STG_E_MEDIUMFULL ((HRESULT)0x80030070L) +#define STG_E_MEDIUMFULL ((HRESULT)0x80030070L)
+ +
+class CInMemoryStream: +class CInMemoryStream:
+ public IInStream, + public IInStream,
+ public IStreamGetSize, + public IStreamGetSize,
+ public CMyUnknownImp + public CMyUnknownImp
+{ +{
+public: +public:
+ CInMemoryStream(const Bytef *data, UInt64 size) : + CInMemoryStream(const Bytef *data, UInt64 size) :
+ m_data(data), m_size(size), m_offset(0) {} + m_data(data), m_size(size), m_offset(0) {}
+ +
+ virtual ~CInMemoryStream() {} + virtual ~CInMemoryStream() {}
+ +
+ MY_UNKNOWN_IMP2(IInStream, IStreamGetSize) + MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
+ +
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize)
+ { + {
+ if (size > m_size - m_offset) + if (size > m_size - m_offset)
+ size = m_size - m_offset; + size = m_size - m_offset;
+ +
+ if (size) { + if (size) {
+ memcpy(data, m_data + m_offset, size); + memcpy(data, m_data + m_offset, size);
+ } + }
+ +
+ m_offset += size; + m_offset += size;
+ +
+ if (processedSize) + if (processedSize)
+ *processedSize = size; + *processedSize = size;
+ +
+ return S_OK; + return S_OK;
+ } + }
+ +
+ STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize) + STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize)
+ { + {
+ return Read(data, size, processedSize); + return Read(data, size, processedSize);
+ } + }
+ +
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+ { + {
+ UInt64 _offset; + UInt64 _offset;
+ +
+ if (seekOrigin == STREAM_SEEK_SET) _offset = offset; + if (seekOrigin == STREAM_SEEK_SET) _offset = offset;
+ else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset; + else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset;
+ else if (seekOrigin == STREAM_SEEK_END) _offset = m_size; + else if (seekOrigin == STREAM_SEEK_END) _offset = m_size;
+ else return STG_E_INVALIDFUNCTION; + else return STG_E_INVALIDFUNCTION;
+ +
+ if (_offset < 0 || _offset > m_size) + if (_offset < 0 || _offset > m_size)
+ return STG_E_SEEKERROR; + return STG_E_SEEKERROR;
+ +
+ m_offset = _offset; + m_offset = _offset;
+ +
+ if (newPosition) + if (newPosition)
+ *newPosition = m_offset; + *newPosition = m_offset;
+ +
+ return S_OK; + return S_OK;
+ } + }
+ +
+ STDMETHOD(GetSize)(UInt64 *size) + STDMETHOD(GetSize)(UInt64 *size)
+ { + {
+ *size = m_size; + *size = m_size;
+ return S_OK; + return S_OK;
+ } + }
+protected: +protected:
+ const Bytef *m_data; + const Bytef *m_data;
+ UInt64 m_size; + UInt64 m_size;
+ UInt64 m_offset; + UInt64 m_offset;
+}; +};
+ +
+class COutMemoryStream: +class COutMemoryStream:
+ public IOutStream, + public IOutStream,
+ public CMyUnknownImp + public CMyUnknownImp
+{ +{
+public: +public:
+ COutMemoryStream(Bytef *data, UInt64 maxsize) : + COutMemoryStream(Bytef *data, UInt64 maxsize) :
+ m_data(data), m_size(0), m_maxsize(maxsize), m_offset(0) {} + m_data(data), m_size(0), m_maxsize(maxsize), m_offset(0) {}
+ virtual ~COutMemoryStream() {} + virtual ~COutMemoryStream() {}
+ +
+ MY_UNKNOWN_IMP1(IOutStream) + MY_UNKNOWN_IMP1(IOutStream)
+ +
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize)
+ { + {
+ if (size > m_maxsize - m_offset) + if (size > m_maxsize - m_offset)
+ size = m_maxsize - m_offset; + size = m_maxsize - m_offset;
+ +
+ if (size) { + if (size) {
+ memcpy(m_data + m_offset, data, size); + memcpy(m_data + m_offset, data, size);
+ } + }
+ +
+ m_offset += size; + m_offset += size;
+ +
+ if (m_offset > m_size) + if (m_offset > m_size)
+ m_size = m_offset; + m_size = m_offset;
+ +
+ if (processedSize) + if (processedSize)
+ *processedSize = size; + *processedSize = size;
+ +
+ return S_OK; + return S_OK;
+ } + }
+ +
+ STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize) + STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize)
+ { + {
+ return Write(data, size, processedSize); + return Write(data, size, processedSize);
+ } + }
+ +
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+ { + {
+ UInt64 _offset; + UInt64 _offset;
+ +
+ if (seekOrigin == STREAM_SEEK_SET) _offset = offset; + if (seekOrigin == STREAM_SEEK_SET) _offset = offset;
+ else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset; + else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset;
+ else if (seekOrigin == STREAM_SEEK_END) _offset = m_size; + else if (seekOrigin == STREAM_SEEK_END) _offset = m_size;
+ else return STG_E_INVALIDFUNCTION; + else return STG_E_INVALIDFUNCTION;
+ +
+ if (_offset < 0 || _offset > m_maxsize) + if (_offset < 0 || _offset > m_maxsize)
+ return STG_E_SEEKERROR; + return STG_E_SEEKERROR;
+ +
+ m_offset = _offset; + m_offset = _offset;
+ +
+ if (newPosition) + if (newPosition)
+ *newPosition = m_offset; + *newPosition = m_offset;
+ +
+ return S_OK; + return S_OK;
+ } + }
+ +
+ STDMETHOD(SetSize)(Int64 newSize) + STDMETHOD(SetSize)(Int64 newSize)
+ { + {
+ if ((UInt64)newSize > m_maxsize) + if ((UInt64)newSize > m_maxsize)
+ return STG_E_MEDIUMFULL; + return STG_E_MEDIUMFULL;
+ +
+ return S_OK; + return S_OK;
+ } + }
+protected: +protected:
+ Bytef *m_data; + Bytef *m_data;
+ UInt64 m_size; + UInt64 m_size;
+ UInt64 m_maxsize; + UInt64 m_maxsize;
+ UInt64 m_offset; + UInt64 m_offset;
+}; +};
+ +
+ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen, + const Bytef *source, uLong sourceLen,
+ int level)) + int level))
+{ +{
+ CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen); + CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
+ CMyComPtr<ISequentialInStream> inStream = inStreamSpec; + CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
+ +
+ COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen); + COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
+ CMyComPtr<ISequentialOutStream> outStream = outStreamSpec; + CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+ +
+ NCompress::NLZMA::CEncoder *encoderSpec = + NCompress::NLZMA::CEncoder *encoderSpec =
+ new NCompress::NLZMA::CEncoder; + new NCompress::NLZMA::CEncoder;
+ CMyComPtr<ICompressCoder> encoder = encoderSpec; + CMyComPtr<ICompressCoder> encoder = encoderSpec;
+ +
+ PROPID propIDs[] = + PROPID propIDs[] =
+ { + {
+ NCoderPropID::kDictionarySize, + NCoderPropID::kDictionarySize,
+ NCoderPropID::kPosStateBits, + NCoderPropID::kPosStateBits,
+ NCoderPropID::kLitContextBits, + NCoderPropID::kLitContextBits,
+ NCoderPropID::kLitPosBits, + NCoderPropID::kLitPosBits,
+ NCoderPropID::kAlgorithm, + NCoderPropID::kAlgorithm,
+ NCoderPropID::kNumFastBytes, + NCoderPropID::kNumFastBytes,
+ NCoderPropID::kMatchFinder, + NCoderPropID::kMatchFinder,
+ NCoderPropID::kEndMarker + NCoderPropID::kEndMarker
+ }; + };
+ const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]); + const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
+ +
+ PROPVARIANT properties[kNumProps]; + PROPVARIANT properties[kNumProps];
+ for (int p = 0; p < 6; p++) + for (int p = 0; p < 6; p++)
+ properties[p].vt = VT_UI4; + properties[p].vt = VT_UI4;
+ properties[0].ulVal = UInt32(1 << (level + 14)); + properties[0].ulVal = UInt32(1 << (level + 14));
+ properties[1].ulVal = UInt32(ZLIB_PB); + properties[1].ulVal = UInt32(ZLIB_PB);
+ properties[2].ulVal = UInt32(ZLIB_LC); // for normal files + properties[2].ulVal = UInt32(ZLIB_LC); // for normal files
+ properties[3].ulVal = UInt32(ZLIB_LP); // for normal files + properties[3].ulVal = UInt32(ZLIB_LP); // for normal files
+ properties[4].ulVal = UInt32(2); + properties[4].ulVal = UInt32(2);
+ properties[5].ulVal = UInt32(128); + properties[5].ulVal = UInt32(128);
+ +
+ properties[6].vt = VT_BSTR; + properties[6].vt = VT_BSTR;
+ properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4"; + properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4";
+ +
+ properties[7].vt = VT_BOOL; + properties[7].vt = VT_BOOL;
+ properties[7].boolVal = VARIANT_TRUE; + properties[7].boolVal = VARIANT_TRUE;
+ +
+ if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK) + if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
+ return Z_MEM_ERROR; // should not happen + return Z_MEM_ERROR; // should not happen
+ +
+ HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0); + HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
+ if (result == E_OUTOFMEMORY) + if (result == E_OUTOFMEMORY)
+ { + {
+ return Z_MEM_ERROR; + return Z_MEM_ERROR;
+ } + }
+ else if (result != S_OK) + else if (result != S_OK)
+ { + {
+ return Z_BUF_ERROR; // should not happen + return Z_BUF_ERROR; // should not happen
+ } + }
+ +
+ UInt64 fileSize; + UInt64 fileSize;
+ outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize); + outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
+ *destLen = fileSize; + *destLen = fileSize;
+ +
+ return Z_OK; + return Z_OK;
+} +}
+ +
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen)) + const Bytef *source, uLong sourceLen))
+{ +{
+ CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen); + CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
+ CMyComPtr<ISequentialInStream> inStream = inStreamSpec; + CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
+ +
+ COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen); + COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
+ CMyComPtr<ISequentialOutStream> outStream = outStreamSpec; + CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+ +
+ NCompress::NLZMA::CDecoder *decoderSpec = + NCompress::NLZMA::CDecoder *decoderSpec =
+ new NCompress::NLZMA::CDecoder; + new NCompress::NLZMA::CDecoder;
+ CMyComPtr<ICompressCoder> decoder = decoderSpec; + CMyComPtr<ICompressCoder> decoder = decoderSpec;
+ +
+ if (decoderSpec->SetDecoderPropertiesRaw(ZLIB_LC, + if (decoderSpec->SetDecoderPropertiesRaw(ZLIB_LC,
+ ZLIB_LP, ZLIB_PB, (1 << 23)) != S_OK) return Z_DATA_ERROR; + ZLIB_LP, ZLIB_PB, (1 << 23)) != S_OK) return Z_DATA_ERROR;
+ +
+ UInt64 fileSize = *destLen; + UInt64 fileSize = *destLen;
+ +
+ if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK) + if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
+ { + {
+ return Z_DATA_ERROR; + return Z_DATA_ERROR;
+ } + }
+ +
+ outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize); + outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
+ *destLen = fileSize; + *destLen = fileSize;
+ +
+ return Z_OK; + return Z_OK;
+} +}