1 | /*[clinic input] |
2 | preserve |
3 | [clinic start generated code]*/ |
4 | |
5 | PyDoc_STRVAR(zlib_compress__doc__, |
6 | "compress($module, data, /, level=Z_DEFAULT_COMPRESSION)\n" |
7 | "--\n" |
8 | "\n" |
9 | "Returns a bytes object containing compressed data.\n" |
10 | "\n" |
11 | " data\n" |
12 | " Binary data to be compressed.\n" |
13 | " level\n" |
14 | " Compression level, in 0-9 or -1." ); |
15 | |
16 | #define ZLIB_COMPRESS_METHODDEF \ |
17 | {"compress", (PyCFunction)(void(*)(void))zlib_compress, METH_FASTCALL|METH_KEYWORDS, zlib_compress__doc__}, |
18 | |
19 | static PyObject * |
20 | zlib_compress_impl(PyObject *module, Py_buffer *data, int level); |
21 | |
22 | static PyObject * |
23 | zlib_compress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
24 | { |
25 | PyObject *return_value = NULL; |
26 | static const char * const _keywords[] = {"" , "level" , NULL}; |
27 | static _PyArg_Parser _parser = {NULL, _keywords, "compress" , 0}; |
28 | PyObject *argsbuf[2]; |
29 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
30 | Py_buffer data = {NULL, NULL}; |
31 | int level = Z_DEFAULT_COMPRESSION; |
32 | |
33 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
34 | if (!args) { |
35 | goto exit; |
36 | } |
37 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
38 | goto exit; |
39 | } |
40 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
41 | _PyArg_BadArgument("compress" , "argument 1" , "contiguous buffer" , args[0]); |
42 | goto exit; |
43 | } |
44 | if (!noptargs) { |
45 | goto skip_optional_pos; |
46 | } |
47 | level = _PyLong_AsInt(args[1]); |
48 | if (level == -1 && PyErr_Occurred()) { |
49 | goto exit; |
50 | } |
51 | skip_optional_pos: |
52 | return_value = zlib_compress_impl(module, &data, level); |
53 | |
54 | exit: |
55 | /* Cleanup for data */ |
56 | if (data.obj) { |
57 | PyBuffer_Release(&data); |
58 | } |
59 | |
60 | return return_value; |
61 | } |
62 | |
63 | PyDoc_STRVAR(zlib_decompress__doc__, |
64 | "decompress($module, data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)\n" |
65 | "--\n" |
66 | "\n" |
67 | "Returns a bytes object containing the uncompressed data.\n" |
68 | "\n" |
69 | " data\n" |
70 | " Compressed data.\n" |
71 | " wbits\n" |
72 | " The window buffer size and container format.\n" |
73 | " bufsize\n" |
74 | " The initial output buffer size." ); |
75 | |
76 | #define ZLIB_DECOMPRESS_METHODDEF \ |
77 | {"decompress", (PyCFunction)(void(*)(void))zlib_decompress, METH_FASTCALL|METH_KEYWORDS, zlib_decompress__doc__}, |
78 | |
79 | static PyObject * |
80 | zlib_decompress_impl(PyObject *module, Py_buffer *data, int wbits, |
81 | Py_ssize_t bufsize); |
82 | |
83 | static PyObject * |
84 | zlib_decompress(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
85 | { |
86 | PyObject *return_value = NULL; |
87 | static const char * const _keywords[] = {"" , "wbits" , "bufsize" , NULL}; |
88 | static _PyArg_Parser _parser = {NULL, _keywords, "decompress" , 0}; |
89 | PyObject *argsbuf[3]; |
90 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
91 | Py_buffer data = {NULL, NULL}; |
92 | int wbits = MAX_WBITS; |
93 | Py_ssize_t bufsize = DEF_BUF_SIZE; |
94 | |
95 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); |
96 | if (!args) { |
97 | goto exit; |
98 | } |
99 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
100 | goto exit; |
101 | } |
102 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
103 | _PyArg_BadArgument("decompress" , "argument 1" , "contiguous buffer" , args[0]); |
104 | goto exit; |
105 | } |
106 | if (!noptargs) { |
107 | goto skip_optional_pos; |
108 | } |
109 | if (args[1]) { |
110 | wbits = _PyLong_AsInt(args[1]); |
111 | if (wbits == -1 && PyErr_Occurred()) { |
112 | goto exit; |
113 | } |
114 | if (!--noptargs) { |
115 | goto skip_optional_pos; |
116 | } |
117 | } |
118 | { |
119 | Py_ssize_t ival = -1; |
120 | PyObject *iobj = _PyNumber_Index(args[2]); |
121 | if (iobj != NULL) { |
122 | ival = PyLong_AsSsize_t(iobj); |
123 | Py_DECREF(iobj); |
124 | } |
125 | if (ival == -1 && PyErr_Occurred()) { |
126 | goto exit; |
127 | } |
128 | bufsize = ival; |
129 | } |
130 | skip_optional_pos: |
131 | return_value = zlib_decompress_impl(module, &data, wbits, bufsize); |
132 | |
133 | exit: |
134 | /* Cleanup for data */ |
135 | if (data.obj) { |
136 | PyBuffer_Release(&data); |
137 | } |
138 | |
139 | return return_value; |
140 | } |
141 | |
142 | PyDoc_STRVAR(zlib_compressobj__doc__, |
143 | "compressobj($module, /, level=Z_DEFAULT_COMPRESSION, method=DEFLATED,\n" |
144 | " wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL,\n" |
145 | " strategy=Z_DEFAULT_STRATEGY, zdict=None)\n" |
146 | "--\n" |
147 | "\n" |
148 | "Return a compressor object.\n" |
149 | "\n" |
150 | " level\n" |
151 | " The compression level (an integer in the range 0-9 or -1; default is\n" |
152 | " currently equivalent to 6). Higher compression levels are slower,\n" |
153 | " but produce smaller results.\n" |
154 | " method\n" |
155 | " The compression algorithm. If given, this must be DEFLATED.\n" |
156 | " wbits\n" |
157 | " +9 to +15: The base-two logarithm of the window size. Include a zlib\n" |
158 | " container.\n" |
159 | " -9 to -15: Generate a raw stream.\n" |
160 | " +25 to +31: Include a gzip container.\n" |
161 | " memLevel\n" |
162 | " Controls the amount of memory used for internal compression state.\n" |
163 | " Valid values range from 1 to 9. Higher values result in higher memory\n" |
164 | " usage, faster compression, and smaller output.\n" |
165 | " strategy\n" |
166 | " Used to tune the compression algorithm. Possible values are\n" |
167 | " Z_DEFAULT_STRATEGY, Z_FILTERED, and Z_HUFFMAN_ONLY.\n" |
168 | " zdict\n" |
169 | " The predefined compression dictionary - a sequence of bytes\n" |
170 | " containing subsequences that are likely to occur in the input data." ); |
171 | |
172 | #define ZLIB_COMPRESSOBJ_METHODDEF \ |
173 | {"compressobj", (PyCFunction)(void(*)(void))zlib_compressobj, METH_FASTCALL|METH_KEYWORDS, zlib_compressobj__doc__}, |
174 | |
175 | static PyObject * |
176 | zlib_compressobj_impl(PyObject *module, int level, int method, int wbits, |
177 | int memLevel, int strategy, Py_buffer *zdict); |
178 | |
179 | static PyObject * |
180 | zlib_compressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
181 | { |
182 | PyObject *return_value = NULL; |
183 | static const char * const _keywords[] = {"level" , "method" , "wbits" , "memLevel" , "strategy" , "zdict" , NULL}; |
184 | static _PyArg_Parser _parser = {NULL, _keywords, "compressobj" , 0}; |
185 | PyObject *argsbuf[6]; |
186 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
187 | int level = Z_DEFAULT_COMPRESSION; |
188 | int method = DEFLATED; |
189 | int wbits = MAX_WBITS; |
190 | int memLevel = DEF_MEM_LEVEL; |
191 | int strategy = Z_DEFAULT_STRATEGY; |
192 | Py_buffer zdict = {NULL, NULL}; |
193 | |
194 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 6, 0, argsbuf); |
195 | if (!args) { |
196 | goto exit; |
197 | } |
198 | if (!noptargs) { |
199 | goto skip_optional_pos; |
200 | } |
201 | if (args[0]) { |
202 | level = _PyLong_AsInt(args[0]); |
203 | if (level == -1 && PyErr_Occurred()) { |
204 | goto exit; |
205 | } |
206 | if (!--noptargs) { |
207 | goto skip_optional_pos; |
208 | } |
209 | } |
210 | if (args[1]) { |
211 | method = _PyLong_AsInt(args[1]); |
212 | if (method == -1 && PyErr_Occurred()) { |
213 | goto exit; |
214 | } |
215 | if (!--noptargs) { |
216 | goto skip_optional_pos; |
217 | } |
218 | } |
219 | if (args[2]) { |
220 | wbits = _PyLong_AsInt(args[2]); |
221 | if (wbits == -1 && PyErr_Occurred()) { |
222 | goto exit; |
223 | } |
224 | if (!--noptargs) { |
225 | goto skip_optional_pos; |
226 | } |
227 | } |
228 | if (args[3]) { |
229 | memLevel = _PyLong_AsInt(args[3]); |
230 | if (memLevel == -1 && PyErr_Occurred()) { |
231 | goto exit; |
232 | } |
233 | if (!--noptargs) { |
234 | goto skip_optional_pos; |
235 | } |
236 | } |
237 | if (args[4]) { |
238 | strategy = _PyLong_AsInt(args[4]); |
239 | if (strategy == -1 && PyErr_Occurred()) { |
240 | goto exit; |
241 | } |
242 | if (!--noptargs) { |
243 | goto skip_optional_pos; |
244 | } |
245 | } |
246 | if (PyObject_GetBuffer(args[5], &zdict, PyBUF_SIMPLE) != 0) { |
247 | goto exit; |
248 | } |
249 | if (!PyBuffer_IsContiguous(&zdict, 'C')) { |
250 | _PyArg_BadArgument("compressobj" , "argument 'zdict'" , "contiguous buffer" , args[5]); |
251 | goto exit; |
252 | } |
253 | skip_optional_pos: |
254 | return_value = zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict); |
255 | |
256 | exit: |
257 | /* Cleanup for zdict */ |
258 | if (zdict.obj) { |
259 | PyBuffer_Release(&zdict); |
260 | } |
261 | |
262 | return return_value; |
263 | } |
264 | |
265 | PyDoc_STRVAR(zlib_decompressobj__doc__, |
266 | "decompressobj($module, /, wbits=MAX_WBITS, zdict=b\'\')\n" |
267 | "--\n" |
268 | "\n" |
269 | "Return a decompressor object.\n" |
270 | "\n" |
271 | " wbits\n" |
272 | " The window buffer size and container format.\n" |
273 | " zdict\n" |
274 | " The predefined compression dictionary. This must be the same\n" |
275 | " dictionary as used by the compressor that produced the input data." ); |
276 | |
277 | #define ZLIB_DECOMPRESSOBJ_METHODDEF \ |
278 | {"decompressobj", (PyCFunction)(void(*)(void))zlib_decompressobj, METH_FASTCALL|METH_KEYWORDS, zlib_decompressobj__doc__}, |
279 | |
280 | static PyObject * |
281 | zlib_decompressobj_impl(PyObject *module, int wbits, PyObject *zdict); |
282 | |
283 | static PyObject * |
284 | zlib_decompressobj(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
285 | { |
286 | PyObject *return_value = NULL; |
287 | static const char * const _keywords[] = {"wbits" , "zdict" , NULL}; |
288 | static _PyArg_Parser _parser = {NULL, _keywords, "decompressobj" , 0}; |
289 | PyObject *argsbuf[2]; |
290 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
291 | int wbits = MAX_WBITS; |
292 | PyObject *zdict = NULL; |
293 | |
294 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf); |
295 | if (!args) { |
296 | goto exit; |
297 | } |
298 | if (!noptargs) { |
299 | goto skip_optional_pos; |
300 | } |
301 | if (args[0]) { |
302 | wbits = _PyLong_AsInt(args[0]); |
303 | if (wbits == -1 && PyErr_Occurred()) { |
304 | goto exit; |
305 | } |
306 | if (!--noptargs) { |
307 | goto skip_optional_pos; |
308 | } |
309 | } |
310 | zdict = args[1]; |
311 | skip_optional_pos: |
312 | return_value = zlib_decompressobj_impl(module, wbits, zdict); |
313 | |
314 | exit: |
315 | return return_value; |
316 | } |
317 | |
318 | PyDoc_STRVAR(zlib_Compress_compress__doc__, |
319 | "compress($self, data, /)\n" |
320 | "--\n" |
321 | "\n" |
322 | "Returns a bytes object containing compressed data.\n" |
323 | "\n" |
324 | " data\n" |
325 | " Binary data to be compressed.\n" |
326 | "\n" |
327 | "After calling this function, some of the input data may still\n" |
328 | "be stored in internal buffers for later processing.\n" |
329 | "Call the flush() method to clear these buffers." ); |
330 | |
331 | #define ZLIB_COMPRESS_COMPRESS_METHODDEF \ |
332 | {"compress", (PyCFunction)(void(*)(void))zlib_Compress_compress, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_compress__doc__}, |
333 | |
334 | static PyObject * |
335 | zlib_Compress_compress_impl(compobject *self, PyTypeObject *cls, |
336 | Py_buffer *data); |
337 | |
338 | static PyObject * |
339 | zlib_Compress_compress(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
340 | { |
341 | PyObject *return_value = NULL; |
342 | static const char * const _keywords[] = {"" , NULL}; |
343 | static _PyArg_Parser _parser = {NULL, _keywords, "compress" , 0}; |
344 | PyObject *argsbuf[1]; |
345 | Py_buffer data = {NULL, NULL}; |
346 | |
347 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
348 | if (!args) { |
349 | goto exit; |
350 | } |
351 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
352 | goto exit; |
353 | } |
354 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
355 | _PyArg_BadArgument("compress" , "argument 1" , "contiguous buffer" , args[0]); |
356 | goto exit; |
357 | } |
358 | return_value = zlib_Compress_compress_impl(self, cls, &data); |
359 | |
360 | exit: |
361 | /* Cleanup for data */ |
362 | if (data.obj) { |
363 | PyBuffer_Release(&data); |
364 | } |
365 | |
366 | return return_value; |
367 | } |
368 | |
369 | PyDoc_STRVAR(zlib_Decompress_decompress__doc__, |
370 | "decompress($self, data, /, max_length=0)\n" |
371 | "--\n" |
372 | "\n" |
373 | "Return a bytes object containing the decompressed version of the data.\n" |
374 | "\n" |
375 | " data\n" |
376 | " The binary data to decompress.\n" |
377 | " max_length\n" |
378 | " The maximum allowable length of the decompressed data.\n" |
379 | " Unconsumed input data will be stored in\n" |
380 | " the unconsumed_tail attribute.\n" |
381 | "\n" |
382 | "After calling this function, some of the input data may still be stored in\n" |
383 | "internal buffers for later processing.\n" |
384 | "Call the flush() method to clear these buffers." ); |
385 | |
386 | #define ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF \ |
387 | {"decompress", (PyCFunction)(void(*)(void))zlib_Decompress_decompress, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_decompress__doc__}, |
388 | |
389 | static PyObject * |
390 | zlib_Decompress_decompress_impl(compobject *self, PyTypeObject *cls, |
391 | Py_buffer *data, Py_ssize_t max_length); |
392 | |
393 | static PyObject * |
394 | zlib_Decompress_decompress(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
395 | { |
396 | PyObject *return_value = NULL; |
397 | static const char * const _keywords[] = {"" , "max_length" , NULL}; |
398 | static _PyArg_Parser _parser = {NULL, _keywords, "decompress" , 0}; |
399 | PyObject *argsbuf[2]; |
400 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
401 | Py_buffer data = {NULL, NULL}; |
402 | Py_ssize_t max_length = 0; |
403 | |
404 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
405 | if (!args) { |
406 | goto exit; |
407 | } |
408 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
409 | goto exit; |
410 | } |
411 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
412 | _PyArg_BadArgument("decompress" , "argument 1" , "contiguous buffer" , args[0]); |
413 | goto exit; |
414 | } |
415 | if (!noptargs) { |
416 | goto skip_optional_pos; |
417 | } |
418 | { |
419 | Py_ssize_t ival = -1; |
420 | PyObject *iobj = _PyNumber_Index(args[1]); |
421 | if (iobj != NULL) { |
422 | ival = PyLong_AsSsize_t(iobj); |
423 | Py_DECREF(iobj); |
424 | } |
425 | if (ival == -1 && PyErr_Occurred()) { |
426 | goto exit; |
427 | } |
428 | max_length = ival; |
429 | } |
430 | skip_optional_pos: |
431 | return_value = zlib_Decompress_decompress_impl(self, cls, &data, max_length); |
432 | |
433 | exit: |
434 | /* Cleanup for data */ |
435 | if (data.obj) { |
436 | PyBuffer_Release(&data); |
437 | } |
438 | |
439 | return return_value; |
440 | } |
441 | |
442 | PyDoc_STRVAR(zlib_Compress_flush__doc__, |
443 | "flush($self, mode=zlib.Z_FINISH, /)\n" |
444 | "--\n" |
445 | "\n" |
446 | "Return a bytes object containing any remaining compressed data.\n" |
447 | "\n" |
448 | " mode\n" |
449 | " One of the constants Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH.\n" |
450 | " If mode == Z_FINISH, the compressor object can no longer be\n" |
451 | " used after calling the flush() method. Otherwise, more data\n" |
452 | " can still be compressed." ); |
453 | |
454 | #define ZLIB_COMPRESS_FLUSH_METHODDEF \ |
455 | {"flush", (PyCFunction)(void(*)(void))zlib_Compress_flush, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_flush__doc__}, |
456 | |
457 | static PyObject * |
458 | zlib_Compress_flush_impl(compobject *self, PyTypeObject *cls, int mode); |
459 | |
460 | static PyObject * |
461 | zlib_Compress_flush(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
462 | { |
463 | PyObject *return_value = NULL; |
464 | static const char * const _keywords[] = {"" , NULL}; |
465 | static _PyArg_Parser _parser = {NULL, _keywords, "flush" , 0}; |
466 | PyObject *argsbuf[1]; |
467 | int mode = Z_FINISH; |
468 | |
469 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
470 | if (!args) { |
471 | goto exit; |
472 | } |
473 | if (nargs < 1) { |
474 | goto skip_optional_posonly; |
475 | } |
476 | mode = _PyLong_AsInt(args[0]); |
477 | if (mode == -1 && PyErr_Occurred()) { |
478 | goto exit; |
479 | } |
480 | skip_optional_posonly: |
481 | return_value = zlib_Compress_flush_impl(self, cls, mode); |
482 | |
483 | exit: |
484 | return return_value; |
485 | } |
486 | |
487 | #if defined(HAVE_ZLIB_COPY) |
488 | |
489 | PyDoc_STRVAR(zlib_Compress_copy__doc__, |
490 | "copy($self, /)\n" |
491 | "--\n" |
492 | "\n" |
493 | "Return a copy of the compression object." ); |
494 | |
495 | #define ZLIB_COMPRESS_COPY_METHODDEF \ |
496 | {"copy", (PyCFunction)(void(*)(void))zlib_Compress_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress_copy__doc__}, |
497 | |
498 | static PyObject * |
499 | zlib_Compress_copy_impl(compobject *self, PyTypeObject *cls); |
500 | |
501 | static PyObject * |
502 | zlib_Compress_copy(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
503 | { |
504 | if (nargs) { |
505 | PyErr_SetString(PyExc_TypeError, "copy() takes no arguments" ); |
506 | return NULL; |
507 | } |
508 | return zlib_Compress_copy_impl(self, cls); |
509 | } |
510 | |
511 | #endif /* defined(HAVE_ZLIB_COPY) */ |
512 | |
513 | #if defined(HAVE_ZLIB_COPY) |
514 | |
515 | PyDoc_STRVAR(zlib_Compress___copy____doc__, |
516 | "__copy__($self, /)\n" |
517 | "--\n" |
518 | "\n" ); |
519 | |
520 | #define ZLIB_COMPRESS___COPY___METHODDEF \ |
521 | {"__copy__", (PyCFunction)(void(*)(void))zlib_Compress___copy__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress___copy____doc__}, |
522 | |
523 | static PyObject * |
524 | zlib_Compress___copy___impl(compobject *self, PyTypeObject *cls); |
525 | |
526 | static PyObject * |
527 | zlib_Compress___copy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
528 | { |
529 | if (nargs) { |
530 | PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments" ); |
531 | return NULL; |
532 | } |
533 | return zlib_Compress___copy___impl(self, cls); |
534 | } |
535 | |
536 | #endif /* defined(HAVE_ZLIB_COPY) */ |
537 | |
538 | #if defined(HAVE_ZLIB_COPY) |
539 | |
540 | PyDoc_STRVAR(zlib_Compress___deepcopy____doc__, |
541 | "__deepcopy__($self, memo, /)\n" |
542 | "--\n" |
543 | "\n" ); |
544 | |
545 | #define ZLIB_COMPRESS___DEEPCOPY___METHODDEF \ |
546 | {"__deepcopy__", (PyCFunction)(void(*)(void))zlib_Compress___deepcopy__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Compress___deepcopy____doc__}, |
547 | |
548 | static PyObject * |
549 | zlib_Compress___deepcopy___impl(compobject *self, PyTypeObject *cls, |
550 | PyObject *memo); |
551 | |
552 | static PyObject * |
553 | zlib_Compress___deepcopy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
554 | { |
555 | PyObject *return_value = NULL; |
556 | static const char * const _keywords[] = {"" , NULL}; |
557 | static _PyArg_Parser _parser = {NULL, _keywords, "__deepcopy__" , 0}; |
558 | PyObject *argsbuf[1]; |
559 | PyObject *memo; |
560 | |
561 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
562 | if (!args) { |
563 | goto exit; |
564 | } |
565 | memo = args[0]; |
566 | return_value = zlib_Compress___deepcopy___impl(self, cls, memo); |
567 | |
568 | exit: |
569 | return return_value; |
570 | } |
571 | |
572 | #endif /* defined(HAVE_ZLIB_COPY) */ |
573 | |
574 | #if defined(HAVE_ZLIB_COPY) |
575 | |
576 | PyDoc_STRVAR(zlib_Decompress_copy__doc__, |
577 | "copy($self, /)\n" |
578 | "--\n" |
579 | "\n" |
580 | "Return a copy of the decompression object." ); |
581 | |
582 | #define ZLIB_DECOMPRESS_COPY_METHODDEF \ |
583 | {"copy", (PyCFunction)(void(*)(void))zlib_Decompress_copy, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_copy__doc__}, |
584 | |
585 | static PyObject * |
586 | zlib_Decompress_copy_impl(compobject *self, PyTypeObject *cls); |
587 | |
588 | static PyObject * |
589 | zlib_Decompress_copy(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
590 | { |
591 | if (nargs) { |
592 | PyErr_SetString(PyExc_TypeError, "copy() takes no arguments" ); |
593 | return NULL; |
594 | } |
595 | return zlib_Decompress_copy_impl(self, cls); |
596 | } |
597 | |
598 | #endif /* defined(HAVE_ZLIB_COPY) */ |
599 | |
600 | #if defined(HAVE_ZLIB_COPY) |
601 | |
602 | PyDoc_STRVAR(zlib_Decompress___copy____doc__, |
603 | "__copy__($self, /)\n" |
604 | "--\n" |
605 | "\n" ); |
606 | |
607 | #define ZLIB_DECOMPRESS___COPY___METHODDEF \ |
608 | {"__copy__", (PyCFunction)(void(*)(void))zlib_Decompress___copy__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress___copy____doc__}, |
609 | |
610 | static PyObject * |
611 | zlib_Decompress___copy___impl(compobject *self, PyTypeObject *cls); |
612 | |
613 | static PyObject * |
614 | zlib_Decompress___copy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
615 | { |
616 | if (nargs) { |
617 | PyErr_SetString(PyExc_TypeError, "__copy__() takes no arguments" ); |
618 | return NULL; |
619 | } |
620 | return zlib_Decompress___copy___impl(self, cls); |
621 | } |
622 | |
623 | #endif /* defined(HAVE_ZLIB_COPY) */ |
624 | |
625 | #if defined(HAVE_ZLIB_COPY) |
626 | |
627 | PyDoc_STRVAR(zlib_Decompress___deepcopy____doc__, |
628 | "__deepcopy__($self, memo, /)\n" |
629 | "--\n" |
630 | "\n" ); |
631 | |
632 | #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF \ |
633 | {"__deepcopy__", (PyCFunction)(void(*)(void))zlib_Decompress___deepcopy__, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress___deepcopy____doc__}, |
634 | |
635 | static PyObject * |
636 | zlib_Decompress___deepcopy___impl(compobject *self, PyTypeObject *cls, |
637 | PyObject *memo); |
638 | |
639 | static PyObject * |
640 | zlib_Decompress___deepcopy__(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
641 | { |
642 | PyObject *return_value = NULL; |
643 | static const char * const _keywords[] = {"" , NULL}; |
644 | static _PyArg_Parser _parser = {NULL, _keywords, "__deepcopy__" , 0}; |
645 | PyObject *argsbuf[1]; |
646 | PyObject *memo; |
647 | |
648 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
649 | if (!args) { |
650 | goto exit; |
651 | } |
652 | memo = args[0]; |
653 | return_value = zlib_Decompress___deepcopy___impl(self, cls, memo); |
654 | |
655 | exit: |
656 | return return_value; |
657 | } |
658 | |
659 | #endif /* defined(HAVE_ZLIB_COPY) */ |
660 | |
661 | PyDoc_STRVAR(zlib_Decompress_flush__doc__, |
662 | "flush($self, length=zlib.DEF_BUF_SIZE, /)\n" |
663 | "--\n" |
664 | "\n" |
665 | "Return a bytes object containing any remaining decompressed data.\n" |
666 | "\n" |
667 | " length\n" |
668 | " the initial size of the output buffer." ); |
669 | |
670 | #define ZLIB_DECOMPRESS_FLUSH_METHODDEF \ |
671 | {"flush", (PyCFunction)(void(*)(void))zlib_Decompress_flush, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, zlib_Decompress_flush__doc__}, |
672 | |
673 | static PyObject * |
674 | zlib_Decompress_flush_impl(compobject *self, PyTypeObject *cls, |
675 | Py_ssize_t length); |
676 | |
677 | static PyObject * |
678 | zlib_Decompress_flush(compobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
679 | { |
680 | PyObject *return_value = NULL; |
681 | static const char * const _keywords[] = {"" , NULL}; |
682 | static _PyArg_Parser _parser = {NULL, _keywords, "flush" , 0}; |
683 | PyObject *argsbuf[1]; |
684 | Py_ssize_t length = DEF_BUF_SIZE; |
685 | |
686 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
687 | if (!args) { |
688 | goto exit; |
689 | } |
690 | if (nargs < 1) { |
691 | goto skip_optional_posonly; |
692 | } |
693 | { |
694 | Py_ssize_t ival = -1; |
695 | PyObject *iobj = _PyNumber_Index(args[0]); |
696 | if (iobj != NULL) { |
697 | ival = PyLong_AsSsize_t(iobj); |
698 | Py_DECREF(iobj); |
699 | } |
700 | if (ival == -1 && PyErr_Occurred()) { |
701 | goto exit; |
702 | } |
703 | length = ival; |
704 | } |
705 | skip_optional_posonly: |
706 | return_value = zlib_Decompress_flush_impl(self, cls, length); |
707 | |
708 | exit: |
709 | return return_value; |
710 | } |
711 | |
712 | PyDoc_STRVAR(zlib_adler32__doc__, |
713 | "adler32($module, data, value=1, /)\n" |
714 | "--\n" |
715 | "\n" |
716 | "Compute an Adler-32 checksum of data.\n" |
717 | "\n" |
718 | " value\n" |
719 | " Starting value of the checksum.\n" |
720 | "\n" |
721 | "The returned checksum is an integer." ); |
722 | |
723 | #define ZLIB_ADLER32_METHODDEF \ |
724 | {"adler32", (PyCFunction)(void(*)(void))zlib_adler32, METH_FASTCALL, zlib_adler32__doc__}, |
725 | |
726 | static PyObject * |
727 | zlib_adler32_impl(PyObject *module, Py_buffer *data, unsigned int value); |
728 | |
729 | static PyObject * |
730 | zlib_adler32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
731 | { |
732 | PyObject *return_value = NULL; |
733 | Py_buffer data = {NULL, NULL}; |
734 | unsigned int value = 1; |
735 | |
736 | if (!_PyArg_CheckPositional("adler32" , nargs, 1, 2)) { |
737 | goto exit; |
738 | } |
739 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
740 | goto exit; |
741 | } |
742 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
743 | _PyArg_BadArgument("adler32" , "argument 1" , "contiguous buffer" , args[0]); |
744 | goto exit; |
745 | } |
746 | if (nargs < 2) { |
747 | goto skip_optional; |
748 | } |
749 | value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); |
750 | if (value == (unsigned int)-1 && PyErr_Occurred()) { |
751 | goto exit; |
752 | } |
753 | skip_optional: |
754 | return_value = zlib_adler32_impl(module, &data, value); |
755 | |
756 | exit: |
757 | /* Cleanup for data */ |
758 | if (data.obj) { |
759 | PyBuffer_Release(&data); |
760 | } |
761 | |
762 | return return_value; |
763 | } |
764 | |
765 | PyDoc_STRVAR(zlib_crc32__doc__, |
766 | "crc32($module, data, value=0, /)\n" |
767 | "--\n" |
768 | "\n" |
769 | "Compute a CRC-32 checksum of data.\n" |
770 | "\n" |
771 | " value\n" |
772 | " Starting value of the checksum.\n" |
773 | "\n" |
774 | "The returned checksum is an integer." ); |
775 | |
776 | #define ZLIB_CRC32_METHODDEF \ |
777 | {"crc32", (PyCFunction)(void(*)(void))zlib_crc32, METH_FASTCALL, zlib_crc32__doc__}, |
778 | |
779 | static PyObject * |
780 | zlib_crc32_impl(PyObject *module, Py_buffer *data, unsigned int value); |
781 | |
782 | static PyObject * |
783 | zlib_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
784 | { |
785 | PyObject *return_value = NULL; |
786 | Py_buffer data = {NULL, NULL}; |
787 | unsigned int value = 0; |
788 | |
789 | if (!_PyArg_CheckPositional("crc32" , nargs, 1, 2)) { |
790 | goto exit; |
791 | } |
792 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
793 | goto exit; |
794 | } |
795 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
796 | _PyArg_BadArgument("crc32" , "argument 1" , "contiguous buffer" , args[0]); |
797 | goto exit; |
798 | } |
799 | if (nargs < 2) { |
800 | goto skip_optional; |
801 | } |
802 | value = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); |
803 | if (value == (unsigned int)-1 && PyErr_Occurred()) { |
804 | goto exit; |
805 | } |
806 | skip_optional: |
807 | return_value = zlib_crc32_impl(module, &data, value); |
808 | |
809 | exit: |
810 | /* Cleanup for data */ |
811 | if (data.obj) { |
812 | PyBuffer_Release(&data); |
813 | } |
814 | |
815 | return return_value; |
816 | } |
817 | |
818 | #ifndef ZLIB_COMPRESS_COPY_METHODDEF |
819 | #define ZLIB_COMPRESS_COPY_METHODDEF |
820 | #endif /* !defined(ZLIB_COMPRESS_COPY_METHODDEF) */ |
821 | |
822 | #ifndef ZLIB_COMPRESS___COPY___METHODDEF |
823 | #define ZLIB_COMPRESS___COPY___METHODDEF |
824 | #endif /* !defined(ZLIB_COMPRESS___COPY___METHODDEF) */ |
825 | |
826 | #ifndef ZLIB_COMPRESS___DEEPCOPY___METHODDEF |
827 | #define ZLIB_COMPRESS___DEEPCOPY___METHODDEF |
828 | #endif /* !defined(ZLIB_COMPRESS___DEEPCOPY___METHODDEF) */ |
829 | |
830 | #ifndef ZLIB_DECOMPRESS_COPY_METHODDEF |
831 | #define ZLIB_DECOMPRESS_COPY_METHODDEF |
832 | #endif /* !defined(ZLIB_DECOMPRESS_COPY_METHODDEF) */ |
833 | |
834 | #ifndef ZLIB_DECOMPRESS___COPY___METHODDEF |
835 | #define ZLIB_DECOMPRESS___COPY___METHODDEF |
836 | #endif /* !defined(ZLIB_DECOMPRESS___COPY___METHODDEF) */ |
837 | |
838 | #ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF |
839 | #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF |
840 | #endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */ |
841 | /*[clinic end generated code: output=1bda0d996fb51269 input=a9049054013a1b77]*/ |
842 | |