core: add status code strings and descriptions
This commit is contained in:
@@ -5,10 +5,55 @@
|
||||
case s: \
|
||||
return #s;
|
||||
|
||||
#define ENUM_STR2(c, s) \
|
||||
case c: \
|
||||
return s;
|
||||
|
||||
const char *b_status_to_string(b_status status)
|
||||
{
|
||||
switch (status) {
|
||||
ENUM_STR(B_SUCCESS);
|
||||
ENUM_STR(B_ERR_NO_MEMORY);
|
||||
ENUM_STR(B_ERR_OUT_OF_BOUNDS);
|
||||
ENUM_STR(B_ERR_INVALID_ARGUMENT);
|
||||
ENUM_STR(B_ERR_NAME_EXISTS);
|
||||
ENUM_STR(B_ERR_NOT_SUPPORTED);
|
||||
ENUM_STR(B_ERR_BAD_STATE);
|
||||
ENUM_STR(B_ERR_NO_ENTRY);
|
||||
ENUM_STR(B_ERR_NO_DATA);
|
||||
ENUM_STR(B_ERR_NO_SPACE);
|
||||
ENUM_STR(B_ERR_UNKNOWN_FUNCTION);
|
||||
ENUM_STR(B_ERR_BAD_FORMAT);
|
||||
ENUM_STR(B_ERR_IO_FAILURE);
|
||||
ENUM_STR(B_ERR_IS_DIRECTORY);
|
||||
ENUM_STR(B_ERR_NOT_DIRECTORY);
|
||||
ENUM_STR(B_ERR_PERMISSION_DENIED);
|
||||
ENUM_STR(B_ERR_BUSY);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const char *b_status_description(b_status status)
|
||||
{
|
||||
switch (status) {
|
||||
ENUM_STR2(B_SUCCESS, "Success");
|
||||
ENUM_STR2(B_ERR_NO_MEMORY, "Out of memory");
|
||||
ENUM_STR2(B_ERR_OUT_OF_BOUNDS, "Argument out of bounds");
|
||||
ENUM_STR2(B_ERR_INVALID_ARGUMENT, "Invalid argument");
|
||||
ENUM_STR2(B_ERR_NAME_EXISTS, "Name already exists");
|
||||
ENUM_STR2(B_ERR_NOT_SUPPORTED, "Operation not supported");
|
||||
ENUM_STR2(B_ERR_BAD_STATE, "Bad state");
|
||||
ENUM_STR2(B_ERR_NO_ENTRY, "No entry");
|
||||
ENUM_STR2(B_ERR_NO_DATA, "No data available");
|
||||
ENUM_STR2(B_ERR_NO_SPACE, "No space available");
|
||||
ENUM_STR2(B_ERR_UNKNOWN_FUNCTION, "Unknown function");
|
||||
ENUM_STR2(B_ERR_BAD_FORMAT, "Bad format");
|
||||
ENUM_STR2(B_ERR_IO_FAILURE, "I/O failure");
|
||||
ENUM_STR2(B_ERR_IS_DIRECTORY, "Object is a directory");
|
||||
ENUM_STR2(B_ERR_NOT_DIRECTORY, "Object is not a directory");
|
||||
ENUM_STR2(B_ERR_PERMISSION_DENIED, "Permission denied");
|
||||
ENUM_STR2(B_ERR_BUSY, "Resource busy or locked");
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user