From 1c8174674d522a2c55b4f143f7e0dac848e34281 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 9 Sep 2016 03:33:14 +0200 Subject: blogc: common: moved "file" to common --- Makefile.am | 7 +- src/blogc/file.c | 70 -------------- src/blogc/file.h | 19 ---- src/blogc/loader.c | 6 +- src/common/error.c | 6 +- src/common/error.h | 2 +- src/common/file.c | 67 ++++++++++++++ src/common/file.h | 19 ++++ tests/blogc/check_loader.c | 222 ++++++++++++++++++++++----------------------- 9 files changed, 207 insertions(+), 211 deletions(-) delete mode 100644 src/blogc/file.c delete mode 100644 src/blogc/file.h create mode 100644 src/common/file.c create mode 100644 src/common/file.h diff --git a/Makefile.am b/Makefile.am index d025b16..6cf2f6c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,13 +35,13 @@ noinst_HEADERS = \ src/blogc/content-parser.h \ src/blogc/datetime-parser.h \ src/blogc/debug.h \ - src/blogc/file.h \ src/blogc/loader.h \ src/blogc/renderer.h \ src/blogc/source-parser.h \ src/blogc/template-parser.h \ src/common/config-parser.h \ src/common/error.h \ + src/common/file.h \ src/common/utf8.h \ src/common/utils.h \ $(NULL) @@ -77,7 +77,6 @@ check_PROGRAMS = \ libblogc_la_SOURCES = \ src/blogc/content-parser.c \ src/blogc/datetime-parser.c \ - src/blogc/file.c \ src/blogc/loader.c \ src/blogc/renderer.c \ src/blogc/source-parser.c \ @@ -96,6 +95,7 @@ libblogc_la_LIBADD = \ libblogc_common_la_SOURCES = \ src/common/config-parser.c \ src/common/error.c \ + src/common/file.c \ src/common/utf8.c \ src/common/utils.c \ $(NULL) @@ -291,8 +291,7 @@ tests_blogc_check_loader_CFLAGS = \ tests_blogc_check_loader_LDFLAGS = \ -no-install \ - -Wl,--wrap=blogc_file_get_contents \ - -Wl,--wrap=blogc_fprintf \ + -Wl,--wrap=bc_file_get_contents \ $(NULL) tests_blogc_check_loader_LDADD = \ diff --git a/src/blogc/file.c b/src/blogc/file.c deleted file mode 100644 index 518c665..0000000 --- a/src/blogc/file.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * blogc: A blog compiler. - * Copyright (C) 2015-2016 Rafael G. Martins - * - * This program can be distributed under the terms of the BSD License. - * See the file LICENSE. - */ - -#include -#include -#include -#include -#include -#include -#include "file.h" -#include "../common/error.h" -#include "../common/utf8.h" -#include "../common/utils.h" - -// this would belong to loader.c, but we need it in a separated file to be -// able to mock it when unit testing the loader functions. - - -char* -blogc_file_get_contents(const char *path, size_t *len, bc_error_t **err) -{ - if (path == NULL || err == NULL || *err != NULL) - return NULL; - - *len = 0; - FILE *fp = fopen(path, "r"); - - if (fp == NULL) { - int tmp_errno = errno; - *err = bc_error_new_printf(BLOGC_ERROR_FILE, - "Failed to open file (%s): %s", path, strerror(tmp_errno)); - return NULL; - } - - bc_string_t *str = bc_string_new(); - char buffer[BLOGC_FILE_CHUNK_SIZE]; - char *tmp; - - while (!feof(fp)) { - size_t read_len = fread(buffer, sizeof(char), BLOGC_FILE_CHUNK_SIZE, fp); - - tmp = buffer; - - if (str->len == 0 && read_len > 0) { - // skipping BOM before validation, for performance. should be safe - // enough - size_t skip = bc_utf8_skip_bom((uint8_t*) buffer, read_len); - read_len -= skip; - tmp += skip; - } - - *len += read_len; - bc_string_append_len(str, tmp, read_len); - } - fclose(fp); - - if (!bc_utf8_validate_str(str)) { - *err = bc_error_new_printf(BLOGC_ERROR_FILE, - "File content is not valid UTF-8: %s", path); - bc_string_free(str, true); - return NULL; - } - - return bc_string_free(str, false); -} diff --git a/src/blogc/file.h b/src/blogc/file.h deleted file mode 100644 index 6a0e094..0000000 --- a/src/blogc/file.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * blogc: A blog compiler. - * Copyright (C) 2015-2016 Rafael G. Martins - * - * This program can be distributed under the terms of the BSD License. - * See the file LICENSE. - */ - -#ifndef _FILE_H -#define _FILE_H - -#include -#include "../common/error.h" - -#define BLOGC_FILE_CHUNK_SIZE 1024 - -char* blogc_file_get_contents(const char *path, size_t *len, bc_error_t **err); - -#endif /* _FILE_H */ diff --git a/src/blogc/loader.c b/src/blogc/loader.c index 754723b..b182e0b 100644 --- a/src/blogc/loader.c +++ b/src/blogc/loader.c @@ -12,11 +12,11 @@ #include #include #include -#include "file.h" #include "source-parser.h" #include "template-parser.h" #include "loader.h" #include "../common/error.h" +#include "../common/file.h" #include "../common/utils.h" @@ -63,7 +63,7 @@ blogc_template_parse_from_file(const char *f, bc_error_t **err) if (err == NULL || *err != NULL) return NULL; size_t len; - char *s = blogc_file_get_contents(f, &len, err); + char *s = bc_file_get_contents(f, &len, err); if (s == NULL) return NULL; bc_slist_t *rv = blogc_template_parse(s, len, err); @@ -78,7 +78,7 @@ blogc_source_parse_from_file(const char *f, bc_error_t **err) if (err == NULL || *err != NULL) return NULL; size_t len; - char *s = blogc_file_get_contents(f, &len, err); + char *s = bc_file_get_contents(f, &len, err); if (s == NULL) return NULL; bc_trie_t *rv = blogc_source_parse(s, len, err); diff --git a/src/common/error.c b/src/common/error.c index 1ea6e0d..a6a5f24 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -112,6 +112,9 @@ bc_error_print(bc_error_t *err) case BC_ERROR_CONFIG_PARSER: fprintf(stderr, "error: config-parser: %s\n", err->msg); break; + case BC_ERROR_FILE: + fprintf(stderr, "error: file: %s\n", err->msg); + break; case BLOGC_ERROR_SOURCE_PARSER: fprintf(stderr, "error: source: %s\n", err->msg); break; @@ -121,9 +124,6 @@ bc_error_print(bc_error_t *err) case BLOGC_ERROR_LOADER: fprintf(stderr, "error: loader: %s\n", err->msg); break; - case BLOGC_ERROR_FILE: - fprintf(stderr, "error: file: %s\n", err->msg); - break; case BLOGC_WARNING_DATETIME_PARSER: fprintf(stderr, "warning: datetime: %s\n", err->msg); break; diff --git a/src/common/error.h b/src/common/error.h index 2569538..d65a3e7 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -16,12 +16,12 @@ typedef enum { // errors for src/common BC_ERROR_CONFIG_PARSER = 1, + BC_ERROR_FILE, // errors for src/blogc BLOGC_ERROR_SOURCE_PARSER = 100, BLOGC_ERROR_TEMPLATE_PARSER, BLOGC_ERROR_LOADER, - BLOGC_ERROR_FILE, BLOGC_WARNING_DATETIME_PARSER, } bc_error_type_t; diff --git a/src/common/file.c b/src/common/file.c new file mode 100644 index 0000000..70a5631 --- /dev/null +++ b/src/common/file.c @@ -0,0 +1,67 @@ +/* + * blogc: A blog compiler. + * Copyright (C) 2015-2016 Rafael G. Martins + * + * This program can be distributed under the terms of the BSD License. + * See the file LICENSE. + */ + +#include +#include +#include +#include +#include +#include +#include "file.h" +#include "error.h" +#include "utf8.h" +#include "utils.h" + + +char* +bc_file_get_contents(const char *path, size_t *len, bc_error_t **err) +{ + if (path == NULL || err == NULL || *err != NULL) + return NULL; + + *len = 0; + FILE *fp = fopen(path, "r"); + + if (fp == NULL) { + int tmp_errno = errno; + *err = bc_error_new_printf(BC_ERROR_FILE, + "Failed to open file (%s): %s", path, strerror(tmp_errno)); + return NULL; + } + + bc_string_t *str = bc_string_new(); + char buffer[BC_FILE_CHUNK_SIZE]; + char *tmp; + + while (!feof(fp)) { + size_t read_len = fread(buffer, sizeof(char), BC_FILE_CHUNK_SIZE, fp); + + tmp = buffer; + + if (str->len == 0 && read_len > 0) { + // skipping BOM before validation, for performance. should be safe + // enough + size_t skip = bc_utf8_skip_bom((uint8_t*) buffer, read_len); + read_len -= skip; + tmp += skip; + } + + *len += read_len; + bc_string_append_len(str, tmp, read_len); + } + fclose(fp); + + if (!bc_utf8_validate_str(str)) { + *err = bc_error_new_printf(BC_ERROR_FILE, + "File content is not valid UTF-8: %s", path); + bc_string_free(str, true); + return NULL; + } + + return bc_string_free(str, false); +} diff --git a/src/common/file.h b/src/common/file.h new file mode 100644 index 0000000..e095de7 --- /dev/null +++ b/src/common/file.h @@ -0,0 +1,19 @@ +/* + * blogc: A blog compiler. + * Copyright (C) 2015-2016 Rafael G. Martins + * + * This program can be distributed under the terms of the BSD License. + * See the file LICENSE. + */ + +#ifndef _FILE_H +#define _FILE_H + +#include +#include "error.h" + +#define BC_FILE_CHUNK_SIZE 1024 + +char* bc_file_get_contents(const char *path, size_t *len, bc_error_t **err); + +#endif /* _FILE_H */ diff --git a/tests/blogc/check_loader.c b/tests/blogc/check_loader.c index 5257e1d..52521e2 100644 --- a/tests/blogc/check_loader.c +++ b/tests/blogc/check_loader.c @@ -50,7 +50,7 @@ test_get_filename(void **state) char* -__wrap_blogc_file_get_contents(const char *path, size_t *len, bc_error_t **err) +__wrap_bc_file_get_contents(const char *path, size_t *len, bc_error_t **err) { assert_null(*err); const char *_path = mock_type(const char*); @@ -68,8 +68,8 @@ static void test_template_parse_from_file(void **state) { bc_error_t *err = NULL; - will_return(__wrap_blogc_file_get_contents, "bola"); - will_return(__wrap_blogc_file_get_contents, bc_strdup("{{ BOLA }}\n")); + will_return(__wrap_bc_file_get_contents, "bola"); + will_return(__wrap_bc_file_get_contents, bc_strdup("{{ BOLA }}\n")); bc_slist_t *l = blogc_template_parse_from_file("bola", &err); assert_null(err); assert_non_null(l); @@ -82,8 +82,8 @@ static void test_template_parse_from_file_null(void **state) { bc_error_t *err = NULL; - will_return(__wrap_blogc_file_get_contents, "bola"); - will_return(__wrap_blogc_file_get_contents, NULL); + will_return(__wrap_bc_file_get_contents, "bola"); + will_return(__wrap_bc_file_get_contents, NULL); bc_slist_t *l = blogc_template_parse_from_file("bola", &err); assert_null(err); assert_null(l); @@ -94,8 +94,8 @@ static void test_source_parse_from_file(void **state) { bc_error_t *err = NULL; - will_return(__wrap_blogc_file_get_contents, "bola.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "--------\n" "bola")); @@ -117,8 +117,8 @@ static void test_source_parse_from_file_null(void **state) { bc_error_t *err = NULL; - will_return(__wrap_blogc_file_get_contents, "bola.txt"); - will_return(__wrap_blogc_file_get_contents, NULL); + will_return(__wrap_bc_file_get_contents, "bola.txt"); + will_return(__wrap_bc_file_get_contents, NULL); bc_trie_t *t = blogc_source_parse_from_file("bola.txt", &err); assert_null(err); assert_null(t); @@ -128,20 +128,20 @@ test_source_parse_from_file_null(void **state) static void test_source_parse_from_files(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "DATE: 2001-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "--------\n" @@ -170,22 +170,22 @@ test_source_parse_from_files(void **state) static void test_source_parse_from_files_filter_by_tag(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "DATE: 2001-02-03 04:05:06\n" "TAGS: chunda\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "TAGS: bola, chunda\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "--------\n" @@ -216,44 +216,44 @@ test_source_parse_from_files_filter_by_tag(void **state) static void test_source_parse_from_files_filter_by_page(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "DATE: 2001-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola4.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola4.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7891\n" "DATE: 2004-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola5.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola5.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7892\n" "DATE: 2005-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola6.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola6.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7893\n" "DATE: 2006-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola7.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola7.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7894\n" "DATE: 2007-02-03 04:05:06\n" "--------\n" @@ -294,44 +294,44 @@ test_source_parse_from_files_filter_by_page(void **state) static void test_source_parse_from_files_filter_by_page2(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "DATE: 2001-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola4.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola4.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7891\n" "DATE: 2004-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola5.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola5.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7892\n" "DATE: 2005-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola6.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola6.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7893\n" "DATE: 2006-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola7.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola7.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7894\n" "DATE: 2007-02-03 04:05:06\n" "--------\n" @@ -373,44 +373,44 @@ test_source_parse_from_files_filter_by_page2(void **state) static void test_source_parse_from_files_filter_by_page3(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "DATE: 2001-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola4.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola4.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7891\n" "DATE: 2004-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola5.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola5.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7892\n" "DATE: 2005-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola6.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola6.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7893\n" "DATE: 2006-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola7.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola7.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7894\n" "DATE: 2007-02-03 04:05:06\n" "--------\n" @@ -451,48 +451,48 @@ test_source_parse_from_files_filter_by_page3(void **state) static void test_source_parse_from_files_filter_by_page_and_tag(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "DATE: 2001-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "TAGS: chunda\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "TAGS: chunda bola\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola4.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola4.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7891\n" "DATE: 2004-02-03 04:05:06\n" "TAGS: bola\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola5.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola5.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7892\n" "DATE: 2005-02-03 04:05:06\n" "TAGS: chunda\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola6.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola6.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7893\n" "DATE: 2006-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola7.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola7.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7894\n" "DATE: 2007-02-03 04:05:06\n" "TAGS: yay chunda\n" @@ -536,44 +536,44 @@ test_source_parse_from_files_filter_by_page_and_tag(void **state) static void test_source_parse_from_files_filter_by_page_invalid(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "DATE: 2001-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola4.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola4.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7891\n" "DATE: 2004-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola5.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola5.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7892\n" "DATE: 2005-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola6.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola6.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7893\n" "DATE: 2006-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola7.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola7.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7894\n" "DATE: 2007-02-03 04:05:06\n" "--------\n" @@ -614,44 +614,44 @@ test_source_parse_from_files_filter_by_page_invalid(void **state) static void test_source_parse_from_files_filter_by_page_invalid2(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "DATE: 2001-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola4.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola4.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7891\n" "DATE: 2004-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola5.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola5.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7892\n" "DATE: 2005-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola6.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola6.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7893\n" "DATE: 2006-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola7.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola7.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 7894\n" "DATE: 2007-02-03 04:05:06\n" "--------\n" @@ -679,19 +679,19 @@ test_source_parse_from_files_filter_by_page_invalid2(void **state) static void test_source_parse_from_files_without_all_dates(void **state) { - will_return(__wrap_blogc_file_get_contents, "bola1.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola1.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 123\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola2.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola2.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 456\n" "DATE: 2002-02-03 04:05:06\n" "--------\n" "bola")); - will_return(__wrap_blogc_file_get_contents, "bola3.txt"); - will_return(__wrap_blogc_file_get_contents, bc_strdup( + will_return(__wrap_bc_file_get_contents, "bola3.txt"); + will_return(__wrap_bc_file_get_contents, bc_strdup( "ASD: 789\n" "DATE: 2003-02-03 04:05:06\n" "--------\n" -- cgit v1.2.3-18-g5258