those prevented good modularization.
Signed-off-by: Pierre Habouzit <madcoder@madism.org>
#include "attach.h"
#include <imap/imap.h>
-#include <imap/mx_imap.h>
#ifdef USE_NNTP
#include "nntp.h"
#endif
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/intl
noinst_LIBRARIES = libimap.a
-noinst_HEADERS = auth.h imap_private.h message.h mx_imap.h
+noinst_HEADERS = auth.h imap_private.h message.h
-libimap_a_SOURCES = auth.c auth_login.c browse.c command.c imap.c imap.h mx_imap.h \
- message.c utf7.c util.c mx_imap.c $(AUTHENTICATORS) auth_gss.c
+libimap_a_SOURCES = auth.c auth_login.c browse.c command.c imap.c imap.h \
+ message.c utf7.c util.c $(AUTHENTICATORS) auth_gss.c
-include ../cflags.mk
/* imap_access: Check permissions on an IMAP mailbox.
* TODO: ACL checks. Right now we assume if it exists we can
* mess with it. */
-int imap_access (const char *path, int flags __attribute__ ((unused)))
+static int imap_access (const char *path, int flags __attribute__ ((unused)))
{
IMAP_DATA *idata;
IMAP_MBOX mx;
return s;
}
-int imap_open_mailbox (CONTEXT * ctx)
+static int imap_open_mailbox (CONTEXT * ctx)
{
CONNECTION *conn;
IMAP_DATA *idata;
}
/* imap_close_mailbox: clean up IMAP data in CONTEXT */
-void imap_close_mailbox (CONTEXT * ctx)
+static void imap_close_mailbox (CONTEXT * ctx)
{
IMAP_DATA *idata;
int i;
mx_open_mailbox (ctx->path, 0, ctx);
return 0;
}
+
+int imap_is_magic (const char* path, struct stat* st __attribute__ ((unused))) {
+ url_scheme_t s;
+ if (!path || !*path)
+ return (-1);
+ s = url_check_scheme (NONULL (path));
+ return ((s == U_IMAP || s == U_IMAPS) ? M_IMAP : -1);
+}
+
+static int acl_check_imap (CONTEXT* ctx, int bit) {
+ return (!mutt_bit_isset (((IMAP_DATA*) ctx->data)->capabilities, ACL) ||
+ mutt_bit_isset (((IMAP_DATA*) ctx->data)->rights, bit));
+}
+
+static int imap_open_new_message (MESSAGE * msg,
+ CONTEXT * dest __attribute__ ((unused)),
+ HEADER * hdr __attribute__ ((unused)))
+{
+ char tmp[_POSIX_PATH_MAX];
+
+ mutt_mktemp (tmp);
+ if ((msg->fp = safe_fopen (tmp, "w")) == NULL) {
+ mutt_perror (tmp);
+ return (-1);
+ }
+ msg->path = m_strdup(tmp);
+ return 0;
+}
+
+/* this ugly kludge is required since the last int to
+ * imap_check_mailbox() doesn't mean 'lock' but 'force'... */
+static int _imap_check_mailbox (CONTEXT* ctx,
+ int* index_hint,
+ int lock __attribute__ ((unused))) {
+ return (imap_check_mailbox (ctx, index_hint, 0));
+}
+
+static int imap_commit_message (MESSAGE* msg, CONTEXT* ctx) {
+ int r = 0;
+
+ if ((r = safe_fclose (&msg->fp)) == 0)
+ r = imap_append_message (ctx, msg);
+ return (r);
+}
+
+mx_t const imap_mx = {
+ M_IMAP,
+ 0,
+ imap_is_magic,
+ NULL,
+ imap_access,
+ imap_open_mailbox,
+ imap_open_new_message,
+ acl_check_imap,
+ _imap_check_mailbox,
+ imap_close_mailbox,
+ imap_sync_mailbox,
+ imap_commit_message,
+};
#include "browser.h"
#include "mx.h"
+extern mx_t const imap_mx;
+
/* -- data structures -- */
typedef struct {
ACCOUNT account;
} IMAP_MBOX;
/* imap.c */
-int imap_access (const char *, int);
+int imap_is_magic(const char*, struct stat*);
+
int imap_check_mailbox (CONTEXT * ctx, int *index_hint, int force);
int imap_delete_mailbox (CONTEXT * idata, IMAP_MBOX mx);
-int imap_open_mailbox (CONTEXT * ctx);
int imap_open_mailbox_append (CONTEXT * ctx);
int imap_sync_mailbox (CONTEXT * ctx, int expunge, int *index_hint);
-void imap_close_mailbox (CONTEXT * ctx);
-int imap_buffy_check (char *path);
int imap_mailbox_check (char *path, int new);
int imap_search (CONTEXT* ctx, const pattern_t* pat);
int imap_subscribe (char *path, int subscribe);
void imap_logout_all (void);
/* util.c */
-int imap_expand_path (char *path, size_t len);
int imap_parse_path (const char *path, IMAP_MBOX * mx);
void imap_pretty_mailbox (char *path);
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#include <lib-lib/lib-lib.h>
-
-#include "mutt.h"
-#include "imap_private.h"
-
-#include "mx.h"
-#include "mx_imap.h"
-
-int imap_is_magic (const char* path, struct stat* st __attribute__ ((unused))) {
- url_scheme_t s;
- if (!path || !*path)
- return (-1);
- s = url_check_scheme (NONULL (path));
- return ((s == U_IMAP || s == U_IMAPS) ? M_IMAP : -1);
-}
-
-static int acl_check_imap (CONTEXT* ctx, int bit) {
- return (!mutt_bit_isset (((IMAP_DATA*) ctx->data)->capabilities, ACL) ||
- mutt_bit_isset (((IMAP_DATA*) ctx->data)->rights, bit));
-}
-
-static int imap_open_new_message (MESSAGE * msg,
- CONTEXT * dest __attribute__ ((unused)),
- HEADER * hdr __attribute__ ((unused)))
-{
- char tmp[_POSIX_PATH_MAX];
-
- mutt_mktemp (tmp);
- if ((msg->fp = safe_fopen (tmp, "w")) == NULL) {
- mutt_perror (tmp);
- return (-1);
- }
- msg->path = m_strdup(tmp);
- return 0;
-}
-
-/* this ugly kludge is required since the last int to
- * imap_check_mailbox() doesn't mean 'lock' but 'force'... */
-static int _imap_check_mailbox (CONTEXT* ctx,
- int* index_hint,
- int lock __attribute__ ((unused))) {
- return (imap_check_mailbox (ctx, index_hint, 0));
-}
-
-static int imap_commit_message (MESSAGE* msg, CONTEXT* ctx) {
- int r = 0;
-
- if ((r = safe_fclose (&msg->fp)) == 0)
- r = imap_append_message (ctx, msg);
- return (r);
-}
-
-mx_t const imap_mx = {
- M_IMAP,
- 0,
- imap_is_magic,
- NULL,
- imap_access,
- imap_open_mailbox,
- imap_open_new_message,
- acl_check_imap,
- _imap_check_mailbox,
- imap_close_mailbox,
- imap_sync_mailbox,
- imap_commit_message,
-};
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-/*
- * interface of mx_t implementation for IMAP
- */
-
-#ifndef _IMAP_MX_H
-#define _IMAP_MX_H
-
-#include "mx.h"
-
-extern mx_t const imap_mx;
-
-int imap_is_magic(const char*, struct stat*);
-
-#endif /* !_IMAP_MX_H */
/* -- public functions -- */
-/* imap_expand_path: IMAP implementation of mutt_expand_path. Rewrite
- * an IMAP path in canonical and absolute form.
- * Inputs: a buffer containing an IMAP path, and the number of bytes in
- * that buffer.
- * Outputs: The buffer is rewritten in place with the canonical IMAP path.
- * Returns 0 on success, or -1 if imap_parse_path chokes or url_ciss_tostring
- * fails, which it might if there isn't enough room in the buffer. */
-int imap_expand_path (char *path, size_t len)
-{
- IMAP_MBOX mx;
- ciss_url_t url;
- int rc;
-
- if (imap_parse_path (path, &mx) < 0)
- return -1;
-
- mutt_account_tourl (&mx.account, &url);
- url.path = mx.mbox;
-
- rc = url_ciss_tostring (&url, path, len, U_DECODE_PASSWD);
- p_delete(&mx.mbox);
-
- return rc;
-}
-
/* imap_parse_path: given an IMAP mailbox name, return host, port
* and a path IMAP servers will recognise.
* mx.mbox is malloc'd, caller must free it */
#include "version.h"
#include <imap/imap.h>
-#include <imap/mx_imap.h>
#include <lib-crypt/crypt.h>
#include "dotlock.h"
#include <imap/imap.h>
-#include <imap/mx_imap.h>
-
#include <pop/pop.h>
-#include <pop/mx_pop.h>
#ifdef USE_NNTP
-#include "nntp/nntp.h"
-#include "nntp/mx_nntp.h"
+#include <nntp/nntp.h>
#endif
#include <lib-crypt/crypt.h>
static void mx_unlink_empty (const char *path)
{
int fd;
- struct stat sb;
if ((fd = open (path, O_RDWR)) == -1)
return;
INCLUDES = -I$(top_srcdir) -I../intl
noinst_LIBRARIES = libnntp.a
-noinst_HEADERS = nntp.h mx_nntp.h
+noinst_HEADERS = nntp.h
-libnntp_a_SOURCES = nntp.h mx_nntp.h \
- nntp.c mx_nntp.c newsrc.c
+libnntp_a_SOURCES = nntp.h nntp.c newsrc.c
-include ../cflags.mk
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#include <lib-lib/lib-lib.h>
-
-#include "mutt.h"
-#include "nntp.h"
-
-#include "mx.h"
-#include "mx_nntp.h"
-
-static int nntp_is_magic (const char* path, struct stat* st) {
- url_scheme_t s = url_check_scheme (NONULL (path));
- return ((s == U_NNTP || s == U_NNTPS) ? M_NNTP : -1);
-}
-
-static int acl_check_nntp (CONTEXT* ctx, int bit) {
- switch (bit) {
- case ACL_INSERT: /* editing messages */
- case ACL_WRITE: /* change importance */
- return (0);
- case ACL_DELETE: /* (un)deletion */
- case ACL_SEEN: /* mark as read */
- return (1);
- default:
- return (0);
- }
-}
-
-mx_t const nntp_mx = {
- M_NNTP,
- 0,
- nntp_is_magic,
- NULL,
- NULL,
- nntp_open_mailbox,
- NULL,
- acl_check_nntp,
- nntp_check_mailbox,
- nntp_fastclose_mailbox,
- nntp_sync_mailbox,
- NULL,
-};
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-/*
- * interface of mx_t implementation for NNTP
- */
-
-#ifndef _NNTP_MX_H
-#define _NNTP_MX_H
-
-#include "mx.h"
-
-extern mx_t const nntp_mx;
-
-#endif /* !_NNTP_MX_H */
#include "mutt.h"
#include "sort.h"
#include "mx.h"
-#include "mx_nntp.h"
#include "nntp.h"
#include "buffy.h"
/*
* currently, nntp "mailbox" is "newsgroup"
*/
-int nntp_open_mailbox (CONTEXT * ctx)
+static int nntp_open_mailbox (CONTEXT * ctx)
{
NNTP_DATA *nntp_data;
NNTP_SERVER *serv;
p_delete(&data);
}
-int nntp_sync_mailbox (CONTEXT * ctx, int unused1, int* unused2)
+static int nntp_sync_mailbox (CONTEXT * ctx, int unused1, int* unused2)
{
NNTP_DATA *data = ctx->data;
return 0;
}
-void nntp_fastclose_mailbox (CONTEXT * ctx)
+static void nntp_fastclose_mailbox (CONTEXT * ctx)
{
NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
return 0;
}
-int nntp_check_mailbox (CONTEXT * ctx, int* unused1, int unused2)
+static int nntp_check_mailbox (CONTEXT * ctx, int* unused1, int unused2)
{
return _nntp_check_mailbox (ctx, (NNTP_DATA *) ctx->data);
}
p_delete(&cc.child);
return ret;
}
+
+static int nntp_is_magic (const char* path, struct stat* st) {
+ url_scheme_t s = url_check_scheme (NONULL (path));
+ return ((s == U_NNTP || s == U_NNTPS) ? M_NNTP : -1);
+}
+
+static int acl_check_nntp (CONTEXT* ctx, int bit) {
+ switch (bit) {
+ case ACL_INSERT: /* editing messages */
+ case ACL_WRITE: /* change importance */
+ return (0);
+ case ACL_DELETE: /* (un)deletion */
+ case ACL_SEEN: /* mark as read */
+ return (1);
+ default:
+ return (0);
+ }
+}
+
+mx_t const nntp_mx = {
+ M_NNTP,
+ 0,
+ nntp_is_magic,
+ NULL,
+ NULL,
+ nntp_open_mailbox,
+ NULL,
+ acl_check_nntp,
+ nntp_check_mailbox,
+ nntp_fastclose_mailbox,
+ nntp_sync_mailbox,
+ NULL,
+};
#include <lib-sys/mutt_socket.h>
#include "mx.h"
+extern mx_t const nntp_mx;
+
#define NNTP_PORT 119
#define NNTP_SSL_PORT 563
NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
void nntp_clear_cacheindex (NNTP_SERVER *);
int mutt_newsrc_update (NNTP_SERVER *);
-int nntp_open_mailbox (CONTEXT *);
-int nntp_sync_mailbox (CONTEXT *, int, int*);
-int nntp_check_mailbox (CONTEXT *, int*, int);
int nntp_close_mailbox (CONTEXT *);
-void nntp_fastclose_mailbox (CONTEXT *);
int nntp_fetch_message (MESSAGE *, CONTEXT *, int);
int nntp_post (const char *);
int nntp_check_msgid (CONTEXT *, const char *);
INCLUDES = -I$(top_srcdir) -I../intl
noinst_LIBRARIES = libpop.a
-noinst_HEADERS = pop.h mx_pop.h
+noinst_HEADERS = pop.h
-libpop_a_SOURCES = pop.c pop_auth.c pop_lib.c pop.h mx_pop.h mx_pop.c
+libpop_a_SOURCES = pop.c pop_auth.c pop_lib.c pop.h
-include ../cflags.mk
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#include <lib-lib/lib-lib.h>
-
-#include "mutt.h"
-#include "pop.h"
-#include "mx.h"
-#include "mx_pop.h"
-
-static int pop_is_magic (const char* path, struct stat* st __attribute__ ((unused))) {
- url_scheme_t s = url_check_scheme (NONULL (path));
- return ((s == U_POP || s == U_POPS) ? M_POP : -1);
-}
-
-static int acl_check_pop (CONTEXT* ctx __attribute__ ((unused)), int bit) {
- switch (bit) {
- case ACL_INSERT: /* editing messages */
- case ACL_WRITE: /* change importance */
- return (0);
- case ACL_DELETE: /* (un)deletion */
- case ACL_SEEN: /* mark as read */
- return (1);
- default:
- return (0);
- }
-}
-
-mx_t const pop_mx = {
- M_POP,
- 0,
- pop_is_magic,
- NULL,
- NULL,
- pop_open_mailbox,
- NULL,
- acl_check_pop,
- pop_check_mailbox,
- pop_close_mailbox,
- pop_sync_mailbox,
- NULL,
-};
+++ /dev/null
-/*
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-/*
- * interface of mx_t implementation for POP
- */
-
-#ifndef _POP_MX_H
-#define _POP_MX_H
-
-#include "mx.h"
-
-extern mx_t const pop_mx;
-
-#endif /* !_POP_MX_H */
}
/* open POP mailbox - fetch only headers */
-int pop_open_mailbox (CONTEXT * ctx)
+static int pop_open_mailbox (CONTEXT * ctx)
{
int ret;
char buf[LONG_STRING];
}
/* close POP mailbox */
-void pop_close_mailbox (CONTEXT * ctx)
+static void pop_close_mailbox (CONTEXT * ctx)
{
POP_DATA *pop_data = (POP_DATA *) ctx->data;
}
/* update POP mailbox - delete messages from server */
-pop_query_status pop_sync_mailbox (CONTEXT * ctx,
- int unused __attribute__ ((unused)),
- int *index_hint __attribute__ ((unused)))
+static pop_query_status
+pop_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)),
+ int *index_hint __attribute__ ((unused)))
{
int i;
pop_query_status ret;
}
/* Check for new messages and fetch headers */
-int pop_check_mailbox (CONTEXT * ctx,
- int *index_hint __attribute__ ((unused)),
- int unused __attribute__ ((unused)))
+static int pop_check_mailbox (CONTEXT * ctx,
+ int *index_hint __attribute__ ((unused)),
+ int unused __attribute__ ((unused)))
{
int ret;
POP_DATA *pop_data = (POP_DATA *) ctx->data;
mutt_socket_close (conn);
p_delete(&pop_data);
}
+
+static int pop_is_magic (const char* path, struct stat* st __attribute__ ((unused))) {
+ url_scheme_t s = url_check_scheme (NONULL (path));
+ return ((s == U_POP || s == U_POPS) ? M_POP : -1);
+}
+
+static int acl_check_pop (CONTEXT* ctx __attribute__ ((unused)), int bit) {
+ switch (bit) {
+ case ACL_INSERT: /* editing messages */
+ case ACL_WRITE: /* change importance */
+ return (0);
+ case ACL_DELETE: /* (un)deletion */
+ case ACL_SEEN: /* mark as read */
+ return (1);
+ default:
+ return (0);
+ }
+}
+
+mx_t const pop_mx = {
+ M_POP,
+ 0,
+ pop_is_magic,
+ NULL,
+ NULL,
+ pop_open_mailbox,
+ NULL,
+ acl_check_pop,
+ pop_check_mailbox,
+ pop_close_mailbox,
+ pop_sync_mailbox,
+ NULL,
+};
#include "mx.h"
+extern mx_t const pop_mx;
+
+
#define POP_PORT 110
#define POP_SSL_PORT 995
void pop_error (POP_DATA *, char *);
/* pop.c */
-int pop_check_mailbox (CONTEXT *, int *, int);
-int pop_open_mailbox (CONTEXT *);
-pop_query_status pop_sync_mailbox (CONTEXT *, int, int *);
int pop_fetch_message (MESSAGE *, CONTEXT *, int);
-void pop_close_mailbox (CONTEXT *);
void pop_fetch_mail (void);
#endif
#include <lib-crypt/crypt.h>
#include <imap/imap.h>
-#include <imap/mx_imap.h>
static struct mapping_t PostponeHelp[] = {
{N_("Exit"), OP_EXIT},