1 diff -Nur lzma432/C/7zip/Compress/LZMA_Lib/makefile lzma432-owrt/C/7zip/Compress/LZMA_Lib/makefile
2 --- lzma432/C/7zip/Compress/LZMA_Lib/makefile 1970-01-01 01:00:00.000000000 +0100
3 +++ lzma432-owrt/C/7zip/Compress/LZMA_Lib/makefile 2006-03-22 14:23:38.000000000 +0100
23 + CommandLineParser.o \
34 + $(AR) r $(PROG) $(OBJS)
37 + $(CXX) $(CFLAGS) ZLib.cpp
39 +LZMADecoder.o: ../LZMA/LZMADecoder.cpp
40 + $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
42 +LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
43 + $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
45 +LZInWindow.o: ../LZ/LZInWindow.cpp
46 + $(CXX) $(CFLAGS) ../LZ/LZInWindow.cpp
48 +LZOutWindow.o: ../LZ/LZOutWindow.cpp
49 + $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
51 +RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
52 + $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp
54 +InBuffer.o: ../../Common/InBuffer.cpp
55 + $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
57 +OutBuffer.o: ../../Common/OutBuffer.cpp
58 + $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
60 +FileStreams.o: ../../Common/FileStreams.cpp
61 + $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
63 +Alloc.o: ../../../Common/Alloc.cpp
64 + $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp
66 +C_FileIO.o: ../../../Common/C_FileIO.cpp
67 + $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp
69 +CommandLineParser.o: ../../../Common/CommandLineParser.cpp
70 + $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp
72 +CRC.o: ../../../Common/CRC.cpp
73 + $(CXX) $(CFLAGS) ../../../Common/CRC.cpp
75 +MyWindows.o: ../../../Common/MyWindows.cpp
76 + $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
78 +String.o: ../../../Common/String.cpp
79 + $(CXX) $(CFLAGS) ../../../Common/String.cpp
81 +StringConvert.o: ../../../Common/StringConvert.cpp
82 + $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp
84 +StringToInt.o: ../../../Common/StringToInt.cpp
85 + $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp
87 +Vector.o: ../../../Common/Vector.cpp
88 + $(CXX) $(CFLAGS) ../../../Common/Vector.cpp
91 + -$(RM) $(PROG) $(OBJS)
93 diff -Nur lzma432/C/7zip/Compress/LZMA_Lib/ZLib.cpp lzma432-owrt/C/7zip/Compress/LZMA_Lib/ZLib.cpp
94 --- lzma432/C/7zip/Compress/LZMA_Lib/ZLib.cpp 1970-01-01 01:00:00.000000000 +0100
95 +++ lzma432-owrt/C/7zip/Compress/LZMA_Lib/ZLib.cpp 2006-03-22 14:23:38.000000000 +0100
98 + * lzma zlib simplified wrapper
100 + * Copyright (c) 2005 Oleg I. Vdovikin <oleg@cs.msu.su>
101 + * Modified for LZMA 4.27 SDK Craig.Peacock@beyondlogic.org
103 + * This library is free software; you can redistribute
104 + * it and/or modify it under the terms of the GNU Lesser
105 + * General Public License as published by the Free Software
106 + * Foundation; either version 2.1 of the License, or
107 + * (at your option) any later version.
109 + * This library is distributed in the hope that it will be
110 + * useful, but WITHOUT ANY WARRANTY; without even the implied
111 + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
112 + * PURPOSE. See the GNU Lesser General Public License
113 + * for more details.
115 + * You should have received a copy of the GNU Lesser General
116 + * Public License along with this library; if not, write to
117 + * the Free Software Foundation, Inc., 59 Temple Place,
118 + * Suite 330, Boston, MA 02111-1307 USA
122 + * default values for encoder/decoder used by wrapper
132 +#include <initguid.h>
137 +#include "../../../Common/MyWindows.h"
138 +#include "../LZMA/LZMADecoder.h"
139 +#include "../LZMA/LZMAEncoder.h"
141 +#define STG_E_SEEKERROR ((HRESULT)0x80030019L)
142 +#define STG_E_MEDIUMFULL ((HRESULT)0x80030070L)
144 +class CInMemoryStream:
146 + public IStreamGetSize,
147 + public CMyUnknownImp
150 + CInMemoryStream(const Bytef *data, UInt64 size) :
151 + m_data(data), m_size(size), m_offset(0) {}
153 + virtual ~CInMemoryStream() {}
155 + MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
157 + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize)
159 + if (size > m_size - m_offset)
160 + size = m_size - m_offset;
163 + memcpy(data, m_data + m_offset, size);
169 + *processedSize = size;
174 + STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize)
176 + return Read(data, size, processedSize);
179 + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
183 + if (seekOrigin == STREAM_SEEK_SET) _offset = offset;
184 + else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset;
185 + else if (seekOrigin == STREAM_SEEK_END) _offset = m_size;
186 + else return STG_E_INVALIDFUNCTION;
188 + if (_offset < 0 || _offset > m_size)
189 + return STG_E_SEEKERROR;
191 + m_offset = _offset;
194 + *newPosition = m_offset;
199 + STDMETHOD(GetSize)(UInt64 *size)
205 + const Bytef *m_data;
210 +class COutMemoryStream:
212 + public CMyUnknownImp
215 + COutMemoryStream(Bytef *data, UInt64 maxsize) :
216 + m_data(data), m_size(0), m_maxsize(maxsize), m_offset(0) {}
217 + virtual ~COutMemoryStream() {}
219 + MY_UNKNOWN_IMP1(IOutStream)
221 + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize)
223 + if (size > m_maxsize - m_offset)
224 + size = m_maxsize - m_offset;
227 + memcpy(m_data + m_offset, data, size);
232 + if (m_offset > m_size)
236 + *processedSize = size;
241 + STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize)
243 + return Write(data, size, processedSize);
246 + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
250 + if (seekOrigin == STREAM_SEEK_SET) _offset = offset;
251 + else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset;
252 + else if (seekOrigin == STREAM_SEEK_END) _offset = m_size;
253 + else return STG_E_INVALIDFUNCTION;
255 + if (_offset < 0 || _offset > m_maxsize)
256 + return STG_E_SEEKERROR;
258 + m_offset = _offset;
261 + *newPosition = m_offset;
266 + STDMETHOD(SetSize)(Int64 newSize)
268 + if ((UInt64)newSize > m_maxsize)
269 + return STG_E_MEDIUMFULL;
280 +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
281 + const Bytef *source, uLong sourceLen,
284 + CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
285 + CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
287 + COutMemoryStream *outStreamSpec = new COutMemoryStream(dest+4, (*destLen)-4);
288 + CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
290 + NCompress::NLZMA::CEncoder *encoderSpec =
291 + new NCompress::NLZMA::CEncoder;
292 + CMyComPtr<ICompressCoder> encoder = encoderSpec;
296 + NCoderPropID::kDictionarySize,
297 + NCoderPropID::kPosStateBits,
298 + NCoderPropID::kLitContextBits,
299 + NCoderPropID::kLitPosBits,
300 + NCoderPropID::kAlgorithm,
301 + NCoderPropID::kNumFastBytes,
302 + NCoderPropID::kMatchFinder,
303 + NCoderPropID::kEndMarker
305 + const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
307 + PROPVARIANT properties[kNumProps];
308 + for (int p = 0; p < 6; p++)
309 + properties[p].vt = VT_UI4;
310 + properties[0].ulVal = UInt32(1 << 15);
311 + properties[1].ulVal = UInt32(ZLIB_PB);
312 + properties[2].ulVal = UInt32(ZLIB_LC); // for normal files
313 + properties[3].ulVal = UInt32(ZLIB_LP); // for normal files
314 + properties[4].ulVal = UInt32(0);
315 + properties[5].ulVal = UInt32(0x28);
317 + properties[6].vt = VT_BSTR;
318 + properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4";
320 + properties[7].vt = VT_BOOL;
321 + properties[7].boolVal = VARIANT_TRUE;
323 + if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
324 + return Z_MEM_ERROR; // should not happen
326 + if (encoderSpec->WriteCoderProperties(outStream) != S_OK)
327 + return Z_MEM_ERROR;
329 + HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
330 + if (result == E_OUTOFMEMORY)
332 + return Z_MEM_ERROR;
334 + else if (result != S_OK)
336 + return Z_BUF_ERROR; // should not happen
340 + outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
341 + *destLen = fileSize;
343 + /* Copy size of uncompressed string into first four bytes */
344 + memcpy(dest, &sourceLen, 4);
349 +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
350 + const Bytef *source, uLong sourceLen))
352 + CInMemoryStream *inStreamSpec = new CInMemoryStream(source+9, sourceLen-9);
353 + CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
355 + COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
356 + CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
358 + NCompress::NLZMA::CDecoder *decoderSpec =
359 + new NCompress::NLZMA::CDecoder;
360 + CMyComPtr<ICompressCoder> decoder = decoderSpec;
362 + //if (decoderSpec->SetDecoderPropertiesRaw(ZLIB_LC,
363 + // ZLIB_LP, ZLIB_PB, (1 << 23)) != S_OK) return Z_DATA_ERROR;
365 + if (decoderSpec->SetDecoderProperties2(source+4, 5) != S_OK)
366 + return Z_DATA_ERROR;
368 + UInt64 fileSize = *destLen;
370 + if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
372 + return Z_DATA_ERROR;
375 + outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
376 + *destLen = fileSize;
380 diff -Nur lzma432/C/Common/CommandLineParser.h lzma432-owrt/C/Common/CommandLineParser.h
381 --- lzma432/C/Common/CommandLineParser.h 2005-03-07 17:03:46.000000000 +0100
382 +++ lzma432-owrt/C/Common/CommandLineParser.h 2006-03-22 14:23:38.000000000 +0100
384 #ifndef __COMMON_COMMANDLINEPARSER_H
385 #define __COMMON_COMMANDLINEPARSER_H
387 -#include "Common/String.h"
390 namespace NCommandLineParser {
392 diff -Nur lzma432/C/Common/StringConvert.h lzma432-owrt/C/Common/StringConvert.h
393 --- lzma432/C/Common/StringConvert.h 2005-09-16 10:19:44.000000000 +0200
394 +++ lzma432-owrt/C/Common/StringConvert.h 2006-03-22 14:23:38.000000000 +0100
396 #define __COMMON_STRINGCONVERT_H
398 #include "MyWindows.h"
399 -#include "Common/String.h"
403 UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP);
404 diff -Nur lzma432/C/Common/String.cpp lzma432-owrt/C/Common/String.cpp
405 --- lzma432/C/Common/String.cpp 2005-09-28 11:44:06.000000000 +0200
406 +++ lzma432-owrt/C/Common/String.cpp 2006-03-22 14:23:38.000000000 +0100
411 -#include "Common/String.h"