diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-07-25 19:46:14 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-07-25 19:46:14 +0200 |
commit | 803eb202e9d2d96fbb0de6f0514db2f0ab959d11 (patch) | |
tree | fc7572bf8f67ae36e302f766f15be179fa0515f2 /src | |
parent | 776e8daf9454307ea344b089a57da973d163bfd7 (diff) | |
download | blogc-803eb202e9d2d96fbb0de6f0514db2f0ab959d11.tar.gz blogc-803eb202e9d2d96fbb0de6f0514db2f0ab959d11.tar.bz2 blogc-803eb202e9d2d96fbb0de6f0514db2f0ab959d11.zip |
loader: added FILTER_REVERSE
Diffstat (limited to 'src')
-rw-r--r-- | src/blogc/loader.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/blogc/loader.c b/src/blogc/loader.c index a9a660e..881661b 100644 --- a/src/blogc/loader.c +++ b/src/blogc/loader.c @@ -103,6 +103,17 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err) if (err == NULL || *err != NULL) return NULL; + bool reverse = bc_trie_lookup(conf, "FILTER_REVERSE"); + bc_slist_t* sources = NULL; + for (bc_slist_t *tmp = l; tmp != NULL; tmp = tmp->next) { + if (reverse) { + sources = bc_slist_prepend(sources, tmp->data); + } + else { + sources = bc_slist_append(sources, tmp->data); + } + } + bc_error_t *tmp_err = NULL; bc_slist_t *rv = NULL; unsigned int with_date = 0; @@ -135,7 +146,7 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err) unsigned int end = start + per_page; unsigned int counter = 0; - for (bc_slist_t *tmp = l; tmp != NULL; tmp = tmp->next) { + for (bc_slist_t *tmp = sources; tmp != NULL; tmp = tmp->next) { char *f = tmp->data; bc_trie_t *s = blogc_source_parse_from_file(f, &tmp_err); if (s == NULL) { @@ -182,6 +193,8 @@ blogc_source_parse_from_files(bc_trie_t *conf, bc_slist_t *l, bc_error_t **err) rv = bc_slist_append(rv, s); } + bc_slist_free(sources); + if (with_date > 0 && with_date < bc_slist_length(rv)) { *err = bc_error_new_printf(BLOGC_ERROR_LOADER, "'DATE' variable provided for at least one source file, but not " |