Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 74 / 15c57c698f89bbf1dc7db537c93eab4101ec49
1 Return-Path: <tomi.ollila@iki.fi>\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 6DD38431FC0\r
6         for <notmuch@notmuchmail.org>; Wed, 25 Mar 2015 09:48:09 -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=disabled\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 oYmNPJBJ0VIb for <notmuch@notmuchmail.org>;\r
16         Wed, 25 Mar 2015 09:48:06 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id E8A15431FBC\r
19         for <notmuch@notmuchmail.org>; Wed, 25 Mar 2015 09:48:05 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 6AD48100086;\r
22         Wed, 25 Mar 2015 18:47:44 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: David Bremner <david@tethera.net>, David Bremner <david@tethera.net>,\r
25         notmuch@notmuchmail.org\r
26 Subject: Re: [Patch v5 5/8] lib: add a log function with output to a string\r
27         in      notmuch_database_t\r
28 In-Reply-To: <1427203451-1540-6-git-send-email-david@tethera.net>\r
29 References: <1426352554-4383-10-git-send-email-david@tethera.net>\r
30         <1427203451-1540-1-git-send-email-david@tethera.net>\r
31         <1427203451-1540-6-git-send-email-david@tethera.net>\r
32 User-Agent: Notmuch/0.19+92~g402df12 (http://notmuchmail.org) Emacs/24.3.1\r
33         (x86_64-unknown-linux-gnu)\r
34 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
35         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
36         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
37 Date: Wed, 25 Mar 2015 18:47:44 +0200\r
38 Message-ID: <m28ueluiq7.fsf@guru.guru-group.fi>\r
39 MIME-Version: 1.0\r
40 Content-Type: text/plain\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Wed, 25 Mar 2015 16:48:09 -0000\r
54 \r
55 On Tue, Mar 24 2015, David Bremner <david@tethera.net> wrote:\r
56 \r
57 > In principle in the future this could do something fancier than sprintf.\r
58 \r
59 It would be better talking of sNprintf -- it is more accurate and\r
60 potentially more educational.\r
61 \r
62 Rest of the patches in this series OK\r
63 \r
64 > ---\r
65 >  lib/database-private.h |  4 ++++\r
66 >  lib/database.cc        | 24 ++++++++++++++++++++++++\r
67 >  lib/notmuch-private.h  |  4 ++++\r
68 >  lib/notmuch.h          |  7 +++++++\r
69 >  4 files changed, 39 insertions(+)\r
70 >\r
71 > diff --git a/lib/database-private.h b/lib/database-private.h\r
72 > index 6d6fa2c..24243db 100644\r
73 > --- a/lib/database-private.h\r
74 > +++ b/lib/database-private.h\r
75 > @@ -154,6 +154,10 @@ struct _notmuch_database {\r
76 >      unsigned int last_doc_id;\r
77 >      uint64_t last_thread_id;\r
78 >  \r
79 > +    /* error reporting; this value persists only until the\r
80 > +     * next library call. May be NULL */\r
81 > +    char *status_string;\r
82 > +\r
83 >      Xapian::QueryParser *query_parser;\r
84 >      Xapian::TermGenerator *term_gen;\r
85 >      Xapian::ValueRangeProcessor *value_range_processor;\r
86 > diff --git a/lib/database.cc b/lib/database.cc\r
87 > index 36849d7..673561b 100644\r
88 > --- a/lib/database.cc\r
89 > +++ b/lib/database.cc\r
90 > @@ -348,6 +348,23 @@ notmuch_status_to_string (notmuch_status_t status)\r
91 >      }\r
92 >  }\r
93 >  \r
94 > +void\r
95 > +_notmuch_database_log (notmuch_database_t *notmuch,\r
96 > +                   const char *format,\r
97 > +                   ...)\r
98 > +{\r
99 > +    va_list va_args;\r
100 > +\r
101 > +    va_start (va_args, format);\r
102 > +\r
103 > +    if (notmuch->status_string)\r
104 > +     talloc_free (notmuch->status_string);\r
105 > +\r
106 > +    notmuch->status_string = talloc_vasprintf (notmuch, format, va_args);\r
107 > +\r
108 > +    va_end (va_args);\r
109 > +}\r
110 > +\r
111 >  static void\r
112 >  find_doc_ids_for_term (notmuch_database_t *notmuch,\r
113 >                      const char *term,\r
114 > @@ -845,6 +862,7 @@ notmuch_database_open_verbose (const char *path,\r
115 >  \r
116 >      notmuch = talloc_zero (NULL, notmuch_database_t);\r
117 >      notmuch->exception_reported = FALSE;\r
118 > +    notmuch->status_string = NULL;\r
119 >      notmuch->path = talloc_strdup (notmuch, path);\r
120 >  \r
121 >      if (notmuch->path[strlen (notmuch->path) - 1] == '/')\r
122 > @@ -2530,3 +2548,9 @@ notmuch_database_get_all_tags (notmuch_database_t *db)\r
123 >       return NULL;\r
124 >      }\r
125 >  }\r
126 > +\r
127 > +const char *\r
128 > +notmuch_database_status_string (notmuch_database_t *notmuch)\r
129 > +{\r
130 > +    return notmuch->status_string;\r
131 > +}\r
132 > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
133 > index 8a1f2fa..7cb6fd4 100644\r
134 > --- a/lib/notmuch-private.h\r
135 > +++ b/lib/notmuch-private.h\r
136 > @@ -190,6 +190,10 @@ _notmuch_message_id_compressed (void *ctx, const char *message_id);\r
137 >  notmuch_status_t\r
138 >  _notmuch_database_ensure_writable (notmuch_database_t *notmuch);\r
139 >  \r
140 > +void\r
141 > +_notmuch_database_log (notmuch_database_t *notmuch,\r
142 > +                    const char *format, ...);\r
143 > +\r
144 >  const char *\r
145 >  _notmuch_database_relative_path (notmuch_database_t *notmuch,\r
146 >                                const char *path);\r
147 > diff --git a/lib/notmuch.h b/lib/notmuch.h\r
148 > index c671d82..20c4e01 100644\r
149 > --- a/lib/notmuch.h\r
150 > +++ b/lib/notmuch.h\r
151 > @@ -302,6 +302,13 @@ notmuch_database_open_verbose (const char *path,\r
152 >                              char **error_message);\r
153 >  \r
154 >  /**\r
155 > + * Retrieve last status string for given database.\r
156 > + *\r
157 > + */\r
158 > +const char *\r
159 > +notmuch_database_status_string (notmuch_database_t *notmuch);\r
160 > +\r
161 > +/**\r
162 >   * Commit changes and close the given notmuch database.\r
163 >   *\r
164 >   * After notmuch_database_close has been called, calls to other\r
165 > -- \r
166 > 2.1.4\r
167 >\r
168 > _______________________________________________\r
169 > notmuch mailing list\r
170 > notmuch@notmuchmail.org\r
171 > http://notmuchmail.org/mailman/listinfo/notmuch\r