From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id O8tYL/88MWAJbAAA0tVLHw (envelope-from ) for ; Sat, 20 Feb 2021 16:46:55 +0000 Received: from aspmx2.migadu.com ([2001:41d0:2:c151::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 2FiQKv88MWBDYAAAbx9fmQ (envelope-from ) for ; Sat, 20 Feb 2021 16:46:55 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx2.migadu.com (Postfix) with ESMTPS id 55DF916ABD for ; Sat, 20 Feb 2021 17:46:55 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 31DA02755B; Sat, 20 Feb 2021 11:45:56 -0500 (EST) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id B29AE26BEA for ; Sat, 20 Feb 2021 11:45:13 -0500 (EST) Received: by fethera.tethera.net (Postfix, from userid 1001) id 9BF4E60666; Sat, 20 Feb 2021 11:45:13 -0500 (EST) Received: (nullmailer pid 3956170 invoked by uid 1000); Sat, 20 Feb 2021 16:44:54 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 05/18] WIP: add n_d_get_config_values Date: Sat, 20 Feb 2021 12:44:35 -0400 Message-Id: <20210220164448.3956011-6-david@tethera.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210220164448.3956011-1-david@tethera.net> References: <20210220164448.3956011-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 2ASBAY7NRIYFZO7BXCWNWFMJI55F7OVL X-Message-ID-Hash: 2ASBAY7NRIYFZO7BXCWNWFMJI55F7OVL X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 0.48 Authentication-Results: aspmx2.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx2.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 55DF916ABD X-Spam-Score: 0.48 X-Migadu-Scanner: scn0.migadu.com X-TUID: T5UtE1BcUzG7 --- lib/config.cc | 14 ++++++++++---- lib/notmuch.h | 2 ++ test/T590-libconfig.sh | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/config.cc b/lib/config.cc index 32ed6f8f..47e8bf82 100644 --- a/lib/config.cc +++ b/lib/config.cc @@ -258,13 +258,19 @@ _notmuch_config_load_from_database (notmuch_database_t *notmuch) notmuch_config_values_t * notmuch_config_get_values (notmuch_database_t *notmuch, notmuch_config_key_t key) { - notmuch_config_values_t *values = NULL; - bool ok = false; - const char *key_str = _notmuch_config_key_to_string (key); if (! key_str) - goto DONE; + return NULL; + + return notmuch_database_get_config_values (notmuch, key_str); +} + +notmuch_config_values_t * +notmuch_database_get_config_values (notmuch_database_t *notmuch, const char *key_str) +{ + notmuch_config_values_t *values = NULL; + bool ok = false; values = talloc (notmuch, notmuch_config_values_t); if (unlikely(! values)) diff --git a/lib/notmuch.h b/lib/notmuch.h index 60c79696..45616a22 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -2475,6 +2475,8 @@ notmuch_config_list_move_to_next (notmuch_config_list_t *config_list); void notmuch_config_list_destroy (notmuch_config_list_t *config_list); +notmuch_config_values_t * +notmuch_database_get_config_values (notmuch_database_t *notmuch, const char *key_string); /** * Configuration keys known to libnotmuch diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index dc9964cf..ad044275 100755 --- a/test/T590-libconfig.sh +++ b/test/T590-libconfig.sh @@ -255,6 +255,29 @@ EOF test_expect_equal_file EXPECTED OUTPUT restore_database +test_begin_subtest "notmuch_database_get_config_values" +cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL% +{ + notmuch_config_values_t *values; + EXPECT0(notmuch_database_set_config (db, "test.list", "x;y;z")); + for (values = notmuch_database_get_config_values (db, "test.list"); + notmuch_config_values_valid (values); + notmuch_config_values_move_to_next (values)) + { + puts (notmuch_config_values_get (values)); + } +} +EOF +cat <<'EOF' >EXPECTED +== stdout == +x +y +z +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT +restore_database + test_begin_subtest "notmuch_config_get_values (restart)" cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL% { -- 2.30.0