blob: 6120d5c439baf211172c9e0d3d6d87d9f6209ab5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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]));
}
|