From 7a7e09d564017f7f514f843996f9a0fb5fad5fd2 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 16 May 2008 12:35:02 +0000 Subject: Implement g_key_file_get_string_list --- eglib/gmain.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/eglib/gmain.c b/eglib/gmain.c index 27f168d5..3259a43e 100644 --- a/eglib/gmain.c +++ b/eglib/gmain.c @@ -1739,7 +1739,31 @@ gchar **g_key_file_get_string_list(GKeyFile *key_file, const gchar *group_name, const gchar *key, gsize *length, GError **error) { - return g_new0(gchar *, 1); + gchar *str, *item, **list; + int items = 0; + + str = g_key_file_get_string(key_file, group_name, key, error); + if (!str) + return NULL; + + items = 0; + list = g_new0(char *, 1); + + item = strtok(str, ","); + while (item) { + items++; + + list = g_renew(char *, list, items + 1); + + list[items - 1] = g_strdup(item); + list[items] = NULL; + + item = strtok(NULL, ","); + } + + g_free(str); + + return list; } /* GString */ -- cgit