aboutsummaryrefslogtreecommitdiffstats
path: root/src/renderer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer.c')
-rw-r--r--src/renderer.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/renderer.c b/src/renderer.c
index 3061c43..52af8d9 100644
--- a/src/renderer.c
+++ b/src/renderer.c
@@ -13,7 +13,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
-#include "utils/utils.h"
+#include <squareball.h>
#include "datetime-parser.h"
#include "error.h"
#include "loader.h"
@@ -23,51 +23,51 @@
const char*
-blogc_get_variable(const char *name, b_trie_t *global, b_trie_t *local)
+blogc_get_variable(const char *name, sb_trie_t *global, sb_trie_t *local)
{
const char *rv = NULL;
if (local != NULL) {
- rv = b_trie_lookup(local, name);
+ rv = sb_trie_lookup(local, name);
if (rv != NULL)
return rv;
}
if (global != NULL)
- rv = b_trie_lookup(global, name);
+ rv = sb_trie_lookup(global, name);
return rv;
}
char*
-blogc_format_date(const char *date, b_trie_t *global, b_trie_t *local)
+blogc_format_date(const char *date, sb_trie_t *global, sb_trie_t *local)
{
const char *date_format = blogc_get_variable("DATE_FORMAT", global, local);
if (date == NULL)
return NULL;
if (date_format == NULL)
- return b_strdup(date);
+ return sb_strdup(date);
blogc_error_t *err = NULL;
char *rv = blogc_convert_datetime(date, date_format, &err);
if (err != NULL) {
blogc_error_print(err);
blogc_error_free(err);
- return b_strdup(date);
+ return sb_strdup(date);
}
return rv;
}
char*
-blogc_format_variable(const char *name, b_trie_t *global, b_trie_t *local)
+blogc_format_variable(const char *name, sb_trie_t *global, sb_trie_t *local)
{
char *var = NULL;
bool must_format = false;
- if (b_str_ends_with(name, "_FORMATTED")) {
- var = b_strndup(name, strlen(name) - 10);
+ if (sb_str_ends_with(name, "_FORMATTED")) {
+ var = sb_strndup(name, strlen(name) - 10);
must_format = true;
}
if (var == NULL)
- var = b_strdup(name);
+ var = sb_strdup(name);
const char *value = blogc_get_variable(var, global, local);
free(var);
@@ -77,29 +77,29 @@ blogc_format_variable(const char *name, b_trie_t *global, b_trie_t *local)
char *rv = NULL;
if (must_format) {
- if (b_str_starts_with(name, "DATE_")) {
+ if (sb_str_starts_with(name, "DATE_")) {
rv = blogc_format_date(value, global, local);
}
}
if (rv == NULL)
- return b_strdup(value);
+ return sb_strdup(value);
return rv;
}
char*
-blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing)
+blogc_render(sb_slist_t *tmpl, sb_slist_t *sources, sb_trie_t *config, bool listing)
{
if (tmpl == NULL)
return NULL;
- b_slist_t *current_source = NULL;
- b_slist_t *listing_start = NULL;
+ sb_slist_t *current_source = NULL;
+ sb_slist_t *listing_start = NULL;
- b_string_t *str = b_string_new();
+ sb_string_t *str = sb_string_new();
- b_trie_t *tmp_source = NULL;
+ sb_trie_t *tmp_source = NULL;
char *config_value = NULL;
char *defined = NULL;
@@ -112,7 +112,7 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing
int cmp = 0;
- b_slist_t *tmp = tmpl;
+ sb_slist_t *tmp = tmpl;
while (tmp != NULL) {
blogc_template_stmt_t *stmt = tmp->data;
@@ -120,7 +120,7 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing
case BLOGC_TEMPLATE_CONTENT_STMT:
if (stmt->value != NULL)
- b_string_append(str, stmt->value);
+ sb_string_append(str, stmt->value);
break;
case BLOGC_TEMPLATE_BLOCK_STMT:
@@ -177,7 +177,7 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing
config_value = blogc_format_variable(stmt->value,
config, inside_block ? tmp_source : NULL);
if (config_value != NULL) {
- b_string_append(str, config_value);
+ sb_string_append(str, config_value);
free(config_value);
config_value = NULL;
break;
@@ -218,7 +218,7 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing
(stmt->value2[0] == '"') &&
(stmt->value2[strlen(stmt->value2) - 1] == '"'))
{
- defined2 = b_strndup(stmt->value2 + 1,
+ defined2 = sb_strndup(stmt->value2 + 1,
strlen(stmt->value2) - 2);
}
else {
@@ -285,5 +285,5 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources, b_trie_t *config, bool listing
tmp = tmp->next;
}
- return b_string_free(str, false);
+ return sb_string_free(str, false);
}