From 99a9e0b030eb0381d25c6fbfcdf841fb253254a9 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Mon, 7 Sep 2015 10:15:45 +2100 Subject: [PATCH] [PATCH 1/3] cli: add utility routine to print error status. --- 28/1d7ff45af88e81d94dd09ef1ee53200873afc6 | 118 ++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 28/1d7ff45af88e81d94dd09ef1ee53200873afc6 diff --git a/28/1d7ff45af88e81d94dd09ef1ee53200873afc6 b/28/1d7ff45af88e81d94dd09ef1ee53200873afc6 new file mode 100644 index 000000000..0f8211419 --- /dev/null +++ b/28/1d7ff45af88e81d94dd09ef1ee53200873afc6 @@ -0,0 +1,118 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 7B2DF6DE1640 + for ; Sun, 6 Sep 2015 06:58:44 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 2.648 +X-Spam-Level: ** +X-Spam-Status: No, score=2.648 tagged_above=-999 required=5 tests=[AWL=-1.042, + RCVD_IN_BRBL_LASTEXT=1.644, RCVD_IN_SBL=2.596, RP_MATCHES_RCVD=-0.55] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id yqg3-669NIf3 for ; + Sun, 6 Sep 2015 06:58:42 -0700 (PDT) +X-Greylist: delayed 2569 seconds by postgrey-1.35 at arlo; + Sun, 06 Sep 2015 06:58:42 PDT +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + by arlo.cworth.org (Postfix) with ESMTPS id B7E4D6DE1633 + for ; Sun, 6 Sep 2015 06:58:42 -0700 (PDT) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1ZYZnT-0002wz-L9; Sun, 06 Sep 2015 10:15:51 -0300 +Received: (nullmailer pid 29725 invoked by uid 1000); Sun, 06 Sep 2015 + 13:15:48 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH 1/3] cli: add utility routine to print error status. +Date: Sun, 6 Sep 2015 10:15:45 -0300 +Message-Id: <1441545347-29549-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.5.1 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 06 Sep 2015 13:58:44 -0000 + +No attention to formatting here, initially just focus on getting the +relevant strings out of the library. +--- + Makefile.local | 1 + + notmuch-client.h | 9 +++++++++ + status.c | 21 +++++++++++++++++++++ + 3 files changed, 31 insertions(+) + create mode 100644 status.c + +diff --git a/Makefile.local b/Makefile.local +index 61a9c4c..d58cea0 100644 +--- a/Makefile.local ++++ b/Makefile.local +@@ -271,6 +271,7 @@ dataclean: distclean + notmuch_client_srcs = \ + command-line-arguments.c\ + debugger.c \ ++ status.c \ + gmime-filter-reply.c \ + hooks.c \ + notmuch.c \ +diff --git a/notmuch-client.h b/notmuch-client.h +index 882aa30..de8a3b1 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -449,6 +449,15 @@ notmuch_database_dump (notmuch_database_t *notmuch, + dump_format_t output_format, + notmuch_bool_t gzip_output); + ++/* If status is non-zero (i.e. error) print appropriate ++ messages to stderr. ++*/ ++ ++notmuch_status_t ++print_status_query (const char *loc, ++ const notmuch_query_t *query, ++ notmuch_status_t status); ++ + #include "command-line-arguments.h" + + extern char *notmuch_requested_db_uuid; +diff --git a/status.c b/status.c +new file mode 100644 +index 0000000..8fa81cb +--- /dev/null ++++ b/status.c +@@ -0,0 +1,21 @@ ++#include "notmuch-client.h" ++ ++notmuch_status_t ++print_status_query (const char *loc, ++ const notmuch_query_t *query, ++ notmuch_status_t status) ++{ ++ if (status) { ++ const char *msg; ++ notmuch_database_t *notmuch; ++ ++ fprintf (stderr, "%s: %s\n", loc, ++ notmuch_status_to_string (status)); ++ ++ notmuch = notmuch_query_get_database (query); ++ msg = notmuch_database_status_string (notmuch); ++ if (msg) ++ fputs (msg, stderr); ++ } ++ return status; ++} +-- +2.5.1 + -- 2.26.2