diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-11-14 09:26:42 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2019-11-14 09:26:42 -0500 |
commit | 062ae1ba5f5661b249366969e03024992f843b5d (patch) | |
tree | f0bd339ac74acd21b1a948de2a7f8a8d7b1fe60e | |
parent | 244fa85e98fa6f325025f49aca6e1fbb1e440582 (diff) | |
download | reloc-062ae1ba5f5661b249366969e03024992f843b5d.tar.gz |
Add initial error handler code
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | reloc_error.c | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c718375..637e47f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ configure_file(version.h.in version.h) include_directories("${CMAKE_BINARY_DIR}") add_library(relocate - STATIC reloc.c) + STATIC reloc.c reloc_error.c) add_executable(reloc main.c) diff --git a/reloc_error.c b/reloc_error.c new file mode 100644 index 0000000..e072f4c --- /dev/null +++ b/reloc_error.c @@ -0,0 +1,21 @@ +#include "reloc.h" + +int reloc_error = 0; +const char *_reloc_errors[] = { + "Success", + "Read error", + "Write error", + "Verification failure", + "Length too long", + "Memory allocation failure", + NULL, +}; + + +const char *reloc_strerror(int code) { + return _reloc_errors[code]; +} + +void reloc_perror(const char *msg) { + fprintf(stderr, "%s: %s\n", msg, reloc_strerror(reloc_error)); +} |