diff options
author | David Bremner <david@tethera.net> | 2014-03-29 14:53:17 -0300 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-04-12 07:59:44 -0300 |
commit | 85d9219a62c23c3ff58b42a63b65390526b89b6b (patch) | |
tree | fbf5b430c91b6ffa6b2c773c86184790232b2fe1 /util/zlib-extra.h | |
parent | 3c13bc0321baaf340663779d6fce2b1f34c1c2c3 (diff) |
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.
Diffstat (limited to 'util/zlib-extra.h')
-rw-r--r-- | util/zlib-extra.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/util/zlib-extra.h b/util/zlib-extra.h new file mode 100644 index 00000000..aedfd48f --- /dev/null +++ b/util/zlib-extra.h @@ -0,0 +1,25 @@ +#ifndef _ZLIB_EXTRA_H +#define _ZLIB_EXTRA_H + +#include "util.h" +#include <zlib.h> + +/* Like getline, but read from a gzFile. Allocation is with talloc. + * Returns: + * + * UTIL_SUCCESS, UTIL_OUT_OF_MEMORY, UTIL_ERRNO, UTIL_GZERROR + * Consult util.h for description + * + * UTIL_EOF End of file encountered before + * any characters read + */ +util_status_t +gz_getline (void *ctx, char **lineptr, ssize_t *bytes_read, gzFile stream); + +/* return a suitable error string based on the return status + * from gz_readline + */ + +const char * +gz_error_string (util_status_t status, gzFile stream); +#endif |