diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/imap/imap-feature.c | |
parent | Initial commit. (diff) | |
download | dovecot-upstream.tar.xz dovecot-upstream.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/imap/imap-feature.c')
-rw-r--r-- | src/imap/imap-feature.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/imap/imap-feature.c b/src/imap/imap-feature.c new file mode 100644 index 0000000..d8d52b8 --- /dev/null +++ b/src/imap/imap-feature.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2018 Dovecot authors, see the included COPYING file */ + +#include "imap-common.h" +#include "imap-feature.h" + +static ARRAY_TYPE(imap_feature) feature_register = ARRAY_INIT; + +bool imap_feature_lookup(const char *name, unsigned int *feature_idx_r) +{ + for (unsigned int idx = 0; idx < array_count(&feature_register); idx++) { + const struct imap_feature *feat = + array_idx(&feature_register, idx); + if (strcasecmp(name, feat->feature) == 0) { + *feature_idx_r = idx; + return TRUE; + } + } + return FALSE; +} + +const struct imap_feature *imap_feature_idx(unsigned int feature_idx) +{ + return array_idx(&feature_register, feature_idx); +} + +unsigned int +imap_feature_register(const char *feature, enum mailbox_feature mailbox_features, + imap_client_enable_callback_t *callback) +{ + struct imap_feature *feat = array_append_space(&feature_register); + feat->feature = feature; + feat->mailbox_features = mailbox_features; + feat->callback = callback; + return array_count(&feature_register)-1; +} + +void imap_features_init(void) +{ + i_assert(!array_is_created(&feature_register)); + i_array_init(&feature_register, 8); +} + +void imap_features_deinit(void) +{ + array_free(&feature_register); +} |