This is in the client code, rather than libnotmuch_util, because it
prints to stderr. Also it in pretends to generate notmuch status
codes.
#include <errno.h>
#include <signal.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <ctype.h>
#include "talloc-extra.h"
#include "crypto.h"
#include "talloc-extra.h"
#include "crypto.h"
dump_include_t include,
bool gzip_output);
dump_include_t include,
bool gzip_output);
-/* If status is non-zero (i.e. error) print appropriate
+/* If status indicates error print appropriate
int
status_to_exit (notmuch_status_t status);
int
status_to_exit (notmuch_status_t status);
+notmuch_status_t
+print_status_gzbytes (const char *loc,
+ gzFile file,
+ int bytes);
+
#include "command-line-arguments.h"
extern const char *notmuch_requested_db_uuid;
#include "command-line-arguments.h"
extern const char *notmuch_requested_db_uuid;
+
+notmuch_status_t
+print_status_gzbytes (const char *loc, gzFile file, int bytes)
+{
+ if (bytes <= 0) {
+ int errnum;
+ const char *errstr = gzerror (file, &errnum);
+ fprintf (stderr, "%s: zlib error %s (%d)\n", loc, errstr, errnum);
+ return NOTMUCH_STATUS_FILE_ERROR;
+ } else {
+ return NOTMUCH_STATUS_SUCCESS;
+ }
+}
+