Commit 9febf2c9 authored by Thomas Roessler's avatar Thomas Roessler

Brendan Cully's latest IMAP clean-up.

parent d79ed355
......@@ -6,6 +6,16 @@
AUTOMAKE_OPTIONS = foreign
EXTRA_PROGRAMS = mutt_dotlock pgpring
if BUILD_CHARMAPS
CHARMAP_SUBDIR = charmaps
endif
if BUILD_IMAP
IMAP_SUBDIR = imap
endif
SUBDIRS = m4 po intl doc contrib $(CHARMAP_SUBDIR) $(IMAP_SUBDIR)
if NEEDS_PGPEWRAP
bin_SCRIPTS = pgpewrap
else
......@@ -16,7 +26,7 @@ BUILT_SOURCES = keymap_defs.h
bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
mutt_SOURCES = $(BUILT_SOURCES) \
addrbook.c alias.c attach.c browser.c buffy.c color.c \
addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
handler.c hash.c hdrline.c headers.c help.c hook.c keymap.c \
......@@ -27,7 +37,7 @@ mutt_SOURCES = $(BUILT_SOURCES) \
status.c system.c thread.c charset.c history.c lib.c \
muttlib.c
mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(INTLLIBS)
mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(INTLLIBS)
mutt_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(INTLDEPS)
DEFS=-DSHAREDIR=\"$(sharedir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
......@@ -41,14 +51,13 @@ non_us_sources = pgp.c pgpinvoke.c pgpkey.c pgplib.c sha1dgst.c \
contrib/pgp2.rc contrib/pgp5.rc contrib/gpg.rc
EXTRA_mutt_SOURCES = pgp.c pgpinvoke.c pgpkey.c pgplib.c sha1dgst.c \
gnupgparse.c resize.c dotlock.c pop.c imap.c socket.c
remailer.c remailer.h browser.h
gnupgparse.c resize.c dotlock.c pop.c remailer.c remailer.h browser.h
EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h attach.h \
buffy.h charset.h config.h copy.h dotlock.h functions.h gen_defs \
globals.h hash.h history.h imap.h init.h keymap.h \
globals.h hash.h history.h init.h keymap.h \
mailbox.h mapping.h mime.h mutt.h mutt_curses.h mutt_menu.h \
mutt_regex.h mutt_socket.h mx.h pager.h parse.h pgp.h protos.h \
mutt_regex.h mx.h pager.h parse.h pgp.h protos.h \
reldate.h rfc1524.h rfc2047.h rfc2231.h rfc822.h sha.h sha_locl.h \
sort.h mime.types VERSION prepare _regex.h OPS.MIX \
README.SECURITY remailer.c remailer.h browser.h \
......@@ -73,8 +82,6 @@ ACLOCAL_AMFLAGS = -I m4
LDADD = @LIBOBJS@ @INTLLIBS@
SUBDIRS = m4 po intl doc contrib $(ADD_SUBDIRS)
OPS=@OPS@
keymap_defs.h: $(OPS) $(srcdir)/gen_defs
......
/*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
* 02139, USA.
*/
/* Base64 handling elsewhere in mutt should be modified to call these
* routines. These routines were written because IMAP's AUTHENTICATE
* protocol required them, and base64 handling elsewhere wasn't
* sufficiently generic. */
/* This code is heavily modified from fetchmail (also GPL'd, of course) */
#include "mutt.h"
#include "mime.h"
#define BAD -1
/* raw bytes to null-terminated base 64 string */
void mutt_to_base64 (unsigned char *out, const unsigned char *in, int len)
{
while (len >= 3)
{
*out++ = B64Chars[in[0] >> 2];
*out++ = B64Chars[((in[0] << 4) & 0x30) | (in[1] >> 4)];
*out++ = B64Chars[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
*out++ = B64Chars[in[2] & 0x3f];
len -= 3;
in += 3;
}
/* clean up remainder */
if (len > 0)
{
unsigned char fragment;
*out++ = B64Chars[in[0] >> 2];
fragment = (in[0] << 4) & 0x30;
if (len > 1)
fragment |= in[1] >> 4;
*out++ = B64Chars[fragment];
*out++ = (len < 2) ? '=' : B64Chars[(in[1] << 2) & 0x3c];
*out++ = '=';
}
*out = '\0';
}
/* Convert '\0'-terminated base 64 string to raw bytes.
* Returns length of returned buffer, or -1 on error */
int mutt_from_base64 (char *out, const char *in)
{
int len = 0;
register unsigned char digit1, digit2, digit3, digit4;
do
{
digit1 = in[0];
if (digit1 > 127 || base64val (digit1) == BAD)
return -1;
digit2 = in[1];
if (digit2 > 127 || base64val (digit2) == BAD)
return -1;
digit3 = in[2];
if (digit3 > 127 || ((digit3 != '=') && (base64val (digit3) == BAD)))
return -1;
digit4 = in[3];
if (digit4 > 127 || ((digit4 != '=') && (base64val (digit4) == BAD)))
return -1;
in += 4;
/* digits are already sanity-checked */
*out++ = (base64val(digit1) << 2) | (base64val(digit2) >> 4);
len++;
if (digit3 != '=')
{
*out++ = ((base64val(digit2) << 4) & 0xf0) | (base64val(digit3) >> 2);
len++;
if (digit4 != '=')
{
*out++ = ((base64val(digit3) << 6) & 0xc0) | base64val(digit4);
len++;
}
}
}
while (*in && digit4 != '=');
return len;
}
......@@ -392,6 +392,7 @@ if test ! -f $mutt_cv_charmaps/ISO_10646 ; then
mutt_cv_add_subdirs=""
echo "If you want character set support, read INSTALL". >& AC_FD_MSG
fi
need_charmaps=yes
else
AC_MSG_RESULT(yes)
fi
......@@ -406,7 +407,7 @@ fi
AC_DEFINE_UNQUOTED(CHARMAPS_DIR, "$mutt_cv_charmaps")
charmaps=$mutt_cv_charmaps
AC_SUBST(charmaps)
AM_CONDITIONAL(BUILD_CHARMAPS, test x$need_charmaps = xyes)
AC_ARG_WITH(docdir, [ --with-docdir=PATH specify where to put the documentation],
[mutt_cv_docdir=$withval],
......@@ -447,10 +448,14 @@ AC_ARG_ENABLE(pop, [ --enable-pop Enable POP3 support],
AC_ARG_ENABLE(imap, [ --enable-imap Enable IMAP support],
[ AC_DEFINE(USE_IMAP)
AC_PROG_RANLIB
AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS imap.o socket.o"
LIBIMAP="-Limap -limap"
CPPFLAGS="$CPPFLAGS -I\$(srcdir)/imap"
need_imap="yes"
])
AM_CONDITIONAL(BUILD_IMAP, test x$need_imap = xyes)
AC_ARG_ENABLE(debug, [ --enable-debug Enable debugging support],
[ AC_DEFINE(DEBUG) ])
......@@ -504,9 +509,7 @@ AC_ARG_ENABLE(exact-address, [ --enable-exact-address enable regeneration o
fi])
AC_SUBST(MUTT_LIB_OBJECTS)
ADD_SUBDIRS="$mutt_cv_add_subdirs"
AC_SUBST(ADD_SUBDIRS)
AC_SUBST(LIBIMAP)
MUTT_AM_GNU_GETTEXT
CPPFLAGS="$CPPFLAGS -I\$(srcdir)/intl"
......@@ -515,5 +518,6 @@ MUTTLOCALEDIR=$mutt_cv_prefix/$DATADIRNAME/locale
AC_SUBST(MUTTLOCALEDIR)
AC_DEFINE_UNQUOTED(MUTTLOCALEDIR, "$MUTTLOCALEDIR")
AC_OUTPUT(Makefile intl/Makefile m4/Makefile po/Makefile.in doc/Makefile contrib/Makefile charmaps/Makefile)
AC_OUTPUT(Makefile intl/Makefile m4/Makefile dnl
po/Makefile.in doc/Makefile contrib/Makefile dnl
charmaps/Makefile imap/Makefile)
......@@ -33,8 +33,6 @@
#include <ctype.h>
#include <unistd.h> /* needed for SEEK_SET under SunOS 4.1.4 */
extern char MimeSpecials[];
static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date);
/* Ok, the only reason for not merging this with mutt_copy_header()
......
......@@ -48,6 +48,7 @@ WHERE char *Homedir;
WHERE char *Hostname;
#ifdef USE_IMAP
WHERE char *ImapUser INITVAL (NULL);
WHERE char *ImapCRAMKey INITVAL (NULL);
WHERE char *ImapPass INITVAL (NULL);
WHERE short ImapCheckTime;
WHERE char *ImapHomeNamespace INITVAL (NULL);
......
## Process this file with automake to produce Makefile.in
AUTOMAKE_OPTIONS = foreign
noinst_LIBRARIES = libimap.a
noinst_HEADERS = imap_private.h imap_socket.h md5.h
libimap_a_SOURCES = imap.c imap.h auth.c browse.c md5c.c socket.c
/*
* Copyright (C) 1996-8 Michael R. Elkins <me@cs.hmc.edu>
* Copyright (C) 1996-9 Brandon Long <blong@fiction.net>
* Copyright (C) 1999 Brendan Cully <brendan@kublai.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* IMAP login/authentication code */
#include "mutt.h"
#include "imap_private.h"
#include "md5.h"
#define MD5_BLOCK_LEN 64
#define MD5_DIGEST_LEN 16
/* forward declarations */
static void hmac_md5 (const char* password, char* challenge,
unsigned char* response);
static int imap_auth_cram_md5 (IMAP_DATA* idata, const char* user,
const char* pass);
/* hmac_md5: produce CRAM-MD5 challenge response. */
static void hmac_md5 (const char* password, char* challenge,
unsigned char* response)
{
MD5_CTX ctx;
unsigned char ipad[MD5_BLOCK_LEN], opad[MD5_BLOCK_LEN];
unsigned char secret[MD5_BLOCK_LEN+1];
unsigned char hash_passwd[MD5_DIGEST_LEN];
unsigned int secret_len, chal_len;
int i;
secret_len = strlen (password);
chal_len = strlen (challenge);
/* passwords longer than MD5_BLOCK_LEN bytes are substituted with their MD5
* digests */
if (secret_len > MD5_BLOCK_LEN)
{
MD5Init (&ctx);
MD5Update (&ctx, (unsigned char*) password, secret_len);
MD5Final (hash_passwd, &ctx);
strfcpy ((char*) secret, (char*) hash_passwd, MD5_DIGEST_LEN);
secret_len = MD5_DIGEST_LEN;
}
else
strfcpy (secret, password, sizeof (secret));
memset (ipad, 0, sizeof (ipad));
memset (opad, 0, sizeof (opad));
memcpy (ipad, secret, secret_len);
memcpy (opad, secret, secret_len);
for (i = 0; i < MD5_BLOCK_LEN; i++)
{
ipad[i] ^= 0x36;
opad[i] ^= 0x5c;
}
/* inner hash: challenge and ipadded secret */
MD5Init (&ctx);
MD5Update (&ctx, ipad, MD5_BLOCK_LEN);
MD5Update (&ctx, (unsigned char*) challenge, chal_len);
MD5Final (response, &ctx);
/* outer hash: inner hash and opadded secret */
MD5Init (&ctx);
MD5Update (&ctx, opad, MD5_BLOCK_LEN);
MD5Update (&ctx, response, MD5_DIGEST_LEN);
MD5Final (response, &ctx);
}
/* imap_auth_cram_md5: AUTH=CRAM-MD5 support. Used unconditionally if the
* server supports it */
static int imap_auth_cram_md5 (IMAP_DATA* idata, const char* user,
const char* pass)
{
char ibuf[LONG_STRING], obuf[LONG_STRING];
unsigned char hmac_response[MD5_DIGEST_LEN];
int len;
char seq[16];
dprint (2, (debugfile, "Attempting CRAM-MD5 login...\n"));
mutt_message _("Logging in (CRAM-MD5)...");
imap_make_sequence (seq, sizeof (seq));
snprintf (obuf, LONG_STRING, "%s AUTHENTICATE CRAM-MD5\r\n", seq);
mutt_socket_write (idata->conn, obuf);
/* From RFC 2195:
* The data encoded in the first ready response contains a presumptively
* arbitrary string of random digits, a timestamp, and the fully-qualified
* primary host name of the server. The syntax of the unencoded form must
* correspond to that of an RFC 822 'msg-id' [RFC822] as described in [POP3].
*/
if (mutt_socket_read_line_d (ibuf, LONG_STRING, idata->conn) < 0)
{
dprint (1, (debugfile, "Error receiving server response.\n"));
return -1;
}
if (ibuf[0] != '+')
{
dprint (1, (debugfile, "Invalid response from server: %s\n", ibuf));
return -1;
}
if ((len = mutt_from_base64 (obuf, ibuf + 2)) == -1)
{
dprint (1, (debugfile, "Error decoding base64 response.\n"));
return -1;
}
obuf[len] = '\0';
dprint (2, (debugfile, "CRAM challenge: %s\n", obuf));
/* The client makes note of the data and then responds with a string
* consisting of the user name, a space, and a 'digest'. The latter is
* computed by applying the keyed MD5 algorithm from [KEYED-MD5] where the
* key is a shared secret and the digested text is the timestamp (including
* angle-brackets).
*
* (Note: it's unspecified whether the user name needs IMAP quoting.)
*/
hmac_md5 (pass, obuf, hmac_response);
dprint (2, (debugfile, "CRAM response: %s,[%s]->", obuf, pass));
/* dubious optimisation I saw elsewhere: make the whole string in one call */
snprintf (obuf, sizeof (obuf),
"%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
user,
hmac_response[0], hmac_response[1], hmac_response[2], hmac_response[3],
hmac_response[4], hmac_response[5], hmac_response[6], hmac_response[7],
hmac_response[8], hmac_response[9], hmac_response[10], hmac_response[11],
hmac_response[12], hmac_response[13], hmac_response[14], hmac_response[15]);
dprint(2, (debugfile, "%s\n", obuf));
mutt_to_base64 ((unsigned char*) ibuf, (unsigned char*) obuf, strlen (obuf));
strcpy (ibuf + strlen (ibuf), "\r\n");
mutt_socket_write (idata->conn, ibuf);
if (mutt_socket_read_line_d (ibuf, LONG_STRING, idata->conn) < 0)
{
dprint (1, (debugfile, "Error receiving server response.\n"));
return -1;
}
if (imap_code (ibuf))
{
dprint (2, (debugfile, "CRAM login complete.\n"));
return 0;
}
dprint (2, (debugfile, "CRAM login failed.\n"));
return -1;
}
/* imap_authenticate: loop until success or user abort. At each loop, all
* supported authentication methods are tried, from strongest to weakest.
* Currently available:
* CRAM-MD5: like APOP or CHAP. Safe against replay and sniffing, but
* requires that your key be stored on the server, readable by the
* server account. UW-IMAP supports this method since at least 4.5, if
* the key file exists on the server.
* LOGIN: ugh. Don't use this if you can help it. Uses cleartext password
* exchange, furthermore uses unix login techniques so this same password
* can be used to log in to the server or others that share the
* credentials database.
* Pending:
* GSSAPI: strongest available form, requires Kerberos V infrastructure,
* or possibly alternatively Heimdal.
* Unavailable:
* KERBEROS_V4. Superceded by GSSAPI.
*/
int imap_authenticate (IMAP_DATA *idata, CONNECTION *conn)
{
char buf[LONG_STRING];
char user[SHORT_STRING], q_user[SHORT_STRING];
char ckey[SHORT_STRING];
char pass[SHORT_STRING], q_pass[SHORT_STRING];
char seq[16];
int r = 1;
while (r != 0)
{
if (!ImapUser)
{
strfcpy (user, NONULL(Username), sizeof (user));
if (mutt_get_field (_("IMAP Username: "), user, sizeof (user), 0) != 0 ||
!user[0])
{
user[0] = 0;
return (-1);
}
}
else
strfcpy (user, ImapUser, sizeof (user));
/* attempt CRAM-MD5 if available */
if (mutt_bit_isset (idata->capabilities, ACRAM_MD5))
{
if (!ImapCRAMKey)
{
ckey[0] = '\0';
snprintf (buf, sizeof (buf), _("CRAM key for %s@%s: "), user,
conn->server);
if (mutt_get_field (buf, ckey, sizeof (ckey), M_PASS) != 0 ||
!ckey[0])
return -1;
else
/* strip CR */
ckey[strlen (ckey)] = '\0';
}
else
strfcpy (ckey, ImapCRAMKey, sizeof (ckey));
if ((r = imap_auth_cram_md5 (idata, user, ckey)))
{
mutt_error _("CRAM-MD5 login failed.");
sleep (1);
}
else
return 0;
}
else
dprint (2, (debugfile, "CRAM-MD5 authentication is not supported\n"));
if (!ImapPass)
{
pass[0]=0;
snprintf (buf, sizeof (buf), _("Password for %s@%s: "), user, conn->server);
if (mutt_get_field (buf, pass, sizeof (pass), M_PASS) != 0 ||
!pass[0])
{
return (-1);
}
}
else
strfcpy (pass, ImapPass, sizeof (pass));
imap_quote_string (q_user, sizeof (q_user), user);
imap_quote_string (q_pass, sizeof (q_pass), pass);
mutt_message _("Logging in...");
imap_make_sequence (seq, sizeof (seq));
snprintf (buf, sizeof (buf), "%s LOGIN %s %s\r\n", seq, q_user, q_pass);
r = imap_exec (buf, sizeof (buf), idata, seq, buf, IMAP_OK_FAIL);
if (r == -1)
{
/* connection or protocol problem */
imap_error ("imap_open_connection()", buf);
return (-1);
}
else if (r == -2)
{
/* Login failed, try again */
mutt_error _("Login failed.");
sleep (1);
FREE (&ImapUser);
FREE (&ImapPass);
}
else
{
/* If they have a successful login, we may as well cache the
* user/password. */
if (!ImapUser)
ImapUser = safe_strdup (user);
if (!ImapPass)
ImapPass = safe_strdup (pass);
}
}
return 0;
}
This diff is collapsed.
This diff is collapsed.
......@@ -20,6 +20,7 @@
#define _IMAP_H 1
#include "browser.h"
#include "mailbox.h"
int imap_append_message (CONTEXT *ctx, MESSAGE *msg);
int imap_check_mailbox (CONTEXT *ctx, int *index_hint);
......
/*
* Copyright (C) 1996-9 Brandon Long <blong@fiction.net>
* Copyright (C) 1999 Brendan Cully <brendan@kublai.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _IMAP_PRIVATE_H
#define _IMAP_PRIVATE_H 1
#include "imap_socket.h"
/* -- symbols -- */
/* number of entries in the hash table */
#define IMAP_CACHE_LEN 10
#define IMAP_PORT 143
#define SEQLEN 5
enum
{
IMAP_FATAL = 1,
IMAP_NEW_MAIL,
IMAP_EXPUNGE,
IMAP_BYE,
IMAP_OK_FAIL,
IMAP_REOPENED
};
enum
{
/* States */
IMAP_DISCONNECTED = 0,
IMAP_CONNECTED,
IMAP_AUTHENTICATED,
IMAP_SELECTED
};
enum
{
/* Namespace types */
IMAP_NS_PERSONAL = 0,
IMAP_NS_OTHER,
IMAP_NS_SHARED
};
/* ACL Rights */
enum
{
IMAP_ACL_LOOKUP = 0,
IMAP_ACL_READ,
IMAP_ACL_SEEN,
IMAP_ACL_WRITE,
IMAP_ACL_INSERT,
IMAP_ACL_POST,
IMAP_ACL_CREATE,
IMAP_ACL_DELETE,
IMAP_ACL_ADMIN,
RIGHTSMAX
};
/* Capabilities */
enum
{
IMAP4 = 0,
IMAP4REV1,
STATUS,
ACL, /* RFC 2086: IMAP4 ACL extension */
NAMESPACE, /* RFC 2342: IMAP4 Namespace */
ACRAM_MD5, /* RFC 2195: CRAM-MD5 authentication */
/* From here down, we don't care */
AKERBEROS_V4, /* AUTH=KERBEROS_V4 */
AGSSAPI, /* AUTH=GSSAPI */
ALOGIN, /* AUTH=LOGIN */
AUTH_LOGIN, /* AUTH-LOGIN */
APLAIN, /* AUTH=PLAIN */
ASKEY, /* AUTH=SKEY */
IDLE, /* RFC 2177: IMAP4 IDLE command */
LOGIN_REFERRALS, /* LOGIN-REFERRALS */
MAILBOX_REFERRALS, /* MAILBOX-REFERRALS */
SCAN,
SORT,
TORDEREDSUBJECT, /* THREAD=ORDEREDSUBJECT */
UIDPLUS, /* RFC 2859: IMAP4 UIDPLUS extension */
CAPMAX
};
/* -- data structures -- */
typedef struct
{
unsigned int index;
char *path;
} IMAP_CACHE;
typedef struct
{
int type;
int listable;
char *prefix;
char delim;
int home_namespace;
/* We get these when we check if namespace exists - cache them */
int noselect;
int noinferiors;
} IMAP_NAMESPACE_INFO;
/* Linked list to hold header information while downloading message
* headers
*/
typedef struct imap_header_info
{
unsigned int read : 1;
unsigned int old : 1;
unsigned int deleted : 1;
unsigned int flagged : 1;
unsigned int replied : 1;
unsigned int changed : 1;
unsigned int number;
time_t received;
long content_length;
struct imap_header_info *next;
} IMAP_HEADER_INFO;
typedef struct
{
/* This data is specific to a CONNECTION to an IMAP server */
short status;
short state;
short check_status;
char delim;
unsigned char capabilities[(CAPMAX + 7)/8];
CONNECTION *conn;
/* The following data is all specific to the currently SELECTED mbox */
CONTEXT *selected_ctx;
char *selected_mailbox;
unsigned char rights[(RIGHTSMAX + 7)/8];
unsigned int newMailCount;
IMAP_CACHE cache[IMAP_CACHE_LEN];
} IMAP_DATA;
/* -- macros -- */
#define CTX_DATA ((IMAP_DATA *) ctx->data)
#define CONN_DATA ((IMAP_DATA *) conn->data)
/* -- private IMAP functions -- */
/* imap.c */
int imap_code (const char *s);
void imap_error (const char *where, const char *msg);
int imap_exec (char *buf, size_t buflen, IMAP_DATA *idata,
const char *seq, const char *cmd, int flags);
char *imap_fix_path (IMAP_DATA *idata, char *mailbox, char *path,
size_t plen);
int imap_handle_untagged (IMAP_DATA *idata, char *s);
void imap_make_sequence (char *buf, size_t buflen);
char *imap_next_word (char *s);
int imap_open_connection (IMAP_DATA *idata, CONNECTION *conn);
int imap_parse_list_response(CONNECTION *conn, char *buf, int buflen,
char **name, int *noselect, int *noinferiors, char *delim);
int imap_parse_path (char *path, char *host, size_t hlen, int *port,
char **mbox);
void imap_quote_string (char *dest, size_t slen, const char *src);
void imap_unquote_string (char *s);
/* imap_auth.c */
int imap_authenticate (IMAP_DATA *idata, CONNECTION *conn);
#endif
/*
* Copyright (C) 1998 Brandon Long <blong@fiction.net>
* Copyright (C) 1999 Brendan Cully <brendan@kublai.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -16,8 +17,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _MUTT_SOCKET_H_
#define _MUTT_SOCKET_H_ 1
#ifndef _IMAP_SOCKET_H_
#define _IMAP_SOCKET_H_ 1
typedef struct _connection
{
......@@ -40,4 +41,4 @@ CONNECTION *mutt_socket_select_connection (char *host, int port, int flags);
int mutt_socket_open_connection (CONNECTION *conn);
#endif /* _MUTT_SOCKET_H_ */