summaryrefslogtreecommitdiff
path: root/include/xmlsec/nodeset.h
blob: 76304670b3c2993630caf65f32d32a3ff333e701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/** 
 * XML Security Library (http://www.aleksey.com/xmlsec).
 *
 * Enchanced nodes Set
 *
 * This is free software; see Copyright file in the source
 * distribution for preciese wording.
 * 
 * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com>
 */
#ifndef __XMLSEC_NODESET_H__
#define __XMLSEC_NODESET_H__    

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */ 

#include <libxml/tree.h>
#include <libxml/xpath.h>

#include <xmlsec/xmlsec.h>

typedef struct _xmlSecNodeSet 	xmlSecNodeSet, *xmlSecNodeSetPtr;

/** 
 * xmlSecNodeSetType:
 * @xmlSecNodeSetNormal: 	nodes set = nodes in the list.
 * @xmlSecNodeSetInvert:  	nodes set = all document nodes minus nodes in the list.
 * @xmlSecNodeSetTree: 		nodes set = nodes in the list and all their subtress.
 * @xmlSecNodeSetTreeWithoutComments: 		nodes set = nodes in the list and 
 *				all their subtress but no comment nodes.
 * @xmlSecNodeSetTreeInvert: 	nodes set = all document nodes minus nodes in the 
 * 				list and all their subtress.
 * @xmlSecNodeSetTreeWithoutCommentsInvert: 	nodes set = all document nodes 
 * 				minus (nodes in the list and all their subtress 
 *				plus all comment nodes).
 * @xmlSecNodeSetList: 		nodes set = all nodes in the chidren list of nodes sets.
 * 
 * The basic nodes sets types.
 */
typedef enum {
    xmlSecNodeSetNormal = 0,
    xmlSecNodeSetInvert,
    xmlSecNodeSetTree,
    xmlSecNodeSetTreeWithoutComments, 
    xmlSecNodeSetTreeInvert,
    xmlSecNodeSetTreeWithoutCommentsInvert,
    xmlSecNodeSetList
} xmlSecNodeSetType;

/**
 * xmlSecNodeSetOp:
 * @xmlSecNodeSetIntersection: 	intersection.
 * @xmlSecNodeSetSubtraction: 	subtraction.
 * @xmlSecNodeSetUnion: 	union.
 * 
 * The simple nodes sets operations.
 */
typedef enum {
    xmlSecNodeSetIntersection = 0,
    xmlSecNodeSetSubtraction,
    xmlSecNodeSetUnion
} xmlSecNodeSetOp;

/**
 * xmlSecNodeSet:
 * @nodes: 			the nodes list.
 * @doc: 			the parent XML document.
 * @destroyDoc:			the flag: if set to 1 then @doc will
 *				be destroyed when node set is destroyed.
 * @type: 			the nodes set type.
 * @op: 			the operation type.
 * @next: 			the next nodes set.
 * @prev: 			the previous nodes set.
 * @children: 			the children list (valid only if type 
 *				equal to #xmlSecNodeSetList).
 *
 * The enchanced nodes set.
 */
struct _xmlSecNodeSet {
    xmlNodeSetPtr	nodes;
    xmlDocPtr		doc;
    int			destroyDoc;
    xmlSecNodeSetType	type;
    xmlSecNodeSetOp	op;
    xmlSecNodeSetPtr	next;
    xmlSecNodeSetPtr	prev;
    xmlSecNodeSetPtr	children;
};

/**
 * xmlSecNodeSetWalkCallback:
 * @nset: 			the pointer to #xmlSecNodeSet structure.
 * @cur: 			the pointer current XML node.
 * @parent: 			the pointer to the @cur parent node.
 * @data: 			the pointer to application specific data.
 *
 * The callback function called once per each node in the nodes set.
 *
 * Returns: 0 on success or a negative value if an error occurs
 * an walk procedure should be interrupted.
 */
typedef int (*xmlSecNodeSetWalkCallback)		(xmlSecNodeSetPtr nset,
							 xmlNodePtr cur,
							 xmlNodePtr parent,
							 void* data);

XMLSEC_EXPORT xmlSecNodeSetPtr	xmlSecNodeSetCreate	(xmlDocPtr doc,
							 xmlNodeSetPtr nodes,
							 xmlSecNodeSetType type);
XMLSEC_EXPORT void		xmlSecNodeSetDestroy	(xmlSecNodeSetPtr nset);
XMLSEC_EXPORT void		xmlSecNodeSetDocDestroy	(xmlSecNodeSetPtr nset);
XMLSEC_EXPORT int		xmlSecNodeSetContains	(xmlSecNodeSetPtr nset,
							 xmlNodePtr node,
							 xmlNodePtr parent);
XMLSEC_EXPORT xmlSecNodeSetPtr	xmlSecNodeSetAdd	(xmlSecNodeSetPtr nset,
							 xmlSecNodeSetPtr newNSet,
							 xmlSecNodeSetOp op);
XMLSEC_EXPORT xmlSecNodeSetPtr	xmlSecNodeSetAddList	(xmlSecNodeSetPtr nset,
							 xmlSecNodeSetPtr newNSet,
							 xmlSecNodeSetOp op);
XMLSEC_EXPORT xmlSecNodeSetPtr	xmlSecNodeSetGetChildren(xmlDocPtr doc,
							 const xmlNodePtr parent,
							 int withComments,
							 int invert);
XMLSEC_EXPORT int		xmlSecNodeSetWalk	(xmlSecNodeSetPtr nset,
							 xmlSecNodeSetWalkCallback walkFunc,
							 void* data);
XMLSEC_EXPORT int		xmlSecNodeSetDumpTextNodes(xmlSecNodeSetPtr nset,
							xmlOutputBufferPtr out);
XMLSEC_EXPORT void		xmlSecNodeSetDebugDump	(xmlSecNodeSetPtr nset,
							 FILE *output);
							 
#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __XMLSEC_NODESET_H__ */