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 /reloc_error.c | |
parent | 244fa85e98fa6f325025f49aca6e1fbb1e440582 (diff) | |
download | reloc-062ae1ba5f5661b249366969e03024992f843b5d.tar.gz |
Add initial error handler code
Diffstat (limited to 'reloc_error.c')
-rw-r--r-- | reloc_error.c | 21 |
1 files changed, 21 insertions, 0 deletions
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)); +} |