blob: 3e4a468967dfbbcd43fb59115c0395ebaac3f123 [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__,
Serhiy Storchaka12785612014-01-25 11:49:49 +02006"a2b_uu(module, data)\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +02007"Decode a line of uuencoded data.");
8
9#define BINASCII_A2B_UU_METHODDEF \
10 {"a2b_uu", (PyCFunction)binascii_a2b_uu, METH_VARARGS, binascii_a2b_uu__doc__},
11
12static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +020013binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020014
15static PyObject *
16binascii_a2b_uu(PyModuleDef *module, PyObject *args)
17{
18 PyObject *return_value = NULL;
Serhiy Storchaka12785612014-01-25 11:49:49 +020019 Py_buffer data;
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020020
21 if (!PyArg_ParseTuple(args,
22 "O&:a2b_uu",
Serhiy Storchaka12785612014-01-25 11:49:49 +020023 ascii_buffer_converter, &data))
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020024 goto exit;
Serhiy Storchaka12785612014-01-25 11:49:49 +020025 return_value = binascii_a2b_uu_impl(module, &data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020026
27exit:
28 return return_value;
29}
30
31PyDoc_STRVAR(binascii_b2a_uu__doc__,
32"b2a_uu(module, data)\n"
33"Uuencode line of data.");
34
35#define BINASCII_B2A_UU_METHODDEF \
36 {"b2a_uu", (PyCFunction)binascii_b2a_uu, METH_VARARGS, binascii_b2a_uu__doc__},
37
38static PyObject *
39binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data);
40
41static PyObject *
42binascii_b2a_uu(PyModuleDef *module, PyObject *args)
43{
44 PyObject *return_value = NULL;
45 Py_buffer data = {NULL, NULL};
46
47 if (!PyArg_ParseTuple(args,
48 "y*:b2a_uu",
49 &data))
50 goto exit;
51 return_value = binascii_b2a_uu_impl(module, &data);
52
53exit:
54 /* Cleanup for data */
55 if (data.obj)
56 PyBuffer_Release(&data);
57
58 return return_value;
59}
60
61PyDoc_STRVAR(binascii_a2b_base64__doc__,
Serhiy Storchaka12785612014-01-25 11:49:49 +020062"a2b_base64(module, data)\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020063"Decode a line of base64 data.");
64
65#define BINASCII_A2B_BASE64_METHODDEF \
66 {"a2b_base64", (PyCFunction)binascii_a2b_base64, METH_VARARGS, binascii_a2b_base64__doc__},
67
68static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +020069binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020070
71static PyObject *
72binascii_a2b_base64(PyModuleDef *module, PyObject *args)
73{
74 PyObject *return_value = NULL;
Serhiy Storchaka12785612014-01-25 11:49:49 +020075 Py_buffer data;
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020076
77 if (!PyArg_ParseTuple(args,
78 "O&:a2b_base64",
Serhiy Storchaka12785612014-01-25 11:49:49 +020079 ascii_buffer_converter, &data))
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020080 goto exit;
Serhiy Storchaka12785612014-01-25 11:49:49 +020081 return_value = binascii_a2b_base64_impl(module, &data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +020082
83exit:
84 return return_value;
85}
86
87PyDoc_STRVAR(binascii_b2a_base64__doc__,
88"b2a_base64(module, data)\n"
89"Base64-code line of data.");
90
91#define BINASCII_B2A_BASE64_METHODDEF \
92 {"b2a_base64", (PyCFunction)binascii_b2a_base64, METH_VARARGS, binascii_b2a_base64__doc__},
93
94static PyObject *
95binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data);
96
97static PyObject *
98binascii_b2a_base64(PyModuleDef *module, PyObject *args)
99{
100 PyObject *return_value = NULL;
101 Py_buffer data = {NULL, NULL};
102
103 if (!PyArg_ParseTuple(args,
104 "y*:b2a_base64",
105 &data))
106 goto exit;
107 return_value = binascii_b2a_base64_impl(module, &data);
108
109exit:
110 /* Cleanup for data */
111 if (data.obj)
112 PyBuffer_Release(&data);
113
114 return return_value;
115}
116
117PyDoc_STRVAR(binascii_a2b_hqx__doc__,
Serhiy Storchaka12785612014-01-25 11:49:49 +0200118"a2b_hqx(module, data)\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200119"Decode .hqx coding.");
120
121#define BINASCII_A2B_HQX_METHODDEF \
122 {"a2b_hqx", (PyCFunction)binascii_a2b_hqx, METH_VARARGS, binascii_a2b_hqx__doc__},
123
124static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +0200125binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200126
127static PyObject *
128binascii_a2b_hqx(PyModuleDef *module, PyObject *args)
129{
130 PyObject *return_value = NULL;
Serhiy Storchaka12785612014-01-25 11:49:49 +0200131 Py_buffer data;
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200132
133 if (!PyArg_ParseTuple(args,
134 "O&:a2b_hqx",
Serhiy Storchaka12785612014-01-25 11:49:49 +0200135 ascii_buffer_converter, &data))
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200136 goto exit;
Serhiy Storchaka12785612014-01-25 11:49:49 +0200137 return_value = binascii_a2b_hqx_impl(module, &data);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200138
139exit:
140 return return_value;
141}
142
143PyDoc_STRVAR(binascii_rlecode_hqx__doc__,
144"rlecode_hqx(module, data)\n"
145"Binhex RLE-code binary data.");
146
147#define BINASCII_RLECODE_HQX_METHODDEF \
148 {"rlecode_hqx", (PyCFunction)binascii_rlecode_hqx, METH_VARARGS, binascii_rlecode_hqx__doc__},
149
150static PyObject *
151binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data);
152
153static PyObject *
154binascii_rlecode_hqx(PyModuleDef *module, PyObject *args)
155{
156 PyObject *return_value = NULL;
157 Py_buffer data = {NULL, NULL};
158
159 if (!PyArg_ParseTuple(args,
160 "y*:rlecode_hqx",
161 &data))
162 goto exit;
163 return_value = binascii_rlecode_hqx_impl(module, &data);
164
165exit:
166 /* Cleanup for data */
167 if (data.obj)
168 PyBuffer_Release(&data);
169
170 return return_value;
171}
172
173PyDoc_STRVAR(binascii_b2a_hqx__doc__,
174"b2a_hqx(module, data)\n"
175"Encode .hqx data.");
176
177#define BINASCII_B2A_HQX_METHODDEF \
178 {"b2a_hqx", (PyCFunction)binascii_b2a_hqx, METH_VARARGS, binascii_b2a_hqx__doc__},
179
180static PyObject *
181binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data);
182
183static PyObject *
184binascii_b2a_hqx(PyModuleDef *module, PyObject *args)
185{
186 PyObject *return_value = NULL;
187 Py_buffer data = {NULL, NULL};
188
189 if (!PyArg_ParseTuple(args,
190 "y*:b2a_hqx",
191 &data))
192 goto exit;
193 return_value = binascii_b2a_hqx_impl(module, &data);
194
195exit:
196 /* Cleanup for data */
197 if (data.obj)
198 PyBuffer_Release(&data);
199
200 return return_value;
201}
202
203PyDoc_STRVAR(binascii_rledecode_hqx__doc__,
204"rledecode_hqx(module, data)\n"
205"Decode hexbin RLE-coded string.");
206
207#define BINASCII_RLEDECODE_HQX_METHODDEF \
208 {"rledecode_hqx", (PyCFunction)binascii_rledecode_hqx, METH_VARARGS, binascii_rledecode_hqx__doc__},
209
210static PyObject *
211binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data);
212
213static PyObject *
214binascii_rledecode_hqx(PyModuleDef *module, PyObject *args)
215{
216 PyObject *return_value = NULL;
217 Py_buffer data = {NULL, NULL};
218
219 if (!PyArg_ParseTuple(args,
220 "y*:rledecode_hqx",
221 &data))
222 goto exit;
223 return_value = binascii_rledecode_hqx_impl(module, &data);
224
225exit:
226 /* Cleanup for data */
227 if (data.obj)
228 PyBuffer_Release(&data);
229
230 return return_value;
231}
232
233PyDoc_STRVAR(binascii_crc_hqx__doc__,
234"crc_hqx(module, data, crc)\n"
235"Compute hqx CRC incrementally.");
236
237#define BINASCII_CRC_HQX_METHODDEF \
238 {"crc_hqx", (PyCFunction)binascii_crc_hqx, METH_VARARGS, binascii_crc_hqx__doc__},
239
240static int
241binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, int crc);
242
243static PyObject *
244binascii_crc_hqx(PyModuleDef *module, PyObject *args)
245{
246 PyObject *return_value = NULL;
247 Py_buffer data = {NULL, NULL};
248 int crc;
249 int _return_value;
250
251 if (!PyArg_ParseTuple(args,
252 "y*i:crc_hqx",
253 &data, &crc))
254 goto exit;
255 _return_value = binascii_crc_hqx_impl(module, &data, crc);
256 if ((_return_value == -1) && PyErr_Occurred())
257 goto exit;
258 return_value = PyLong_FromLong((long)_return_value);
259
260exit:
261 /* Cleanup for data */
262 if (data.obj)
263 PyBuffer_Release(&data);
264
265 return return_value;
266}
267
268PyDoc_STRVAR(binascii_crc32__doc__,
269"crc32(module, data, crc=0)\n"
270"Compute CRC-32 incrementally.");
271
272#define BINASCII_CRC32_METHODDEF \
273 {"crc32", (PyCFunction)binascii_crc32, METH_VARARGS, binascii_crc32__doc__},
274
275static unsigned int
276binascii_crc32_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc);
277
278static PyObject *
279binascii_crc32(PyModuleDef *module, PyObject *args)
280{
281 PyObject *return_value = NULL;
282 Py_buffer data = {NULL, NULL};
283 unsigned int crc = 0;
284 unsigned int _return_value;
285
286 if (!PyArg_ParseTuple(args,
287 "y*|I:crc32",
288 &data, &crc))
289 goto exit;
290 _return_value = binascii_crc32_impl(module, &data, crc);
291 if ((_return_value == -1) && PyErr_Occurred())
292 goto exit;
293 return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
294
295exit:
296 /* Cleanup for data */
297 if (data.obj)
298 PyBuffer_Release(&data);
299
300 return return_value;
301}
302
303PyDoc_STRVAR(binascii_b2a_hex__doc__,
304"b2a_hex(module, data)\n"
305"Hexadecimal representation of binary data.\n"
306"\n"
307"The return value is a bytes object. This function is also\n"
308"available as \"hexlify()\".");
309
310#define BINASCII_B2A_HEX_METHODDEF \
311 {"b2a_hex", (PyCFunction)binascii_b2a_hex, METH_VARARGS, binascii_b2a_hex__doc__},
312
313static PyObject *
314binascii_b2a_hex_impl(PyModuleDef *module, Py_buffer *data);
315
316static PyObject *
317binascii_b2a_hex(PyModuleDef *module, PyObject *args)
318{
319 PyObject *return_value = NULL;
320 Py_buffer data = {NULL, NULL};
321
322 if (!PyArg_ParseTuple(args,
323 "y*:b2a_hex",
324 &data))
325 goto exit;
326 return_value = binascii_b2a_hex_impl(module, &data);
327
328exit:
329 /* Cleanup for data */
330 if (data.obj)
331 PyBuffer_Release(&data);
332
333 return return_value;
334}
335
336PyDoc_STRVAR(binascii_a2b_hex__doc__,
337"a2b_hex(module, hexstr)\n"
338"Binary data of hexadecimal representation.\n"
339"\n"
340"hexstr must contain an even number of hex digits (upper or lower case).\n"
341"This function is also available as \"unhexlify()\".");
342
343#define BINASCII_A2B_HEX_METHODDEF \
344 {"a2b_hex", (PyCFunction)binascii_a2b_hex, METH_VARARGS, binascii_a2b_hex__doc__},
345
346static PyObject *
347binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr);
348
349static PyObject *
350binascii_a2b_hex(PyModuleDef *module, PyObject *args)
351{
352 PyObject *return_value = NULL;
353 Py_buffer hexstr;
354
355 if (!PyArg_ParseTuple(args,
356 "O&:a2b_hex",
357 ascii_buffer_converter, &hexstr))
358 goto exit;
359 return_value = binascii_a2b_hex_impl(module, &hexstr);
360
361exit:
362 return return_value;
363}
364
365PyDoc_STRVAR(binascii_a2b_qp__doc__,
Serhiy Storchaka12785612014-01-25 11:49:49 +0200366"a2b_qp(module, data, header=False)\n"
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200367"Decode a string of qp-encoded data.");
368
369#define BINASCII_A2B_QP_METHODDEF \
Serhiy Storchaka12785612014-01-25 11:49:49 +0200370 {"a2b_qp", (PyCFunction)binascii_a2b_qp, METH_VARARGS|METH_KEYWORDS, binascii_a2b_qp__doc__},
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200371
372static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +0200373binascii_a2b_qp_impl(PyModuleDef *module, Py_buffer *data, int header);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200374
375static PyObject *
Serhiy Storchaka12785612014-01-25 11:49:49 +0200376binascii_a2b_qp(PyModuleDef *module, PyObject *args, PyObject *kwargs)
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200377{
378 PyObject *return_value = NULL;
Serhiy Storchaka12785612014-01-25 11:49:49 +0200379 static char *_keywords[] = {"data", "header", NULL};
380 Py_buffer data;
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200381 int header = 0;
382
Serhiy Storchaka12785612014-01-25 11:49:49 +0200383 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
384 "O&|i:a2b_qp", _keywords,
385 ascii_buffer_converter, &data, &header))
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200386 goto exit;
Serhiy Storchaka12785612014-01-25 11:49:49 +0200387 return_value = binascii_a2b_qp_impl(module, &data, header);
Serhiy Storchaka3ffd9132014-01-25 11:21:23 +0200388
389exit:
390 return return_value;
391}
392
393PyDoc_STRVAR(binascii_b2a_qp__doc__,
394"b2a_qp(module, data, quotetabs=False, istext=True, header=False)\n"
395"Encode a string using quoted-printable encoding.\n"
396"\n"
397"On encoding, when istext is set, newlines are not encoded, and white\n"
398"space at end of lines is. When istext is not set, \\r and \\n (CR/LF)\n"
399"are both encoded. When quotetabs is set, space and tabs are encoded.");
400
401#define BINASCII_B2A_QP_METHODDEF \
402 {"b2a_qp", (PyCFunction)binascii_b2a_qp, METH_VARARGS|METH_KEYWORDS, binascii_b2a_qp__doc__},
403
404static PyObject *
405binascii_b2a_qp_impl(PyModuleDef *module, Py_buffer *data, int quotetabs, int istext, int header);
406
407static PyObject *
408binascii_b2a_qp(PyModuleDef *module, PyObject *args, PyObject *kwargs)
409{
410 PyObject *return_value = NULL;
411 static char *_keywords[] = {"data", "quotetabs", "istext", "header", NULL};
412 Py_buffer data = {NULL, NULL};
413 int quotetabs = 0;
414 int istext = 1;
415 int header = 0;
416
417 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
418 "y*|iii:b2a_qp", _keywords,
419 &data, &quotetabs, &istext, &header))
420 goto exit;
421 return_value = binascii_b2a_qp_impl(module, &data, quotetabs, istext, header);
422
423exit:
424 /* Cleanup for data */
425 if (data.obj)
426 PyBuffer_Release(&data);
427
428 return return_value;
429}
Serhiy Storchaka12785612014-01-25 11:49:49 +0200430/*[clinic end generated code: checksum=abe48ca8020fa3ec25e13bd9fa7414f6b3ee2946]*/