xref: /titanic_51/usr/src/lib/libpool/common/pool_xml_impl.h (revision b3697b90e692e3e5d859fb77d285d4c056d99eda)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_POOL_XML_IMPL_H
28 #define	_POOL_XML_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * This file contains the definitions of types and supporting
38  * functions to implement the libpool XML specific data manipulation
39  * facility.
40  *
41  * For more information on the libpool generic data manipulation
42  * facility, look at pool_impl.h.
43  *
44  * The central types for the generic data representation/storage
45  * facility are here enhanced to provide additional XML specific
46  * information.
47  */
48 
49 /*
50  * pool_xml_elem_t is the XML (to be precise, libxml - although this
51  * could be easily ported to an alternative C-API xml library)
52  * specific representation of the pool_elem_t structure.
53  *
54  * The pxe_node pointer is a pointer to an XML element which
55  * represents the element in the XML document
56  */
57 typedef struct pool_xml_elem {
58 	/*
59 	 * Common to pool_elem_t
60 	 */
61 	pool_elem_t pxe_elem;
62 	void *pxe_pad1;
63 	void *pxe_pad2;
64 	/*
65 	 * Common to pool_xml_elem_t
66 	 */
67 	xmlNodePtr pxe_node;				/* XML Element */
68 } pool_xml_elem_t;
69 
70 typedef pool_xml_elem_t pool_xml_system_t;
71 
72 typedef struct pool_xml_resource  {
73 	/*
74 	 * Common to pool_elem_t
75 	 */
76 	pool_elem_t pxe_elem;
77 	/*
78 	 * Specific to pool_resource_t
79 	 */
80 	int (*pr_is_system)(const pool_resource_t *);
81 	int (*pr_can_associate)(const pool_resource_t *);
82 	/*
83 	 * Common to pool_xml_elem_t
84 	 */
85 	xmlNodePtr pxe_node;				/* XML Element */
86 } pool_xml_resource_t;
87 
88 typedef struct pool_xml_pool {
89 	/*
90 	 * Common to pool_elem_t
91 	 */
92 	pool_elem_t pxe_elem;
93 	/*
94 	 * Specific to pool_t
95 	 */
96 	int (*pp_associate)(pool_t *, const pool_resource_t *);
97 	int (*pp_dissociate)(pool_t *, const pool_resource_t *);
98 	/*
99 	 * Common to pool_xml_elem_t
100 	 */
101 	xmlNodePtr pxe_node;				/* XML Element */
102 } pool_xml_pool_t;
103 
104 typedef pool_xml_elem_t pool_xml_component_t;
105 
106 /*
107  * pool_xml_result_set_t is the XML (to be precise, libxml - although
108  * this could be easily ported to an alternative C-API xml library)
109  * specific representation of the pool_result_set_t structure.
110  *
111  * The pxr_ctx member is a pointer to an XML XPath Context which
112  * represents the context in which this result set is valid. AN
113  * alternative way of thinking about this is to envisage the context
114  * as the root of the search which is used to build the result set.
115  *
116  * The pxr_path member is a pointer to the compiled XPath statement
117  * used to generate this result set.
118  *
119  * The prs_index member is a cursor into the result set and is used by
120  * the various result set functions to determine which result set
121  * member to access.
122  *
123  */
124 typedef struct pool_xml_result_set {
125 	const pool_conf_t *prs_conf;			/* Configuration */
126 	int prs_active;					/* Query active? */
127 	int prs_index;					/* Result Index */
128 	pool_elem_t *(*prs_next)(pool_result_set_t *);
129 	pool_elem_t *(*prs_prev)(pool_result_set_t *);
130 	pool_elem_t *(*prs_first)(pool_result_set_t *);
131 	pool_elem_t *(*prs_last)(pool_result_set_t *);
132 	int (*prs_set_index)(pool_result_set_t *, int);
133 	int (*prs_get_index)(pool_result_set_t *);
134 	int (*prs_close)(pool_result_set_t *);
135 	int (*prs_count)(pool_result_set_t *);
136 	/*
137 	 * End of common part
138 	 */
139 	xmlXPathContextPtr pxr_ctx;			/* Result Context */
140 	xmlXPathObjectPtr pxr_path;			/* Result Path Object */
141 } pool_xml_result_set_t;
142 
143 /*
144  * pool_xml_connection_t is the XML (to be precise, libxml - although
145  * this could be easily ported to an alternative C-API xml library)
146  * specific representation of the pool_result_set_t structure.
147  *
148  * The pxc_doc member is a pointer to an XML document structure which
149  * contains information about the XML document which acts as the data
150  * store for this connection.
151  *
152  * The pxc_file member is a FILE pointer to the data file used to
153  * store the XML document.
154  *
155  * The pxc_oflags member is the OR'd list of options specified when
156  * opening this connection.
157  *
158  * The pxc_cleanup member is a boolean flag indicating whether a
159  * configuration has a backup which needs to be cleaned up. This is
160  * used as a means of providing resilient configuration changes in the
161  * face of potential failure.
162  *
163  */
164 typedef struct pool_xml_connection {
165 	const char *pc_name;				/* Provider name */
166 	int pc_store_type;				/* Datastore type */
167 	int pc_oflags;					/* Open flags */
168 	int (*pc_close)(pool_conf_t *);
169 	int (*pc_validate)(const pool_conf_t *, pool_valid_level_t);
170 	int (*pc_commit)(pool_conf_t *);
171 	int (*pc_export)(const pool_conf_t *, const char *,
172 	    pool_export_format_t);
173 	int (*pc_rollback)(pool_conf_t *);
174 	pool_result_set_t *(*pc_exec_query)(const pool_conf_t *,
175 	    const pool_elem_t *, const char *,
176 	    pool_elem_class_t, pool_value_t **);
177 	pool_elem_t *(*pc_elem_create)(pool_conf_t *, pool_elem_class_t,
178 	    pool_resource_elem_class_t, pool_component_elem_class_t);
179 	int (*pc_remove)(pool_conf_t *);
180 	int (*pc_res_xfer)(pool_resource_t *, pool_resource_t *, uint64_t);
181 	int (*pc_res_xxfer)(pool_resource_t *, pool_resource_t *,
182 	    pool_component_t **);
183 	char *(*pc_get_binding)(pool_conf_t *, pid_t);
184 	int (*pc_set_binding)(pool_conf_t *, const char *, idtype_t, id_t);
185 	char *(*pc_get_resource_binding)(pool_conf_t *,
186 	    pool_resource_elem_class_t, pid_t);
187 	/*
188 	 * End of common part
189 	 */
190 	xmlDocPtr pxc_doc;				/* XML document */
191 	FILE *pxc_file;					/* XML File */
192 } pool_xml_connection_t;
193 
194 #ifdef	__cplusplus
195 }
196 #endif
197 
198 #endif	/* _POOL_XML_IMPL_H */
199