Commit b88c148d b88c148d185d11e0bdcf876e586e309ef8ea78f2 by Sergey Poznyakoff

Rewrite default mailbox format support to make sure it does not break format aut…

…odetection. Improve the docs.

* configure.ac (MU_DEFAULT_SCHEME): New configuration variable.
* mailbox/version.c (mu_conf_opt): Include default scheme.

* examples/mimetest.c, examples/mta.c, libmu_scm/mu_scm.c: Remove
mu_path_record. Use mu_registrar_set_default_record.

* libproto/mbox/folder.c (_path_is_scheme): Rename to
_mbox_is_scheme. Minor changes as well.
(_path_record, mu_path_record): Removed.
(_mbox_record): Use _mbox_is_scheme.

* libsieve/actions.c: Remove unused variable.

* include/mailutils/Makefile.am (types.h rule): Replace
_MU_DEFAULT_RECORD_. Change MU_OFF_TYPE replacement pattern to
_MU_OFF_TYPE_.

* include/mailutils/mailbox.h (mu_mailbox_set_default_proto)
(mu_mailbox_get_default_proto): Remove. See below.
* include/mailutils/registrar.h (mu_registrar_set_default_scheme)
(mu_registrar_get_default_scheme)
(mu_registrar_get_default_record)
(mu_registrar_set_default_record)
(mu_registrar_lookup_scheme): New prototypes.
(mu_path_record): Remove.
(mu_register_all_mbox_formats): Remove mu_path_record.
Set default scheme using mu_registrar_set_default_record.
(mu_register_local_mbox_formats): Likewise.
* include/mailutils/types.hin (MU_OFF_TYPE): Rename to
_MU_OFF_TYPE_.
(MU_DEFAULT_RECORD): New define.

* mailbox/mailbox.c (mu_mailbox_set_default_proto)
(mu_mailbox_get_default_proto): Remove.
(mu_mailbox_create): Remove default_proto kludge. mu_registrar
stuff is responsible for finding the correct record.
* mailbox/registrar.c (mu_registrar_set_default_record)
(mu_registrar_get_default_record)
(mu_registrar_set_default_scheme)
(mu_registrar_get_default_scheme)
(mu_registrar_lookup_scheme): New functions.
(mu_registrar_lookup_url): Fall back to default record if no
matching record is found and the URL was not set explicitly
(i.e. does not begin with a scheme).

* mailbox/gocs.c: Use mu_registrar_set_default_scheme instead of
mu_mailbox_set_default_proto.
* libsieve/extensions/pipe.c, libsieve/extensions/spamd.c,
libsieve/extensions/vacation.c: Fix comments.

* doc/texinfo/getdate.texi: New file (from gnulib).
* doc/texinfo/Makefile.am (mailutils_TEXINFOS): Add getdate.texi
(fix-sentence-spacing): New rule. Forces single-space
inter-sentence spacing.
(check-tabs, check-sentence-spacing): New rules.
(check-format): Depend on the above two.
(check-refs, check-fixmes, check-unrevised): Fix copy-paste
errors. Print diagnostics to stderr.

* doc/texinfo/auth.texi, doc/texinfo/fdl.texi,
doc/texinfo/framework.texi, doc/texinfo/imap4.texi,
doc/texinfo/libmuauth.texi, doc/texinfo/mailbox.texi,
doc/texinfo/mailcap.texi, doc/texinfo/mailutils.texi,
doc/texinfo/mbox.texi, doc/texinfo/message.texi,
doc/texinfo/mom.texi, doc/texinfo/mu_message.texi,
doc/texinfo/mu_mime.texi, doc/texinfo/mu_scm.texi,
doc/texinfo/muint.texi, doc/texinfo/pop3.texi,
doc/texinfo/rendition.texi, doc/texinfo/sieve.texi,
doc/texinfo/url.texi, doc/texinfo/usage.texi: Use GNU instead of
@sc{gnu}, because latter looks awful when typeset (especially when
followed by a capitalized word). Fix format by running `make final'.

* doc/texinfo/programs.texi: Document more config statements.
* doc/texinfo/libsieve.texi: Document loadable actions and tests.
1 parent 8b4b2e28
2008-11-09 Sergey Poznyakoff <gray@gnu.org.ua>
Rewrite default mailbox format support to make sure it does not
break format autodetection. Improve the docs.
* configure.ac (MU_DEFAULT_SCHEME): New configuration variable.
* mailbox/version.c (mu_conf_opt): Include default scheme.
* examples/mimetest.c, examples/mta.c, libmu_scm/mu_scm.c: Remove
mu_path_record. Use mu_registrar_set_default_record.
* libproto/mbox/folder.c (_path_is_scheme): Rename to
_mbox_is_scheme. Minor changes as well.
(_path_record, mu_path_record): Removed.
(_mbox_record): Use _mbox_is_scheme.
* libsieve/actions.c: Remove unused variable.
* include/mailutils/Makefile.am (types.h rule): Replace
_MU_DEFAULT_RECORD_. Change MU_OFF_TYPE replacement pattern to
_MU_OFF_TYPE_.
* include/mailutils/mailbox.h (mu_mailbox_set_default_proto)
(mu_mailbox_get_default_proto): Remove. See below.
* include/mailutils/registrar.h (mu_registrar_set_default_scheme)
(mu_registrar_get_default_scheme)
(mu_registrar_get_default_record)
(mu_registrar_set_default_record)
(mu_registrar_lookup_scheme): New prototypes.
(mu_path_record): Remove.
(mu_register_all_mbox_formats): Remove mu_path_record.
Set default scheme using mu_registrar_set_default_record.
(mu_register_local_mbox_formats): Likewise.
* include/mailutils/types.hin (MU_OFF_TYPE): Rename to
_MU_OFF_TYPE_.
(MU_DEFAULT_RECORD): New define.
* mailbox/mailbox.c (mu_mailbox_set_default_proto)
(mu_mailbox_get_default_proto): Remove.
(mu_mailbox_create): Remove default_proto kludge. mu_registrar
stuff is responsible for finding the correct record.
* mailbox/registrar.c (mu_registrar_set_default_record)
(mu_registrar_get_default_record)
(mu_registrar_set_default_scheme)
(mu_registrar_get_default_scheme)
(mu_registrar_lookup_scheme): New functions.
(mu_registrar_lookup_url): Fall back to default record if no
matching record is found and the URL was not set explicitly
(i.e. does not begin with a scheme).
* mailbox/gocs.c: Use mu_registrar_set_default_scheme instead of
mu_mailbox_set_default_proto.
* libsieve/extensions/pipe.c, libsieve/extensions/spamd.c,
libsieve/extensions/vacation.c: Fix comments.
* doc/texinfo/getdate.texi: New file (from gnulib).
* doc/texinfo/Makefile.am (mailutils_TEXINFOS): Add getdate.texi
(fix-sentence-spacing): New rule. Forces single-space
inter-sentence spacing.
(check-tabs, check-sentence-spacing): New rules.
(check-format): Depend on the above two.
(check-refs, check-fixmes, check-unrevised): Fix copy-paste
errors. Print diagnostics to stderr.
* doc/texinfo/auth.texi, doc/texinfo/fdl.texi,
doc/texinfo/framework.texi, doc/texinfo/imap4.texi,
doc/texinfo/libmuauth.texi, doc/texinfo/mailbox.texi,
doc/texinfo/mailcap.texi, doc/texinfo/mailutils.texi,
doc/texinfo/mbox.texi, doc/texinfo/message.texi,
doc/texinfo/mom.texi, doc/texinfo/mu_message.texi,
doc/texinfo/mu_mime.texi, doc/texinfo/mu_scm.texi,
doc/texinfo/muint.texi, doc/texinfo/pop3.texi,
doc/texinfo/rendition.texi, doc/texinfo/sieve.texi,
doc/texinfo/url.texi, doc/texinfo/usage.texi: Use GNU instead of
@sc{gnu}, because latter looks awful when typeset (especially when
followed by a capitalized word). Fix format by running `make final'.
* doc/texinfo/programs.texi: Document more config statements.
* doc/texinfo/libsieve.texi: Document loadable actions and tests.
2008-11-07 Sergey Poznyakoff <gray@gnu.org.ua>
Bugfix
......
......@@ -1095,6 +1095,29 @@ if test "$EMACS" != "no"; then
fi
AC_SUBST(lisp_LISP)
# Default mailbox record
# Note: 1. Support for mbox type is always enabled.
# 2. Only local mailbox types are allowed for MU_DEFAULT_SCHEME
AC_ARG_VAR([MU_DEFAULT_SCHEME],
[Default mailbox record. Allowed values are: mbox (default), mh, and maildir.])
if test -z "$MU_DEFAULT_SCHEME"; then
MU_DEFAULT_SCHEME=mbox
fi
case $MU_DEFAULT_SCHEME in
mbox)
;;
mh|maildir)
eval testval=\$mu_cv_enable_$MU_DEFAULT_SCHEME
if test "$testval" != yes; then
AC_MSG_ERROR([Cannot set default mailbox record type: support for $MU_DEFAULT_SCHEME is disabled])
fi
;;
*) AC_MSG_ERROR([Unknown or not allowed mailbox scheme: $MU_DEFAULT_SCHEME]);;
esac
AC_DEFINE_UNQUOTED(MU_DEFAULT_SCHEME, "$MU_DEFAULT_SCHEME",
[Default mailbox scheme.])
AC_SUBST(MU_DEFAULT_RECORD,mu_${MU_DEFAULT_SCHEME}_record)
AC_ARG_VAR([DEFAULT_CUPS_CONFDIR],
[Set the location of CUPS configuration directory. Default is \$sysconfdir/cups])
......@@ -1134,6 +1157,7 @@ cat <<EOF
*******************************************************************
GNU Mailutils configured with the following settings:
Default mailbox scheme......... $status_scheme
Use PAM........................ $status_pam
Use -ltdl...................... $status_ltdl
Use DBM........................ $status_dbm
......@@ -1168,7 +1192,8 @@ Sendmail....................... $status_sendmail
Before proceeding, verify if these satisfy your requirements.
EOF
],
[status_pam=$status_pam
[status_scheme=$MU_DEFAULT_SCHEME
status_pam=$status_pam
status_ltdl=$status_ltdl
status_dbm="$status_dbm"
status_ldap=$status_ldap
......
......@@ -41,6 +41,7 @@ mailutils_TEXINFOS = \
fdl.texi\
folder.texi\
framework.texi\
getdate.texi\
headers.texi\
imap4.texi\
iterator.texi\
......@@ -115,40 +116,57 @@ master-menu:
untabify:
emacs -batch -l untabify.el $(info_TEXINFOS) $(mailutils_TEXINFOS)
fix-sentence-spacing:
for file in $(info_TEXINFOS) $(mailutils_TEXINFOS); \
do \
if grep -q '\. [@A-Z]' $$file; then \
mv $$file $${file}~; \
sed -r 's/\. ([@A-Z])/. \1/g' $${file}~ > $$file; \
fi; \
done
final: untabify master-menu
# Checks
check-format:
check-tabs:
@if test -n "`cat $(info_TEXINFOS) $(mailutils_TEXINFOS) |\
tr -d -c '\t'`"; then \
echo "Sources contain tabs; run make untabify"; \
echo >&2 "Sources contain tabs; run make untabify"; \
false; \
fi
check-sentence-spacing:
@if grep -q '\. [@A-Z]' $(info_TEXINFOS) $(mailutils_TEXINFOS); then \
echo >&2 "Sources contain double-space sentence separators"; \
echo >&2 "Run make fix-sentence-spacing to fix"; \
fi
check-format: check-tabs check-sentence-spacing
check-refs:
@for file in $(info_TEXINFOS) $(dico_TEXINFOS); \
@for file in $(info_TEXINFOS) $(mailutils_TEXINFOS); \
do \
sed -e = $$file | \
sed -n 'N;/@FIXME-.*ref/{s/\(^[0-9][0-9]*\).*@FIXME-.*ref{\([^}]*\)}.*/'$$file':\1: \2/gp}'; \
done > $@-t; \
if [ -s $@-t ]; then \
echo "Unresolved cross-references:"; \
cat $@-t;\
echo >&2 "Unresolved cross-references:"; \
cat $@-t >&2;\
rm $@-t; \
else \
rm -f $@-t; \
fi
check-fixmes:
@for file in $(info_TEXINFOS); \
@for file in $(info_TEXINFOS) $(mailutils_TEXINFOS); \
do \
sed -e = $$file | \
sed -n 'N;/@FIXME{/{s/\(^[0-9][0-9]*\).*@FIXME{\([^}]*\).*/'$$file':\1: \2/gp}'; \
done > $@-t; \
if [ -s $@-t ]; then \
echo "Unresolved FIXMEs:"; \
cat $@-t; \
echo >&2 "Unresolved FIXMEs:"; \
cat $@-t >&2; \
rm $@-t; \
false; \
else \
......@@ -156,10 +174,10 @@ check-fixmes:
fi
check-unrevised:
@grep -Hn @UNREVISED $(info_TEXINFOS) $(dico_TEXINFOS) > $@-t; \
@grep -Hn @UNREVISED $(info_TEXINFOS) $(mailutils_TEXINFOS) > $@-t; \
if [ -s $@-t ]; then \
echo "Unrevised nodes:"; \
cat $@-t; \
echo >&2 "Unrevised nodes:"; \
cat $@-t >&2; \
rm $@-t; \
false;\
else \
......
......@@ -25,7 +25,7 @@
Wherever the mail is and whatever format it is stored in, it is operated
upon using the same set of functions. To unified the C API,
@sc{gnu} Mailutils offers a heteroclite set of objects that work in
GNU Mailutils offers a heteroclite set of objects that work in
aggregation to do operations on emails.
Each object does a specific task and delegates non-related tasks to others.
The object comes alive by specifying a @emph{URL} parameter when created,
......
......@@ -4,7 +4,7 @@
@c See file mailutils.texi for copying conditions.
@comment *******************************************************************
@code{Libsieve} is @sc{gnu} implementation of the mail filtering
@code{Libsieve} is GNU implementation of the mail filtering
language Sieve. The library is built around a @dfn{Sieve Machine} --- an
abstract computer constructed specially to handle mail filtering tasks.
This computer has two registers: program counter and numeric accumulator;
......@@ -664,7 +664,7 @@ Dump the disassembled code of the sieve machine @var{mach}.
@subsection Writing Loadable Commands
This section contains an example of how to write external loadable
commands for @sc{gnu} libsieve.
commands for GNU libsieve.
@smallexample
@include numaddr.inc
......
......@@ -97,6 +97,7 @@ This edition of the @cite{GNU Mailutils Manual}, last updated on
Appendices
* References:: References.
* Date Input Formats::
* Usage Vars:: Configuring Help Summary
* GNU FDL:: This manual is under the GNU Free
Documentation License.
......@@ -388,6 +389,29 @@ Preprocessor
* #include:: Include the contents of a file.
* #searchpath:: Modify the current search path.
Tests
* Built-in Tests::
* External Tests::
Actions
* Built-in Actions::
* External Actions::
Date Input Formats
* General date syntax:: Common rules.
* Calendar date items:: 19 Dec 1994.
* Time of day items:: 9:20pm.
* Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}.
* Day of week items:: Monday and others.
* Relative items in date strings:: next tuesday, 2 years ago.
* Pure numbers in date strings:: 19931219, 1440.
* Seconds since the Epoch:: @@1078100502.
* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0".
* Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
@end detailmenu
@end menu
......@@ -673,6 +697,10 @@ Notifications}
@end itemize
@end itemize
@node Date Input Formats
@appendix Date Input Formats
@include getdate.texi
@include usage.texi
@include fdl.texi
......
......@@ -80,9 +80,9 @@ main (int argc, char **argv)
/* Registration. */
mu_registrar_record (mu_imap_record);
mu_registrar_record (mu_mbox_record);
mu_registrar_record (mu_path_record);
mu_registrar_record (mu_pop_record);
mu_registrar_record (mu_mbox_record);
mu_registrar_set_default_record (mu_mbox_record);
MU_ASSERT (mu_mailbox_create_default (&mbox, mailbox_name));
......
......@@ -250,9 +250,10 @@ make_tmp (FILE *input, const char *from, char **tempfile)
void
register_handlers ()
{
mu_registrar_record (mu_path_record);
mu_registrar_record (mu_mbox_record);
mu_registrar_record (mu_sendmail_record);
mu_registrar_record (mu_smtp_record);
mu_registrar_set_default_record (mu_mbox_record);
}
int
......
......@@ -27,7 +27,7 @@ debug.h: $(top_srcdir)/scripts/debugdef.m4 debug.hm4
m4 $(top_srcdir)/scripts/debugdef.m4 debug.hm4 > debug.h
types.h: $(top_srcdir)/include/mailutils/types.hin Makefile
sed 's/MU_OFF_TYPE/$(MU_OFF_TYPE)/' $(top_srcdir)/include/mailutils/types.hin > $@
sed 's/_MU_OFF_TYPE_/$(MU_OFF_TYPE)/;s/_MU_DEFAULT_RECORD_/$(MU_DEFAULT_RECORD)/' $(top_srcdir)/include/mailutils/types.hin > $@
DISTCLEANFILES = types.h
pkginclude_DATA = types.h
......
......@@ -35,10 +35,6 @@ const char *mu_mailbox_url (void);
const char *mu_folder_directory (void);
int mu_construct_user_mailbox_url (char **pout, const char *name);
/* Default mailbox protocol */
int mu_mailbox_set_default_proto (const char *proto);
const char *mu_mailbox_get_default_proto (void);
/* Constructor/destructor and possible types. */
extern int mu_mailbox_create (mu_mailbox_t *, const char *);
extern int mu_mailbox_create_from_url (mu_mailbox_t *, mu_url_t);
......
......@@ -47,10 +47,19 @@ struct _mu_record
int (*_list_p) (mu_record_t, const char *, int);
};
/* Defaults */
extern int mu_registrar_set_default_scheme (const char *scheme);
extern const char *mu_registrar_get_default_scheme (void);
extern int mu_registrar_get_default_record (mu_record_t *prec);
extern void mu_registrar_set_default_record (mu_record_t record);
/* Registration. */
extern int mu_registrar_get_iterator (mu_iterator_t *);
extern int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated));
extern int mu_registrar_lookup_scheme (const char *scheme,
mu_record_t *precord);
extern int mu_registrar_lookup (const char *name, int flags,
mu_record_t *precord, int *pflags);
extern int mu_registrar_lookup_url (mu_url_t url, int flags,
......@@ -101,8 +110,6 @@ extern mu_record_t mu_nntp_record;
/* Local Mailbox Unix Mailbox, "mbox:" */
extern mu_record_t mu_mbox_record;
/* Local Folder/Mailbox, / */
extern mu_record_t mu_path_record;
/* Local MH, "mh:" */
extern mu_record_t mu_mh_record;
/* Maildir, "maildir:" */
......@@ -131,7 +138,6 @@ extern mu_record_t mu_sendmail_record;
extern mu_record_t mu_prog_record;
#define mu_register_all_mbox_formats() do {\
mu_registrar_record (mu_path_record);\
mu_registrar_record (mu_mbox_record);\
mu_registrar_record (mu_pop_record);\
mu_registrar_record (mu_pops_record);\
......@@ -139,13 +145,14 @@ extern mu_record_t mu_prog_record;
mu_registrar_record (mu_imaps_record);\
mu_registrar_record (mu_mh_record);\
mu_registrar_record (mu_maildir_record);\
mu_registrar_set_default_record (MU_DEFAULT_RECORD);\
} while (0)
#define mu_register_local_mbox_formats() do {\
mu_registrar_record (mu_path_record);\
mu_registrar_record (mu_mbox_record);\
mu_registrar_record (mu_mh_record);\
mu_registrar_record (mu_maildir_record);\
mu_registrar_set_default_record (MU_DEFAULT_RECORD);\
} while (0)
#define mu_register_remote_mbox_formats() do {\
......
......@@ -71,7 +71,7 @@ struct _mu_acl;
struct _mu_server;
struct _mu_tcp_server;
typedef MU_OFF_TYPE mu_off_t;
typedef _MU_OFF_TYPE_ mu_off_t;
typedef struct _mu_address *mu_address_t;
typedef struct _mu_attribute *mu_attribute_t;
......@@ -122,6 +122,8 @@ typedef struct _mu_progmailer *mu_progmailer_t;
#define mu_offsetof(s,f) ((size_t)&((s*)0)->f)
#define MU_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
#define MU_DEFAULT_RECORD _MU_DEFAULT_RECORD_
#ifdef __cplusplus
}
#endif
......
......@@ -219,5 +219,6 @@ mu_scm_init ()
mu_scm_mime_init ();
#include "mu_scm.x"
mu_registrar_record (mu_path_record);
mu_registrar_record (MU_DEFAULT_RECORD);
mu_registrar_set_default_record (MU_DEFAULT_RECORD);
}
......
......@@ -46,30 +46,14 @@
/* We export url parsing and the initialisation of
the mailbox, via the register entry/record. */
static struct _mu_record _mbox_record =
{
MU_MBOX_PRIO,
MU_MBOX_SCHEME,
mu_url_expand_path, /* URL init. */
_mailbox_mbox_init, /* Mailbox init. */
NULL, /* Mailer init. */
_folder_mbox_init, /* Folder init. */
NULL, /* No need for an 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_mbox_record = &_mbox_record;
static int
_path_is_scheme (mu_record_t record, mu_url_t url, int flags)
_mbox_is_scheme (mu_record_t record, mu_url_t url, int flags)
{
int rc = 0;
if (url && record->scheme)
{
if (mu_url_is_scheme (url, record->scheme))
return MU_FOLDER_ATTRIBUTE_FILE & flags;
if (mu_scheme_autodetect_p (url))
{
struct stat st;
......@@ -77,11 +61,7 @@ _path_is_scheme (mu_record_t record, mu_url_t url, int flags)
mu_url_sget_path (url, &path);
if (stat (path, &st) < 0)
{
if (errno == ENOENT)
rc |= MU_FOLDER_ATTRIBUTE_FILE;
return rc;
}
return 0;
if (S_ISREG (st.st_mode) || S_ISCHR (st.st_mode))
{
......@@ -114,26 +94,25 @@ _path_is_scheme (mu_record_t record, mu_url_t url, int flags)
&& S_ISDIR (st.st_mode))
rc |= MU_FOLDER_ATTRIBUTE_DIRECTORY;
}
}
return rc;
}
static struct _mu_record _path_record =
static struct _mu_record _mbox_record =
{
MU_PATH_PRIO,
MU_PATH_SCHEME,
NULL, /* URL init. */
MU_MBOX_PRIO,
MU_MBOX_SCHEME,
mu_url_expand_path, /* URL init. */
_mailbox_mbox_init, /* Mailbox init. */
NULL, /* Mailer init. */
_folder_mbox_init, /* Folder init. */
NULL, /* No need for an owner. */
_path_is_scheme, /* is_scheme method. */
NULL, /* get_url method. */
NULL, /* get_mailbox method. */
NULL, /* get_mailer method. */
NULL /* get_folder method. */
NULL, /* No need for an back pointer. */
_mbox_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_path_record = &_path_record;
mu_record_t mu_mbox_record = &_mbox_record;
/* lsub/subscribe/unsubscribe are not needed. */
static void folder_mbox_destroy (mu_folder_t);
......
......@@ -533,7 +533,7 @@ perms_tag_checker (const char *name, mu_list_t tags, mu_list_t args)
mu_iterator_next (itr))
{
int flag;
char *p;
const char *p;
mu_sieve_runtime_tag_t *t;
mu_iterator_current (itr, (void **)&t);
if (strcmp (t->tag, "permissions") == 0)
......
......@@ -16,7 +16,11 @@
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
/* Syntax: pipe [:envelope] <program call: string>
/* Syntax: pipe [:envelope] <program: string>
The pipe action executes a shell command specified by its
argument and pipes the entire message to its standard input.
The envelope of the message is included, if the :envelope tag is given.
Notes/FIXME: 1. it would be nice to implement meta-variables in
<program call> which would expand to various
......
......@@ -232,7 +232,7 @@ sigpipe_handler (int sig MU_ARG_UNUSED)
/* The test proper */
/* Syntax: spamd [":host" <tcp-host: string]
/* Syntax: spamd [":host" <tcp-host: string>]
[":port" <tcp-port: number> /
":socket" <unix-socket: string>]
[":user" <name: string>]
......
......@@ -23,7 +23,7 @@
[:reply_regex <expr: string>]
[:reply_prefix <prefix: string>]
<reply text: string>
*/
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
......
......@@ -32,6 +32,7 @@
#include <mailutils/nls.h>
#include <mailutils/debug.h>
#include <mailutils/syslog.h>
#include <mailutils/registrar.h>
#include <syslog.h>
int mu_load_user_rcfile = 1;
......@@ -73,7 +74,7 @@ mu_gocs_mailbox_init (void *data)
}
if (p->mailbox_type)
{
if (mu_mailbox_set_default_proto (p->mailbox_type))
if (mu_registrar_set_default_scheme (p->mailbox_type))
mu_error (_("Invalid mailbox type: %s"), p->mailbox_type);
free (p->mailbox_type);
p->mailbox_type = NULL;
......
......@@ -77,44 +77,6 @@ mailbox_folder_create (mu_mailbox_t mbox, const char *name,
return rc;
}
static char *default_proto;
int
mu_mailbox_set_default_proto (const char *proto)
{
char *p;
size_t len = strlen (proto);
if (proto [len - 1] == ':')
{
p = strdup (proto);
if (!p)
return ENOMEM;
}
else
{
p = malloc (len + 2);
if (!p)
return ENOMEM;
strcpy (p, proto);
p[len] = ':';
p[len+1] = 0;
}
if (mu_registrar_lookup (p, MU_FOLDER_ATTRIBUTE_FILE, NULL, NULL))
return MU_ERR_NO_HANDLER;
if (default_proto)
free (default_proto);
default_proto = p;
return 0;
}
const char *
mu_mailbox_get_default_proto ()
{
return default_proto ? default_proto : "/";
}
static int
_create_mailbox0 (mu_mailbox_t *pmbox, mu_url_t url, const char *name)
{
......@@ -235,22 +197,10 @@ _create_mailbox (mu_mailbox_t *pmbox, const char *name)
int
mu_mailbox_create (mu_mailbox_t *pmbox, const char *name)
{
int rc;
if (pmbox == NULL)
return MU_ERR_OUT_PTR_NULL;
if (!mu_is_proto (name) && default_proto)
{
char *tmp_name = malloc (strlen (default_proto) + strlen (name) + 1);
strcpy (tmp_name, default_proto);
strcat (tmp_name, name);
rc = _create_mailbox (pmbox, tmp_name);
free (tmp_name);
}
else
rc = _create_mailbox (pmbox, name);
return rc;
return _create_mailbox (pmbox, name);
}
int
......
......@@ -35,7 +35,7 @@
#include <mailutils/nls.h>
#include <mailutils/error.h>
#include <mailutils/url.h>
#include <mailutils/mutil.h>
#include <registrar0.h>
/* NOTE: We will leak here since the monitor and the registrar will never
......@@ -43,6 +43,44 @@
static mu_list_t registrar_list;
struct mu_monitor registrar_monitor = MU_MONITOR_INITIALIZER;
static mu_record_t mu_default_record;
void
mu_registrar_set_default_record (mu_record_t record)
{
mu_default_record = record;
}
int
mu_registrar_get_default_record (mu_record_t *prec)
{
if (mu_default_record)
{
if (prec)
*prec = mu_default_record;
return 0;
}
return MU_ERR_NOENT;
}
int
mu_registrar_set_default_scheme (const char *scheme)
{
int status;
mu_record_t rec;
status = mu_registrar_lookup_scheme (scheme, &rec);
if (status == 0)
mu_default_record = rec;
return status;
}
const char *
mu_registrar_get_default_scheme ()
{
return mu_default_record ? mu_default_record->scheme : NULL;
}
static int
_registrar_get_list (mu_list_t *plist)
{
......@@ -91,6 +129,34 @@ mu_registrar_get_iterator (mu_iterator_t *pitr)
}
int
mu_registrar_lookup_scheme (const char *scheme, mu_record_t *precord)
{
size_t len;
mu_iterator_t iterator;
int status = mu_registrar_get_iterator (&iterator);
if (status != 0)
return status;
status = MU_ERR_NOENT;
len = strcspn (scheme, ":");
for (mu_iterator_first (iterator); !mu_iterator_is_done (iterator);
mu_iterator_next (iterator))
{
mu_record_t record;
mu_iterator_current (iterator, (void **)&record);
if (strlen (record->scheme) == len
&& memcmp (record->scheme, scheme, len) == 0)
{
if (precord)
*precord = record;
status = 0;
break;
}
}
mu_iterator_destroy (&iterator);
return status;
}
int
mu_registrar_lookup_url (mu_url_t url, int flags,
mu_record_t *precord, int *pflags)
{
......@@ -116,6 +182,17 @@ mu_registrar_lookup_url (mu_url_t url, int flags,
}
}
mu_iterator_destroy (&iterator);
if (status &&
/*s FIXME: This check is not enough. */
!mu_is_proto (mu_url_to_string (url))
&& mu_registrar_get_default_record (precord) == 0)
{
status = 0;
if (pflags)
*pflags = flags & MU_FOLDER_ATTRIBUTE_FILE; /* FIXME? */
}
return status;
}
......
......@@ -47,6 +47,7 @@ static struct mu_conf_option mu_conf_option[] = {
{ "VERSION=" VERSION, N_("Version of this package") },
{ "SYSCONFDIR=" SYSCONFDIR, N_("System configuration directory") },
{ "MAILSPOOLDIR=" MU_PATH_MAILDIR, N_("Default mail spool directory") },
{ "SCHEME=" MU_DEFAULT_SCHEME, N_("Default mailbox type") },
{ "LOG_FACILITY=" LOG_FACILITY_STRING, N_("Default syslog facility") },
#ifdef USE_LIBPAM
{ "USE_LIBPAM", N_("PAM support") },
......