X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fdatabase.cc;h=4c4c9edc0b870241125ae8a06c2b2a76b322d3e0;hb=4b17201c4fa5ce1b4c46c09659b187164dbc1c12;hp=4f02815ffa6e45593a6a89fec7e3c98d3efeb84c;hpb=b52cda90f0b05ce5055fb840e6d9dd88c09f1f83;p=notmuch diff --git a/lib/database.cc b/lib/database.cc index 4f02815f..4c4c9edc 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -322,6 +322,12 @@ _setup_query_field_default (const prefix_t *prefix, notmuch_database_t *notmuch) notmuch->query_parser->add_boolean_prefix (prefix->name, prefix->prefix); } +notmuch_string_map_iterator_t * +_notmuch_database_user_headers (notmuch_database_t *notmuch) +{ + return _notmuch_string_map_iterator_create (notmuch->user_header, "", false); +} + const char * _user_prefix (void *ctx, const char* name) { @@ -422,6 +428,26 @@ _find_prefix (const char *name) return ""; } +/* Like find prefix, but include the possibility of user defined + * prefixes specific to this database */ + +const char * +_notmuch_database_prefix (notmuch_database_t *notmuch, const char *name) +{ + unsigned int i; + + /*XXX TODO: reduce code duplication */ + for (i = 0; i < ARRAY_SIZE (prefix_table); i++) { + if (strcmp (name, prefix_table[i].name) == 0) + return prefix_table[i].prefix; + } + + if (notmuch->user_prefix) + return _notmuch_string_map_get (notmuch->user_prefix, name); + + return NULL; +} + static const struct { /* NOTMUCH_FEATURE_* value. */ _notmuch_features value;