From 0d8a8b913f6a15088523bc69cbcf6240de945cda Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 15 Oct 2003 19:26:58 +0000 Subject: Sunil's transaction patches. svn path=/trunk/; revision=3858 --- imap.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'imap.c') diff --git a/imap.c b/imap.c index e3a6f4ec..13bc170d 100644 --- a/imap.c +++ b/imap.c @@ -785,8 +785,8 @@ static int imap_getrange(int sock, return(PS_SUCCESS); } -static int imap_getsizes(int sock, int count, int *sizes) -/* capture the sizes of all messages */ +static int imap_getpartialsizes(int sock, int first, int last, int *sizes) +/* capture the sizes of messages #first-#last */ { char buf [MSGBUFSIZE+1]; @@ -824,14 +824,15 @@ static int imap_getsizes(int sock, int count, int *sizes) * on the fact that the sizes array has been preinitialized with a * known-bad size value. */ - /* if fetchall is specified, startcount is 1; - * else if there is new mail, startcount is first unseen message; - * else startcount is greater than count. - */ - if (count == startcount) - gen_send(sock, "FETCH %d RFC822.SIZE", count); - else if (count > startcount) - gen_send(sock, "FETCH %d:%d RFC822.SIZE", startcount, count); + + /* expunges change the fetch numbers */ + first -= expunged; + last -= expunged; + + if (last == first) + gen_send(sock, "FETCH %d RFC822.SIZE", last); + else if (last > first) + gen_send(sock, "FETCH %d:%d RFC822.SIZE", first, last); else /* no unseen messages! */ return(PS_SUCCESS); for (;;) @@ -852,8 +853,8 @@ static int imap_getsizes(int sock, int count, int *sizes) break; else if (sscanf(buf, "* %u FETCH (RFC822.SIZE %u)", &num, &size) == 2) { - if (num > 0 && num <= count) - sizes[num - 1] = size; + if (num >= first && num <= last) + sizes[num - first] = size; else report(stderr, "Warning: ignoring bogus data for message sizes returned by the server.\n"); } @@ -862,6 +863,12 @@ static int imap_getsizes(int sock, int count, int *sizes) return(PS_SUCCESS); } +static int imap_getsizes(int sock, int count, int *sizes) +/* capture the sizes of all messages */ +{ + return imap_getpartialsizes(sock, 1, count, sizes); +} + static int imap_is_old(int sock, struct query *ctl, int number) /* is the given message old? */ { @@ -1119,6 +1126,7 @@ const static struct method imap = imap_getauth, /* get authorization */ imap_getrange, /* query range of messages */ imap_getsizes, /* get sizes of messages (used for ESMTP SIZE option) */ + imap_getpartialsizes, /* get sizes of subset of messages (used for ESMTP SIZE option) */ imap_is_old, /* no UID check */ imap_fetch_headers, /* request given message headers */ imap_fetch_body, /* request given message body */ -- cgit v1.2.3