--- 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 _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org