]> git.pld-linux.org Git - packages/xz.git/blob - lzma427_zlib.patch
- License is basically LGPL v2.1+;
[packages/xz.git] / lzma427_zlib.patch
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
4 @@ -0,0 +1,88 @@
5 +PROG = liblzma.a\r
6 +CXX = g++ -O3 -Wall\r
7 +AR = ar
8 +RM = rm -f\r
9 +CFLAGS = -c\r
10 +\r
11 +OBJS = \\r
12 +  ZLib.o \\r
13 +  LZMADecoder.o \\r
14 +  LZMAEncoder.o \\r
15 +  LZInWindow.o \\r
16 +  LZOutWindow.o \\r
17 +  RangeCoderBit.o \\r
18 +  InBuffer.o \\r
19 +  OutBuffer.o \\r
20 +  FileStreams.o \\r
21 +  StreamUtils.o \
22 +  Alloc.o \\r
23 +  C_FileIO.o \\r
24 +  CommandLineParser.o \\r
25 +  CRC.o \\r
26 +  String.o \\r
27 +  StringConvert.o \\r
28 +  StringToInt.o \\r
29 +  Vector.o \\r
30 +\r
31 +\r
32 +all: $(PROG)\r
33 +\r
34 +$(PROG): $(OBJS)\r
35 +       $(AR) r $(PROG) $(OBJS)\r
36 +\r
37 +ZLib.o: ZLib.cpp\r
38 +       $(CXX) $(CFLAGS) ZLib.cpp\r
39 +\r
40 +LZMADecoder.o: ../LZMA/LZMADecoder.cpp\r
41 +       $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp\r
42 +\r
43 +LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp\r
44 +       $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp\r
45 +\r
46 +LZInWindow.o: ../LZ/LZInWindow.cpp\r
47 +       $(CXX) $(CFLAGS) ../LZ/LZInWindow.cpp\r
48 +\r
49 +LZOutWindow.o: ../LZ/LZOutWindow.cpp\r
50 +       $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp\r
51 +\r
52 +RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp\r
53 +       $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp\r
54 +\r
55 +InBuffer.o: ../../Common/InBuffer.cpp\r
56 +       $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp\r
57 +\r
58 +OutBuffer.o: ../../Common/OutBuffer.cpp\r
59 +       $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp\r
60 +\r
61 +FileStreams.o: ../../Common/FileStreams.cpp\r
62 +       $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp\r
63 +
64 +StreamUtils.o: ../../Common/StreamUtils.cpp
65 +       $(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
66 +\r
67 +Alloc.o: ../../../Common/Alloc.cpp\r
68 +       $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp\r
69 +\r
70 +C_FileIO.o: ../../../Common/C_FileIO.cpp\r
71 +       $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp\r
72 +\r
73 +CommandLineParser.o: ../../../Common/CommandLineParser.cpp\r
74 +       $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp\r
75 +\r
76 +CRC.o: ../../../Common/CRC.cpp\r
77 +       $(CXX) $(CFLAGS) ../../../Common/CRC.cpp\r
78 +\r
79 +MyWindows.o: ../../../Common/MyWindows.cpp\r
80 +       $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp\r
81 +\r
82 +String.o: ../../../Common/String.cpp\r
83 +       $(CXX) $(CFLAGS) ../../../Common/String.cpp\r
84 +\r
85 +StringConvert.o: ../../../Common/StringConvert.cpp\r
86 +       $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp\r
87 +\r
88 +StringToInt.o: ../../../Common/StringToInt.cpp\r
89 +       $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp\r
90 +\r
91 +Vector.o: ../../../Common/Vector.cpp\r
92 +       $(CXX) $(CFLAGS) ../../../Common/Vector.cpp\r
93 +\r
94 +clean:\r
95 +       -$(RM) $(PROG) $(OBJS)\r
96 +\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
100 @@ -0,0 +1,273 @@
101 +/*
102 + * lzma zlib simplified wrapper
103 + *
104 + * Copyright (c) 2005 Oleg I. Vdovikin <oleg@cs.msu.su>
105 + *
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.
111 + *
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.
117 + *
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
122 + */
123 +
124 +/*
125 + * default values for encoder/decoder used by wrapper
126 + */
127 +#include "lzmalib.h"
128 +
129 +#define ZLIB_LC 3
130 +#define ZLIB_LP 0
131 +#define ZLIB_PB 2
132 +
133 +#ifdef WIN32
134 +#include <initguid.h>
135 +#else
136 +#define INITGUID
137 +#endif
138 +
139 +#include "../../../Common/MyWindows.h"
140 +#include "../../Common/StreamUtils.h"
141 +#include "../LZMA/LZMADecoder.h"
142 +#include "../LZMA/LZMAEncoder.h"
143 +
144 +#define STG_E_SEEKERROR                  ((HRESULT)0x80030019L)
145 +#define STG_E_MEDIUMFULL                 ((HRESULT)0x80030070L)
146 +
147 +class CInMemoryStream:
148 +  public IInStream,
149 +  public IStreamGetSize,
150 +  public CMyUnknownImp
151 +{
152 +public:
153 +  CInMemoryStream(const Bytef *data, UInt64 size) :
154 +         m_data(data), m_size(size), m_offset(0) {}
155 +
156 +  virtual ~CInMemoryStream() {}
157 +
158 +  MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
159 +
160 +  STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize)
161 +  {
162 +         if (size > m_size - m_offset)
163 +                 size = m_size - m_offset;
164 +
165 +         if (size) {
166 +                 memcpy(data, m_data + m_offset, size);
167 +         }
168 +
169 +         m_offset += size;
170 +
171 +         if (processedSize)
172 +                 *processedSize = size;
173 +
174 +         return S_OK;
175 +  }
176 +
177 +  STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize)
178 +  {
179 +       return Read(data, size, processedSize);
180 +  }
181 +
182 +  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
183 +  {
184 +         UInt64 _offset;
185 +
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;
190 +
191 +         if (_offset > m_size)
192 +                 return STG_E_SEEKERROR;
193 +
194 +         m_offset = _offset;
195 +
196 +         if (newPosition)
197 +                 *newPosition = m_offset;
198 +
199 +         return S_OK;
200 +  }
201 +
202 +  STDMETHOD(GetSize)(UInt64 *size)
203 +  {
204 +         *size = m_size;
205 +         return S_OK;
206 +  }
207 +protected:
208 +       const Bytef *m_data;
209 +       UInt64 m_size;
210 +       UInt64 m_offset;
211 +};
212 +
213 +class COutMemoryStream:
214 +  public IOutStream,
215 +  public CMyUnknownImp
216 +{
217 +public:
218 +  COutMemoryStream(Bytef *data, UInt64 maxsize) :
219 +         m_data(data), m_size(0), m_maxsize(maxsize), m_offset(0) {}
220 +  virtual ~COutMemoryStream() {}
221 +
222 +  MY_UNKNOWN_IMP1(IOutStream)
223 +
224 +  STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize)
225 +  {
226 +         if (size > m_maxsize - m_offset)
227 +                 size = m_maxsize - m_offset;
228 +
229 +         if (size) {
230 +                 memcpy(m_data + m_offset, data, size);
231 +         }
232 +
233 +         m_offset += size;
234 +
235 +         if (m_offset > m_size)
236 +               m_size = m_offset;
237 +
238 +         if (processedSize)
239 +                 *processedSize = size;
240 +
241 +         return S_OK;
242 +  }
243 +
244 +  STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize)
245 +  {
246 +         return Write(data, size, processedSize);
247 +  }
248 +
249 +  STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
250 +  {
251 +         UInt64 _offset;
252 +
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;
257 +
258 +         if (_offset > m_maxsize)
259 +                 return STG_E_SEEKERROR;
260 +
261 +         m_offset = _offset;
262 +
263 +         if (newPosition)
264 +                 *newPosition = m_offset;
265 +
266 +         return S_OK;
267 +  }
268 +
269 +  STDMETHOD(SetSize)(Int64 newSize)
270 +  {
271 +         if ((UInt64)newSize > m_maxsize)
272 +                 return STG_E_MEDIUMFULL;
273 +
274 +         return S_OK;
275 +  }
276 +protected:
277 +       Bytef *m_data;
278 +       UInt64 m_size;
279 +       UInt64 m_maxsize;
280 +       UInt64 m_offset;
281 +};
282 +
283 +ZEXTERN int ZEXPORT lzma_compress OF((Bytef *dest,   uLongf *destLen,
284 +                                  const Bytef *source, uLong sourceLen,
285 +                                  int level))
286 +{
287 +       CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
288 +       CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
289 +
290 +       COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
291 +       CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
292 +
293 +       NCompress::NLZMA::CEncoder *encoderSpec =
294 +               new NCompress::NLZMA::CEncoder;
295 +       CMyComPtr<ICompressCoder> encoder = encoderSpec;
296 +
297 +       PROPID propIDs[] =
298 +       {
299 +               NCoderPropID::kDictionarySize,
300 +               NCoderPropID::kPosStateBits,
301 +               NCoderPropID::kLitContextBits,
302 +               NCoderPropID::kLitPosBits,
303 +               NCoderPropID::kAlgorithm,
304 +               NCoderPropID::kNumFastBytes,
305 +               NCoderPropID::kMatchFinder,
306 +               NCoderPropID::kEndMarker
307 +       };
308 +       const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
309 +
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);
319 +
320 +       properties[6].vt = VT_BSTR;
321 +       properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4";
322 +
323 +       properties[7].vt = VT_BOOL;
324 +       properties[7].boolVal = VARIANT_TRUE;
325 +
326 +       if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
327 +               return Z_MEM_ERROR; // should not happen
328 +
329 +       HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
330 +       if (result == E_OUTOFMEMORY)
331 +       {
332 +               return Z_MEM_ERROR;
333 +       }
334 +       else if (result != S_OK)
335 +       {
336 +               return Z_BUF_ERROR;     // should not happen
337 +       }
338 +
339 +       UInt64 fileSize;
340 +       outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
341 +       *destLen = fileSize;
342 +
343 +       return Z_OK;
344 +}
345 +
346 +ZEXTERN int ZEXPORT lzma_uncompress OF((Bytef *dest,   uLongf *destLen,
347 +                                   const Bytef *source, uLong sourceLen))
348 +{
349 +       CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
350 +       CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
351 +
352 +       COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
353 +       CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
354 +
355 +       NCompress::NLZMA::CDecoder *decoderSpec =
356 +               new NCompress::NLZMA::CDecoder;
357 +       CMyComPtr<ICompressCoder> decoder = decoderSpec;
358 +
359 +       if (decoderSpec->SetDecoderPropertiesRaw(ZLIB_LC,
360 +               ZLIB_LP, ZLIB_PB, (1 << 23)) != S_OK) return Z_DATA_ERROR;
361 +
362 +       UInt64 fileSize = *destLen;
363 +
364 +       if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
365 +       {
366 +               return Z_DATA_ERROR;
367 +       }
368 +
369 +       outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
370 +       *destLen = fileSize;
371 +
372 +       return Z_OK;
373 +}
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
377 @@ -3,7 +3,7 @@
378  #ifndef __COMMON_COMMANDLINEPARSER_H\r
379  #define __COMMON_COMMANDLINEPARSER_H\r
380  \r
381 -#include "Common/String.h"\r
382 +#include "String.h"\r
383  \r
384  namespace NCommandLineParser {\r
385  \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
389 @@ -4,7 +4,7 @@
390  #define __COMMON_STRINGCONVERT_H\r
391  \r
392  #include "MyWindows.h"\r
393 -#include "Common/String.h"\r
394 +#include "String.h"\r
395  #include "Types.h"\r
396  \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
401 @@ -8,7 +8,7 @@
402  #include <ctype.h>\r
403  #endif\r
404  \r
405 -#include "Common/String.h"\r
406 +#include "String.h"\r
407  \r
408  \r
409  #ifdef _WIN32\r
This page took 0.092825 seconds and 3 git commands to generate.