diff --git a/README.Rmd b/README.Rmd index 9a46df4..5cb076f 100644 --- a/README.Rmd +++ b/README.Rmd @@ -16,8 +16,8 @@ knitr::opts_chunk$set( [![CRAN status](https://www.r-pkg.org/badges/version/secretbase?color=17411d)](https://CRAN.R-project.org/package=secretbase) -[![R-multiverse status](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fcommunity.r-multiverse.org%2Fapi%2Fpackages%2Fsecretbase&query=%24.Version&label=r-multiverse)](https://community.r-multiverse.org/secretbase) -[![secretbase status badge](https://shikokuchuo.r-universe.dev/badges/secretbase?color=e67f53)](https://shikokuchuo.r-universe.dev/secretbase) +[![R-multiverse status](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fcommunity.r-multiverse.org%2Fapi%2Fpackages%2Fsecretbase&query=%24.Version&label=r-multiverse&color=17411d)](https://community.r-multiverse.org/secretbase) +[![secretbase status badge](https://shikokuchuo.r-universe.dev/badges/secretbase?color=ff803d)](https://shikokuchuo.r-universe.dev/secretbase) [![R-CMD-check](https://github.com/shikokuchuo/secretbase/workflows/R-CMD-check/badge.svg)](https://github.com/shikokuchuo/secretbase/actions) [![codecov](https://codecov.io/gh/shikokuchuo/secretbase/graph/badge.svg)](https://app.codecov.io/gh/shikokuchuo/secretbase) [![DOI](https://zenodo.org/badge/745691432.svg)](https://zenodo.org/doi/10.5281/zenodo.10553139) diff --git a/README.md b/README.md index 51e625d..ffea88b 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ [![CRAN status](https://www.r-pkg.org/badges/version/secretbase?color=17411d)](https://CRAN.R-project.org/package=secretbase) [![R-multiverse -status](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fcommunity.r-multiverse.org%2Fapi%2Fpackages%2Fsecretbase&query=%24.Version&label=r-multiverse)](https://community.r-multiverse.org/secretbase) +status](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fcommunity.r-multiverse.org%2Fapi%2Fpackages%2Fsecretbase&query=%24.Version&label=r-multiverse&color=17411d)](https://community.r-multiverse.org/secretbase) [![secretbase status -badge](https://shikokuchuo.r-universe.dev/badges/secretbase?color=e67f53)](https://shikokuchuo.r-universe.dev/secretbase) +badge](https://shikokuchuo.r-universe.dev/badges/secretbase?color=ff803d)](https://shikokuchuo.r-universe.dev/secretbase) [![R-CMD-check](https://github.com/shikokuchuo/secretbase/workflows/R-CMD-check/badge.svg)](https://github.com/shikokuchuo/secretbase/actions) [![codecov](https://codecov.io/gh/shikokuchuo/secretbase/graph/badge.svg)](https://app.codecov.io/gh/shikokuchuo/secretbase) [![DOI](https://zenodo.org/badge/745691432.svg)](https://zenodo.org/doi/10.5281/zenodo.10553139) diff --git a/src/secret.c b/src/secret.c index 853921f..1dbbe67 100644 --- a/src/secret.c +++ b/src/secret.c @@ -256,7 +256,7 @@ static void hash_file(mbedtls_sha3_context *ctx, const SEXP x) { size_t cur; if ((f = fopen(file, "rb")) == NULL) - Rf_error("file not found or no read permission at '%s'", file); + ERROR_FOPEN(file); setbuf(f, NULL); @@ -266,7 +266,7 @@ static void hash_file(mbedtls_sha3_context *ctx, const SEXP x) { if (ferror(f)) { fclose(f); - Rf_error("file read error at '%s'", file); + ERROR_FREAD(file); } fclose(f); diff --git a/src/secret.h b/src/secret.h index a508fbb..db254cb 100644 --- a/src/secret.h +++ b/src/secret.h @@ -118,6 +118,8 @@ typedef struct nano_buf_s { Rf_error("write buffer insufficient"); } #define ERROR_OUT(x) if (x->len) R_Free(x->buf); \ Rf_error("serialization exceeds max length of raw vector") +#define ERROR_FOPEN(x) Rf_error("file not found or no read permission at '%s'", x) +#define ERROR_FREAD(x) Rf_error("file read error at '%s'", x) void clear_buffer(void *, size_t); SEXP hash_to_sexp(unsigned char *, size_t, int); diff --git a/src/secret2.c b/src/secret2.c index 801e518..d06ec54 100644 --- a/src/secret2.c +++ b/src/secret2.c @@ -391,7 +391,7 @@ static void hash_file(mbedtls_sha256_context *ctx, const SEXP x) { size_t cur; if ((f = fopen(file, "rb")) == NULL) - Rf_error("file not found or no read permission at '%s'", file); + ERROR_FOPEN(file); setbuf(f, NULL); @@ -401,7 +401,7 @@ static void hash_file(mbedtls_sha256_context *ctx, const SEXP x) { if (ferror(f)) { fclose(f); - Rf_error("file read error at '%s'", file); + ERROR_FREAD(file); } fclose(f); diff --git a/src/secret3.c b/src/secret3.c index a25e69c..a8c3a80 100644 --- a/src/secret3.c +++ b/src/secret3.c @@ -198,7 +198,7 @@ static void hash_file(CSipHash *ctx, const SEXP x) { size_t cur; if ((f = fopen(file, "rb")) == NULL) - Rf_error("file not found or no read permission at '%s'", file); + ERROR_FOPEN(file); while ((cur = fread(buf, sizeof(char), SB_BUF_SIZE, f))) { c_siphash_append(ctx, buf, cur); @@ -206,7 +206,7 @@ static void hash_file(CSipHash *ctx, const SEXP x) { if (ferror(f)) { fclose(f); - Rf_error("file read error at '%s'", file); + ERROR_FREAD(file); } fclose(f);