1 diff -ruN lzma427.orig/C/7zip/Compress/LZMA_Lib/makefile lzma427.mod/C/7zip/Compress/LZMA_Lib/makefile
2 --- lzma427.orig/C/7zip/Compress/LZMA_Lib/makefile 1970-01-01 09:30:00.000000000 +0930
3 +++ lzma427.mod/C/7zip/Compress/LZMA_Lib/makefile 2005-08-20 22:45:31.000000000 +0930
24 + CommandLineParser.o \
\r
35 + $(AR) r $(PROG) $(OBJS)
\r
38 + $(CXX) $(CFLAGS) ZLib.cpp
\r
40 +LZMADecoder.o: ../LZMA/LZMADecoder.cpp
\r
41 + $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
\r
43 +LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
\r
44 + $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
\r
46 +LZInWindow.o: ../LZ/LZInWindow.cpp
\r
47 + $(CXX) $(CFLAGS) ../LZ/LZInWindow.cpp
\r
49 +LZOutWindow.o: ../LZ/LZOutWindow.cpp
\r
50 + $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
\r
52 +RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
\r
53 + $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp
\r
55 +InBuffer.o: ../../Common/InBuffer.cpp
\r
56 + $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
\r
58 +OutBuffer.o: ../../Common/OutBuffer.cpp
\r
59 + $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
\r
61 +FileStreams.o: ../../Common/FileStreams.cpp
\r
62 + $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
\r
64 +StreamUtils.o: ../../Common/StreamUtils.cpp
65 + $(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
67 +Alloc.o: ../../../Common/Alloc.cpp
\r
68 + $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp
\r
70 +C_FileIO.o: ../../../Common/C_FileIO.cpp
\r
71 + $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp
\r
73 +CommandLineParser.o: ../../../Common/CommandLineParser.cpp
\r
74 + $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp
\r
76 +CRC.o: ../../../Common/CRC.cpp
\r
77 + $(CXX) $(CFLAGS) ../../../Common/CRC.cpp
\r
79 +MyWindows.o: ../../../Common/MyWindows.cpp
\r
80 + $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
\r
82 +String.o: ../../../Common/String.cpp
\r
83 + $(CXX) $(CFLAGS) ../../../Common/String.cpp
\r
85 +StringConvert.o: ../../../Common/StringConvert.cpp
\r
86 + $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp
\r
88 +StringToInt.o: ../../../Common/StringToInt.cpp
\r
89 + $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp
\r
91 +Vector.o: ../../../Common/Vector.cpp
\r
92 + $(CXX) $(CFLAGS) ../../../Common/Vector.cpp
\r
95 + -$(RM) $(PROG) $(OBJS)
\r
97 diff -ruN lzma427.orig/C/7zip/Compress/LZMA_Lib/ZLib.cpp lzma427.mod/C/7zip/Compress/LZMA_Lib/ZLib.cpp
98 --- lzma427.orig/C/7zip/Compress/LZMA_Lib/ZLib.cpp 1970-01-01 09:30:00.000000000 +0930
99 +++ lzma427.mod/C/7zip/Compress/LZMA_Lib/ZLib.cpp 2005-08-20 23:00:33.000000000 +0930
102 + * lzma zlib simplified wrapper
104 + * Copyright (c) 2005 Oleg I. Vdovikin <oleg@cs.msu.su>
106 + * This library is free software; you can redistribute
107 + * it and/or modify it under the terms of the GNU Lesser
108 + * General Public License as published by the Free Software
109 + * Foundation; either version 2.1 of the License, or
110 + * (at your option) any later version.
112 + * This library is distributed in the hope that it will be
113 + * useful, but WITHOUT ANY WARRANTY; without even the implied
114 + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
115 + * PURPOSE. See the GNU Lesser General Public License
116 + * for more details.
118 + * You should have received a copy of the GNU Lesser General
119 + * Public License along with this library; if not, write to
120 + * the Free Software Foundation, Inc., 59 Temple Place,
121 + * Suite 330, Boston, MA 02111-1307 USA
125 + * default values for encoder/decoder used by wrapper
127 +#include "lzmalib.h"
134 +#include <initguid.h>
139 +#include "../../../Common/MyWindows.h"
140 +#include "../../Common/StreamUtils.h"
141 +#include "../LZMA/LZMADecoder.h"
142 +#include "../LZMA/LZMAEncoder.h"
144 +#define STG_E_SEEKERROR ((HRESULT)0x80030019L)
145 +#define STG_E_MEDIUMFULL ((HRESULT)0x80030070L)
147 +class CInMemoryStream:
149 + public IStreamGetSize,
150 + public CMyUnknownImp
153 + CInMemoryStream(const Bytef *data, UInt64 size) :
154 + m_data(data), m_size(size), m_offset(0) {}
156 + virtual ~CInMemoryStream() {}
158 + MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
160 + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize)
162 + if (size > m_size - m_offset)
163 + size = m_size - m_offset;
166 + memcpy(data, m_data + m_offset, size);
172 + *processedSize = size;
177 + STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize)
179 + return Read(data, size, processedSize);
182 + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
186 + if (seekOrigin == STREAM_SEEK_SET) _offset = offset;
187 + else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset;
188 + else if (seekOrigin == STREAM_SEEK_END) _offset = m_size;
189 + else return STG_E_INVALIDFUNCTION;
191 + if (_offset > m_size)
192 + return STG_E_SEEKERROR;
194 + m_offset = _offset;
197 + *newPosition = m_offset;
202 + STDMETHOD(GetSize)(UInt64 *size)
208 + const Bytef *m_data;
213 +class COutMemoryStream:
215 + public CMyUnknownImp
218 + COutMemoryStream(Bytef *data, UInt64 maxsize) :
219 + m_data(data), m_size(0), m_maxsize(maxsize), m_offset(0) {}
220 + virtual ~COutMemoryStream() {}
222 + MY_UNKNOWN_IMP1(IOutStream)
224 + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize)
226 + if (size > m_maxsize - m_offset)
227 + size = m_maxsize - m_offset;
230 + memcpy(m_data + m_offset, data, size);
235 + if (m_offset > m_size)
239 + *processedSize = size;
244 + STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize)
246 + return Write(data, size, processedSize);
249 + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
253 + if (seekOrigin == STREAM_SEEK_SET) _offset = offset;
254 + else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset;
255 + else if (seekOrigin == STREAM_SEEK_END) _offset = m_size;
256 + else return STG_E_INVALIDFUNCTION;
258 + if (_offset > m_maxsize)
259 + return STG_E_SEEKERROR;
261 + m_offset = _offset;
264 + *newPosition = m_offset;
269 + STDMETHOD(SetSize)(Int64 newSize)
271 + if ((UInt64)newSize > m_maxsize)
272 + return STG_E_MEDIUMFULL;
283 +ZEXTERN int ZEXPORT lzma_compress OF((Bytef *dest, uLongf *destLen,
284 + const Bytef *source, uLong sourceLen,
287 + CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
288 + CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
290 + COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
291 + CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
293 + NCompress::NLZMA::CEncoder *encoderSpec =
294 + new NCompress::NLZMA::CEncoder;
295 + CMyComPtr<ICompressCoder> encoder = encoderSpec;
299 + NCoderPropID::kDictionarySize,
300 + NCoderPropID::kPosStateBits,
301 + NCoderPropID::kLitContextBits,
302 + NCoderPropID::kLitPosBits,
303 + NCoderPropID::kAlgorithm,
304 + NCoderPropID::kNumFastBytes,
305 + NCoderPropID::kMatchFinder,
306 + NCoderPropID::kEndMarker
308 + const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
310 + PROPVARIANT properties[kNumProps];
311 + for (int p = 0; p < 6; p++)
312 + properties[p].vt = VT_UI4;
313 + properties[0].ulVal = UInt32(1 << (level + 14));
314 + properties[1].ulVal = UInt32(ZLIB_PB);
315 + properties[2].ulVal = UInt32(ZLIB_LC); // for normal files
316 + properties[3].ulVal = UInt32(ZLIB_LP); // for normal files
317 + properties[4].ulVal = UInt32(2);
318 + properties[5].ulVal = UInt32(128);
320 + properties[6].vt = VT_BSTR;
321 + properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4";
323 + properties[7].vt = VT_BOOL;
324 + properties[7].boolVal = VARIANT_TRUE;
326 + if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
327 + return Z_MEM_ERROR; // should not happen
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;
346 +ZEXTERN int ZEXPORT lzma_uncompress OF((Bytef *dest, uLongf *destLen,
347 + const Bytef *source, uLong sourceLen))
349 + CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
350 + CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
352 + COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
353 + CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
355 + NCompress::NLZMA::CDecoder *decoderSpec =
356 + new NCompress::NLZMA::CDecoder;
357 + CMyComPtr<ICompressCoder> decoder = decoderSpec;
359 + if (decoderSpec->SetDecoderPropertiesRaw(ZLIB_LC,
360 + ZLIB_LP, ZLIB_PB, (1 << 23)) != S_OK) return Z_DATA_ERROR;
362 + UInt64 fileSize = *destLen;
364 + if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
366 + return Z_DATA_ERROR;
369 + outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
370 + *destLen = fileSize;
374 diff -ruN lzma427.orig/C/Common/CommandLineParser.h lzma427.mod/C/Common/CommandLineParser.h
375 --- lzma427.orig/C/Common/CommandLineParser.h 2005-03-08 01:33:46.000000000 +1030
376 +++ lzma427.mod/C/Common/CommandLineParser.h 2005-08-20 22:52:04.000000000 +0930
378 #ifndef __COMMON_COMMANDLINEPARSER_H
\r
379 #define __COMMON_COMMANDLINEPARSER_H
\r
381 -#include "Common/String.h"
\r
382 +#include "String.h"
\r
384 namespace NCommandLineParser {
\r
386 diff -ruN lzma427.orig/C/Common/StringConvert.h lzma427.mod/C/Common/StringConvert.h
387 --- lzma427.orig/C/Common/StringConvert.h 2005-03-08 01:34:24.000000000 +1030
388 +++ lzma427.mod/C/Common/StringConvert.h 2005-08-20 22:53:38.000000000 +0930
390 #define __COMMON_STRINGCONVERT_H
\r
392 #include "MyWindows.h"
\r
393 -#include "Common/String.h"
\r
394 +#include "String.h"
\r
397 UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP);
\r
398 diff -ruN lzma427.orig/C/Common/String.cpp lzma427.mod/C/Common/String.cpp
399 --- lzma427.orig/C/Common/String.cpp 2005-03-08 01:33:46.000000000 +1030
400 +++ lzma427.mod/C/Common/String.cpp 2005-08-20 22:53:19.000000000 +0930
405 -#include "Common/String.h"
\r
406 +#include "String.h"
\r