diff options
| author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2017-10-20 22:25:42 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2017-10-21 19:54:24 -0300 |
| commit | 886c0b1666478548485682fbcaa667bb3cc0f138 (patch) | |
| tree | 86a932b1b0091a392595d381a2fdc6229e58fd93 /notmuch-config.c | |
| parent | 4dfcc8c9b2e1dbb965f69283dca50c7581c88050 (diff) | |
config: test whether an item is stored in the database by name
QUERY_STRING was only used in two places, both to test whether a
variable should be stored in (or retrieved from) the database.
Since other configuration variables might be stored in the database in
the future, consolidate that test into a single function.
We also document that these configuration options should not be placed
in the config file.
Diffstat (limited to 'notmuch-config.c')
| -rw-r--r-- | notmuch-config.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/notmuch-config.c b/notmuch-config.c index 8fb59f96..74668718 100644 --- a/notmuch-config.c +++ b/notmuch-config.c @@ -808,7 +808,14 @@ _item_split (char *item, char **group, char **key) } #define BUILT_WITH_PREFIX "built_with." -#define QUERY_PREFIX "query." + +static bool +_stored_in_db (const char *item) +{ + if (STRNCMP_LITERAL (item, "query.") == 0) + return true; + return false; +} static int _print_db_config(notmuch_config_t *config, const char *name) @@ -857,7 +864,7 @@ notmuch_config_command_get (notmuch_config_t *config, char *item) } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) { printf ("%s\n", notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false"); - } else if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) { + } else if (_stored_in_db (item)) { return _print_db_config (config, item); } else { char **value; @@ -928,7 +935,7 @@ notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char return 1; } - if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) { + if (_stored_in_db (item)) { return _set_db_config (config, item, argc, argv); } |
