Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(binascii_a2b_uu__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 6 | "a2b_uu($module, data, /)\n" |
| 7 | "--\n" |
| 8 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 9 | "Decode a line of uuencoded data."); |
| 10 | |
| 11 | #define BINASCII_A2B_UU_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 12 | {"a2b_uu", (PyCFunction)binascii_a2b_uu, METH_O, binascii_a2b_uu__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 13 | |
| 14 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 15 | binascii_a2b_uu_impl(PyObject *module, Py_buffer *data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 16 | |
| 17 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 18 | binascii_a2b_uu(PyObject *module, PyObject *arg) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 19 | { |
| 20 | PyObject *return_value = NULL; |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 21 | Py_buffer data = {NULL, NULL}; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 22 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 23 | if (!ascii_buffer_converter(arg, &data)) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 24 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 25 | } |
Serhiy Storchaka | 1278561 | 2014-01-25 11:49:49 +0200 | [diff] [blame] | 26 | return_value = binascii_a2b_uu_impl(module, &data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 27 | |
| 28 | exit: |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 29 | /* Cleanup for data */ |
| 30 | if (data.obj) |
| 31 | PyBuffer_Release(&data); |
| 32 | |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 33 | return return_value; |
| 34 | } |
| 35 | |
| 36 | PyDoc_STRVAR(binascii_b2a_uu__doc__, |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 37 | "b2a_uu($module, data, /, *, backtick=False)\n" |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 38 | "--\n" |
| 39 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 40 | "Uuencode line of data."); |
| 41 | |
| 42 | #define BINASCII_B2A_UU_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 43 | {"b2a_uu", (PyCFunction)(void(*)(void))binascii_b2a_uu, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_uu__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 44 | |
| 45 | static PyObject * |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 46 | binascii_b2a_uu_impl(PyObject *module, Py_buffer *data, int backtick); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 47 | |
| 48 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 49 | binascii_b2a_uu(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 50 | { |
| 51 | PyObject *return_value = NULL; |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 52 | static const char * const _keywords[] = {"", "backtick", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 53 | static _PyArg_Parser _parser = {NULL, _keywords, "b2a_uu", 0}; |
| 54 | PyObject *argsbuf[2]; |
| 55 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 56 | Py_buffer data = {NULL, NULL}; |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 57 | int backtick = 0; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 58 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 59 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 60 | if (!args) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 61 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 62 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 63 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
| 64 | goto exit; |
| 65 | } |
| 66 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 67 | _PyArg_BadArgument("b2a_uu", "argument 1", "contiguous buffer", args[0]); |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 68 | goto exit; |
| 69 | } |
| 70 | if (!noptargs) { |
| 71 | goto skip_optional_kwonly; |
| 72 | } |
| 73 | if (PyFloat_Check(args[1])) { |
| 74 | PyErr_SetString(PyExc_TypeError, |
| 75 | "integer argument expected, got float" ); |
| 76 | goto exit; |
| 77 | } |
| 78 | backtick = _PyLong_AsInt(args[1]); |
| 79 | if (backtick == -1 && PyErr_Occurred()) { |
| 80 | goto exit; |
| 81 | } |
| 82 | skip_optional_kwonly: |
Xiang Zhang | 13f1f42 | 2017-05-03 11:16:21 +0800 | [diff] [blame] | 83 | return_value = binascii_b2a_uu_impl(module, &data, backtick); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 84 | |
| 85 | exit: |
| 86 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 87 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 88 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 89 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 90 | |
| 91 | return return_value; |
| 92 | } |
| 93 | |
| 94 | PyDoc_STRVAR(binascii_a2b_base64__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 95 | "a2b_base64($module, data, /)\n" |
| 96 | "--\n" |
| 97 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 98 | "Decode a line of base64 data."); |
| 99 | |
| 100 | #define BINASCII_A2B_BASE64_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 101 | {"a2b_base64", (PyCFunction)binascii_a2b_base64, METH_O, binascii_a2b_base64__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 102 | |
| 103 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 104 | binascii_a2b_base64_impl(PyObject *module, Py_buffer *data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 105 | |
| 106 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 107 | binascii_a2b_base64(PyObject *module, PyObject *arg) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 108 | { |
| 109 | PyObject *return_value = NULL; |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 110 | Py_buffer data = {NULL, NULL}; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 111 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 112 | if (!ascii_buffer_converter(arg, &data)) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 113 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 114 | } |
Serhiy Storchaka | 1278561 | 2014-01-25 11:49:49 +0200 | [diff] [blame] | 115 | return_value = binascii_a2b_base64_impl(module, &data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 116 | |
| 117 | exit: |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 118 | /* Cleanup for data */ |
| 119 | if (data.obj) |
| 120 | PyBuffer_Release(&data); |
| 121 | |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 122 | return return_value; |
| 123 | } |
| 124 | |
| 125 | PyDoc_STRVAR(binascii_b2a_base64__doc__, |
Xiang Zhang | 1374dbb | 2017-05-01 13:12:07 +0800 | [diff] [blame] | 126 | "b2a_base64($module, data, /, *, newline=True)\n" |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 127 | "--\n" |
| 128 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 129 | "Base64-code line of data."); |
| 130 | |
| 131 | #define BINASCII_B2A_BASE64_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 132 | {"b2a_base64", (PyCFunction)(void(*)(void))binascii_b2a_base64, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_base64__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 133 | |
| 134 | static PyObject * |
Serhiy Storchaka | 2954f83 | 2016-07-07 18:20:03 +0300 | [diff] [blame] | 135 | binascii_b2a_base64_impl(PyObject *module, Py_buffer *data, int newline); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 136 | |
| 137 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 138 | binascii_b2a_base64(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 139 | { |
| 140 | PyObject *return_value = NULL; |
Xiang Zhang | 1374dbb | 2017-05-01 13:12:07 +0800 | [diff] [blame] | 141 | static const char * const _keywords[] = {"", "newline", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 142 | static _PyArg_Parser _parser = {NULL, _keywords, "b2a_base64", 0}; |
| 143 | PyObject *argsbuf[2]; |
| 144 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 145 | Py_buffer data = {NULL, NULL}; |
Victor Stinner | e84c976 | 2015-10-11 11:01:02 +0200 | [diff] [blame] | 146 | int newline = 1; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 147 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 148 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 149 | if (!args) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 150 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 151 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 152 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
| 153 | goto exit; |
| 154 | } |
| 155 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 156 | _PyArg_BadArgument("b2a_base64", "argument 1", "contiguous buffer", args[0]); |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 157 | goto exit; |
| 158 | } |
| 159 | if (!noptargs) { |
| 160 | goto skip_optional_kwonly; |
| 161 | } |
| 162 | if (PyFloat_Check(args[1])) { |
| 163 | PyErr_SetString(PyExc_TypeError, |
| 164 | "integer argument expected, got float" ); |
| 165 | goto exit; |
| 166 | } |
| 167 | newline = _PyLong_AsInt(args[1]); |
| 168 | if (newline == -1 && PyErr_Occurred()) { |
| 169 | goto exit; |
| 170 | } |
| 171 | skip_optional_kwonly: |
Victor Stinner | e84c976 | 2015-10-11 11:01:02 +0200 | [diff] [blame] | 172 | return_value = binascii_b2a_base64_impl(module, &data, newline); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 173 | |
| 174 | exit: |
| 175 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 176 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 177 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 178 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 179 | |
| 180 | return return_value; |
| 181 | } |
| 182 | |
| 183 | PyDoc_STRVAR(binascii_a2b_hqx__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 184 | "a2b_hqx($module, data, /)\n" |
| 185 | "--\n" |
| 186 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 187 | "Decode .hqx coding."); |
| 188 | |
| 189 | #define BINASCII_A2B_HQX_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 190 | {"a2b_hqx", (PyCFunction)binascii_a2b_hqx, METH_O, binascii_a2b_hqx__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 191 | |
| 192 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 193 | binascii_a2b_hqx_impl(PyObject *module, Py_buffer *data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 194 | |
| 195 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 196 | binascii_a2b_hqx(PyObject *module, PyObject *arg) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 197 | { |
| 198 | PyObject *return_value = NULL; |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 199 | Py_buffer data = {NULL, NULL}; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 200 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 201 | if (!ascii_buffer_converter(arg, &data)) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 202 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 203 | } |
Serhiy Storchaka | 1278561 | 2014-01-25 11:49:49 +0200 | [diff] [blame] | 204 | return_value = binascii_a2b_hqx_impl(module, &data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 205 | |
| 206 | exit: |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 207 | /* Cleanup for data */ |
| 208 | if (data.obj) |
| 209 | PyBuffer_Release(&data); |
| 210 | |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 211 | return return_value; |
| 212 | } |
| 213 | |
| 214 | PyDoc_STRVAR(binascii_rlecode_hqx__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 215 | "rlecode_hqx($module, data, /)\n" |
| 216 | "--\n" |
| 217 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 218 | "Binhex RLE-code binary data."); |
| 219 | |
| 220 | #define BINASCII_RLECODE_HQX_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 221 | {"rlecode_hqx", (PyCFunction)binascii_rlecode_hqx, METH_O, binascii_rlecode_hqx__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 222 | |
| 223 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 224 | binascii_rlecode_hqx_impl(PyObject *module, Py_buffer *data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 225 | |
| 226 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 227 | binascii_rlecode_hqx(PyObject *module, PyObject *arg) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 228 | { |
| 229 | PyObject *return_value = NULL; |
| 230 | Py_buffer data = {NULL, NULL}; |
| 231 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 232 | if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { |
| 233 | goto exit; |
| 234 | } |
| 235 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 236 | _PyArg_BadArgument("rlecode_hqx", "argument", "contiguous buffer", arg); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 237 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 238 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 239 | return_value = binascii_rlecode_hqx_impl(module, &data); |
| 240 | |
| 241 | exit: |
| 242 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 243 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 244 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 245 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 246 | |
| 247 | return return_value; |
| 248 | } |
| 249 | |
| 250 | PyDoc_STRVAR(binascii_b2a_hqx__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 251 | "b2a_hqx($module, data, /)\n" |
| 252 | "--\n" |
| 253 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 254 | "Encode .hqx data."); |
| 255 | |
| 256 | #define BINASCII_B2A_HQX_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 257 | {"b2a_hqx", (PyCFunction)binascii_b2a_hqx, METH_O, binascii_b2a_hqx__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 258 | |
| 259 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 260 | binascii_b2a_hqx_impl(PyObject *module, Py_buffer *data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 261 | |
| 262 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 263 | binascii_b2a_hqx(PyObject *module, PyObject *arg) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 264 | { |
| 265 | PyObject *return_value = NULL; |
| 266 | Py_buffer data = {NULL, NULL}; |
| 267 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 268 | if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { |
| 269 | goto exit; |
| 270 | } |
| 271 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 272 | _PyArg_BadArgument("b2a_hqx", "argument", "contiguous buffer", arg); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 273 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 274 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 275 | return_value = binascii_b2a_hqx_impl(module, &data); |
| 276 | |
| 277 | exit: |
| 278 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 279 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 280 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 281 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 282 | |
| 283 | return return_value; |
| 284 | } |
| 285 | |
| 286 | PyDoc_STRVAR(binascii_rledecode_hqx__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 287 | "rledecode_hqx($module, data, /)\n" |
| 288 | "--\n" |
| 289 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 290 | "Decode hexbin RLE-coded string."); |
| 291 | |
| 292 | #define BINASCII_RLEDECODE_HQX_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 293 | {"rledecode_hqx", (PyCFunction)binascii_rledecode_hqx, METH_O, binascii_rledecode_hqx__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 294 | |
| 295 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 296 | binascii_rledecode_hqx_impl(PyObject *module, Py_buffer *data); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 297 | |
| 298 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 299 | binascii_rledecode_hqx(PyObject *module, PyObject *arg) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 300 | { |
| 301 | PyObject *return_value = NULL; |
| 302 | Py_buffer data = {NULL, NULL}; |
| 303 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 304 | if (PyObject_GetBuffer(arg, &data, PyBUF_SIMPLE) != 0) { |
| 305 | goto exit; |
| 306 | } |
| 307 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 308 | _PyArg_BadArgument("rledecode_hqx", "argument", "contiguous buffer", arg); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 309 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 310 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 311 | return_value = binascii_rledecode_hqx_impl(module, &data); |
| 312 | |
| 313 | exit: |
| 314 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 315 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 316 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 317 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 318 | |
| 319 | return return_value; |
| 320 | } |
| 321 | |
| 322 | PyDoc_STRVAR(binascii_crc_hqx__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 323 | "crc_hqx($module, data, crc, /)\n" |
| 324 | "--\n" |
| 325 | "\n" |
Martin Panter | 3310e14 | 2016-12-24 07:36:44 +0000 | [diff] [blame] | 326 | "Compute CRC-CCITT incrementally."); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 327 | |
| 328 | #define BINASCII_CRC_HQX_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 329 | {"crc_hqx", (PyCFunction)(void(*)(void))binascii_crc_hqx, METH_FASTCALL, binascii_crc_hqx__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 330 | |
Serhiy Storchaka | 2ef7c47 | 2015-04-20 09:26:49 +0300 | [diff] [blame] | 331 | static unsigned int |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 332 | binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 333 | |
| 334 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 335 | binascii_crc_hqx(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 336 | { |
| 337 | PyObject *return_value = NULL; |
| 338 | Py_buffer data = {NULL, NULL}; |
Serhiy Storchaka | 2ef7c47 | 2015-04-20 09:26:49 +0300 | [diff] [blame] | 339 | unsigned int crc; |
| 340 | unsigned int _return_value; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 341 | |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame] | 342 | if (!_PyArg_CheckPositional("crc_hqx", nargs, 2, 2)) { |
| 343 | goto exit; |
| 344 | } |
| 345 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
| 346 | goto exit; |
| 347 | } |
| 348 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 349 | _PyArg_BadArgument("crc_hqx", "argument 1", "contiguous buffer", args[0]); |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame] | 350 | goto exit; |
| 351 | } |
| 352 | if (PyFloat_Check(args[1])) { |
| 353 | PyErr_SetString(PyExc_TypeError, |
| 354 | "integer argument expected, got float" ); |
| 355 | goto exit; |
| 356 | } |
| 357 | crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); |
| 358 | if (crc == (unsigned int)-1 && PyErr_Occurred()) { |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 359 | goto exit; |
| 360 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 361 | _return_value = binascii_crc_hqx_impl(module, &data, crc); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 362 | if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 363 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 364 | } |
Serhiy Storchaka | 2ef7c47 | 2015-04-20 09:26:49 +0300 | [diff] [blame] | 365 | return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 366 | |
| 367 | exit: |
| 368 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 369 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 370 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 371 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 372 | |
| 373 | return return_value; |
| 374 | } |
| 375 | |
| 376 | PyDoc_STRVAR(binascii_crc32__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 377 | "crc32($module, data, crc=0, /)\n" |
| 378 | "--\n" |
| 379 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 380 | "Compute CRC-32 incrementally."); |
| 381 | |
| 382 | #define BINASCII_CRC32_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 383 | {"crc32", (PyCFunction)(void(*)(void))binascii_crc32, METH_FASTCALL, binascii_crc32__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 384 | |
| 385 | static unsigned int |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 386 | binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 387 | |
| 388 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 389 | binascii_crc32(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 390 | { |
| 391 | PyObject *return_value = NULL; |
| 392 | Py_buffer data = {NULL, NULL}; |
| 393 | unsigned int crc = 0; |
| 394 | unsigned int _return_value; |
| 395 | |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame] | 396 | if (!_PyArg_CheckPositional("crc32", nargs, 1, 2)) { |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 397 | goto exit; |
| 398 | } |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame] | 399 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
| 400 | goto exit; |
| 401 | } |
| 402 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 403 | _PyArg_BadArgument("crc32", "argument 1", "contiguous buffer", args[0]); |
Serhiy Storchaka | 4fa9591 | 2019-01-11 16:01:14 +0200 | [diff] [blame] | 404 | goto exit; |
| 405 | } |
| 406 | if (nargs < 2) { |
| 407 | goto skip_optional; |
| 408 | } |
| 409 | if (PyFloat_Check(args[1])) { |
| 410 | PyErr_SetString(PyExc_TypeError, |
| 411 | "integer argument expected, got float" ); |
| 412 | goto exit; |
| 413 | } |
| 414 | crc = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); |
| 415 | if (crc == (unsigned int)-1 && PyErr_Occurred()) { |
| 416 | goto exit; |
| 417 | } |
| 418 | skip_optional: |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 419 | _return_value = binascii_crc32_impl(module, &data, crc); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 420 | if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 421 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 422 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 423 | return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); |
| 424 | |
| 425 | exit: |
| 426 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 427 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 428 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 429 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 430 | |
| 431 | return return_value; |
| 432 | } |
| 433 | |
| 434 | PyDoc_STRVAR(binascii_b2a_hex__doc__, |
Serhiy Storchaka | 279f446 | 2019-09-14 12:24:05 +0300 | [diff] [blame] | 435 | "b2a_hex($module, /, data, sep=<unrepresentable>, bytes_per_sep=1)\n" |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 436 | "--\n" |
| 437 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 438 | "Hexadecimal representation of binary data.\n" |
| 439 | "\n" |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 440 | " sep\n" |
| 441 | " An optional single character or byte to separate hex bytes.\n" |
| 442 | " bytes_per_sep\n" |
| 443 | " How many bytes between separators. Positive values count from the\n" |
| 444 | " right, negative values count from the left.\n" |
| 445 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 446 | "The return value is a bytes object. This function is also\n" |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 447 | "available as \"hexlify()\".\n" |
| 448 | "\n" |
| 449 | "Example:\n" |
| 450 | ">>> binascii.b2a_hex(b\'\\xb9\\x01\\xef\')\n" |
| 451 | "b\'b901ef\'\n" |
| 452 | ">>> binascii.hexlify(b\'\\xb9\\x01\\xef\', \':\')\n" |
| 453 | "b\'b9:01:ef\'\n" |
| 454 | ">>> binascii.b2a_hex(b\'\\xb9\\x01\\xef\', b\'_\', 2)\n" |
| 455 | "b\'b9_01ef\'"); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 456 | |
| 457 | #define BINASCII_B2A_HEX_METHODDEF \ |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 458 | {"b2a_hex", (PyCFunction)(void(*)(void))binascii_b2a_hex, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_hex__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 459 | |
| 460 | static PyObject * |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 461 | binascii_b2a_hex_impl(PyObject *module, Py_buffer *data, PyObject *sep, |
| 462 | int bytes_per_sep); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 463 | |
| 464 | static PyObject * |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 465 | binascii_b2a_hex(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 466 | { |
| 467 | PyObject *return_value = NULL; |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 468 | static const char * const _keywords[] = {"data", "sep", "bytes_per_sep", NULL}; |
| 469 | static _PyArg_Parser _parser = {NULL, _keywords, "b2a_hex", 0}; |
| 470 | PyObject *argsbuf[3]; |
| 471 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 472 | Py_buffer data = {NULL, NULL}; |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 473 | PyObject *sep = NULL; |
| 474 | int bytes_per_sep = 1; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 475 | |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 476 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); |
| 477 | if (!args) { |
| 478 | goto exit; |
| 479 | } |
| 480 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 481 | goto exit; |
| 482 | } |
| 483 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 484 | _PyArg_BadArgument("b2a_hex", "argument 'data'", "contiguous buffer", args[0]); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 485 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 486 | } |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 487 | if (!noptargs) { |
| 488 | goto skip_optional_pos; |
| 489 | } |
| 490 | if (args[1]) { |
| 491 | sep = args[1]; |
| 492 | if (!--noptargs) { |
| 493 | goto skip_optional_pos; |
| 494 | } |
| 495 | } |
| 496 | if (PyFloat_Check(args[2])) { |
| 497 | PyErr_SetString(PyExc_TypeError, |
| 498 | "integer argument expected, got float" ); |
| 499 | goto exit; |
| 500 | } |
| 501 | bytes_per_sep = _PyLong_AsInt(args[2]); |
| 502 | if (bytes_per_sep == -1 && PyErr_Occurred()) { |
| 503 | goto exit; |
| 504 | } |
| 505 | skip_optional_pos: |
| 506 | return_value = binascii_b2a_hex_impl(module, &data, sep, bytes_per_sep); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 507 | |
| 508 | exit: |
| 509 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 510 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 511 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 512 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 513 | |
| 514 | return return_value; |
| 515 | } |
| 516 | |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 517 | PyDoc_STRVAR(binascii_hexlify__doc__, |
Serhiy Storchaka | 279f446 | 2019-09-14 12:24:05 +0300 | [diff] [blame] | 518 | "hexlify($module, /, data, sep=<unrepresentable>, bytes_per_sep=1)\n" |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 519 | "--\n" |
| 520 | "\n" |
| 521 | "Hexadecimal representation of binary data.\n" |
| 522 | "\n" |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 523 | " sep\n" |
| 524 | " An optional single character or byte to separate hex bytes.\n" |
| 525 | " bytes_per_sep\n" |
| 526 | " How many bytes between separators. Positive values count from the\n" |
| 527 | " right, negative values count from the left.\n" |
| 528 | "\n" |
| 529 | "The return value is a bytes object. This function is also\n" |
| 530 | "available as \"b2a_hex()\"."); |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 531 | |
| 532 | #define BINASCII_HEXLIFY_METHODDEF \ |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 533 | {"hexlify", (PyCFunction)(void(*)(void))binascii_hexlify, METH_FASTCALL|METH_KEYWORDS, binascii_hexlify__doc__}, |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 534 | |
| 535 | static PyObject * |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 536 | binascii_hexlify_impl(PyObject *module, Py_buffer *data, PyObject *sep, |
| 537 | int bytes_per_sep); |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 538 | |
| 539 | static PyObject * |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 540 | binascii_hexlify(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 541 | { |
| 542 | PyObject *return_value = NULL; |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 543 | static const char * const _keywords[] = {"data", "sep", "bytes_per_sep", NULL}; |
| 544 | static _PyArg_Parser _parser = {NULL, _keywords, "hexlify", 0}; |
| 545 | PyObject *argsbuf[3]; |
| 546 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 547 | Py_buffer data = {NULL, NULL}; |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 548 | PyObject *sep = NULL; |
| 549 | int bytes_per_sep = 1; |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 550 | |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 551 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); |
| 552 | if (!args) { |
| 553 | goto exit; |
| 554 | } |
| 555 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 556 | goto exit; |
| 557 | } |
| 558 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 559 | _PyArg_BadArgument("hexlify", "argument 'data'", "contiguous buffer", args[0]); |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 560 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 561 | } |
Gregory P. Smith | 0c2f930 | 2019-05-29 11:46:58 -0700 | [diff] [blame] | 562 | if (!noptargs) { |
| 563 | goto skip_optional_pos; |
| 564 | } |
| 565 | if (args[1]) { |
| 566 | sep = args[1]; |
| 567 | if (!--noptargs) { |
| 568 | goto skip_optional_pos; |
| 569 | } |
| 570 | } |
| 571 | if (PyFloat_Check(args[2])) { |
| 572 | PyErr_SetString(PyExc_TypeError, |
| 573 | "integer argument expected, got float" ); |
| 574 | goto exit; |
| 575 | } |
| 576 | bytes_per_sep = _PyLong_AsInt(args[2]); |
| 577 | if (bytes_per_sep == -1 && PyErr_Occurred()) { |
| 578 | goto exit; |
| 579 | } |
| 580 | skip_optional_pos: |
| 581 | return_value = binascii_hexlify_impl(module, &data, sep, bytes_per_sep); |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 582 | |
| 583 | exit: |
| 584 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 585 | if (data.obj) { |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 586 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 587 | } |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 588 | |
| 589 | return return_value; |
| 590 | } |
| 591 | |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 592 | PyDoc_STRVAR(binascii_a2b_hex__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 593 | "a2b_hex($module, hexstr, /)\n" |
| 594 | "--\n" |
| 595 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 596 | "Binary data of hexadecimal representation.\n" |
| 597 | "\n" |
| 598 | "hexstr must contain an even number of hex digits (upper or lower case).\n" |
| 599 | "This function is also available as \"unhexlify()\"."); |
| 600 | |
| 601 | #define BINASCII_A2B_HEX_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 602 | {"a2b_hex", (PyCFunction)binascii_a2b_hex, METH_O, binascii_a2b_hex__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 603 | |
| 604 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 605 | binascii_a2b_hex_impl(PyObject *module, Py_buffer *hexstr); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 606 | |
| 607 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 608 | binascii_a2b_hex(PyObject *module, PyObject *arg) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 609 | { |
| 610 | PyObject *return_value = NULL; |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 611 | Py_buffer hexstr = {NULL, NULL}; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 612 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 613 | if (!ascii_buffer_converter(arg, &hexstr)) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 614 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 615 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 616 | return_value = binascii_a2b_hex_impl(module, &hexstr); |
| 617 | |
| 618 | exit: |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 619 | /* Cleanup for hexstr */ |
| 620 | if (hexstr.obj) |
| 621 | PyBuffer_Release(&hexstr); |
| 622 | |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 623 | return return_value; |
| 624 | } |
| 625 | |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 626 | PyDoc_STRVAR(binascii_unhexlify__doc__, |
| 627 | "unhexlify($module, hexstr, /)\n" |
| 628 | "--\n" |
| 629 | "\n" |
| 630 | "Binary data of hexadecimal representation.\n" |
| 631 | "\n" |
| 632 | "hexstr must contain an even number of hex digits (upper or lower case)."); |
| 633 | |
| 634 | #define BINASCII_UNHEXLIFY_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 635 | {"unhexlify", (PyCFunction)binascii_unhexlify, METH_O, binascii_unhexlify__doc__}, |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 636 | |
| 637 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 638 | binascii_unhexlify_impl(PyObject *module, Py_buffer *hexstr); |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 639 | |
| 640 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 641 | binascii_unhexlify(PyObject *module, PyObject *arg) |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 642 | { |
| 643 | PyObject *return_value = NULL; |
| 644 | Py_buffer hexstr = {NULL, NULL}; |
| 645 | |
Serhiy Storchaka | 32d96a2 | 2018-12-25 13:23:47 +0200 | [diff] [blame] | 646 | if (!ascii_buffer_converter(arg, &hexstr)) { |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 647 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 648 | } |
Zachary Ware | b176d40 | 2015-01-20 13:59:46 -0600 | [diff] [blame] | 649 | return_value = binascii_unhexlify_impl(module, &hexstr); |
| 650 | |
| 651 | exit: |
| 652 | /* Cleanup for hexstr */ |
| 653 | if (hexstr.obj) |
| 654 | PyBuffer_Release(&hexstr); |
| 655 | |
| 656 | return return_value; |
| 657 | } |
| 658 | |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 659 | PyDoc_STRVAR(binascii_a2b_qp__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 660 | "a2b_qp($module, /, data, header=False)\n" |
| 661 | "--\n" |
| 662 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 663 | "Decode a string of qp-encoded data."); |
| 664 | |
| 665 | #define BINASCII_A2B_QP_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 666 | {"a2b_qp", (PyCFunction)(void(*)(void))binascii_a2b_qp, METH_FASTCALL|METH_KEYWORDS, binascii_a2b_qp__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 667 | |
| 668 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 669 | binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 670 | |
| 671 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 672 | binascii_a2b_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 673 | { |
| 674 | PyObject *return_value = NULL; |
Serhiy Storchaka | 9171a8b | 2016-08-14 10:52:18 +0300 | [diff] [blame] | 675 | static const char * const _keywords[] = {"data", "header", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 676 | static _PyArg_Parser _parser = {NULL, _keywords, "a2b_qp", 0}; |
| 677 | PyObject *argsbuf[2]; |
| 678 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 679 | Py_buffer data = {NULL, NULL}; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 680 | int header = 0; |
| 681 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 682 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
| 683 | if (!args) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 684 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 685 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 686 | if (!ascii_buffer_converter(args[0], &data)) { |
| 687 | goto exit; |
| 688 | } |
| 689 | if (!noptargs) { |
| 690 | goto skip_optional_pos; |
| 691 | } |
| 692 | if (PyFloat_Check(args[1])) { |
| 693 | PyErr_SetString(PyExc_TypeError, |
| 694 | "integer argument expected, got float" ); |
| 695 | goto exit; |
| 696 | } |
| 697 | header = _PyLong_AsInt(args[1]); |
| 698 | if (header == -1 && PyErr_Occurred()) { |
| 699 | goto exit; |
| 700 | } |
| 701 | skip_optional_pos: |
Serhiy Storchaka | 1278561 | 2014-01-25 11:49:49 +0200 | [diff] [blame] | 702 | return_value = binascii_a2b_qp_impl(module, &data, header); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 703 | |
| 704 | exit: |
Benjamin Peterson | b62deac | 2014-01-26 10:41:58 -0500 | [diff] [blame] | 705 | /* Cleanup for data */ |
| 706 | if (data.obj) |
| 707 | PyBuffer_Release(&data); |
| 708 | |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 709 | return return_value; |
| 710 | } |
| 711 | |
| 712 | PyDoc_STRVAR(binascii_b2a_qp__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 713 | "b2a_qp($module, /, data, quotetabs=False, istext=True, header=False)\n" |
| 714 | "--\n" |
| 715 | "\n" |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 716 | "Encode a string using quoted-printable encoding.\n" |
| 717 | "\n" |
| 718 | "On encoding, when istext is set, newlines are not encoded, and white\n" |
| 719 | "space at end of lines is. When istext is not set, \\r and \\n (CR/LF)\n" |
| 720 | "are both encoded. When quotetabs is set, space and tabs are encoded."); |
| 721 | |
| 722 | #define BINASCII_B2A_QP_METHODDEF \ |
Serhiy Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 723 | {"b2a_qp", (PyCFunction)(void(*)(void))binascii_b2a_qp, METH_FASTCALL|METH_KEYWORDS, binascii_b2a_qp__doc__}, |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 724 | |
| 725 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 726 | binascii_b2a_qp_impl(PyObject *module, Py_buffer *data, int quotetabs, |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 727 | int istext, int header); |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 728 | |
| 729 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 730 | binascii_b2a_qp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 731 | { |
| 732 | PyObject *return_value = NULL; |
Serhiy Storchaka | 9171a8b | 2016-08-14 10:52:18 +0300 | [diff] [blame] | 733 | static const char * const _keywords[] = {"data", "quotetabs", "istext", "header", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 734 | static _PyArg_Parser _parser = {NULL, _keywords, "b2a_qp", 0}; |
| 735 | PyObject *argsbuf[4]; |
| 736 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 737 | Py_buffer data = {NULL, NULL}; |
| 738 | int quotetabs = 0; |
| 739 | int istext = 1; |
| 740 | int header = 0; |
| 741 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 742 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf); |
| 743 | if (!args) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 744 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 745 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 746 | if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) { |
| 747 | goto exit; |
| 748 | } |
| 749 | if (!PyBuffer_IsContiguous(&data, 'C')) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 750 | _PyArg_BadArgument("b2a_qp", "argument 'data'", "contiguous buffer", args[0]); |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 751 | goto exit; |
| 752 | } |
| 753 | if (!noptargs) { |
| 754 | goto skip_optional_pos; |
| 755 | } |
| 756 | if (args[1]) { |
| 757 | if (PyFloat_Check(args[1])) { |
| 758 | PyErr_SetString(PyExc_TypeError, |
| 759 | "integer argument expected, got float" ); |
| 760 | goto exit; |
| 761 | } |
| 762 | quotetabs = _PyLong_AsInt(args[1]); |
| 763 | if (quotetabs == -1 && PyErr_Occurred()) { |
| 764 | goto exit; |
| 765 | } |
| 766 | if (!--noptargs) { |
| 767 | goto skip_optional_pos; |
| 768 | } |
| 769 | } |
| 770 | if (args[2]) { |
| 771 | if (PyFloat_Check(args[2])) { |
| 772 | PyErr_SetString(PyExc_TypeError, |
| 773 | "integer argument expected, got float" ); |
| 774 | goto exit; |
| 775 | } |
| 776 | istext = _PyLong_AsInt(args[2]); |
| 777 | if (istext == -1 && PyErr_Occurred()) { |
| 778 | goto exit; |
| 779 | } |
| 780 | if (!--noptargs) { |
| 781 | goto skip_optional_pos; |
| 782 | } |
| 783 | } |
| 784 | if (PyFloat_Check(args[3])) { |
| 785 | PyErr_SetString(PyExc_TypeError, |
| 786 | "integer argument expected, got float" ); |
| 787 | goto exit; |
| 788 | } |
| 789 | header = _PyLong_AsInt(args[3]); |
| 790 | if (header == -1 && PyErr_Occurred()) { |
| 791 | goto exit; |
| 792 | } |
| 793 | skip_optional_pos: |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 794 | return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header); |
| 795 | |
| 796 | exit: |
| 797 | /* Cleanup for data */ |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 798 | if (data.obj) { |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 799 | PyBuffer_Release(&data); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 800 | } |
Serhiy Storchaka | 3ffd913 | 2014-01-25 11:21:23 +0200 | [diff] [blame] | 801 | |
| 802 | return return_value; |
| 803 | } |
Serhiy Storchaka | 279f446 | 2019-09-14 12:24:05 +0300 | [diff] [blame] | 804 | /*[clinic end generated code: output=ec26d03c2007eaac input=a9049054013a1b77]*/ |