summaryrefslogtreecommitdiff
path: root/saedit/xml.c
diff options
context:
space:
mode:
Diffstat (limited to 'saedit/xml.c')
-rw-r--r--saedit/xml.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/saedit/xml.c b/saedit/xml.c
new file mode 100644
index 0000000..6120d5c
--- /dev/null
+++ b/saedit/xml.c
@@ -0,0 +1,46 @@
+/*=======================================*\
+| ____ ____ |
+| / \ /\ | |
+| \____ / \ |____ |
+| \ /____\ | |
+| \____/prite / \nimation |____ditor |
+| |
+| Copyleft Vasily_Makarov 2011 |
+| |
+\*=======================================*/
+
+#include <glib.h>
+#include <ibusxml.h>
+#include "common.h"
+#include "xml.h"
+
+gchar **xml_attr_new(gchar *name, gchar *value) {
+ gchar **attr = g_new0(gchar*, 2);
+ attr[0] = name;
+ attr[1] = value;
+ return attr;
+}
+
+gchar* xml_node_get_attr_value(XMLNode *node, gchar *attr_name) {
+ gchar **attr = node->attributes;
+ int i;
+ for (i = 0; i < g_strv_length(attr); i += 2)
+ if (g_str_equal(attr[i], attr_name))
+ return attr[i + 1];
+ return NULL;
+}
+
+
+gint xml_node_compare_with_name_func(gconstpointer a, gconstpointer b) {
+ return g_strcmp0((gchar *)b, ((XMLNode *)a)->name);
+}
+
+gint xml_node_compare_with_action_node_by_imageset_name_func(gconstpointer a, gconstpointer b) {
+ return g_strcmp0("action", ((XMLNode *)a)->name) ||
+ g_strcmp0((gchar *)b, xml_node_get_attr_value((XMLNode *)a, "imageset"));
+}
+
+gint xml_node_compare_with_attr_func(const XMLNode *node, const gchar **attr) {
+ return g_strcmp0(attr[1],
+ xml_node_get_attr_value(node, attr[0]));
+}