From 464df1d5e5ab1322e2dd0a7796939fff1aeefa9a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 17:49:25 +0200 Subject: Adding upstream version 1.47.0. Signed-off-by: Daniel Baumann --- lib/e2p/errcode.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 lib/e2p/errcode.c (limited to 'lib/e2p/errcode.c') diff --git a/lib/e2p/errcode.c b/lib/e2p/errcode.c new file mode 100644 index 0000000..1627c9d --- /dev/null +++ b/lib/e2p/errcode.c @@ -0,0 +1,48 @@ +/* + * errcode.c - convert an error code to a string + */ + +#include "config.h" +#include +#include +#include + +#include "e2p.h" + +static const char *err_string[] = { + "", + "UNKNOWN", /* 1 */ + "EIO", /* 2 */ + "ENOMEM", /* 3 */ + "EFSBADCRC", /* 4 */ + "EFSCORRUPTED", /* 5 */ + "ENOSPC", /* 6 */ + "ENOKEY", /* 7 */ + "EROFS", /* 8 */ + "EFBIG", /* 9 */ + "EEXIST", /* 10 */ + "ERANGE", /* 11 */ + "EOVERFLOW", /* 12 */ + "EBUSY", /* 13 */ + "ENOTDIR", /* 14 */ + "ENOTEMPTY", /* 15 */ + "ESHUTDOWN", /* 16 */ + "EFAULT", /* 17 */ +}; + +#define ARRAY_SIZE(array) \ + (sizeof(array) / sizeof(array[0])) + +/* Return the name of an encoding or NULL */ +const char *e2p_errcode2str(unsigned int err) +{ + static char buf[32]; + + if (err < ARRAY_SIZE(err_string)) + return err_string[err]; + + sprintf(buf, "UNKNOWN_ERRCODE_%u", err); + return buf; +} + + -- cgit v1.2.3