From e8eb1953ec8cc7e595c710c9838cacfc28adfa50 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 27 Dec 2014 23:05:33 +0100 Subject: [PATCH] [PATCH v2 2/6] lib/database: add field for last error string --- 63/a15859d4b0200367482dea7bfc4e58fa3110b3 | 114 ++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 63/a15859d4b0200367482dea7bfc4e58fa3110b3 diff --git a/63/a15859d4b0200367482dea7bfc4e58fa3110b3 b/63/a15859d4b0200367482dea7bfc4e58fa3110b3 new file mode 100644 index 000000000..ed72b9141 --- /dev/null +++ b/63/a15859d4b0200367482dea7bfc4e58fa3110b3 @@ -0,0 +1,114 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id BAF5D429E30 + for ; Sat, 27 Dec 2014 14:06:41 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 93PJNzLRxtuk for ; + Sat, 27 Dec 2014 14:06:39 -0800 (PST) +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id B5B60429E49 + for ; Sat, 27 Dec 2014 14:06:19 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1Y4zV5-0000ES-AT; Sat, 27 Dec 2014 18:06:19 -0400 +Received: (nullmailer pid 1475 invoked by uid 1000); Sat, 27 Dec 2014 + 22:05:48 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH v2 2/6] lib/database: add field for last error string +Date: Sat, 27 Dec 2014 23:05:33 +0100 +Message-Id: <1419717937-1108-3-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.3 +In-Reply-To: <1419717937-1108-1-git-send-email-david@tethera.net> +References: <1419717937-1108-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Sat, 27 Dec 2014 22:06:42 -0000 + +The idea is to have a logging function setting this string instead of +printing to stderr. +--- + lib/database-private.h | 4 ++++ + lib/database.cc | 7 +++++++ + lib/notmuch.h | 7 +++++++ + 3 files changed, 18 insertions(+) + +diff --git a/lib/database-private.h b/lib/database-private.h +index 15e03cc..7efd98b 100644 +--- a/lib/database-private.h ++++ b/lib/database-private.h +@@ -146,6 +146,10 @@ struct _notmuch_database { + unsigned int last_doc_id; + uint64_t last_thread_id; + ++ /* error reporting; this value persists only until the ++ * next library call. May be NULL */ ++ char *status_string; ++ + Xapian::QueryParser *query_parser; + Xapian::TermGenerator *term_gen; + Xapian::ValueRangeProcessor *value_range_processor; +diff --git a/lib/database.cc b/lib/database.cc +index 06e6fc5..249eb68 100644 +--- a/lib/database.cc ++++ b/lib/database.cc +@@ -858,6 +858,7 @@ notmuch_database_open_verbose (const char *path, + + notmuch = talloc_zero (NULL, notmuch_database_t); + notmuch->exception_reported = FALSE; ++ notmuch->status_string = NULL; + notmuch->path = talloc_strdup (notmuch, path); + + if (notmuch->path[strlen (notmuch->path) - 1] == '/') +@@ -2538,3 +2539,9 @@ notmuch_database_get_all_tags (notmuch_database_t *db) + return NULL; + } + } ++ ++const char * ++notmuch_database_status_string (notmuch_database_t *notmuch) ++{ ++ return notmuch->status_string; ++} +diff --git a/lib/notmuch.h b/lib/notmuch.h +index 0dfac8f..2ab2998 100644 +--- a/lib/notmuch.h ++++ b/lib/notmuch.h +@@ -302,6 +302,13 @@ notmuch_database_open_verbose (const char *path, + char **error_message); + + /** ++ * Retrieve last status string for given database. ++ * ++ */ ++const char * ++notmuch_database_status_string (notmuch_database_t *notmuch); ++ ++/** + * Commit changes and close the given notmuch database. + * + * After notmuch_database_close has been called, calls to other +-- +2.1.3 + -- 2.26.2