diff --git a/bshell.runtime/include/bshell/status.h b/bshell.runtime/include/bshell/status.h index 82a49be..4a423d3 100644 --- a/bshell.runtime/include/bshell/status.h +++ b/bshell.runtime/include/bshell/status.h @@ -20,5 +20,6 @@ enum bshell_status { }; extern enum bshell_status bshell_status_from_errno(int err); +extern const char *bshell_status_get_description(int err); #endif diff --git a/bshell.runtime/status.c b/bshell.runtime/status.c index f489c8a..241e290 100644 --- a/bshell.runtime/status.c +++ b/bshell.runtime/status.c @@ -17,3 +17,41 @@ enum bshell_status bshell_status_from_errno(int err) return BSHELL_ERR_INTERNAL_FAILURE; } } + +const char *bshell_status_get_description(int err) +{ + switch (err) { + case BSHELL_SUCCESS: + return "Success"; + case BSHELL_ERR_EOF: + return "Unexpected end-of-file"; + case BSHELL_ERR_BAD_SYNTAX: + return "Bad syntax"; + case BSHELL_ERR_BAD_FORMAT: + return "Bad data format"; + case BSHELL_ERR_BAD_STATE: + return "Object is in bad state"; + case BSHELL_ERR_INVALID_VALUE: + return "Invalid value"; + case BSHELL_ERR_INVALID_ARGUMENT: + return "Invalid argument"; + case BSHELL_ERR_NO_MEMORY: + return "Out of memory"; + case BSHELL_ERR_NO_ENTRY: + return "No such file or directory"; + case BSHELL_ERR_NO_DATA: + return "No data available"; + case BSHELL_ERR_NAME_EXISTS: + return "File or object already exists"; + case BSHELL_ERR_NOT_SUPPORTED: + return "Operation not supported"; + case BSHELL_ERR_IO_FAILURE: + return "I/O failure"; + case BSHELL_ERR_ACCESS_DENIED: + return "Access denied"; + case BSHELL_ERR_INTERNAL_FAILURE: + return "Internal failure"; + default: + return "Unknown error"; + } +}