Home | History | Annotate | Download | only in clinic
      1 /*[clinic input]
      2 preserve
      3 [clinic start generated code]*/
      4 
      5 PyDoc_STRVAR(binascii_a2b_uu__doc__,
      6 "a2b_uu($module, data, /)\n"
      7 "--\n"
      8 "\n"
      9 "Decode a line of uuencoded data.");
     10 
     11 #define BINASCII_A2B_UU_METHODDEF    \
     12     {"a2b_uu", (PyCFunction)binascii_a2b_uu, METH_O, binascii_a2b_uu__doc__},
     13 
     14 static PyObject *
     15 binascii_a2b_uu_impl(PyObject *module, Py_buffer *data);
     16 
     17 static PyObject *
     18 binascii_a2b_uu(PyObject *module, PyObject *arg)
     19 {
     20     PyObject *return_value = NULL;
     21     Py_buffer data = {NULL, NULL};
     22 
     23     if (!PyArg_Parse(arg, "O&:a2b_uu", ascii_buffer_converter, &data)) {
     24         goto exit;
     25     }
     26     return_value = binascii_a2b_uu_impl(module, &data);
     27 
     28 exit:
     29     /* Cleanup for data */
     30     if (data.obj)
     31        PyBuffer_Release(&data);
     32 
     33     return return_value;
     34 }
     35 
     36 PyDoc_STRVAR(binascii_b2a_uu__doc__,
     37 "b2a_uu($module, data, /)\n"
     38 "--\n"
     39 "\n"
     40 "Uuencode line of data.");
     41 
     42 #define BINASCII_B2A_UU_METHODDEF    \
     43     {"b2a_uu", (PyCFunction)binascii_b2a_uu, METH_O, binascii_b2a_uu__doc__},
     44 
     45 static PyObject *
     46 binascii_b2a_uu_impl(PyObject *module, Py_buffer *data);
     47 
     48 static PyObject *
     49 binascii_b2a_uu(PyObject *module, PyObject *arg)
     50 {
     51     PyObject *return_value = NULL;
     52     Py_buffer data = {NULL, NULL};
     53 
     54     if (!PyArg_Parse(arg, "y*:b2a_uu", &data)) {
     55         goto exit;
     56     }
     57     return_value = binascii_b2a_uu_impl(module, &data);
     58 
     59 exit:
     60     /* Cleanup for data */
     61     if (data.obj) {
     62        PyBuffer_Release(&data);
     63     }
     64 
     65     return return_value;
     66 }
     67 
     68 PyDoc_STRVAR(binascii_a2b_base64__doc__,
     69 "a2b_base64($module, data, /)\n"
     70 "--\n"
     71 "\n"
     72 "Decode a line of base64 data.");
     73 
     74 #define BINASCII_A2B_BASE64_METHODDEF    \
     75     {"a2b_base64", (PyCFunction)binascii_a2b_base64, METH_O, binascii_a2b_base64__doc__},
     76 
     77 static PyObject *
     78 binascii_a2b_base64_impl(PyObject *module, Py_buffer *data);
     79 
     80 static PyObject *
     81 binascii_a2b_base64(PyObject *module, PyObject *arg)
     82 {
     83     PyObject *return_value = NULL;
     84     Py_buffer data = {NULL, NULL};
     85 
     86     if (!PyArg_Parse(arg, "O&:a2b_base64", ascii_buffer_converter, &data)) {
     87         goto exit;
     88     }
     89     return_value = binascii_a2b_base64_impl(module, &data);
     90 
     91 exit:
     92     /* Cleanup for data */
     93     if (data.obj)
     94        PyBuffer_Release(&data);
     95 
     96     return return_value;
     97 }
     98 
     99 PyDoc_STRVAR(binascii_b2a_base64__doc__,
    100 "b2a_base64($module, /, data, *, newline=True)\n"
    101 "--\n"
    102 "\n"
    103 "Base64-code line of data.");
    104 
    105 #define BINASCII_B2A_BASE64_METHODDEF    \
    106     {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_FASTCALL, binascii_b2a_base64__doc__},
    107 
    108 static PyObject *
    109 binascii_b2a_base64_impl(PyObject *module, Py_buffer *data, int newline);
    110 
    111 static PyObject *
    112 binascii_b2a_base64(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    113 {
    114     PyObject *return_value = NULL;
    115     static const char * const _keywords[] = {"data", "newline", NULL};
    116     static _PyArg_Parser _parser = {"y*|$i:b2a_base64", _keywords, 0};
    117     Py_buffer data = {NULL, NULL};
    118     int newline = 1;
    119 
    120     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    121         &data, &newline)) {
    122         goto exit;
    123     }
    124     return_value = binascii_b2a_base64_impl(module, &data, newline);
    125 
    126 exit:
    127     /* Cleanup for data */
    128     if (data.obj) {
    129        PyBuffer_Release(&data);
    130     }
    131 
    132     return return_value;
    133 }
    134 
    135 PyDoc_STRVAR(binascii_a2b_hqx__doc__,
    136 "a2b_hqx($module, data, /)\n"
    137 "--\n"
    138 "\n"
    139 "Decode .hqx coding.");
    140 
    141 #define BINASCII_A2B_HQX_METHODDEF    \
    142     {"a2b_hqx", (PyCFunction)binascii_a2b_hqx, METH_O, binascii_a2b_hqx__doc__},
    143 
    144 static PyObject *
    145 binascii_a2b_hqx_impl(PyObject *module, Py_buffer *data);
    146 
    147 static PyObject *
    148 binascii_a2b_hqx(PyObject *module, PyObject *arg)
    149 {
    150     PyObject *return_value = NULL;
    151     Py_buffer data = {NULL, NULL};
    152 
    153     if (!PyArg_Parse(arg, "O&:a2b_hqx", ascii_buffer_converter, &data)) {
    154         goto exit;
    155     }
    156     return_value = binascii_a2b_hqx_impl(module, &data);
    157 
    158 exit:
    159     /* Cleanup for data */
    160     if (data.obj)
    161        PyBuffer_Release(&data);
    162 
    163     return return_value;
    164 }
    165 
    166 PyDoc_STRVAR(binascii_rlecode_hqx__doc__,
    167 "rlecode_hqx($module, data, /)\n"
    168 "--\n"
    169 "\n"
    170 "Binhex RLE-code binary data.");
    171 
    172 #define BINASCII_RLECODE_HQX_METHODDEF    \
    173     {"rlecode_hqx", (PyCFunction)binascii_rlecode_hqx, METH_O, binascii_rlecode_hqx__doc__},
    174 
    175 static PyObject *
    176 binascii_rlecode_hqx_impl(PyObject *module, Py_buffer *data);
    177 
    178 static PyObject *
    179 binascii_rlecode_hqx(PyObject *module, PyObject *arg)
    180 {
    181     PyObject *return_value = NULL;
    182     Py_buffer data = {NULL, NULL};
    183 
    184     if (!PyArg_Parse(arg, "y*:rlecode_hqx", &data)) {
    185         goto exit;
    186     }
    187     return_value = binascii_rlecode_hqx_impl(module, &data);
    188 
    189 exit:
    190     /* Cleanup for data */
    191     if (data.obj) {
    192        PyBuffer_Release(&data);
    193     }
    194 
    195     return return_value;
    196 }
    197 
    198 PyDoc_STRVAR(binascii_b2a_hqx__doc__,
    199 "b2a_hqx($module, data, /)\n"
    200 "--\n"
    201 "\n"
    202 "Encode .hqx data.");
    203 
    204 #define BINASCII_B2A_HQX_METHODDEF    \
    205     {"b2a_hqx", (PyCFunction)binascii_b2a_hqx, METH_O, binascii_b2a_hqx__doc__},
    206 
    207 static PyObject *
    208 binascii_b2a_hqx_impl(PyObject *module, Py_buffer *data);
    209 
    210 static PyObject *
    211 binascii_b2a_hqx(PyObject *module, PyObject *arg)
    212 {
    213     PyObject *return_value = NULL;
    214     Py_buffer data = {NULL, NULL};
    215 
    216     if (!PyArg_Parse(arg, "y*:b2a_hqx", &data)) {
    217         goto exit;
    218     }
    219     return_value = binascii_b2a_hqx_impl(module, &data);
    220 
    221 exit:
    222     /* Cleanup for data */
    223     if (data.obj) {
    224        PyBuffer_Release(&data);
    225     }
    226 
    227     return return_value;
    228 }
    229 
    230 PyDoc_STRVAR(binascii_rledecode_hqx__doc__,
    231 "rledecode_hqx($module, data, /)\n"
    232 "--\n"
    233 "\n"
    234 "Decode hexbin RLE-coded string.");
    235 
    236 #define BINASCII_RLEDECODE_HQX_METHODDEF    \
    237     {"rledecode_hqx", (PyCFunction)binascii_rledecode_hqx, METH_O, binascii_rledecode_hqx__doc__},
    238 
    239 static PyObject *
    240 binascii_rledecode_hqx_impl(PyObject *module, Py_buffer *data);
    241 
    242 static PyObject *
    243 binascii_rledecode_hqx(PyObject *module, PyObject *arg)
    244 {
    245     PyObject *return_value = NULL;
    246     Py_buffer data = {NULL, NULL};
    247 
    248     if (!PyArg_Parse(arg, "y*:rledecode_hqx", &data)) {
    249         goto exit;
    250     }
    251     return_value = binascii_rledecode_hqx_impl(module, &data);
    252 
    253 exit:
    254     /* Cleanup for data */
    255     if (data.obj) {
    256        PyBuffer_Release(&data);
    257     }
    258 
    259     return return_value;
    260 }
    261 
    262 PyDoc_STRVAR(binascii_crc_hqx__doc__,
    263 "crc_hqx($module, data, crc, /)\n"
    264 "--\n"
    265 "\n"
    266 "Compute CRC-CCITT incrementally.");
    267 
    268 #define BINASCII_CRC_HQX_METHODDEF    \
    269     {"crc_hqx", (PyCFunction)binascii_crc_hqx, METH_VARARGS, binascii_crc_hqx__doc__},
    270 
    271 static unsigned int
    272 binascii_crc_hqx_impl(PyObject *module, Py_buffer *data, unsigned int crc);
    273 
    274 static PyObject *
    275 binascii_crc_hqx(PyObject *module, PyObject *args)
    276 {
    277     PyObject *return_value = NULL;
    278     Py_buffer data = {NULL, NULL};
    279     unsigned int crc;
    280     unsigned int _return_value;
    281 
    282     if (!PyArg_ParseTuple(args, "y*I:crc_hqx",
    283         &data, &crc)) {
    284         goto exit;
    285     }
    286     _return_value = binascii_crc_hqx_impl(module, &data, crc);
    287     if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
    288         goto exit;
    289     }
    290     return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
    291 
    292 exit:
    293     /* Cleanup for data */
    294     if (data.obj) {
    295        PyBuffer_Release(&data);
    296     }
    297 
    298     return return_value;
    299 }
    300 
    301 PyDoc_STRVAR(binascii_crc32__doc__,
    302 "crc32($module, data, crc=0, /)\n"
    303 "--\n"
    304 "\n"
    305 "Compute CRC-32 incrementally.");
    306 
    307 #define BINASCII_CRC32_METHODDEF    \
    308     {"crc32", (PyCFunction)binascii_crc32, METH_VARARGS, binascii_crc32__doc__},
    309 
    310 static unsigned int
    311 binascii_crc32_impl(PyObject *module, Py_buffer *data, unsigned int crc);
    312 
    313 static PyObject *
    314 binascii_crc32(PyObject *module, PyObject *args)
    315 {
    316     PyObject *return_value = NULL;
    317     Py_buffer data = {NULL, NULL};
    318     unsigned int crc = 0;
    319     unsigned int _return_value;
    320 
    321     if (!PyArg_ParseTuple(args, "y*|I:crc32",
    322         &data, &crc)) {
    323         goto exit;
    324     }
    325     _return_value = binascii_crc32_impl(module, &data, crc);
    326     if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
    327         goto exit;
    328     }
    329     return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
    330 
    331 exit:
    332     /* Cleanup for data */
    333     if (data.obj) {
    334        PyBuffer_Release(&data);
    335     }
    336 
    337     return return_value;
    338 }
    339 
    340 PyDoc_STRVAR(binascii_b2a_hex__doc__,
    341 "b2a_hex($module, data, /)\n"
    342 "--\n"
    343 "\n"
    344 "Hexadecimal representation of binary data.\n"
    345 "\n"
    346 "The return value is a bytes object.  This function is also\n"
    347 "available as \"hexlify()\".");
    348 
    349 #define BINASCII_B2A_HEX_METHODDEF    \
    350     {"b2a_hex", (PyCFunction)binascii_b2a_hex, METH_O, binascii_b2a_hex__doc__},
    351 
    352 static PyObject *
    353 binascii_b2a_hex_impl(PyObject *module, Py_buffer *data);
    354 
    355 static PyObject *
    356 binascii_b2a_hex(PyObject *module, PyObject *arg)
    357 {
    358     PyObject *return_value = NULL;
    359     Py_buffer data = {NULL, NULL};
    360 
    361     if (!PyArg_Parse(arg, "y*:b2a_hex", &data)) {
    362         goto exit;
    363     }
    364     return_value = binascii_b2a_hex_impl(module, &data);
    365 
    366 exit:
    367     /* Cleanup for data */
    368     if (data.obj) {
    369        PyBuffer_Release(&data);
    370     }
    371 
    372     return return_value;
    373 }
    374 
    375 PyDoc_STRVAR(binascii_hexlify__doc__,
    376 "hexlify($module, data, /)\n"
    377 "--\n"
    378 "\n"
    379 "Hexadecimal representation of binary data.\n"
    380 "\n"
    381 "The return value is a bytes object.");
    382 
    383 #define BINASCII_HEXLIFY_METHODDEF    \
    384     {"hexlify", (PyCFunction)binascii_hexlify, METH_O, binascii_hexlify__doc__},
    385 
    386 static PyObject *
    387 binascii_hexlify_impl(PyObject *module, Py_buffer *data);
    388 
    389 static PyObject *
    390 binascii_hexlify(PyObject *module, PyObject *arg)
    391 {
    392     PyObject *return_value = NULL;
    393     Py_buffer data = {NULL, NULL};
    394 
    395     if (!PyArg_Parse(arg, "y*:hexlify", &data)) {
    396         goto exit;
    397     }
    398     return_value = binascii_hexlify_impl(module, &data);
    399 
    400 exit:
    401     /* Cleanup for data */
    402     if (data.obj) {
    403        PyBuffer_Release(&data);
    404     }
    405 
    406     return return_value;
    407 }
    408 
    409 PyDoc_STRVAR(binascii_a2b_hex__doc__,
    410 "a2b_hex($module, hexstr, /)\n"
    411 "--\n"
    412 "\n"
    413 "Binary data of hexadecimal representation.\n"
    414 "\n"
    415 "hexstr must contain an even number of hex digits (upper or lower case).\n"
    416 "This function is also available as \"unhexlify()\".");
    417 
    418 #define BINASCII_A2B_HEX_METHODDEF    \
    419     {"a2b_hex", (PyCFunction)binascii_a2b_hex, METH_O, binascii_a2b_hex__doc__},
    420 
    421 static PyObject *
    422 binascii_a2b_hex_impl(PyObject *module, Py_buffer *hexstr);
    423 
    424 static PyObject *
    425 binascii_a2b_hex(PyObject *module, PyObject *arg)
    426 {
    427     PyObject *return_value = NULL;
    428     Py_buffer hexstr = {NULL, NULL};
    429 
    430     if (!PyArg_Parse(arg, "O&:a2b_hex", ascii_buffer_converter, &hexstr)) {
    431         goto exit;
    432     }
    433     return_value = binascii_a2b_hex_impl(module, &hexstr);
    434 
    435 exit:
    436     /* Cleanup for hexstr */
    437     if (hexstr.obj)
    438        PyBuffer_Release(&hexstr);
    439 
    440     return return_value;
    441 }
    442 
    443 PyDoc_STRVAR(binascii_unhexlify__doc__,
    444 "unhexlify($module, hexstr, /)\n"
    445 "--\n"
    446 "\n"
    447 "Binary data of hexadecimal representation.\n"
    448 "\n"
    449 "hexstr must contain an even number of hex digits (upper or lower case).");
    450 
    451 #define BINASCII_UNHEXLIFY_METHODDEF    \
    452     {"unhexlify", (PyCFunction)binascii_unhexlify, METH_O, binascii_unhexlify__doc__},
    453 
    454 static PyObject *
    455 binascii_unhexlify_impl(PyObject *module, Py_buffer *hexstr);
    456 
    457 static PyObject *
    458 binascii_unhexlify(PyObject *module, PyObject *arg)
    459 {
    460     PyObject *return_value = NULL;
    461     Py_buffer hexstr = {NULL, NULL};
    462 
    463     if (!PyArg_Parse(arg, "O&:unhexlify", ascii_buffer_converter, &hexstr)) {
    464         goto exit;
    465     }
    466     return_value = binascii_unhexlify_impl(module, &hexstr);
    467 
    468 exit:
    469     /* Cleanup for hexstr */
    470     if (hexstr.obj)
    471        PyBuffer_Release(&hexstr);
    472 
    473     return return_value;
    474 }
    475 
    476 PyDoc_STRVAR(binascii_a2b_qp__doc__,
    477 "a2b_qp($module, /, data, header=False)\n"
    478 "--\n"
    479 "\n"
    480 "Decode a string of qp-encoded data.");
    481 
    482 #define BINASCII_A2B_QP_METHODDEF    \
    483     {"a2b_qp", (PyCFunction)binascii_a2b_qp, METH_FASTCALL, binascii_a2b_qp__doc__},
    484 
    485 static PyObject *
    486 binascii_a2b_qp_impl(PyObject *module, Py_buffer *data, int header);
    487 
    488 static PyObject *
    489 binascii_a2b_qp(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    490 {
    491     PyObject *return_value = NULL;
    492     static const char * const _keywords[] = {"data", "header", NULL};
    493     static _PyArg_Parser _parser = {"O&|i:a2b_qp", _keywords, 0};
    494     Py_buffer data = {NULL, NULL};
    495     int header = 0;
    496 
    497     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    498         ascii_buffer_converter, &data, &header)) {
    499         goto exit;
    500     }
    501     return_value = binascii_a2b_qp_impl(module, &data, header);
    502 
    503 exit:
    504     /* Cleanup for data */
    505     if (data.obj)
    506        PyBuffer_Release(&data);
    507 
    508     return return_value;
    509 }
    510 
    511 PyDoc_STRVAR(binascii_b2a_qp__doc__,
    512 "b2a_qp($module, /, data, quotetabs=False, istext=True, header=False)\n"
    513 "--\n"
    514 "\n"
    515 "Encode a string using quoted-printable encoding.\n"
    516 "\n"
    517 "On encoding, when istext is set, newlines are not encoded, and white\n"
    518 "space at end of lines is.  When istext is not set, \\r and \\n (CR/LF)\n"
    519 "are both encoded.  When quotetabs is set, space and tabs are encoded.");
    520 
    521 #define BINASCII_B2A_QP_METHODDEF    \
    522     {"b2a_qp", (PyCFunction)binascii_b2a_qp, METH_FASTCALL, binascii_b2a_qp__doc__},
    523 
    524 static PyObject *
    525 binascii_b2a_qp_impl(PyObject *module, Py_buffer *data, int quotetabs,
    526                      int istext, int header);
    527 
    528 static PyObject *
    529 binascii_b2a_qp(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    530 {
    531     PyObject *return_value = NULL;
    532     static const char * const _keywords[] = {"data", "quotetabs", "istext", "header", NULL};
    533     static _PyArg_Parser _parser = {"y*|iii:b2a_qp", _keywords, 0};
    534     Py_buffer data = {NULL, NULL};
    535     int quotetabs = 0;
    536     int istext = 1;
    537     int header = 0;
    538 
    539     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    540         &data, &quotetabs, &istext, &header)) {
    541         goto exit;
    542     }
    543     return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header);
    544 
    545 exit:
    546     /* Cleanup for data */
    547     if (data.obj) {
    548        PyBuffer_Release(&data);
    549     }
    550 
    551     return return_value;
    552 }
    553 /*[clinic end generated code: output=458eb09731cb7877 input=a9049054013a1b77]*/
    554