aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-25 01:47:50 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-25 01:47:50 +0100
commit54d563e10f381ea01cf0ed93f2b97fcac848808c (patch)
treee9d1e7655576413d6cdaa4f519a720273006e5ee /src/common
parent6636bd99d6767a99546b1b82ce69ade6df867b42 (diff)
downloadblogc-54d563e10f381ea01cf0ed93f2b97fcac848808c.tar.gz
blogc-54d563e10f381ea01cf0ed93f2b97fcac848808c.tar.bz2
blogc-54d563e10f381ea01cf0ed93f2b97fcac848808c.zip
config-parser: bc_config_get_list should return array instead of list
Diffstat (limited to 'src/common')
-rw-r--r--src/common/config-parser.c15
-rw-r--r--src/common/config-parser.h2
2 files changed, 12 insertions, 5 deletions
diff --git a/src/common/config-parser.c b/src/common/config-parser.c
index 19ca192..8d6c10e 100644
--- a/src/common/config-parser.c
+++ b/src/common/config-parser.c
@@ -240,7 +240,7 @@ bc_config_list_sections(bc_config_t *config)
char **rv = bc_malloc(sizeof(char*) * (bc_slist_length(l) + 1));
- unsigned int i = 0;
+ size_t i = 0;
for (bc_slist_t *tmp = l; tmp != NULL; tmp = tmp->next, i++)
rv[i] = tmp->data;
rv[i] = NULL;
@@ -269,7 +269,7 @@ bc_config_list_keys(bc_config_t *config, const char *section)
char **rv = bc_malloc(sizeof(char*) * (bc_slist_length(l) + 1));
- unsigned int i = 0;
+ size_t i = 0;
for (bc_slist_t *tmp = l; tmp != NULL; tmp = tmp->next, i++)
rv[i] = tmp->data;
rv[i] = NULL;
@@ -308,7 +308,7 @@ bc_config_get_with_default(bc_config_t *config, const char *section, const char
}
-bc_slist_t*
+char**
bc_config_get_list(bc_config_t *config, const char *section)
{
if (config == NULL)
@@ -321,7 +321,14 @@ bc_config_get_list(bc_config_t *config, const char *section)
if (s->type != CONFIG_SECTION_TYPE_LIST)
return NULL;
- return s->data;
+ char **rv = bc_malloc(sizeof(char*) * (bc_slist_length(s->data) + 1));
+
+ size_t i = 0;
+ for (bc_slist_t *tmp = s->data; tmp != NULL; tmp = tmp->next, i++)
+ rv[i] = bc_strdup(tmp->data);
+ rv[i] = NULL;
+
+ return rv;
}
diff --git a/src/common/config-parser.h b/src/common/config-parser.h
index 0bf1706..01d66dc 100644
--- a/src/common/config-parser.h
+++ b/src/common/config-parser.h
@@ -25,7 +25,7 @@ const char* bc_config_get(bc_config_t *config, const char *section,
const char *key);
const char* bc_config_get_with_default(bc_config_t *config, const char *section,
const char *key, const char *default_);
-bc_slist_t* bc_config_get_list(bc_config_t *config, const char *section);
+char** bc_config_get_list(bc_config_t *config, const char *section);
void bc_config_free(bc_config_t *config);
#endif /* _CONFIG_PARSER_H */