summaryrefslogtreecommitdiff
path: root/src/u8c/err.h.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/u8c/err.h.d')
-rw-r--r--src/u8c/err.h.d/geterr.c27
-rw-r--r--src/u8c/err.h.d/regerrhandl.c9
-rw-r--r--src/u8c/err.h.d/seterr.c17
3 files changed, 32 insertions, 21 deletions
diff --git a/src/u8c/err.h.d/geterr.c b/src/u8c/err.h.d/geterr.c
index 58f3612..5219348 100644
--- a/src/u8c/err.h.d/geterr.c
+++ b/src/u8c/err.h.d/geterr.c
@@ -18,14 +18,21 @@
# include <stdint.h>
# include <u8c/err.h>
# include <u8c/intern.h>
-# include <u8c/u32.h>
-bool u8c_geterr(size_t * const _sz,char32_t const * * const _out) {
- # if defined(u8c_bethrdsafe)
- mtx_lock(&u8c_dat.errlock);
- # endif
- u8c_u32cp(_sz,_out,u8c_dat.err);
- # if defined(u8c_bethrdsafe)
- mtx_unlock(&u8c_dat.errlock);
- # endif
- return false;
+# include <u8c/str.h>
+struct u8c_geterr_tuple u8c_geterr(void) {
+ struct u8c_geterr_tuple ret = {
+ .stat = false,
+ };
+ {
+# if defined(u8c_bethrdsafe)
+ mtx_lock(&u8c_dat.errlock);
+# endif
+ struct u8c_strcp_tuple const tuple = u8c_strcp(u8c_dat.err);
+# if defined(u8c_bethrdsafe)
+ mtx_unlock(&u8c_dat.errlock);
+# endif
+ ret.err = tuple.str;
+ ret.errsz = tuple.strsz;
}
+ return ret;
+}
diff --git a/src/u8c/err.h.d/regerrhandl.c b/src/u8c/err.h.d/regerrhandl.c
index 5e97177..5ac43a5 100644
--- a/src/u8c/err.h.d/regerrhandl.c
+++ b/src/u8c/err.h.d/regerrhandl.c
@@ -20,12 +20,15 @@
static void u8c_regerrhandl_seterrhandl(enum u8c_errtyp _typ,u8c_errhandltyp _errhandl) {
u8c_dat.errhandls[(size_t)_typ] = _errhandl;
}
-bool u8c_regerrhandl(enum u8c_errtyp _typ,u8c_errhandltyp _errhandl) {
+struct u8c_regerrhandl_tuple u8c_regerrhandl(enum u8c_errtyp _typ,u8c_errhandltyp _errhandl) {
+ struct u8c_regerrhandl_tuple ret = {
+ .stat = false,
+ };
# if defined(u8c_bethrdsafe)
mtx_lock(&u8c_dat.errhandlslock);
# endif
if(_typ == u8c_errtyp_all) {
- for(register int n = 0x0;n < (int)u8c_errtyp_maxerrtyp;n += 0x1) {
+ for(register int n = 0x0;n < (int)u8c_errtyp_all;n += 0x1) {
u8c_regerrhandl_seterrhandl((enum u8c_errtyp)n,_errhandl);
}
}
@@ -35,5 +38,5 @@ bool u8c_regerrhandl(enum u8c_errtyp _typ,u8c_errhandltyp _errhandl) {
# if defined(u8c_bethrdsafe)
mtx_unlock(&u8c_dat.errhandlslock);
# endif
- return false;
+ return ret;
}
diff --git a/src/u8c/err.h.d/seterr.c b/src/u8c/err.h.d/seterr.c
index 017e45e..89edf19 100644
--- a/src/u8c/err.h.d/seterr.c
+++ b/src/u8c/err.h.d/seterr.c
@@ -13,25 +13,26 @@
If not, see <https://www.gnu.org/licenses/>.
*/
-# include <assert.h>
# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <u8c/err.h>
# include <u8c/fmt.h>
# include <u8c/intern.h>
-# include <u8c/u32.h>
+# include <u8c/str.h>
# if defined(u8c_bethrdsafe)
# include <threads.h>
# endif
-bool u8c_seterr(char32_t const * const _msg,enum u8c_errtyp _typ) {
- assert(_msg != NULL);
- //u8c_dbgprint(_msg);
+struct u8c_seterr_tuple u8c_seterr(enum u8c_errtyp _typ,char32_t const * const restrict _msg) {
+ struct u8c_seterr_tuple ret = {
+ .stat = false,
+ };
+ /* u8c_dbgprint(_msg); */
# if defined(u8c_bethrdsafe)
mtx_lock(&u8c_dat.errlock);
# endif
- u8c_u32free(&u8c_dat.err);
- u8c_u32cp(NULL,&u8c_dat.err,_msg);
+ u8c_strfree(u8c_dat.err);
+ u8c_dat.err = u8c_strcp(_msg).str;
# if defined(u8c_bethrdsafe)
mtx_unlock(&u8c_dat.errlock);
# endif
@@ -44,5 +45,5 @@ bool u8c_seterr(char32_t const * const _msg,enum u8c_errtyp _typ) {
# if defined(u8c_bethrdsafe)
mtx_unlock(&u8c_dat.errhandlslock);
# endif
- return false;
+ return ret;
}