aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--reloc_error.c21
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));
+}