From d81e3ef854ce1448a5233da34da803c005db1fce Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Sat, 4 Oct 2008 13:03:26 +0000 Subject: [PATCH] Implement error handling in the personlization library --- ykpers.c | 24 +++++++++++++++++++++++- ykpers.h | 5 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ykpers.c b/ykpers.c index de0c58d..095cfae 100644 --- a/ykpers.c +++ b/ykpers.c @@ -271,5 +271,27 @@ int ykp_read_config(CONFIG *cfg, void *userdata), void *userdata) { - return -1; + ykp_errno = YKP_ENOTYETIMPL; + return 0; +} + +/* As soon as we find a way to safely detect if we're in a threaded environment + or not, this should be changed to support per-thread locations. Until then, + we only support non-threaded applications. */ +static int _ykp_errno = 0; + +int * const _ykp_errno_location(void) +{ + return &_ykp_errno; +} + +static const char *errtext[] = { + "", + "not yet implemented" +}; +const char *ykp_strerror(int errnum) +{ + if (errnum < sizeof(errtext)/sizeof(errtext[0])) + return errtext[errnum]; + return NULL; } diff --git a/ykpers.h b/ykpers.h index 3438f29..6f90571 100644 --- a/ykpers.h +++ b/ykpers.h @@ -49,5 +49,10 @@ int ykp_read_config(CONFIG *cfg, void *userdata), void *userdata); +extern int * const _ykp_errno_location(void); +#define ykp_errno (*_ykp_errno_location()) +const char *ykp_strerror(int errnum); + +#define YKP_ENOTYETIMPL 0x01 #endif // __YKPERS_H_INCLUDED__ -- 2.39.5