return;
}
- auth_requests = array_idx_modifiable(&auth_failures_arr, 0);
+ auth_requests = array_first_modifiable(&auth_failures_arr);
/* count the number of requests that we need to flush */
for (i = 0; i < count; i++) {
auth_request = auth_requests[aqueue_idx(auth_failures, i)];
struct auth_worker_connection **connp, *conn;
while (array_count(&connections) > 0) {
- connp = array_idx_modifiable(&connections, 0);
+ connp = array_first_modifiable(&connections);
conn = *connp;
auth_worker_destroy(&conn, "Shutting down", FALSE);
}
if (count == 0)
return NULL;
- requests = array_idx(&conn->request_array, 0);
+ requests = array_first(&conn->request_array);
for (i = 0; i < count; i++) {
request = requests[aqueue_idx(conn->request_queue, i)];
if (request->msgid == msgid) {
timeout_remove(&conn->to);
if (conn->pending_count != 0) {
- requests = array_idx(&conn->request_array, 0);
+ requests = array_first(&conn->request_array);
for (i = 0; i < conn->pending_count; i++) {
request = requests[aqueue_idx(conn->request_queue, i)];
new_filter = config_filter_init(ctx->pool);
array_append_zero(&ctx->all_parsers);
- config_filter_add_all(new_filter, array_idx(&ctx->all_parsers, 0));
+ config_filter_add_all(new_filter, array_first(&ctx->all_parsers));
if (ret < 0)
;
dict_connection_ref(conn);
while (array_count(&conn->cmds) > 0) {
- first_cmdp = array_idx(&conn->cmds, 0);
+ first_cmdp = array_first(&conn->cmds);
cmd = *first_cmdp;
i_assert(cmd->async_reply_id == 0);
struct dict_connection_cmd *const *first_cmdp;
if (cmd->conn->minor_version < DICT_CLIENT_PROTOCOL_TIMINGS_MIN_VERSION) {
- first_cmdp = array_idx(&cmd->conn->cmds, 0);
+ first_cmdp = array_first(&cmd->conn->cmds);
if (*first_cmdp != cmd)
return;
}
*_dir = NULL;
while (array_count(&dir->connections) > 0) {
- connp = array_idx(&dir->connections, 0);
+ connp = array_first(&dir->connections);
conn = *connp;
director_connection_deinit(&conn, "Shutting down");
}
timeout_remove(&dir->to_remove_dirs);
timeout_remove(&dir->to_callback);
while (array_count(&dir->dir_hosts) > 0) {
- hostp = array_idx(&dir->dir_hosts, 0);
+ hostp = array_first(&dir->dir_hosts);
host = *hostp;
director_host_free(&host);
}
t_strsplit_spaces(doveadm_settings->dsync_hashed_headers, " ,");
if (array_count(&ctx->exclude_mailboxes) > 0) {
/* array is NULL-terminated in init() */
- set.exclude_mailboxes = array_idx(&ctx->exclude_mailboxes, 0);
+ set.exclude_mailboxes = array_first(&ctx->exclude_mailboxes);
}
doveadm_user_init_dsync(user);
if (count == 0)
return;
- keywords = array_idx(&index->keywords, 0);
+ keywords = array_first(&index->keywords);
for (i = 0; i < count; i++)
printf("%3u = %s\n", i, keywords[kw_indexes[i]]);
}
const struct kick_user *user;
if (array_count(&k_pid->users) == 1) {
- user = array_idx(&k_pid->users, 0);
+ user = array_first(&k_pid->users);
if (!user->kick_me)
return FALSE;
} else {
if (array_count(&server->queue) > 0) {
struct server_connection *conn;
- char *const *usernamep = array_idx(&server->queue, 0);
+ char *const *usernamep = array_first(&server->queue);
char *username = *usernamep;
conn = doveadm_server_find_unused_conn(server);
while (array_count(&server->connections) > 0) {
struct server_connection *const *connp, *conn;
- connp = array_idx(&server->connections, 0);
+ connp = array_first(&server->connections);
conn = *connp;
server_connection_destroy(&conn);
}
iter->only_selectable = TRUE;
iter->iter_flags = iter_flags;
iter->iter = mailbox_list_iter_init_namespaces(user->namespaces,
- array_idx(&iter->patterns, 0),
+ array_first(&iter->patterns),
ns_mask, iter_flags);
return iter;
}
entry->value = value;
if (ctx.idx >= array_count(&ctx.headers)) {
- if (var_expand(ctx.buf, ctx.format, array_idx(&ctx.headers,0), &error) <= 0) {
+ if (var_expand(ctx.buf, ctx.format, array_first(&ctx.headers), &error) <= 0) {
i_error("Failed to expand print format '%s': %s",
ctx.format, error);
}
if (array_count(&user->ips) == 0)
i_zero(ip_r);
else {
- const struct ip_addr *ip = array_idx(&user->ips, 0);
+ const struct ip_addr *ip = array_first(&user->ips);
*ip_r = *ip;
}
}
if (array_count(&pipe->item_queue) == 0)
return NULL;
- item = array_idx_modifiable(&pipe->item_queue, 0);
+ item = array_first_modifiable(&pipe->item_queue);
i_assert(item->type == type);
pipe->pop_item = *item;
array_delete(&pipe->item_queue, 0, 1);
if (array_count(&pipe->item_queue) == 0)
return FALSE;
- item = array_idx(&pipe->item_queue, 0);
+ item = array_first(&pipe->item_queue);
if (item->type != ITEM_END_OF_LIST)
return FALSE;
struct item *item;
if (array_count(&pipe->item_queue) > 0) {
- item = array_idx_modifiable(&pipe->item_queue, 0);
+ item = array_first_modifiable(&pipe->item_queue);
if (item->type == ITEM_MAIL &&
item->u.mail.input != NULL)
i_stream_unref(&item->u.mail.input);
array_count(&instances->seqs) == 0)
continue;
- uids = array_idx(&instances->seqs, 0);
+ uids = array_first(&instances->seqs);
seq = uids[0].seq1;
if (!instances->searched) {
instances->searched = TRUE;
&const_guid, 1);
continue;
}
- uids = array_idx(&instances->seqs, 0);
+ uids = array_first(&instances->seqs);
seq = uids[0].seq1;
seq_range_array_add(&sarg->value.seqset, seq);
}
if (t1->timestamp > t2->timestamp)
return 1;
- m1 = array_idx(&t1->msgs, 0);
- m2 = array_idx(&t2->msgs, 0);
+ m1 = array_first(&t1->msgs);
+ m2 = array_first(&t2->msgs);
if (*m1 < *m2)
return -1;
if (*m1 > *m2)
&status);
keywords = count == 0 ? NULL :
- array_idx(client->keywords.names, 0);
+ array_first(client->keywords.names);
str = t_str_new(128);
str_append(str, "* FLAGS (");
imap_write_flags(str, status.flags, keywords);
{
const struct imap_fetch_handler *handler, *first_handler;
- first_handler = array_idx(&fetch_handlers, 0);
+ first_handler = array_first(&fetch_handlers);
handler = imap_fetch_handler_lookup(name);
i_assert(handler != NULL);
array_delete(&fetch_handlers, handler - first_handler, 1);
MAIL_FETCH_STREAM_BODY)) == 0)) {
array_append_zero(&ctx->all_headers);
- headers = array_idx(&ctx->all_headers, 0);
+ headers = array_first(&ctx->all_headers);
wanted_headers = mailbox_header_lookup_init(box, headers);
array_delete(&ctx->all_headers,
array_count(&ctx->all_headers)-1, 1);
DLLIST_REMOVE(&conn->group->connections, conn);
while (array_count(&conn->cmds) > 0) {
- cmdp = array_idx(&conn->cmds, 0);
+ cmdp = array_first(&conn->cmds);
cmd = *cmdp;
ipc_connection_cmd_free(&cmd, error);
struct ipc_group *const *groupp, *group;
while (array_count(&ipc_groups) > 0) {
- groupp = array_idx(&ipc_groups, 0);
+ groupp = array_first(&ipc_groups);
group = *groupp;
while ((*groupp)->connections != NULL) {
if (line[0] != '*' || str_to_uint(line+1, &num_replies) < 0)
break;
- reply = array_idx_modifiable(&dict->replies, 0);
+ reply = array_first_modifiable(&dict->replies);
i_assert(reply->reply_count > 0);
if (reply->reply_count != num_replies) {
*error_r = t_strdup_printf(
if (*line != '+' && *line != ':')
break;
/* success, just ignore the actual reply */
- reply = array_idx_modifiable(&dict->replies, 0);
+ reply = array_first_modifiable(&dict->replies);
i_assert(reply->reply_count > 0);
if (--reply->reply_count == 0) {
const struct dict_commit_result result = {
array_append_zero(&np->utf16_token);
array_delete(&np->utf16_token, array_count(&np->utf16_token)-1, 1);
array_clear(&np->trans_token);
- if (fts_icu_translate(&np->trans_token, array_idx(&np->utf16_token, 0),
+ if (fts_icu_translate(&np->trans_token, array_first(&np->utf16_token),
array_count(&np->utf16_token),
np->transliterator, error_r) < 0)
return -1;
if (array_count(&np->trans_token) == 0)
return 0;
- fts_icu_utf16_to_utf8(np->utf8_token, array_idx(&np->trans_token, 0),
+ fts_icu_utf16_to_utf8(np->utf8_token, array_first(&np->trans_token),
array_count(&np->trans_token));
fts_filter_truncate_token(np->utf8_token, np->filter.max_length);
*token = str_c(np->utf8_token);
{
const struct fts_language *const *langp;
- langp = array_idx(&list->languages, 0);
+ langp = array_first(&list->languages);
return *langp;
}
/* if there's only a single wanted language, return it always. */
if (array_count(&list->languages) == 1) {
const struct fts_language *const *langp =
- array_idx(&list->languages, 0);
+ array_first(&list->languages);
*lang_r = *langp;
return FTS_LANGUAGE_RESULT_OK;
}
string_t *str = t_str_new(64);
if (array_count(&conn->request_wait_list) > 0) {
- requestp = array_idx(&conn->request_wait_list, 0);
+ requestp = array_first(&conn->request_wait_list);
str_append(str, "Request ");
http_client_request_append_stats_text(*requestp, str);
i_assert(array_is_created(&conn->request_wait_list));
i_assert(array_count(&conn->request_wait_list) > 0);
- requestp = array_idx(&conn->request_wait_list, 0);
+ requestp = array_first(&conn->request_wait_list);
timeout_msecs = (*requestp)->attempt_timeout_msecs;
if (timeout_msecs == 0)
&& array_is_created(&coding->parameters)
&& array_count(&coding->parameters) > 0) {
const struct http_transfer_param *param =
- array_idx(&coding->parameters, 0);
+ array_first(&coding->parameters);
parser->error_code = HTTP_MESSAGE_PARSE_ERROR_BAD_MESSAGE;
parser->error = t_strdup_printf(
/* FIXME: stupid algorithm */
if (array_count(&client->conns) == 0)
return imapc_client_add_connection(client)->conn;
- connp = array_idx(&client->conns, 0);
+ connp = array_first(&client->conns);
return (*connp)->conn;
}
cmd->sent = TRUE;
/* everything sent. move command to wait list. */
- cmdp = array_idx(&conn->cmd_send_queue, 0);
+ cmdp = array_first(&conn->cmd_send_queue);
i_assert(*cmdp == cmd);
array_delete(&conn->cmd_send_queue, 0, 1);
array_append(&conn->cmd_wait_list, &cmd, 1);
if (!array_is_created(&cmd->streams) || array_count(&cmd->streams) == 0)
return NULL;
- stream = array_idx_modifiable(&cmd->streams, 0);
+ stream = array_first_modifiable(&cmd->streams);
if (stream->pos != cmd->send_pos)
return NULL;
return stream;
return FALSE;
}
- first = array_idx(&msgmap->uids, 0);
+ first = array_first(&msgmap->uids);
*rseq_r = (p - first) + 1;
return TRUE;
}
array_count(parser->cur_list) != 1)
return FALSE;
- arg = array_idx(&parser->root_list, 0);
+ arg = array_first(&parser->root_list);
if (arg->type != IMAP_ARG_ATOM)
return FALSE;
ssize_t diff = (ssize_t)new_padded_hdr_size -
(ssize_t)old_padded_hdr_size;
- ext = array_idx_modifiable(&map->extensions, 0);
+ ext = array_first_modifiable(&map->extensions);
for (i = ext_map_idx + 1; i < count; i++) {
ext[i].ext_offset += diff;
ext[i].hdr_offset += diff;
int i, days;
hdr = *mail_index_get_header(t->view);
- rec = array_idx(&t->appends, 0);
+ rec = array_first(&t->appends);
stamp = time_to_local_day_start(day_stamp);
if ((time_t)hdr.day_stamp >= stamp)
kw_idx = array_get(&ctx->lost_new_kw, &count);
if (count == 0)
return 0;
- kw_names = array_idx(&ctx->view->index->keywords, 0);
+ kw_names = array_first(&ctx->view->index->keywords);
i_zero(&thdr);
thdr.type = MAIL_TRANSACTION_KEYWORD_UPDATE | MAIL_TRANSACTION_EXTERNAL;
We're mapping the files in reverse order so that _log_file_map()
can verify that prev_file_offset matches how far it actually managed
to sync the file. */
- files = array_idx(&view->file_refs, 0);
+ files = array_first(&view->file_refs);
for (i = array_count(&view->file_refs); i > 0; i--) {
file = files[i-1];
start_offset = file->hdr.file_seq == min_file_seq ?
later on. */
i_assert(array_count(&changes.saved_uids) == 1);
const struct seq_range *range =
- array_idx(&changes.saved_uids, 0);
+ array_first(&changes.saved_uids);
i_assert(range->seq1 == range->seq2);
ctx->dest_mail = mail_deliver_open_mail(box, range->seq1,
MAIL_FETCH_STREAM_BODY | MAIL_FETCH_GUID, &t);
if (array_count(&changes_r->saved_uids) > 0) {
const struct seq_range *range =
- array_idx(&changes_r->saved_uids, 0);
+ array_first(&changes_r->saved_uids);
mail_deliver_cache_update_post_commit(box, range->seq1);
}
const struct ldap_attribute *attr;
array_foreach(&entry->attributes, attr) {
if (strcasecmp(attr->name, attribute) == 0) {
- return array_idx(&attr->values, 0);
+ return array_first(&attr->values);
}
}
return NULL;
}
array_append_zero(&conn->streams);
- inputs = array_idx_modifiable(&conn->streams, 0);
+ inputs = array_first_modifiable(&conn->streams);
input = i_stream_create_concat(inputs);
istream_attachment_connector_free(conn);
*_query = NULL;
count = aqueue_count(client->queries);
- queries = array_idx(&client->queries_arr, 0);
+ queries = array_first(&client->queries_arr);
for (i = 0; i < count; i++) {
if (queries[aqueue_idx(client->queries, i)] == query) {
query->callback = NULL;
parser->state.state = SMTP_REPLY_PARSE_STATE_INIT;
parser->state.reply->text_lines =
- array_idx(&parser->state.reply_lines, 0);
+ array_first(&parser->state.reply_lines);
*reply_r = parser->state.reply;
return 1;
}
parser->state.state = SMTP_REPLY_PARSE_STATE_INIT;
parser->state.reply->text_lines =
- array_idx(&parser->state.reply_lines, 0);
+ array_first(&parser->state.reply_lines);
*reply_r = parser->state.reply;
return 1;
}
/* [SP Mail-parameters] */
if (array_is_created(&conn->mail_param_extensions))
- param_extensions = array_idx(&conn->mail_param_extensions, 0);
+ param_extensions = array_first(&conn->mail_param_extensions);
if (smtp_params_mail_parse(cmd->pool, params, caps, param_extensions,
NULL, &mail_data->params, &pperror,
&error) < 0) {
/* [SP Rcpt-parameters] */
if (array_is_created(&conn->rcpt_param_extensions))
- param_extensions = array_idx(&conn->rcpt_param_extensions, 0);
+ param_extensions = array_first(&conn->rcpt_param_extensions);
if (smtp_params_rcpt_parse(rcpt->pool, params, caps, param_extensions,
&rcpt->params, &pperror, &error) < 0) {
switch (pperror) {
conn->stats.reply_count++;
i_assert(array_is_created(&cmd->replies));
- reply = array_idx_modifiable(&cmd->replies, 0);
+ reply = array_first_modifiable(&cmd->replies);
i_assert(reply->content != NULL);
if (reply->content->status == 221 || reply->content->status == 421) {
if (array_count(&trans->rcpt_to) == 1) {
struct smtp_server_recipient *const *rcpts =
- array_idx(&trans->rcpt_to, 0);
+ array_first(&trans->rcpt_to);
rcpt_to = smtp_address_encode(rcpts[0]->path);
}
array_clear(&db->pending_prepares);
while (array_count(&db->results) > 0) {
- resultp = array_idx(&db->results, 0);
+ resultp = array_first(&db->results);
if ((*resultp)->error == NULL)
(*resultp)->error = i_strdup(error);
result_finish(*resultp);
{
struct cassandra_result *result = (struct cassandra_result *)_result;
- return array_idx(&result->fields, 0);
+ return array_first(&result->fields);
}
static const char *driver_cassandra_result_get_error(struct sql_result *_result)
{
struct test_sql_db *db = (struct test_sql_db*)_db;
struct test_driver_result *result =
- array_idx_modifiable(&db->expected, 0);
+ array_first_modifiable(&db->expected);
i_assert(result->cur < result->nqueries);
/* i_debug("DUMMY EXECUTE: %s", query);
{
struct test_sql_db *db = (struct test_sql_db*)_db;
struct test_driver_result *result =
- array_idx_modifiable(&db->expected, 0);
+ array_first_modifiable(&db->expected);
struct test_sql_result *res = i_new(struct test_sql_result, 1);
driver_test_exec(_db, query);
{
struct test_sql_db *db= (struct test_sql_db*)ctx->db;
struct test_driver_result *result =
- array_idx_modifiable(&db->expected, 0);
+ array_first_modifiable(&db->expected);
driver_test_exec(ctx->db, query);
if (affected_rows != NULL)
}
if (array_count(&ctx->primary_file_ids) > 0) {
const struct seq_range *range =
- array_idx(&ctx->primary_file_ids, 0);
+ array_first(&ctx->primary_file_ids);
ctx->lowest_primary_file_id = range[0].seq1;
}
if (errno != 0) {
unsigned int highest_pop3_uidl_idx;
uint32_t uid;
- mails = array_idx(&ctx->mails, 0);
+ mails = array_first(&ctx->mails);
highest_pop3_uidl_idx =
ctx->ctx.highest_pop3_uidl_seq - mails[0].seq;
i_assert(mails[highest_pop3_uidl_idx].seq == ctx->ctx.highest_pop3_uidl_seq);
unsigned int i, count, names_count;
if (array_is_created(&data->keywords))
- return array_idx(&data->keywords, 0);
+ return array_first(&data->keywords);
(void)index_mail_get_keyword_indexes(_mail);
/* end with NULL */
array_append_zero(&data->keywords);
- return array_idx(&data->keywords, 0);
+ return array_first(&data->keywords);
}
const ARRAY_TYPE(keyword_indexes) *
if (!index_sort_list_next(_ctx->sort_program, &seq))
return FALSE;
- mailp = array_idx(&ctx->mails, 0);
+ mailp = array_first(&ctx->mails);
mail_set_seq(*mailp, seq);
index_mail_update_access_parts_pre(*mailp);
index_mail_update_access_parts_post(*mailp);
const struct mail_index_sync_rec *syncs;
unsigned int i;
- syncs = array_idx(&ctx->syncs, 0);
+ syncs = array_first(&ctx->syncs);
for (i = 0; i < count; i++) {
if (syncs[i].type == MAIL_INDEX_SYNC_TYPE_EXPUNGE) {
memcpy(expunged_guid_128_r, syncs[i].guid_128,
} while (root->parent_root_idx1 != 0);
i_assert(!root->ignore);
- shadows = array_idx_modifiable(&ctx->shadow_nodes, 0);
+ shadows = array_first_modifiable(&ctx->shadow_nodes);
if (cur->dummy) {
/* If both messages are dummies, append the current
message's children to the children of the message in
if (roots[i].parent_root_idx1 != 0 && !roots[i].ignore) {
mail_thread_root_thread_merge(ctx, &roots[i]);
/* more roots may have been added */
- roots = array_idx_modifiable(&ctx->roots, 0);
+ roots = array_first_modifiable(&ctx->roots);
changed = TRUE;
}
}
roots = array_get_modifiable(&ctx->roots, &root_count);
/* drop childless dummy nodes */
- shadows = array_idx(&ctx->shadow_nodes, 0);
+ shadows = array_first(&ctx->shadow_nodes);
for (idx = 1; idx < root_count; idx++) {
if (roots[idx].dummy &&
shadows[roots[idx].node.idx].first_child_idx == 0)
i_assert(reply != NULL);
i_assert(array_count(&client->commands) > 0);
- cmd = array_idx_modifiable(&client->commands, 0);
+ cmd = array_first_modifiable(&client->commands);
if (cmd->input != NULL && state == POP3C_COMMAND_STATE_OK &&
!cmd->reading_dot) {
/* read the full input into seekable-istream before calling
if (array_count(&pq->items) == 0)
return NULL;
- items = array_idx(&pq->items, 0);
+ items = array_first(&pq->items);
return items[0];
}
if (array_count(&pq->items) == 0)
return NULL;
- return array_idx(&pq->items, 0);
+ return array_first(&pq->items);
}
if (notify->io_write == NULL)
return;
- processes = array_idx_modifiable(¬ify->processes, 0);
+ processes = array_first_modifiable(¬ify->processes);
count = aqueue_count(notify->process_queue);
for (i = 0; i < count; i++) {
process = processes[aqueue_idx(notify->process_queue, i)];
struct service_process *const *processes, *process;
while (aqueue_count(notify->process_queue) > 0) {
- processes = array_idx_modifiable(¬ify->processes, 0);
+ processes = array_first_modifiable(¬ify->processes);
process = processes[aqueue_idx(notify->process_queue, 0)];
if (notify->write_callback(notify->fd, process) < 0) {
unsigned int *count_r)
{
*count_r = array_count(&cache->right_idx_name_map);
- return array_idx(&cache->right_idx_name_map, 0);
+ return array_first(&cache->right_idx_name_map);
}
static void
hash_table_destroy(&solr_lookup_context.mailboxes);
array_append_zero(&solr_lookup_context.results);
- *box_results_r = array_idx_modifiable(&solr_lookup_context.results, 0);
+ *box_results_r = array_first_modifiable(&solr_lookup_context.results);
return parse_ret;
}
memcpy(rec->guid, mailbox->guid, sizeof(rec->guid));
/* uint32_t expunge_uid_ranges[]; */
- buffer_append(output, array_idx(&mailbox->uids, 0),
+ buffer_append(output, array_first(&mailbox->uids),
array_count(&mailbox->uids) *
sizeof(struct seq_range));
/* uint32_t expunge_count; */
test_assert(strcmp(binary_to_hex(key_id->data, key_id->used), pubid1) == 0);
const struct mail_crypt_global_private_key *key =
- array_idx(&keys.private_keys, 0);
+ array_first(&keys.private_keys);
buffer_set_used_size(key_id, 0);
test_assert(dcrypt_key_id_private(key->key, MAIL_CRYPT_KEY_ID_ALGORITHM, key_id, &error) == TRUE);
return;
}
/* use the first quota root for everything */
- refresh_root = array_idx(&refresh->roots, 0);
+ refresh_root = array_first(&refresh->roots);
array_foreach("a->roots, rootp) {
if ((*rootp)->backend.name == quota_backend_imapc.name) {
anything we didn't expect. */
while (array_count(&root->refresh.roots) > 0) {
const struct imapc_quota_refresh_root *refresh_root =
- array_idx(&root->refresh.roots, 0);
+ array_first(&root->refresh.roots);
if (strcmp(refresh_root->name, root->root_name) == 0)
break;
array_delete(&root->refresh.roots, 0, 1);
if (!virtual_sync_find_seqs(bbox, &sync_rec,
&idx1, &idx2))
break;
- uidmap = array_idx(&bbox->uids, 0);
+ uidmap = array_first(&bbox->uids);
for (; idx1 <= idx2; idx1++) {
vuid = uidmap[idx1].virtual_uid;
if (vuid == 0) {
env_put(*envs);
}
- args = array_idx(&exec_args, 0);
+ args = array_first(&exec_args);
execvp_const(args[0], args);
}