rest of the ~rewrite?

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@172 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-04-26 08:10:09 +00:00 committed by cras
commit d29ca0b107
32 changed files with 2049 additions and 1536 deletions

View file

@ -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;
}