1/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__,
6"Parse($self, data, isfinal=False, /)\n"
7"--\n"
8"\n"
9"Parse XML data.\n"
10"\n"
11"`isfinal\' should be true at end of input.");
12
13#define PYEXPAT_XMLPARSER_PARSE_METHODDEF \
14 {"Parse", (PyCFunction)(void(*)(void))pyexpat_xmlparser_Parse, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_Parse__doc__},
15
16static PyObject *
17pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyTypeObject *cls,
18 PyObject *data, int isfinal);
19
20static PyObject *
21pyexpat_xmlparser_Parse(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
22{
23 PyObject *return_value = NULL;
24 static const char * const _keywords[] = {"", "", NULL};
25 static _PyArg_Parser _parser = {NULL, _keywords, "Parse", 0};
26 PyObject *argsbuf[2];
27 PyObject *data;
28 int isfinal = 0;
29
30 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
31 if (!args) {
32 goto exit;
33 }
34 data = args[0];
35 if (nargs < 2) {
36 goto skip_optional_posonly;
37 }
38 isfinal = _PyLong_AsInt(args[1]);
39 if (isfinal == -1 && PyErr_Occurred()) {
40 goto exit;
41 }
42skip_optional_posonly:
43 return_value = pyexpat_xmlparser_Parse_impl(self, cls, data, isfinal);
44
45exit:
46 return return_value;
47}
48
49PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__,
50"ParseFile($self, file, /)\n"
51"--\n"
52"\n"
53"Parse XML data from file-like object.");
54
55#define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \
56 {"ParseFile", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ParseFile, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ParseFile__doc__},
57
58static PyObject *
59pyexpat_xmlparser_ParseFile_impl(xmlparseobject *self, PyTypeObject *cls,
60 PyObject *file);
61
62static PyObject *
63pyexpat_xmlparser_ParseFile(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
64{
65 PyObject *return_value = NULL;
66 static const char * const _keywords[] = {"", NULL};
67 static _PyArg_Parser _parser = {NULL, _keywords, "ParseFile", 0};
68 PyObject *argsbuf[1];
69 PyObject *file;
70
71 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
72 if (!args) {
73 goto exit;
74 }
75 file = args[0];
76 return_value = pyexpat_xmlparser_ParseFile_impl(self, cls, file);
77
78exit:
79 return return_value;
80}
81
82PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__,
83"SetBase($self, base, /)\n"
84"--\n"
85"\n"
86"Set the base URL for the parser.");
87
88#define PYEXPAT_XMLPARSER_SETBASE_METHODDEF \
89 {"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_O, pyexpat_xmlparser_SetBase__doc__},
90
91static PyObject *
92pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base);
93
94static PyObject *
95pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg)
96{
97 PyObject *return_value = NULL;
98 const char *base;
99
100 if (!PyUnicode_Check(arg)) {
101 _PyArg_BadArgument("SetBase", "argument", "str", arg);
102 goto exit;
103 }
104 Py_ssize_t base_length;
105 base = PyUnicode_AsUTF8AndSize(arg, &base_length);
106 if (base == NULL) {
107 goto exit;
108 }
109 if (strlen(base) != (size_t)base_length) {
110 PyErr_SetString(PyExc_ValueError, "embedded null character");
111 goto exit;
112 }
113 return_value = pyexpat_xmlparser_SetBase_impl(self, base);
114
115exit:
116 return return_value;
117}
118
119PyDoc_STRVAR(pyexpat_xmlparser_GetBase__doc__,
120"GetBase($self, /)\n"
121"--\n"
122"\n"
123"Return base URL string for the parser.");
124
125#define PYEXPAT_XMLPARSER_GETBASE_METHODDEF \
126 {"GetBase", (PyCFunction)pyexpat_xmlparser_GetBase, METH_NOARGS, pyexpat_xmlparser_GetBase__doc__},
127
128static PyObject *
129pyexpat_xmlparser_GetBase_impl(xmlparseobject *self);
130
131static PyObject *
132pyexpat_xmlparser_GetBase(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
133{
134 return pyexpat_xmlparser_GetBase_impl(self);
135}
136
137PyDoc_STRVAR(pyexpat_xmlparser_GetInputContext__doc__,
138"GetInputContext($self, /)\n"
139"--\n"
140"\n"
141"Return the untranslated text of the input that caused the current event.\n"
142"\n"
143"If the event was generated by a large amount of text (such as a start tag\n"
144"for an element with many attributes), not all of the text may be available.");
145
146#define PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF \
147 {"GetInputContext", (PyCFunction)pyexpat_xmlparser_GetInputContext, METH_NOARGS, pyexpat_xmlparser_GetInputContext__doc__},
148
149static PyObject *
150pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self);
151
152static PyObject *
153pyexpat_xmlparser_GetInputContext(xmlparseobject *self, PyObject *Py_UNUSED(ignored))
154{
155 return pyexpat_xmlparser_GetInputContext_impl(self);
156}
157
158PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__,
159"ExternalEntityParserCreate($self, context, encoding=<unrepresentable>,\n"
160" /)\n"
161"--\n"
162"\n"
163"Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler.");
164
165#define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \
166 {"ExternalEntityParserCreate", (PyCFunction)(void(*)(void))pyexpat_xmlparser_ExternalEntityParserCreate, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__},
167
168static PyObject *
169pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self,
170 PyTypeObject *cls,
171 const char *context,
172 const char *encoding);
173
174static PyObject *
175pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
176{
177 PyObject *return_value = NULL;
178 static const char * const _keywords[] = {"", "", NULL};
179 static _PyArg_Parser _parser = {NULL, _keywords, "ExternalEntityParserCreate", 0};
180 PyObject *argsbuf[2];
181 const char *context;
182 const char *encoding = NULL;
183
184 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
185 if (!args) {
186 goto exit;
187 }
188 if (args[0] == Py_None) {
189 context = NULL;
190 }
191 else if (PyUnicode_Check(args[0])) {
192 Py_ssize_t context_length;
193 context = PyUnicode_AsUTF8AndSize(args[0], &context_length);
194 if (context == NULL) {
195 goto exit;
196 }
197 if (strlen(context) != (size_t)context_length) {
198 PyErr_SetString(PyExc_ValueError, "embedded null character");
199 goto exit;
200 }
201 }
202 else {
203 _PyArg_BadArgument("ExternalEntityParserCreate", "argument 1", "str or None", args[0]);
204 goto exit;
205 }
206 if (nargs < 2) {
207 goto skip_optional_posonly;
208 }
209 if (!PyUnicode_Check(args[1])) {
210 _PyArg_BadArgument("ExternalEntityParserCreate", "argument 2", "str", args[1]);
211 goto exit;
212 }
213 Py_ssize_t encoding_length;
214 encoding = PyUnicode_AsUTF8AndSize(args[1], &encoding_length);
215 if (encoding == NULL) {
216 goto exit;
217 }
218 if (strlen(encoding) != (size_t)encoding_length) {
219 PyErr_SetString(PyExc_ValueError, "embedded null character");
220 goto exit;
221 }
222skip_optional_posonly:
223 return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, cls, context, encoding);
224
225exit:
226 return return_value;
227}
228
229PyDoc_STRVAR(pyexpat_xmlparser_SetParamEntityParsing__doc__,
230"SetParamEntityParsing($self, flag, /)\n"
231"--\n"
232"\n"
233"Controls parsing of parameter entities (including the external DTD subset).\n"
234"\n"
235"Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n"
236"XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n"
237"XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n"
238"was successful.");
239
240#define PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF \
241 {"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_O, pyexpat_xmlparser_SetParamEntityParsing__doc__},
242
243static PyObject *
244pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag);
245
246static PyObject *
247pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg)
248{
249 PyObject *return_value = NULL;
250 int flag;
251
252 flag = _PyLong_AsInt(arg);
253 if (flag == -1 && PyErr_Occurred()) {
254 goto exit;
255 }
256 return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag);
257
258exit:
259 return return_value;
260}
261
262#if (XML_COMBINED_VERSION >= 19505)
263
264PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__,
265"UseForeignDTD($self, flag=True, /)\n"
266"--\n"
267"\n"
268"Allows the application to provide an artificial external subset if one is not specified as part of the document instance.\n"
269"\n"
270"This readily allows the use of a \'default\' document type controlled by the\n"
271"application, while still getting the advantage of providing document type\n"
272"information to the parser. \'flag\' defaults to True if not provided.");
273
274#define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \
275 {"UseForeignDTD", (PyCFunction)(void(*)(void))pyexpat_xmlparser_UseForeignDTD, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pyexpat_xmlparser_UseForeignDTD__doc__},
276
277static PyObject *
278pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, PyTypeObject *cls,
279 int flag);
280
281static PyObject *
282pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
283{
284 PyObject *return_value = NULL;
285 static const char * const _keywords[] = {"", NULL};
286 static _PyArg_Parser _parser = {NULL, _keywords, "UseForeignDTD", 0};
287 PyObject *argsbuf[1];
288 int flag = 1;
289
290 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
291 if (!args) {
292 goto exit;
293 }
294 if (nargs < 1) {
295 goto skip_optional_posonly;
296 }
297 flag = PyObject_IsTrue(args[0]);
298 if (flag < 0) {
299 goto exit;
300 }
301skip_optional_posonly:
302 return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, cls, flag);
303
304exit:
305 return return_value;
306}
307
308#endif /* (XML_COMBINED_VERSION >= 19505) */
309
310PyDoc_STRVAR(pyexpat_ParserCreate__doc__,
311"ParserCreate($module, /, encoding=None, namespace_separator=None,\n"
312" intern=<unrepresentable>)\n"
313"--\n"
314"\n"
315"Return a new XML parser object.");
316
317#define PYEXPAT_PARSERCREATE_METHODDEF \
318 {"ParserCreate", (PyCFunction)(void(*)(void))pyexpat_ParserCreate, METH_FASTCALL|METH_KEYWORDS, pyexpat_ParserCreate__doc__},
319
320static PyObject *
321pyexpat_ParserCreate_impl(PyObject *module, const char *encoding,
322 const char *namespace_separator, PyObject *intern);
323
324static PyObject *
325pyexpat_ParserCreate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
326{
327 PyObject *return_value = NULL;
328 static const char * const _keywords[] = {"encoding", "namespace_separator", "intern", NULL};
329 static _PyArg_Parser _parser = {NULL, _keywords, "ParserCreate", 0};
330 PyObject *argsbuf[3];
331 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
332 const char *encoding = NULL;
333 const char *namespace_separator = NULL;
334 PyObject *intern = NULL;
335
336 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 3, 0, argsbuf);
337 if (!args) {
338 goto exit;
339 }
340 if (!noptargs) {
341 goto skip_optional_pos;
342 }
343 if (args[0]) {
344 if (args[0] == Py_None) {
345 encoding = NULL;
346 }
347 else if (PyUnicode_Check(args[0])) {
348 Py_ssize_t encoding_length;
349 encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length);
350 if (encoding == NULL) {
351 goto exit;
352 }
353 if (strlen(encoding) != (size_t)encoding_length) {
354 PyErr_SetString(PyExc_ValueError, "embedded null character");
355 goto exit;
356 }
357 }
358 else {
359 _PyArg_BadArgument("ParserCreate", "argument 'encoding'", "str or None", args[0]);
360 goto exit;
361 }
362 if (!--noptargs) {
363 goto skip_optional_pos;
364 }
365 }
366 if (args[1]) {
367 if (args[1] == Py_None) {
368 namespace_separator = NULL;
369 }
370 else if (PyUnicode_Check(args[1])) {
371 Py_ssize_t namespace_separator_length;
372 namespace_separator = PyUnicode_AsUTF8AndSize(args[1], &namespace_separator_length);
373 if (namespace_separator == NULL) {
374 goto exit;
375 }
376 if (strlen(namespace_separator) != (size_t)namespace_separator_length) {
377 PyErr_SetString(PyExc_ValueError, "embedded null character");
378 goto exit;
379 }
380 }
381 else {
382 _PyArg_BadArgument("ParserCreate", "argument 'namespace_separator'", "str or None", args[1]);
383 goto exit;
384 }
385 if (!--noptargs) {
386 goto skip_optional_pos;
387 }
388 }
389 intern = args[2];
390skip_optional_pos:
391 return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern);
392
393exit:
394 return return_value;
395}
396
397PyDoc_STRVAR(pyexpat_ErrorString__doc__,
398"ErrorString($module, code, /)\n"
399"--\n"
400"\n"
401"Returns string error for given number.");
402
403#define PYEXPAT_ERRORSTRING_METHODDEF \
404 {"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_O, pyexpat_ErrorString__doc__},
405
406static PyObject *
407pyexpat_ErrorString_impl(PyObject *module, long code);
408
409static PyObject *
410pyexpat_ErrorString(PyObject *module, PyObject *arg)
411{
412 PyObject *return_value = NULL;
413 long code;
414
415 code = PyLong_AsLong(arg);
416 if (code == -1 && PyErr_Occurred()) {
417 goto exit;
418 }
419 return_value = pyexpat_ErrorString_impl(module, code);
420
421exit:
422 return return_value;
423}
424
425#ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
426 #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF
427#endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */
428/*[clinic end generated code: output=5d60049d385d5d56 input=a9049054013a1b77]*/
429