From c9a6b1c0134be96a61da006b97ed4007ea31e8d9 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Wed, 13 Jan 2016 23:10:09 +2000 Subject: [PATCH] [WIP2 3/4] CLI: add print_status_database --- 9a/51c64965e0f93fd025481b4d2cd231cc5404a0 | 98 +++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 9a/51c64965e0f93fd025481b4d2cd231cc5404a0 diff --git a/9a/51c64965e0f93fd025481b4d2cd231cc5404a0 b/9a/51c64965e0f93fd025481b4d2cd231cc5404a0 new file mode 100644 index 000000000..f40b38493 --- /dev/null +++ b/9a/51c64965e0f93fd025481b4d2cd231cc5404a0 @@ -0,0 +1,98 @@ +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 243CE6DE0FB1 + for ; Tue, 12 Jan 2016 19:10:27 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.31 +X-Spam-Level: +X-Spam-Status: No, score=-0.31 tagged_above=-999 required=5 tests=[AWL=0.241, + RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] 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 L7FwuLIaFBQK for ; + Tue, 12 Jan 2016 19:10:25 -0800 (PST) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id 87FB36DE020B + for ; Tue, 12 Jan 2016 19:10:23 -0800 (PST) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84) + (envelope-from ) + id 1aJBp7-0000yT-6E; Tue, 12 Jan 2016 22:10:13 -0500 +Received: (nullmailer pid 23102 invoked by uid 1000); + Wed, 13 Jan 2016 03:10:18 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [WIP2 3/4] CLI: add print_status_database +Date: Tue, 12 Jan 2016 23:10:09 -0400 +Message-Id: <1452654610-22864-4-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.6.4 +In-Reply-To: <1452654610-22864-1-git-send-email-david@tethera.net> +References: <1452654610-22864-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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: Wed, 13 Jan 2016 03:10:27 -0000 + +This could probably be used at quite a few places in the existing code, +but in the immediate future I plan to use in some new code in +notmuch-dump +--- + notmuch-client.h | 5 +++++ + status.c | 17 +++++++++++++++++ + 2 files changed, 22 insertions(+) + +diff --git a/notmuch-client.h b/notmuch-client.h +index 3bd2903..7c9a1ea 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -459,6 +459,11 @@ print_status_query (const char *loc, + const notmuch_query_t *query, + notmuch_status_t status); + ++notmuch_status_t ++print_status_database (const char *loc, ++ const notmuch_database_t *database, ++ notmuch_status_t status); ++ + #include "command-line-arguments.h" + + extern char *notmuch_requested_db_uuid; +diff --git a/status.c b/status.c +index 8fa81cb..45d3fb4 100644 +--- a/status.c ++++ b/status.c +@@ -19,3 +19,20 @@ print_status_query (const char *loc, + } + return status; + } ++ ++notmuch_status_t ++print_status_database (const char *loc, ++ const notmuch_database_t *notmuch, ++ notmuch_status_t status) ++{ ++ if (status) { ++ const char *msg; ++ ++ fprintf (stderr, "%s: %s\n", loc, ++ notmuch_status_to_string (status)); ++ msg = notmuch_database_status_string (notmuch); ++ if (msg) ++ fputs (msg, stderr); ++ } ++ return status; ++} +-- +2.6.4 + -- 2.26.2