From ddd0e2aa854c23ecdaf6e620f7fc38a81effbd1b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 14 Sep 1997 20:14:54 +0000 Subject: Simplify the length handling. svn path=/trunk/; revision=1339 --- driver.c | 10 +++++----- etrn.c | 1 - fetchmail.h | 1 - imap.c | 5 +++-- pop2.c | 1 - pop3.c | 19 ++++++++++++------- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/driver.c b/driver.c index 7d674ef7..e7320f13 100644 --- a/driver.c +++ b/driver.c @@ -1552,12 +1552,12 @@ const struct method *proto; /* protocol method table */ force_retrieval = !peek_capable && (ctl->errcount > 0); /* - * We may need to get sizes in order to check message - * limits. Or it may be forced because the fetch methods - * don't return reliable sizes. + * We need the size of each method before it's loaded in + * order to pass via the ESMTP SIZE option. If the protocol + * has a getsizes method, we presume this means it doesn't + * get reliable sizes from message fetch responses. */ - msgsizes = (int *)NULL; - if (proto->getsizes && (proto->force_getsizes || ctl->limit > 0)) + if (proto->getsizes) { msgsizes = (int *)alloca(sizeof(int) * count); diff --git a/etrn.c b/etrn.c index 36a2e037..bafaa04e 100644 --- a/etrn.c +++ b/etrn.c @@ -153,7 +153,6 @@ const static struct method etrn = 25, /* standard SMTP port */ FALSE, /* this is not a tagged protocol */ FALSE, /* this does not use a message delimiter */ - FALSE, /* no getsizes method */ etrn_ok, /* parse command response */ NULL, /* no need to get authentication */ etrn_getrange, /* initialize message sending */ diff --git a/fetchmail.h b/fetchmail.h index 3fbb1cb9..9cc13b46 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -159,7 +159,6 @@ struct method int port; /* service port */ flag tagged; /* if true, generate & expect command tags */ flag delimited; /* if true, accept "." message delimiter */ - flag force_getsizes; /* if true, fetch's size return unreliable */ int (*parse_response)(); /* response_parsing function */ int (*getauth)(); /* authorization fetcher */ int (*getrange)(); /* get message range to fetch */ diff --git a/imap.c b/imap.c index 3b25c6ec..0668ff36 100644 --- a/imap.c +++ b/imap.c @@ -443,6 +443,7 @@ static int imap_getrange(int sock, return(PS_SUCCESS); } +#ifdef __UNUSED__ static int imap_getsizes(int sock, int count, int *sizes) /* capture the sizes of all messages */ { @@ -465,6 +466,7 @@ static int imap_getsizes(int sock, int count, int *sizes) return(PS_SUCCESS); } +#endif /* __UNUSED__ */ static int imap_is_old(int sock, struct query *ctl, int number) /* is the given message old? */ @@ -644,11 +646,10 @@ const static struct method imap = 143, /* standard IMAP2bis/IMAP4 port */ TRUE, /* this is a tagged protocol */ FALSE, /* no message delimiter */ - FALSE, /* fetch response size is reliable */ imap_ok, /* parse command response */ imap_getauth, /* get authorization */ imap_getrange, /* query range of messages */ - imap_getsizes, /* grab message sizes */ + NULL, /* we can get message sizes from individual messages */ imap_is_old, /* no UID check */ imap_fetch_headers, /* request given message headers */ imap_fetch_body, /* request given message body */ diff --git a/pop2.c b/pop2.c index 170c07ac..b1ba8dfe 100644 --- a/pop2.c +++ b/pop2.c @@ -120,7 +120,6 @@ const static struct method pop2 = 109, /* standard POP2 port */ FALSE, /* this is not a tagged protocol */ FALSE, /* does not use message delimiter */ - FALSE, /* no getsizes method */ pop2_ok, /* parse command response */ pop2_getauth, /* get authorization */ pop2_getrange, /* query range of messages */ diff --git a/pop3.c b/pop3.c index 6411c48d..4f206d7b 100644 --- a/pop3.c +++ b/pop3.c @@ -433,20 +433,26 @@ static int pop3_fetch(int sock, struct query *ctl, int number, int *lenp) #ifdef __UNUSED__ /* * Look for "nnn octets" -- there may or may not be preceding cruft. - * It's OK to punt and pass back -1 as a failure indication here, as - * long as the force_getsizes flag has forced sizes to be preloaded. + * This works with Eudora qpopper and some other common servers. + * It's OK to punt and pass back -1 as a failure indication here. */ - if ((cp = strstr(buf, " octets")) == (char *)NULL) - *lenp = -1; - else + if ((cp = strstr(buf, " octets")) != (char *)NULL) { while (--cp >= buf && isdigit(*cp)) continue; *lenp = atoi(++cp); } + else + *lenp = -1; #endif /* __UNUSED__ */ - *lenp = -1; /* POP3 is delimited, we don't care about lengths */ + /* + * POP3 is delimited, we don't care about lengths. + * Editorial comment: it's really bogus that standard POP3 + * doesn't give you a length in the fetch response, before + * the message. Even freakin' *POP2* got this right! + */ + *lenp = -1; return(0); } @@ -476,7 +482,6 @@ const static struct method pop3 = 110, /* standard POP3 port */ FALSE, /* this is not a tagged protocol */ TRUE, /* this uses a message delimiter */ - TRUE, /* RFC 1725 doesn't require a size field in fetch */ pop3_ok, /* parse command response */ pop3_getauth, /* get authorization */ pop3_getrange, /* query range of messages */ -- cgit v1.2.3