summaryrefslogtreecommitdiff
path: root/src/common/xml.h
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2009-09-19 13:01:04 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2009-09-19 13:01:04 (GMT)
commit859bdb6b51d76058eb1a8bfa619a15978f50b251 (patch)
tree306ba7f92d84f10c0a7fc8e385cb32b85bb3cb73 /src/common/xml.h
parentff4fd84840beca40a88db2ca0ce90e6511fb852b (diff)
Improved the pyoida module.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@116 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/common/xml.h')
-rw-r--r--src/common/xml.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/src/common/xml.h b/src/common/xml.h
new file mode 100644
index 0000000..82e2578
--- /dev/null
+++ b/src/common/xml.h
@@ -0,0 +1,122 @@
+
+/* Firebox Tools - Outils de configurations pour le WM Firebox
+ * xml.h - prototypes pour la lecture ou l'écriture de documents XML
+ *
+ * Copyright (C) 2006-2007 Cyrille Bagard
+ *
+ * This file is part of Firebox Tools.
+ *
+ * Firebox Tools 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Firebox Tools 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _XML_H
+#define _XML_H
+
+
+#include <stdbool.h>
+#include <glib/gtypes.h>
+#include <libxml/tree.h>
+#include <libxml/xmlwriter.h>
+#include <libxml/xpath.h>
+
+
+
+
+/* Crée un nouveau fichier XML. */
+bool create_new_xml_file(xmlDocPtr *, xmlXPathContextPtr *);
+
+/* Sauvegarde une structure XML dans un fichier. */
+bool save_xml_file(xmlDocPtr, const char *);
+
+/* Ferme une structure XML. */
+void close_xml_file(xmlDocPtr, xmlXPathContextPtr);
+
+
+
+/* --------------------- OPERATIONS DE LECTURE D'UN FICHIER XML --------------------- */
+
+
+#define XPATH_OBJ_NODES_COUNT(obj) (obj != NULL ? obj->nodesetval->nodeNr : 0)
+#define NODE_FROM_PATH_OBJ(obj, i) obj->nodesetval->nodeTab[i]
+
+
+/* Ouvre un fichier XML de façon encadrée. */
+gboolean open_xml_file(const char *filename, xmlDoc **, xmlXPathContextPtr *);
+
+/* Obtient de façon encadrée l'accès à un noeud défini. */
+xmlXPathObjectPtr get_node_xpath_object(xmlXPathContextPtr, const char *);
+
+/* Obtient une valeur placée entre <...> et </...>. */
+char *qck_get_node_text_value(xmlNodePtr);
+
+/* Obtient une valeur placée entre <...> et </...>. */
+char *get_node_text_value(xmlXPathContextPtr, const char *);
+
+/* Obtient la valeur d'une propriété d'un élément. */
+char *qck_get_node_prop_value(xmlNodePtr, const char *);
+
+/* Obtient la valeur d'une propriété d'un élément. */
+char *get_node_prop_value(xmlXPathContextPtr, const char *, const char *);
+
+/* Construit un chemin d'accès complet selon le fichier XML. */
+char *qck_build_filename_with_doc_url(xmlNodePtr);
+
+/* Construit un chemin d'accès complet selon le fichier XML. */
+char *build_filename_with_doc_url(xmlXPathContextPtr xpathCtx, const char *path);
+
+
+
+/* --------------------- OPERATIONS D'ECRITURE D'UN FICHIER XML --------------------- */
+
+
+/* Amorce l'écriture d'un nouveau fichier XML. */
+xmlTextWriterPtr start_writing_xml_file(const char *);
+
+/* Met fin à l'écriture d'un nouveau fichier XML. */
+bool end_writing_xml_file(xmlTextWriterPtr);
+
+/* Ecrit une balise et ne la referme pas. */
+bool open_xml_element(xmlTextWriterPtr, const char *);
+
+/* Ferme la dernière balise laissée ouverte. */
+bool close_xml_element(xmlTextWriterPtr);
+
+/* Ecrit une balise avec un contenu textuel. */
+bool write_xml_element_with_content(xmlTextWriterPtr, const char *, const char *, ...);
+
+/* Ecrit un attribut avec un contenu textuel. */
+bool write_xml_attribute(xmlTextWriterPtr, const char *, const char *, ...);
+
+/* Ecrit un contenu textuel. */
+bool write_xml_content(xmlTextWriterPtr, const char *, ...);
+
+
+
+/* --------------------- OPERATIONS D'ECRITURE D'UN FICHIER XML --------------------- */
+
+
+/* Fournit le premier noeud correspondant à un chemin XPath. */
+xmlNodePtr get_node_from_xpath(xmlXPathContextPtr, const char *);
+
+/* S'assure qu'un noeud donné est bien présent dans le document. */
+xmlNodePtr ensure_node_exist(xmlDocPtr, xmlXPathContextPtr, const char *);
+
+/* S'assure qu'un noeud donné est bien présent dans le document. */
+bool add_content_to_node(xmlDocPtr, xmlXPathContextPtr, const char *, const char *);
+
+
+
+#endif /* _XML_H */