/* $Id: xmlconfig.h,v 1.11 2007/09/30 15:41:10 mgdepalma Exp $
 *
 * Copyright (C) 2007 Softcraft Impresa, LLC <info@softcraft.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; You may only use version 2 of the License,
 * you have no option to use any other version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef XML_CONFIG_H
#define XML_CONFIG_H

#include <fcntl.h>
#include <libxml/xmlreader.h>
#include <string.h>
#include <glib.h>

G_BEGIN_DECLS

/* Global program data structure */
typedef struct _configuration_node ConfigurationNode;
typedef struct _configuration_attrib ConfigurationAttrib;

struct _configuration_attrib
{
  gchar *name;			/* attribute name */
  gchar *value;			/* attribute value */
  ConfigurationAttrib *next;	/* next record */
};

struct _configuration_node
{
  ConfigurationAttrib *attrib;	/* attributes list */
  ConfigurationNode *back;	/* previous record */
  ConfigurationNode *next;	/* next record */
  gchar *element;		/* element name/value */
  gpointer data;		/* user defined data */
  guint depth;			/* element depth */
  guint type;			/* element type */
};

/* Methods exported in the implementation */
gchar *configuration_attrib (ConfigurationNode *config, gchar *name);
gchar *configuration_path (ConfigurationNode *config);

ConfigurationNode *configuration_find (ConfigurationNode *config,
                                             const gchar *element);

ConfigurationNode *configuration_find_next (ConfigurationNode *config,
                                                  const gchar *element);

gboolean configuration_insert (ConfigurationNode *config,
                               ConfigurationNode *node,
                                        gboolean  nest);

gboolean configuration_remove (ConfigurationNode *node);

ConfigurationNode *configuration_read (const gchar *data,
                                       const gchar *schema,
                                          gboolean  memory);

void configuration_write (ConfigurationNode *config,
                                 const char *header,
                                       FILE *stream);

G_END_DECLS

#endif /* </XML_CONFIG_H> */
