From MAILER-DAEMON Mon Apr 06 05:18:56 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lqkym-00086S-ID for mharc-commit-mailutils@gnu.org; Mon, 06 Apr 2009 05:18:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lqkyk-00086N-26 for commit-mailutils@gnu.org; Mon, 06 Apr 2009 05:18:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lqkyh-000863-7y for commit-mailutils@gnu.org; Mon, 06 Apr 2009 05:18:52 -0400 Received: from [199.232.76.173] (port=40303 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lqkyh-000860-2N for commit-mailutils@gnu.org; Mon, 06 Apr 2009 05:18:51 -0400 Received: from savannah.gnu.org ([199.232.41.3]:41432 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lqkyg-0006Wy-RY for commit-mailutils@gnu.org; Mon, 06 Apr 2009 05:18:50 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lqkyf-0004Um-Of for commit-mailutils@gnu.org; Mon, 06 Apr 2009 09:18:50 +0000 Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lqkyd-0004Tu-4L for commit-mailutils@gnu.org; Mon, 06 Apr 2009 09:18:49 +0000 From: "Sergey Poznyakoff" To: commit-mailutils@gnu.org X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 4372418df0a5872ea27419d6ed8d16400dd9c965 X-Git-Newrev: 14e0fd63234afa62f413369009bb15073fcc5cfe Message-Id: Date: Mon, 06 Apr 2009 09:18:47 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-259-g14e0fd6 X-BeenThere: commit-mailutils@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Commit notices for GNU mailutils List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2009 09:18:54 -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=14e0fd63234afa62f413369009bb15073fcc5cfe The branch, master has been updated via 14e0fd63234afa62f413369009bb15073fcc5cfe (commit) from 4372418df0a5872ea27419d6ed8d16400dd9c965 (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 14e0fd63234afa62f413369009bb15073fcc5cfe Author: Sergey Poznyakoff Date: Mon Apr 6 12:18:27 2009 +0300 Bugfix. * libproto/remote/folder.c (_remote_is_scheme): Fix invalid return value. ----------------------------------------------------------------------- Summary of changes: libproto/remote/folder.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libproto/remote/folder.c b/libproto/remote/folder.c index 69b3898..a9fa675 100644 --- a/libproto/remote/folder.c +++ b/libproto/remote/folder.c @@ -52,7 +52,7 @@ _remote_is_scheme (mu_record_t record, mu_url_t url, int flags) || scheme_len < MU_REMOTE_MBOX_PREFIX_LEN || memcmp (MU_REMOTE_MBOX_PREFIX, scheme, MU_REMOTE_MBOX_PREFIX_LEN) != 0) - return EINVAL; + return 0; memcpy (&s_url, url, sizeof (s_url)); hooks/post-receive -- GNU Mailutils From MAILER-DAEMON Tue Apr 07 09:34:35 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LrBRj-0007vn-8Y for mharc-commit-mailutils@gnu.org; Tue, 07 Apr 2009 09:34:35 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LrBRh-0007vC-4o for commit-mailutils@gnu.org; Tue, 07 Apr 2009 09:34:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LrBRf-0007uq-R7 for commit-mailutils@gnu.org; Tue, 07 Apr 2009 09:34:32 -0400 Received: from [199.232.76.173] (port=52251 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrBRf-0007uZ-Dd for commit-mailutils@gnu.org; Tue, 07 Apr 2009 09:34:31 -0400 Received: from savannah.gnu.org ([199.232.41.3]:56842 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LrBRe-0004Xp-2u for commit-mailutils@gnu.org; Tue, 07 Apr 2009 09:34:30 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LrBRd-0000dB-Db for commit-mailutils@gnu.org; Tue, 07 Apr 2009 13:34:29 +0000 Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LrBRW-0000c4-Aj for commit-mailutils@gnu.org; Tue, 07 Apr 2009 13:34:29 +0000 From: "Sergey Poznyakoff" To: commit-mailutils@gnu.org X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 14e0fd63234afa62f413369009bb15073fcc5cfe X-Git-Newrev: 1e7a81ad25005ac5268e43a39c9c9dd9d8906557 Message-Id: Date: Tue, 07 Apr 2009 13:34:23 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-260-g1e7a81a X-BeenThere: commit-mailutils@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Commit notices for GNU mailutils List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2009 13:34:33 -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=1e7a81ad25005ac5268e43a39c9c9dd9d8906557 The branch, master has been updated via 1e7a81ad25005ac5268e43a39c9c9dd9d8906557 (commit) from 14e0fd63234afa62f413369009bb15073fcc5cfe (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 1e7a81ad25005ac5268e43a39c9c9dd9d8906557 Author: Sergey Poznyakoff Date: Tue Apr 7 16:22:11 2009 +0300 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. ----------------------------------------------------------------------- Summary of changes: NEWS | 30 +++++++- configure.ac | 2 - include/mailutils/registrar.h | 5 +- libmu_argp/mu_argp.h | 3 +- libproto/Makefile.am | 4 +- libproto/include/mailer0.h | 6 +- libproto/include/registrar0.h | 11 +-- libproto/include/url0.h | 1 + libproto/mailer/Makefile.am | 6 +- libproto/{remote => mailer}/mbox.c | 36 +++------ libproto/mailer/prog.c | 20 +++-- libproto/mailer/remote.c | 148 ++++++++++++++++++++++++++++++++++++ libproto/mailer/sendmail.c | 59 +++++++++----- libproto/mailer/smtp.c | 36 ++++++++- libproto/mailer/url_sendmail.c | 60 --------------- libproto/mailer/url_smtp.c | 52 ------------- libproto/remote/.gitignore | 9 -- libproto/remote/Makefile.am | 29 ------- libproto/remote/folder.c | 80 ------------------- maidag/Makefile.am | 1 - maidag/deliver.c | 34 +-------- maidag/guile.c | 4 +- maidag/maidag.c | 15 +++- mailbox/mailbox.c | 17 ++-- mailbox/url.c | 3 + 25 files changed, 315 insertions(+), 356 deletions(-) rename libproto/{remote => mailer}/mbox.c (89%) create mode 100644 libproto/mailer/remote.c delete mode 100644 libproto/mailer/url_sendmail.c delete mode 100644 libproto/mailer/url_smtp.c delete mode 100644 libproto/remote/.gitignore delete mode 100644 libproto/remote/Makefile.am delete mode 100644 libproto/remote/folder.c diff --git a/NEWS b/NEWS index 24a2faa..ae078c9 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -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. diff --git a/configure.ac b/configure.ac index 453e537..a675b11 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/include/mailutils/registrar.h b/include/mailutils/registrar.h index 818badc..6462054 100644 --- a/include/mailutils/registrar.h +++ b/include/mailutils/registrar.h @@ -1,6 +1,6 @@ /* 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 diff --git a/libmu_argp/mu_argp.h b/libmu_argp/mu_argp.h index 1b316fa..0c20be2 100644 --- a/libmu_argp/mu_argp.h +++ b/libmu_argp/mu_argp.h @@ -1,6 +1,6 @@ /* 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 } diff --git a/libproto/Makefile.am b/libproto/Makefile.am index 591ef65..2cc7634 100644 --- a/libproto/Makefile.am +++ b/libproto/Makefile.am @@ -1,6 +1,6 @@ ## 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 diff --git a/libproto/include/mailer0.h b/libproto/include/mailer0.h index 40fd56d..49d1414 100644 --- a/libproto/include/mailer0.h +++ b/libproto/include/mailer0.h @@ -1,5 +1,6 @@ /* 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) diff --git a/libproto/include/registrar0.h b/libproto/include/registrar0.h index a535846..89abb6f 100644 --- a/libproto/include/registrar0.h +++ b/libproto/include/registrar0.h @@ -1,5 +1,6 @@ /* 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) diff --git a/libproto/include/url0.h b/libproto/include/url0.h index d47af57..5931d0e 100644 --- a/libproto/include/url0.h +++ b/libproto/include/url0.h @@ -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 *); }; diff --git a/libproto/mailer/Makefile.am b/libproto/mailer/Makefile.am index 592e9d8..3513f9e 100644 --- a/libproto/mailer/Makefile.am +++ b/libproto/mailer/Makefile.am @@ -1,6 +1,6 @@ ## 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 diff --git a/libproto/remote/mbox.c b/libproto/mailer/mbox.c similarity index 89% rename from libproto/remote/mbox.c rename to libproto/mailer/mbox.c index d4741c5..008f72a 100644 --- a/libproto/remote/mbox.c +++ b/libproto/mailer/mbox.c @@ -1,5 +1,5 @@ /* 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 #include #include +#include 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; +} diff --git a/libproto/mailer/prog.c b/libproto/mailer/prog.c index 5884553..4f02b6b 100644 --- a/libproto/mailer/prog.c +++ b/libproto/mailer/prog.c @@ -1,5 +1,5 @@ /* 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 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; diff --git a/libproto/mailer/remote.c b/libproto/mailer/remote.c new file mode 100644 index 0000000..b6fa83a --- /dev/null +++ b/libproto/mailer/remote.c @@ -0,0 +1,148 @@ +/* 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 . */ + +/* 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 +#endif + +#ifdef ENABLE_SMTP + +#include +#include + +#include +#include +#include + +#include +#include +#include + +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 diff --git a/libproto/mailer/sendmail.c b/libproto/mailer/sendmail.c index 7773a7e..8588267 100644 --- a/libproto/mailer/sendmail.c +++ b/libproto/mailer/sendmail.c @@ -1,6 +1,6 @@ /* 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 #include +#include #include #include -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 #include diff --git a/libproto/mailer/smtp.c b/libproto/mailer/smtp.c index 9e184cd..da5e820 100644 --- a/libproto/mailer/smtp.c +++ b/libproto/mailer/smtp.c @@ -1,6 +1,6 @@ /* 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 #include +#include #include +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 #include mu_record_t mu_smtp_record = NULL; +mu_record_t mu_remote_smtp_record = NULL; #endif diff --git a/libproto/mailer/url_sendmail.c b/libproto/mailer/url_sendmail.c deleted file mode 100644 index 8ad8e70..0000000 --- a/libproto/mailer/url_sendmail.c +++ /dev/null @@ -1,60 +0,0 @@ -/* 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 -#endif - -#ifdef ENABLE_SENDMAIL - -#include -#include -#include - -#ifdef HAVE_PATHS_H -# include -#endif - -#ifndef _PATH_SENDMAIL -# define _PATH_SENDMAIL "/usr/lib/sendmail" -#endif - -#include -#include - -/* - 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 */ diff --git a/libproto/mailer/url_smtp.c b/libproto/mailer/url_smtp.c deleted file mode 100644 index 13eb436..0000000 --- a/libproto/mailer/url_smtp.c +++ /dev/null @@ -1,52 +0,0 @@ -/* 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 -#endif - -#ifdef ENABLE_SMTP - -#include -#include -#include - -#include -#include - -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 */ diff --git a/libproto/remote/.gitignore b/libproto/remote/.gitignore deleted file mode 100644 index a343739..0000000 --- a/libproto/remote/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.la -*.lo -.deps -.libs -Makefile -Makefile.in -T -_* -.gdbinit diff --git a/libproto/remote/Makefile.am b/libproto/remote/Makefile.am deleted file mode 100644 index 11423c2..0000000 --- a/libproto/remote/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -## 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 - - diff --git a/libproto/remote/folder.c b/libproto/remote/folder.c deleted file mode 100644 index a9fa675..0000000 --- a/libproto/remote/folder.c +++ /dev/null @@ -1,80 +0,0 @@ -/* 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 -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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; diff --git a/maidag/Makefile.am b/maidag/Makefile.am index cb4a8ff..24b73bc 100644 --- a/maidag/Makefile.am +++ b/maidag/Makefile.am @@ -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@\ diff --git a/maidag/deliver.c b/maidag/deliver.c index e8a5b07..87e3cd0 100644 --- a/maidag/deliver.c +++ b/maidag/deliver.c @@ -1,6 +1,6 @@ /* 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; } diff --git a/maidag/guile.c b/maidag/guile.c index ce374be..44b08a6 100644 --- a/maidag/guile.c +++ b/maidag/guile.c @@ -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; } diff --git a/maidag/maidag.c b/maidag/maidag.c index 94aaa03..f0ccefc 100644 --- a/maidag/maidag.c +++ b/maidag/maidag.c @@ -1,5 +1,5 @@ /* 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); diff --git a/mailbox/mailbox.c b/mailbox/mailbox.c index 6864bef..aeb22c6 100644 --- a/mailbox/mailbox.c +++ b/mailbox/mailbox.c @@ -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. diff --git a/mailbox/url.c b/mailbox/url.c index 3bbea29..8bbdfba 100644 --- a/mailbox/url.c +++ b/mailbox/url.c @@ -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; hooks/post-receive -- GNU Mailutils From MAILER-DAEMON Tue Apr 07 13:17:42 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LrEve-0000Qu-7J for mharc-commit-mailutils@gnu.org; Tue, 07 Apr 2009 13:17:42 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LrEvd-0000QW-6d for commit-mailutils@gnu.org; Tue, 07 Apr 2009 13:17:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LrEvb-0000Pg-Dv for commit-mailutils@gnu.org; Tue, 07 Apr 2009 13:17:40 -0400 Received: from [199.232.76.173] (port=46897 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LrEvb-0000Pa-3I for commit-mailutils@gnu.org; Tue, 07 Apr 2009 13:17:39 -0400 Received: from savannah.gnu.org ([199.232.41.3]:47267 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LrEva-0004lr-Mx for commit-mailutils@gnu.org; Tue, 07 Apr 2009 13:17:38 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LrEvV-00061v-T4 for commit-mailutils@gnu.org; Tue, 07 Apr 2009 17:17:34 +0000 Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LrEvO-000607-BF for commit-mailutils@gnu.org; Tue, 07 Apr 2009 17:17:31 +0000 From: "Sergey Poznyakoff" To: commit-mailutils@gnu.org X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 1e7a81ad25005ac5268e43a39c9c9dd9d8906557 X-Git-Newrev: 4616b75f8a0e1d6fbbff7b20f418bc39c44ee34f Message-Id: Date: Tue, 07 Apr 2009 17:17:28 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-261-g4616b75 X-BeenThere: commit-mailutils@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Commit notices for GNU mailutils List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Apr 2009 17:17:41 -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=4616b75f8a0e1d6fbbff7b20f418bc39c44ee34f The branch, master has been updated via 4616b75f8a0e1d6fbbff7b20f418bc39c44ee34f (commit) from 1e7a81ad25005ac5268e43a39c9c9dd9d8906557 (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 4616b75f8a0e1d6fbbff7b20f418bc39c44ee34f Author: Sergey Poznyakoff Date: Tue Apr 7 20:17:15 2009 +0300 Bugfix. * mailbox/mbx_default.c (mu_mailbox_create_default): Reset mail to NULL if it is "". ----------------------------------------------------------------------- Summary of changes: mailbox/mbx_default.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mailbox/mbx_default.c b/mailbox/mbx_default.c index 1ce2389..ac7f9b1 100644 --- a/mailbox/mbx_default.c +++ b/mailbox/mbx_default.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2000, 2001, 2003, 2004, - 2005, 2006, 2007 Free Software Foundation, Inc. + 2005, 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 @@ -394,7 +394,10 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail) if (pmbox == NULL) return MU_ERR_OUT_PTR_NULL; - if (mail == NULL || *mail == '\0') + if (mail && *mail == 0) + mail = NULL; + + if (mail == NULL) { if (!_mu_mailbox_pattern) { hooks/post-receive -- GNU Mailutils From MAILER-DAEMON Mon Apr 13 03:42:55 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LtGoh-0007YT-PU for mharc-commit-mailutils@gnu.org; Mon, 13 Apr 2009 03:42:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LtGof-0007WS-F8 for commit-mailutils@gnu.org; Mon, 13 Apr 2009 03:42:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LtGod-0007WG-O1 for commit-mailutils@gnu.org; Mon, 13 Apr 2009 03:42:52 -0400 Received: from [199.232.76.173] (port=52323 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LtGod-0007WD-If for commit-mailutils@gnu.org; Mon, 13 Apr 2009 03:42:51 -0400 Received: from savannah.gnu.org ([199.232.41.3]:32995 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LtGod-00067J-4M for commit-mailutils@gnu.org; Mon, 13 Apr 2009 03:42:51 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LtGoc-000082-Cp for commit-mailutils@gnu.org; Mon, 13 Apr 2009 07:42:50 +0000 Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LtGob-00007Y-Vc for commit-mailutils@gnu.org; Mon, 13 Apr 2009 07:42:50 +0000 From: "Sergey Poznyakoff" To: commit-mailutils@gnu.org X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 4616b75f8a0e1d6fbbff7b20f418bc39c44ee34f X-Git-Newrev: 5969fca5b35d8ba4a3f88e2d1a25cd4e9c985a7e Message-Id: Date: Mon, 13 Apr 2009 07:42:50 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-262-g5969fca X-BeenThere: commit-mailutils@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Commit notices for GNU mailutils List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Apr 2009 07:42:53 -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=5969fca5b35d8ba4a3f88e2d1a25cd4e9c985a7e The branch, master has been updated via 5969fca5b35d8ba4a3f88e2d1a25cd4e9c985a7e (commit) from 4616b75f8a0e1d6fbbff7b20f418bc39c44ee34f (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 5969fca5b35d8ba4a3f88e2d1a25cd4e9c985a7e Author: Sergey Poznyakoff Date: Mon Apr 13 10:42:44 2009 +0300 Bugfix * libproto/imap/folder.c (imap_list): Fix memory overrun. Set response->level. ----------------------------------------------------------------------- Summary of changes: libproto/imap/folder.c | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libproto/imap/folder.c b/libproto/imap/folder.c index 2fdda56..85a7ba8 100644 --- a/libproto/imap/folder.c +++ b/libproto/imap/folder.c @@ -1402,13 +1402,13 @@ imap_list (f_imap_t f_imap) if (f_imap->enum_stop) return 0; - buffer = malloc (len); + buffer = malloc (len + 1); if (!buffer) return ENOMEM; memcpy (buffer, f_imap->buffer, len); buffer[len] = '\0'; - lr = malloc (sizeof (*lr)); + lr = calloc (1, sizeof (*lr)); if (!lr) return ENOMEM; @@ -1488,6 +1488,23 @@ imap_list (f_imap_t f_imap) if (!lr->name) status = ENOMEM; } + if (lr->separator) + { + size_t off; + char delim[2]; + size_t n = 0; + + delim[0] = lr->separator; + delim[1] = 0; + s = lr->name; + while (off = strcspn (s, delim), s[off]) + { + n++; + off++; + s += off; + } + lr->level = n; + } } mu_argcv_free (argc, argv); free (buffer); hooks/post-receive -- GNU Mailutils From MAILER-DAEMON Tue Apr 14 02:37:49 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LtcHE-0002VK-TA for mharc-commit-mailutils@gnu.org; Tue, 14 Apr 2009 02:37:48 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LtcHD-0002VF-Aw for commit-mailutils@gnu.org; Tue, 14 Apr 2009 02:37:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LtcHB-0002V3-Ab for commit-mailutils@gnu.org; Tue, 14 Apr 2009 02:37:45 -0400 Received: from [199.232.76.173] (port=46376 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LtcHB-0002V0-48 for commit-mailutils@gnu.org; Tue, 14 Apr 2009 02:37:45 -0400 Received: from savannah.gnu.org ([199.232.41.3]:58761 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LtcHA-0001Bo-CL for commit-mailutils@gnu.org; Tue, 14 Apr 2009 02:37:44 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LtcH9-00084e-Ix for commit-mailutils@gnu.org; Tue, 14 Apr 2009 06:37:43 +0000 Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LtcH8-000848-Lh for commit-mailutils@gnu.org; Tue, 14 Apr 2009 06:37:43 +0000 From: "Sergey Poznyakoff" To: commit-mailutils@gnu.org X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 5969fca5b35d8ba4a3f88e2d1a25cd4e9c985a7e X-Git-Newrev: b1594c2aaaaf49641fa93d568a41613c6d8de9aa Message-Id: Date: Tue, 14 Apr 2009 06:37:42 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-263-gb1594c2 X-BeenThere: commit-mailutils@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Commit notices for GNU mailutils List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Apr 2009 06:37:48 -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=b1594c2aaaaf49641fa93d568a41613c6d8de9aa The branch, master has been updated via b1594c2aaaaf49641fa93d568a41613c6d8de9aa (commit) from 5969fca5b35d8ba4a3f88e2d1a25cd4e9c985a7e (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 b1594c2aaaaf49641fa93d568a41613c6d8de9aa Author: Sergey Poznyakoff Date: Tue Apr 14 09:36:41 2009 +0300 Allow to set user's personal namespace in imap4d. * imap4d/imap4d.c (homedir): Remove variable. (real_homedir, imap4d_homedir, modify_homedir): New variables. (imap4d_cfg_param): New statements: homedir, personal-namespace. (imap4d_session_setup0): Initialize real_homedir and imap4d_homedir. * imap4d/imap4d.h (homedir, rootdir): Remove declarations. (real_homedir, imap4d_homedir, modify_homedir): New declarations. Include mailutils/vartab.h. * imap4d/list.c, imap4d/lsub.c, imap4d/namespace.c, imap4d/subscribe.c, imap4d/unsubscribe.c, imap4d/util.c: Use imap4d_homedir and real_homedir, where appropriate. * NEWS: Update. * imap4d/preauth.c: Remove inclusion of mailutils/vartab.h ----------------------------------------------------------------------- Summary of changes: NEWS | 7 ++++- imap4d/imap4d.c | 68 +++++++++++++++++++++++++++++++++++++++---------- imap4d/imap4d.h | 6 +++- imap4d/list.c | 6 ++-- imap4d/lsub.c | 4 +- imap4d/namespace.c | 14 ++++++---- imap4d/preauth.c | 3 +- imap4d/subscribe.c | 4 +- imap4d/unsubscribe.c | 4 +- imap4d/util.c | 12 ++++---- 10 files changed, 88 insertions(+), 40 deletions(-) diff --git a/NEWS b/NEWS index ae078c9..832d30f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -GNU mailutils NEWS -- history of user-visible changes. 2009-04-07 +GNU mailutils NEWS -- history of user-visible changes. 2009-04-14 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. See the end of file for copying conditions. @@ -13,6 +13,11 @@ Version 2.0.90 (Git) All MU client utilities make use of the user ticket file, ~/.mu-tickets, if it is present. +* Imap4d + +New configuration file entities allow to modify user's personal +namespace and visible home directory. + * API * New mailbox formats diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c index 04b8a88..dc5cc90 100644 --- a/imap4d/imap4d.c +++ b/imap4d/imap4d.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + 2005, 2006, 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 @@ -28,10 +28,12 @@ mu_m_server_t server; unsigned int idle_timeout; int imap4d_transcript; -mu_mailbox_t mbox; -char *homedir; -int state = STATE_NONAUTH; -struct mu_auth_data *auth_data; +mu_mailbox_t mbox; /* Current mailbox */ +char *real_homedir; /* Homedir as returned by user database */ +char *imap4d_homedir; /* Homedir as visible for the remote party */ +char *modify_homedir; /* Expression to produce imap4d_homedir */ +int state = STATE_NONAUTH; /* Current IMAP4 state */ +struct mu_auth_data *auth_data; int login_disabled; /* Disable LOGIN command */ int tls_required; /* Require STARTTLS */ @@ -297,6 +299,11 @@ cb_mailbox_mode (mu_debug_t debug, void *data, mu_config_value_t *val) } static struct mu_cfg_param imap4d_cfg_param[] = { + { "homedir", mu_cfg_string, &modify_homedir, 0, NULL, + N_("Modify home directory") }, + { "personal-namespace", MU_CFG_LIST_OF(mu_cfg_string), &namespace[NS_PRIVATE], + 0, NULL, + N_("Set personal namespace.") }, { "other-namespace", MU_CFG_LIST_OF(mu_cfg_string), &namespace[NS_OTHER], 0, NULL, N_("Set other users' namespace.") }, @@ -342,15 +349,48 @@ static struct mu_cfg_param imap4d_cfg_param[] = { int imap4d_session_setup0 () { - homedir = mu_normalize_path (mu_strdup (auth_data->dir)); - if (imap4d_check_home_dir (homedir, auth_data->uid, auth_data->gid)) + real_homedir = mu_normalize_path (mu_strdup (auth_data->dir)); + if (imap4d_check_home_dir (real_homedir, auth_data->uid, auth_data->gid)) return 1; + + if (modify_homedir) + { + int rc; + mu_vartab_t vtab; + char *expr = mu_tilde_expansion (modify_homedir, "/", real_homedir); + + mu_vartab_create (&vtab); + mu_vartab_define (vtab, "user", auth_data->name, 0); + mu_vartab_define (vtab, "home", real_homedir, 0); + rc = mu_vartab_expand (vtab, expr, &imap4d_homedir); + mu_vartab_destroy (&vtab); + free (expr); + if (rc) + { + free (real_homedir); + mu_diag_output (MU_DIAG_ERR, + _("Error expanding %s: %s"), + modify_homedir, mu_strerror (rc)); + return 1; + } + } + else + imap4d_homedir = strdup (real_homedir); + + if (strcmp (imap4d_homedir, real_homedir) + && imap4d_check_home_dir (imap4d_homedir, + auth_data->uid, auth_data->gid)) + { + free (imap4d_homedir); + free (real_homedir); + return 1; + } if (auth_data->change_uid) setuid (auth_data->uid); - util_chdir (homedir); - namespace_init_session (homedir); + util_chdir (imap4d_homedir); + namespace_init_session (imap4d_homedir); mu_diag_output (MU_DIAG_INFO, _("User `%s' logged in (source: %s)"), auth_data->name, auth_data->source); @@ -447,23 +487,23 @@ imap4d_check_home_dir (const char *dir, uid_t uid, gid_t gid) { struct stat st; - if (stat (homedir, &st)) + if (stat (dir, &st)) { if (errno == ENOENT && create_home_dir) { mode_t mode = umask (0); - int rc = mkdir (homedir, home_dir_mode); + int rc = mkdir (dir, home_dir_mode); umask (mode); if (rc) { mu_error ("Cannot create home directory `%s': %s", - homedir, mu_strerror (errno)); + dir, mu_strerror (errno)); return 1; } - if (chown (homedir, uid, gid)) + if (chown (dir, uid, gid)) { mu_error ("Cannot set owner for home directory `%s': %s", - homedir, mu_strerror (errno)); + dir, mu_strerror (errno)); return 1; } } diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h index c2705e3..3de5fee 100644 --- a/imap4d/imap4d.h +++ b/imap4d/imap4d.h @@ -102,6 +102,7 @@ #include #include #include +#include #include #include @@ -175,8 +176,9 @@ enum imap4d_preauth extern struct imap4d_command imap4d_command_table[]; extern mu_mailbox_t mbox; -extern char *homedir; -extern char *rootdir; +extern char *imap4d_homedir; +extern char *real_homedir; +extern char *modify_homedir; extern int state; extern size_t children; extern int is_virtual; diff --git a/imap4d/list.c b/imap4d/list.c index 7d0c69e..e19091f 100644 --- a/imap4d/list.c +++ b/imap4d/list.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2001, 2002, 2005, 2006, - 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 @@ -47,7 +47,7 @@ list_fun (mu_folder_t folder, struct mu_list_response *resp, void *data) name = resp->name; size = strlen (name); if (size == refinfo->homelen + 6 - && memcmp (name, homedir, refinfo->homelen) == 0 + && memcmp (name, imap4d_homedir, refinfo->homelen) == 0 && memcmp (name + refinfo->homelen + 1, "INBOX", 5) == 0) return 0; @@ -251,7 +251,7 @@ imap4d_list (struct imap4d_command *command, imap4d_tokbuf_t tok) refinfo.refptr = ref; refinfo.reflen = strlen (ref); refinfo.pfxlen = strlen (cwd); - refinfo.homelen = strlen (homedir); + refinfo.homelen = strlen (imap4d_homedir); /* The special name INBOX is included in the output from LIST, if INBOX is supported by this server for this user and if the diff --git a/imap4d/lsub.c b/imap4d/lsub.c index de9d3f7..3ab3416 100644 --- a/imap4d/lsub.c +++ b/imap4d/lsub.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2001, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 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 @@ -50,7 +50,7 @@ imap4d_lsub (struct imap4d_command *command, imap4d_tokbuf_t tok) if (!pattern) return util_finish (command, RESP_NO, "Not enough memory"); - asprintf (&file, "%s/.mailboxlist", homedir); + asprintf (&file, "%s/.mailboxlist", real_homedir); if (!file) { free (pattern); diff --git a/imap4d/namespace.c b/imap4d/namespace.c index f5581dd..63636cf 100644 --- a/imap4d/namespace.c +++ b/imap4d/namespace.c @@ -1,5 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2001, 2005, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2005, 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 @@ -25,9 +26,9 @@ mu_list_t namespace[NS_MAX]; static char * printable_pathname (char *str) { - if (strncmp (str, homedir, strlen (homedir)) == 0) + if (strncmp (str, imap4d_homedir, strlen (imap4d_homedir)) == 0) { - str += strlen (homedir); + str += strlen (imap4d_homedir); if (str[0] == '/') str++; } @@ -244,9 +245,10 @@ namespace_getfullpath (const char *name, const char *delim, int *nspace) int namespace_init_session (char *path) { - mu_list_create (&namespace[NS_PRIVATE]); - mu_list_append (namespace[NS_PRIVATE], - mu_strdup (mu_normalize_path (path))); + if (!namespace[NS_PRIVATE]) + mu_list_create (&namespace[NS_PRIVATE]); + mu_list_prepend (namespace[NS_PRIVATE], + mu_strdup (mu_normalize_path (path))); return 0; } diff --git a/imap4d/preauth.c b/imap4d/preauth.c index 7ee250e..06eb231 100644 --- a/imap4d/preauth.c +++ b/imap4d/preauth.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2001, 2002, 2003, 2004, - 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + 2005, 2006, 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 @@ -20,7 +20,6 @@ /* Preauth support for imap4d */ #include "imap4d.h" -#include #include "des.h" diff --git a/imap4d/subscribe.c b/imap4d/subscribe.c index 50874d0..7cc1b3d 100644 --- a/imap4d/subscribe.c +++ b/imap4d/subscribe.c @@ -1,5 +1,5 @@ /* GNU mailutils - a suite of utilities for electronic mail - Copyright (C) 1999, 2001, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 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 published by @@ -41,7 +41,7 @@ imap4d_subscribe (struct imap4d_command *command, imap4d_tokbuf_t tok) name = imap4d_tokbuf_getarg (tok, IMAP4_ARG_1); - asprintf (&file, "%s/.mailboxlist", homedir); + asprintf (&file, "%s/.mailboxlist", real_homedir); fp = fopen (file, "a"); free (file); if (fp) diff --git a/imap4d/unsubscribe.c b/imap4d/unsubscribe.c index 1bc9659..5b8a46a 100644 --- a/imap4d/unsubscribe.c +++ b/imap4d/unsubscribe.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2001, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 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 @@ -100,7 +100,7 @@ imap4d_unsubscribe (struct imap4d_command *command, imap4d_tokbuf_t tok) name = imap4d_tokbuf_getarg (tok, IMAP4_ARG_1); - asprintf (&file, "%s/.mailboxlist", homedir); + asprintf (&file, "%s/.mailboxlist", real_homedir); sd.result = 0; sd.name = name; diff --git a/imap4d/util.c b/imap4d/util.c index f63fc90..f798d54 100644 --- a/imap4d/util.c +++ b/imap4d/util.c @@ -30,7 +30,7 @@ static const char *sc2string (int); char * util_tilde_expansion (const char *ref, const char *delim) { - return mu_tilde_expansion (ref, delim, homedir); + return mu_tilde_expansion (ref, delim, imap4d_homedir); } /* Get the absolute path. */ @@ -42,8 +42,8 @@ util_getfullpath (char *name, const char *delim) if (*p != delim[0]) { char *s = - calloc (strlen (homedir) + strlen (delim) + strlen (p) + 1, 1); - sprintf (s, "%s%s%s", homedir, delim, p); + calloc (strlen (imap4d_homedir) + strlen (delim) + strlen (p) + 1, 1); + sprintf (s, "%s%s%s", imap4d_homedir, delim, p); free (p); p = s; } @@ -1085,12 +1085,12 @@ util_run_events (int old_state, int new_state) } void -util_chdir (const char *homedir) +util_chdir (const char *dir) { - int rc = chdir (homedir); + int rc = chdir (dir); if (rc) mu_error ("Cannot change to home directory `%s': %s", - homedir, mu_strerror (errno)); + dir, mu_strerror (errno)); } int hooks/post-receive -- GNU Mailutils From MAILER-DAEMON Wed Apr 15 10:49:47 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Lu6Qt-0007bJ-HQ for mharc-commit-mailutils@gnu.org; Wed, 15 Apr 2009 10:49:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lu6Qr-0007b0-Ff for commit-mailutils@gnu.org; Wed, 15 Apr 2009 10:49:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lu6Qo-0007ag-Jp for commit-mailutils@gnu.org; Wed, 15 Apr 2009 10:49:44 -0400 Received: from [199.232.76.173] (port=46682 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lu6Qo-0007aa-8Y for commit-mailutils@gnu.org; Wed, 15 Apr 2009 10:49:42 -0400 Received: from savannah.gnu.org ([199.232.41.3]:37357 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lu6Qm-0004Of-Ki for commit-mailutils@gnu.org; Wed, 15 Apr 2009 10:49:42 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lu6Qh-0001dG-OB for commit-mailutils@gnu.org; Wed, 15 Apr 2009 14:49:35 +0000 Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lu6Qh-0001ci-6r for commit-mailutils@gnu.org; Wed, 15 Apr 2009 14:49:35 +0000 From: "Sergey Poznyakoff" To: commit-mailutils@gnu.org X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: b1594c2aaaaf49641fa93d568a41613c6d8de9aa X-Git-Newrev: d971eaba5417d3a06c332d1a6bf1929bb51f4d90 Message-Id: Date: Wed, 15 Apr 2009 14:49:35 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-264-gd971eab X-BeenThere: commit-mailutils@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Commit notices for GNU mailutils List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Apr 2009 14:49:45 -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=d971eaba5417d3a06c332d1a6bf1929bb51f4d90 The branch, master has been updated via d971eaba5417d3a06c332d1a6bf1929bb51f4d90 (commit) from b1594c2aaaaf49641fa93d568a41613c6d8de9aa (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 d971eaba5417d3a06c332d1a6bf1929bb51f4d90 Author: Sergey Poznyakoff Date: Wed Apr 15 17:49:12 2009 +0300 Improve RFC822 address parsing. * examples/addr.c: Allow to modify hints via command line (-v) and within the shell (\...). * include/mailutils/address.h (MU_ADDR_HINT_*): New defines. (struct _mu_address): Definition. (mu_address_create_hint): New prototype. * include/mailutils/parse822.h (mu_parse822_address_list) (mu_parse822_mail_box, mu_parse822_group) (mu_parse822_address, mu_parse822_route_addr) (mu_parse822_route, mu_parse822_addr_spec) (mu_parse822_unix_mbox, mu_parse822_local_part): Take hint and hint flags. * mailbox/parse822.c: Likewise. * libproto/include/Makefile.am (noinst_HEADERS): Remove address0.h * libproto/include/address0.h: Removed. * mailbox/address.c (mu_address_create_hint): New function. (mu_address_create): Rewrite using mu_address_create_hint. * mh/mh_init.c (mh_expand_aliases): Use mu_header_sget_field_name * mh/mh_whom.c (mh_alias_expand): Rewrite using mu_address_create_hint. This fixes parsing addresses similar to "a@b ". * mh/send.c: New command line option --preserve (--keep) ----------------------------------------------------------------------- Summary of changes: examples/addr.c | 100 ++++++++++++++++-- include/mailutils/address.h | 43 ++++++++- include/mailutils/parse822.h | 117 +++++++++++++-------- libproto/include/Makefile.am | 4 +- libproto/include/address0.h | 65 ------------ mailbox/address.c | 47 ++++++--- mailbox/parse822.c | 235 +++++++++++++++++++++++++++-------------- mh/mh_init.c | 7 +- mh/mh_whom.c | 82 ++++++--------- mh/send.c | 19 +++- 10 files changed, 443 insertions(+), 276 deletions(-) delete mode 100644 libproto/include/address0.h diff --git a/examples/addr.c b/examples/addr.c index 277352b..f8b5874 100644 --- a/examples/addr.c +++ b/examples/addr.c @@ -26,10 +26,14 @@ #include #include +#include #include #define EPARSE MU_ERR_NOENT +struct _mu_address hint; +int hflags; + static int parse (const char *str) { @@ -39,8 +43,7 @@ parse (const char *str) const char *buf; mu_address_t address = NULL; - mu_set_user_email_domain ("localhost"); - status = mu_address_create (&address, str); + status = mu_address_create_hint (&address, str, &hint, hflags); mu_address_get_count (address, &pcount); if (status) @@ -96,6 +99,73 @@ parse (const char *str) return 0; } +struct mu_kwd hintnames[] = { + { "comments", MU_ADDR_HINT_COMMENTS }, + { "personal", MU_ADDR_HINT_PERSONAL }, + { "email", MU_ADDR_HINT_EMAIL }, + { "local", MU_ADDR_HINT_LOCAL }, + { "domain", MU_ADDR_HINT_DOMAIN }, + { "route", MU_ADDR_HINT_ROUTE }, + { NULL } +}; + +static char ** +addr_fieldptr_by_mask (mu_address_t addr, int mask) +{ + switch (mask) + { + case MU_ADDR_HINT_ADDR: + return &addr->addr; + + case MU_ADDR_HINT_COMMENTS: + return &addr->comments; + + case MU_ADDR_HINT_PERSONAL: + return &addr->personal; + + case MU_ADDR_HINT_EMAIL: + return &addr->email; + + case MU_ADDR_HINT_LOCAL: + return &addr->local_part; + + case MU_ADDR_HINT_DOMAIN: + return &addr->domain; + + case MU_ADDR_HINT_ROUTE: + return &addr->route; + } + return NULL; +} + +void +sethint (char *str) +{ + int mask; + char *p = strchr (str, '='); + + if (!p) + { + printf ("%s=> bad assignment\n\n", str); + return; + } + *p++ = 0; + if (mu_kwd_xlat_name (hintnames, str, &mask) == 0) + { + char **fptr = addr_fieldptr_by_mask (&hint, mask); + + if (*p == 0) + hflags &= ~mask; + else + { + *fptr = strdup (p); + hflags |= mask; + } + } + else + printf ("%s=> unknown hint name\n\n", str); +} + static int parseinput (void) { @@ -104,26 +174,34 @@ parseinput (void) while (fgets (buf, sizeof (buf), stdin) != 0) { buf[strlen (buf) - 1] = 0; - parse (buf); + if (buf[0] == '\\') + sethint (buf + 1); + else + parse (buf); } return 0; } int -main (int argc, const char *argv[]) +main (int argc, char *argv[]) { - argc = 1; - - if (!argv[argc]) + int i; + + hint.domain = "localhost"; + hflags = MU_ADDR_HINT_DOMAIN; + + if (argc == 1) return parseinput (); - - for (; argv[argc]; argc++) + + for (i = 1; i < argc; i++) { - if (strcmp (argv[argc], "-") == 0) + if (strcmp (argv[i], "-") == 0) parseinput (); + else if (strncmp (argv[i], "-v", 2) == 0) + sethint (argv[i] + 2); else - parse (argv[argc]); + parse (argv[i]); } return 0; diff --git a/include/mailutils/address.h b/include/mailutils/address.h index 5adaa57..c68811c 100644 --- a/include/mailutils/address.h +++ b/include/mailutils/address.h @@ -1,5 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2005, 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 @@ -25,6 +26,46 @@ extern "C" { #endif +#define MU_ADDR_HINT_ADDR 0x0001 /* Not used yet */ +#define MU_ADDR_HINT_COMMENTS 0x0002 +#define MU_ADDR_HINT_PERSONAL 0x0004 +#define MU_ADDR_HINT_EMAIL 0x0008 +#define MU_ADDR_HINT_LOCAL 0x0010 +#define MU_ADDR_HINT_DOMAIN 0x0020 +#define MU_ADDR_HINT_ROUTE 0x0040 + +/* + * The data-structure representing an RFC822 MAILBOX. It may be + * one MAILBOX or a list of them, as found in an ADDRESS or + * a MAILBOX list (as found in a GROUP). + * + * Capitalized names are from RFC 822, section 6.1 (Address Syntax). + */ +struct _mu_address +{ + char *addr; + /* the original string that this list of addresses was created + * from, only present at the head of the list */ + + char *comments; + /* the collection of comments stripped during parsing this MAILBOX */ + char *personal; + /* the PHRASE portion of a MAILBOX, called the DISPLAY-NAME in drums */ + char *email; + /* the ADDR-SPEC, the LOCAL-PART@DOMAIN */ + char *local_part; + /* the LOCAL-PART of a MAILBOX */ + char *domain; + /* the DOMAIN of a MAILBOX */ + char *route; + /* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */ + + struct _mu_address *next; +}; + +extern int mu_address_create_hint (mu_address_t *, const char *, + mu_address_t, int); + extern int mu_address_create (mu_address_t *, const char *); extern int mu_address_createv (mu_address_t *, const char *v[], size_t); extern void mu_address_destroy (mu_address_t *); diff --git a/include/mailutils/parse822.h b/include/mailutils/parse822.h index f1aad60..83e3820 100644 --- a/include/mailutils/parse822.h +++ b/include/mailutils/parse822.h @@ -1,5 +1,6 @@ /* 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 @@ -49,57 +50,89 @@ extern int mu_parse822_is_q_text (char c); extern int mu_parse822_is_d_text (char c); extern int mu_parse822_is_smtp_q (char c); -extern int mu_parse822_skip_crlf (const char** p, const char* e); -extern int mu_parse822_skip_lwsp_char (const char** p, const char* e); -extern int mu_parse822_skip_lwsp (const char** p, const char* e); -extern int mu_parse822_skip_comments (const char** p, const char* e); -extern int mu_parse822_skip_nl (const char** p, const char* e); - -extern int mu_parse822_digits (const char** p, const char* e, int min, int max, int* digits); -extern int mu_parse822_special (const char** p, const char* e, char c); -extern int mu_parse822_comment (const char** p, const char* e, char** comment); -extern int mu_parse822_atom (const char** p, const char* e, char** atom); -extern int mu_parse822_quoted_pair (const char** p, const char* e, char** qpair); -extern int mu_parse822_quoted_string (const char** p, const char* e, char** qstr); -extern int mu_parse822_word (const char** p, const char* e, char** word); -extern int mu_parse822_phrase (const char** p, const char* e, char** phrase); -extern int mu_parse822_d_text (const char** p, const char* e, char** dtext); +extern int mu_parse822_skip_crlf (const char **p, const char *e); +extern int mu_parse822_skip_lwsp_char (const char **p, const char *e); +extern int mu_parse822_skip_lwsp (const char **p, const char *e); +extern int mu_parse822_skip_comments (const char **p, const char *e); +extern int mu_parse822_skip_nl (const char **p, const char *e); + +extern int mu_parse822_digits (const char **p, const char *e, + int min, int max, int *digits); +extern int mu_parse822_special (const char **p, const char *e, char c); +extern int mu_parse822_comment (const char **p, const char *e, + char **comment); +extern int mu_parse822_atom (const char **p, const char *e, + char **atom); +extern int mu_parse822_quoted_pair (const char **p, const char *e, + char **qpair); +extern int mu_parse822_quoted_string (const char **p, const char *e, + char **qstr); +extern int mu_parse822_word (const char **p, const char *e, + char **word); +extern int mu_parse822_phrase (const char **p, const char *e, + char **phrase); +extern int mu_parse822_d_text (const char **p, const char *e, + char **dtext); /* From RFC 822, 6.1 Address Specification Syntax */ -extern int mu_parse822_address_list (mu_address_t* a, const char* s); -extern int mu_parse822_mail_box (const char** p, const char* e, mu_address_t* a); -extern int mu_parse822_group (const char** p, const char* e, mu_address_t* a); -extern int mu_parse822_address (const char** p, const char* e, mu_address_t* a); -extern int mu_parse822_route_addr (const char** p, const char* e, mu_address_t* a); -extern int mu_parse822_route (const char** p, const char* e, char** route); -extern int mu_parse822_addr_spec (const char** p, const char* e, mu_address_t* a); -extern int mu_parse822_unix_mbox (const char** p, const char* e, mu_address_t* a); -extern int mu_parse822_local_part (const char** p, const char* e, char** local_part); -extern int mu_parse822_domain (const char** p, const char* e, char** domain); -extern int mu_parse822_sub_domain (const char** p, const char* e, char** sub_domain); -extern int mu_parse822_domain_ref (const char** p, const char* e, char** domain_ref); -extern int mu_parse822_domain_literal (const char** p, const char* e, char** domain_literal); +extern int mu_parse822_address_list (mu_address_t *a, const char *s, + mu_address_t hint, int hflags); +extern int mu_parse822_mail_box (const char **p, const char *e, + mu_address_t *a, + mu_address_t hint, int hflags); +extern int mu_parse822_group (const char **p, const char *e, + mu_address_t *a, + mu_address_t hint, int hflags); +extern int mu_parse822_address (const char **p, const char *e, + mu_address_t *a, + mu_address_t hint, int hflags); +extern int mu_parse822_route_addr (const char **p, const char *e, + mu_address_t *a, + mu_address_t hint, int hflags); +extern int mu_parse822_route (const char **p, const char *e, + char **route); +extern int mu_parse822_addr_spec (const char **p, const char *e, + mu_address_t *a, + mu_address_t hint, int hflags); +extern int mu_parse822_unix_mbox (const char **p, const char *e, + mu_address_t *a, + mu_address_t hint, int hflags); +extern int mu_parse822_local_part (const char **p, const char *e, + char **local_part); +extern int mu_parse822_domain (const char **p, const char *e, + char **domain); +extern int mu_parse822_sub_domain (const char **p, const char *e, + char **sub_domain); +extern int mu_parse822_domain_ref (const char **p, const char *e, + char **domain_ref); +extern int mu_parse822_domain_literal (const char **p, const char *e, + char **domain_literal); /* RFC 822 Quoting Functions -* Various elements must be quoted if then contain non-safe characters. What -* characters are allowed depend on the element. The following functions will -* allocate a quoted version of the raw element, it may not actually be -* quoted if no unsafe characters were in the raw string. -*/ + * Various elements must be quoted if then contain non-safe characters. What + * characters are allowed depend on the element. The following functions will + * allocate a quoted version of the raw element, it may not actually be + * quoted if no unsafe characters were in the raw string. + */ -extern int mu_parse822_quote_string (char** quoted, const char* raw); -extern int mu_parse822_quote_local_part (char** quoted, const char* raw); +extern int mu_parse822_quote_string (char **quoted, const char *raw); +extern int mu_parse822_quote_local_part (char **quoted, const char *raw); -extern int mu_parse822_field_body (const char** p, const char *e, char** fieldbody); -extern int mu_parse822_field_name (const char** p, const char *e, char** fieldname); +extern int mu_parse822_field_body (const char **p, const char *e, + char **fieldbody); +extern int mu_parse822_field_name (const char **p, const char *e, + char **fieldname); /***** From RFC 822, 5.1 Date and Time Specification Syntax *****/ -extern int mu_parse822_day (const char** p, const char* e, int* day); -extern int mu_parse822_date (const char** p, const char* e, int* day, int* mon, int* year); -extern int mu_parse822_time (const char** p, const char* e, int* h, int* m, int* s, int* tz, const char** tz_name); -extern int mu_parse822_date_time (const char** p, const char* e, struct tm* tm, mu_timezone* tz); +extern int mu_parse822_day (const char **p, const char *e, int *day); +extern int mu_parse822_date (const char **p, const char *e, int *day, + int *mon, int *year); +extern int mu_parse822_time (const char **p, const char *e, int *h, + int *m, int *s, int *tz, const char **tz_name); +extern int mu_parse822_date_time (const char **p, const char *e, + struct tm *tm, mu_timezone *tz); #ifdef __cplusplus diff --git a/libproto/include/Makefile.am b/libproto/include/Makefile.am index 406e550..b2be394 100644 --- a/libproto/include/Makefile.am +++ b/libproto/include/Makefile.am @@ -1,6 +1,7 @@ ## Process this file with GNU Automake to create Makefile.in -## Copyright (C) 2000, 2001, 2002, 2007 Free Software Foundation, Inc. +## Copyright (C) 2000, 2001, 2002, 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 @@ -18,7 +19,6 @@ ## 02110-1301 USA noinst_HEADERS = \ -address0.h \ attribute0.h \ amd.h \ auth0.h \ diff --git a/libproto/include/address0.h b/libproto/include/address0.h deleted file mode 100644 index da5ea95..0000000 --- a/libproto/include/address0.h +++ /dev/null @@ -1,65 +0,0 @@ -/* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2001, 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 */ - -#ifndef _ADDRESS0_H -#define _ADDRESS0_H - -#ifdef DMALLOC -# include -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The data-structure representing an RFC822 MAILBOX. It may be - * one MAILBOX or a list of them, as found in an ADDRESS or - * a MAILBOX list (as found in a GROUP). - * - * Capitalized names are from RFC 822, section 6.1 (Address Syntax). - */ -struct _mu_address -{ - char *addr; - /* the original string that this list of addresses was created - * from, only present at the head of the list */ - - char *comments; - /* the collection of comments stripped during parsing this MAILBOX */ - char *personal; - /* the PHRASE portion of a MAILBOX, called the DISPLAY-NAME in drums */ - char *email; - /* the ADDR-SPEC, the LOCAL-PART@DOMAIN */ - char *local_part; - /* the LOCAL-PART of a MAILBOX */ - char *domain; - /* the DOMAIN of a MAILBOX */ - char *route; - /* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */ - - struct _mu_address *next; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* _ADDRESS0_H */ diff --git a/mailbox/address.c b/mailbox/address.c index a22fb1e..115ee86 100644 --- a/mailbox/address.c +++ b/mailbox/address.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2000, 2001, 2005, 2006, - 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 @@ -34,12 +34,12 @@ #include #include #include - -#include +#include /* Get email addresses from rfc822 address. */ int -mu_address_create (mu_address_t * a, const char *s) +mu_address_create_hint (mu_address_t *a, const char *s, mu_address_t hint, + int hflags) { /* 'a' must exist, and can't already have been initialized */ @@ -52,7 +52,7 @@ mu_address_create (mu_address_t * a, const char *s) return EINVAL; *a = NULL; - status = mu_parse822_address_list (a, s); + status = mu_parse822_address_list (a, s, hint, hflags); if (status == 0) { /* And address-list may contain 0 addresses but parse correctly. @@ -70,9 +70,20 @@ mu_address_create (mu_address_t * a, const char *s) return status; } -/* Get email addresses from array of rfc822 addresses. */ int -mu_address_createv (mu_address_t * a, const char *sv[], size_t len) +mu_address_create (mu_address_t *a, const char *s) +{ + struct _mu_address hint; + const char *d; + mu_get_user_email_domain (&d); + hint.domain = (char*) d; + return mu_address_create_hint (a, s, &hint, MU_ADDR_HINT_DOMAIN); +} + +/* Get email addresses from array of rfc822 addresses. + FIXME: No hints? */ +int +mu_address_createv (mu_address_t *a, const char *sv[], size_t len) { int status = 0; size_t buflen = 0; @@ -130,7 +141,7 @@ mu_address_createv (mu_address_t * a, const char *sv[], size_t len) } void -mu_address_destroy (mu_address_t * paddress) +mu_address_destroy (mu_address_t *paddress) { if (paddress && *paddress) { @@ -160,7 +171,7 @@ mu_address_destroy (mu_address_t * paddress) } int -mu_address_concatenate (mu_address_t to, mu_address_t * from) +mu_address_concatenate (mu_address_t to, mu_address_t *from) { if (!to || !from || !*from) return EINVAL; @@ -254,7 +265,6 @@ ACCESSOR(sget,field) (mu_address_t addr, size_t no, char const **sptr) \ subaddr = _address_get_nth (addr, no); \ if (!subaddr) \ return MU_ERR_NOENT; \ - \ *sptr = subaddr->field; \ return 0; \ } @@ -262,7 +272,7 @@ ACCESSOR(sget,field) (mu_address_t addr, size_t no, char const **sptr) \ #define DECL_GET(field) \ int \ ACCESSOR(get,field) (mu_address_t addr, size_t no, char *buf, size_t len, \ - size_t * n) \ + size_t *n) \ { \ size_t i; \ const char *str; \ @@ -429,7 +439,7 @@ mu_address_is_group (mu_address_t addr, size_t no, int *yes) } int -mu_address_to_string (mu_address_t addr, char *buf, size_t len, size_t * n) +mu_address_to_string (mu_address_t addr, char *buf, size_t len, size_t *n) { size_t i; if (addr == NULL) @@ -453,7 +463,7 @@ mu_address_to_string (mu_address_t addr, char *buf, size_t len, size_t * n) } int -mu_address_get_count (mu_address_t addr, size_t * pcount) +mu_address_get_count (mu_address_t addr, size_t *pcount) { size_t j; for (j = 0; addr; addr = addr->next, j++) @@ -464,7 +474,7 @@ mu_address_get_count (mu_address_t addr, size_t * pcount) } int -mu_address_get_group_count (mu_address_t addr, size_t * pcount) +mu_address_get_group_count (mu_address_t addr, size_t *pcount) { size_t j; for (j = 0; addr; addr = addr->next) @@ -478,7 +488,7 @@ mu_address_get_group_count (mu_address_t addr, size_t * pcount) } int -mu_address_get_email_count (mu_address_t addr, size_t * pcount) +mu_address_get_email_count (mu_address_t addr, size_t *pcount) { size_t j; for (j = 0; addr; addr = addr->next) @@ -492,7 +502,7 @@ mu_address_get_email_count (mu_address_t addr, size_t * pcount) } int -mu_address_get_unix_mailbox_count (mu_address_t addr, size_t * pcount) +mu_address_get_unix_mailbox_count (mu_address_t addr, size_t *pcount) { size_t j; for (j = 0; addr; addr = addr->next) @@ -522,6 +532,11 @@ mu_address_dup (mu_address_t src) if (!dst) return NULL; + /* FIXME: How about: + if (src->addr) + dst->addr = strdup (src->addr); + ? + */ if (src->comments) dst->comments = strdup (src->comments); if (src->personal) diff --git a/mailbox/parse822.c b/mailbox/parse822.c index 0501144..a26815d 100644 --- a/mailbox/parse822.c +++ b/mailbox/parse822.c @@ -1,5 +1,6 @@ /* 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 @@ -87,10 +88,9 @@ actually help. # include #endif -#include "address0.h" - #include #include +#include #ifdef EOK # undef EOK @@ -478,7 +478,7 @@ mu_parse822_atom (const char **p, const char *e, char **atom) save = *p; - while ((*p != e) && mu_parse822_is_atom_char (**p)) + while ((*p != e) && (**p == '.' || mu_parse822_is_atom_char (**p))) { rc = str_append_char (atom, **p); *p += 1; @@ -495,24 +495,18 @@ int parse822_atom_ex (const char **p, const char *e, char **atom) { /* atom = 1* */ - - const char *save = *p; - int rc = EPARSE; + const char *ptr; + int rc; mu_parse822_skip_comments (p, e); - save = *p; - - while ((*p != e) && parse822_is_atom_char_ex (**p)) - { - rc = str_append_char (atom, **p); - *p += 1; - if (rc != EOK) - { - *p = save; - break; - } - } + for (ptr = *p; (ptr != e) && parse822_is_atom_char_ex (*ptr); ptr++) + ; + if (ptr - *p == 0) + return EPARSE; + rc = str_append_n (atom, *p, ptr - *p); + if (rc == 0) + *p = ptr; return rc; } @@ -714,59 +708,133 @@ new_mb (void) return calloc (1, sizeof (struct _mu_address)); } +static char * +addr_field_by_mask (mu_address_t addr, int mask) +{ + switch (mask) + { + case MU_ADDR_HINT_ADDR: + return addr->addr; + + case MU_ADDR_HINT_COMMENTS: + return addr->comments; + + case MU_ADDR_HINT_PERSONAL: + return addr->personal; + + case MU_ADDR_HINT_EMAIL: + return addr->email; + + case MU_ADDR_HINT_LOCAL: + return addr->local_part; + + case MU_ADDR_HINT_DOMAIN: + return addr->domain; + + case MU_ADDR_HINT_ROUTE: + return addr->route; + } + return NULL; +} + +static char * +get_val (mu_address_t hint, int hflags, char *value, int mask, int *memflag) +{ + if (!value && hint && (hflags & mask)) + { + char *p = addr_field_by_mask (hint, mask); + if (p) + { + if (memflag) + *memflag |= mask; + value = strdup (p); + } + } + return value; +} + +static void +addr_free_fields (mu_address_t a, int memflag) +{ + char *p; + + if ((p = addr_field_by_mask (a, memflag & MU_ADDR_HINT_ADDR))) + free (p); + if ((p = addr_field_by_mask (a, memflag & MU_ADDR_HINT_COMMENTS))) + free (p); + if ((p = addr_field_by_mask (a, memflag & MU_ADDR_HINT_PERSONAL))) + free (p); + if ((p = addr_field_by_mask (a, memflag & MU_ADDR_HINT_EMAIL))) + free (p); + if ((p = addr_field_by_mask (a, memflag & MU_ADDR_HINT_LOCAL))) + free (p); + if ((p = addr_field_by_mask (a, memflag & MU_ADDR_HINT_DOMAIN))) + free (p); + if ((p = addr_field_by_mask (a, memflag & MU_ADDR_HINT_ROUTE))) + free (p); +} + static int -fill_mb (mu_address_t * a, - char *comments, char *personal, char *local, char *domain) +fill_mb (mu_address_t *pa, + char *comments, char *personal, char *local, char *domain, + mu_address_t hint, int hflags) { int rc = EOK; + mu_address_t a; + int memflag = 0; - *a = new_mb (); + a = new_mb (); - if (!*a) - { - return ENOMEM; - } + if (!a) + return ENOMEM; - (*a)->comments = comments; - (*a)->personal = personal; + a->comments = get_val (hint, hflags, comments, MU_ADDR_HINT_COMMENTS, + &memflag); + a->personal = get_val (hint, hflags, personal, MU_ADDR_HINT_PERSONAL, + &memflag); + domain = get_val (hint, hflags, domain, MU_ADDR_HINT_DOMAIN, + &memflag); + local = get_val (hint, hflags, local, MU_ADDR_HINT_LOCAL, + &memflag); do { /* loop exists only to break out of */ - const char *d = domain; - if (!d) - { - mu_get_user_email_domain (&d); - } - if (!local || !d) - { - /* no email to construct */ - break; - } - if ((rc = mu_parse822_quote_local_part (&(*a)->email, local))) - break; - if ((rc = str_append (&(*a)->email, "@"))) + if (!local) + /* no email to construct */ break; - if ((rc = str_append (&(*a)->email, d))) + + if ((rc = mu_parse822_quote_local_part (&a->email, local))) break; + if (domain) + { + if ((rc = str_append (&a->email, "@"))) + break; + if ((rc = str_append (&a->email, domain))) + break; + } } while (0); - (*a)->local_part = local; - (*a)->domain = domain; + a->local_part = local; + a->domain = domain; if (rc != EOK) { + addr_free_fields (a, memflag); /* note that the arguments have NOT been freed, we only own * them on success. */ - free (*a); + free (a); } + else + *pa = a; return rc; } int -mu_parse822_address_list (mu_address_t * a, const char *s) +mu_parse822_address_list (mu_address_t *a, const char *s, + mu_address_t hint, int hflags) { /* address-list = #(address) */ @@ -775,7 +843,7 @@ mu_parse822_address_list (mu_address_t * a, const char *s) int rc = EOK; mu_address_t *n = a; /* the next address we'll be creating */ - rc = mu_parse822_address (p, e, n); + rc = mu_parse822_address (p, e, n, hint, hflags); /* A list may start with a leading <,>, we'll find out if * that's not the case at the top of the while, but give @@ -808,7 +876,7 @@ mu_parse822_address_list (mu_address_t * a, const char *s) } mu_parse822_skip_comments (p, e); - rc = mu_parse822_address (p, e, n); + rc = mu_parse822_address (p, e, n, hint, hflags); if (rc == EOK || rc == EPARSE) { @@ -833,20 +901,24 @@ mu_parse822_address_list (mu_address_t * a, const char *s) } int -mu_parse822_address (const char **p, const char *e, mu_address_t * a) +mu_parse822_address (const char **p, const char *e, mu_address_t *a, + mu_address_t hint, int hflags) { /* address = mailbox / group / unix-mbox */ int rc; - if ((rc = mu_parse822_mail_box (p, e, a)) == EPARSE) + if ((rc = mu_parse822_mail_box (p, e, a, hint, hflags)) == EPARSE) { - if ((rc = mu_parse822_group (p, e, a)) == EPARSE) + if ((rc = mu_parse822_group (p, e, a, hint, hflags)) == EPARSE) { - rc = mu_parse822_unix_mbox (p, e, a); + rc = mu_parse822_unix_mbox (p, e, a, hint, hflags); } } + if (rc == 0 && *a && !(*a)->route) + (*a)->route = get_val (hint, hflags, NULL, MU_ADDR_HINT_ROUTE, NULL); + return rc; } @@ -856,7 +928,8 @@ mu_parse822_address (const char **p, const char *e, mu_address_t * a) */ #undef ADD_GROUPS int -mu_parse822_group (const char **p, const char *e, mu_address_t * a) +mu_parse822_group (const char **p, const char *e, mu_address_t *a, + mu_address_t hint, int hflags) { /* group = phrase ":" [#mailbox] ";" */ @@ -886,7 +959,7 @@ mu_parse822_group (const char **p, const char *e, mu_address_t * a) /* fake up an address node for the group's descriptive phrase, if * it fails, clean-up will happen after the loop */ - if ((rc = fill_mb (a, 0, phrase, 0, 0)) == EOK) + if ((rc = fill_mb (a, 0, phrase, 0, 0, hint, hflags)) == EOK) { a = &(*a)->next; } @@ -907,7 +980,7 @@ mu_parse822_group (const char **p, const char *e, mu_address_t * a) mu_parse822_skip_comments (p, e); /* it's ok not be a mailbox, but other errors are fatal */ - rc = mu_parse822_mail_box (p, e, a); + rc = mu_parse822_mail_box (p, e, a, hint, hflags); if (rc == EOK) { a = &(*a)->next; @@ -941,7 +1014,8 @@ mu_parse822_group (const char **p, const char *e, mu_address_t * a) } int -mu_parse822_mail_box (const char **p, const char *e, mu_address_t * a) +mu_parse822_mail_box (const char **p, const char *e, mu_address_t *a, + mu_address_t hint, int hflags) { /* mailbox = * addr-spec [ "(" comment ")" ] / @@ -956,7 +1030,7 @@ mu_parse822_mail_box (const char **p, const char *e, mu_address_t * a) int rc; /* -> addr-spec */ - if ((rc = mu_parse822_addr_spec (p, e, a)) == EOK) + if ((rc = mu_parse822_addr_spec (p, e, a, hint, hflags)) == EOK) { mu_parse822_skip_lwsp (p, e); @@ -987,7 +1061,7 @@ mu_parse822_mail_box (const char **p, const char *e, mu_address_t * a) return rc; } - if ((rc = mu_parse822_route_addr (p, e, a)) == EOK) + if ((rc = mu_parse822_route_addr (p, e, a, hint, hflags)) == EOK) { /* add the phrase */ (*a)->personal = phrase; @@ -1005,14 +1079,16 @@ mu_parse822_mail_box (const char **p, const char *e, mu_address_t * a) } int -mu_parse822_route_addr (const char **p, const char *e, mu_address_t * a) +mu_parse822_route_addr (const char **p, const char *e, mu_address_t *a, + mu_address_t hint, int hflags) { /* route-addr = "<" [route] addr-spec ">" */ const char *save = *p; - char *route = 0; + char *route = NULL; int rc; - + int memflag = 0; + mu_parse822_skip_comments (p, e); if ((rc = mu_parse822_special (p, e, '<'))) @@ -1023,15 +1099,15 @@ mu_parse822_route_addr (const char **p, const char *e, mu_address_t * a) } if (!(rc = mu_parse822_special (p, e, '>'))) { - (void) (((rc = fill_mb (a, 0, 0, 0, 0)) == EOK) - && ((rc = str_append (&(*a)->email, "")) == EOK)); + if ((rc = fill_mb (a, 0, 0, 0, 0, hint, hflags)) == EOK) + rc = str_append (&(*a)->email, ""); return rc; } mu_parse822_route (p, e, &route); - if ((rc = mu_parse822_addr_spec (p, e, a))) + if ((rc = mu_parse822_addr_spec (p, e, a, hint, hflags))) { *p = save; @@ -1040,7 +1116,8 @@ mu_parse822_route_addr (const char **p, const char *e, mu_address_t * a) return rc; } - (*a)->route = route; /* now we don't have to free our local */ + (*a)->route = get_val (hint, hflags, route, MU_ADDR_HINT_ROUTE, + &memflag); mu_parse822_skip_comments (p, e); @@ -1121,7 +1198,8 @@ mu_parse822_route (const char **p, const char *e, char **route) } int -mu_parse822_addr_spec (const char **p, const char *e, mu_address_t * a) +mu_parse822_addr_spec (const char **p, const char *e, mu_address_t *a, + mu_address_t hint, int hflags) { /* addr-spec = local-part "@" domain */ @@ -1137,18 +1215,16 @@ mu_parse822_addr_spec (const char **p, const char *e, mu_address_t * a) if (!rc) { rc = mu_parse822_special (p, e, '@'); - } - - if (!rc) - { - rc = mu_parse822_domain (p, e, &domain); - } + + if (!rc) + { + rc = mu_parse822_domain (p, e, &domain); - if (!rc) - { - rc = fill_mb (a, 0, 0, local_part, domain); + if (!rc) + rc = fill_mb (a, 0, 0, local_part, domain, hint, hflags); + } } - + if (rc) { *p = save; @@ -1159,7 +1235,8 @@ mu_parse822_addr_spec (const char **p, const char *e, mu_address_t * a) } int -mu_parse822_unix_mbox (const char **p, const char *e, mu_address_t * a) +mu_parse822_unix_mbox (const char **p, const char *e, mu_address_t *a, + mu_address_t hint, int hflags) { /* unix-mbox = atom */ @@ -1172,9 +1249,7 @@ mu_parse822_unix_mbox (const char **p, const char *e, mu_address_t * a) rc = mu_parse822_atom (p, e, &mbox); if (!rc) - { - rc = fill_mb (a, 0, 0, mbox, 0); - } + rc = fill_mb (a, 0, 0, mbox, 0, hint, hflags); if (rc) { diff --git a/mh/mh_init.c b/mh/mh_init.c index 7fc2629..629fb04 100644 --- a/mh/mh_init.c +++ b/mh/mh_init.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2000, 2001, 2002, 2003, - 2005, 2006, 2007 Free Software Foundation, Inc. + 2005, 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 published by @@ -931,13 +931,13 @@ mh_expand_aliases (mu_message_t msg, { mu_header_t hdr; size_t i, num; - char *buf; + const char *buf; mu_message_get_header (msg, &hdr); mu_header_get_field_count (hdr, &num); for (i = 1; i <= num; i++) { - if (mu_header_aget_field_name (hdr, i, &buf) == 0) + if (mu_header_sget_field_name (hdr, i, &buf) == 0) { if (strcasecmp (buf, MU_HEADER_TO) == 0 || strcasecmp (buf, MU_HEADER_CC) == 0 @@ -958,7 +958,6 @@ mh_expand_aliases (mu_message_t msg, else if (strcasecmp (buf, MU_HEADER_BCC) == 0) mu_address_union (addr_bcc ? addr_bcc : addr_to, addr); } - free (buf); } } } diff --git a/mh/mh_whom.c b/mh/mh_whom.c index 1fb3410..70371c7 100644 --- a/mh/mh_whom.c +++ b/mh/mh_whom.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2003, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 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 published by @@ -51,69 +51,47 @@ ismydomain (char *p) return strcasecmp (domain, p + 1) == 0; } +/* FIXME: incl is not used */ int mh_alias_expand (const char *str, mu_address_t *paddr, int *incl) { - int argc; - char **argv; - int i; - char *buf; - mu_address_t exaddr = NULL; - + size_t i, count; + mu_address_t addr; + int status; + if (incl) *incl = 0; - mu_argcv_get (str, ",", NULL, &argc, &argv); - for (i = 0; i < argc;) + status = mu_address_create_hint (&addr, str, NULL, 0); + if (status) { - if (i + 1 == argc) - { - if (mh_alias_get_address (argv[i], &exaddr, incl) == 0) - { - free (argv[i]); - memcpy (&argv[i], &argv[i+1], - (argc - i + 1) * sizeof (argv[0])); - argc--; - } - else - i++; - } - else if (argv[i + 1][0] == ',') + mu_error (_("Bad address `%s': %s"), str, mu_strerror (status)); + return 1; + } + + mu_address_get_count (addr, &count); + for (i = 1; i <= count; i++) + { + mu_address_t subaddr = NULL; + const char *key; + + if (mu_address_sget_domain (addr, i, &key) == 0 && key == NULL) { - if (mh_alias_get_address (argv[i], &exaddr, incl) == 0) - { - free (argv[i]); - free (argv[i+1]); - memcpy (&argv[i], &argv[i+2], - (argc - i) * sizeof (argv[0])); - argc -= 2; - } - else - i += 2; + if (mu_address_sget_local_part (addr, i, &key) == 0 + && mh_alias_get_address (key, paddr, incl) == 0) + continue; } - else + + status = mu_address_get_nth (addr, i, &subaddr); + if (status) { - for (; i < argc; i++) - if (argv[i][0] == ',') - { - i++; - break; - } + mu_error (_("%s: cannot get address #%lu: %s"), + str, (unsigned long) i, mu_strerror (status)); + continue; } - } - if (argc) - { - int status; - mu_argcv_string (argc, argv, &buf); - if ((status = mu_address_create (paddr, buf))) - mu_error (_("Bad address `%s': %s"), buf, mu_strerror (status)); - free (buf); + mu_address_union (paddr, subaddr); + mu_address_destroy (&subaddr); } - - mu_argcv_free (argc, argv); - - mu_address_union (paddr, exaddr); - mu_address_destroy (&exaddr); return 0; } diff --git a/mh/send.c b/mh/send.c index 42a60fc..7563b24 100644 --- a/mh/send.c +++ b/mh/send.c @@ -1,5 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 2006, 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 @@ -61,6 +62,9 @@ static struct argp_option options[] = { {"push", ARG_PUSH, N_("BOOL"), OPTION_ARG_OPTIONAL, N_("Run in the backround.") }, {"nopush", ARG_NOPUSH, NULL, OPTION_HIDDEN, "" }, + {"preserve", ARG_PRESERVE, N_("BOOL"), OPTION_ARG_OPTIONAL, + N_("Keep draft files") }, + {"keep", 0, NULL, OPTION_ALIAS, NULL}, {"split", ARG_SPLIT, N_("SECONDS"), 0, N_("Split the draft into several partial messages and send them with SECONDS interval") }, {"chunksize", ARG_CHUNKSIZE, N_("NUMBER"), 0, @@ -91,7 +95,9 @@ struct mh_option mh_option[] = { {"forward", 4, MH_OPT_BOOL, NULL}, {"mime", 2, MH_OPT_BOOL, NULL}, {"msgid", 2, MH_OPT_BOOL, NULL}, - {"push", 1, MH_OPT_BOOL, NULL}, + {"push", 2, MH_OPT_BOOL, NULL}, + {"preserve", 2, MH_OPT_BOOL, NULL}, + {"keep", 1, MH_OPT_BOOL, NULL}, {"split", 1, 0, "seconds"}, {"verbose", 1, MH_OPT_BOOL, NULL}, {"watch", 2, MH_OPT_BOOL, NULL}, @@ -116,6 +122,8 @@ static int verbose; /* Produce verbose diagnostics */ static int watch; /* Watch the delivery process */ static unsigned width = 76; /* Maximum width of header fields */ +static int keep_files; /* Keep draft files */ + #define DEFAULT_X_MAILER "MH (" PACKAGE_STRING ")" #define WATCH(c) do {\ @@ -196,6 +204,10 @@ opt_handler (int key, char *arg, void *unused, struct argp_state *state) case ARG_NOMSGID: append_msgid = 0; break; + + case ARG_PRESERVE: + keep_files = is_true (arg); + break; case ARG_PUSH: background = is_true (arg); @@ -690,7 +702,8 @@ _action_send (void *item, void *data) mu_mailer_close (mailer); mu_mailer_destroy (&mailer); - backup_file (elt->file_name); + if (!keep_files) + backup_file (elt->file_name); return 0; } hooks/post-receive -- GNU Mailutils From MAILER-DAEMON Thu Apr 16 10:46:39 2009 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LuSrP-0006ln-L6 for mharc-commit-mailutils@gnu.org; Thu, 16 Apr 2009 10:46:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LuSrN-0006jn-EG for commit-mailutils@gnu.org; Thu, 16 Apr 2009 10:46:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LuSrL-0006iS-Fj for commit-mailutils@gnu.org; Thu, 16 Apr 2009 10:46:36 -0400 Received: from [199.232.76.173] (port=46772 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LuSrL-0006iP-Ab for commit-mailutils@gnu.org; Thu, 16 Apr 2009 10:46:35 -0400 Received: from savannah.gnu.org ([199.232.41.3]:36163 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LuSrK-0007tR-Tm for commit-mailutils@gnu.org; Thu, 16 Apr 2009 10:46:35 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LuSrK-000754-1r for commit-mailutils@gnu.org; Thu, 16 Apr 2009 14:46:34 +0000 Received: from gray by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LuSrJ-000749-GU for commit-mailutils@gnu.org; Thu, 16 Apr 2009 14:46:33 +0000 From: "Sergey Poznyakoff" To: commit-mailutils@gnu.org X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: d971eaba5417d3a06c332d1a6bf1929bb51f4d90 X-Git-Newrev: dfae7b2baeb620fe266e5ac6aa6000a7c3acfb5c Message-Id: Date: Thu, 16 Apr 2009 14:46:33 +0000 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [SCM] GNU Mailutils branch, master, updated. mu-1-2-90-separate-argp-cfg-265-gdfae7b2 X-BeenThere: commit-mailutils@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Commit notices for GNU mailutils List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Apr 2009 14:46:37 -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=dfae7b2baeb620fe266e5ac6aa6000a7c3acfb5c The branch, master has been updated via dfae7b2baeb620fe266e5ac6aa6000a7c3acfb5c (commit) from d971eaba5417d3a06c332d1a6bf1929bb51f4d90 (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 dfae7b2baeb620fe266e5ac6aa6000a7c3acfb5c Author: Sergey Poznyakoff Date: Thu Apr 16 17:46:16 2009 +0300 Minor changes. * include/mailutils/address.h (struct _mu_address): Rename to struct mu_address: it is public interface. * include/mailutils/types.hin: Likewise. * examples/addr.c: Likewise. * mailbox/address.c: Likewise. * mailbox/parse822.c: Likewise. * libmu_sieve/extensions/vacation.c (vacation_reply): Fix memory leaks. * libproto/mailer/mbox.c (remote_mbox_append_message): Use mu_address_create_hint instead of mu_set_user_email_domain/mu_address_create. * maidag/maidag.c (main): Set both diag and debug printers explicitly. * mail/from.c (mail_from0): minor change. * mail/reply.c (reply0): Fix memory leak. * mailbox/header.c: minor change. ----------------------------------------------------------------------- Summary of changes: examples/addr.c | 2 +- include/mailutils/address.h | 4 +- include/mailutils/types.hin | 6 +- libmu_sieve/extensions/vacation.c | 91 +++++++++++++++++++------------------ libproto/mailer/mbox.c | 15 +++--- maidag/maidag.c | 11 +++-- mail/from.c | 22 ++++----- mail/reply.c | 5 ++- mailbox/address.c | 2 +- mailbox/header.c | 6 +-- mailbox/parse822.c | 2 +- 11 files changed, 85 insertions(+), 81 deletions(-) diff --git a/examples/addr.c b/examples/addr.c index f8b5874..74beaf2 100644 --- a/examples/addr.c +++ b/examples/addr.c @@ -31,7 +31,7 @@ #define EPARSE MU_ERR_NOENT -struct _mu_address hint; +struct mu_address hint; int hflags; static int diff --git a/include/mailutils/address.h b/include/mailutils/address.h index c68811c..dfc3575 100644 --- a/include/mailutils/address.h +++ b/include/mailutils/address.h @@ -41,7 +41,7 @@ extern "C" { * * Capitalized names are from RFC 822, section 6.1 (Address Syntax). */ -struct _mu_address +struct mu_address { char *addr; /* the original string that this list of addresses was created @@ -60,7 +60,7 @@ struct _mu_address char *route; /* the optional ROUTE in the ROUTE-ADDR form of MAILBOX */ - struct _mu_address *next; + struct mu_address *next; }; extern int mu_address_create_hint (mu_address_t *, const char *, diff --git a/include/mailutils/types.hin b/include/mailutils/types.hin index 77d9059..94fcc02 100644 --- a/include/mailutils/types.hin +++ b/include/mailutils/types.hin @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail -*- c -*- Copyright (C) 1999, 2000, 2001, 2005, 2007, - 2008 Free Software Foundation, Inc. + 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,7 +38,7 @@ extern "C" { #endif -struct _mu_address; +struct mu_address; struct _mu_attribute; struct _mu_authority; struct _mu_body; @@ -73,7 +73,7 @@ struct _mu_tcp_server; typedef _MU_OFF_TYPE_ mu_off_t; -typedef struct _mu_address *mu_address_t; +typedef struct mu_address *mu_address_t; typedef struct _mu_attribute *mu_attribute_t; typedef struct _mu_authority *mu_authority_t; typedef struct _mu_body *mu_body_t; diff --git a/libmu_sieve/extensions/vacation.c b/libmu_sieve/extensions/vacation.c index fe6b511..72715d2 100644 --- a/libmu_sieve/extensions/vacation.c +++ b/libmu_sieve/extensions/vacation.c @@ -1,5 +1,5 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 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 @@ -478,60 +478,63 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, return -1; mu_mime_get_message (mime, &newmsg); mu_message_get_header (newmsg, &newhdr); - + rc = mu_address_create (&to_addr, to); if (rc) { mu_sieve_error (mach, _("%d: cannot create recipient address <%s>: %s"), mu_sieve_get_message_num (mach), from, mu_strerror (rc)); - return -1; - } - - mu_header_set_value (newhdr, MU_HEADER_TO, to, 0); - - vacation_subject (mach, tags, msg, newhdr); - - if (from) - { - if (mu_address_create (&from_addr, from)) - from_addr = NULL; } else { - from_addr = NULL; - } - - if (mu_rfc2822_in_reply_to (msg, &value) == 0) - { - mu_header_set_value (newhdr, MU_HEADER_IN_REPLY_TO, value, 1); - free (value); - } - - if (mu_rfc2822_references (msg, &value) == 0) - { - mu_header_set_value (newhdr, MU_HEADER_REFERENCES, value, 1); - free (value); - } - - mailer = mu_sieve_get_mailer (mach); - rc = mu_mailer_open (mailer, 0); - if (rc) - { - mu_url_t url = NULL; - mu_mailer_get_url (mailer, &url); + mu_header_set_value (newhdr, MU_HEADER_TO, to, 0); - mu_sieve_error (mach, - _("%d: cannot open mailer %s: %s"), - mu_sieve_get_message_num (mach), - mu_url_to_string (url), mu_strerror (rc)); - return -1; - } - else - { - rc = mu_mailer_send_message (mailer, newmsg, from_addr, to_addr); - mu_mailer_close (mailer); + vacation_subject (mach, tags, msg, newhdr); + + if (from) + { + if (mu_address_create (&from_addr, from)) + from_addr = NULL; + } + else + { + from_addr = NULL; + } + + if (mu_rfc2822_in_reply_to (msg, &value) == 0) + { + mu_header_set_value (newhdr, MU_HEADER_IN_REPLY_TO, value, 1); + free (value); + } + + if (mu_rfc2822_references (msg, &value) == 0) + { + mu_header_set_value (newhdr, MU_HEADER_REFERENCES, value, 1); + free (value); + } + + mailer = mu_sieve_get_mailer (mach); + rc = mu_mailer_open (mailer, 0); + if (rc) + { + mu_url_t url = NULL; + mu_mailer_get_url (mailer, &url); + + mu_sieve_error (mach, + _("%d: cannot open mailer %s: %s"), + mu_sieve_get_message_num (mach), + mu_url_to_string (url), mu_strerror (rc)); + } + else + { + rc = mu_mailer_send_message (mailer, newmsg, from_addr, to_addr); + mu_mailer_close (mailer); + } + mu_mailer_destroy (&mailer); } + mu_address_destroy (&to_addr); + mu_address_destroy (&from_addr); mu_mime_destroy (&mime); return rc; } diff --git a/libproto/mailer/mbox.c b/libproto/mailer/mbox.c index 008f72a..8e09df3 100644 --- a/libproto/mailer/mbox.c +++ b/libproto/mailer/mbox.c @@ -138,12 +138,14 @@ remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg) mkaddr (mbox, property, "TO", &to); if (!to) { - const char *rcpt, *host; - char *domain = NULL; + const char *rcpt; status = mu_url_sget_user (mbox->url, &rcpt); if (status != MU_ERR_NOENT) { + const char *host; + struct mu_address hint; + if (status) { MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR, @@ -152,13 +154,10 @@ remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg) return status; } - /* FIXME: Set before if? */ - mu_aget_user_email_domain (&domain); mu_url_sget_host (mbox->url, &host); - mu_set_user_email_domain (host); - status = mu_address_create (&to, rcpt); - mu_set_user_email_domain (domain); - free (domain); + hint.domain = (char*) host; + status = mu_address_create_hint (&to, rcpt, &hint, + MU_ADDR_HINT_DOMAIN); if (status) { diff --git a/maidag/maidag.c b/maidag/maidag.c index f0ccefc..460deda 100644 --- a/maidag/maidag.c +++ b/maidag/maidag.c @@ -481,6 +481,7 @@ int main (int argc, char *argv[]) { int arg_index; + mu_debug_t debug; /* Preparative work: close inherited fds, force a reasonable umask and prepare a logging. */ @@ -535,16 +536,18 @@ main (int argc, char *argv[]) if (log_to_stderr == -1) log_to_stderr = url_option || (!lmtp_mode && (current_uid != 0)); + mu_diag_get_debug (&debug); if (!log_to_stderr) { - mu_debug_t debug; - openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility); - mu_diag_get_debug (&debug); mu_debug_set_print (debug, mu_diag_syslog_printer, NULL); - mu_debug_default_printer = mu_debug_syslog_printer; } + else + { + mu_debug_set_print (debug, mu_diag_stderr_printer, NULL); + mu_debug_default_printer = mu_debug_stderr_printer; + } argc -= arg_index; argv += arg_index; diff --git a/mail/from.c b/mail/from.c index de3928c..a148d3c 100644 --- a/mail/from.c +++ b/mail/from.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2000, 2001, 2002, 2003, - 2005, 2007 Free Software Foundation, Inc. + 2005, 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 published by @@ -42,8 +42,7 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) mu_address_t address = NULL; if (mu_address_create (&address, from) == 0) { - char name[128]; - size_t len; + char *name; const char *email; if (mu_address_sget_email (address, 1, &email) == 0) @@ -53,7 +52,8 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) { char *tmp; - if (mu_header_aget_value_unfold (hdr, MU_HEADER_TO, &tmp) == 0) + if (mu_header_aget_value_unfold (hdr, MU_HEADER_TO, + &tmp) == 0) { mu_address_t addr_to; if (mu_address_create (&addr_to, tmp) == 0) @@ -66,16 +66,14 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) } } - len = strlen (from) + 1; - *name = '\0'; - mu_address_get_personal (address, 1, name, sizeof name, NULL); - if (*name && len) + if ((mu_address_aget_personal (address, 1, &name) == 0 + && name) + || (mu_address_aget_email (address, 1, &name) == 0 + && name)) { - strncpy (from, name, len - 1); - from[len - 1] = '\0'; + free (from); + from = name; } - else - mu_address_get_email (address, 1, from, len, NULL); mu_address_destroy (&address); } } diff --git a/mail/reply.c b/mail/reply.c index 045a822..cdf6f75 100644 --- a/mail/reply.c +++ b/mail/reply.c @@ -1,5 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2001, 2002, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002, 2005, 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 published by @@ -91,6 +92,8 @@ reply0 (msgset_t *mspec, mu_message_t msg, void *data) COMPOSE_SINGLE_LINE); } + mu_address_destroy (&addr); + /* Finally, add any Ccs */ if (mu_header_aget_value (hdr, MU_HEADER_CC, &str) == 0) compose_header_set (&env, MU_HEADER_TO, str, COMPOSE_SINGLE_LINE); diff --git a/mailbox/address.c b/mailbox/address.c index 115ee86..8c81f45 100644 --- a/mailbox/address.c +++ b/mailbox/address.c @@ -73,7 +73,7 @@ mu_address_create_hint (mu_address_t *a, const char *s, mu_address_t hint, int mu_address_create (mu_address_t *a, const char *s) { - struct _mu_address hint; + struct mu_address hint; const char *d; mu_get_user_email_domain (&d); hint.domain = (char*) d; diff --git a/mailbox/header.c b/mailbox/header.c index 94e28fd..5f805f7 100644 --- a/mailbox/header.c +++ b/mailbox/header.c @@ -1,6 +1,6 @@ /* GNU Mailutils -- a suite of utilities for electronic mail Copyright (C) 1999, 2000, 2001, 2004, 2005, - 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 @@ -761,9 +761,7 @@ mu_header_get_address_n (mu_header_t header, const char *name, int n, if (status) return status; - status = mu_address_create(addr, value); - - return status; + return mu_address_create (addr, value); } diff --git a/mailbox/parse822.c b/mailbox/parse822.c index a26815d..837fe6b 100644 --- a/mailbox/parse822.c +++ b/mailbox/parse822.c @@ -705,7 +705,7 @@ mu_parse822_phrase (const char **p, const char *e, char **phrase) static mu_address_t new_mb (void) { - return calloc (1, sizeof (struct _mu_address)); + return calloc (1, sizeof (struct mu_address)); } static char * hooks/post-receive -- GNU Mailutils