commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-152-g1e409dd


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-152-g1e409dd
Date: Wed, 20 Oct 2010 19:15:34 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=1e409dd4c3369bc70cf2353935a610314228fa65

The branch, master has been updated
       via  1e409dd4c3369bc70cf2353935a610314228fa65 (commit)
      from  f50c5d11f2775f11cb450c97008f9fa4b9e39fa1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1e409dd4c3369bc70cf2353935a610314228fa65
Author: Sergey Poznyakoff <address@hidden>
Date:   Wed Oct 20 22:13:00 2010 +0300

    Improve registrar/url interaction.  Fix SMTP URLs to comply to 
draft-earhart-url-smtp-00.  Minor fix in maidag (url mode).
    
    * include/mailutils/registrar.h (MU_RECORD_DEFAULT)
    (MU_RECORD_LOCAL): New flags.
    (_mu_record) <flags,url_may_have,url_must_have>: New members.
    Remove unnecessary externs.
    (mu_record_set_.*): Remove all protos.
    (mu_record_check_url, mu_registrar_test_local_url): New protos.
    * include/mailutils/sys/url.h (_mu_url) <flags>: New member.
    (MU_URL_USER, MU_URL_SECRET, MU_URL_AUTH)
    (MU_URL_HOST, MU_URL_PORT, MU_URL_PATH)
    (MU_URL_PARAM, MU_URL_QUERY)
    (MU_URL_CRED, MU_URL_INET, MU_URL_ALL): New flags.
    (mu_url_get_flags, mu_url_has_flag): New protos.
    * libmailutils/base/registrar.c (mu_record_set_.*): Remove all.
    (mu_record_check_url): New function.
    (mu_registrar_test_local_url): New function.
    * libmailutils/base/url.c (mu_url_copy0): Copy flags.
    (mu_url_parse): Use flags intead of inspecting each
    structure member. Set flags.
    (mu_url_get_flags, mu_url_has_flag): New functions.
    * libmailutils/diag/errors (MU_ERR_URL_MISS_PARTS)
    (MU_ERR_URL_EXTRA_PARTS): New error codes.
    * libmailutils/mailbox/folder.c (mu_folder_create_from_record): Check
    the URL using mu_record_check_url.
    * libproto/imap/folder.c (_imap_record, _imaps_record): Initialize new 
fields.
    * libproto/maildir/folder.c (_maildir_record): Likewise.
    * libproto/mbox/folder.c (_mbox_record): Likewise.
    * libproto/mh/folder.c (_mh_record): Likewise.
    * libproto/nntp/folder.c (_nntp_record): Likewise.
    * libproto/pop/folder.c (_pop_record, _pops_record): Likewise.
    * libproto/mailer/prog.c (_prog_record): Likewise.
    (_url_prog_init): Remove extra checks, rely on mu_record_check_url.
    * libproto/mailer/remote.c (_mu_remote_smtp_record)
    (_mu_remote_sendmail_record,_mu_remote_prog_record): Initialize new fields.
    * libproto/mailer/sendmail.c (_url_sendmail_init): Remove extra checks, rely
    on mu_record_check_url.
    (_sendmail_record): Initialize new fields.
    * libproto/nntp/url.c (url_nntp_destroy): Remove.
    (_nntp_url_init): Remove extra checks.
    * libproto/pop/url.c (url_pop_destroy): Remove.
    (_url_pop_init, _url_pops_init): Remove extra checks.
    
    * libproto/mailer/smtp.c (_url_smtp_init): Remove extra checks.
    (_smtp_record): Initialize new fields.
    (smtp_mailer_add_auth_mech): New function.
    (smtp_open): Allow for auth= part before the host name.
    
    * maidag/deliver.c (is_remote_url): New function.
    (do_delivery): Do not try to switch user privileges if the
    URL refers to a remote mailbox.
    * maidag/maidag.c (main): Initialize TLS.

-----------------------------------------------------------------------

Summary of changes:
 include/mailutils/registrar.h |   68 ++++++++++-----------
 include/mailutils/sys/url.h   |    1 +
 include/mailutils/url.h       |   23 +++++++
 libmailutils/base/registrar.c |  134 ++++++++++++++---------------------------
 libmailutils/base/url.c       |   57 +++++++++++++----
 libmailutils/diag/errors      |    3 +
 libmailutils/mailbox/folder.c |    7 ++-
 libproto/imap/folder.c        |    6 ++
 libproto/maildir/folder.c     |    3 +
 libproto/mailer/prog.c        |   10 ++--
 libproto/mailer/remote.c      |    9 +++
 libproto/mailer/sendmail.c    |   11 ++--
 libproto/mailer/smtp.c        |   52 ++++++++--------
 libproto/mbox/folder.c        |    3 +
 libproto/mh/folder.c          |    3 +
 libproto/nntp/folder.c        |    3 +
 libproto/nntp/url.c           |   24 -------
 libproto/pop/folder.c         |    6 ++
 libproto/pop/url.c            |   21 -------
 maidag/deliver.c              |   14 ++++-
 maidag/maidag.c               |    3 +
 21 files changed, 238 insertions(+), 223 deletions(-)

diff --git a/include/mailutils/registrar.h b/include/mailutils/registrar.h
index 2042966..cf77925 100644
--- a/include/mailutils/registrar.h
+++ b/include/mailutils/registrar.h
@@ -25,11 +25,21 @@
 extern "C" {
 #endif
 
+#define MU_RECORD_DEFAULT 0
+#define MU_RECORD_LOCAL   0x0001
+  /* This record represents a "local entity", e.g. a UNIX or MH mailbox */
+
+  
 /* Public Interface, to allow static initialization.  */
 struct _mu_record
 {
   int priority;    /* Higher priority records are scanned first */
   const char *scheme;
+  int flags;       /* MU_RECORD_ flags */
+  int url_may_have; /* MU_URL_ flags (see url.h) describing what an URL
+                      for this record may have */
+  int url_must_have;/* MU_URL_ flags telling what such an URL must have */
+  
   int (*_url) (mu_url_t);
   int (*_mailbox) (mu_mailbox_t);
   int (*_mailer) (mu_mailer_t);
@@ -47,54 +57,40 @@ struct _mu_record
 };
 
 /* Defaults */  
-extern int mu_registrar_set_default_scheme (const char *scheme);
-extern const char *mu_registrar_get_default_scheme (void);
-extern int mu_registrar_get_default_record (mu_record_t *prec);
-extern void mu_registrar_set_default_record (mu_record_t record);
+int mu_registrar_set_default_scheme (const char *scheme);
+const char *mu_registrar_get_default_scheme (void);
+int mu_registrar_get_default_record (mu_record_t *prec);
+void mu_registrar_set_default_record (mu_record_t record);
   
 /* Registration.  */
-extern int mu_registrar_get_iterator (mu_iterator_t *);
-extern int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated));
+int mu_registrar_get_iterator (mu_iterator_t *);
+int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated));
 
-extern int mu_registrar_lookup_scheme (const char *scheme,
+int mu_registrar_lookup_scheme (const char *scheme,
                                       mu_record_t *precord);
-  
-extern int mu_registrar_lookup (const char *name, int flags, 
-                                mu_record_t *precord, int *pflags);
-extern int mu_registrar_lookup_url (mu_url_t url, int flags,
+
+int mu_registrar_lookup (const char *name, int flags, 
+                         mu_record_t *precord, int *pflags);
+int mu_registrar_lookup_url (mu_url_t url, int flags,
                                    mu_record_t *precord, int *pflags);
-extern int mu_registrar_record       (mu_record_t);
-extern int mu_unregistrar_record     (mu_record_t);
+int mu_registrar_record       (mu_record_t);
+int mu_unregistrar_record     (mu_record_t);
 
 /* Scheme.  */
-extern int mu_record_is_scheme       (mu_record_t, mu_url_t, int flags);
-extern int mu_record_set_scheme      (mu_record_t, const char *);
-extern int mu_record_set_is_scheme   (mu_record_t, 
-                      int (*_is_scheme) (mu_record_t, mu_url_t, int));
+int mu_record_is_scheme       (mu_record_t, mu_url_t, int flags);
 
 /* Url.  */
-extern int mu_record_get_url         (mu_record_t, int (*(*)) (mu_url_t));
-extern int mu_record_set_url         (mu_record_t, int (*) (mu_url_t));
-extern int mu_record_set_get_url     (mu_record_t, 
-                      int (*_get_url) (mu_record_t, int (*(*)) (mu_url_t)));
+int mu_record_get_url         (mu_record_t, int (*(*)) (mu_url_t));
+int mu_record_check_url (mu_record_t record, mu_url_t url, int *pmask);
+int mu_registrar_test_local_url (mu_url_t url, int *pres);
 /*  Mailbox. */
-extern int mu_record_get_mailbox     (mu_record_t, int (*(*)) (mu_mailbox_t));
-extern int mu_record_set_mailbox     (mu_record_t, int (*) (mu_mailbox_t));
-extern int mu_record_set_get_mailbox (mu_record_t, 
-                 int (*_get_mailbox) (mu_record_t, int (*(*)) (mu_mailbox_t)));
+int mu_record_get_mailbox     (mu_record_t, int (*(*)) (mu_mailbox_t));
 /* Mailer.  */
-extern int mu_record_get_mailer      (mu_record_t,
-                                  int (*(*)) (mu_mailer_t));
-extern int mu_record_set_mailer      (mu_record_t, int (*) (mu_mailer_t));
-extern int mu_record_set_get_mailer  (mu_record_t, 
-        int (*_get_mailer) (mu_record_t, int (*(*)) (mu_mailer_t)));
+int mu_record_get_mailer      (mu_record_t, int (*(*)) (mu_mailer_t));
 /* Folder.  */
-extern int mu_record_get_folder      (mu_record_t, int (*(*)) (mu_folder_t));
-extern int mu_record_set_folder      (mu_record_t, int (*) (mu_folder_t));
-extern int mu_record_set_get_folder  (mu_record_t, 
-         int (*_get_folder) (mu_record_t, int (*(*)) (mu_folder_t)));
-
-extern int mu_record_list_p (mu_record_t record, const char *name, int);
+int mu_record_get_folder      (mu_record_t, int (*(*)) (mu_folder_t));
+  
+int mu_record_list_p (mu_record_t record, const char *name, int);
   
 /* Records provided by the library.  */
 
diff --git a/include/mailutils/sys/url.h b/include/mailutils/sys/url.h
index 095a111..f782bb0 100644
--- a/include/mailutils/sys/url.h
+++ b/include/mailutils/sys/url.h
@@ -27,6 +27,7 @@ extern "C" {
 
 struct _mu_url
 {
+  int flags;  /* See MU_URL_ flags in ../url.h */
   /* Data */
   char  *name;
   char  *scheme;
diff --git a/include/mailutils/url.h b/include/mailutils/url.h
index 449fbc4..231432d 100644
--- a/include/mailutils/url.h
+++ b/include/mailutils/url.h
@@ -25,10 +25,33 @@
 extern "C" {
 #endif
 
+#define MU_URL_USER   0x0001 /* Has a user part */
+#define MU_URL_SECRET 0x0002 /* Has a secret (password) part */
+#define MU_URL_AUTH   0x0004 /* Has auth part */
+#define MU_URL_HOST   0x0008 /* Has host part */
+#define MU_URL_PORT   0x0010 /* Has port part */  
+#define MU_URL_PATH   0x0020 /* Has path */
+#define MU_URL_PARAM  0x0040 /* Has parameters */
+#define MU_URL_QUERY  0x0080 /* Has query */
+  
+#define MU_URL_CRED (MU_URL_USER | MU_URL_SECRET | MU_URL_AUTH)  
+  /* Has some of authentication credentials */
+#define MU_URL_INET (MU_URL_HOST | MU_URL_PORT)
+  /* Has Inet address */
+#define MU_URL_ALL \
+  (MU_URL_CRED | \
+   MU_URL_HOST | \
+   MU_URL_PATH | \
+   MU_URL_PARAM | \
+   MU_URL_QUERY)
+
 int  mu_url_create    (mu_url_t *, const char *name);
 int  mu_url_dup       (mu_url_t old_url, mu_url_t *new_url);
 int  mu_url_uplevel   (mu_url_t url, mu_url_t *upurl);
 
+int mu_url_get_flags (mu_url_t, int *);
+int mu_url_has_flag (mu_url_t, int);  
+  
 void mu_url_destroy   (mu_url_t *);
 int  mu_url_parse     (mu_url_t);
 
diff --git a/libmailutils/base/registrar.c b/libmailutils/base/registrar.c
index d24aac2..da43bff 100644
--- a/libmailutils/base/registrar.c
+++ b/libmailutils/base/registrar.c
@@ -281,25 +281,6 @@ mu_record_is_scheme (mu_record_t record, mu_url_t url, int 
flags)
 }
 
 int
-mu_record_set_scheme (mu_record_t record, const char *scheme)
-{
-  if (record == NULL)
-    return EINVAL;
-  record->scheme = scheme;
-  return 0;
-}
-
-int
-mu_record_set_is_scheme (mu_record_t record,
-                        int (*_is_scheme) (mu_record_t, mu_url_t, int))
-{
-  if (record == NULL)
-    return EINVAL;
-  record->_is_scheme = _is_scheme;
-  return 0;
-}
-
-int
 mu_record_get_url (mu_record_t record, int (*(*_purl)) (mu_url_t))
 {
   if (record == NULL)
@@ -314,25 +295,6 @@ mu_record_get_url (mu_record_t record, int (*(*_purl)) 
(mu_url_t))
 }
 
 int
-mu_record_set_url (mu_record_t record, int (*_mu_url) (mu_url_t))
-{
-  if (record == NULL)
-    return EINVAL;
-  record->_url = _mu_url;
-  return 0;
-}
-
-int
-mu_record_set_get_url (mu_record_t record, int (*_get_url)
-                   (mu_record_t, int (*(*)) (mu_url_t)))
-{
-  if (record == NULL)
-    return EINVAL;
-  record->_get_url = _get_url;
-  return 0;
-}
-
-int
 mu_record_get_mailbox (mu_record_t record, int (*(*_pmailbox)) (mu_mailbox_t))
 {
   if (record == NULL)
@@ -347,25 +309,6 @@ mu_record_get_mailbox (mu_record_t record, int 
(*(*_pmailbox)) (mu_mailbox_t))
 }
 
 int
-mu_record_set_mailbox (mu_record_t record, int (*_mu_mailbox) (mu_mailbox_t))
-{
-  if (record)
-    return EINVAL;
-  record->_mailbox = _mu_mailbox;
-  return 0;
-}
-
-int
-mu_record_set_get_mailbox (mu_record_t record, 
-     int (*_get_mailbox) (mu_record_t, int (*(*)) (mu_mailbox_t)))
-{
-  if (record)
-    return EINVAL;
-  record->_get_mailbox = _get_mailbox;
-  return 0;
-}
-
-int
 mu_record_get_mailer (mu_record_t record, int (*(*_pmailer)) (mu_mailer_t))
 {
   if (record == NULL)
@@ -380,25 +323,6 @@ mu_record_get_mailer (mu_record_t record, int 
(*(*_pmailer)) (mu_mailer_t))
 }
 
 int
-mu_record_set_mailer (mu_record_t record, int (*_mu_mailer) (mu_mailer_t))
-{
-  if (record)
-    return EINVAL;
-  record->_mailer = _mu_mailer;
-  return 0;
-}
-
-int
-mu_record_set_get_mailer (mu_record_t record, 
-  int (*_get_mailer) (mu_record_t, int (*(*)) (mu_mailer_t)))
-{
-  if (record == NULL)
-    return EINVAL;
-  record->_get_mailer = _get_mailer;
-  return 0;
-}
-
-int
 mu_record_get_folder (mu_record_t record, int (*(*_pfolder)) (mu_folder_t))
 {
   if (record == NULL)
@@ -413,30 +337,64 @@ mu_record_get_folder (mu_record_t record, int 
(*(*_pfolder)) (mu_folder_t))
 }
 
 int
-mu_record_set_folder (mu_record_t record, int (*_mu_folder) (mu_folder_t))
+mu_record_list_p (mu_record_t record, const char *name, int flags)
 {
   if (record == NULL)
     return EINVAL;
-  record->_folder = _mu_folder;
-  return 0;
+  return record == NULL
+          || !record->_list_p
+          || record->_list_p (record, name, flags);
 }
 
 int
-mu_record_set_get_folder (mu_record_t record, 
-   int (*_get_folder) (mu_record_t, int (*(*)) (mu_folder_t)))
+mu_record_check_url (mu_record_t record, mu_url_t url, int *pmask)
 {
-  if (record == NULL)
+  int mask;
+  int flags;
+  int rc;
+  
+  if (!record || !url)
     return EINVAL;
-  record->_get_folder = _get_folder;
+
+  rc = mu_url_get_flags (url, &flags);
+  if (rc)
+    return rc;
+
+  mask = flags & record->url_must_have;
+  if (mask != record->url_must_have)
+    {
+      if (pmask)
+       *pmask = record->url_must_have & ~mask;
+      return MU_ERR_URL_MISS_PARTS;
+    }
+  mask = flags & ~(record->url_may_have | record->url_must_have);
+  if (mask)
+    {
+      if (pmask)
+       *pmask = mask;
+      return MU_ERR_URL_EXTRA_PARTS;
+    }
   return 0;
 }
 
+/* Test if URL corresponds to a local record.  
+   Return:
+     0            -  OK, the result is stored in *pres;
+     MU_ERR_NOENT -  don't know: there's no matching record;
+     EINVAL       -  some of the arguments is not valid;
+     other        -  URL lookup failed.
+*/
 int
-mu_record_list_p (mu_record_t record, const char *name, int flags)
+mu_registrar_test_local_url (mu_url_t url, int *pres)
 {
-  if (record == NULL)
+  int rc;
+  mu_record_t rec;
+
+  if (!url || !pres)
     return EINVAL;
-  return record == NULL
-          || !record->_list_p
-          || record->_list_p (record, name, flags);
+  rc = mu_registrar_lookup_url (url, MU_FOLDER_ATTRIBUTE_ALL, &rec, NULL);
+  if (rc)
+    return rc;
+  *pres = rec->flags & MU_RECORD_LOCAL;
+  return 0;
 }
diff --git a/libmailutils/base/url.c b/libmailutils/base/url.c
index 82b9f3f..9b4e102 100644
--- a/libmailutils/base/url.c
+++ b/libmailutils/base/url.c
@@ -176,6 +176,7 @@ mu_url_copy0 (mu_url_t old_url, mu_url_t new_url)
        return ENOMEM;
       new_url->qargc = argc;
     }
+  new_url->flags = old_url->flags;
   return 0;
 #undef URLCOPY
 }
@@ -292,8 +293,7 @@ mu_url_parse (mu_url_t url)
 
   memset (&u, 0, sizeof u);
   /* can't have been parsed already */
-  if (url->scheme || url->user || url->secret || url->auth ||
-      url->host || url->path || url->qargc)
+  if (url->flags)
     return EINVAL;
 
   n = strdup (url->name);
@@ -331,21 +331,25 @@ mu_url_parse (mu_url_t url)
         though.
        */
 
-#define UALLOC(X)                                                      \
-      if (u.X && u.X[0] &&                                             \
-         !(url->X = (want_decode ? mu_url_decode (u.X) : strdup (u.X)))) \
+#define UALLOC(X,f)                                                    \
+      if (u.X && u.X[0])                                               \
        {                                                               \
-         err = ENOMEM;                                                 \
-         goto CLEANUP;                                                 \
+         url->X = want_decode ? mu_url_decode (u.X) : strdup (u.X);    \
+         if (!url->X)                                                  \
+           {                                                           \
+             err = ENOMEM;                                             \
+             goto CLEANUP;                                             \
+           }                                                           \
+         url->flags |= f;                                              \
        }                                                               \
       else                                                             \
        {                                                               \
          /* Set zero-length strings to NULL. */                        \
-         u.X = NULL;                                                   \
+         url->X = NULL;                                                \
        }
 
-      UALLOC (scheme);
-      UALLOC (user);
+      UALLOC (scheme, 0);
+      UALLOC (user, MU_URL_USER);
 
       if (u.secret)
        {
@@ -357,20 +361,27 @@ mu_url_parse (mu_url_t url)
            goto CLEANUP;
 
          url->secret = newsec;
+         url->flags |= MU_URL_SECRET;
        }
 
-      UALLOC (auth);
-      UALLOC (host);
-      UALLOC (path);
+      UALLOC (auth, MU_URL_AUTH);
+      UALLOC (host, MU_URL_HOST);
+      UALLOC (path, MU_URL_PATH);
 
 #undef UALLOC
       url->fvcount = u.fvcount;
       url->fvpairs = u.fvpairs;
-
+      if (u.fvcount)
+       url->flags |= MU_URL_PARAM;
+         
       url->qargc = u.qargc;
       url->qargv = u.qargv;
+      if (u.qargc)
+       url->flags |= MU_URL_QUERY;
 
       url->port = u.port;
+      if (u.port)
+       url->flags |= MU_URL_PORT;
     }
 
 CLEANUP:
@@ -1189,3 +1200,21 @@ mu_url_expand_path (mu_url_t url)
 
   return 0;
 }
+
+int
+mu_url_get_flags (mu_url_t url, int *pf)
+{
+  if (!url || !pf)
+    return EINVAL;
+  *pf = url->flags;
+  return 0;
+}
+
+int
+mu_url_has_flag (mu_url_t url, int flags)
+{
+  if (!url)
+    return 0;
+  return url->flags & flags;
+}
+
diff --git a/libmailutils/diag/errors b/libmailutils/diag/errors
index 5f82f7b..3807524 100644
--- a/libmailutils/diag/errors
+++ b/libmailutils/diag/errors
@@ -92,3 +92,6 @@ MU_ERR_READ                 _("Read error")
 
 MU_ERR_NO_TRANSPORT         _("Transport stream not set")
 MU_ERR_AUTH_NO_CRED         _("No credentials supplied")
+
+MU_ERR_URL_MISS_PARTS       _("URL missing required parts")
+MU_ERR_URL_EXTRA_PARTS      _("URL has parts not allowed by its scheme")
diff --git a/libmailutils/mailbox/folder.c b/libmailutils/mailbox/folder.c
index 2b85601..f6e75c0 100644
--- a/libmailutils/mailbox/folder.c
+++ b/libmailutils/mailbox/folder.c
@@ -76,10 +76,15 @@ mu_folder_create_from_record (mu_folder_t *pfolder, 
mu_url_t url,
       mu_record_get_folder (record, &f_init);
       if (f_init)
         {
-         int status;
+         int status, mask;
          mu_folder_t folder;
          int (*u_init) (mu_url_t) = NULL;
 
+         status = mu_record_check_url (record, url, &mask);
+         if (status)
+           /* FIXME: mask would provide more info */
+           return status;
+         
          mu_record_get_url (record, &u_init);
          if (u_init)
            {
diff --git a/libproto/imap/folder.c b/libproto/imap/folder.c
index c95c930..ed5ba54 100644
--- a/libproto/imap/folder.c
+++ b/libproto/imap/folder.c
@@ -66,6 +66,9 @@ static struct _mu_record _imap_record =
 {
   MU_IMAP_PRIO,
   MU_IMAP_SCHEME,
+  MU_RECORD_DEFAULT,
+  MU_URL_CRED | MU_URL_INET | MU_URL_PATH,
+  MU_URL_HOST,
   _url_imap_init,     /* url entry.  */
   _mailbox_imap_init, /* Mailbox entry.  */
   NULL,               /* Mailer entry.  */
@@ -87,6 +90,9 @@ static struct _mu_record _imaps_record =
 {
   MU_IMAP_PRIO,
   MU_IMAPS_SCHEME,
+  MU_RECORD_DEFAULT,
+  MU_URL_CRED | MU_URL_INET | MU_URL_PATH | MU_URL_PARAM,
+  MU_URL_HOST,
   _url_imaps_init,     /* url entry.  */
   _mailbox_imaps_init, /* Mailbox entry.  */
   NULL,                /* Mailer entry.  */
diff --git a/libproto/maildir/folder.c b/libproto/maildir/folder.c
index 4fef07b..657dfa5 100644
--- a/libproto/maildir/folder.c
+++ b/libproto/maildir/folder.c
@@ -98,6 +98,9 @@ static struct _mu_record _maildir_record =
 {
   MU_MAILDIR_PRIO,
   MU_MAILDIR_SCHEME,
+  MU_RECORD_LOCAL,
+  MU_URL_PATH,
+  MU_URL_PATH,
   mu_url_expand_path, /* Url init.  */
   _mailbox_maildir_init, /* Mailbox init.  */
   NULL, /* Mailer init.  */
diff --git a/libproto/mailer/prog.c b/libproto/mailer/prog.c
index 216869c..d026177 100644
--- a/libproto/mailer/prog.c
+++ b/libproto/mailer/prog.c
@@ -44,6 +44,11 @@ static struct _mu_record _prog_record =
 {
   MU_PROG_PRIO,
   MU_PROG_SCHEME,
+  MU_RECORD_DEFAULT,
+  /* FIXME: MU_URL_USER could be used to request running with this
+     user privileges. */
+  MU_URL_PATH | MU_URL_QUERY, 
+  MU_URL_PATH,
   _url_prog_init,    /* url init.  */
   _mu_mailer_mailbox_init,  /* Mailbox entry.  */
   _mu_mailer_prog_init, /* Mailer entry.  */
@@ -68,11 +73,6 @@ _url_prog_uplevel (const mu_url_t orig, mu_url_t *up)
 static int
 _url_prog_init (mu_url_t url)
 {
-  /* not valid in a prog url */
-  if (url->secret || url->auth || url->host || url->port)
-    return EINVAL;
-  if (!url->path)
-    return EINVAL;
   url->_uplevel = _url_prog_uplevel;
   return 0;
 }
diff --git a/libproto/mailer/remote.c b/libproto/mailer/remote.c
index 1781687..ae96cee 100644
--- a/libproto/mailer/remote.c
+++ b/libproto/mailer/remote.c
@@ -75,6 +75,9 @@ _url_remote_smtp_init (mu_url_t url)
 static struct _mu_record _mu_remote_smtp_record = {
   MU_SMTP_PRIO,
   "remote+smtp",
+  MU_RECORD_DEFAULT,
+  MU_URL_CRED | MU_URL_INET | MU_URL_PATH | MU_URL_PARAM,
+  MU_URL_HOST,
   _url_remote_smtp_init,       /* url init.  */
   _mu_mailer_mailbox_init,      /* Mailbox init.  */
   NULL,                                /* Mailer init.  */
@@ -104,6 +107,9 @@ static struct _mu_record _mu_remote_sendmail_record =
 {
   MU_SENDMAIL_PRIO,
   "remote+sendmail",
+  MU_RECORD_DEFAULT,
+  MU_URL_PATH,
+  MU_URL_PATH,
   _url_remote_sendmail_init,    /* url init.  */
   _mu_mailer_mailbox_init,      /* Mailbox entry.  */
   _mu_mailer_sendmail_init, /* Mailer entry.  */
@@ -130,6 +136,9 @@ static struct _mu_record _mu_remote_prog_record =
 {
   MU_PROG_PRIO,
   "remote+prog",
+  MU_RECORD_DEFAULT,
+  MU_URL_CRED | MU_URL_PATH | MU_URL_QUERY,
+  MU_URL_PATH,
   _url_remote_prog_init,    /* url init.  */
   _mu_mailer_mailbox_init,  /* Mailbox entry.  */
   _mu_mailer_prog_init, /* Mailer entry.  */
diff --git a/libproto/mailer/sendmail.c b/libproto/mailer/sendmail.c
index 0a991a3..f1ba068 100644
--- a/libproto/mailer/sendmail.c
+++ b/libproto/mailer/sendmail.c
@@ -53,12 +53,7 @@ static int sendmail_send_message (mu_mailer_t, mu_message_t, 
mu_address_t,
 static int
 _url_sendmail_init (mu_url_t url)
 {
-  /* not valid in a sendmail url */
-  if (url->user || url->secret || url->auth || url->qargc
-      || url->host || url->port)
-    return EINVAL;
-
-  if (url->path == 0)
+  if (url->path == NULL)
     if ((url->path = strdup (PATH_SENDMAIL)) == 0)
       return ENOMEM;
 
@@ -275,6 +270,10 @@ static struct _mu_record _sendmail_record =
 {
   MU_SENDMAIL_PRIO,
   MU_SENDMAIL_SCHEME,
+  MU_RECORD_DEFAULT,
+  MU_URL_PATH,
+  0, /* Nothing is required in the URL, except scheme. Missing path means
+       using PATH_SENDMAIL. */
   _url_sendmail_init,    /* url init.  */
   _mu_mailer_mailbox_init,     /* Mailbox entry.  */
   _mu_mailer_sendmail_init, /* Mailer entry.  */
diff --git a/libproto/mailer/smtp.c b/libproto/mailer/smtp.c
index 72e7c7c..cfcad0e 100644
--- a/libproto/mailer/smtp.c
+++ b/libproto/mailer/smtp.c
@@ -56,26 +56,17 @@ 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,
+  MU_RECORD_DEFAULT,
+  MU_URL_CRED | MU_URL_INET | MU_URL_PARAM,
+  MU_URL_HOST,
   _url_smtp_init,              /* url init.  */
   _mu_mailer_mailbox_init,     /* Mailbox init.  */
   _mailer_smtp_init,           /* Mailer init.  */
@@ -101,10 +92,27 @@ struct _smtp_mailer
   mu_address_t    rcpt_bcc;
 };
 
+static void
+smtp_mailer_add_auth_mech (struct _smtp_mailer *smtp_mailer, const char *str)
+{
+  int mc, i, rc;
+  char **mv;
+  
+  rc = mu_argcv_get_np (str, strlen (str),
+                       ",", NULL,
+                       0,
+                       &mc, &mv, NULL);
+  if (rc == 0)
+    for (i = 0; i < mc; i++)
+      mu_smtp_add_auth_mech (smtp_mailer->smtp, mv[i]);
+  
+  free (mv);
+}
+
 static int
 smtp_open (mu_mailer_t mailer, int flags)
 {
-  const char *host;
+  const char *host, *auth;
   long port;
   struct _smtp_mailer *smtp_mailer = mailer->data;
   int rc;
@@ -134,6 +142,9 @@ smtp_open (mu_mailer_t mailer, int flags)
   if (mu_url_get_port (mailer->url, &port))
     port = 25;
 
+  if (mu_url_sget_auth (mailer->url, &auth) == 0)
+    smtp_mailer_add_auth_mech (smtp_mailer, auth);
+  
   /* Additional information is supplied in the arguments */
   if (mu_url_sget_fvpairs (mailer->url, &parmc, &parmv) == 0)
     {
@@ -146,20 +157,7 @@ smtp_open (mu_mailer_t mailer, int flags)
          else if (strcmp (parmv[i], "noauth") == 0)
            noauth = 1;
          else if (strncmp (parmv[i], "auth=", 5) == 0)
-           {
-             int mc, j;
-             char **mv;
-         
-             rc = mu_argcv_get_np (parmv[i] + 5, strlen (parmv[i] + 5),
-                                   ",", NULL,
-                                   0,
-                                   &mc, &mv, NULL);
-             if (rc == 0)
-               for (j = 0; j < mc; j++)
-                 mu_smtp_add_auth_mech (smtp_mailer->smtp, mv[j]);
-             
-             free (mv);
-           }
+           smtp_mailer_add_auth_mech (smtp_mailer, parmv[i] + 5);
          /* unrecognized arguments silently ignored */
        }
     }
diff --git a/libproto/mbox/folder.c b/libproto/mbox/folder.c
index 7697825..c6a9d51 100644
--- a/libproto/mbox/folder.c
+++ b/libproto/mbox/folder.c
@@ -100,6 +100,9 @@ static struct _mu_record _mbox_record =
 {
   MU_MBOX_PRIO,
   MU_MBOX_SCHEME,
+  MU_RECORD_LOCAL,
+  MU_URL_PATH,
+  MU_URL_PATH,
   mu_url_expand_path, /* URL init.  */
   _mailbox_mbox_init, /* Mailbox init.  */
   NULL, /* Mailer init.  */
diff --git a/libproto/mh/folder.c b/libproto/mh/folder.c
index 1743ca0..f5feb1f 100644
--- a/libproto/mh/folder.c
+++ b/libproto/mh/folder.c
@@ -138,6 +138,9 @@ static struct _mu_record _mh_record =
 {
   MU_MH_PRIO,
   MU_MH_SCHEME,
+  MU_RECORD_LOCAL,
+  MU_URL_PATH,
+  MU_URL_PATH,
   mu_url_expand_path, /* Url init.  */
   _mailbox_mh_init, /* Mailbox init.  */
   NULL, /* Mailer init.  */
diff --git a/libproto/nntp/folder.c b/libproto/nntp/folder.c
index 4573559..071ffae 100644
--- a/libproto/nntp/folder.c
+++ b/libproto/nntp/folder.c
@@ -45,6 +45,9 @@ static struct _mu_record _nntp_record =
 {
   MU_NNTP_PRIO,
   MU_NNTP_URL_SCHEME,
+  MU_RECORD_DEFAULT,
+  MU_URL_CRED | MU_URL_INET | MU_URL_PATH,
+  MU_URL_HOST,
   _nntp_url_init, /* Url init.  */
   _nntp_mailbox_init, /* Mailbox init.  */
   NULL, /* Mailer init.  */
diff --git a/libproto/nntp/url.c b/libproto/nntp/url.c
index 5354750..3870107 100644
--- a/libproto/nntp/url.c
+++ b/libproto/nntp/url.c
@@ -33,13 +33,6 @@
 
 #include <mailutils/sys/url.h>
 
-static void url_nntp_destroy (mu_url_t url);
-
-static void
-url_nntp_destroy (mu_url_t url MU_ARG_UNUSED)
-{
-}
-
 /*
   POP URL:
   nntp://<host>:<port>/<newsgroup-name>/<article-number>
@@ -48,23 +41,6 @@ url_nntp_destroy (mu_url_t url MU_ARG_UNUSED)
 int
 _nntp_url_init (mu_url_t url)
 {
-  int status = 0;
-
-  url->_destroy = url_nntp_destroy;
-
-  status = mu_url_parse(url);
-
-  if(status)
-    return status;
-
-  /* is it nntp? */
-  if (strcmp (MU_NNTP_URL_SCHEME, url->scheme) != 0)
-    return EINVAL;
-
-  /* not valid in a nntp url */
-  if (!url->host || !url->path)
-    return EINVAL;
-
   if (url->port == 0)
     url->port = MU_NNTP_DEFAULT_PORT;
 
diff --git a/libproto/pop/folder.c b/libproto/pop/folder.c
index 82f8197..ec945f9 100644
--- a/libproto/pop/folder.c
+++ b/libproto/pop/folder.c
@@ -47,6 +47,9 @@ static struct _mu_record _pop_record =
 {
   MU_POP_PRIO,
   MU_POP_SCHEME,
+  MU_RECORD_DEFAULT,
+  MU_URL_CRED | MU_URL_INET,
+  MU_URL_HOST,
   _url_pop_init, /* Url init.  */
   _mailbox_pop_init, /* Mailbox init.  */
   NULL, /* Mailer init.  */
@@ -65,6 +68,9 @@ static struct _mu_record _pops_record =
 {
   MU_POP_PRIO,
   MU_POPS_SCHEME,
+  MU_RECORD_DEFAULT,
+  MU_URL_CRED | MU_URL_INET,
+  MU_URL_HOST,
   _url_pops_init, /* Url init.  */
   _mailbox_pops_init, /* Mailbox init.  */
   NULL, /* Mailer init.  */
diff --git a/libproto/pop/url.c b/libproto/pop/url.c
index 86992b6..f528064 100644
--- a/libproto/pop/url.c
+++ b/libproto/pop/url.c
@@ -33,13 +33,6 @@
 #include <mailutils/sys/url.h>
 #include <mailutils/sys/registrar.h>
 
-static void url_pop_destroy (mu_url_t url);
-
-static void
-url_pop_destroy (mu_url_t url MU_ARG_UNUSED)
-{
-}
-
 /*
   POP URLs:
     pop://[<user>[;AUTH=<auth>address@hidden<host>[:<port>]
@@ -51,13 +44,6 @@ _url_pop_init (mu_url_t url)
 {
   if (url->port == 0)
     url->port = MU_POP_PORT;
-  
-  url->_destroy = url_pop_destroy;
-
-  /* not valid in pop url */
-  if (url->path || url->qargc || !url->host)
-    return EINVAL;
-
   return 0;
 }
 
@@ -72,13 +58,6 @@ _url_pops_init (mu_url_t url)
 {
   if (url->port == 0)
     url->port = MU_POPS_PORT;
-
-  url->_destroy = url_pop_destroy;
-
-  /* not valid in pops url */
-  if (url->path || url->qargc || !url->host)
-    return EINVAL;
-
   return 0;
 }
 
diff --git a/maidag/deliver.c b/maidag/deliver.c
index 57684b9..5a65259 100644
--- a/maidag/deliver.c
+++ b/maidag/deliver.c
@@ -314,13 +314,25 @@ deliver_to_mailbox (mu_mailbox_t mbox, mu_message_t msg,
 }
 
 static int
+is_remote_url (mu_url_t url)
+{
+  int rc, res;
+
+  if (!url)
+    return 0;
+  
+  rc = mu_registrar_test_local_url (url, &res);
+  return rc == 0 && res == 0;
+}
+
+static int
 do_delivery (mu_url_t url, mu_message_t msg, const char *name, char **errp)
 {
   struct mu_auth_data *auth = NULL;
   mu_mailbox_t mbox;
   int status;
 
-  if (name)
+  if (name && !is_remote_url (url))
     {
       auth = mu_get_auth_by_name (name);
       if (!auth)
diff --git a/maidag/maidag.c b/maidag/maidag.c
index f67b581..b588ca9 100644
--- a/maidag/maidag.c
+++ b/maidag/maidag.c
@@ -564,6 +564,9 @@ main (int argc, char *argv[])
   maidag_cfg_init ();
   
   /* Parse command line */
+#ifdef WITH_TLS
+  mu_gocs_register ("tls", mu_tls_module_init);
+#endif
   mu_argp_init (NULL, NULL);
 
   mu_m_server_create (&server, program_version);


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]