aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-02-26 01:04:32 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-02-26 01:04:32 +0100
commit3b0f9293a3432023cdca91df01418347d9781ffa (patch)
treee872df7080979732ddf3efbdaabc8a4bdafd0653 /src/main.c
parentbdff66b0013165c3ef7eff644fb276235f3dd082 (diff)
downloadblogc-3b0f9293a3432023cdca91df01418347d9781ffa.tar.gz
blogc-3b0f9293a3432023cdca91df01418347d9781ffa.tar.bz2
blogc-3b0f9293a3432023cdca91df01418347d9781ffa.zip
build: replace src/utils with squareball
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/main.c b/src/main.c
index f3f990b..143c836 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,7 +24,7 @@
#include <stdio.h>
#include <string.h>
-#include "utils/utils.h"
+#include <squareball.h>
#include "source-parser.h"
#include "template-parser.h"
#include "loader.h"
@@ -71,7 +71,7 @@ blogc_print_usage(void)
static void
blogc_mkdir_recursive(const char *filename)
{
- char *fname = b_strdup(filename);
+ char *fname = sb_strdup(filename);
for (char *tmp = fname; *tmp != '\0'; tmp++) {
if (*tmp != '/' && *tmp != '\\')
continue;
@@ -117,9 +117,9 @@ main(int argc, char **argv)
char *tmp = NULL;
char **pieces = NULL;
- b_slist_t *sources = NULL;
- b_trie_t *config = b_trie_new(free);
- b_trie_insert(config, "BLOGC_VERSION", b_strdup(PACKAGE_VERSION));
+ sb_slist_t *sources = NULL;
+ sb_trie_t *config = sb_trie_new(free);
+ sb_trie_insert(config, "BLOGC_VERSION", sb_strdup(PACKAGE_VERSION));
for (unsigned int i = 1; i < argc; i++) {
tmp = NULL;
@@ -136,21 +136,21 @@ main(int argc, char **argv)
break;
case 't':
if (argv[i][2] != '\0')
- template = b_strdup(argv[i] + 2);
+ template = sb_strdup(argv[i] + 2);
else if (i + 1 < argc)
- template = b_strdup(argv[++i]);
+ template = sb_strdup(argv[++i]);
break;
case 'o':
if (argv[i][2] != '\0')
- output = b_strdup(argv[i] + 2);
+ output = sb_strdup(argv[i] + 2);
else if (i + 1 < argc)
- output = b_strdup(argv[++i]);
+ output = sb_strdup(argv[++i]);
break;
case 'p':
if (argv[i][2] != '\0')
- print = b_strdup(argv[i] + 2);
+ print = sb_strdup(argv[i] + 2);
else if (i + 1 < argc)
- print = b_strdup(argv[++i]);
+ print = sb_strdup(argv[++i]);
break;
case 'D':
if (argv[i][2] != '\0')
@@ -158,11 +158,11 @@ main(int argc, char **argv)
else if (i + 1 < argc)
tmp = argv[++i];
if (tmp != NULL) {
- pieces = b_str_split(tmp, '=', 2);
- if (b_strv_length(pieces) != 2) {
+ pieces = sb_str_split(tmp, '=', 2);
+ if (sb_strv_length(pieces) != 2) {
fprintf(stderr, "blogc: error: invalid value for "
"-D (must have an '='): %s\n", tmp);
- b_strv_free(pieces);
+ sb_strv_free(pieces);
rv = 2;
goto cleanup;
}
@@ -173,13 +173,13 @@ main(int argc, char **argv)
fprintf(stderr, "blogc: error: invalid value "
"for -D (configuration key must be uppercase "
"with '_'): %s\n", pieces[0]);
- b_strv_free(pieces);
+ sb_strv_free(pieces);
rv = 2;
goto cleanup;
}
}
- b_trie_insert(config, pieces[0], b_strdup(pieces[1]));
- b_strv_free(pieces);
+ sb_trie_insert(config, pieces[0], sb_strdup(pieces[1]));
+ sb_strv_free(pieces);
pieces = NULL;
}
break;
@@ -192,17 +192,17 @@ main(int argc, char **argv)
}
}
else
- sources = b_slist_append(sources, b_strdup(argv[i]));
+ sources = sb_slist_append(sources, sb_strdup(argv[i]));
}
- if (!listing && b_slist_length(sources) == 0) {
+ if (!listing && sb_slist_length(sources) == 0) {
blogc_print_usage();
fprintf(stderr, "blogc: error: one source file is required\n");
rv = 2;
goto cleanup;
}
- if (!listing && b_slist_length(sources) > 1) {
+ if (!listing && sb_slist_length(sources) > 1) {
blogc_print_usage();
fprintf(stderr, "blogc: error: only one source file should be provided, "
"if running without '-l'\n");
@@ -212,14 +212,14 @@ main(int argc, char **argv)
blogc_error_t *err = NULL;
- b_slist_t *s = blogc_source_parse_from_files(config, sources, &err);
+ sb_slist_t *s = blogc_source_parse_from_files(config, sources, &err);
if (err != NULL) {
blogc_error_print(err);
rv = 2;
goto cleanup2;
}
- b_slist_t* l = blogc_template_parse_from_file(template, &err);
+ sb_slist_t* l = blogc_template_parse_from_file(template, &err);
if (err != NULL) {
blogc_error_print(err);
rv = 2;
@@ -227,7 +227,7 @@ main(int argc, char **argv)
}
if (print != NULL) {
- const char *val = b_trie_lookup(config, print);
+ const char *val = sb_trie_lookup(config, print);
if (val == NULL) {
fprintf(stderr, "blogc: error: configuration variable not found: %s\n",
print);
@@ -273,13 +273,13 @@ cleanup4:
cleanup3:
blogc_template_free_stmts(l);
cleanup2:
- b_slist_free_full(s, (b_free_func_t) b_trie_free);
+ sb_slist_free_full(s, (sb_free_func_t) sb_trie_free);
blogc_error_free(err);
cleanup:
- b_trie_free(config);
+ sb_trie_free(config);
free(template);
free(output);
free(print);
- b_slist_free_full(sources, free);
+ sb_slist_free_full(sources, free);
return rv;
}