static int count, seen, recent, unseen, deletecount, imap_version;
-int imap_ok (int sock, char *argbuf)
+int imap_ok(int sock, char *argbuf)
/* parse command response */
{
char buf [POPBUFSIZE+1];
*/
unseen = 0;
for (cp = buf; *cp && !isdigit(*cp); cp++)
- {
- unseen = atoi(cp);
- break;
- }
+ continue;
+ unseen = atoi(cp);
}
if (strstr(buf, "FLAGS"))
seen = (strstr(buf, "Seen") != (char *)NULL);
if (tag[0] == '\0')
{
- strcpy(argbuf, buf);
+ if (argbuf)
+ strcpy(argbuf, buf);
return(PS_SUCCESS);
}
else
if (strncmp(cp, "OK", 2) == 0)
{
- strcpy(argbuf, cp);
+ if (argbuf)
+ strcpy(argbuf, cp);
return(PS_SUCCESS);
}
else if (strncmp(cp, "BAD", 2) == 0)
error(0, 0, "Protocol identified as IMAP4 rev 0");
}
- peek_capable = (imap_version >= IMAP4);
+ /* eat the tail of the CAPABILITY response (if any) */
+ if ((peek_capable = (imap_version >= IMAP4)))
+ if ((ok = imap_ok(sock, (char *)NULL)))
+ return(ok);
#ifdef KERBEROS_V4
if (strstr(rbuf, "AUTH=KERBEROS_V4"))
char buf [POPBUFSIZE+1];
gen_send(sock, "FETCH 1:%d RFC822.SIZE", count);
- while (SockRead(sock, buf, sizeof(buf)))
+ for (;;)
{
int num, size, ok;
return(PS_SUCCESS);
}
-static flag imap_retain_check(int num, char *buf)
-/* is this a special message that should be retained? */
-{
- /*
- * The University of Washington IMAP server (the reference
- * implementation of IMAP4 written by Mark Crispin) relies
- * on being able to keep base-UID information in a special
- * message at the head of the mailbox. This message should
- * neither be deleted nor forwarded.
- */
- return (num == 1 && !strncasecmp(buf, "X-IMAP:", 7));
-}
-
const static struct method imap =
{
"IMAP", /* Internet Message Access Protocol */
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 */
+ imap_getsizes, /* get sizes of messages (used for --limit option */
imap_is_old, /* no UID check */
imap_fetch_headers, /* request given message headers */
imap_fetch_body, /* request given message body */
imap_trail, /* eat message trailer */
imap_delete, /* delete the message */
- imap_retain_check, /* leave this message alone? */
"LOGOUT", /* the IMAP exit command */
};