30
30
#include "../sdk/C/Aes.h"
31
31
#include "../sdk/C/Bra.h"
32
32
#include "../sdk/C/Bcj2.h"
33
+ #include "../sdk/C/Delta.h"
33
34
34
35
#include "pylzma.h"
35
36
#include "pylzma_compress.h"
@@ -269,6 +270,46 @@ pylzma_bcj2_decode(PyObject *self, PyObject *args)
269
270
return NULL ;
270
271
}
271
272
273
+ const char
274
+ doc_delta_decode [] =
275
+ "delta_decode(data, delta) -- Decode Delta streams." ;
276
+
277
+ static PyObject *
278
+ pylzma_delta_decode (PyObject * self , PyObject * args )
279
+ {
280
+ char * data ;
281
+ PARSE_LENGTH_TYPE length ;
282
+ unsigned int delta ;
283
+ Byte state [DELTA_STATE_SIZE ];
284
+ Byte * tmp ;
285
+ PyObject * result ;
286
+
287
+ if (!PyArg_ParseTuple (args , "s#I" , & data , & length , & delta )) {
288
+ return NULL ;
289
+ }
290
+
291
+ if (!delta ) {
292
+ PyErr_SetString (PyExc_TypeError , "delta must be non-zero" );
293
+ return NULL ;
294
+ }
295
+
296
+ if (!length ) {
297
+ return PyBytes_FromString ("" );
298
+ }
299
+
300
+ result = PyBytes_FromStringAndSize (data , length );
301
+ if (!result ) {
302
+ return NULL ;
303
+ }
304
+
305
+ Delta_Init (state );
306
+ tmp = (Byte * ) PyBytes_AS_STRING (result );
307
+ Py_BEGIN_ALLOW_THREADS
308
+ Delta_Decode (state , delta , tmp , length );
309
+ Py_END_ALLOW_THREADS
310
+ return result ;
311
+ }
312
+
272
313
PyMethodDef
273
314
methods [] = {
274
315
// exported functions
@@ -288,6 +329,8 @@ methods[] = {
288
329
{"bcj_sparc_convert" , (PyCFunction )pylzma_bcj_sparc_convert , METH_VARARGS , (char * )& doc_bcj_sparc_convert },
289
330
{"bcj_ia64_convert" , (PyCFunction )pylzma_bcj_ia64_convert , METH_VARARGS , (char * )& doc_bcj_ia64_convert },
290
331
{"bcj2_decode" , (PyCFunction )pylzma_bcj2_decode , METH_VARARGS , (char * )& doc_bcj2_decode },
332
+ // Delta
333
+ {"delta_decode" , (PyCFunction )pylzma_delta_decode , METH_VARARGS , (char * )& doc_delta_decode },
291
334
{NULL , NULL },
292
335
};
293
336
0 commit comments