const ARRAY_TYPE(const_string) *tokens)
{
struct mail_search_arg *arg, *or_arg, **argp;
- const char *const *tokenp;
+ const char *token;
/* create the OR arg first as the parent */
or_arg = p_new(pool, struct mail_search_arg, 1);
/* now create all the child args for the OR */
argp = &or_arg->value.subargs;
- array_foreach(tokens, tokenp) {
+ array_foreach_elem(tokens, token) {
arg = p_new(pool, struct mail_search_arg, 1);
*arg = *orig_arg;
arg->match_not = FALSE; /* we copied this to the root OR */
arg->next = NULL;
- arg->value.str = p_strdup(pool, *tokenp);
+ arg->value.str = p_strdup(pool, token);
*argp = arg;
argp = &arg->next;
struct mail_search_arg **argp)
{
const ARRAY_TYPE(fts_user_language) *languages;
- struct fts_user_language *const *langp;
+ struct fts_user_language *lang;
struct mail_search_arg *or_arg, *orig_arg = *argp;
const char *error, *orig_token = orig_arg->value.str;
or_arg->match_not = orig_arg->match_not;
or_arg->next = orig_arg->next;
- array_foreach(languages, langp) {
- if (fts_backend_dovecot_tokenize_lang(*langp, pool, or_arg,
+ array_foreach_elem(languages, lang) {
+ if (fts_backend_dovecot_tokenize_lang(lang, pool, or_arg,
orig_arg, orig_token, &error) < 0) {
i_error("fts: %s", error);
return -1;
fts_user_language_find(struct mail_user *user,
const struct fts_language *lang)
{
- struct fts_user_language *const *user_langp;
+ struct fts_user_language *user_lang;
struct fts_user *fuser = FTS_USER_CONTEXT(user);
i_assert(fuser != NULL);
- array_foreach(&fuser->languages, user_langp) {
- if (strcmp((*user_langp)->lang->name, lang->name) == 0)
- return *user_langp;
+ array_foreach_elem(&fuser->languages, user_lang) {
+ if (strcmp(user_lang->lang->name, lang->name) == 0)
+ return user_lang;
}
return NULL;
}
struct fts_user *fuser,
const char **error_r)
{
- const struct fts_language *const *langp;
+ const struct fts_language *lang;
- array_foreach(fts_language_list_get_all(fuser->lang_list), langp) {
- if (fts_user_language_create(user, fuser, *langp, error_r) < 0)
+ array_foreach_elem(fts_language_list_get_all(fuser->lang_list), lang) {
+ if (fts_user_language_create(user, fuser, lang, error_r) < 0)
return -1;
}
return 0;
static void fts_user_free(struct fts_user *fuser)
{
- struct fts_user_language *const *user_langp;
+ struct fts_user_language *user_lang;
if (fuser->lang_list != NULL)
fts_language_list_deinit(&fuser->lang_list);
- array_foreach(&fuser->languages, user_langp)
- fts_user_language_free(*user_langp);
+ array_foreach_elem(&fuser->languages, user_lang)
+ fts_user_language_free(user_lang);
}
int fts_mail_user_init(struct mail_user *user, const char **error_r)
return -1;
}
- const char *const *id;
+ const char *id;
bool found = FALSE;
string_t *uid = t_str_new(64);
ret = 0;
/* then perform sharing */
- array_foreach(&ids, id) {
- if (strchr(*id, '/') != NULL) {
+ array_foreach_elem(&ids, id) {
+ if (strchr(id, '/') != NULL) {
str_truncate(uid, 0);
- const char *hexuid = t_strcut(*id, '/');
+ const char *hexuid = t_strcut(id, '/');
hex_to_binary(hexuid, uid);
if (mcp_update_shared_key(t, user, str_c(uid), key,
&error) < 0) {
mailbox_get_vname(box),
error);
} else {
- const char *const *id;
+ const char *id;
const char *boxname = mailbox_get_vname(box);
if (value.value == NULL)
value.value = "<NO ACTIVE KEY>";
- array_foreach(&ids, id) {
+ array_foreach_elem(&ids, id) {
struct generated_key key;
key.name = boxname;
- key.id = *id;
+ key.id = id;
if (value.value != NULL)
- key.active = strcmp(*id, value.value) == 0;
+ key.active = strcmp(id, value.value) == 0;
else
key.active = FALSE;
key.box = box;
struct mailbox_transaction_context *t;
t = mailbox_transaction_begin(src_box, 0, __func__);
- const char *const *hash;
- array_foreach(&digests, hash) {
+ const char *hash;
+ array_foreach_elem(&digests, hash) {
const char *ptr;
/* if the id contains username part, skip to key public id */
- if ((ptr = strchr(*hash, '/')) != NULL)
+ if ((ptr = strchr(hash, '/')) != NULL)
ptr++;
else
- ptr = *hash;
+ ptr = hash;
if ((ret = mail_crypt_box_unset_shared_key(t, ptr, dest_user,
error_r)) < 0) {
ret = -1;
const char **error_r)
{
struct dcrypt_public_key *key = NULL;
- struct dcrypt_private_key **keyp;
+ struct dcrypt_private_key *priv_key;
int ret = 0;
if (!set) {
dcrypt_key_unref_public(&key);
if (ret >= 0) {
- array_foreach_modifiable(&keys, keyp) {
- dcrypt_key_unref_private(keyp);
- }
+ array_foreach_elem(&keys, priv_key)
+ dcrypt_key_unref_private(&priv_key);
}
if (mailbox_transaction_commit(&t) < 0) {
{
i_assert(dest_user == NULL || dest_pub_key != NULL);
- struct dcrypt_private_key *const *priv_keyp, *priv_key;
+ struct dcrypt_private_key *priv_key;
buffer_t *key_id = t_str_new(MAIL_CRYPT_HASH_BUF_SIZE);
int ret = 0;
- array_foreach(priv_keys, priv_keyp) {
- priv_key = *priv_keyp;
+ array_foreach_elem(priv_keys, priv_key) {
ret = -1;
if (!dcrypt_key_id_private(priv_key, MAIL_CRYPT_KEY_ID_ALGORITHM,
key_id, error_r) ||
{
struct mail_user *user = mail_storage_get_user(mailbox_get_storage(box));
struct notify_status_user *nuser = NOTIFY_STATUS_USER_CONTEXT(user);
- struct imap_match_glob **glob;
+ struct imap_match_glob *glob;
/* not enabled */
if (nuser == NULL)
return FALSE;
if (array_count(&nuser->patterns) == 0)
return TRUE;
- array_foreach_modifiable(&nuser->patterns, glob) {
- if ((imap_match(*glob, mailbox_get_vname(box)) & IMAP_MATCH_YES) != 0)
+ array_foreach_elem(&nuser->patterns, glob) {
+ if ((imap_match(glob, mailbox_get_vname(box)) & IMAP_MATCH_YES) != 0)
return TRUE;
}
return FALSE;
push_notification_driver_dlog_begin_txn(
struct push_notification_driver_txn *dtxn)
{
- const struct push_notification_event *const *event;
+ const struct push_notification_event *event;
i_debug("Called begin_txn push_notification plugin hook.");
- array_foreach(&push_notification_events, event) {
- push_notification_event_init(dtxn, (*event)->name, NULL);
- }
-
+ array_foreach_elem(&push_notification_events, event)
+ push_notification_event_init(dtxn, event->name, NULL);
return TRUE;
}
struct push_notification_driver_txn *dtxn ATTR_UNUSED,
struct push_notification_txn_mbox *mbox)
{
- struct push_notification_txn_event *const *event;
+ struct push_notification_txn_event *event;
i_debug("Called process_mbox push_notification plugin hook.");
i_debug("Mailbox data: Mailbox [%s]", mbox->mailbox);
if (array_is_created(&mbox->eventdata)) {
- array_foreach(&mbox->eventdata, event) {
- if ((*event)->event->event->mbox.debug_mbox != NULL)
- (*event)->event->event->mbox.debug_mbox(*event);
+ array_foreach_elem(&mbox->eventdata, event) {
+ if (event->event->event->mbox.debug_mbox != NULL)
+ event->event->event->mbox.debug_mbox(event);
}
}
}
struct push_notification_driver_txn *dtxn ATTR_UNUSED,
struct push_notification_txn_msg *msg)
{
- struct push_notification_txn_event *const *event;
+ struct push_notification_txn_event *event;
i_debug("Called process_msg push_notification plugin hook.");
msg->mailbox, msg->uid, msg->uid_validity);
if (array_is_created(&msg->eventdata)) {
- array_foreach(&msg->eventdata, event) {
- if ((*event)->event->event->msg.debug_msg != NULL) {
- (*event)->event->event->msg.debug_msg(*event);
- }
+ array_foreach_elem(&msg->eventdata, event) {
+ if (event->event->event->msg.debug_msg != NULL)
+ event->event->event->msg.debug_msg(event);
}
}
}
struct push_notification_driver_txn *dtxn)
{
struct dlua_push_notification_context *ctx = dtxn->duser->context;
- const struct push_notification_event *const *event;
+ const struct push_notification_event *event;
ctx->config_mn.flags = DLUA_DEFAULT_EVENTS;
ctx->config_ma.flags = DLUA_DEFAULT_EVENTS;
ctx->config_fc.store_old = TRUE;
bool found_one = FALSE;
/* Register *all* events that are present in Lua */
- array_foreach(push_notification_get_events(), event) {
- const char *name = (*event)->name;
+ array_foreach_elem(push_notification_get_events(), event) {
+ const char *name = event->name;
const char *fn = push_notification_driver_lua_to_fn(name);
if (!dlua_script_has_function(ctx->script, fn))
continue;
} else if (strcmp(name, "FlagsClear") == 0) {
push_notification_event_init(dtxn, name,
&ctx->config_fc);
- } else if ((*event)->init.default_config != NULL) {
- void *config = (*event)->init.default_config();
+ } else if (event->init.default_config != NULL) {
+ void *config = event->init.default_config();
push_notification_event_init(dtxn, name, config);
} else {
push_notification_event_init(dtxn, name, NULL);
struct push_notification_driver_txn *dtxn,
struct push_notification_txn_mbox *mbox)
{
- struct push_notification_txn_event *const *event;
+ struct push_notification_txn_event *event;
struct dlua_push_notification_context *ctx = dtxn->duser->context;
struct dlua_push_notification_txn_context *tctx = dtxn->context;
if (array_is_created(&mbox->eventdata)) {
- array_foreach(&mbox->eventdata, event) {
+ array_foreach_elem(&mbox->eventdata, event) {
push_notification_driver_lua_call(ctx, tctx,
- (*event), mbox, NULL);
+ event, mbox, NULL);
}
}
}
struct push_notification_driver_txn *dtxn,
struct push_notification_txn_msg *msg)
{
- struct push_notification_txn_event *const *event;
+ struct push_notification_txn_event *event;
struct dlua_push_notification_context *ctx = dtxn->duser->context;
struct dlua_push_notification_txn_context *tctx = dtxn->context;
if (array_is_created(&msg->eventdata)) {
- array_foreach(&msg->eventdata, event) {
+ array_foreach_elem(&msg->eventdata, event) {
push_notification_driver_lua_call(ctx, tctx,
- (*event), NULL, msg);
+ event, NULL, msg);
}
}
}
void push_notification_driver_cleanup_all(void)
{
- const struct push_notification_driver *const *driver;
+ const struct push_notification_driver *driver;
/* Loop through driver list and perform global cleanup tasks. We may not
have used all drivers in this plugin/worker, but the cleanup hooks
are designed to ignore these unused drivers. */
- array_foreach(&push_notification_drivers, driver) {
- if ((*driver)->v.cleanup != NULL)
- (*driver)->v.cleanup();
+ array_foreach_elem(&push_notification_drivers, driver) {
+ if (driver->v.cleanup != NULL)
+ driver->v.cleanup();
}
}
struct push_notification_txn_event *event)
{
struct push_notification_event_flagsclear_data *data = event->data;
- const char *const *keyword;
+ const char *keyword;
if ((data->flags_clear & MAIL_ANSWERED) != 0)
i_debug("%s: Answered flag cleared", EVENT_NAME);
if ((data->flags_clear & MAIL_DRAFT) != 0)
i_debug("%s: Draft flag cleared", EVENT_NAME);
- array_foreach(&data->keywords_clear, keyword)
- i_debug("%s: Keyword clear [%s]", EVENT_NAME, *keyword);
+ array_foreach_elem(&data->keywords_clear, keyword)
+ i_debug("%s: Keyword clear [%s]", EVENT_NAME, keyword);
}
static struct push_notification_event_flagsclear_data *
struct push_notification_txn_event *event)
{
struct push_notification_event_flagsset_data *data = event->data;
- const char *const *keyword;
+ const char *keyword;
if ((data->flags_set & MAIL_ANSWERED) != 0)
i_debug("%s: Answered flag set", EVENT_NAME);
if ((data->flags_set & MAIL_DRAFT) != 0)
i_debug("%s: Draft flag set", EVENT_NAME);
- array_foreach(&data->keywords_set, keyword)
- i_debug("%s: Keyword set [%s]", EVENT_NAME, *keyword);
+ array_foreach_elem(&data->keywords_set, keyword)
+ i_debug("%s: Keyword set [%s]", EVENT_NAME, keyword);
}
static struct push_notification_event_flagsset_data *
push_notification_transaction_init(struct push_notification_txn *ptxn)
{
struct push_notification_driver_txn *dtxn;
- struct push_notification_driver_user **duser;
+ struct push_notification_driver_user *duser;
struct mail_storage *storage;
if (ptxn->initialized)
return;
}
- array_foreach_modifiable(&ptxn->puser->driverlist->drivers, duser) {
+ array_foreach_elem(&ptxn->puser->driverlist->drivers, duser) {
dtxn = p_new(ptxn->pool, struct push_notification_driver_txn, 1);
- dtxn->duser = *duser;
+ dtxn->duser = duser;
dtxn->ptxn = ptxn;
if ((dtxn->duser->driver->v.begin_txn == NULL) ||
push_notification_transaction_end(struct push_notification_txn *ptxn,
bool success)
{
- struct push_notification_driver_txn **dtxn;
+ struct push_notification_driver_txn *dtxn;
if (ptxn->initialized) {
- array_foreach_modifiable(&ptxn->drivers, dtxn) {
- if ((*dtxn)->duser->driver->v.end_txn != NULL) {
- (*dtxn)->duser->driver->v.end_txn(*dtxn,
- success);
- }
+ array_foreach_elem(&ptxn->drivers, dtxn) {
+ if (dtxn->duser->driver->v.end_txn != NULL)
+ dtxn->duser->driver->v.end_txn(dtxn, success);
}
}
struct push_notification_user *puser =
PUSH_NOTIFICATION_USER_CONTEXT(user);
struct push_notification_driver_list *dlist = puser->driverlist;
- struct push_notification_driver_user **duser;
+ struct push_notification_driver_user *duser;
struct ioloop *prev_ioloop = current_ioloop;
/* Make sure we're in the main ioloop, so if the deinit/cleanup moves
*/
io_loop_set_current(main_ioloop);
- array_foreach_modifiable(&dlist->drivers, duser) {
- if ((*duser)->driver->v.deinit != NULL)
- (*duser)->driver->v.deinit(*duser);
- if ((*duser)->driver->v.cleanup != NULL)
- (*duser)->driver->v.cleanup();
+ array_foreach_elem(&dlist->drivers, duser) {
+ if (duser->driver->v.deinit != NULL)
+ duser->driver->v.deinit(duser);
+ if (duser->driver->v.cleanup != NULL)
+ duser->driver->v.cleanup();
}
io_loop_set_current(prev_ioloop);
struct push_notification_txn *txn, struct mailbox *box,
struct push_notification_txn_mbox *mbox)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_mbox_common(
txn, box, &mbox, PUSH_NOTIFICATION_EVENT_TRIGGER_MBOX_CREATE);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
- if ((*ec)->event->mbox_triggers.create != NULL) {
- (*ec)->event->mbox_triggers.create(
- txn, *ec, mbox);
- }
+ array_foreach_elem(&txn->events, ec) {
+ if (ec->event->mbox_triggers.create != NULL)
+ ec->event->mbox_triggers.create(txn, ec, mbox);
}
}
}
struct push_notification_txn *txn, struct mailbox *box,
struct push_notification_txn_mbox *mbox)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_mbox_common(
txn, box, &mbox, PUSH_NOTIFICATION_EVENT_TRIGGER_MBOX_DELETE);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
- if ((*ec)->event->mbox_triggers.delete != NULL) {
- (*ec)->event->mbox_triggers.delete(
- txn, *ec, mbox);
- }
+ array_foreach_elem(&txn->events, ec) {
+ if (ec->event->mbox_triggers.delete != NULL)
+ ec->event->mbox_triggers.delete(txn, ec, mbox);
}
}
}
struct mailbox *src, struct mailbox *dest,
struct push_notification_txn_mbox *mbox)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_mbox_common(
txn, dest, &mbox, PUSH_NOTIFICATION_EVENT_TRIGGER_MBOX_RENAME);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
- if ((*ec)->event->mbox_triggers.rename != NULL) {
- (*ec)->event->mbox_triggers.rename(
- txn, *ec, mbox, src);
+ array_foreach_elem(&txn->events, ec) {
+ if (ec->event->mbox_triggers.rename != NULL) {
+ ec->event->mbox_triggers.rename(
+ txn, ec, mbox, src);
}
}
}
struct push_notification_txn *txn, struct mailbox *box, bool subscribed,
struct push_notification_txn_mbox *mbox)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_mbox_common(
txn, box, &mbox,
PUSH_NOTIFICATION_EVENT_TRIGGER_MBOX_SUBSCRIBE);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
+ array_foreach_elem(&txn->events, ec) {
if (subscribed == TRUE) {
- if ((*ec)->event->mbox_triggers.subscribe != NULL) {
- (*ec)->event->mbox_triggers.subscribe(
- txn, *ec, mbox);
+ if (ec->event->mbox_triggers.subscribe != NULL) {
+ ec->event->mbox_triggers.subscribe(
+ txn, ec, mbox);
}
} else {
- if ((*ec)->event->mbox_triggers.unsubscribe != NULL) {
- (*ec)->event->mbox_triggers.unsubscribe(
- txn, *ec, mbox);
+ if (ec->event->mbox_triggers.unsubscribe != NULL) {
+ ec->event->mbox_triggers.unsubscribe(
+ txn, ec, mbox);
}
}
}
struct push_notification_txn *txn, struct mail *mail,
struct push_notification_txn_msg *msg)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_msg_common(
txn, mail, &msg, PUSH_NOTIFICATION_EVENT_TRIGGER_MSG_SAVE_NEW);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
- if ((*ec)->event->msg_triggers.save != NULL) {
- (*ec)->event->msg_triggers.save(
- txn, *ec, msg, mail);
+ array_foreach_elem(&txn->events, ec) {
+ if (ec->event->msg_triggers.save != NULL) {
+ ec->event->msg_triggers.save(
+ txn, ec, msg, mail);
}
}
}
struct push_notification_txn *txn, struct mail *mail,
struct push_notification_txn_msg *msg)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_msg_common(
txn, mail, &msg,
PUSH_NOTIFICATION_EVENT_TRIGGER_MSG_SAVE_APPEND);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
- if ((*ec)->event->msg_triggers.append != NULL) {
- (*ec)->event->msg_triggers.append(
- txn, *ec, msg, mail);
+ array_foreach_elem(&txn->events, ec) {
+ if (ec->event->msg_triggers.append != NULL) {
+ ec->event->msg_triggers.append(
+ txn, ec, msg, mail);
}
}
}
struct push_notification_txn *txn, struct mail *mail,
struct push_notification_txn_msg *msg)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_msg_common(
txn, mail, &msg, PUSH_NOTIFICATION_EVENT_TRIGGER_MSG_EXPUNGE);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
- if ((*ec)->event->msg_triggers.expunge != NULL) {
- (*ec)->event->msg_triggers.expunge(
- txn, *ec, msg);
- }
+ array_foreach_elem(&txn->events, ec) {
+ if (ec->event->msg_triggers.expunge != NULL)
+ ec->event->msg_triggers.expunge(txn, ec, msg);
}
}
}
struct push_notification_txn *txn, struct mail *mail,
struct push_notification_txn_msg *msg, enum mail_flags old_flags)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_msg_common(
txn, mail, &msg,
PUSH_NOTIFICATION_EVENT_TRIGGER_MSG_FLAGCHANGE);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
- if ((*ec)->event->msg_triggers.flagchange != NULL) {
- (*ec)->event->msg_triggers.flagchange(
- txn, *ec, msg, mail, old_flags);
+ array_foreach_elem(&txn->events, ec) {
+ if (ec->event->msg_triggers.flagchange != NULL) {
+ ec->event->msg_triggers.flagchange(
+ txn, ec, msg, mail, old_flags);
}
}
}
struct push_notification_txn *txn, struct mail *mail,
struct push_notification_txn_msg *msg, const char *const *old_keywords)
{
- struct push_notification_event_config **ec;
+ struct push_notification_event_config *ec;
push_notification_trigger_msg_common(
txn, mail, &msg,
PUSH_NOTIFICATION_EVENT_TRIGGER_MSG_KEYWORDCHANGE);
if (array_is_created(&txn->events)) {
- array_foreach_modifiable(&txn->events, ec) {
- if ((*ec)->event->msg_triggers.keywordchange != NULL) {
- (*ec)->event->msg_triggers.keywordchange(
- txn, *ec, msg, mail, old_keywords);
+ array_foreach_elem(&txn->events, ec) {
+ if (ec->event->msg_triggers.keywordchange != NULL) {
+ ec->event->msg_triggers.keywordchange(
+ txn, ec, msg, mail, old_keywords);
}
}
}