bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenmailbox_keywords_create_skip(struct mailbox *box,
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen const char *const keywords[])
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen if (mailbox_keyword_is_valid(box, *keywords, &error))
31a574fda352ef4f71dbff9c30e15e4744e132c0Timo Sirainen array_append_zero(&valid_keywords); /* NULL-terminate */
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen kw = mail_index_keywords_create(box->index, keywords);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenmailbox_keywords_are_valid(struct mailbox *box, const char *const keywords[],
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen const char **error_r)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen unsigned int i;
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen if (!mailbox_keyword_is_valid(box, keywords[i], error_r))
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenint mailbox_keywords_create(struct mailbox *box, const char *const keywords[],
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen const char *error, *empty_keyword_list = NULL;
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen if (!mailbox_keywords_are_valid(box, keywords, &error)) {
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS, error);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen *keywords_r = mail_index_keywords_create(box->index, keywords);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenmailbox_keywords_create_valid(struct mailbox *box,
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen const char *const keywords[])
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen if (mailbox_keywords_are_valid(box, keywords, &error))
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen return mail_index_keywords_create(box->index, keywords);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen /* found invalid keywords, do this the slow way */
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen return mailbox_keywords_create_skip(box, keywords);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenmailbox_keywords_create_from_indexes(struct mailbox *box,
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen return mail_index_keywords_create_from_indexes(box->index, idx);
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenvoid mailbox_keywords_ref(struct mail_keywords *keywords)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenvoid mailbox_keywords_unref(struct mail_keywords **keywords)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainenbool mailbox_keyword_is_valid(struct mailbox *box, const char *keyword,
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen const char **error_r)
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen /* if it already exists, skip validity checks */
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen if (mail_index_keyword_lookup(box->index, keyword, &idx))
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen /* these are IMAP-specific restrictions, but for now IMAP is all we
8871c97974dd4e682c7b8d5cff0bbc5b024f56f2Timo Sirainen care about */