Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(pyexpat_xmlparser_Parse__doc__, |
Serhiy Storchaka | 8b2e8b6 | 2015-05-30 11:30:39 +0300 | [diff] [blame] | 6 | "Parse($self, data, isfinal=False, /)\n" |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 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)pyexpat_xmlparser_Parse, METH_VARARGS, pyexpat_xmlparser_Parse__doc__}, |
| 15 | |
| 16 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 17 | pyexpat_xmlparser_Parse_impl(xmlparseobject *self, PyObject *data, |
Serhiy Storchaka | 8b2e8b6 | 2015-05-30 11:30:39 +0300 | [diff] [blame] | 18 | int isfinal); |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 19 | |
| 20 | static PyObject * |
| 21 | pyexpat_xmlparser_Parse(xmlparseobject *self, PyObject *args) |
| 22 | { |
| 23 | PyObject *return_value = NULL; |
| 24 | PyObject *data; |
Serhiy Storchaka | 8b2e8b6 | 2015-05-30 11:30:39 +0300 | [diff] [blame] | 25 | int isfinal = 0; |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 26 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 27 | if (!PyArg_ParseTuple(args, "O|i:Parse", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 28 | &data, &isfinal)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 29 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 30 | } |
Serhiy Storchaka | 8b2e8b6 | 2015-05-30 11:30:39 +0300 | [diff] [blame] | 31 | return_value = pyexpat_xmlparser_Parse_impl(self, data, isfinal); |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 32 | |
| 33 | exit: |
| 34 | return return_value; |
| 35 | } |
| 36 | |
| 37 | PyDoc_STRVAR(pyexpat_xmlparser_ParseFile__doc__, |
| 38 | "ParseFile($self, file, /)\n" |
| 39 | "--\n" |
| 40 | "\n" |
| 41 | "Parse XML data from file-like object."); |
| 42 | |
| 43 | #define PYEXPAT_XMLPARSER_PARSEFILE_METHODDEF \ |
| 44 | {"ParseFile", (PyCFunction)pyexpat_xmlparser_ParseFile, METH_O, pyexpat_xmlparser_ParseFile__doc__}, |
| 45 | |
| 46 | PyDoc_STRVAR(pyexpat_xmlparser_SetBase__doc__, |
| 47 | "SetBase($self, base, /)\n" |
| 48 | "--\n" |
| 49 | "\n" |
| 50 | "Set the base URL for the parser."); |
| 51 | |
| 52 | #define PYEXPAT_XMLPARSER_SETBASE_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 53 | {"SetBase", (PyCFunction)pyexpat_xmlparser_SetBase, METH_O, pyexpat_xmlparser_SetBase__doc__}, |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 54 | |
| 55 | static PyObject * |
| 56 | pyexpat_xmlparser_SetBase_impl(xmlparseobject *self, const char *base); |
| 57 | |
| 58 | static PyObject * |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 59 | pyexpat_xmlparser_SetBase(xmlparseobject *self, PyObject *arg) |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 60 | { |
| 61 | PyObject *return_value = NULL; |
| 62 | const char *base; |
| 63 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 64 | if (!PyArg_Parse(arg, "s:SetBase", &base)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 65 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 66 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 67 | return_value = pyexpat_xmlparser_SetBase_impl(self, base); |
| 68 | |
| 69 | exit: |
| 70 | return return_value; |
| 71 | } |
| 72 | |
| 73 | PyDoc_STRVAR(pyexpat_xmlparser_GetBase__doc__, |
| 74 | "GetBase($self, /)\n" |
| 75 | "--\n" |
| 76 | "\n" |
| 77 | "Return base URL string for the parser."); |
| 78 | |
| 79 | #define PYEXPAT_XMLPARSER_GETBASE_METHODDEF \ |
| 80 | {"GetBase", (PyCFunction)pyexpat_xmlparser_GetBase, METH_NOARGS, pyexpat_xmlparser_GetBase__doc__}, |
| 81 | |
| 82 | static PyObject * |
| 83 | pyexpat_xmlparser_GetBase_impl(xmlparseobject *self); |
| 84 | |
| 85 | static PyObject * |
| 86 | pyexpat_xmlparser_GetBase(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) |
| 87 | { |
| 88 | return pyexpat_xmlparser_GetBase_impl(self); |
| 89 | } |
| 90 | |
| 91 | PyDoc_STRVAR(pyexpat_xmlparser_GetInputContext__doc__, |
| 92 | "GetInputContext($self, /)\n" |
| 93 | "--\n" |
| 94 | "\n" |
| 95 | "Return the untranslated text of the input that caused the current event.\n" |
| 96 | "\n" |
| 97 | "If the event was generated by a large amount of text (such as a start tag\n" |
| 98 | "for an element with many attributes), not all of the text may be available."); |
| 99 | |
| 100 | #define PYEXPAT_XMLPARSER_GETINPUTCONTEXT_METHODDEF \ |
| 101 | {"GetInputContext", (PyCFunction)pyexpat_xmlparser_GetInputContext, METH_NOARGS, pyexpat_xmlparser_GetInputContext__doc__}, |
| 102 | |
| 103 | static PyObject * |
| 104 | pyexpat_xmlparser_GetInputContext_impl(xmlparseobject *self); |
| 105 | |
| 106 | static PyObject * |
| 107 | pyexpat_xmlparser_GetInputContext(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) |
| 108 | { |
| 109 | return pyexpat_xmlparser_GetInputContext_impl(self); |
| 110 | } |
| 111 | |
| 112 | PyDoc_STRVAR(pyexpat_xmlparser_ExternalEntityParserCreate__doc__, |
| 113 | "ExternalEntityParserCreate($self, context, encoding=None, /)\n" |
| 114 | "--\n" |
| 115 | "\n" |
| 116 | "Create a parser for parsing an external entity based on the information passed to the ExternalEntityRefHandler."); |
| 117 | |
| 118 | #define PYEXPAT_XMLPARSER_EXTERNALENTITYPARSERCREATE_METHODDEF \ |
| 119 | {"ExternalEntityParserCreate", (PyCFunction)pyexpat_xmlparser_ExternalEntityParserCreate, METH_VARARGS, pyexpat_xmlparser_ExternalEntityParserCreate__doc__}, |
| 120 | |
| 121 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 122 | pyexpat_xmlparser_ExternalEntityParserCreate_impl(xmlparseobject *self, |
| 123 | const char *context, |
| 124 | const char *encoding); |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 125 | |
| 126 | static PyObject * |
| 127 | pyexpat_xmlparser_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args) |
| 128 | { |
| 129 | PyObject *return_value = NULL; |
| 130 | const char *context; |
| 131 | const char *encoding = NULL; |
| 132 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 133 | if (!PyArg_ParseTuple(args, "z|s:ExternalEntityParserCreate", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 134 | &context, &encoding)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 135 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 136 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 137 | return_value = pyexpat_xmlparser_ExternalEntityParserCreate_impl(self, context, encoding); |
| 138 | |
| 139 | exit: |
| 140 | return return_value; |
| 141 | } |
| 142 | |
| 143 | PyDoc_STRVAR(pyexpat_xmlparser_SetParamEntityParsing__doc__, |
| 144 | "SetParamEntityParsing($self, flag, /)\n" |
| 145 | "--\n" |
| 146 | "\n" |
| 147 | "Controls parsing of parameter entities (including the external DTD subset).\n" |
| 148 | "\n" |
| 149 | "Possible flag values are XML_PARAM_ENTITY_PARSING_NEVER,\n" |
| 150 | "XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n" |
| 151 | "XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n" |
| 152 | "was successful."); |
| 153 | |
| 154 | #define PYEXPAT_XMLPARSER_SETPARAMENTITYPARSING_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 155 | {"SetParamEntityParsing", (PyCFunction)pyexpat_xmlparser_SetParamEntityParsing, METH_O, pyexpat_xmlparser_SetParamEntityParsing__doc__}, |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 156 | |
| 157 | static PyObject * |
| 158 | pyexpat_xmlparser_SetParamEntityParsing_impl(xmlparseobject *self, int flag); |
| 159 | |
| 160 | static PyObject * |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 161 | pyexpat_xmlparser_SetParamEntityParsing(xmlparseobject *self, PyObject *arg) |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 162 | { |
| 163 | PyObject *return_value = NULL; |
| 164 | int flag; |
| 165 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 166 | if (!PyArg_Parse(arg, "i:SetParamEntityParsing", &flag)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 167 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 168 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 169 | return_value = pyexpat_xmlparser_SetParamEntityParsing_impl(self, flag); |
| 170 | |
| 171 | exit: |
| 172 | return return_value; |
| 173 | } |
| 174 | |
| 175 | #if (XML_COMBINED_VERSION >= 19505) |
| 176 | |
| 177 | PyDoc_STRVAR(pyexpat_xmlparser_UseForeignDTD__doc__, |
| 178 | "UseForeignDTD($self, flag=True, /)\n" |
| 179 | "--\n" |
| 180 | "\n" |
| 181 | "Allows the application to provide an artificial external subset if one is not specified as part of the document instance.\n" |
| 182 | "\n" |
| 183 | "This readily allows the use of a \'default\' document type controlled by the\n" |
| 184 | "application, while still getting the advantage of providing document type\n" |
| 185 | "information to the parser. \'flag\' defaults to True if not provided."); |
| 186 | |
| 187 | #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF \ |
| 188 | {"UseForeignDTD", (PyCFunction)pyexpat_xmlparser_UseForeignDTD, METH_VARARGS, pyexpat_xmlparser_UseForeignDTD__doc__}, |
| 189 | |
| 190 | static PyObject * |
| 191 | pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag); |
| 192 | |
| 193 | static PyObject * |
| 194 | pyexpat_xmlparser_UseForeignDTD(xmlparseobject *self, PyObject *args) |
| 195 | { |
| 196 | PyObject *return_value = NULL; |
| 197 | int flag = 1; |
| 198 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 199 | if (!PyArg_ParseTuple(args, "|p:UseForeignDTD", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 200 | &flag)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 201 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 202 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 203 | return_value = pyexpat_xmlparser_UseForeignDTD_impl(self, flag); |
| 204 | |
| 205 | exit: |
| 206 | return return_value; |
| 207 | } |
| 208 | |
| 209 | #endif /* (XML_COMBINED_VERSION >= 19505) */ |
| 210 | |
| 211 | PyDoc_STRVAR(pyexpat_xmlparser___dir____doc__, |
| 212 | "__dir__($self, /)\n" |
Zachary Ware | 8ef887c | 2015-04-13 18:22:35 -0500 | [diff] [blame] | 213 | "--\n" |
| 214 | "\n"); |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 215 | |
| 216 | #define PYEXPAT_XMLPARSER___DIR___METHODDEF \ |
| 217 | {"__dir__", (PyCFunction)pyexpat_xmlparser___dir__, METH_NOARGS, pyexpat_xmlparser___dir____doc__}, |
| 218 | |
| 219 | static PyObject * |
| 220 | pyexpat_xmlparser___dir___impl(xmlparseobject *self); |
| 221 | |
| 222 | static PyObject * |
| 223 | pyexpat_xmlparser___dir__(xmlparseobject *self, PyObject *Py_UNUSED(ignored)) |
| 224 | { |
| 225 | return pyexpat_xmlparser___dir___impl(self); |
| 226 | } |
| 227 | |
| 228 | PyDoc_STRVAR(pyexpat_ParserCreate__doc__, |
| 229 | "ParserCreate($module, /, encoding=None, namespace_separator=None,\n" |
| 230 | " intern=None)\n" |
| 231 | "--\n" |
| 232 | "\n" |
| 233 | "Return a new XML parser object."); |
| 234 | |
| 235 | #define PYEXPAT_PARSERCREATE_METHODDEF \ |
Victor Stinner | 37e4ef7 | 2016-09-09 20:00:13 -0700 | [diff] [blame] | 236 | {"ParserCreate", (PyCFunction)pyexpat_ParserCreate, METH_FASTCALL, pyexpat_ParserCreate__doc__}, |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 237 | |
| 238 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 239 | pyexpat_ParserCreate_impl(PyObject *module, const char *encoding, |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 240 | const char *namespace_separator, PyObject *intern); |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 241 | |
| 242 | static PyObject * |
Victor Stinner | 37e4ef7 | 2016-09-09 20:00:13 -0700 | [diff] [blame] | 243 | pyexpat_ParserCreate(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 244 | { |
| 245 | PyObject *return_value = NULL; |
Serhiy Storchaka | 9171a8b | 2016-08-14 10:52:18 +0300 | [diff] [blame] | 246 | static const char * const _keywords[] = {"encoding", "namespace_separator", "intern", NULL}; |
| 247 | static _PyArg_Parser _parser = {"|zzO:ParserCreate", _keywords, 0}; |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 248 | const char *encoding = NULL; |
| 249 | const char *namespace_separator = NULL; |
| 250 | PyObject *intern = NULL; |
| 251 | |
Victor Stinner | 37e4ef7 | 2016-09-09 20:00:13 -0700 | [diff] [blame] | 252 | if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 253 | &encoding, &namespace_separator, &intern)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 254 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 255 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 256 | return_value = pyexpat_ParserCreate_impl(module, encoding, namespace_separator, intern); |
| 257 | |
| 258 | exit: |
| 259 | return return_value; |
| 260 | } |
| 261 | |
| 262 | PyDoc_STRVAR(pyexpat_ErrorString__doc__, |
| 263 | "ErrorString($module, code, /)\n" |
| 264 | "--\n" |
| 265 | "\n" |
| 266 | "Returns string error for given number."); |
| 267 | |
| 268 | #define PYEXPAT_ERRORSTRING_METHODDEF \ |
Serhiy Storchaka | 92e8af6 | 2015-04-04 00:12:11 +0300 | [diff] [blame] | 269 | {"ErrorString", (PyCFunction)pyexpat_ErrorString, METH_O, pyexpat_ErrorString__doc__}, |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 270 | |
| 271 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 272 | pyexpat_ErrorString_impl(PyObject *module, long code); |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 273 | |
| 274 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 275 | pyexpat_ErrorString(PyObject *module, PyObject *arg) |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 276 | { |
| 277 | PyObject *return_value = NULL; |
| 278 | long code; |
| 279 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 280 | if (!PyArg_Parse(arg, "l:ErrorString", &code)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 281 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 282 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 283 | return_value = pyexpat_ErrorString_impl(module, code); |
| 284 | |
| 285 | exit: |
| 286 | return return_value; |
| 287 | } |
| 288 | |
| 289 | #ifndef PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF |
| 290 | #define PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF |
| 291 | #endif /* !defined(PYEXPAT_XMLPARSER_USEFOREIGNDTD_METHODDEF) */ |
Victor Stinner | 37e4ef7 | 2016-09-09 20:00:13 -0700 | [diff] [blame] | 292 | /*[clinic end generated code: output=e889f7c6af6cc42f input=a9049054013a1b77]*/ |