mbox-index.c revision 934d42dec29def3fc2b070932f2a7247ec2eea8a
e59faf65ce864fe95dc00f5d52b8323cdbd0608aTimo Sirainen/* Copyright (C) 2002 Timo Sirainen */
f7539a17ea306191b53b8f5e752e228937df9ec3Timo Sirainen/* Don't try reading more custom flags than this. */
f7539a17ea306191b53b8f5e752e228937df9ec3Timo Sirainenint mbox_set_syscall_error(struct mail_index *index, const char *function)
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen index_set_error(index, "%s failed with mbox file %s: %m",
e5fd6dfd0a492e4708d4dbb7971d7fc5d7b8fd85Timo Sirainen fd = open(index->mailbox_path, index->mailbox_readonly ?
d22301419109ed4a38351715e6760011421dadecTimo Sirainenstruct istream *mbox_get_stream(struct mail_index *index, uoff_t offset,
d22301419109ed4a38351715e6760011421dadecTimo Sirainen /* don't drop exclusive lock, it may be there for a reason */
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen if (index->mbox_lock_type != MAIL_LOCK_EXCLUSIVE) {
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen i_stream_set_read_limit(index->mbox_stream, 0);
3c493c276f599d9b9cd10764876d648003046954Timo Sirainen i_stream_set_start_offset(index->mbox_stream, (uoff_t)offset);
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainenvoid mbox_file_close_stream(struct mail_index *index)
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainenvoid mbox_file_close_fd(struct mail_index *index)
dca6d617a23e3f93af3b8df59acb46478179fe55Timo Sirainenvoid mbox_header_init_context(struct mbox_header_context *ctx,
3e564425db51f3921ce4de11859777135fdedd15Timo Sirainen memset(ctx, 0, sizeof(struct mbox_header_context));
7bafda1813454621e03615e83d55bccfa7cc56bdTimo Sirainen ctx->custom_flags = mail_custom_flags_list_get(index->custom_flags);
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainenvoid mbox_header_free_context(struct mbox_header_context *ctx __attr_unused__)
2649b237dd4690575e75a30b2bf3b39ebd37b835Timo Sirainenmbox_get_status_flags(const unsigned char *value, size_t len)
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen for (i = 0; i < len; i++) {
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen switch (value[i]) {
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainenstatic void mbox_update_custom_flags(const unsigned char *value __attr_unused__,
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen *flags |= 1 << (index + MAIL_CUSTOM_FLAG_1_BIT);
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainenmbox_get_keyword_flags(const unsigned char *value, size_t len,
flags = 0;
return flags;
char *end;
unsigned int count;
int ret;
t_push();
pos++;
t_pop();
MAX_CUSTOM_FLAGS * sizeof(const char *));
t_pop();
size_t i;
if (fixed)
void *context)
value++;
len--;
if (len == 0)
for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++) {
value++;
len--;
if (len == 0)
for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++) {
if (i == MAIL_CUSTOM_FLAGS_COUNT)
const unsigned char *data;
pos = 0;
if (pos == 0) {
return TRUE;
return FALSE;
pos++;
return FALSE;
return TRUE;
return TRUE;
const unsigned char *data;
for (i = 0; i < size; i++) {
if (i < size)
const unsigned char *msg;
i = startpos;
for (; i < size; i++) {
i -= startpos;
return FALSE;
const unsigned char *msg;
new_state = 0;
switch (state) {
else if (header) {
int valid;
if (valid) {
if (new_state != 0)
else if (eoh == 0)
i -= startpos;
if (eoh != 0) {
eoh -= i;
if (eoh != 0) {
startpos--;
startpos--;
const unsigned char *data;
return FALSE;
return TRUE;
return FALSE;
if (size > 0) {
return FALSE;
return size == 0 ||
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return TRUE;
struct mail_index *
const char *control_dir)
return index;
return FALSE;
return TRUE;
int external_change)
return FALSE;
if (!external_change) {
return TRUE;
return FALSE;
return TRUE;