aboutsummaryrefslogtreecommitdiffstats
path: root/pop3.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-10-10 21:45:42 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-10-10 21:45:42 +0000
commit6e539dabb45ba4066f2bfbfa652b8bf375e8358e (patch)
tree533dd3834996672cf33b0ce0b9d65b2ee3f3b4c5 /pop3.c
parent473437ebe5a57fc2d4bfd782ecc004394f339033 (diff)
downloadfetchmail-6e539dabb45ba4066f2bfbfa652b8bf375e8358e.tar.gz
fetchmail-6e539dabb45ba4066f2bfbfa652b8bf375e8358e.tar.bz2
fetchmail-6e539dabb45ba4066f2bfbfa652b8bf375e8358e.zip
UIDs, phase 2.
svn path=/trunk/; revision=287
Diffstat (limited to 'pop3.c')
-rw-r--r--pop3.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/pop3.c b/pop3.c
index 2edbb907..592a5c7c 100644
--- a/pop3.c
+++ b/pop3.c
@@ -149,8 +149,29 @@ int *countp;
gen_send(socket,"LAST");
ok = pop3_ok(socket, buf);
- if (ok == 0 && sscanf(buf, "%d", &last) == 0)
- return(PS_ERROR);
+ if (ok == 0)
+ {
+ if (sscanf(buf, "%d", &last) == 0)
+ return(PS_ERROR);
+ }
+ else
+ {
+ int num;
+
+ /* grab the mailbox's UID list */
+ gen_send(socket, "UIDL");
+ if ((ok = pop3_ok(buf, socket)) == 0) {
+ while (SockGets(socket, buf, sizeof(buf)) >= 0) {
+ if (outlevel == O_VERBOSE)
+ fprintf(stderr,"%s\n",buf);
+ if (strcmp(buf, ".\n") == 0) {
+ break;
+ }
+ if (sscanf(buf, "%d %s\n", &num, id) == 2)
+ save_uid(&queryctl->unseen, num, id);
+ }
+ }
+ }
}
return(0);
@@ -161,7 +182,26 @@ int socket;
struct hostrec *queryctl;
int num;
{
- return (num <= last);
+ if (!queryctl->saved)
+ return (num <= last);
+ else
+ {
+ char buf [POPBUFSIZE+1];
+ int ok;
+
+ gen_send(socket, "UIDL %d", num);
+ if ((ok = pop3_ok(socket, buf)) != 0)
+ return(ok);
+ else
+ {
+ char id[IDLEN+1];
+
+ if (sscanf(buf, "%*d %s", id) == 2)
+ return(uid_in_list(&queryctl->saved, id));
+ else
+ return(0);
+ }
+ }
}
static int pop3_fetch(socket, number, lenp)