aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blogc-git-receiver/settings.c2
-rw-r--r--src/blogc-make/settings.c2
-rw-r--r--src/common/config-parser.c10
-rw-r--r--src/common/config-parser.h3
4 files changed, 13 insertions, 4 deletions
diff --git a/src/blogc-git-receiver/settings.c b/src/blogc-git-receiver/settings.c
index db29b18..e437a67 100644
--- a/src/blogc-git-receiver/settings.c
+++ b/src/blogc-git-receiver/settings.c
@@ -95,7 +95,7 @@ bgr_settings_parse(void)
return NULL;
}
- bc_config_t *config = bc_config_parse(config_content, len, NULL, &err);
+ bc_config_t *config = bc_config_parse(config_content, len, NULL, NULL, &err);
free(config_content);
if (err != NULL) {
fprintf(stderr, "warning: failed to parse configuration file (%s): %s\n",
diff --git a/src/blogc-make/settings.c b/src/blogc-make/settings.c
index be976e3..c8bbc63 100644
--- a/src/blogc-make/settings.c
+++ b/src/blogc-make/settings.c
@@ -86,7 +86,7 @@ bm_settings_parse(const char *content, size_t content_len, bc_error_t **err)
return NULL;
bc_config_t *config = bc_config_parse(content, content_len, list_sections,
- err);
+ NULL, err);
if (config == NULL || (err != NULL && *err != NULL))
return NULL;
diff --git a/src/common/config-parser.c b/src/common/config-parser.c
index bc4831b..f72b7fb 100644
--- a/src/common/config-parser.c
+++ b/src/common/config-parser.c
@@ -60,7 +60,7 @@ free_section(bc_configparser_section_t *section)
bc_config_t*
bc_config_parse(const char *src, size_t src_len, const char *list_sections[],
- bc_error_t **err)
+ const char *list_sections_prefix[], bc_error_t **err)
{
if (err == NULL || *err != NULL)
return NULL;
@@ -150,6 +150,14 @@ bc_config_parse(const char *src, size_t src_len, const char *list_sections[],
}
}
}
+ if (list_sections_prefix != NULL) {
+ for (size_t i = 0; list_sections_prefix[i] != NULL; i++) {
+ if (bc_str_starts_with(section_name, list_sections_prefix[i])) {
+ section->type = CONFIG_SECTION_TYPE_LIST;
+ break;
+ }
+ }
+ }
switch (section->type) {
case CONFIG_SECTION_TYPE_MAP:
section->data = bc_trie_new(free);
diff --git a/src/common/config-parser.h b/src/common/config-parser.h
index 0b75ff8..fa29437 100644
--- a/src/common/config-parser.h
+++ b/src/common/config-parser.h
@@ -18,7 +18,8 @@ typedef struct {
} bc_config_t;
bc_config_t* bc_config_parse(const char *src, size_t src_len,
- const char *list_sections[], bc_error_t **err);
+ const char *list_sections[], const char *list_sections_prefix[],
+ bc_error_t **err);
char** bc_config_list_sections(bc_config_t *config);
char** bc_config_list_keys(bc_config_t *config, const char *section);
const char* bc_config_get(bc_config_t *config, const char *section,