Commit 1e7a81ad 1e7a81ad25005ac5268e43a39c9c9dd9d8906557 by Sergey Poznyakoff

Allow to use mailer URLs as append-only mailboxes (deprecates remote+ mailboxes)

* NEWS: Update.

* configure.ac (MU_LIB_REMOTE): Remove.
(AC_CONFIG_FILES): Remove libproto/remote/Makefile.
* include/mailutils/registrar.h (mu_remote_mbox_record): Remove.
(MU_REMOTE_MBOX_PRIO): Remove.

* libproto/Makefile.am (SUBDIRS): Remove remote.
* libproto/include/mailer0.h (_mu_mailer_mailbox_init)
(_mu_mailer_folder_init): New protos.
* libproto/include/registrar0.h (_url_smtp_init)
(_mailer_smtp_init): Remove.
(_mu_mailer_sendmail_init, _mu_mailer_prog_init): Add prototype.

* libproto/include/url0.h (struct _mu_url._uplevel): New member.
* libproto/mailer/Makefile.am (libmu_mailer_la_SOURCES): Remove
url_sendmail.c and url_smtp.c.
* libproto/mailer/mbox.c: Move from ../remote.
* libproto/mailer/url_sendmail.c: Remove.
* libproto/mailer/url_smtp.c: Remove.
* libproto/mailer/prog.c: Fix namespace.
* libproto/mailer/sendmail.c: Likewise.
* libproto/mailer/smtp.c: Likewise.
* libproto/mailer/remote.c: New file.

* libproto/remote/: Remove.

* maidag/Makefile.am (maidag_LDADD): Remove ${MU_LIB_REMOTE}.
* maidag/deliver.c (deliver_url): Remove `remote+' hack.
(deliver): Fix error message.
* maidag/guile.c: Fix indentation.
* maidag/maidag.c: Support `remote+' mailboxes for backward compatibility.
* mailbox/mailbox.c (_create_mailbox0): Call u_init after ensuring that
url->scheme coincides with record->scheme.
* mailbox/url.c (mu_url_uplevel): Use url->_uplevel, if defined.

* libmu_argp/mu_argp.h (mu_check_option): Remove duplicate and
incorrect prototype.
1 parent 14e0fd63
GNU mailutils NEWS -- history of user-visible changes. 2009-03-04
GNU mailutils NEWS -- history of user-visible changes. 2009-04-07
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2009 Free Software Foundation, Inc.
See the end of file for copying conditions.
......@@ -15,6 +15,32 @@ All MU client utilities make use of the user ticket file,
* API
* New mailbox formats
Three new append-only mailbox formats are introduced. The URL syntax of
each of them is the same as that of the corresponding mailer.
** smtp
Send message using the `smtp' mailer. It is equivalent to
`remote+smtp', introduced in previous version.
** sendmail.
Send message using the `sendmail' mailer. It is equivalent to
`remote+sendmail', introduced in previous version.
** prog
Send message using the `prog' mailer. It is equivalent to
`remote+prog', introduced in previous version.
* Deprecated mailbox formats.
The `remote+sendmail', `remote+prog' and `remote+smtp' mailbox formats
are deprecated in favor of `sendmail', `prog' and `smtp',
correspondingly.
** Removed functions
- mu_sieve_get_ticket
......@@ -359,7 +385,7 @@ that can be done over them is mu_mailbox_append_message. E.g.,
appending to the URL `remote+smtp://127.0.0.1:24' is equivalent to
sending a message using mailer `smtp://127.0.0.1:24'.
In addirion, "remote+prog" mailbox (abbreviated as "|") is useful for
In addition, "remote+prog" mailbox (abbreviated as "|") is useful for
piping messages to the standard input of an external program.
** New argcv functions.
......
......@@ -45,7 +45,6 @@ AC_SUBST(MU_LIB_MBOX,'${top_builddir}/libproto/mbox/libmu_mbox.la')
AC_SUBST(MU_LIB_MH,'${top_builddir}/libproto/mh/libmu_mh.la')
AC_SUBST(MU_LIB_NNTP,'${top_builddir}/libproto/nntp/libmu_nntp.la')
AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la')
AC_SUBST(MU_LIB_REMOTE,'${top_builddir}/libproto/remote/libmu_remotembox.la')
AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libmu_sieve/libmu_sieve.la')
AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la')
AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la')
......@@ -1308,7 +1307,6 @@ AC_CONFIG_FILES([Makefile
libproto/nntp/Makefile
libproto/imap/Makefile
libproto/include/Makefile
libproto/remote/Makefile
maidag/Makefile
mail/Makefile
mail/testsuite/Makefile
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2004, 2005, 2006,
2007, 2008 Free Software Foundation, Inc.
2007, 2008, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -114,8 +114,6 @@ extern mu_record_t mu_mbox_record;
extern mu_record_t mu_mh_record;
/* Maildir, "maildir:" */
extern mu_record_t mu_maildir_record;
/* Remote mailbox */
extern mu_record_t mu_remote_mbox_record;
#define MU_IMAP_PRIO 100
#define MU_POP_PRIO 200
......@@ -125,7 +123,6 @@ extern mu_record_t mu_remote_mbox_record;
#define MU_NNTP_PRIO 600
#define MU_PATH_PRIO 1000
#define MU_REMOTE_MBOX_PRIO 10000
#define MU_SMTP_PRIO 10000
#define MU_SENDMAIL_PRIO 10000
#define MU_PROG_PRIO 10000
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2007 Free Software Foundation, Inc.
2007, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -37,7 +37,6 @@ extern void mu_argp_done (struct argp *argp);
extern int mu_register_argp_capa (const char *name, struct argp_child *child);
extern void mu_print_options (void);
extern const char *mu_check_option (char *name);
#ifdef __cplusplus
}
......
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2006, 2007 Free Software Foundation, Inc.
## Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
##
## GNU Mailutils is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
......@@ -17,5 +17,5 @@
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
SUBDIRS = include mbox pop nntp imap mh maildir mailer remote
SUBDIRS = include mbox pop nntp imap mh maildir mailer
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2005, 2007 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2005, 2007,
2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -57,6 +58,9 @@ struct _mu_mailer
int (*_send_message) (mu_mailer_t, mu_message_t, mu_address_t, mu_address_t);
};
int _mu_mailer_mailbox_init (mu_mailbox_t mailbox);
int _mu_mailer_folder_init (mu_folder_t folder MU_ARG_UNUSED);
#define MAILER_NOTIFY(mailer, type) \
if (mailer->observer) observer_notify (mailer->observer, type)
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2004, 2005, 2007, 2008,
2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -73,16 +74,14 @@ extern int _folder_path_init (mu_folder_t);
#define MU_SMTP_SCHEME "smtp"
#define MU_SMTP_SCHEME_LEN (sizeof (MU_SMTP_SCHEME) - 1)
#define MU_SMTP_PORT 25
extern int _url_smtp_init (mu_url_t);
extern int _mailer_smtp_init (mu_mailer_t);
#define MU_SENDMAIL_SCHEME "sendmail"
#define MU_SENDMAIL_SCHEME_LEN (sizeof (MU_SENDMAIL_SCHEME) - 1)
extern int _url_sendmail_init (mu_url_t);
extern int _mailer_sendmail_init (mu_mailer_t);
extern int _mu_mailer_sendmail_init (mu_mailer_t mailer);
#define MU_PROG_SCHEME "prog"
#define MU_PROG_SCHEME_LEN (sizeof (MU_PROG_SCHEME) - 1)
extern int _mu_mailer_prog_init (mu_mailer_t);
#define MU_MH_SCHEME "mh"
#define MU_MH_SCHEME_LEN (sizeof (MU_MH_SCHEME) - 1)
......
......@@ -59,6 +59,7 @@ struct _mu_url
int (*_get_port) (const mu_url_t, long *);
int (*_get_path) (const mu_url_t, char *, size_t, size_t *);
int (*_get_query) (const mu_url_t, char *, size_t, size_t *);
int (*_uplevel) (const mu_url_t, mu_url_t *);
};
......
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2007, 2008 Free Software Foundation, Inc.
## Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
##
## GNU Mailutils is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
......@@ -24,9 +24,9 @@ libmu_mailer_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
libmu_mailer_la_LIBADD = ${MU_LIB_AUTH} ${MU_LIB_MAILUTILS} @INTLLIBS@
libmu_mailer_la_SOURCES = \
mbox.c\
prog.c\
sendmail.c\
smtp.c\
url_sendmail.c\
url_smtp.c
remote.c
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 Free Software Foundation, Inc.
Copyright (C) 2007, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -31,6 +31,7 @@
#include <mailutils/url.h>
#include <mailutils/mutil.h>
#include <mailbox0.h>
#include <mailer0.h>
struct remote_mbox_data
{
......@@ -200,10 +201,9 @@ remote_sync (mu_mailbox_t mbox)
}
int
remote_mbox_init (mu_mailbox_t mailbox)
_mu_mailer_mailbox_init (mu_mailbox_t mailbox)
{
struct remote_mbox_data *dat;
const char *s, *p;
int rc;
mu_mailer_t mailer;
mu_url_t url;
......@@ -212,35 +212,18 @@ remote_mbox_init (mu_mailbox_t mailbox)
return EINVAL;
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1,
"remote_mbox_init (%s)\n", mu_url_to_string (mailbox->url));
rc = mu_url_sget_scheme (mailbox->url, &s);
if (rc)
return rc;
p = strchr (s, '+');
if (!p)
{
MU_DEBUG2 (mailbox->debug, MU_DEBUG_ERROR,
"remote_mbox_init(%s): invalid url: %s\n",
mu_url_to_string (mailbox->url),
mu_strerror (rc));
return MU_ERR_MAILER_BAD_URL;
}
"_mu_mailer_mailbox_init(%s)\n",
mu_url_to_string (mailbox->url));
rc = mu_url_dup (mailbox->url, &url);
if (rc)
return rc;
rc = mu_url_set_scheme (url, p + 1);
if (rc)
{
mu_url_destroy (&url);
return rc;
}
rc = mu_mailer_create_from_url (&mailer, url);
if (rc)
{
MU_DEBUG2 (mailbox->debug, MU_DEBUG_ERROR,
"remote_mbox_init(%s): cannot create mailer: %s\n",
"_mu_mailer_mailbox_init(%s): cannot create mailer: %s\n",
mu_url_to_string (url), mu_strerror (rc));
mu_url_destroy (&url);
return rc;
......@@ -264,4 +247,9 @@ remote_mbox_init (mu_mailbox_t mailbox)
return 0;
}
int
_mu_mailer_folder_init (mu_folder_t folder MU_ARG_UNUSED)
{
return 0;
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2008 Free Software Foundation, Inc.
Copyright (C) 2008, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -39,16 +39,15 @@
#include <registrar0.h>
static int _url_prog_init (mu_url_t);
static int _mailer_prog_init (mu_mailer_t);
static struct _mu_record _prog_record =
{
MU_PROG_PRIO,
MU_PROG_SCHEME,
_url_prog_init, /* url init. */
NULL, /* Mailbox entry. */
_mailer_prog_init, /* Mailer entry. */
NULL, /* Folder entry. */
_mu_mailer_mailbox_init, /* Mailbox entry. */
_mu_mailer_prog_init, /* Mailer entry. */
_mu_mailer_folder_init, /* Folder entry. */
NULL, /* No need for a back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
......@@ -61,6 +60,12 @@ mu_record_t mu_prog_record = &_prog_record;
static int
_url_prog_uplevel (const mu_url_t orig, mu_url_t *up)
{
return MU_ERR_NOENT;
}
static int
_url_prog_init (mu_url_t url)
{
/* not valid in a prog url */
......@@ -68,6 +73,7 @@ _url_prog_init (mu_url_t url)
return EINVAL;
if (!url->path)
return EINVAL;
url->_uplevel = _url_prog_uplevel;
return 0;
}
......@@ -78,8 +84,8 @@ static int prog_close (mu_mailer_t);
static int prog_send_message (mu_mailer_t, mu_message_t, mu_address_t,
mu_address_t);
static int
_mailer_prog_init (mu_mailer_t mailer)
int
_mu_mailer_prog_init (mu_mailer_t mailer)
{
int status;
mu_progmailer_t pm;
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library. If not,
see <http://www.gnu.org/licenses/>. */
/* This file provides backward-compatible "remote+" mailbox types,
introduced in v. 2.0.
They are only used by maidag.
This file will be removed in v. 2.2
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_SMTP
#include <stdlib.h>
#include <string.h>
#include <mailutils/errno.h>
#include <mailutils/error.h>
#include <mailutils/diag.h>
#include <url0.h>
#include <mailer0.h>
#include <registrar0.h>
static int
_url_remote_init (mu_url_t url, const char *new_scheme)
{
char *scheme;
mu_record_t record;
int rc;
mu_diag_output (MU_DIAG_WARNING,
"%s: this URL scheme is deprecated, use %s instead",
url->name, new_scheme);
rc = mu_registrar_lookup_scheme (new_scheme, &record);
if (rc)
return rc;
scheme = strdup (new_scheme);
if (!scheme)
return ENOMEM;
free (url->scheme);
url->scheme = scheme;
return record->_url ? record->_url (url) : 0;
}
static int
_url_remote_smtp_init (mu_url_t url)
{
return _url_remote_init (url, "smtp");
}
static struct _mu_record _mu_remote_smtp_record = {
MU_SMTP_PRIO,
"remote+smtp",
_url_remote_smtp_init, /* url init. */
_mu_mailer_mailbox_init, /* Mailbox init. */
NULL, /* Mailer init. */
_mu_mailer_folder_init, /* Folder init. */
NULL, /* No need for a back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
mu_record_t mu_remote_smtp_record = &_mu_remote_smtp_record;
static int
_url_remote_sendmail_init (mu_url_t url)
{
return _url_remote_init (url, "sendmail");
}
static struct _mu_record _mu_remote_sendmail_record =
{
MU_SENDMAIL_PRIO,
"remote+sendmail",
_url_remote_sendmail_init, /* url init. */
_mu_mailer_mailbox_init, /* Mailbox entry. */
_mu_mailer_sendmail_init, /* Mailer entry. */
_mu_mailer_folder_init, /* Folder entry. */
NULL, /* No need for a back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
mu_record_t mu_remote_sendmail_record = &_mu_remote_sendmail_record;
static int
_url_remote_prog_init (mu_url_t url)
{
return _url_remote_init (url, "prog");
}
static struct _mu_record _mu_remote_prog_record =
{
MU_PROG_PRIO,
"remote+prog",
_url_remote_prog_init, /* url init. */
_mu_mailer_mailbox_init, /* Mailbox entry. */
_mu_mailer_prog_init, /* Mailer entry. */
_mu_mailer_folder_init, /* Folder entry. */
NULL, /* No need for a back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
mu_record_t mu_remote_prog_record = &_mu_remote_prog_record;
#else
mu_record_t mu_remote_smtp_record = NULL;
mu_record_t mu_remote_sendmail_record = NULL;
mu_record_t mu_remote_prog_record = NULL;
#endif
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2006, 2007, 2008 Free Software Foundation, Inc.
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -38,36 +38,34 @@
#include <mailutils/errno.h>
#include <mailutils/progmailer.h>
#include <url0.h>
#include <mailer0.h>
#include <registrar0.h>
static struct _mu_record _sendmail_record =
{
MU_SENDMAIL_PRIO,
MU_SENDMAIL_SCHEME,
_url_sendmail_init, /* url init. */
NULL, /* Mailbox entry. */
_mailer_sendmail_init, /* Mailer entry. */
NULL, /* Folder entry. */
NULL, /* No need for a back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
/* We export, url parsing and the initialisation of
the mailbox, via the register entry/record. */
mu_record_t mu_sendmail_record = &_sendmail_record;
static void sendmail_destroy (mu_mailer_t);
static int sendmail_open (mu_mailer_t, int);
static int sendmail_close (mu_mailer_t);
static int sendmail_send_message (mu_mailer_t, mu_message_t, mu_address_t,
mu_address_t);
static int
_url_sendmail_init (mu_url_t url)
{
/* not valid in a sendmail url */
if (url->user || url->passwd || url->auth || url->qargc
|| url->host || url->port)
return EINVAL;
if (url->path == 0)
if ((url->path = strdup (_PATH_SENDMAIL)) == 0)
return ENOMEM;
return 0;
}
int
_mailer_sendmail_init (mu_mailer_t mailer)
_mu_mailer_sendmail_init (mu_mailer_t mailer)
{
int status;
mu_progmailer_t pm;
......@@ -272,6 +270,25 @@ sendmail_send_message (mu_mailer_t mailer, mu_message_t msg, mu_address_t from,
return status;
}
static struct _mu_record _sendmail_record =
{
MU_SENDMAIL_PRIO,
MU_SENDMAIL_SCHEME,
_url_sendmail_init, /* url init. */
_mu_mailer_mailbox_init, /* Mailbox entry. */
_mu_mailer_sendmail_init, /* Mailer entry. */
_mu_mailer_folder_init, /* Folder entry. */
NULL, /* No need for a back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
/* We export, url parsing and the initialisation of
the mailbox, via the register entry/record. */
mu_record_t mu_sendmail_record = &_sendmail_record;
#else
#include <stdio.h>
#include <registrar0.h>
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2006, 2007 Free Software Foundation, Inc.
2006, 2007, 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -51,15 +51,38 @@
#include <mailutils/tls.h>
#include <mailer0.h>
#include <url0.h>
#include <registrar0.h>
static int _mailer_smtp_init (mu_mailer_t);
static int
_url_smtp_init (mu_url_t url)
{
/* host isn't optional */
if (!url->host)
return EINVAL;
/* accept url->user, pass, and auth
for the ESMTP authentication */
/* all other fields must be NULL */
if (url->path || url->qargc)
return EINVAL;
if (url->port == 0)
url->port = MU_SMTP_PORT;
return 0;
}
static struct _mu_record _smtp_record = {
MU_SMTP_PRIO,
MU_SMTP_SCHEME,
_url_smtp_init, /* url init. */
NULL, /* Mailbox init. */
&_mailer_smtp_init, /* Mailer init. */
NULL, /* Folder init. */
_mu_mailer_mailbox_init, /* Mailbox init. */
_mailer_smtp_init, /* Mailer init. */
_mu_mailer_folder_init, /* Folder init. */
NULL, /* No need for a back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
......@@ -248,7 +271,7 @@ do \
} \
while (0)
int
static int
_mailer_smtp_init (mu_mailer_t mailer)
{
smtp_t smtp;
......@@ -486,6 +509,7 @@ smtp_close (mu_mailer_t mailer)
return mu_stream_close (mailer->stream);
}
#ifdef WITH_TLS
/*
Client side STARTTLS support.
*/
......@@ -524,6 +548,7 @@ smtp_stream_ctl (void *iodata, mu_stream_t *pold, mu_stream_t new)
if (new)
iop->mailer->stream = new;
}
#endif
static int
smtp_starttls (smtp_t smtp)
......@@ -1195,4 +1220,5 @@ smtp_readline (smtp_t smtp)
#include <stdio.h>
#include <registrar0.h>
mu_record_t mu_smtp_record = NULL;
mu_record_t mu_remote_smtp_record = NULL;
#endif
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_SENDMAIL
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_PATHS_H
# include <paths.h>
#endif
#ifndef _PATH_SENDMAIL
# define _PATH_SENDMAIL "/usr/lib/sendmail"
#endif
#include <registrar0.h>
#include <url0.h>
/*
Sendmail URL:
sendmail:/path/to/sendmail
*/
int
_url_sendmail_init (mu_url_t url)
{
/* not valid in a sendmail url */
if (url->user || url->passwd || url->auth || url->qargc
|| url->host || url->port)
return EINVAL;
if (url->path == 0)
if ((url->path = strdup (_PATH_SENDMAIL)) == 0)
return ENOMEM;
return 0;
}
#endif /* ENABLE_SENDMAIL */
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2005, 2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef ENABLE_SMTP
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <registrar0.h>
#include <url0.h>
int
_url_smtp_init (mu_url_t url)
{
/* host isn't optional */
if (!url->host)
return EINVAL;
/* accept url->user, pass, and auth
for the ESMTP authentication */
/* all other fields must be NULL */
if (url->path || url->qargc)
return EINVAL;
if (url->port == 0)
url->port = MU_SMTP_PORT;
return 0;
}
#endif /* ENABLE_SMTP */
*.la
*.lo
.deps
.libs
Makefile
Makefile.in
T
_*
.gdbinit
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2007 Free Software Foundation, Inc.
##
## GNU Mailutils 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 3, 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. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
INCLUDES = @MU_COMMON_INCLUDES@ -I${top_srcdir}/libproto/include
lib_LTLIBRARIES = libmu_remotembox.la
libmu_remotembox_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
libmu_remotembox_la_LIBADD = ${MU_LIB_MAILUTILS} ${MU_LIB_MAILER}
libmu_remotembox_la_SOURCES = \
folder.c\
mbox.c
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007, 2008 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <mailutils/errno.h>
#include <mailutils/error.h>
#include <mailutils/url.h>
#include <mailbox0.h>
#include <url0.h>
#include <folder0.h>
#include <registrar0.h>
#define MU_REMOTE_MBOX_PREFIX "remote+"
#define MU_REMOTE_MBOX_PREFIX_LEN (sizeof (MU_REMOTE_MBOX_PREFIX) - 1)
extern int remote_mbox_init (mu_mailbox_t mailbox);
static int
remote_folder_init (mu_folder_t folder MU_ARG_UNUSED)
{
return 0;
}
static int
_remote_is_scheme (mu_record_t record, mu_url_t url, int flags)
{
char *scheme = url->scheme;
size_t scheme_len = scheme ? strlen (scheme) : 0;
struct _mu_url s_url;
if (!scheme
|| scheme_len < MU_REMOTE_MBOX_PREFIX_LEN
|| memcmp (MU_REMOTE_MBOX_PREFIX, scheme,
MU_REMOTE_MBOX_PREFIX_LEN) != 0)
return 0;
memcpy (&s_url, url, sizeof (s_url));
s_url.scheme = scheme + MU_REMOTE_MBOX_PREFIX_LEN;
if (mu_registrar_lookup_url (&s_url, 0, NULL, NULL) == 0)
return MU_FOLDER_ATTRIBUTE_FILE;
return 0;
}
static struct _mu_record _remote_mbox_record =
{
MU_REMOTE_MBOX_PRIO,
MU_REMOTE_MBOX_PREFIX,
NULL, /* URL init. */
remote_mbox_init, /* Mailbox init. */
NULL, /* Mailer init. */
remote_folder_init, /* Folder init. */
NULL, /* No need for back pointer. */
_remote_is_scheme, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
mu_record_t mu_remote_mbox_record = &_remote_mbox_record;
......@@ -47,7 +47,6 @@ maidag_LDADD = \
${MU_LIB_MAILDIR}\
${MU_LIB_AUTH}\
${MU_LIB_MAILER}\
${MU_LIB_REMOTE}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS} \
@MU_COMMON_LIBRARIES@\
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2007, 2008 Free Software Foundation, Inc.
2007, 2008, 2009 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -285,9 +285,6 @@ is_mailer_url (mu_url_t url)
&& pfn;
}
#define REMOTE_PREFIX "remote+"
#define REMOTE_PREFIX_LEN (sizeof(REMOTE_PREFIX)-1)
int
deliver_url (mu_url_t url, mu_message_t msg, const char *name, char **errp)
{
......@@ -352,33 +349,6 @@ deliver_url (mu_url_t url, mu_message_t msg, const char *name, char **errp)
}
}
if (is_mailer_url (url))
{
const char *scheme;
size_t len;
char *new_scheme;
mu_url_sget_scheme (url, &scheme);
len = REMOTE_PREFIX_LEN + strlen (scheme);
new_scheme = malloc (len + 1);
if (!new_scheme)
{
mu_error (_("Not enough memory"));
exit (EX_SOFTWARE);
}
strcat (strcpy (new_scheme, REMOTE_PREFIX), scheme);
status = mu_url_set_scheme (url, new_scheme);
free (new_scheme);
if (status)
{
errno = status;
maidag_error (_("Cannot modify URL %s: %s"),
mu_url_to_string (url),
mu_strerror (status));
mu_auth_data_free (auth);
return EX_TEMPFAIL;
}
}
status = mu_mailbox_create_from_url (&mbox, url);
if (status)
......@@ -439,7 +409,7 @@ deliver (mu_message_t msg, char *dest_id, char **errp)
{
maidag_error (_("no user name"));
if (errp)
asprintf (errp, "no user such");
asprintf (errp, "no such user");
exit_code = EX_NOUSER;
return EX_NOUSER;
}
......
......@@ -39,9 +39,9 @@ scheme_check_msg (mu_message_t msg, struct mu_auth_data *auth,
mu_diag_get_debug (&debug);
port = mu_scm_make_debug_port (debug, MU_DIAG_ERROR);
scm_set_current_error_port(port);
scm_set_current_error_port (port);
port = mu_scm_make_debug_port (debug, MU_DIAG_INFO);
scm_set_current_output_port(port);
scm_set_current_output_port (port);
}
initialized = 1;
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007, 2008 Free Software Foundation, Inc.
Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -470,6 +470,12 @@ maidag_cfg_init ()
}
}
/* FIXME: These are for compatibility with MU 2.0.
Remove in 2.2 */
extern mu_record_t mu_remote_smtp_record;
extern mu_record_t mu_remote_sendmail_record;
extern mu_record_t mu_remote_prog_record;
int
main (int argc, char *argv[])
......@@ -497,8 +503,11 @@ main (int argc, char *argv[])
mu_register_all_formats ();
mu_registrar_record (mu_smtp_record);
/* Register a special mailbox */
mu_registrar_record (mu_remote_mbox_record);
/* FIXME: These are for compatibility with MU 2.0.
Remove in 2.1 */
mu_registrar_record (mu_remote_smtp_record);
mu_registrar_record (mu_remote_sendmail_record);
mu_registrar_record (mu_remote_prog_record);
mu_gocs_register ("sieve", mu_sieve_module_init);
......
......@@ -101,20 +101,12 @@ _create_mailbox0 (mu_mailbox_t *pmbox, mu_url_t url, const char *name)
return status;
}
mu_record_get_url (record, &u_init);
if (u_init && (status = u_init (url)) != 0)
{
mu_mailbox_destroy (&mbox);
return status;
}
/* Make sure scheme contains actual mailbox scheme */
/* FIXME: It is appropriate not for all record types. For now we
assume that if the record scheme ends with a plus sign, this
should not be done. Probably it requires some flag in struct
_mu_record? */
if (record->scheme[strlen(record->scheme)-1] != '+'
&& strcmp (url->scheme, record->scheme))
if (strcmp (url->scheme, record->scheme))
{
char *p = strdup (record->scheme);
if (!p)
......@@ -126,6 +118,13 @@ _create_mailbox0 (mu_mailbox_t *pmbox, mu_url_t url, const char *name)
url->scheme = p;
}
mu_record_get_url (record, &u_init);
if (u_init && (status = u_init (url)) != 0)
{
mu_mailbox_destroy (&mbox);
return status;
}
mbox->url = url;
/* Create the folder before initializing the concrete mailbox.
......
......@@ -188,6 +188,9 @@ mu_url_uplevel (mu_url_t url, mu_url_t *upurl)
int rc;
char *p;
mu_url_t new_url;
if (url->_uplevel)
return url->_uplevel (url, upurl);
if (!url->path)
return MU_ERR_NOENT;
......