Code

Prevent localized doubles from being written into filter matrices
[inkscape.git] / src / libcroco / cr-libxml-node-iface.c
1 #include <libxml/tree.h>
2 #include <string.h>
3 #include "cr-libxml-node-iface.h"
5 static CRXMLNodePtr
6 libxml_getParentNode(CRXMLNodePtr cnode)
7 {
8         xmlNode const *xnode = (xmlNode const *) cnode;
9         return xnode->parent;
10 }
12 static CRXMLNodePtr
13 libxml_getFirstChild(CRXMLNodePtr cnode)
14 {
15         xmlNode const *xnode = (xmlNode const *) cnode;
16         return xnode->children;
17 }
19 static CRXMLNodePtr
20 libxml_getNextSibling(CRXMLNodePtr cnode)
21 {
22         xmlNode const *xnode = (xmlNode const *) cnode;
23         return xnode->next;
24 }
26 static CRXMLNodePtr
27 libxml_getPrevSibling(CRXMLNodePtr cnode)
28 {
29         xmlNode const *xnode = (xmlNode const *) cnode;
30         return xnode->prev;
31 }
33 static char const *
34 local_part(char const *const qname)
35 {
36         char const *ret = strrchr(qname, ':');
37         if (ret)
38                 return ++ret;
39         else
40                 return qname;
41 }
43 static char const *
44 libxml_getLocalName(CRXMLNodePtr cnode)
45 {
46         xmlNode const *xnode = (xmlNode const *) cnode;
47         return local_part((char *)xnode->name);
48 }
50 static char *
51 libxml_getProp(CRXMLNodePtr cnode, char const *cprop)
52 {
53         xmlNodePtr xnode = (xmlNodePtr) cnode;
54         xmlChar const *xprop = (xmlChar const *) cprop;
55         return (char *)xmlGetProp(xnode, xprop);
56 }
58 static gboolean
59 libxml_isElementNode(CRXMLNodePtr cnode)
60 {
61         xmlNode const *xnode = (xmlNode const *) cnode;
62         return xnode->type == XML_ELEMENT_NODE;
63 }
65 static void
66 libxml_freePropVal(void *const cval)
67 {
68         xmlFree(cval);
69 }
71 CRNodeIface const cr_libxml_node_iface = {
72         libxml_getParentNode,
73         libxml_getFirstChild,
74         libxml_getNextSibling,
75         libxml_getPrevSibling,
76         libxml_getLocalName,
77         libxml_getProp,  /* fixme: Check whether we want xmlGetNoNsProp instead. */
79         libxml_freePropVal,
80         libxml_isElementNode
81 };