From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/3rdparty/libcroco/cr-libxml-node-iface.c | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/3rdparty/libcroco/cr-libxml-node-iface.c (limited to 'src/3rdparty/libcroco/cr-libxml-node-iface.c') diff --git a/src/3rdparty/libcroco/cr-libxml-node-iface.c b/src/3rdparty/libcroco/cr-libxml-node-iface.c new file mode 100644 index 0000000..bc860f9 --- /dev/null +++ b/src/3rdparty/libcroco/cr-libxml-node-iface.c @@ -0,0 +1,81 @@ +#include +#include +#include "cr-libxml-node-iface.h" + +static CRXMLNodePtr +libxml_getParentNode(CRXMLNodePtr cnode) +{ + xmlNode const *xnode = (xmlNode const *) cnode; + return xnode->parent; +} + +static CRXMLNodePtr +libxml_getFirstChild(CRXMLNodePtr cnode) +{ + xmlNode const *xnode = (xmlNode const *) cnode; + return xnode->children; +} + +static CRXMLNodePtr +libxml_getNextSibling(CRXMLNodePtr cnode) +{ + xmlNode const *xnode = (xmlNode const *) cnode; + return xnode->next; +} + +static CRXMLNodePtr +libxml_getPrevSibling(CRXMLNodePtr cnode) +{ + xmlNode const *xnode = (xmlNode const *) cnode; + return xnode->prev; +} + +static char const * +local_part(char const *const qname) +{ + char const *ret = strrchr(qname, ':'); + if (ret) + return ++ret; + else + return qname; +} + +static char const * +libxml_getLocalName(CRXMLNodePtr cnode) +{ + xmlNode const *xnode = (xmlNode const *) cnode; + return local_part((char *)xnode->name); +} + +static char * +libxml_getProp(CRXMLNodePtr cnode, char const *cprop) +{ + xmlNodePtr xnode = (xmlNodePtr) cnode; + xmlChar const *xprop = (xmlChar const *) cprop; + return (char *)xmlGetProp(xnode, xprop); +} + +static gboolean +libxml_isElementNode(CRXMLNodePtr cnode) +{ + xmlNode const *xnode = (xmlNode const *) cnode; + return xnode->type == XML_ELEMENT_NODE; +} + +static void +libxml_freePropVal(void *const cval) +{ + xmlFree(cval); +} + +CRNodeIface const cr_libxml_node_iface = { + libxml_getParentNode, + libxml_getFirstChild, + libxml_getNextSibling, + libxml_getPrevSibling, + libxml_getLocalName, + libxml_getProp, /* fixme: Check whether we want xmlGetNoNsProp instead. */ + + libxml_freePropVal, + libxml_isElementNode +}; -- cgit v1.2.3