fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
530e2b59e3a1e24b97617608e33a1786f2875502wl * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libgen.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/socket.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/in.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <arpa/inet.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libxml/parser.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libxml/xpath.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_server.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_obj.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "isns_log.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov#if LIBXML_VERSION >= 20904
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov#define XMLSTRING_CAST (const char *)
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov#else
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov#define XMLSTRING_CAST (const xmlChar *)
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov#endif
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * external variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char data_store[MAXPATHLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * local variables
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic xmlDocPtr xml_doc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *xml_file = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *xml_tmp_file = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *xml_bak_file = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int OBJ_DTD_ORDER[MAX_OBJ_TYPE_FOR_SIZE] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 1, /* OBJ_ENTITY */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 2, /* OBJ_ISCSI */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 3, /* OBJ_PORTAL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 4, /* OBJ_PG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 5, /* OBJ_DD */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 6, /* OBJ_DDS */
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 12, /* OBJ_ASSOC_ISCSI */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 14, /* OBJ_ASSOC_DD */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_ROOT(ISNS_DATA, VENDOR, SMI, VERSION, ONE_DOT_O) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ISNS_DATA, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)VENDOR, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)SMI, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)VERSION, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (xmlChar *)ONE_DOT_O
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const xmlChar *xml_root[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_DATA(TAG, TYPE, ARG1, ARG2) (xmlChar *)TAG,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const xmlChar* xmlTag[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_DATA(TAG, TYPE, ARG1, ARG2) TYPE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const char *xmlType[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_DATA(TAG, TYPE, ARG1, ARG2) ARG1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int xmlArg1[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_DATA(TAG, TYPE, ARG1, ARG2) ARG2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int xmlArg2[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_PROP(INDEX, TYPE, NAME, TAG, ID) (xmlChar *)NAME,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const xmlChar *xmlPropName[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_PROP(INDEX, TYPE, NAME, TAG, ID) TAG,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int xmlPropTag[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEF_XML_PROP(INDEX, TYPE, NAME, TAG, ID) ID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const int xmlPropID[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "data.def"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ARRAY_LENGTH(ARRAY) (sizeof (ARRAY) / sizeof (ARRAY[0]))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name - the name of an attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - index or -1 for error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_index_by_name(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const xmlChar *name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < ARRAY_LENGTH(xmlTag); i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlStrEqual(xmlTag[i], name)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name - the type of an object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - index or -1 for error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_index_by_otype(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int otype
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < ARRAY_LENGTH(xmlTag); i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlArg1[i] == otype && xmlType[i][0] == 'o') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name - the tag of an attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - index or -1 for error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_index_by_tag(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int tag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < ARRAY_LENGTH(xmlTag); i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlArg1[i] == tag &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlType[i][0] != 'o' &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlType[i][0] != 'a') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * docp - the doc pointer for returning.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_xml_doc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr *docp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xml_doc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* validate the xml file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* open the xml file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_doc = xmlParseFile(xml_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *docp = xml_doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xml_doc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
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 * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteclose_xml_doc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xml_doc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* just close it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeDoc(xml_doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_doc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert_xml2attr:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert a xml data to a TLV format isns attribute.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconvert_xml2attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int tag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const unsigned char type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar *value,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_attr_t *attr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->tag = tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'u':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 4-bytes non-negative integer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = 4;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui = atoi((const char *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 's':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* literal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen((char *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len += 4 - (len % 4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ptr = (uchar_t *)malloc(attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ptr != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy((char *)attr->value.ptr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'p':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPv6 block data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->len = sizeof (in6_addr_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ip = (in6_addr_t *)malloc(attr->len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr->value.ip != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) inet_pton(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)value,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ip);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert_attr2xml:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * convert a TLV format isns attribute to xml node format.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic xmlNodePtr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconvert_attr2xml(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_attr_t *attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const xmlChar *name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int elm_flag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar buff[INET6_ADDRSTRLEN + 1] = { 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar *value = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr child = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'u':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 4-bytes non-negative integer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlStrPrintf(buff, sizeof (buff),
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov XMLSTRING_CAST "%u",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = (xmlChar *)&buff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 's':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* literal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = (xmlChar *)attr->value.ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'p':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* IPv6 block data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = (xmlChar *)inet_ntop(AF_INET6,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)attr->value.ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)buff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (buff));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (elm_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0: /* attlist */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(node, name, value)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1: /* child element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = xmlNewChild(node, NULL, name, value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2: /* prev sibling element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = xmlNewNode(NULL, name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (child != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlAddPrevSibling(node, child) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeNode(child);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = child;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_CASE_FALLTHRU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 3: /* set content */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodeSetContent(node, value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 4: /* new attr value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSetProp(node, name, value)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (child);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
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 *
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 * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteparse_xml_prop(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *props = &xmlType[i][1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const xmlChar *prop_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar *prop_value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char prop_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int prop_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int prop_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char prop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = props[j ++];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ec == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop >= 'a' && prop <= 'z') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop -= 'a';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_id = xmlPropID[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_tag = xmlPropTag[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_name = xmlPropName[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_type = xmlPropType[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_value = xmlGetProp(node, prop_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (prop_value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = convert_xml2attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_tag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_value,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(obj->attrs[prop_id]));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFree(prop_value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = props[j ++];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
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 *
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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteparse_xml_attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const unsigned char attr_type = xmlType[i][0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int attr_tag = xmlArg1[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int attr_id = xmlArg2[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar *attr_value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_value = xmlNodeGetContent(node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attr_value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = convert_xml2attr(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_tag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr_value,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &(obj->attrs[attr_id]));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFree(attr_value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse_xml_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * parse one isns object from the xml doc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteparse_xml_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr *nodep,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **objp
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node = *nodep;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t *obj = *objp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (node && ec == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node->type == XML_ELEMENT_NODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte children = node->children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = get_index_by_name(node->name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(i >= 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = xmlType[i][0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j == 'o' && obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj = obj_calloc(xmlArg1[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (obj == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ec = parse_xml_prop(node, obj, i)) == 0 &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (children == NULL ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (ec = parse_xml_obj(&children, &obj)) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (children != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte children != node->children) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *nodep = children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *objp = obj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_NOP_IF_STMT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (j == 'o') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (j != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (children != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = parse_xml_attr(children, obj, i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *nodep = children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* assign a default value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *nodep = node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* unknown xml node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* LINTED E_NOP_ELSE_STMT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* carry return or blank spaces, skip it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locate_xml_node:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locate the xml node from xml doc by matching the object UID.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortelocate_xml_node(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int otype,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int match_uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr *node,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathContextPtr *context,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathObjectPtr *result
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodeSetPtr nodeset;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr curr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar expr[32] = { (xmlChar)'/', (xmlChar)'/', 0 };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char prop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const xmlChar *prop_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar *prop_value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *node = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = get_index_by_otype(otype);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(i >= 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *context = xmlXPathNewContext(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*context &&
0687de4f0b1d84cc87ddf92c49ceaec0f551670eAlexander Pyhalov xmlStrPrintf(&expr[2], 30, XMLSTRING_CAST "%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlTag[i]) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *result = xmlXPathEvalExpression(expr, *context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*result) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = xmlArg2[i] - 'a';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_name = xmlPropName[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(xmlPropType[prop] == 'u');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodeset = (*result)->nodesetval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodeset && (j < nodeset->nodeNr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte curr = nodeset->nodeTab[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_value = xmlGetProp(curr, prop_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (prop_value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = atoi((const char *)prop_value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFree(prop_value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == match_uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* found it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *node = curr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*result) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeObject(*result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*context) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeContext(*context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *context = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make_xml_node:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * generate a xml node for presenting an isns object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - an isns object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - the xml node.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic xmlNodePtr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemake_xml_node(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *props;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char prop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const xmlChar *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int prop_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = get_index_by_otype(obj->type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(i >= 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = xmlNewNode(NULL, xmlTag[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* generate xml attributes of the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte props = &xmlType[i][1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = *(props ++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (prop >= 'a' && prop <= 'z') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop -= 'a';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_id = xmlPropID[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = xmlPropName[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = xmlPropType[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[prop_id];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(node, attr, name, type, 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeNode(node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attr->tag = 0; */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = *(props ++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* generate sub elements for isns attributes of the object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (i < NUM_OF_ATTRS[obj->type]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[i ++];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = get_index_by_tag(attr->tag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = xmlTag[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = xmlType[j][0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(node, attr, name, type, 1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeNode(node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_init_data:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialization of the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortexml_init_data(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define XML_PATH "/etc/isns"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define XML_FILE_NAME "/isnsdata.xml"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define XML_DOT_TMP ".tmp"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define XML_DOT_BAK ".bak"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr root;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *xml_path, *p = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *cwd = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int has_bak = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cannot reset the xml file when server is running */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xml_file != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the data store file name along with the backup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* file name and temporary file name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len = strlen(data_store);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (len > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_file = data_store;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p = strdup(xml_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_bak_file = (char *)malloc(len + 5);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_tmp_file = (char *)malloc(len + 5);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_bak_file != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_tmp_file != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_path = dirname(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(xml_bak_file, xml_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(xml_bak_file, XML_DOT_BAK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcpy(xml_tmp_file, xml_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strcat(xml_tmp_file, XML_DOT_TMP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_path = XML_PATH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_file = XML_PATH XML_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 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* save current working directory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cwd = getcwd(NULL, MAXPATHLEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cwd == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check access permission on data store directory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (chdir(xml_path) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno == ENOENT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mkdir(xml_path, S_IRWXU) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chdir(xml_path) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* go back to original working directory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) chdir(cwd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(cwd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do not keep blank spaces */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) xmlKeepBlanksDefault(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
530e2b59e3a1e24b97617608e33a1786f2875502wl /* remove the tmp file if it exists */
530e2b59e3a1e24b97617608e33a1786f2875502wl if (access(xml_tmp_file, F_OK) == 0) {
530e2b59e3a1e24b97617608e33a1786f2875502wl (void) remove(xml_tmp_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* test if we can write the bak file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fd = open(xml_bak_file, O_RDWR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fd = open(xml_bak_file, O_RDWR | O_CREAT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte S_IRUSR | S_IWUSR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) remove(xml_bak_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte has_bak = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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 fd = open(xml_file, O_RDWR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (has_bak == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doc = xmlNewDoc(BAD_CAST "1.0");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root = xmlNewNode(NULL, xml_root[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doc != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte root != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlSetProp(root, xml_root[1], xml_root[2]) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlSetProp(root, xml_root[3], xml_root[4]) !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) xmlDocSetRootElement(doc, root);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlSaveFormatFile(xml_file, doc, 1) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeDoc(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeDoc(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeDoc(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (root != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeNode(root);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isnslog(LOG_WARNING, "get_xml_doc",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "initializing with backup data");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rename(xml_bak_file, xml_file) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_load_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * load an isns object from the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortexml_load_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void **p,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_obj_t **objp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *level
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node = (xmlNodePtr)*p;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *objp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *level = '^';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = get_xml_doc(&doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (node->children != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *level = '>';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (node->next != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *level = 'v';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *level = 'v';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (node != NULL && node->next == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node->type == XML_ELEMENT_NODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *level = '<';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->parent;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* there is a node, parse it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = parse_xml_obj(&node, objp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *p = (void *)node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec == 0 && *objp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = update_deref_obj(*objp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ec != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free_object(*objp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *objp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no object available, close the xml doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*objp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close_xml_doc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_add_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add an isns object to the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being added.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortexml_add_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathContextPtr context = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathObjectPtr result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node, prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr candidate;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid, parent_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the xml doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = get_xml_doc(&doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto add_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create the candidate node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte candidate = make_xml_node(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (candidate == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto add_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* locate the position */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parent_type = TYPE_OF_PARENT[obj->type];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parent_type > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte puid = get_parent_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = locate_xml_node(doc, parent_type, puid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &node, &context, &result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = xmlDocGetRootElement(doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cannot locate the point for inserting the node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeNode(candidate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto add_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* add it with the apporiate child order */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node->children) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node->type == XML_ELEMENT_NODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = get_index_by_name(node->name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(i >= 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlType[i][0] == 'o' &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OBJ_DTD_ORDER[xmlArg1[i]] >=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OBJ_DTD_ORDER[obj->type]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prev = node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = xmlAddNextSibling(prev, candidate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = xmlAddPrevSibling(node, candidate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = xmlAddChild(node, candidate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Failed, free the candidate node. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeNode(candidate);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadd_done:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (result) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeObject(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (context) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeContext(context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_modify_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * modify an isns object in the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the new object.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortexml_modify_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathContextPtr context = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathObjectPtr result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node, child;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *props;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char prop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int prop_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int prop_tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const xmlChar *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_attr_t *attr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j, k;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int make_child;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the doc pointer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = get_xml_doc(&doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* locate the node for the object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = get_index_by_otype(obj->type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(i >= 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = xmlArg2[i] - 'a';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_id = xmlPropID[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[prop_id];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = locate_xml_node(doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte obj->type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr->value.ui,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &node, &context, &result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* modify it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte props = &xmlType[i][1];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = *(props ++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (prop >= 'a' && prop <= 'z') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop -= 'a';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_id = xmlPropID[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_tag = xmlPropTag[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[prop_id];
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 if (prop_tag == ISNS_DD_NAME_ATTR_ID ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_tag == ISNS_DD_SET_NAME_ATTR_ID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = xmlPropName[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = xmlPropType[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(node,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr, name, type, 4)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto modify_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attr->tag = 0; */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = *(props ++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the child */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = node->children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (child == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte make_child = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte make_child = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < NUM_OF_ATTRS[obj->type]; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = &obj->attrs[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte j = get_index_by_tag(attr->tag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name = xmlTag[j];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte type = xmlType[j][0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (make_child == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make a child node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(node, attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name, type, 1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto modify_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (child) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (child->type == XML_ELEMENT_NODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte k = get_index_by_name(child->name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(k >= 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlType[k][0] == 'o' ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlType[k][0] == 'a' ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlArg1[k] > attr->tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(child,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr, name, type, 2)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* internal error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = 11;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto modify_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (xmlArg1[k] == attr->tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* replace content */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(child,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr, name, type, 3)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* internal error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = 11;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto modify_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte child = child->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (child == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make a child node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!convert_attr2xml(node, attr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte name, type, 1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto modify_done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This case is for registering a node which has */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* membership in one or more non-default DD(s). */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = xml_add_obj(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemodify_done:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (result) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeObject(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (context) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeContext(context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_delete_obj:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delete an isns object from the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * obj - the object being deleted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortexml_delete_obj(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *obj
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathContextPtr context = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathObjectPtr result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte isns_type_t otype;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the xml doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = get_xml_doc(&doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte otype = obj->type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WRITE_DATA_ASYNC
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* it is a thin clone */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = obj->attrs[0].value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = get_obj_uid(obj);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* locate the object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = locate_xml_node(doc,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte otype,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &node, &context, &result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* destroy it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlUnlinkNode(node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeNode(node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (result) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeObject(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (context) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeContext(context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_delete_assoc:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delete a DD or DD-set membership from the xml data store.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * assoc - the membership being deleted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortexml_delete_assoc(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const isns_obj_t *assoc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlDocPtr doc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathContextPtr context = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathObjectPtr result = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlNodePtr node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t puid, parent_type;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t uid, match_uid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char prop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const xmlChar *prop_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlChar *prop_value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the xml doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = get_xml_doc(&doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the container object UID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parent_type = TYPE_OF_PARENT[assoc->type];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(parent_type != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte puid = get_parent_uid(assoc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(puid != 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the member object UID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = get_index_by_otype(assoc->type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop = xmlArg2[i] - 'a';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_name = xmlPropName[prop];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte match_uid = assoc->attrs[UID_ATTR_INDEX[assoc->type]].value.ui;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* locate the container object */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = locate_xml_node(doc, parent_type, puid,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &node, &context, &result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the membership nodes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->children;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the matching membership node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node->type == XML_ELEMENT_NODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = get_index_by_name(node->name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ASSERT(i >= 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xmlType[i][0] == 'o' &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlArg1[i] == assoc->type) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prop_value = xmlGetProp(node, prop_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (prop_value) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uid = atoi((const char *)prop_value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFree(prop_value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (uid == match_uid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node = node->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* destroy it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlUnlinkNode(node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeNode(node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (result) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeObject(result);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (context) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlXPathFreeContext(context);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - error code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortexml_update_commit(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ec = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xml_doc) {
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(xml_file, xml_bak_file) != 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* rename the tmp file to the current file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rename(xml_tmp_file, xml_file) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* failed saving file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ec = ISNS_RSP_INTERNAL_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* close the xml_doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeDoc(xml_doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_doc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (ec);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * xml_update_retreat:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ignore all of updates in the xml doc.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return - 0: always successful.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ****************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortexml_update_retreat(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (xml_doc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* close the xml_doc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xmlFreeDoc(xml_doc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte xml_doc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}