data.c revision 0687de4f0b1d84cc87ddf92c49ceaec0f551670e
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
530e2b59e3a1e24b97617608e33a1786f2875502wl * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov#define XMLSTRING_CAST (const char *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * external variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int NUM_OF_ATTRS[MAX_OBJ_TYPE_FOR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int TYPE_OF_PARENT[MAX_OBJ_TYPE_FOR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern const int UID_ATTR_INDEX[MAX_OBJ_TYPE_FOR_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int OBJ_DTD_ORDER[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* MAX_OBJ_TYPE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, /* OBJ_DUMMY4 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_ROOT(ISNS_DATA, VENDOR, SMI, VERSION, ONE_DOT_O) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_DATA(TAG, TYPE, ARG1, ARG2) (xmlChar *)TAG,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char *xmlType[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int xmlArg1[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int xmlArg2[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_PROP(INDEX, TYPE, NAME, TAG, ID) TYPE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const unsigned char xmlPropType[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_PROP(INDEX, TYPE, NAME, TAG, ID) (xmlChar *)NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_PROP(INDEX, TYPE, NAME, TAG, ID) TAG,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int xmlPropTag[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_PROP(INDEX, TYPE, NAME, TAG, ID) ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int xmlPropID[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ARRAY_LENGTH(ARRAY) (sizeof (ARRAY) / sizeof (ARRAY[0]))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_index_by_name:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find the index in the global tables for the name of an attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name - the name of an attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - index or -1 for error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_index_by_otype:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find the index in the global tables for the type of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name - the type of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - index or -1 for error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlArg1[i] == otype && xmlType[i][0] == 'o') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_index_by_tag:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * find the index in the global tables for the tag of an attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name - the tag of an attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - index or -1 for error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get_xml_doc:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * open the xml file and assign the global xml doc if the xml file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is not opened, set the doc pointer with the opened xml file for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returnning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * docp - the doc pointer for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* validate the xml file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* open the xml file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * close_xml_doc:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * close the global xml doc and ignore any changes that has been
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * made in it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* just close it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert_xml2attr:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert a xml data to a TLV format isns attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * tag - the tag of attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - the data type of the xml data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * value - the xml data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attr - TLV format attribute for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const unsigned char type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 4-bytes non-negative integer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* literal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPv6 block data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ip = (in6_addr_t *)malloc(attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert_attr2xml:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert a TLV format isns attribute to xml node format.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node - the xml node where the new node is being added to.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * attr - the TLV format attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name - the name of the attribute in xml node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type - the data type of the attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * elm_flag - 0: adding a xml attlist.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1: adding a xml child node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2: adding a previous sibling node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 3: adding a xml content node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 4: adding a xml attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - xml node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 4-bytes non-negative integer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* literal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPv6 block data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0: /* attlist */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_CASE_FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse_xml_prop:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse the properties of a xml node and convert them to the attributes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of an isns object, these xml properties are the UID attribute and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * key attributes of the isns object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node - the xml node that contains the properties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the isns object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i - the index of the attribute in the global tables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char prop_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse_xml_attr:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse a xml node and convert it to one isns object attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this attribute is the non-key attribute of the isns object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node - the xml node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the isns object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * i - the index of the attribute in the global tables.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse_xml_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse one isns object from the xml doc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nodep - the pointer of the xml node for parsing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * objp - the pointer of isns object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_NOP_IF_STMT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (j == 'o') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (j != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* assign a default value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unknown xml node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_NOP_ELSE_STMT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* carry return or blank spaces, skip it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locate_xml_node:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locate the xml node from xml doc by matching the object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * doc - the xml doc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otype - the matching object type.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * match_uid - the matching object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node - the pointer of matched xml node for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * context - the xml context for matching process.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * result - the xml result for matching process.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar expr[32] = { (xmlChar)'/', (xmlChar)'/', 0 };
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov xmlStrPrintf(&expr[2], 30, XMLSTRING_CAST "%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *result = xmlXPathEvalExpression(expr, *context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* found it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make_xml_node:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * generate a xml node for presenting an isns object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - an isns object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the xml node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *props;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* generate xml attributes of the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(node, attr, name, type, 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attr->tag = 0; */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* generate sub elements for isns attributes of the object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(node, attr, name, type, 1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_init_data:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialization of the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cannot reset the xml file when server is running */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the data store file name along with the backup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* file name and temporary file name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_bak_file = XML_PATH XML_FILE_NAME XML_DOT_BAK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_tmp_file = XML_PATH XML_FILE_NAME XML_DOT_TMP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save current working directory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check access permission on data store directory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* go back to original working directory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do not keep blank spaces */
530e2b59e3a1e24b97617608e33a1786f2875502wl /* remove the tmp file if it exists */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* test if we can write the bak file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Test if we have the data store file, create an empty */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* data store if we do not have the data store file and */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the backup data store. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "initializing with backup data");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_load_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * load an isns object from the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * p - the pointer of current xml node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * objp - the pointer of the object for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * level - the direction of xml parsing for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* there is a node, parse it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = (void *)node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no object available, close the xml doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_add_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add an isns object to the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the xml doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create the candidate node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* locate the position */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cannot locate the point for inserting the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add it with the apporiate child order */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Failed, free the candidate node. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_modify_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * modify an isns object in the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the new object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *props;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j, k;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the doc pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* locate the node for the object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* modify it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no need to update the key attributes, skip it. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* btw, dd and dd-set names are non-key attributes. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attr->tag = 0; */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the child */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make a child node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* internal error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* replace content */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* internal error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make a child node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This case is for registering a node which has */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* membership in one or more non-default DD(s). */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_delete_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delete an isns object from the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being deleted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the xml doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* it is a thin clone */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* locate the object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* destroy it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_delete_assoc:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delete a DD or DD-set membership from the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * assoc - the membership being deleted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the xml doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the container object UID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the member object UID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match_uid = assoc->attrs[UID_ATTR_INDEX[assoc->type]].value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* locate the container object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the membership nodes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the matching membership node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* destroy it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_update_commit:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * backup the current written file and commit all updates from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the xml doc to the written file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* write to tmp file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSaveFormatFile(xml_tmp_file, xml_doc, 1) == -1 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* backup the current file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* rename the tmp file to the current file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* failed saving file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* close the xml_doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_update_retreat:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ignore all of updates in the xml doc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: always successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* close the xml_doc */