common: implement conversion from b_status to ivy_status
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <ivy/misc.h>
|
#include <ivy/misc.h>
|
||||||
|
|
||||||
|
enum b_status;
|
||||||
|
|
||||||
enum ivy_status {
|
enum ivy_status {
|
||||||
IVY_OK = 0,
|
IVY_OK = 0,
|
||||||
IVY_ERR_EOF = -1,
|
IVY_ERR_EOF = -1,
|
||||||
@@ -13,8 +15,11 @@ enum ivy_status {
|
|||||||
IVY_ERR_INTERNAL_FAILURE = -6,
|
IVY_ERR_INTERNAL_FAILURE = -6,
|
||||||
IVY_ERR_BAD_STATE = -7,
|
IVY_ERR_BAD_STATE = -7,
|
||||||
IVY_ERR_INVALID_VALUE = -8,
|
IVY_ERR_INVALID_VALUE = -8,
|
||||||
|
IVY_ERR_NO_ENTRY = -9,
|
||||||
|
IVY_ERR_NAME_EXISTS = -10,
|
||||||
};
|
};
|
||||||
|
|
||||||
IVY_API const char *ivy_status_to_string(enum ivy_status status);
|
IVY_API const char *ivy_status_to_string(enum ivy_status status);
|
||||||
|
IVY_API enum ivy_status ivy_status_from_b_status(enum b_status status);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include <blue/core/status.h>
|
||||||
#include <ivy/status.h>
|
#include <ivy/status.h>
|
||||||
|
|
||||||
#define ENUM_STR(x) \
|
#define ENUM_STR(x) \
|
||||||
@@ -18,3 +19,18 @@ const char *ivy_status_to_string(enum ivy_status status)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ENUM_CONVERT(from, to) \
|
||||||
|
case (from): \
|
||||||
|
return (to)
|
||||||
|
|
||||||
|
enum ivy_status ivy_status_from_b_status(enum b_status status)
|
||||||
|
{
|
||||||
|
switch (status) {
|
||||||
|
ENUM_CONVERT(B_SUCCESS, IVY_OK);
|
||||||
|
ENUM_CONVERT(B_ERR_NAME_EXISTS, IVY_ERR_NAME_EXISTS);
|
||||||
|
ENUM_CONVERT(B_ERR_NO_MEMORY, IVY_ERR_NO_MEMORY);
|
||||||
|
default:
|
||||||
|
return IVY_ERR_INTERNAL_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user