summaryrefslogtreecommitdiff
path: root/src/lib-config/get.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-04-26 08:10:09 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-04-26 08:10:09 +0000
commitd29ca0b107a5b6abb4eadd036f37acd33bb72ed0 (patch)
treebcf53c98b5166a33753fc70444c24118ae8da9d1 /src/lib-config/get.c
parentc95034c6de1bf72536595e1e3431d8ec64b9880e (diff)
downloadirssi-d29ca0b107a5b6abb4eadd036f37acd33bb72ed0.zip
rest of the ~rewrite?
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@172 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/lib-config/get.c')
-rw-r--r--src/lib-config/get.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/lib-config/get.c b/src/lib-config/get.c
index b5c3f42e..8ac3e667 100644
--- a/src/lib-config/get.c
+++ b/src/lib-config/get.c
@@ -40,11 +40,10 @@ CONFIG_NODE *config_node_find(CONFIG_NODE *node, const char *key)
/* find the section from node - if not found create it unless new_type is -1.
you can also specify in new_type if it's NODE_TYPE_LIST or NODE_TYPE_BLOCK */
-CONFIG_NODE *config_node_section(CONFIG_REC *rec, CONFIG_NODE *parent, const char *key, int new_type)
+CONFIG_NODE *config_node_section(CONFIG_NODE *parent, const char *key, int new_type)
{
CONFIG_NODE *node;
- g_return_val_if_fail(rec != NULL, NULL);
g_return_val_if_fail(parent != NULL, NULL);
g_return_val_if_fail(is_node_list(parent), NULL);
@@ -91,7 +90,7 @@ CONFIG_NODE *config_node_traverse(CONFIG_REC *rec, const char *section, int crea
is_list = **tmp == '(';
if (create) new_type = is_list ? NODE_TYPE_LIST : NODE_TYPE_BLOCK;
- node = config_node_section(rec, node, *tmp + is_list, new_type);
+ node = config_node_section(node, *tmp + is_list, new_type);
if (node == NULL) return NULL;
}
g_strfreev(list);
@@ -252,3 +251,34 @@ int config_node_get_keyvalue(CONFIG_NODE *node, const char *key, const char *val
return -1;
}
+
+/* Return all values from from the list `node' in a g_strsplit() array */
+char **config_node_get_list(CONFIG_NODE *node)
+{
+ GString *values;
+ GSList *tmp;
+ char **ret;
+
+ g_return_val_if_fail(node != NULL, NULL);
+ g_return_val_if_fail(is_node_list(node), NULL);
+
+ /* put values to string */
+ values = g_string_new(NULL);
+ for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
+ node = tmp->data;
+
+ if (node->type == NODE_TYPE_VALUE)
+ g_string_sprintfa(values, "%s ", (char *) node->value);
+ }
+
+ /* split the values to **str array */
+ if (values->len == 0)
+ ret = NULL;
+ else {
+ g_string_truncate(values, values->len-1);
+ ret = g_strsplit(values->str, " ", -1);
+ }
+
+ g_string_free(values, TRUE);
+ return ret;
+}