From 3b0f9293a3432023cdca91df01418347d9781ffa Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 26 Feb 2016 01:04:32 +0100 Subject: build: replace src/utils with squareball --- src/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/file.c') diff --git a/src/file.c b/src/file.c index a4c763a..dec7c1b 100644 --- a/src/file.c +++ b/src/file.c @@ -14,7 +14,7 @@ #include #include #include -#include "utils/utils.h" +#include #include "file.h" #include "error.h" @@ -38,16 +38,16 @@ blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err) return NULL; } - b_string_t *str = b_string_new(); + sb_string_t *str = sb_string_new(); char buffer[BLOGC_FILE_CHUNK_SIZE]; while (!feof(fp)) { size_t read_len = fread(buffer, sizeof(char), BLOGC_FILE_CHUNK_SIZE, fp); *len += read_len; - b_string_append_len(str, buffer, read_len); + sb_string_append_len(str, buffer, read_len); } fclose(fp); - return b_string_free(str, false); + return sb_string_free(str, false); } -- cgit v1.2.3-18-g5258 From a2b3551dfb9460470bd79f5648bf597c517c40d4 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sun, 13 Mar 2016 01:48:49 +0100 Subject: *: use squareball error infrastructure --- src/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/file.c') diff --git a/src/file.c b/src/file.c index dec7c1b..972f433 100644 --- a/src/file.c +++ b/src/file.c @@ -23,7 +23,7 @@ char* -blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err) +blogc_file_get_contents(const char *path, size_t *len, sb_error_t **err) { if (path == NULL || err == NULL || *err != NULL) return NULL; @@ -33,7 +33,7 @@ blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err) if (fp == NULL) { int tmp_errno = errno; - *err = blogc_error_new_printf(BLOGC_ERROR_LOADER, + *err = sb_error_new_printf(BLOGC_ERROR_LOADER, "Failed to open file (%s): %s", path, strerror(tmp_errno)); return NULL; } -- cgit v1.2.3-18-g5258 From c7b4bc4d64a3ce669e54b7c7dae87527d9ee3123 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Sat, 19 Mar 2016 10:36:16 +0100 Subject: main: loader: use file utils from squareball --- src/file.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'src/file.c') diff --git a/src/file.c b/src/file.c index 972f433..a12fbc2 100644 --- a/src/file.c +++ b/src/file.c @@ -10,10 +10,8 @@ #include #endif /* HAVE_CONFIG_H */ -#include #include #include -#include #include #include "file.h" #include "error.h" @@ -25,29 +23,7 @@ char* blogc_file_get_contents(const char *path, size_t *len, sb_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 = sb_error_new_printf(BLOGC_ERROR_LOADER, - "Failed to open file (%s): %s", path, strerror(tmp_errno)); - return NULL; - } - - sb_string_t *str = sb_string_new(); - char buffer[BLOGC_FILE_CHUNK_SIZE]; - - while (!feof(fp)) { - size_t read_len = fread(buffer, sizeof(char), BLOGC_FILE_CHUNK_SIZE, fp); - *len += read_len; - sb_string_append_len(str, buffer, read_len); - } - fclose(fp); - return sb_string_free(str, false); + return sb_file_get_contents(path, len, err); } -- cgit v1.2.3-18-g5258 From 25c2e03228e00f577fac4a52079c601010df4f15 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 27 Apr 2016 01:30:12 +0200 Subject: Revert "main: loader: use file utils from squareball" This reverts commit c7b4bc4d64a3ce669e54b7c7dae87527d9ee3123. --- src/file.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/file.c') diff --git a/src/file.c b/src/file.c index a12fbc2..972f433 100644 --- a/src/file.c +++ b/src/file.c @@ -10,8 +10,10 @@ #include #endif /* HAVE_CONFIG_H */ +#include #include #include +#include #include #include "file.h" #include "error.h" @@ -23,7 +25,29 @@ char* blogc_file_get_contents(const char *path, size_t *len, sb_error_t **err) { - return sb_file_get_contents(path, len, 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 = sb_error_new_printf(BLOGC_ERROR_LOADER, + "Failed to open file (%s): %s", path, strerror(tmp_errno)); + return NULL; + } + + sb_string_t *str = sb_string_new(); + char buffer[BLOGC_FILE_CHUNK_SIZE]; + + while (!feof(fp)) { + size_t read_len = fread(buffer, sizeof(char), BLOGC_FILE_CHUNK_SIZE, fp); + *len += read_len; + sb_string_append_len(str, buffer, read_len); + } + fclose(fp); + return sb_string_free(str, false); } -- cgit v1.2.3-18-g5258 From 6153580a13e7e7c48e38fa446572c8adcae08084 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 27 Apr 2016 01:31:02 +0200 Subject: Revert "*: use squareball error infrastructure" This reverts commit a2b3551dfb9460470bd79f5648bf597c517c40d4. --- src/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/file.c') diff --git a/src/file.c b/src/file.c index 972f433..dec7c1b 100644 --- a/src/file.c +++ b/src/file.c @@ -23,7 +23,7 @@ char* -blogc_file_get_contents(const char *path, size_t *len, sb_error_t **err) +blogc_file_get_contents(const char *path, size_t *len, blogc_error_t **err) { if (path == NULL || err == NULL || *err != NULL) return NULL; @@ -33,7 +33,7 @@ blogc_file_get_contents(const char *path, size_t *len, sb_error_t **err) if (fp == NULL) { int tmp_errno = errno; - *err = sb_error_new_printf(BLOGC_ERROR_LOADER, + *err = blogc_error_new_printf(BLOGC_ERROR_LOADER, "Failed to open file (%s): %s", path, strerror(tmp_errno)); return NULL; } -- cgit v1.2.3-18-g5258 From 9699bf0ce6b34c0d05c509925f3367f2200caad5 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 27 Apr 2016 02:34:19 +0200 Subject: remove squareball for good --- src/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/file.c') diff --git a/src/file.c b/src/file.c index dec7c1b..f784d93 100644 --- a/src/file.c +++ b/src/file.c @@ -14,9 +14,9 @@ #include #include #include -#include #include "file.h" #include "error.h" +#include "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. -- cgit v1.2.3-18-g5258