xref: /titanic_41/usr/src/cmd/lvm/metassist/xml/xml_convert.h (revision 6185db853e024a486ff8837e6784dd290d866112)
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 _XML_CONVERT_H
28 #define	_XML_CONVERT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <libxml/parser.h>
37 #include "volume_request.h"
38 #include "volume_defaults.h"
39 
40 /* The location of the volume-request.dtd */
41 #define	VOLUME_REQUEST_DTD_LOC	"/usr/share/lib/xml/dtd/volume-request.dtd"
42 
43 /* The location of the volume-request-defaults.dtd */
44 #define	VOLUME_DEFAULTS_DTD_LOC	"/usr/share/lib/xml/dtd/volume-defaults.dtd"
45 
46 /* The location of the volume-config.dtd */
47 #define	VOLUME_CONFIG_DTD_LOC	"/usr/share/lib/xml/dtd/volume-config.dtd"
48 
49 /* Location of the volume-command.xsl file */
50 #define	VOLUME_COMMAND_XSL_LOC	"/usr/share/lib/xml/style/volume-command.xsl"
51 
52 /*
53  * Valid values for attributes
54  */
55 #define	VALID_ATTR_TRUE			"TRUE"
56 #define	VALID_ATTR_FALSE		"FALSE"
57 #define	VALID_MIRROR_READ_GEOMETRIC	"GEOMETRIC"
58 #define	VALID_MIRROR_READ_FIRST		"FIRST"
59 #define	VALID_MIRROR_READ_ROUNDROBIN	"ROUNDROBIN"
60 #define	VALID_MIRROR_WRITE_SERIAL	"SERIAL"
61 #define	VALID_MIRROR_WRITE_PARALLEL	"PARALLEL"
62 
63 /*
64  * Standard units
65  */
66 #define	UNIT_BLOCKS	"BLOCKS"
67 #define	UNIT_KILOBYTES	"KB"
68 #define	UNIT_MEGABYTES	"MB"
69 #define	UNIT_GIGABYTES	"GB"
70 #define	UNIT_TERABYTES	"TB"
71 
72 /*
73  * Initialize the XML parser, setting defaults across all XML
74  * routines.
75  */
76 extern void init_xml();
77 
78 /*
79  * Clean up any remaining structures before exiting.
80  */
81 extern void cleanup_xml();
82 
83 /*
84  * Converts a volume-request XML document into a request_t.
85  *
86  * @param       doc
87  *		an existing volume-request XML document
88  *
89  * @param       request
90  *		RETURN: a new request_t which must be freed via
91  *		free_request
92  *
93  * @return      0 on success, non-zero otherwise.
94  */
95 extern int xml_to_request(xmlDocPtr doc, request_t **request);
96 
97 /*
98  * Converts a volume-defaults XML document into a defaults_t.
99  *
100  * @param       doc
101  *		an existing volume-defaults XML document
102  *
103  * @param       defaults
104  *		RETURN: a new defaults_t which must be freed via
105  *		free_defaults
106  *
107  * @return      0 on success, non-zero otherwise.
108  */
109 extern int xml_to_defaults(xmlDocPtr doc, defaults_t **defaults);
110 
111 /*
112  * Converts a volume-config XML document into a devconfig_t.
113  *
114  * @param       doc
115  *		an existing volume-config XML document
116  *
117  * @param       config
118  *		RETURN: a new devconfig_t which must be freed via
119  *		free_devconfig
120  *
121  * @return      0 on success, non-zero otherwise.
122  */
123 extern int xml_to_config(xmlDocPtr doc, devconfig_t **config);
124 
125 /*
126  * Converts a devconfig_t into a volume-config XML document.
127  *
128  * @param       config
129  *		an existing devconfig_t representing a volume
130  *		configuration.
131  *
132  * @param       doc
133  *		RETURN: a new volume-config XML document which must be
134  *		freed via xmlFreeDoc
135  *
136  * @return      0 on success, non-zero otherwise.
137  */
138 extern int config_to_xml(devconfig_t *config, xmlDocPtr *doc);
139 
140 /*
141  * Converts a volume-config XML document into a Bourne shell script.
142  *
143  * @param       doc
144  *		an existing volume-config XML document
145  *
146  * @param       commands
147  *		RETURN: a new char* which must be freed
148  *
149  * @return      0 on success, non-zero otherwise.
150  */
151 extern int xml_to_commands(xmlDocPtr doc, char **commands);
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif /* _XML_CONVERT_H */
158