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