diff options
Diffstat (limited to 'src/status.c')
-rw-r--r-- | src/status.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/status.c b/src/status.c index b932ff4..2ca3fe8 100644 --- a/src/status.c +++ b/src/status.c @@ -3,6 +3,8 @@ #include "zix/common.h" +#include <errno.h> + const char* zix_strerror(const ZixStatus status) { @@ -26,3 +28,32 @@ zix_strerror(const ZixStatus status) } return "Unknown error"; } + +ZixStatus +zix_errno_status(const int e) +{ + switch (e) { + case 0: + return ZIX_STATUS_SUCCESS; +#ifdef EAGAIN + case EAGAIN: + return ZIX_STATUS_NO_MEM; +#endif +#ifdef EEXIST + case EEXIST: + return ZIX_STATUS_EXISTS; +#endif +#ifdef EINVAL + case EINVAL: + return ZIX_STATUS_BAD_ARG; +#endif +#ifdef EPERM + case EPERM: + return ZIX_STATUS_BAD_PERMS; +#endif + default: + break; + } + + return ZIX_STATUS_ERROR; +} |