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