]> git.notmuchmail.org Git - notmuch/blobdiff - util/util.c
util: add gz_readline
[notmuch] / util / util.c
diff --git a/util/util.c b/util/util.c
new file mode 100644 (file)
index 0000000..06659b3
--- /dev/null
@@ -0,0 +1,24 @@
+#include "util.h"
+#include "error_util.h"
+#include <string.h>
+#include <errno.h>
+
+const char *
+util_error_string (util_status_t errnum)
+{
+    switch (errnum) {
+    case UTIL_SUCCESS:
+       return "success";
+    case UTIL_OUT_OF_MEMORY:
+       return "out of memory";
+    case UTIL_EOF:
+       return "end of file";
+    case UTIL_ERRNO:
+       return strerror (errno);
+    case UTIL_GZERROR:
+       /* we lack context to be more informative here */
+       return "zlib error";
+    default:
+       INTERNAL_ERROR("unexpected error status %d", errnum);
+    }
+}