Re: thread merge/split proposal
[notmuch-archives.git] / 72 / 8a551e059eb241fb82282fc51ae8877722d401
1 Return-Path: <bremner@tesseract.cs.unb.ca>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 33F69429E32\r
6         for <notmuch@notmuchmail.org>; Tue, 24 Mar 2015 06:25:35 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 2.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=unavailable\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id aL72mQeGrg6O for <notmuch@notmuchmail.org>;\r
16         Tue, 24 Mar 2015 06:25:34 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18         [87.98.215.224])\r
19         (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 94762429E41\r
22         for <notmuch@notmuchmail.org>; Tue, 24 Mar 2015 06:25:24 -0700 (PDT)\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
24         4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
25         id 1YaOoy-0000ry-15; Tue, 24 Mar 2015 13:24:40 +0000\r
26 Received: (nullmailer pid 2684 invoked by uid 1000); Tue, 24 Mar 2015\r
27         13:24:25 -0000\r
28 From: David Bremner <david@tethera.net>\r
29 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
30 Subject: [Patch v5 5/8] lib: add a log function with output to a string in\r
31         notmuch_database_t\r
32 Date: Tue, 24 Mar 2015 09:24:08 -0400\r
33 Message-Id: <1427203451-1540-6-git-send-email-david@tethera.net>\r
34 X-Mailer: git-send-email 2.1.4\r
35 In-Reply-To: <1427203451-1540-1-git-send-email-david@tethera.net>\r
36 References: <1426352554-4383-10-git-send-email-david@tethera.net>\r
37         <1427203451-1540-1-git-send-email-david@tethera.net>\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Tue, 24 Mar 2015 13:25:37 -0000\r
51 \r
52 In principle in the future this could do something fancier than sprintf.\r
53 ---\r
54  lib/database-private.h |  4 ++++\r
55  lib/database.cc        | 24 ++++++++++++++++++++++++\r
56  lib/notmuch-private.h  |  4 ++++\r
57  lib/notmuch.h          |  7 +++++++\r
58  4 files changed, 39 insertions(+)\r
59 \r
60 diff --git a/lib/database-private.h b/lib/database-private.h\r
61 index 6d6fa2c..24243db 100644\r
62 --- a/lib/database-private.h\r
63 +++ b/lib/database-private.h\r
64 @@ -154,6 +154,10 @@ struct _notmuch_database {\r
65      unsigned int last_doc_id;\r
66      uint64_t last_thread_id;\r
67  \r
68 +    /* error reporting; this value persists only until the\r
69 +     * next library call. May be NULL */\r
70 +    char *status_string;\r
71 +\r
72      Xapian::QueryParser *query_parser;\r
73      Xapian::TermGenerator *term_gen;\r
74      Xapian::ValueRangeProcessor *value_range_processor;\r
75 diff --git a/lib/database.cc b/lib/database.cc\r
76 index 36849d7..673561b 100644\r
77 --- a/lib/database.cc\r
78 +++ b/lib/database.cc\r
79 @@ -348,6 +348,23 @@ notmuch_status_to_string (notmuch_status_t status)\r
80      }\r
81  }\r
82  \r
83 +void\r
84 +_notmuch_database_log (notmuch_database_t *notmuch,\r
85 +                     const char *format,\r
86 +                     ...)\r
87 +{\r
88 +    va_list va_args;\r
89 +\r
90 +    va_start (va_args, format);\r
91 +\r
92 +    if (notmuch->status_string)\r
93 +       talloc_free (notmuch->status_string);\r
94 +\r
95 +    notmuch->status_string = talloc_vasprintf (notmuch, format, va_args);\r
96 +\r
97 +    va_end (va_args);\r
98 +}\r
99 +\r
100  static void\r
101  find_doc_ids_for_term (notmuch_database_t *notmuch,\r
102                        const char *term,\r
103 @@ -845,6 +862,7 @@ notmuch_database_open_verbose (const char *path,\r
104  \r
105      notmuch = talloc_zero (NULL, notmuch_database_t);\r
106      notmuch->exception_reported = FALSE;\r
107 +    notmuch->status_string = NULL;\r
108      notmuch->path = talloc_strdup (notmuch, path);\r
109  \r
110      if (notmuch->path[strlen (notmuch->path) - 1] == '/')\r
111 @@ -2530,3 +2548,9 @@ notmuch_database_get_all_tags (notmuch_database_t *db)\r
112         return NULL;\r
113      }\r
114  }\r
115 +\r
116 +const char *\r
117 +notmuch_database_status_string (notmuch_database_t *notmuch)\r
118 +{\r
119 +    return notmuch->status_string;\r
120 +}\r
121 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
122 index 8a1f2fa..7cb6fd4 100644\r
123 --- a/lib/notmuch-private.h\r
124 +++ b/lib/notmuch-private.h\r
125 @@ -190,6 +190,10 @@ _notmuch_message_id_compressed (void *ctx, const char *message_id);\r
126  notmuch_status_t\r
127  _notmuch_database_ensure_writable (notmuch_database_t *notmuch);\r
128  \r
129 +void\r
130 +_notmuch_database_log (notmuch_database_t *notmuch,\r
131 +                      const char *format, ...);\r
132 +\r
133  const char *\r
134  _notmuch_database_relative_path (notmuch_database_t *notmuch,\r
135                                  const char *path);\r
136 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
137 index c671d82..20c4e01 100644\r
138 --- a/lib/notmuch.h\r
139 +++ b/lib/notmuch.h\r
140 @@ -302,6 +302,13 @@ notmuch_database_open_verbose (const char *path,\r
141                                char **error_message);\r
142  \r
143  /**\r
144 + * Retrieve last status string for given database.\r
145 + *\r
146 + */\r
147 +const char *\r
148 +notmuch_database_status_string (notmuch_database_t *notmuch);\r
149 +\r
150 +/**\r
151   * Commit changes and close the given notmuch database.\r
152   *\r
153   * After notmuch_database_close has been called, calls to other\r
154 -- \r
155 2.1.4\r
156 \r