| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | preserve | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(binascii_a2b_uu__doc__, | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "a2b_uu($module, data, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "Decode a line of uuencoded data."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_A2B_UU_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"a2b_uu", (PyCFunction)binascii_a2b_uu, METH_O, binascii_a2b_uu__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_a2b_uu_impl(PyObject *module, Py_buffer *data); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_a2b_uu(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2014-01-26 10:41:58 -05:00
										 |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     if (!ascii_buffer_converter(arg, &data)) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:49:49 +02:00
										 |  |  |     return_value = binascii_a2b_uu_impl(module, &data); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							| 
									
										
										
										
											2014-01-26 10:41:58 -05:00
										 |  |  |     /* Cleanup for data */ | 
					
						
							|  |  |  |     if (data.obj) | 
					
						
							|  |  |  |        PyBuffer_Release(&data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(binascii_b2a_uu__doc__, | 
					
						
							| 
									
										
										
										
											2017-05-03 11:16:21 +08:00
										 |  |  | "b2a_uu($module, data, /, *, backtick=False)\n" | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "Uuencode line of data."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_B2A_UU_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"b2a_uu", _PyCFunction_CAST(binascii_b2a_uu), METH_FASTCALL|METH_KEYWORDS, binascii_b2a_uu__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-05-03 11:16:21 +08:00
										 |  |  | binascii_b2a_uu_impl(PyObject *module, Py_buffer *data, int backtick); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | binascii_b2a_uu(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2017-05-03 11:16:21 +08:00
										 |  |  |     static const char * const _keywords[] = {"", "backtick", NULL}; | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     static _PyArg_Parser _parser = {NULL, _keywords, "b2a_uu", 0}; | 
					
						
							|  |  |  |     PyObject *argsbuf[2]; | 
					
						
							|  |  |  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2017-05-03 11:16:21 +08:00
										 |  |  |     int backtick = 0; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); | 
					
						
							|  |  |  |     if (!args) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!PyBuffer_IsContiguous(&data, 'C')) { | 
					
						
							| 
									
										
										
										
											2019-08-29 16:49:08 +02:00
										 |  |  |         _PyArg_BadArgument("b2a_uu", "argument 1", "contiguous buffer", args[0]); | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!noptargs) { | 
					
						
							|  |  |  |         goto skip_optional_kwonly; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     backtick = _PyLong_AsInt(args[1]); | 
					
						
							|  |  |  |     if (backtick == -1 && PyErr_Occurred()) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | skip_optional_kwonly: | 
					
						
							| 
									
										
										
										
											2017-05-03 11:16:21 +08:00
										 |  |  |     return_value = binascii_b2a_uu_impl(module, &data, backtick); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     /* Cleanup for data */ | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if (data.obj) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |        PyBuffer_Release(&data); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(binascii_a2b_base64__doc__, | 
					
						
							| 
									
										
										
										
											2021-07-19 03:45:19 +03:00
										 |  |  | "a2b_base64($module, data, /, *, strict_mode=False)\n" | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2021-07-19 03:45:19 +03:00
										 |  |  | "Decode a line of base64 data.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "  strict_mode\n" | 
					
						
							|  |  |  | "    When set to True, bytes that are not part of the base64 standard are not allowed.\n" | 
					
						
							|  |  |  | "    The same applies to excess data after padding (= / ==)."); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_A2B_BASE64_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"a2b_base64", _PyCFunction_CAST(binascii_a2b_base64), METH_FASTCALL|METH_KEYWORDS, binascii_a2b_base64__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2021-07-19 03:45:19 +03:00
										 |  |  | binascii_a2b_base64_impl(PyObject *module, Py_buffer *data, int strict_mode); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2021-07-19 03:45:19 +03:00
										 |  |  | binascii_a2b_base64(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2021-07-19 03:45:19 +03:00
										 |  |  |     static const char * const _keywords[] = {"", "strict_mode", NULL}; | 
					
						
							|  |  |  |     static _PyArg_Parser _parser = {NULL, _keywords, "a2b_base64", 0}; | 
					
						
							|  |  |  |     PyObject *argsbuf[2]; | 
					
						
							|  |  |  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; | 
					
						
							| 
									
										
										
										
											2014-01-26 10:41:58 -05:00
										 |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2021-07-19 03:45:19 +03:00
										 |  |  |     int strict_mode = 0; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-19 03:45:19 +03:00
										 |  |  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); | 
					
						
							|  |  |  |     if (!args) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-07-19 03:45:19 +03:00
										 |  |  |     if (!ascii_buffer_converter(args[0], &data)) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!noptargs) { | 
					
						
							|  |  |  |         goto skip_optional_kwonly; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     strict_mode = _PyLong_AsInt(args[1]); | 
					
						
							|  |  |  |     if (strict_mode == -1 && PyErr_Occurred()) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | skip_optional_kwonly: | 
					
						
							|  |  |  |     return_value = binascii_a2b_base64_impl(module, &data, strict_mode); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							| 
									
										
										
										
											2014-01-26 10:41:58 -05:00
										 |  |  |     /* Cleanup for data */ | 
					
						
							|  |  |  |     if (data.obj) | 
					
						
							|  |  |  |        PyBuffer_Release(&data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(binascii_b2a_base64__doc__, | 
					
						
							| 
									
										
										
										
											2017-05-01 13:12:07 +08:00
										 |  |  | "b2a_base64($module, data, /, *, newline=True)\n" | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "Base64-code line of data."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_B2A_BASE64_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"b2a_base64", _PyCFunction_CAST(binascii_b2a_base64), METH_FASTCALL|METH_KEYWORDS, binascii_b2a_base64__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 18:20:03 +03:00
										 |  |  | binascii_b2a_base64_impl(PyObject *module, Py_buffer *data, int newline); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | binascii_b2a_base64(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2017-05-01 13:12:07 +08:00
										 |  |  |     static const char * const _keywords[] = {"", "newline", NULL}; | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     static _PyArg_Parser _parser = {NULL, _keywords, "b2a_base64", 0}; | 
					
						
							|  |  |  |     PyObject *argsbuf[2]; | 
					
						
							|  |  |  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2015-10-11 11:01:02 +02:00
										 |  |  |     int newline = 1; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); | 
					
						
							|  |  |  |     if (!args) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!PyBuffer_IsContiguous(&data, 'C')) { | 
					
						
							| 
									
										
										
										
											2019-08-29 16:49:08 +02:00
										 |  |  |         _PyArg_BadArgument("b2a_base64", "argument 1", "contiguous buffer", args[0]); | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!noptargs) { | 
					
						
							|  |  |  |         goto skip_optional_kwonly; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     newline = _PyLong_AsInt(args[1]); | 
					
						
							|  |  |  |     if (newline == -1 && PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  | skip_optional_kwonly: | 
					
						
							| 
									
										
										
										
											2015-10-11 11:01:02 +02:00
										 |  |  |     return_value = binascii_b2a_base64_impl(module, &data, newline); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     /* Cleanup for data */ | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if (data.obj) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |        PyBuffer_Release(&data); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(binascii_crc_hqx__doc__, | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "crc_hqx($module, data, crc, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2016-12-24 07:36:44 +00:00
										 |  |  | "Compute CRC-CCITT incrementally."); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_CRC_HQX_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"crc_hqx", _PyCFunction_CAST(binascii_crc_hqx), METH_FASTCALL, binascii_crc_hqx__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-22 20:44:22 +01:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | binascii_crc_hqx(PyObject *module, PyObject *const *args, Py_ssize_t nargs) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2015-04-20 09:26:49 +03:00
										 |  |  |     unsigned int crc; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  |     if (!_PyArg_CheckPositional("crc_hqx", nargs, 2, 2)) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!PyBuffer_IsContiguous(&data, 'C')) { | 
					
						
							| 
									
										
										
										
											2019-08-29 16:49:08 +02:00
										 |  |  |         _PyArg_BadArgument("crc_hqx", "argument 1", "contiguous buffer", args[0]); | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); | 
					
						
							|  |  |  |     if (crc == (unsigned int)-1 && PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2017-01-17 01:35:17 +01:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-01-22 20:44:22 +01:00
										 |  |  |     return_value = binascii_crc_hqx_impl(module, &data, crc); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     /* Cleanup for data */ | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if (data.obj) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |        PyBuffer_Release(&data); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(binascii_crc32__doc__, | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "crc32($module, data, crc=0, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "Compute CRC-32 incrementally."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_CRC32_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"crc32", _PyCFunction_CAST(binascii_crc32), METH_FASTCALL, binascii_crc32__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static unsigned int | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | binascii_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							|  |  |  |     unsigned int crc = 0; | 
					
						
							|  |  |  |     unsigned int _return_value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  |     if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!PyBuffer_IsContiguous(&data, 'C')) { | 
					
						
							| 
									
										
										
										
											2019-08-29 16:49:08 +02:00
										 |  |  |         _PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]); | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (nargs < 2) { | 
					
						
							|  |  |  |         goto skip_optional; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); | 
					
						
							|  |  |  |     if (crc == (unsigned int)-1 && PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2017-01-17 01:35:17 +01:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-01-11 16:01:14 +02:00
										 |  |  | skip_optional: | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     _return_value = binascii_crc32_impl(module, &data, crc); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     /* Cleanup for data */ | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if (data.obj) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |        PyBuffer_Release(&data); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(binascii_b2a_hex__doc__, | 
					
						
							| 
									
										
										
										
											2019-09-14 12:24:05 +03:00
										 |  |  | "b2a_hex($module, /, data, sep=<unrepresentable>, bytes_per_sep=1)\n" | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "Hexadecimal representation of binary data.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  | "  sep\n" | 
					
						
							|  |  |  | "    An optional single character or byte to separate hex bytes.\n" | 
					
						
							|  |  |  | "  bytes_per_sep\n" | 
					
						
							|  |  |  | "    How many bytes between separators.  Positive values count from the\n" | 
					
						
							|  |  |  | "    right, negative values count from the left.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "The return value is a bytes object.  This function is also\n" | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  | "available as \"hexlify()\".\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Example:\n" | 
					
						
							|  |  |  | ">>> binascii.b2a_hex(b\'\\xb9\\x01\\xef\')\n" | 
					
						
							|  |  |  | "b\'b901ef\'\n" | 
					
						
							|  |  |  | ">>> binascii.hexlify(b\'\\xb9\\x01\\xef\', \':\')\n" | 
					
						
							|  |  |  | "b\'b9:01:ef\'\n" | 
					
						
							|  |  |  | ">>> binascii.b2a_hex(b\'\\xb9\\x01\\xef\', b\'_\', 2)\n" | 
					
						
							|  |  |  | "b\'b9_01ef\'"); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_B2A_HEX_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"b2a_hex", _PyCFunction_CAST(binascii_b2a_hex), METH_FASTCALL|METH_KEYWORDS, binascii_b2a_hex__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  | binascii_b2a_hex_impl(PyObject *module, Py_buffer *data, PyObject *sep, | 
					
						
							|  |  |  |                       int bytes_per_sep); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  | binascii_b2a_hex(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  |     static const char * const _keywords[] = {"data", "sep", "bytes_per_sep", NULL}; | 
					
						
							|  |  |  |     static _PyArg_Parser _parser = {NULL, _keywords, "b2a_hex", 0}; | 
					
						
							|  |  |  |     PyObject *argsbuf[3]; | 
					
						
							|  |  |  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  |     PyObject *sep = NULL; | 
					
						
							|  |  |  |     int bytes_per_sep = 1; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); | 
					
						
							|  |  |  |     if (!args) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!PyBuffer_IsContiguous(&data, 'C')) { | 
					
						
							| 
									
										
										
										
											2019-08-29 16:49:08 +02:00
										 |  |  |         _PyArg_BadArgument("b2a_hex", "argument 'data'", "contiguous buffer", args[0]); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  |     if (!noptargs) { | 
					
						
							|  |  |  |         goto skip_optional_pos; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (args[1]) { | 
					
						
							|  |  |  |         sep = args[1]; | 
					
						
							|  |  |  |         if (!--noptargs) { | 
					
						
							|  |  |  |             goto skip_optional_pos; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     bytes_per_sep = _PyLong_AsInt(args[2]); | 
					
						
							|  |  |  |     if (bytes_per_sep == -1 && PyErr_Occurred()) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | skip_optional_pos: | 
					
						
							|  |  |  |     return_value = binascii_b2a_hex_impl(module, &data, sep, bytes_per_sep); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     /* Cleanup for data */ | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if (data.obj) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |        PyBuffer_Release(&data); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | PyDoc_STRVAR(binascii_hexlify__doc__, | 
					
						
							| 
									
										
										
										
											2019-09-14 12:24:05 +03:00
										 |  |  | "hexlify($module, /, data, sep=<unrepresentable>, bytes_per_sep=1)\n" | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Hexadecimal representation of binary data.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  | "  sep\n" | 
					
						
							|  |  |  | "    An optional single character or byte to separate hex bytes.\n" | 
					
						
							|  |  |  | "  bytes_per_sep\n" | 
					
						
							|  |  |  | "    How many bytes between separators.  Positive values count from the\n" | 
					
						
							|  |  |  | "    right, negative values count from the left.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "The return value is a bytes object.  This function is also\n" | 
					
						
							|  |  |  | "available as \"b2a_hex()\"."); | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_HEXLIFY_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"hexlify", _PyCFunction_CAST(binascii_hexlify), METH_FASTCALL|METH_KEYWORDS, binascii_hexlify__doc__}, | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  | binascii_hexlify_impl(PyObject *module, Py_buffer *data, PyObject *sep, | 
					
						
							|  |  |  |                       int bytes_per_sep); | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  | binascii_hexlify(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  |     static const char * const _keywords[] = {"data", "sep", "bytes_per_sep", NULL}; | 
					
						
							|  |  |  |     static _PyArg_Parser _parser = {NULL, _keywords, "hexlify", 0}; | 
					
						
							|  |  |  |     PyObject *argsbuf[3]; | 
					
						
							|  |  |  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  |     PyObject *sep = NULL; | 
					
						
							|  |  |  |     int bytes_per_sep = 1; | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); | 
					
						
							|  |  |  |     if (!args) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!PyBuffer_IsContiguous(&data, 'C')) { | 
					
						
							| 
									
										
										
										
											2019-08-29 16:49:08 +02:00
										 |  |  |         _PyArg_BadArgument("hexlify", "argument 'data'", "contiguous buffer", args[0]); | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-29 11:46:58 -07:00
										 |  |  |     if (!noptargs) { | 
					
						
							|  |  |  |         goto skip_optional_pos; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (args[1]) { | 
					
						
							|  |  |  |         sep = args[1]; | 
					
						
							|  |  |  |         if (!--noptargs) { | 
					
						
							|  |  |  |             goto skip_optional_pos; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     bytes_per_sep = _PyLong_AsInt(args[2]); | 
					
						
							|  |  |  |     if (bytes_per_sep == -1 && PyErr_Occurred()) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | skip_optional_pos: | 
					
						
							|  |  |  |     return_value = binascii_hexlify_impl(module, &data, sep, bytes_per_sep); | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     /* Cleanup for data */ | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if (data.obj) { | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  |        PyBuffer_Release(&data); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | PyDoc_STRVAR(binascii_a2b_hex__doc__, | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "a2b_hex($module, hexstr, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "Binary data of hexadecimal representation.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "hexstr must contain an even number of hex digits (upper or lower case).\n" | 
					
						
							|  |  |  | "This function is also available as \"unhexlify()\"."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_A2B_HEX_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"a2b_hex", (PyCFunction)binascii_a2b_hex, METH_O, binascii_a2b_hex__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_a2b_hex_impl(PyObject *module, Py_buffer *hexstr); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_a2b_hex(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2014-01-26 10:41:58 -05:00
										 |  |  |     Py_buffer hexstr = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     if (!ascii_buffer_converter(arg, &hexstr)) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     return_value = binascii_a2b_hex_impl(module, &hexstr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							| 
									
										
										
										
											2014-01-26 10:41:58 -05:00
										 |  |  |     /* Cleanup for hexstr */ | 
					
						
							|  |  |  |     if (hexstr.obj) | 
					
						
							|  |  |  |        PyBuffer_Release(&hexstr); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | PyDoc_STRVAR(binascii_unhexlify__doc__, | 
					
						
							|  |  |  | "unhexlify($module, hexstr, /)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "Binary data of hexadecimal representation.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "hexstr must contain an even number of hex digits (upper or lower case)."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_UNHEXLIFY_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2015-04-04 00:12:11 +03:00
										 |  |  |     {"unhexlify", (PyCFunction)binascii_unhexlify, METH_O, binascii_unhexlify__doc__}, | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_unhexlify_impl(PyObject *module, Py_buffer *hexstr); | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_unhexlify(PyObject *module, PyObject *arg) | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							|  |  |  |     Py_buffer hexstr = {NULL, NULL}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-25 13:23:47 +02:00
										 |  |  |     if (!ascii_buffer_converter(arg, &hexstr)) { | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-01-20 13:59:46 -06:00
										 |  |  |     return_value = binascii_unhexlify_impl(module, &hexstr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     /* Cleanup for hexstr */ | 
					
						
							|  |  |  |     if (hexstr.obj) | 
					
						
							|  |  |  |        PyBuffer_Release(&hexstr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | PyDoc_STRVAR(binascii_a2b_qp__doc__, | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "a2b_qp($module, /, data, header=False)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "Decode a string of qp-encoded data."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_A2B_QP_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"a2b_qp", _PyCFunction_CAST(binascii_a2b_qp), METH_FASTCALL|METH_KEYWORDS, binascii_a2b_qp__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2016-08-14 10:52:18 +03:00
										 |  |  |     static const char * const _keywords[] = {"data", "header", NULL}; | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     static _PyArg_Parser _parser = {NULL, _keywords, "a2b_qp", 0}; | 
					
						
							|  |  |  |     PyObject *argsbuf[2]; | 
					
						
							|  |  |  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; | 
					
						
							| 
									
										
										
										
											2014-01-26 10:41:58 -05:00
										 |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     int header = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); | 
					
						
							|  |  |  |     if (!args) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!ascii_buffer_converter(args[0], &data)) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!noptargs) { | 
					
						
							|  |  |  |         goto skip_optional_pos; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     header = _PyLong_AsInt(args[1]); | 
					
						
							|  |  |  |     if (header == -1 && PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  | skip_optional_pos: | 
					
						
							| 
									
										
										
										
											2014-01-25 11:49:49 +02:00
										 |  |  |     return_value = binascii_a2b_qp_impl(module, &data, header); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							| 
									
										
										
										
											2014-01-26 10:41:58 -05:00
										 |  |  |     /* Cleanup for data */ | 
					
						
							|  |  |  |     if (data.obj) | 
					
						
							|  |  |  |        PyBuffer_Release(&data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(binascii_b2a_qp__doc__, | 
					
						
							| 
									
										
										
										
											2014-02-08 22:15:29 -08:00
										 |  |  | "b2a_qp($module, /, data, quotetabs=False, istext=True, header=False)\n" | 
					
						
							|  |  |  | "--\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | "Encode a string using quoted-printable encoding.\n" | 
					
						
							|  |  |  | "\n" | 
					
						
							|  |  |  | "On encoding, when istext is set, newlines are not encoded, and white\n" | 
					
						
							|  |  |  | "space at end of lines is.  When istext is not set, \\r and \\n (CR/LF)\n" | 
					
						
							|  |  |  | "are both encoded.  When quotetabs is set, space and tabs are encoded."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BINASCII_B2A_QP_METHODDEF    \
 | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  |     {"b2a_qp", _PyCFunction_CAST(binascii_b2a_qp), METH_FASTCALL|METH_KEYWORDS, binascii_b2a_qp__doc__}, | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2016-07-07 17:35:15 +03:00
										 |  |  | binascii_b2a_qp_impl(PyObject *module, Py_buffer *data, int quotetabs, | 
					
						
							| 
									
										
										
										
											2015-04-14 18:07:59 -04:00
										 |  |  |                      int istext, int header); | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2017-12-15 13:11:11 +02:00
										 |  |  | binascii_b2a_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *return_value = NULL; | 
					
						
							| 
									
										
										
										
											2016-08-14 10:52:18 +03:00
										 |  |  |     static const char * const _keywords[] = {"data", "quotetabs", "istext", "header", NULL}; | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     static _PyArg_Parser _parser = {NULL, _keywords, "b2a_qp", 0}; | 
					
						
							|  |  |  |     PyObject *argsbuf[4]; | 
					
						
							|  |  |  |     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     Py_buffer data = {NULL, NULL}; | 
					
						
							|  |  |  |     int quotetabs = 0; | 
					
						
							|  |  |  |     int istext = 1; | 
					
						
							|  |  |  |     int header = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf); | 
					
						
							|  |  |  |     if (!args) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { | 
					
						
							|  |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!PyBuffer_IsContiguous(&data, 'C')) { | 
					
						
							| 
									
										
										
										
											2019-08-29 16:49:08 +02:00
										 |  |  |         _PyArg_BadArgument("b2a_qp", "argument 'data'", "contiguous buffer", args[0]); | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  |         goto exit; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (!noptargs) { | 
					
						
							|  |  |  |         goto skip_optional_pos; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (args[1]) { | 
					
						
							|  |  |  |         quotetabs = _PyLong_AsInt(args[1]); | 
					
						
							|  |  |  |         if (quotetabs == -1 && PyErr_Occurred()) { | 
					
						
							|  |  |  |             goto exit; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!--noptargs) { | 
					
						
							|  |  |  |             goto skip_optional_pos; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (args[2]) { | 
					
						
							|  |  |  |         istext = _PyLong_AsInt(args[2]); | 
					
						
							|  |  |  |         if (istext == -1 && PyErr_Occurred()) { | 
					
						
							|  |  |  |             goto exit; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!--noptargs) { | 
					
						
							|  |  |  |             goto skip_optional_pos; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     header = _PyLong_AsInt(args[3]); | 
					
						
							|  |  |  |     if (header == -1 && PyErr_Occurred()) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |         goto exit; | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-03-14 10:32:22 +02:00
										 |  |  | skip_optional_pos: | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |     return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exit: | 
					
						
							|  |  |  |     /* Cleanup for data */ | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     if (data.obj) { | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  |        PyBuffer_Release(&data); | 
					
						
							| 
									
										
										
										
											2016-06-09 16:16:06 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-01-25 11:21:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return return_value; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-05-03 20:25:41 +02:00
										 |  |  | /*[clinic end generated code: output=ba9ed7b810b8762d input=a9049054013a1b77]*/ |