From 5bd3f8287149511024b95c01fb4212e60ec6fe13 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 19 Oct 1996 16:31:33 +0000 Subject: Major improvements in --check processing. New-message count is now visible. svn path=/trunk/; revision=353 --- pop3.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'pop3.c') diff --git a/pop3.c b/pop3.c index 466926cd..187deec8 100644 --- a/pop3.c +++ b/pop3.c @@ -115,11 +115,11 @@ char *greeting; return(0); } -static pop3_getrange(socket, queryctl, countp) +static pop3_getrange(socket, queryctl, countp, newp) /* get range of messages to be fetched */ int socket; struct hostrec *queryctl; -int *countp; +int *countp, *newp; { int ok; char buf [POPBUFSIZE+1]; @@ -137,8 +137,11 @@ int *countp; /* * Newer, RFC-1725-conformant POP servers may not have the LAST command. + * We work as hard as possible to hide this ugliness, but it makes + * counting new messages intrinsically quadratic in the worst case. */ last = 0; + *newp = -1; if (*countp > 0 && !queryctl->fetchall) { char id [IDLEN+1]; @@ -149,12 +152,15 @@ int *countp; { if (sscanf(buf, "%d", &last) == 0) return(PS_ERROR); + *newp = (*countp - last); } else { int num; + struct idlist *idp; /* grab the mailbox's UID list */ + *newp = 0; gen_send(socket, "UIDL"); if ((ok = pop3_ok(socket, buf)) == 0) { while (SockGets(socket, buf, sizeof(buf)) >= 0) { @@ -164,7 +170,11 @@ int *countp; break; } if (sscanf(buf, "%d %s", &num, id) == 2) + { save_uid(&queryctl->newsaved, num, id); + if (!uid_in_list(&queryctl->oldsaved, id)) + (*newp)++; + } } } } -- cgit v1.2.3