#include "i18n.h"
-#if OPIE_ENABLE
-#endif /* OPIE_ENABLE */
-
-#ifndef strstr /* glibc-2.1 declares this as a macro */
-extern char *strstr(); /* needed on sysV68 R3V7.1. */
-#endif /* strstr */
-
/* imap_version values */
#define IMAP2 -1 /* IMAP2 or IMAP2BIS, RFC1176 */
#define IMAP4 0 /* IMAP4 rev 0, RFC1730 */
#define IMAP4rev1 1 /* IMAP4 rev 1, RFC2060 */
static int count = 0, recentcount = 0, unseen = 0, deletions = 0;
+static int recentcount_ok = 0;
static unsigned int startcount = 1;
static int expunged, expunge_period, saved_timeout = 0;
static int imap_version, preauth;
/* all tokens in responses are caseblind */
for (cp = buf; *cp; cp++)
- if (islower(*cp))
- *cp = toupper(*cp);
+ if (islower((unsigned char)*cp))
+ *cp = toupper((unsigned char)*cp);
/* interpret untagged status responses */
if (strstr(buf, "* CAPABILITY"))
/* a space is required to avoid confusion with the \Recent flag */
else if (strstr(buf, " RECENT"))
{
+ recentcount_ok = 1;
recentcount = atoi(buf+2);
}
+ else if (strstr(buf, "EXPUNGE") && !strstr(buf, "OK"))
+ {
+ count -= atoi(buf+2);
+ if (count < 0)
+ count = 0;
+ }
else if (strstr(buf, "PREAUTH"))
preauth = TRUE;
/*
char *cp;
/* skip the tag */
- for (cp = buf; !isspace(*cp); cp++)
+ for (cp = buf; !isspace((unsigned char)*cp); cp++)
continue;
- while (isspace(*cp))
+ while (isspace((unsigned char)*cp))
cp++;
if (strncasecmp(cp, "OK", 2) == 0)
}
}
-#if NTLM_ENABLE
+#ifdef NTLM_ENABLE
#include "ntlm.h"
static tSmbNtlmAuthRequest request;
if ((ctl->server.authenticate == A_ANY
|| ctl->server.authenticate == A_GSSAPI)
&& strstr(capabilities, "AUTH=GSSAPI"))
- if(ok = do_gssauth(sock, "AUTHENTICATE", ctl->server.truename, ctl->remotename))
+ if(ok = do_gssauth(sock, "AUTHENTICATE", "imap", ctl->server.truename, ctl->remotename))
{
/* SASL cancellation of authentication */
gen_send(sock, "*");
return ok;
}
-#if OPIE_ENABLE
+#ifdef OPIE_ENABLE
if ((ctl->server.authenticate == A_ANY
|| ctl->server.authenticate == A_OTP)
- && strstr(capabilities, "AUTH=X-OTP"))
+ && strstr(capabilities, "AUTH=X-OTP")) {
if ((ok = do_otp(sock, "AUTHENTICATE", ctl)))
{
/* SASL cancellation of authentication */
gen_send(sock, "*");
if(ctl->server.authenticate != A_ANY)
return ok;
- }
- else
+ } else {
return ok;
+ }
+ }
#else
if (ctl->server.authenticate == A_OTP)
{
imap_canonicalize(remotename, ctl->remotename, NAMELEN);
imap_canonicalize(password, ctl->password, PASSWORDLEN);
-#ifdef HAVE_SNPRINTF
snprintf(shroud, sizeof (shroud), "\"%s\"", password);
-#else
- strcpy(shroud, "\"");
- strcat(shroud, password);
- strcat(shroud, "\"");
-#endif
ok = gen_transact(sock, "LOGIN \"%s\" \"%s\"", remotename, password);
shroud[0] = '\0';
#ifdef SSL_ENABLE
{
int ok;
+ recentcount_ok = 0;
+
if ((ok = gen_transact(sock, "EXPUNGE")))
return(ok);
+ /* some servers do not report RECENT after an EXPUNGE. in this case,
+ * the previous value of recentcount is just ignored. */
+ if (!recentcount_ok)
+ recentcount = 0;
+
expunged += deletions;
deletions = 0;
* for new mail.
*/
- /* some servers do not report RECENT after an EXPUNGE. this check
- * forces an incorrect recentcount to be ignored. */
- if (recentcount > count)
- recentcount = 0;
/* this is a while loop because imap_idle() might return on other
* mailbox changes also */
while (recentcount == 0 && do_idle) {
if (recentcount == 0)
count = 0;
if (outlevel >= O_DEBUG)
- report(stdout, GT_("%d messages waiting after re-poll\n"), count);
+ report(stdout, ngettext("%d message waiting after re-poll\n",
+ "%d messages waiting after re-poll\n",
+ count), count);
}
else
{
return(ok);
}
else if (outlevel >= O_DEBUG)
- report(stdout, GT_("%d messages waiting after first poll\n"), count);
+ report(stdout, ngettext("%d message waiting after first poll\n",
+ "%d messages waiting after first poll\n",
+ count), count);
/* no messages? then we may need to idle until we get some */
while (count == 0 && do_idle) {
return(ok);
}
if (outlevel >= O_DEBUG)
- report(stdout, GT_("%d messages waiting after expunge\n"), count);
+ report(stdout, ngettext("%d message waiting after expunge\n",
+ "%d messages waiting after expunge\n",
+ count), count);
}
}
while (*cp && unseen < count)
{
/* skip whitespace */
- while (*cp && isspace(*cp))
+ while (*cp && isspace((unsigned char)*cp))
cp++;
if (*cp)
{
static char *skip_token(char *ptr)
{
- while(isspace(*ptr)) ptr++;
- while(!isspace(*ptr) && !iscntrl(*ptr)) ptr++;
- while(isspace(*ptr)) ptr++;
+ while(isspace((unsigned char)*ptr)) ptr++;
+ while(!isspace((unsigned char)*ptr) && !iscntrl((unsigned char)*ptr)) ptr++;
+ while(isspace((unsigned char)*ptr)) ptr++;
return(ptr);
}
return(gen_transact(sock, "LOGOUT"));
}
-const static struct method imap =
+static const struct method imap =
{
"IMAP", /* Internet Message Access Protocol */
-#if INET6_ENABLE
+#ifdef INET6_ENABLE
"imap",
"imaps",
#else /* INET6_ENABLE */