|
1 /** |
|
2 * XML Security Library (http://www.aleksey.com/xmlsec). |
|
3 * |
|
4 * Enchanced nodes Set |
|
5 * |
|
6 * This is free software; see Copyright file in the source |
|
7 * distribution for preciese wording. |
|
8 * |
|
9 * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com> |
|
10 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
11 */ |
|
12 #ifndef __XMLSEC_NODESET_H__ |
|
13 #define __XMLSEC_NODESET_H__ |
|
14 |
|
15 #ifdef __cplusplus |
|
16 extern "C" { |
|
17 #endif /* __cplusplus */ |
|
18 |
|
19 #include <libxml2_tree.h> |
|
20 #include <libxml2_xpath.h> |
|
21 #include "xmlsec_config.h" |
|
22 #include "xmlsec_xmlsec.h" |
|
23 |
|
24 typedef struct _xmlSecNodeSet xmlSecNodeSet, *xmlSecNodeSetPtr; |
|
25 |
|
26 /** |
|
27 * xmlSecNodeSetType: |
|
28 * @xmlSecNodeSetNormal: nodes set = nodes in the list. |
|
29 * @xmlSecNodeSetInvert: nodes set = all document nodes minus nodes in the list. |
|
30 * @xmlSecNodeSetTree: nodes set = nodes in the list and all their subtress. |
|
31 * @xmlSecNodeSetTreeWithoutComments: nodes set = nodes in the list and |
|
32 * all their subtress but no comment nodes. |
|
33 * @xmlSecNodeSetTreeInvert: nodes set = all document nodes minus nodes in the |
|
34 * list and all their subtress. |
|
35 * @xmlSecNodeSetTreeWithoutCommentsInvert: nodes set = all document nodes |
|
36 * minus (nodes in the list and all their subtress |
|
37 * plus all comment nodes). |
|
38 * @xmlSecNodeSetList: nodes set = all nodes in the chidren list of nodes sets. |
|
39 * |
|
40 * The basic nodes sets types. |
|
41 */ |
|
42 typedef enum { |
|
43 xmlSecNodeSetNormal = 0, |
|
44 xmlSecNodeSetInvert, |
|
45 xmlSecNodeSetTree, |
|
46 xmlSecNodeSetTreeWithoutComments, |
|
47 xmlSecNodeSetTreeInvert, |
|
48 xmlSecNodeSetTreeWithoutCommentsInvert, |
|
49 xmlSecNodeSetList |
|
50 } xmlSecNodeSetType; |
|
51 |
|
52 /** |
|
53 * xmlSecNodeSetOp: |
|
54 * @xmlSecNodeSetIntersection: intersection. |
|
55 * @xmlSecNodeSetSubtraction: subtraction. |
|
56 * @xmlSecNodeSetUnion: union. |
|
57 * |
|
58 * The simple nodes sets operations. |
|
59 */ |
|
60 typedef enum { |
|
61 xmlSecNodeSetIntersection = 0, |
|
62 xmlSecNodeSetSubtraction, |
|
63 xmlSecNodeSetUnion |
|
64 } xmlSecNodeSetOp; |
|
65 |
|
66 /** |
|
67 * xmlSecNodeSet: |
|
68 * @nodes: the nodes list. |
|
69 * @doc: the parent XML document. |
|
70 * @destroyDoc: the flag: if set to 1 then @doc will |
|
71 * be destroyed when node set is destroyed. |
|
72 * @type: the nodes set type. |
|
73 * @op: the operation type. |
|
74 * @next: the next nodes set. |
|
75 * @prev: the previous nodes set. |
|
76 * @children: the children list (valid only if type |
|
77 * equal to #xmlSecNodeSetList). |
|
78 * |
|
79 * The enchanced nodes set. |
|
80 */ |
|
81 struct _xmlSecNodeSet { |
|
82 xmlNodeSetPtr nodes; |
|
83 xmlDocPtr doc; |
|
84 int destroyDoc; |
|
85 xmlSecNodeSetType type; |
|
86 xmlSecNodeSetOp op; |
|
87 xmlSecNodeSetPtr next; |
|
88 xmlSecNodeSetPtr prev; |
|
89 xmlSecNodeSetPtr children; |
|
90 }; |
|
91 |
|
92 /** |
|
93 * xmlSecNodeSetWalkCallback: |
|
94 * @nset: the pointer to #xmlSecNodeSet structure. |
|
95 * @cur: the pointer current XML node. |
|
96 * @parent: the pointer to the @cur parent node. |
|
97 * @data: the pointer to application specific data. |
|
98 * |
|
99 * The callback function called once per each node in the nodes set. |
|
100 * |
|
101 * Returns 0 on success or a negative value if an error occurs |
|
102 * an walk procedure should be interrupted. |
|
103 */ |
|
104 typedef int (*xmlSecNodeSetWalkCallback) (xmlSecNodeSetPtr nset, |
|
105 xmlNodePtr cur, |
|
106 xmlNodePtr parent, |
|
107 void* data); |
|
108 |
|
109 XMLSEC_EXPORT xmlSecNodeSetPtr xmlSecNodeSetCreate (xmlDocPtr doc, |
|
110 xmlNodeSetPtr nodes, |
|
111 xmlSecNodeSetType type); |
|
112 XMLSEC_EXPORT void xmlSecNodeSetDestroy (xmlSecNodeSetPtr nset); |
|
113 XMLSEC_EXPORT void xmlSecNodeSetDocDestroy (xmlSecNodeSetPtr nset); |
|
114 XMLSEC_EXPORT int xmlSecNodeSetContains (xmlSecNodeSetPtr nset, |
|
115 xmlNodePtr node, |
|
116 xmlNodePtr parent); |
|
117 XMLSEC_EXPORT xmlSecNodeSetPtr xmlSecNodeSetAdd (xmlSecNodeSetPtr nset, |
|
118 xmlSecNodeSetPtr newNSet, |
|
119 xmlSecNodeSetOp op); |
|
120 XMLSEC_EXPORT xmlSecNodeSetPtr xmlSecNodeSetAddList (xmlSecNodeSetPtr nset, |
|
121 xmlSecNodeSetPtr newNSet, |
|
122 xmlSecNodeSetOp op); |
|
123 XMLSEC_EXPORT xmlSecNodeSetPtr xmlSecNodeSetGetChildren(xmlDocPtr doc, |
|
124 const xmlNodePtr parent, |
|
125 int withComments, |
|
126 int invert); |
|
127 XMLSEC_EXPORT int xmlSecNodeSetWalk (xmlSecNodeSetPtr nset, |
|
128 xmlSecNodeSetWalkCallback walkFunc, |
|
129 void* data); |
|
130 XMLSEC_EXPORT int xmlSecNodeSetDumpTextNodes(xmlSecNodeSetPtr nset, |
|
131 xmlOutputBufferPtr out); |
|
132 XMLSEC_EXPORT void xmlSecNodeSetDebugDump (xmlSecNodeSetPtr nset, |
|
133 FILE *output); |
|
134 |
|
135 #ifdef __cplusplus |
|
136 } |
|
137 #endif /* __cplusplus */ |
|
138 |
|
139 #endif /* __XMLSEC_NODESET_H__ */ |
|
140 |