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