summaryrefslogtreecommitdiff
path: root/saedit/xml.c
diff options
context:
space:
mode:
authorVasily_Makarov <danilka.pro@gmail.com>2011-06-15 18:24:14 +0400
committerVasily_Makarov <danilka.pro@gmail.com>2011-06-15 18:24:14 +0400
commit6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5 (patch)
tree8a43922891e4f5eb7909d8d2b80f64235760e18d /saedit/xml.c
parent34dbe2ca8daae2595ee6ff37632a15e68fcc7fc2 (diff)
downloadevol-tools-6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5.tar.gz
evol-tools-6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5.tar.bz2
evol-tools-6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5.tar.xz
evol-tools-6c0a4a2bc3809ee49d55fdff7c55c25d3e6ad4a5.zip
saedit: Review code and add some features
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]));
+}