summaryrefslogtreecommitdiffstats
path: root/database/sqlite/sqlite.c
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2008-12-13 02:10:51 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2008-12-13 02:10:51 +0100
commit4942d5a229dca435488aa959d99638c774a0eea7 (patch)
tree810eef61686b13daacc7387c6c5e9b987d5537f9 /database/sqlite/sqlite.c
parent45c5e846e401ec9a4102eff0dbb5c22cf0742b52 (diff)
downloadeurephia-4942d5a229dca435488aa959d99638c774a0eea7.tar.gz
eurephia-4942d5a229dca435488aa959d99638c774a0eea7.tar.xz
eurephia-4942d5a229dca435488aa959d99638c774a0eea7.zip
Added sqlite functions for populating an XML document directly
Diffstat (limited to 'database/sqlite/sqlite.c')
-rw-r--r--database/sqlite/sqlite.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/database/sqlite/sqlite.c b/database/sqlite/sqlite.c
index f74b4d7..c0df997 100644
--- a/database/sqlite/sqlite.c
+++ b/database/sqlite/sqlite.c
@@ -25,6 +25,10 @@
#include <assert.h>
#include <sqlite3.h>
+#ifdef HAVE_LIBXML2
+# include <libxml/tree.h>
+#endif
+
#include <eurephia_log.h>
#include <eurephia_nullsafe.h>
#include <eurephia_directions.h>
@@ -469,6 +473,21 @@ char *sqlite_get_value(dbresult *res, int row, int col) {
return NULL;
}
+
+#ifdef HAVE_LIBXML2
+xmlNodePtr sqlite_xml_value(xmlNodePtr node, xmlFieldType xmltyp, char *name, dbresult *res, int row, int col) {
+ switch( xmltyp ) {
+ case XML_ATTR:
+ xmlNewProp(node, (xmlChar *)name, (xmlChar *) sqlite_get_value(res, row, col));
+ return node;
+
+ case XML_NODE:
+ return xmlNewChild(node, NULL, (xmlChar *) name, (xmlChar *)sqlite_get_value(res, row, col));
+ }
+ return NULL;
+}
+#endif
+
// Retrieve number of tuples in current dbresult structure
int sqlite_get_numtuples(dbresult *res) {
return (res != NULL ? res->num_tuples : 0);