1 Return-Path: <bremner@tethera.net>
\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 arlo.cworth.org (Postfix) with ESMTP id BA5656DE0356
\r
6 for <notmuch@notmuchmail.org>; Fri, 13 May 2016 03:38:30 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.013 tagged_above=-999 required=5
\r
12 tests=[AWL=-0.002, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]
\r
14 Received: from arlo.cworth.org ([127.0.0.1])
\r
15 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 0N5wmMGFUQBr for <notmuch@notmuchmail.org>;
\r
17 Fri, 13 May 2016 03:38:22 -0700 (PDT)
\r
18 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])
\r
19 by arlo.cworth.org (Postfix) with ESMTPS id 277926DE00D3
\r
20 for <notmuch@notmuchmail.org>; Fri, 13 May 2016 03:38:22 -0700 (PDT)
\r
21 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)
\r
22 (envelope-from <bremner@tethera.net>)
\r
23 id 1b1AU2-0003O6-0e; Fri, 13 May 2016 06:38:14 -0400
\r
24 Received: (nullmailer pid 7548 invoked by uid 1000);
\r
25 Fri, 13 May 2016 10:38:16 -0000
\r
26 From: David Bremner <david@tethera.net>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [Patch v5 03/11] lib/cli: add library API / CLI for compile time
\r
30 Date: Fri, 13 May 2016 07:38:05 -0300
\r
31 Message-Id: <1463135893-7471-4-git-send-email-david@tethera.net>
\r
32 X-Mailer: git-send-email 2.8.1
\r
33 In-Reply-To: <1463135893-7471-1-git-send-email-david@tethera.net>
\r
34 References: <1463135893-7471-1-git-send-email-david@tethera.net>
\r
36 Content-Type: text/plain; charset=UTF-8
\r
37 Content-Transfer-Encoding: 8bit
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.20
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Fri, 13 May 2016 10:38:30 -0000
\r
52 This is intentionally low tech; if we have more than two options it may
\r
53 make sense to build up what infrastructure is provided.
\r
55 doc/man1/notmuch-config.rst | 5 +++++
\r
56 lib/Makefile.local | 1 +
\r
57 lib/built-with.c | 34 ++++++++++++++++++++++++++++++++++
\r
58 lib/notmuch.h | 5 +++++
\r
59 notmuch-config.c | 23 +++++++++++++++++++++++
\r
60 test/T030-config.sh | 6 ++++--
\r
61 test/T040-setup.sh | 6 ++++--
\r
62 test/test-lib.sh | 6 ++++++
\r
63 8 files changed, 82 insertions(+), 4 deletions(-)
\r
64 create mode 100644 lib/built-with.c
\r
66 diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst
\r
67 index 40c1272..26a8eb1 100644
\r
68 --- a/doc/man1/notmuch-config.rst
\r
69 +++ b/doc/man1/notmuch-config.rst
\r
70 @@ -132,6 +132,11 @@ The available configuration items are described below.
\r
74 + **built_with.<name>**
\r
76 + Compile time feature <name>. Current possibilities include
\r
77 + "compact" (see **notmuch-compact(1)**)
\r
78 + and "field_processor" (see **notmuch-search-terms(7)**).
\r
82 diff --git a/lib/Makefile.local b/lib/Makefile.local
\r
83 index 3a07090..36c3924 100644
\r
84 --- a/lib/Makefile.local
\r
85 +++ b/lib/Makefile.local
\r
86 @@ -39,6 +39,7 @@ libnotmuch_c_srcs = \
\r
87 $(dir)/message-file.c \
\r
90 + $(dir)/built-with.c \
\r
93 libnotmuch_cxx_srcs = \
\r
94 diff --git a/lib/built-with.c b/lib/built-with.c
\r
95 new file mode 100644
\r
96 index 0000000..7ea1d7f
\r
98 +++ b/lib/built-with.c
\r
100 +/* notmuch - Not much of an email program, (just index and search)
\r
102 + * Copyright © 2016 David Bremner
\r
104 + * This program is free software: you can redistribute it and/or modify
\r
105 + * it under the terms of the GNU General Public License as published by
\r
106 + * the Free Software Foundation, either version 3 of the License, or
\r
107 + * (at your option) any later version.
\r
109 + * This program is distributed in the hope that it will be useful,
\r
110 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
111 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
112 + * GNU General Public License for more details.
\r
114 + * You should have received a copy of the GNU General Public License
\r
115 + * along with this program. If not, see http://www.gnu.org/licenses/ .
\r
117 + * Author: David Bremner <david@tethera.net>
\r
120 +#include "notmuch.h"
\r
121 +#include "notmuch-private.h"
\r
124 +notmuch_built_with (const char *name)
\r
126 + if (STRNCMP_LITERAL (name, "compact") == 0) {
\r
127 + return HAVE_XAPIAN_COMPACT;
\r
128 + } else if (STRNCMP_LITERAL (name, "field_processor") == 0) {
\r
129 + return HAVE_XAPIAN_FIELD_PROCESSOR;
\r
134 diff --git a/lib/notmuch.h b/lib/notmuch.h
\r
135 index cb46fc0..3a092ef 100644
\r
136 --- a/lib/notmuch.h
\r
137 +++ b/lib/notmuch.h
\r
138 @@ -1838,6 +1838,11 @@ notmuch_filenames_move_to_next (notmuch_filenames_t *filenames);
\r
140 notmuch_filenames_destroy (notmuch_filenames_t *filenames);
\r
143 + * interrogate the library for compile time features
\r
146 +notmuch_built_with (const char *name);
\r
150 diff --git a/notmuch-config.c b/notmuch-config.c
\r
151 index d252bb2..01bb185 100644
\r
152 --- a/notmuch-config.c
\r
153 +++ b/notmuch-config.c
\r
154 @@ -750,6 +750,8 @@ _item_split (char *item, char **group, char **key)
\r
158 +#define BUILT_WITH_PREFIX "built_with."
\r
161 notmuch_config_command_get (notmuch_config_t *config, char *item)
\r
163 @@ -773,6 +775,9 @@ notmuch_config_command_get (notmuch_config_t *config, char *item)
\r
164 tags = notmuch_config_get_new_tags (config, &length);
\r
165 for (i = 0; i < length; i++)
\r
166 printf ("%s\n", tags[i]);
\r
167 + } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
\r
169 + notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false");
\r
173 @@ -804,6 +809,11 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
\r
177 + if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
\r
178 + fprintf (stderr, "Error: read only option: %s\n", item);
\r
182 if (_item_split (item, &group, &key))
\r
185 @@ -830,6 +840,18 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char
\r
186 return notmuch_config_save (config);
\r
191 +_notmuch_config_list_built_with ()
\r
193 + printf("%scompact=%s\n",
\r
194 + BUILT_WITH_PREFIX,
\r
195 + notmuch_built_with ("compact") ? "true" : "false");
\r
196 + printf("%sfield_processor=%s\n",
\r
197 + BUILT_WITH_PREFIX,
\r
198 + notmuch_built_with ("field_processor") ? "true" : "false");
\r
202 notmuch_config_command_list (notmuch_config_t *config)
\r
204 @@ -865,6 +887,7 @@ notmuch_config_command_list (notmuch_config_t *config)
\r
206 g_strfreev (groups);
\r
208 + _notmuch_config_list_built_with ();
\r
212 diff --git a/test/T030-config.sh b/test/T030-config.sh
\r
213 index f404908..437269f 100755
\r
214 --- a/test/T030-config.sh
\r
215 +++ b/test/T030-config.sh
\r
216 @@ -44,7 +44,7 @@ test_expect_equal "$(notmuch config get foo.nonexistent)" ""
\r
218 test_begin_subtest "List all items"
\r
219 notmuch config set database.path "/canonical/path"
\r
220 -output=$(notmuch config list)
\r
221 +output=$(notmuch config list | notmuch_built_with_sanitize)
\r
222 test_expect_equal "$output" "\
\r
223 database.path=/canonical/path
\r
224 user.name=Notmuch Test Suite
\r
225 @@ -56,7 +56,9 @@ search.exclude_tags=
\r
226 maildir.synchronize_flags=true
\r
227 crypto.gpg_path=gpg
\r
228 foo.string=this is another string value
\r
229 -foo.list=this;is another;list value;"
\r
230 +foo.list=this;is another;list value;
\r
231 +built_with.compact=something
\r
232 +built_with.field_processor=something"
\r
234 test_begin_subtest "Top level --config=FILE option"
\r
235 cp "${NOTMUCH_CONFIG}" alt-config
\r
236 diff --git a/test/T040-setup.sh b/test/T040-setup.sh
\r
237 index cf0c00b..be2f0db 100755
\r
238 --- a/test/T040-setup.sh
\r
239 +++ b/test/T040-setup.sh
\r
240 @@ -19,7 +19,7 @@ another.suite@example.com
\r
244 -output=$(notmuch --config=new-notmuch-config config list)
\r
245 +output=$(notmuch --config=new-notmuch-config config list | notmuch_built_with_sanitize)
\r
246 test_expect_equal "$output" "\
\r
247 database.path=/path/to/maildir
\r
248 user.name=Test Suite
\r
249 @@ -29,6 +29,8 @@ new.tags=foo;bar;
\r
251 search.exclude_tags=baz;
\r
252 maildir.synchronize_flags=true
\r
253 -crypto.gpg_path=gpg"
\r
254 +crypto.gpg_path=gpg
\r
255 +built_with.compact=something
\r
256 +built_with.field_processor=something"
\r
259 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
260 index ac04b15..09f8731 100644
\r
261 --- a/test/test-lib.sh
\r
262 +++ b/test/test-lib.sh
\r
263 @@ -733,6 +733,12 @@ notmuch_uuid_sanitize ()
\r
265 sed 's/[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/UUID/g'
\r
268 +notmuch_built_with_sanitize ()
\r
270 + sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
\r
273 # End of notmuch helper functions
\r
275 # Use test_set_prereq to tell that a particular prerequisite is available.
\r