Serhiy Storchaka | 98c779e | 2014-01-25 14:02:29 +0200 | [diff] [blame] | 1 | /*[clinic input] |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 2 | preserve |
Serhiy Storchaka | 98c779e | 2014-01-25 14:02:29 +0200 | [diff] [blame] | 3 | [clinic start generated code]*/ |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 4 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 5 | PyDoc_STRVAR(_lzma_LZMACompressor_compress__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 6 | "compress($self, data, /)\n" |
| 7 | "--\n" |
| 8 | "\n" |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 9 | "Provide data to the compressor object.\n" |
| 10 | "\n" |
| 11 | "Returns a chunk of compressed data if possible, or b\'\' otherwise.\n" |
| 12 | "\n" |
| 13 | "When you have finished providing data to the compressor, call the\n" |
| 14 | "flush() method to finish the compression process."); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 15 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 16 | #define _LZMA_LZMACOMPRESSOR_COMPRESS_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 17 | {"compress", (PyCFunction)_lzma_LZMACompressor_compress, METH_O, _lzma_LZMACompressor_compress__doc__}, |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 18 | |
| 19 | static PyObject * |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 20 | _lzma_LZMACompressor_compress_impl(Compressor *self, Py_buffer *data); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 21 | |
Nadeem Vawda | 3797065 | 2013-10-28 21:35:23 +0100 | [diff] [blame] | 22 | static PyObject * |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 23 | _lzma_LZMACompressor_compress(Compressor *self, PyObject *arg) |
Nadeem Vawda | 3797065 | 2013-10-28 21:35:23 +0100 | [diff] [blame] | 24 | { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 25 | PyObject *return_value = NULL; |
| 26 | Py_buffer data = {NULL, NULL}; |
| 27 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame^] | 28 | if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { |
| 29 | goto exit; |
| 30 | } |
| 31 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
| 32 | _PyArg_BadArgument("compress", "contiguous buffer", arg); |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 33 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 34 | } |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 35 | return_value = _lzma_LZMACompressor_compress_impl(self, &data); |
| 36 | |
| 37 | exit: |
| 38 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 39 | if (data.obj) { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 40 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 41 | } |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 42 | |
| 43 | return return_value; |
Nadeem Vawda | 3797065 | 2013-10-28 21:35:23 +0100 | [diff] [blame] | 44 | } |
| 45 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 46 | PyDoc_STRVAR(_lzma_LZMACompressor_flush__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 47 | "flush($self, /)\n" |
| 48 | "--\n" |
| 49 | "\n" |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 50 | "Finish the compression process.\n" |
| 51 | "\n" |
| 52 | "Returns the compressed data left in internal buffers.\n" |
| 53 | "\n" |
| 54 | "The compressor object may not be used after this method is called."); |
| 55 | |
| 56 | #define _LZMA_LZMACOMPRESSOR_FLUSH_METHODDEF \ |
| 57 | {"flush", (PyCFunction)_lzma_LZMACompressor_flush, METH_NOARGS, _lzma_LZMACompressor_flush__doc__}, |
| 58 | |
| 59 | static PyObject * |
| 60 | _lzma_LZMACompressor_flush_impl(Compressor *self); |
| 61 | |
| 62 | static PyObject * |
| 63 | _lzma_LZMACompressor_flush(Compressor *self, PyObject *Py_UNUSED(ignored)) |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 64 | { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 65 | return _lzma_LZMACompressor_flush_impl(self); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 66 | } |
| 67 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 68 | PyDoc_STRVAR(_lzma_LZMADecompressor_decompress__doc__, |
Antoine Pitrou | 26795ba | 2015-01-17 16:22:18 +0100 | [diff] [blame] | 69 | "decompress($self, /, data, max_length=-1)\n" |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 70 | "--\n" |
| 71 | "\n" |
Serhiy Storchaka | 79d8f3f | 2015-02-20 12:46:11 +0200 | [diff] [blame] | 72 | "Decompress *data*, returning uncompressed data as bytes.\n" |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 73 | "\n" |
Antoine Pitrou | 26795ba | 2015-01-17 16:22:18 +0100 | [diff] [blame] | 74 | "If *max_length* is nonnegative, returns at most *max_length* bytes of\n" |
| 75 | "decompressed data. If this limit is reached and further output can be\n" |
| 76 | "produced, *self.needs_input* will be set to ``False``. In this case, the next\n" |
| 77 | "call to *decompress()* may provide *data* as b\'\' to obtain more of the output.\n" |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 78 | "\n" |
Antoine Pitrou | 26795ba | 2015-01-17 16:22:18 +0100 | [diff] [blame] | 79 | "If all of the input data was decompressed and returned (either because this\n" |
| 80 | "was less than *max_length* bytes, or because *max_length* was negative),\n" |
| 81 | "*self.needs_input* will be set to True.\n" |
| 82 | "\n" |
| 83 | "Attempting to decompress data after the end of stream is reached raises an\n" |
| 84 | "EOFError. Any data found after the end of the stream is ignored and saved in\n" |
| 85 | "the unused_data attribute."); |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 86 | |
| 87 | #define _LZMA_LZMADECOMPRESSOR_DECOMPRESS_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 88 | {"decompress", (PyCFunction)(void(*)(void))_lzma_LZMADecompressor_decompress, METH_FASTCALL|METH_KEYWORDS, _lzma_LZMADecompressor_decompress__doc__}, |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 89 | |
| 90 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 91 | _lzma_LZMADecompressor_decompress_impl(Decompressor *self, Py_buffer *data, |
| 92 | Py_ssize_t max_length); |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 93 | |
| 94 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 95 | _lzma_LZMADecompressor_decompress(Decompressor *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 96 | { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 97 | PyObject *return_value = NULL; |
Serhiy Storchaka | 9171a8b | 2016-08-14 10:52:18 +0300 | [diff] [blame] | 98 | static const char * const _keywords[] = {"data", "max_length", NULL}; |
| 99 | static _PyArg_Parser _parser = {"y*|n:decompress", _keywords, 0}; |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 100 | Py_buffer data = {NULL, NULL}; |
Antoine Pitrou | 26795ba | 2015-01-17 16:22:18 +0100 | [diff] [blame] | 101 | Py_ssize_t max_length = -1; |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 102 | |
Victor Stinner | 3e1fad6 | 2017-01-17 01:29:01 +0100 | [diff] [blame] | 103 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 104 | &data, &max_length)) { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 105 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 106 | } |
Antoine Pitrou | 26795ba | 2015-01-17 16:22:18 +0100 | [diff] [blame] | 107 | return_value = _lzma_LZMADecompressor_decompress_impl(self, &data, max_length); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 108 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 109 | exit: |
| 110 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 111 | if (data.obj) { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 112 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 113 | } |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 114 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 115 | return return_value; |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 116 | } |
| 117 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 118 | PyDoc_STRVAR(_lzma_LZMADecompressor___init____doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 119 | "LZMADecompressor(format=FORMAT_AUTO, memlimit=None, filters=None)\n" |
| 120 | "--\n" |
| 121 | "\n" |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 122 | "Create a decompressor object for decompressing data incrementally.\n" |
| 123 | "\n" |
| 124 | " format\n" |
| 125 | " Specifies the container format of the input stream. If this is\n" |
| 126 | " FORMAT_AUTO (the default), the decompressor will automatically detect\n" |
| 127 | " whether the input is FORMAT_XZ or FORMAT_ALONE. Streams created with\n" |
| 128 | " FORMAT_RAW cannot be autodetected.\n" |
| 129 | " memlimit\n" |
| 130 | " Limit the amount of memory used by the decompressor. This will cause\n" |
| 131 | " decompression to fail if the input cannot be decompressed within the\n" |
| 132 | " given limit.\n" |
| 133 | " filters\n" |
| 134 | " A custom filter chain. This argument is required for FORMAT_RAW, and\n" |
| 135 | " not accepted with any other format. When provided, this should be a\n" |
| 136 | " sequence of dicts, each indicating the ID and options for a single\n" |
| 137 | " filter.\n" |
| 138 | "\n" |
| 139 | "For one-shot decompression, use the decompress() function instead."); |
| 140 | |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 141 | static int |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 142 | _lzma_LZMADecompressor___init___impl(Decompressor *self, int format, |
| 143 | PyObject *memlimit, PyObject *filters); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 144 | |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 145 | static int |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 146 | _lzma_LZMADecompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 147 | { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 148 | int return_value = -1; |
Serhiy Storchaka | 9171a8b | 2016-08-14 10:52:18 +0300 | [diff] [blame] | 149 | static const char * const _keywords[] = {"format", "memlimit", "filters", NULL}; |
| 150 | static _PyArg_Parser _parser = {"|iOO:LZMADecompressor", _keywords, 0}; |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 151 | int format = FORMAT_AUTO; |
| 152 | PyObject *memlimit = Py_None; |
| 153 | PyObject *filters = Py_None; |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 154 | |
Serhiy Storchaka | 9171a8b | 2016-08-14 10:52:18 +0300 | [diff] [blame] | 155 | if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 156 | &format, &memlimit, &filters)) { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 157 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 158 | } |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 159 | return_value = _lzma_LZMADecompressor___init___impl((Decompressor *)self, format, memlimit, filters); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 160 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 161 | exit: |
| 162 | return return_value; |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 163 | } |
| 164 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 165 | PyDoc_STRVAR(_lzma_is_check_supported__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 166 | "is_check_supported($module, check_id, /)\n" |
| 167 | "--\n" |
| 168 | "\n" |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 169 | "Test whether the given integrity check is supported.\n" |
| 170 | "\n" |
| 171 | "Always returns True for CHECK_NONE and CHECK_CRC32."); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 172 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 173 | #define _LZMA_IS_CHECK_SUPPORTED_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 174 | {"is_check_supported", (PyCFunction)_lzma_is_check_supported, METH_O, _lzma_is_check_supported__doc__}, |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 175 | |
| 176 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 177 | _lzma_is_check_supported_impl(PyObject *module, int check_id); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 178 | |
| 179 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 180 | _lzma_is_check_supported(PyObject *module, PyObject *arg) |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 181 | { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 182 | PyObject *return_value = NULL; |
| 183 | int check_id; |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 184 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame^] | 185 | if (PyFloat_Check(arg)) { |
| 186 | PyErr_SetString(PyExc_TypeError, |
| 187 | "integer argument expected, got float" ); |
| 188 | goto exit; |
| 189 | } |
| 190 | check_id = _PyLong_AsInt(arg); |
| 191 | if (check_id == -1 && PyErr_Occurred()) { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 192 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 193 | } |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 194 | return_value = _lzma_is_check_supported_impl(module, check_id); |
| 195 | |
| 196 | exit: |
| 197 | return return_value; |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 198 | } |
| 199 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 200 | PyDoc_STRVAR(_lzma__encode_filter_properties__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 201 | "_encode_filter_properties($module, filter, /)\n" |
| 202 | "--\n" |
| 203 | "\n" |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 204 | "Return a bytes object encoding the options (properties) of the filter specified by *filter* (a dict).\n" |
| 205 | "\n" |
| 206 | "The result does not include the filter ID itself, only the options."); |
| 207 | |
| 208 | #define _LZMA__ENCODE_FILTER_PROPERTIES_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 209 | {"_encode_filter_properties", (PyCFunction)_lzma__encode_filter_properties, METH_O, _lzma__encode_filter_properties__doc__}, |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 210 | |
Nadeem Vawda | 3797065 | 2013-10-28 21:35:23 +0100 | [diff] [blame] | 211 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 212 | _lzma__encode_filter_properties_impl(PyObject *module, lzma_filter filter); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 213 | |
| 214 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 215 | _lzma__encode_filter_properties(PyObject *module, PyObject *arg) |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 216 | { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 217 | PyObject *return_value = NULL; |
| 218 | lzma_filter filter = {LZMA_VLI_UNKNOWN, NULL}; |
| 219 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame^] | 220 | if (!lzma_filter_converter(arg, &filter)) { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 221 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 222 | } |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 223 | return_value = _lzma__encode_filter_properties_impl(module, filter); |
| 224 | |
| 225 | exit: |
| 226 | /* Cleanup for filter */ |
| 227 | if (filter.id != LZMA_VLI_UNKNOWN) |
| 228 | PyMem_Free(filter.options); |
| 229 | |
| 230 | return return_value; |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 231 | } |
| 232 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 233 | PyDoc_STRVAR(_lzma__decode_filter_properties__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 234 | "_decode_filter_properties($module, filter_id, encoded_props, /)\n" |
| 235 | "--\n" |
| 236 | "\n" |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 237 | "Return a bytes object encoding the options (properties) of the filter specified by *filter* (a dict).\n" |
| 238 | "\n" |
| 239 | "The result does not include the filter ID itself, only the options."); |
Nadeem Vawda | 3ff069e | 2011-11-30 00:25:06 +0200 | [diff] [blame] | 240 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 241 | #define _LZMA__DECODE_FILTER_PROPERTIES_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 242 | {"_decode_filter_properties", (PyCFunction)(void(*)(void))_lzma__decode_filter_properties, METH_FASTCALL, _lzma__decode_filter_properties__doc__}, |
Nadeem Vawda | f55b329 | 2012-05-06 23:01:27 +0200 | [diff] [blame] | 243 | |
| 244 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 245 | _lzma__decode_filter_properties_impl(PyObject *module, lzma_vli filter_id, |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 246 | Py_buffer *encoded_props); |
Nadeem Vawda | f55b329 | 2012-05-06 23:01:27 +0200 | [diff] [blame] | 247 | |
| 248 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 249 | _lzma__decode_filter_properties(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
Nadeem Vawda | f55b329 | 2012-05-06 23:01:27 +0200 | [diff] [blame] | 250 | { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 251 | PyObject *return_value = NULL; |
| 252 | lzma_vli filter_id; |
| 253 | Py_buffer encoded_props = {NULL, NULL}; |
Nadeem Vawda | f55b329 | 2012-05-06 23:01:27 +0200 | [diff] [blame] | 254 | |
Sylvain | 7445381 | 2017-06-10 06:51:48 +0200 | [diff] [blame] | 255 | if (!_PyArg_ParseStack(args, nargs, "O&y*:_decode_filter_properties", |
| 256 | lzma_vli_converter, &filter_id, &encoded_props)) { |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 257 | goto exit; |
| 258 | } |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 259 | return_value = _lzma__decode_filter_properties_impl(module, filter_id, &encoded_props); |
Nadeem Vawda | f55b329 | 2012-05-06 23:01:27 +0200 | [diff] [blame] | 260 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 261 | exit: |
| 262 | /* Cleanup for encoded_props */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 263 | if (encoded_props.obj) { |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 264 | PyBuffer_Release(&encoded_props); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 265 | } |
Nadeem Vawda | f55b329 | 2012-05-06 23:01:27 +0200 | [diff] [blame] | 266 | |
Larry Hastings | f256c22 | 2014-01-25 21:30:37 -0800 | [diff] [blame] | 267 | return return_value; |
Nadeem Vawda | f55b329 | 2012-05-06 23:01:27 +0200 | [diff] [blame] | 268 | } |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame^] | 269 | /*[clinic end generated code: output=df061bfc2067a90a input=a9049054013a1b77]*/ |