Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4a30a071
Commit
4a30a071
authored
Sep 24, 2000
by
Lars Gustäbel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ExternalEntityParserCreate method (patch 101635).
parent
bb757136
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
Modules/pyexpat.c
Modules/pyexpat.c
+66
-0
No files found.
Modules/pyexpat.c
View file @
4a30a071
...
...
@@ -535,6 +535,70 @@ xmlparse_GetBase(xmlparseobject *self, PyObject *args)
return
Py_BuildValue
(
"z"
,
XML_GetBase
(
self
->
itself
));
}
static
char
xmlparse_ExternalEntityParserCreate__doc__
[]
=
"ExternalEntityParserCreate(context, encoding)
\n
\
Create a parser for parsing an external entity based on the
information passed to the ExternalEntityRefHandler."
;
static
PyObject
*
xmlparse_ExternalEntityParserCreate
(
xmlparseobject
*
self
,
PyObject
*
args
)
{
char
*
context
;
char
*
encoding
=
NULL
;
xmlparseobject
*
new_parser
;
int
i
;
if
(
!
PyArg_ParseTuple
(
args
,
"s|s:ExternalEntityParserCreate"
,
&
context
,
&
encoding
))
{
return
NULL
;
}
#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6
new_parser
=
PyObject_NEW
(
xmlparseobject
,
&
Xmlparsetype
);
if
(
new_parser
==
NULL
)
return
NULL
;
new_parser
->
returns_unicode
=
0
;
#else
/* Code for versions 1.6 and later */
new_parser
=
PyObject_New
(
xmlparseobject
,
&
Xmlparsetype
);
if
(
new_parser
==
NULL
)
return
NULL
;
new_parser
->
returns_unicode
=
1
;
#endif
new_parser
->
itself
=
XML_ExternalEntityParserCreate
(
self
->
itself
,
context
,
encoding
);
if
(
!
new_parser
)
{
Py_DECREF
(
new_parser
);
return
PyErr_NoMemory
();
}
XML_SetUserData
(
new_parser
->
itself
,
(
void
*
)
new_parser
);
/* allocate and clear handlers first */
for
(
i
=
0
;
handler_info
[
i
].
name
!=
NULL
;
i
++
)
/* do nothing */
;
new_parser
->
handlers
=
malloc
(
sizeof
(
PyObject
*
)
*
i
);
clear_handlers
(
new_parser
);
/* then copy handlers from self */
for
(
i
=
0
;
handler_info
[
i
].
name
!=
NULL
;
i
++
)
{
if
(
self
->
handlers
[
i
])
{
Py_INCREF
(
self
->
handlers
[
i
]);
new_parser
->
handlers
[
i
]
=
self
->
handlers
[
i
];
handler_info
[
i
].
setter
(
new_parser
->
itself
,
handler_info
[
i
].
handler
);
}
}
return
new_parser
;
}
static
struct
PyMethodDef
xmlparse_methods
[]
=
{
{
"Parse"
,
(
PyCFunction
)
xmlparse_Parse
,
METH_VARARGS
,
xmlparse_Parse__doc__
},
...
...
@@ -544,6 +608,8 @@ static struct PyMethodDef xmlparse_methods[] = {
METH_VARARGS
,
xmlparse_SetBase__doc__
},
{
"GetBase"
,
(
PyCFunction
)
xmlparse_GetBase
,
METH_VARARGS
,
xmlparse_GetBase__doc__
},
{
"ExternalEntityParserCreate"
,
(
PyCFunction
)
xmlparse_ExternalEntityParserCreate
,
METH_VARARGS
,
xmlparse_ExternalEntityParserCreate__doc__
},
{
NULL
,
NULL
}
/* sentinel */
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment