blob: 5247180a4139fdff25457bef02255257fd45e4fd [file] [log] [blame]
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +02001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(binascii_a2b_uu__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -08006"a2b_uu($module, data, /)\n"
7"--\n"
8"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +02009"Decode a line of uuencoded data.");
10
11#define BINASCII_A2B_UU_METHODDEF \
12 {"a2b_uu", (PyCFunction)binascii_a2b_uu, METH_VARARGS, binascii_a2b_uu__doc__},
13
14static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +020015binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020016
17static PyObject *
18binascii_a2b_uu(PyModuleDef *module, PyObject *args)
19{
20 PyObject *return_value = NULL;
Benjamin Petersonb62deac2014-01-26 10:41:58 -050021 Py_buffer data = {NULL, NULL};
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020022
23 if (!PyArg_ParseTuple(args,
24 "O&:a2b_uu",
Serhiy Storchaka12785612014-01-25 11:49:49 +020025 ascii_buffer_converter, &data))
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020026 goto exit;
Serhiy Storchaka12785612014-01-25 11:49:49 +020027 return_value = binascii_a2b_uu_impl(module, &data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020028
29exit:
Benjamin Petersonb62deac2014-01-26 10:41:58 -050030 /* Cleanup for data */
31 if (data.obj)
32 PyBuffer_Release(&data);
33
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020034 return return_value;
35}
36
37PyDoc_STRVAR(binascii_b2a_uu__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -080038"b2a_uu($module, data, /)\n"
39"--\n"
40"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020041"Uuencode line of data.");
42
43#define BINASCII_B2A_UU_METHODDEF \
44 {"b2a_uu", (PyCFunction)binascii_b2a_uu, METH_VARARGS, binascii_b2a_uu__doc__},
45
46static PyObject *
47binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data);
48
49static PyObject *
50binascii_b2a_uu(PyModuleDef *module, PyObject *args)
51{
52 PyObject *return_value = NULL;
53 Py_buffer data = {NULL, NULL};
54
55 if (!PyArg_ParseTuple(args,
56 "y*:b2a_uu",
57 &data))
58 goto exit;
59 return_value = binascii_b2a_uu_impl(module, &data);
60
61exit:
62 /* Cleanup for data */
63 if (data.obj)
64 PyBuffer_Release(&data);
65
66 return return_value;
67}
68
69PyDoc_STRVAR(binascii_a2b_base64__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -080070"a2b_base64($module, data, /)\n"
71"--\n"
72"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020073"Decode a line of base64 data.");
74
75#define BINASCII_A2B_BASE64_METHODDEF \
76 {"a2b_base64", (PyCFunction)binascii_a2b_base64, METH_VARARGS, binascii_a2b_base64__doc__},
77
78static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +020079binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020080
81static PyObject *
82binascii_a2b_base64(PyModuleDef *module, PyObject *args)
83{
84 PyObject *return_value = NULL;
Benjamin Petersonb62deac2014-01-26 10:41:58 -050085 Py_buffer data = {NULL, NULL};
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020086
87 if (!PyArg_ParseTuple(args,
88 "O&:a2b_base64",
Serhiy Storchaka12785612014-01-25 11:49:49 +020089 ascii_buffer_converter, &data))
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020090 goto exit;
Serhiy Storchaka12785612014-01-25 11:49:49 +020091 return_value = binascii_a2b_base64_impl(module, &data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020092
93exit:
Benjamin Petersonb62deac2014-01-26 10:41:58 -050094 /* Cleanup for data */
95 if (data.obj)
96 PyBuffer_Release(&data);
97
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020098 return return_value;
99}
100
101PyDoc_STRVAR(binascii_b2a_base64__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800102"b2a_base64($module, data, /)\n"
103"--\n"
104"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200105"Base64-code line of data.");
106
107#define BINASCII_B2A_BASE64_METHODDEF \
108 {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_VARARGS, binascii_b2a_base64__doc__},
109
110static PyObject *
111binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data);
112
113static PyObject *
114binascii_b2a_base64(PyModuleDef *module, PyObject *args)
115{
116 PyObject *return_value = NULL;
117 Py_buffer data = {NULL, NULL};
118
119 if (!PyArg_ParseTuple(args,
120 "y*:b2a_base64",
121 &data))
122 goto exit;
123 return_value = binascii_b2a_base64_impl(module, &data);
124
125exit:
126 /* Cleanup for data */
127 if (data.obj)
128 PyBuffer_Release(&data);
129
130 return return_value;
131}
132
133PyDoc_STRVAR(binascii_a2b_hqx__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800134"a2b_hqx($module, data, /)\n"
135"--\n"
136"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200137"Decode .hqx coding.");
138
139#define BINASCII_A2B_HQX_METHODDEF \
140 {"a2b_hqx", (PyCFunction)binascii_a2b_hqx, METH_VARARGS, binascii_a2b_hqx__doc__},
141
142static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +0200143binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200144
145static PyObject *
146binascii_a2b_hqx(PyModuleDef *module, PyObject *args)
147{
148 PyObject *return_value = NULL;
Benjamin Petersonb62deac2014-01-26 10:41:58 -0500149 Py_buffer data = {NULL, NULL};
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200150
151 if (!PyArg_ParseTuple(args,
152 "O&:a2b_hqx",
Serhiy Storchaka12785612014-01-25 11:49:49 +0200153 ascii_buffer_converter, &data))
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200154 goto exit;
Serhiy Storchaka12785612014-01-25 11:49:49 +0200155 return_value = binascii_a2b_hqx_impl(module, &data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200156
157exit:
Benjamin Petersonb62deac2014-01-26 10:41:58 -0500158 /* Cleanup for data */
159 if (data.obj)
160 PyBuffer_Release(&data);
161
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200162 return return_value;
163}
164
165PyDoc_STRVAR(binascii_rlecode_hqx__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800166"rlecode_hqx($module, data, /)\n"
167"--\n"
168"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200169"Binhex RLE-code binary data.");
170
171#define BINASCII_RLECODE_HQX_METHODDEF \
172 {"rlecode_hqx", (PyCFunction)binascii_rlecode_hqx, METH_VARARGS, binascii_rlecode_hqx__doc__},
173
174static PyObject *
175binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data);
176
177static PyObject *
178binascii_rlecode_hqx(PyModuleDef *module, PyObject *args)
179{
180 PyObject *return_value = NULL;
181 Py_buffer data = {NULL, NULL};
182
183 if (!PyArg_ParseTuple(args,
184 "y*:rlecode_hqx",
185 &data))
186 goto exit;
187 return_value = binascii_rlecode_hqx_impl(module, &data);
188
189exit:
190 /* Cleanup for data */
191 if (data.obj)
192 PyBuffer_Release(&data);
193
194 return return_value;
195}
196
197PyDoc_STRVAR(binascii_b2a_hqx__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800198"b2a_hqx($module, data, /)\n"
199"--\n"
200"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200201"Encode .hqx data.");
202
203#define BINASCII_B2A_HQX_METHODDEF \
204 {"b2a_hqx", (PyCFunction)binascii_b2a_hqx, METH_VARARGS, binascii_b2a_hqx__doc__},
205
206static PyObject *
207binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data);
208
209static PyObject *
210binascii_b2a_hqx(PyModuleDef *module, PyObject *args)
211{
212 PyObject *return_value = NULL;
213 Py_buffer data = {NULL, NULL};
214
215 if (!PyArg_ParseTuple(args,
216 "y*:b2a_hqx",
217 &data))
218 goto exit;
219 return_value = binascii_b2a_hqx_impl(module, &data);
220
221exit:
222 /* Cleanup for data */
223 if (data.obj)
224 PyBuffer_Release(&data);
225
226 return return_value;
227}
228
229PyDoc_STRVAR(binascii_rledecode_hqx__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800230"rledecode_hqx($module, data, /)\n"
231"--\n"
232"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200233"Decode hexbin RLE-coded string.");
234
235#define BINASCII_RLEDECODE_HQX_METHODDEF \
236 {"rledecode_hqx", (PyCFunction)binascii_rledecode_hqx, METH_VARARGS, binascii_rledecode_hqx__doc__},
237
238static PyObject *
239binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data);
240
241static PyObject *
242binascii_rledecode_hqx(PyModuleDef *module, PyObject *args)
243{
244 PyObject *return_value = NULL;
245 Py_buffer data = {NULL, NULL};
246
247 if (!PyArg_ParseTuple(args,
248 "y*:rledecode_hqx",
249 &data))
250 goto exit;
251 return_value = binascii_rledecode_hqx_impl(module, &data);
252
253exit:
254 /* Cleanup for data */
255 if (data.obj)
256 PyBuffer_Release(&data);
257
258 return return_value;
259}
260
261PyDoc_STRVAR(binascii_crc_hqx__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800262"crc_hqx($module, data, crc, /)\n"
263"--\n"
264"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200265"Compute hqx CRC incrementally.");
266
267#define BINASCII_CRC_HQX_METHODDEF \
268 {"crc_hqx", (PyCFunction)binascii_crc_hqx, METH_VARARGS, binascii_crc_hqx__doc__},
269
270static int
271binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, int crc);
272
273static PyObject *
274binascii_crc_hqx(PyModuleDef *module, PyObject *args)
275{
276 PyObject *return_value = NULL;
277 Py_buffer data = {NULL, NULL};
278 int crc;
279 int _return_value;
280
281 if (!PyArg_ParseTuple(args,
282 "y*i:crc_hqx",
283 &data, &crc))
284 goto exit;
285 _return_value = binascii_crc_hqx_impl(module, &data, crc);
286 if ((_return_value == -1) && PyErr_Occurred())
287 goto exit;
288 return_value = PyLong_FromLong((long)_return_value);
289
290exit:
291 /* Cleanup for data */
292 if (data.obj)
293 PyBuffer_Release(&data);
294
295 return return_value;
296}
297
298PyDoc_STRVAR(binascii_crc32__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800299"crc32($module, data, crc=0, /)\n"
300"--\n"
301"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200302"Compute CRC-32 incrementally.");
303
304#define BINASCII_CRC32_METHODDEF \
305 {"crc32", (PyCFunction)binascii_crc32, METH_VARARGS, binascii_crc32__doc__},
306
307static unsigned int
308binascii_crc32_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc);
309
310static PyObject *
311binascii_crc32(PyModuleDef *module, PyObject *args)
312{
313 PyObject *return_value = NULL;
314 Py_buffer data = {NULL, NULL};
315 unsigned int crc = 0;
316 unsigned int _return_value;
317
318 if (!PyArg_ParseTuple(args,
319 "y*|I:crc32",
320 &data, &crc))
321 goto exit;
322 _return_value = binascii_crc32_impl(module, &data, crc);
323 if ((_return_value == -1) && PyErr_Occurred())
324 goto exit;
325 return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
326
327exit:
328 /* Cleanup for data */
329 if (data.obj)
330 PyBuffer_Release(&data);
331
332 return return_value;
333}
334
335PyDoc_STRVAR(binascii_b2a_hex__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800336"b2a_hex($module, data, /)\n"
337"--\n"
338"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200339"Hexadecimal representation of binary data.\n"
340"\n"
341"The return value is a bytes object. This function is also\n"
342"available as \"hexlify()\".");
343
344#define BINASCII_B2A_HEX_METHODDEF \
345 {"b2a_hex", (PyCFunction)binascii_b2a_hex, METH_VARARGS, binascii_b2a_hex__doc__},
346
347static PyObject *
348binascii_b2a_hex_impl(PyModuleDef *module, Py_buffer *data);
349
350static PyObject *
351binascii_b2a_hex(PyModuleDef *module, PyObject *args)
352{
353 PyObject *return_value = NULL;
354 Py_buffer data = {NULL, NULL};
355
356 if (!PyArg_ParseTuple(args,
357 "y*:b2a_hex",
358 &data))
359 goto exit;
360 return_value = binascii_b2a_hex_impl(module, &data);
361
362exit:
363 /* Cleanup for data */
364 if (data.obj)
365 PyBuffer_Release(&data);
366
367 return return_value;
368}
369
370PyDoc_STRVAR(binascii_a2b_hex__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800371"a2b_hex($module, hexstr, /)\n"
372"--\n"
373"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200374"Binary data of hexadecimal representation.\n"
375"\n"
376"hexstr must contain an even number of hex digits (upper or lower case).\n"
377"This function is also available as \"unhexlify()\".");
378
379#define BINASCII_A2B_HEX_METHODDEF \
380 {"a2b_hex", (PyCFunction)binascii_a2b_hex, METH_VARARGS, binascii_a2b_hex__doc__},
381
382static PyObject *
383binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr);
384
385static PyObject *
386binascii_a2b_hex(PyModuleDef *module, PyObject *args)
387{
388 PyObject *return_value = NULL;
Benjamin Petersonb62deac2014-01-26 10:41:58 -0500389 Py_buffer hexstr = {NULL, NULL};
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200390
391 if (!PyArg_ParseTuple(args,
392 "O&:a2b_hex",
393 ascii_buffer_converter, &hexstr))
394 goto exit;
395 return_value = binascii_a2b_hex_impl(module, &hexstr);
396
397exit:
Benjamin Petersonb62deac2014-01-26 10:41:58 -0500398 /* Cleanup for hexstr */
399 if (hexstr.obj)
400 PyBuffer_Release(&hexstr);
401
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200402 return return_value;
403}
404
405PyDoc_STRVAR(binascii_a2b_qp__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800406"a2b_qp($module, /, data, header=False)\n"
407"--\n"
408"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200409"Decode a string of qp-encoded data.");
410
411#define BINASCII_A2B_QP_METHODDEF \
Serhiy Storchaka12785612014-01-25 11:49:49 +0200412 {"a2b_qp", (PyCFunction)binascii_a2b_qp, METH_VARARGS|METH_KEYWORDS, binascii_a2b_qp__doc__},
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200413
414static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +0200415binascii_a2b_qp_impl(PyModuleDef *module, Py_buffer *data, int header);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200416
417static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +0200418binascii_a2b_qp(PyModuleDef *module, PyObject *args, PyObject *kwargs)
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200419{
420 PyObject *return_value = NULL;
Serhiy Storchaka12785612014-01-25 11:49:49 +0200421 static char *_keywords[] = {"data", "header", NULL};
Benjamin Petersonb62deac2014-01-26 10:41:58 -0500422 Py_buffer data = {NULL, NULL};
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200423 int header = 0;
424
Serhiy Storchaka12785612014-01-25 11:49:49 +0200425 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
426 "O&|i:a2b_qp", _keywords,
427 ascii_buffer_converter, &data, &header))
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200428 goto exit;
Serhiy Storchaka12785612014-01-25 11:49:49 +0200429 return_value = binascii_a2b_qp_impl(module, &data, header);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200430
431exit:
Benjamin Petersonb62deac2014-01-26 10:41:58 -0500432 /* Cleanup for data */
433 if (data.obj)
434 PyBuffer_Release(&data);
435
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200436 return return_value;
437}
438
439PyDoc_STRVAR(binascii_b2a_qp__doc__,
Larry Hastings2623c8c2014-02-08 22:15:29 -0800440"b2a_qp($module, /, data, quotetabs=False, istext=True, header=False)\n"
441"--\n"
442"\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200443"Encode a string using quoted-printable encoding.\n"
444"\n"
445"On encoding, when istext is set, newlines are not encoded, and white\n"
446"space at end of lines is. When istext is not set, \\r and \\n (CR/LF)\n"
447"are both encoded. When quotetabs is set, space and tabs are encoded.");
448
449#define BINASCII_B2A_QP_METHODDEF \
450 {"b2a_qp", (PyCFunction)binascii_b2a_qp, METH_VARARGS|METH_KEYWORDS, binascii_b2a_qp__doc__},
451
452static PyObject *
453binascii_b2a_qp_impl(PyModuleDef *module, Py_buffer *data, int quotetabs, int istext, int header);
454
455static PyObject *
456binascii_b2a_qp(PyModuleDef *module, PyObject *args, PyObject *kwargs)
457{
458 PyObject *return_value = NULL;
459 static char *_keywords[] = {"data", "quotetabs", "istext", "header", NULL};
460 Py_buffer data = {NULL, NULL};
461 int quotetabs = 0;
462 int istext = 1;
463 int header = 0;
464
465 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
466 "y*|iii:b2a_qp", _keywords,
467 &data, &quotetabs, &istext, &header))
468 goto exit;
469 return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header);
470
471exit:
472 /* Cleanup for data */
473 if (data.obj)
474 PyBuffer_Release(&data);
475
476 return return_value;
477}
Larry Hastings2623c8c2014-02-08 22:15:29 -0800478/*[clinic end generated code: output=68e2bcc6956b6213 input=a9049054013a1b77]*/