Browse Source

dbs: Fix roxml plugin

Serj Kalichev 2 years ago
parent
commit
d0c2f1f1c1

+ 5 - 5
bin/klishd/klishd.c

@@ -227,11 +227,11 @@ err:
 	}
 
 	// Free scheme
-	{
-	kcontext_t *context = kcontext_new(KCONTEXT_PLUGIN_FINI);
-	kscheme_fini(scheme, context, error);
-	kcontext_free(context);
-	kscheme_free(scheme);
+	if (scheme) {
+		kcontext_t *context = kcontext_new(KCONTEXT_PLUGIN_FINI);
+		kscheme_fini(scheme, context, error);
+		kcontext_free(context);
+		kscheme_free(scheme);
 	}
 
 	// Free command line options

+ 2 - 1
dbs/expat/Makefile.am

@@ -6,4 +6,5 @@ kdb_expat_la_CFLAGS = $(AM_LDFLAGS) $(EXPAT_CFLAGS)
 kdb_expat_la_LIBADD = libklish-helper-xml.la
 
 kdb_expat_la_SOURCES += \
-	dbs/expat/expat_api.c
+	dbs/expat/expat_api.c \
+	dbs/expat/expat_plugin.c

+ 35 - 0
dbs/expat/expat_plugin.c

@@ -0,0 +1,35 @@
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <assert.h>
+
+#include <faux/faux.h>
+#include <faux/str.h>
+#include <faux/error.h>
+#include <klish/kxml.h>
+#include <klish/kscheme.h>
+#include <klish/kdb.h>
+
+
+uint8_t kdb_expat_major = KDB_MAJOR;
+uint8_t kdb_expat_minor = KDB_MINOR;
+
+
+bool_t kdb_expat_load_scheme(kdb_t *db, kscheme_t *scheme)
+{
+	faux_ini_t *ini = NULL;
+	faux_error_t *error = NULL;
+	const char *xml_path = NULL;
+
+	assert(db);
+	if (!db)
+		return BOOL_FALSE;
+
+	// Get configuration info from kdb object
+	ini = kdb_ini(db);
+	if (ini)
+		xml_path = faux_ini_find(ini, "XMLPath");
+	error = kdb_error(db);
+
+	return kxml_load_scheme(scheme, xml_path, error);
+}

+ 0 - 2
dbs/libxml2/libxml2_plugin.c

@@ -2,8 +2,6 @@
 #include <errno.h>
 #include <string.h>
 #include <assert.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
 
 #include <faux/faux.h>
 #include <faux/str.h>

+ 2 - 1
dbs/roxml/Makefile.am

@@ -6,4 +6,5 @@ kdb_roxml_la_CFLAGS = $(AM_LDFLAGS) $(ROXML_CFLAGS)
 kdb_roxml_la_LIBADD = libklish-helper-xml.la
 
 kdb_roxml_la_SOURCES += \
-	dbs/roxml/roxml_api.c
+	dbs/roxml/roxml_api.c \
+	dbs/roxml/roxml_plugin.c

+ 2 - 2
dbs/roxml/roxml_api.c

@@ -74,7 +74,7 @@ const char *kxml_doc_get_err_msg(kxml_doc_t *doc)
 }
 */
 
-kxml_nodetype_e kxml_node_get_type(const kxml_node_t *node)
+kxml_nodetype_e kxml_node_type(const kxml_node_t *node)
 {
 	int type = 0;
 
@@ -250,7 +250,7 @@ void kxml_node_content_free(char *str)
 }
 
 
-char *kxml_node_get_name(const kxml_node_t *node)
+char *kxml_node_name(const kxml_node_t *node)
 {
 	if (!node)
 		return NULL;

+ 35 - 0
dbs/roxml/roxml_plugin.c

@@ -0,0 +1,35 @@
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <assert.h>
+
+#include <faux/faux.h>
+#include <faux/str.h>
+#include <faux/error.h>
+#include <klish/kxml.h>
+#include <klish/kscheme.h>
+#include <klish/kdb.h>
+
+
+uint8_t kdb_roxml_major = KDB_MAJOR;
+uint8_t kdb_roxml_minor = KDB_MINOR;
+
+
+bool_t kdb_roxml_load_scheme(kdb_t *db, kscheme_t *scheme)
+{
+	faux_ini_t *ini = NULL;
+	faux_error_t *error = NULL;
+	const char *xml_path = NULL;
+
+	assert(db);
+	if (!db)
+		return BOOL_FALSE;
+
+	// Get configuration info from kdb object
+	ini = kdb_ini(db);
+	if (ini)
+		xml_path = faux_ini_find(ini, "XMLPath");
+	error = kdb_error(db);
+
+	return kxml_load_scheme(scheme, xml_path, error);
+}