From 85d9219a62c23c3ff58b42a63b65390526b89b6b Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 29 Mar 2014 14:53:17 -0300 Subject: util: add gz_readline The idea is to provide a more or less drop in replacement for readline to read from zlib/gzip streams. Take the opportunity to replace malloc with talloc. --- util/util.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 util/util.c (limited to 'util/util.c') diff --git a/util/util.c b/util/util.c new file mode 100644 index 00000000..06659b35 --- /dev/null +++ b/util/util.c @@ -0,0 +1,24 @@ +#include "util.h" +#include "error_util.h" +#include +#include + +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); + } +} -- cgit v1.2.3