diff options
author | David Robillard <d@drobilla.net> | 2022-06-28 19:01:40 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-06-28 19:04:05 -0400 |
commit | fcb82f18e7db39aeee726c41007845d9710a9cb8 (patch) | |
tree | 8c9d709d3f745dc4f65a22b1c86414fab66947d2 | |
parent | 71c4a3a6d66e96661fd341e1a089c4d8bd63fb13 (diff) | |
download | zix-fcb82f18e7db39aeee726c41007845d9710a9cb8.tar.gz zix-fcb82f18e7db39aeee726c41007845d9710a9cb8.tar.bz2 zix-fcb82f18e7db39aeee726c41007845d9710a9cb8.zip |
Move zix_strerror to library
-rw-r--r-- | include/zix/common.h | 29 | ||||
-rw-r--r-- | meson.build | 1 | ||||
-rw-r--r-- | src/status.c | 28 |
3 files changed, 35 insertions, 23 deletions
diff --git a/include/zix/common.h b/include/zix/common.h index eaac408..02b0f64 100644 --- a/include/zix/common.h +++ b/include/zix/common.h @@ -4,6 +4,8 @@ #ifndef ZIX_COMMON_H #define ZIX_COMMON_H +#include "zix/attributes.h" + #include <stdbool.h> /** @@ -26,29 +28,10 @@ typedef enum { ZIX_STATUS_REACHED_END } ZixStatus; -static inline const char* -zix_strerror(const ZixStatus status) -{ - switch (status) { - case ZIX_STATUS_SUCCESS: - return "Success"; - case ZIX_STATUS_ERROR: - return "Unknown error"; - case ZIX_STATUS_NO_MEM: - return "Out of memory"; - case ZIX_STATUS_NOT_FOUND: - return "Not found"; - case ZIX_STATUS_EXISTS: - return "Exists"; - case ZIX_STATUS_BAD_ARG: - return "Bad argument"; - case ZIX_STATUS_BAD_PERMS: - return "Bad permissions"; - case ZIX_STATUS_REACHED_END: - return "Reached end"; - } - return "Unknown error"; -} +/// Return a string describing a status code +ZIX_API +const char* +zix_strerror(ZixStatus status); /// Function for comparing two elements typedef int (*ZixComparator)(const void* a, diff --git a/meson.build b/meson.build index 5b54107..4cdecf5 100644 --- a/meson.build +++ b/meson.build @@ -95,6 +95,7 @@ sources = files( 'src/digest.c', 'src/hash.c', 'src/ring.c', + 'src/status.c', 'src/tree.c', ) diff --git a/src/status.c b/src/status.c new file mode 100644 index 0000000..b932ff4 --- /dev/null +++ b/src/status.c @@ -0,0 +1,28 @@ +// Copyright 2014-2020 David Robillard <d@drobilla.net> +// SPDX-License-Identifier: ISC + +#include "zix/common.h" + +const char* +zix_strerror(const ZixStatus status) +{ + switch (status) { + case ZIX_STATUS_SUCCESS: + return "Success"; + case ZIX_STATUS_ERROR: + return "Unknown error"; + case ZIX_STATUS_NO_MEM: + return "Out of memory"; + case ZIX_STATUS_NOT_FOUND: + return "Not found"; + case ZIX_STATUS_EXISTS: + return "Exists"; + case ZIX_STATUS_BAD_ARG: + return "Bad argument"; + case ZIX_STATUS_BAD_PERMS: + return "Bad permissions"; + case ZIX_STATUS_REACHED_END: + return "Reached end"; + } + return "Unknown error"; +} |