mail-messageset.c revision 73637408663279c5a3df51efcd573b9760ede15f
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "mail-index.h"
#include "mail-index-util.h"
#include "mail-hash.h"
#include "mail-modifylog.h"
#include "mail-messageset.h"
static unsigned int get_next_number(const char **str)
{
unsigned int num;
num = 0;
while (**str != '\0') {
break;
(*str)++;
}
return num;
}
const char **error)
{
const unsigned int *expunges;
unsigned int expunges_before;
int expunges_found;
/* Second sequence can't be smaller than first - we could swap
them but I think it's a bug in client if it does this,
and better complain about it immediately than later let
them wonder why it doesn't work with other imapds.. */
return -2;
}
/* get list of expunged messages in our range. the expunges_before
can be used to calculate the current real sequence position */
/* Reset index errors, since we later rely on it to check if failed */
/* get the first non-expunged message. note that if all messages
were expunged in the range, this points outside wanted range. */
/* skip expunged sequences */
expunges++;
seq++;
}
break;
t_push();
t_pop();
return 0;
}
t_pop();
}
/* error occured */
return -1;
}
}
unsigned int messages_count,
const char **error)
{
const char *input;
if (messages_count == 0) {
/* no messages in mailbox */
return 1;
}
input = messageset;
while (*input != '\0') {
if (*input == '*') {
/* last message */
input++;
} else {
if (seq == 0) {
messageset, NULL);
return -2;
}
}
if (*input != ':')
else {
/* first:last range */
input++;
if (*input != '*') {
if (seq2 == 0) {
"messageset: ",
messageset, NULL);
return -2;
}
if (seq2 > messages_count) {
/* too large .. ignore silently */
}
} else {
input++;
}
}
if (*input == ',')
input++;
else if (*input != '\0') {
"with messageset: %s",
*input, messageset);
return -2;
}
if (seq > messages_count) {
/* too large .. ignore silently */
} else {
if (ret <= 0)
return ret;
if (ret == 2)
}
}
}
unsigned int max_sequence,
const char **error)
{
const unsigned int *expunges;
unsigned int seq;
int expunges_found;
/* not allowed - see mail_index_foreach() */
return -2;
}
/* get list of expunged messages in our range. */
/* skip expunged messages at the beginning */
expunges++;
/* all were expunged */
return 2;
}
}
/* since we skipped the known expunged messages at the beginning
and our UIDs are contiguously allocated, the first hash lookup
_should_ work.. */
if (pos != 0) {
/* hash is corrupted */
"lookup returned offset outside range",
return -1;
}
/* hash is corrupted */
"lookup returned offset to different "
return -1;
}
} else {
/* ..however if for any reason it doesn't,
still handle it properly */
return 2;
return 2;
}
expunges++;
seq++;
}
t_push();
t_pop();
return 0;
}
t_pop();
seq++;
}
/* error occured */
return -1;
}
return 1;
}
unsigned int messages_count,
const char **error)
{
const char *input;
int ret;
if (messages_count == 0) {
/* no messages in mailbox */
return 1;
}
while (*input != '\0') {
if (*input == '*') {
/* last message */
input++;
} else {
if (uid == 0) {
return -2;
}
}
if (*input != ':')
else {
/* first:last range */
input++;
if (*input != '*') {
if (uid2 == 0) {
return -2;
}
} else {
input++;
}
}
if (*input == ',')
input++;
else if (*input != '\0') {
return -2;
}
/* too large .. ignore silently */
} else {
if (ret <= 0)
return ret;
}
}
return 1;
}