From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 336B26DE023C for ; Thu, 10 May 2018 23:58:13 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.018 X-Spam-Level: X-Spam-Status: No, score=-0.018 tagged_above=-999 required=5 tests=[AWL=-0.018, RCVD_IN_DNSWL_NONE=-0.0001] 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 JvkvqIV3HKlB for ; Thu, 10 May 2018 23:58:12 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id 3B2E46DE00C6 for ; Thu, 10 May 2018 23:58:10 -0700 (PDT) Received: from fifthhorseman.net (unknown [38.109.115.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by che.mayfirst.org (Postfix) with ESMTPSA id 482FEF99A for ; Fri, 11 May 2018 02:58:08 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 6B1C820E6C; Fri, 11 May 2018 02:58:03 -0400 (EDT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH v3 4/8] cli: add print_status_message() Date: Fri, 11 May 2018 02:57:55 -0400 Message-Id: <20180511065759.8556-5-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511065759.8556-1-dkg@fifthhorseman.net> References: <20180511065759.8556-1-dkg@fifthhorseman.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 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: Fri, 11 May 2018 06:58:13 -0000 This function is a parallel to print_status_query() or print_status_database(). Thanks to David Bremner for the suggestion! --- notmuch-client.h | 5 +++++ status.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/notmuch-client.h b/notmuch-client.h index 0985a7b0..6c84ecc0 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -481,6 +481,11 @@ print_status_query (const char *loc, const notmuch_query_t *query, notmuch_status_t status); +notmuch_status_t +print_status_message (const char *loc, + const notmuch_message_t *message, + notmuch_status_t status); + notmuch_status_t print_status_database (const char *loc, const notmuch_database_t *database, diff --git a/status.c b/status.c index 8bc2fe4b..01fd8c99 100644 --- a/status.c +++ b/status.c @@ -20,6 +20,26 @@ print_status_query (const char *loc, return status; } +notmuch_status_t +print_status_message (const char *loc, + const notmuch_message_t *message, + 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_message_get_database (message); + msg = notmuch_database_status_string (notmuch); + if (msg) + fputs (msg, stderr); + } + return status; +} + notmuch_status_t print_status_database (const char *loc, const notmuch_database_t *notmuch, -- 2.17.0