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 \
......
......@@ -10,14 +10,14 @@
@end smallexample
There are many ways to authenticate to a server. To be flexible the
There are many ways to authenticate to a server. To be flexible the
authentication process is provided by three objects @code{mu_authority_t},
@code{mu_ticket_t}, and @code{mu_wicket_t}. The @code{mu_authority_t} can implement
@code{mu_ticket_t}, and @code{mu_wicket_t}. The @code{mu_authority_t} can implement
different protocol like APOP, MD5-AUTH, One Time Passwd, etc. By default
if a mailbox does not understand or know how to authenticate it falls back
to user/passwd authentication. The @code{mu_ticket_t} is a way for
to user/passwd authentication. The @code{mu_ticket_t} is a way for
Mailboxes and Mailers provide a way to authenticate when the URL does not
contain enough information. The default action is to call the function
contain enough information. The default action is to call the function
@code{mu_authority_authenticate()} which will get the @emph{user} and @emph{passwd}
if not set, this function can be overridden by a custom method.
......
......@@ -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,
......
......@@ -10,8 +10,8 @@
@end smallexample
Internet Message Access Protocol - Version (4rev1). In IMAP4, the client
must be prepared to accept any responses at all times. The server responses
Internet Message Access Protocol - Version (4rev1). In IMAP4, the client
must be prepared to accept any responses at all times. The server responses
have three forms: status responses, server data and command continuation
request. Untagged responses, for historical reasons are also call
"unsolicited responses".
......
......@@ -9,7 +9,7 @@ the system user database. The library @file{libmuauth} extends this
functionality, allowing @file{libmailbox} functions to obtain
information about a user from several places, like @sc{sql} database,
etc. The method used is described in detail in @ref{Auth Statement,
authentication}. This chapter contains a very succinct description of
authentication}. This chapter contains a very succinct description of
the underlying library mechanism.
@menu
......
......@@ -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;
......@@ -620,7 +620,7 @@ string @var{str}.
@deftypefun {void *} mu_sieve_mrealloc (mu_sieve_machine_t @var{mach}, void *@var{ptr}, size_t @var{size})
Changes the size of the memory block pointed to by @var{ptr} to
@var{size} bytes. The contents will be unchanged to the minimum of the
@var{size} bytes. The contents will be unchanged to the minimum of the
old and new sizes; newly allocated memory will be uninitialized. If
@var{ptr} is @code{NULL}, the call is equivalent to
@code{mu_sieve_malloc(@var{mach}, @var{size})}; if @var{size} is equal to
......@@ -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
......
......@@ -69,7 +69,7 @@ Destroys and releases resources held by @var{mbox}.
@deftypefun int mu_mailbox_open (mu_mailbox_t @var{mbox}, int @var{flag})
A connection is open, if no stream was provided, a stream
is created based on the @var{mbox} type. The @var{flag} can be OR'ed.
is created based on the @var{mbox} type. The @var{flag} can be OR'ed.
See @code{stream_create()} for @var{flag}'s description.
The return value is @code{0} on success and a code number on error conditions:
......
......@@ -12,7 +12,7 @@
The standard @cite{RFC 1524} (A User Agent Configuration Mechanism)
suggests a file format to be used to inform a mail user agent about
facilities for handling mail in various format. The configuration
facilities for handling mail in various format. The configuration
file is known also as mailcap and it is tipically found in UNIX
platforms, a example of @file{/etc/mailcap}:
......@@ -24,10 +24,10 @@ application/pgp; gpg < %s | metamail; needsterminal; \
@end smallexample
A mailcap file consits of a set of mailcap entries per line, lines
beginning with @samp{#} are considered comments and ignored. Long
beginning with @samp{#} are considered comments and ignored. Long
mailcap entry may be continued on multiple lines if each line ends
with a backslash character @samp{\}, the multiline will be considered
a single mailcap entry. The overall format in @acronym{BNF}:
a single mailcap entry. The overall format in @acronym{BNF}:
@smallexample
@group
......
......@@ -55,11 +55,11 @@ Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
and with the Back-Cover Texts as in (a) below. A copy of the license
and with the Back-Cover Texts as in (a) below. A copy of the license
is included in the section entitled ``GNU Free Documentation License''.
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
this GNU Manual, like GNU software. Copies published by the Free
this GNU Manual, like GNU software. Copies published by the Free
Software Foundation raise funds for GNU development.''
@end copying
......@@ -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
......@@ -395,10 +419,10 @@ Preprocessor
@chapter Introduction
GNU Mailutils contains a series of useful mail clients, servers,
and libraries. These are the primary mail utilities of the GNU system.
and libraries. These are the primary mail utilities of the GNU system.
Specifically, this package contains a POP3 server, an IMAP4 server,
and a Sieve mail filter. It also provides a POSIX `mailx' client,
and a collection of other tools. All utilities can manipulate the
and a Sieve mail filter. It also provides a POSIX `mailx' client,
and a collection of other tools. All utilities can manipulate the
mailboxes of various formats, both local, stored on the hard disk,
and remote, accessed via network protocols, such as POP3 or IMAP4.
......@@ -406,7 +430,7 @@ The GNU Mailutils libraries supply a rich set of primitives for
handling electronic mail in programs written in C, C++ or Scheme.
This software is part of the GNU Project and belongs to the Free
Software Foundation. All libraries are licensed using the GNU LGPL.
Software Foundation. All libraries are licensed using the GNU LGPL.
The documentation is licensed under the GNU FDL, and everything
else is licensed using the GNU GPL.
......@@ -420,17 +444,17 @@ else is licensed using the GNU GPL.
@UNREVISED
@FIXME{This is more a plan on how the document should be structured,
than a description of its actual structure. However it is:}
than a description of its actual structure. However it is:}
This book addresses a wide audience of both system administrators
and users that aim to use Mailutils programs, and programmers who wish
to use Mailutils libraries in their programs. Given this audience,
to use Mailutils libraries in their programs. Given this audience,
the book is divided in three major parts.
The first part provides a detailed description of each Mailutils
utility, and advices on how to use them in various situations. This
utility, and advices on how to use them in various situations. This
part is intended for users and system administrators who are using
Mailutils programs. If you are not interested in programming using
Mailutils programs. If you are not interested in programming using
Mailutils, this is the only part you need to read.
Subsequent parts address programmers.
......@@ -447,9 +471,9 @@ reference.
@UNREVISED
This package started off to try and handle large mailbox files more
gracefully then current POP3 servers did. While it handles this task,
gracefully then current POP3 servers did. While it handles this task,
it also allows you to support a variety of different mailbox formats
without any real effort on your part. Also, if a new format is added
without any real effort on your part. Also, if a new format is added
at a later date, your program will support that new format
automatically as soon as it is compiled against the new library.
......@@ -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
......
......@@ -10,7 +10,7 @@
@end smallexample
The most common mailbox format on UNIX platform is @emph{mbox}. Mbox is a
The most common mailbox format on UNIX platform is @emph{mbox}. Mbox is a
text file that contains messages separated by a special format string.
@smallexample
......@@ -34,7 +34,7 @@ check to see if the format is a valid format or an empty file. The scanning
of the mailbox is done by @code{mu_mbox_scan ()}, the function, takes callback
functions called during the scanning to provide information on progress and
new messages found. The scanning will cache some of the headers fields for
speed, new fields could be add with @code{mu_mbox_add_hcache ()}. On Closing
speed, new fields could be add with @code{mu_mbox_add_hcache ()}. On Closing
the @var{mu_mbox_t}, @code{mu_mbox_close ()} will free any resources like, headers
cache, locks etc ... The messages with attributes marked deleted will only
be removed on @code{mu_mbox_expunge ()}, if there is a need to save the
......@@ -68,8 +68,8 @@ reclaim memory.
@deftypefun int mu_mbox_set_carrier (mu_mbox_t, stream_t @var{carrier});
Another type of stream can be provided, the @var{carrier}
is set in the @var{mu_mbox_t} handle. Any previous @var{carrier} stream in
the handle, will be close and destroy. Since the parsing code
is set in the @var{mu_mbox_t} handle. Any previous @var{carrier} stream in
the handle, will be close and destroy. Since the parsing code
maintain only the offsets off the message the @var{carrier} stream must be
seekable.
......@@ -80,7 +80,7 @@ seekable.
@deftypefun int mu_mbox_get_carrier (mu_mbox_t, stream_t *@var{carrier});
Return the @var{mu_mbox_t} carrier. If none was set, a new file stream will be
Return the @var{mu_mbox_t} carrier. If none was set, a new file stream will be
created.
@table @code
......@@ -91,7 +91,7 @@ created.
@deftypefun int mu_mbox_open (mu_mbox_t, const char *@var{filename}, int @var{flags})
Open carrier stream with @var{filename} and @var{flags}. The stream will be
Open carrier stream with @var{filename} and @var{flags}. The stream will be
quickly examine to see if it is a mbox format.
@table @code
......@@ -285,7 +285,7 @@ Add to the current cache for the scan, the fields in @var{array}.
@deftypefun int mu_mbox_value_hcache (mu_mbox_t, unsigned int @var{msgno}, const char *@var{field}, char *@var{buffer}, size_t @var{buflen}, size_t *@var{writen})
Get the value of @var{field} in the header cache for @var{msgno}. The
Get the value of @var{field} in the header cache for @var{msgno}. The
result is copied in a @var{buffer} of @var{buflen} and @var{writen} is set
to the number of byte put in @var{buffer}.
......@@ -329,7 +329,7 @@ NULL to get the default.
@deftypefun int mu_mbox_append_hb (mu_mbox_t, const char *@var{sep}, stream_t @var{hstream}, stream_t @var{bstream})
Append to the mailbox an rfc822 message represented by a header, @var{hstream},
and a body, @var{bstream}. The variable @var{sep} should contain a valid
and a body, @var{bstream}. The variable @var{sep} should contain a valid
"From " separator or NULL to get the default.
@table @code
......@@ -339,11 +339,11 @@ and a body, @var{bstream}. The variable @var{sep} should contain a valid
@deftypefun int mu_mbox_scan (mu_mbox_t, unsigned int @var{start}, unsigned int *@var{count})
Start scanning the mailbox for new messages. The variable @var{start} can be
a message number starting point. The result of the scanning will be in
@var{count}. The scanning will trigger the @code{mu_mbox_newmsg_cb()} callback
Start scanning the mailbox for new messages. The variable @var{start} can be
a message number starting point. The result of the scanning will be in
@var{count}. The scanning will trigger the @code{mu_mbox_newmsg_cb()} callback
for each new message and @code{mu_mbox_progress_cb ()} at different interval
to notify progression. The return values of the those callback should be
to notify progression. The return values of the those callback should be
0 is different then 0 the scanning will be stop an the function returns
MU_ERROR_INTERRUPTED.
......@@ -361,8 +361,8 @@ Same as @code{mu_mbox_scan ()} but does not call the callbacks.
@end deftypefun
@deftypefun int mu_mbox_set_progress_cb (mu_mbox_t, int (*@var{callback}) (int @var{percentage}, void *)), void *@var{arg})
Set the callback function for progress. The variable @var{arg} will be pass
back in the callback as the second argument. The first argument of the
Set the callback function for progress. The variable @var{arg} will be pass
back in the callback as the second argument. The first argument of the
callback represents a @var{percentage} of the scanning progress.
@table @code
......@@ -372,8 +372,8 @@ callback represents a @var{percentage} of the scanning progress.
@deftypefun int mu_mbox_set_newmsg_cb (mu_mbox_t, int (*@var{callback}) (int @var{count}, void *)), void *@var{arg})
Set the callback function for new messages. The variable @var{arg} will be
pass back in the callback as the second argument. The first argument
Set the callback function for new messages. The variable @var{arg} will be
pass back in the callback as the second argument. The first argument
is the total of messages found.
@table @code
......@@ -383,7 +383,7 @@ is the total of messages found.
@deftypefun int mu_mbox_set_error_cb (mu_mbox_t, int (*@var{callback}) (int, void *)), void *@var{arg})
Set the callback function for errors. The variable @var{arg} will be
Set the callback function for errors. The variable @var{arg} will be
pass back in the callback as the second argument.
@table @code
......
......@@ -10,7 +10,7 @@
@end smallexample
The @code{mu_message_t} object is a convenient way to manipulate messages. It
The @code{mu_message_t} object is a convenient way to manipulate messages. It
encapsulates the @code{envelope_t}, the @code{header_t} and the @code{body_t}.
@smallexample
......
......@@ -14,7 +14,7 @@ but by using structures and pointers to function, it is possible to provide
a simple framework.
Every Mailutils object has a corresponding C structure holding its interface
and specific data. For example mu_object_t, is the root object and all mailutils objects
and specific data. For example mu_object_t, is the root object and all mailutils objects
extends it:
@smallexample
......@@ -37,7 +37,7 @@ struct _mu_object
@end smallexample
The @var{vtable} is an array of pointers to function, it provides the interface
or the list of function for this object. The library provides wrapper to
or the list of function for this object. The library provides wrapper to
access the functions instead using the @var{vtable} directly.
@smallexample
......
......@@ -57,7 +57,7 @@ Returns the list of headers in the message @var{mesg}. Optional argument
@c snarfed from "mu_message.c":510
@deffn {Scheme procedure} mu-message-set-header-fields mesg list replace
Set the headers in the message @var{mesg} from @var{list}
@var{list} is a list of conses (cons HEADER VALUE). The function sets
@var{list} is a list of conses (cons HEADER VALUE). The function sets
these headers in the message @var{mesg}.
Optional parameter @var{replace} specifies whether the new header
values should replace the headers already present in the
......
@c snarfed from "mu_mime.c":95
@deffn {Scheme procedure} mu-mime-create flags mesg
Creates a new @acronym{MIME} object. Both arguments are optional.
Creates a new @acronym{MIME} object. Both arguments are optional.
@var{flags} specifies the type of the object to create (@samp{0} is a reasonable
value). @var{mesg} gives the message to create the @acronym{MIME} object from.
value). @var{mesg} gives the message to create the @acronym{MIME} object from.
@end deffn
@c snarfed from "mu_mime.c":131
......
@c snarfed from "mu_scm.c":130
@deffn {Scheme procedure} mu-register-format rest
Registers desired mailutils formats. Any number of arguments can be given.
Registers desired mailutils formats. Any number of arguments can be given.
Each argument must be one of the following strings:
@multitable @columnfractions 0.3 0.6
......
......@@ -11,7 +11,7 @@
@ifinfo
@dircategory GNU libraries
@direntry
* mailutils-int: (muint). The internals of GNU Mailutils.
* mailutils-int: (muint). The internals of GNU Mailutils.
@end direntry
@end ifinfo
......@@ -26,11 +26,11 @@ Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
and with the Back-Cover Texts as in (a) below. A copy of the license
and with the Back-Cover Texts as in (a) below. A copy of the license
is included in the section entitled ``GNU Free Documentation License''.
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
this GNU Manual, like GNU software. Copies published by the Free
this GNU Manual, like GNU software. Copies published by the Free
Software Foundation raise funds for GNU development.''
@end copying
......@@ -51,7 +51,7 @@ Software Foundation raise funds for GNU development.''
@chapter Scope of this Document
This document describes the internals of the GNU Mailutils. It
This document describes the internals of the GNU Mailutils. It
includes description of Mailutils' architecture, algorithms and
data structures. It is intended primarily for Mailutils developers
and those who wish to participate in the development of the package.
......
......@@ -17,9 +17,9 @@
The purpose of the Post Office Protocol Version 3 (POP3) is to permit a client
to download a maildrop from a remote server, the protocol does not provide
complex or extensive operation on the maildrop. When the client successfully
complex or extensive operation on the maildrop. When the client successfully
authenticates, the server acquires an exclusive access lock on the mailbox
and holds it the entire duration of the session. After the authentication,
and holds it the entire duration of the session. After the authentication,
the session enters transaction state and the client may issues commands to
access messages in the mailbox.
......@@ -72,16 +72,16 @@ and closes the TCP connection.
@cindex mu_pop3_t
An opaque structure @code{mu_pop3_t} is use as a handle for the session, it is allocated and initialize by
calling @code{mu_pop3_create()}. All Functions will wait for a reply from the POP3 server before returning.
calling @code{mu_pop3_create()}. All Functions will wait for a reply from the POP3 server before returning.
The duration of the wait can be set by calling @code{mu_pop3_set_timeout()}, the default is 2 minutes.
On the server side, there is also an idle timeout of 10 minutes before the POP3 server closes the connection,
although the @cite{RFC 1939} specifies that the minimum
default timeout to be ten minutes, many servers have shorter idle period, care should be taken to at least send a
@code{mu_pop3_noop()} between lengthy period of idle time. Once a successful connection is established with
@code{mu_pop3_noop()} between lengthy period of idle time. Once a successful connection is established with
@code{mu_pop3_connect()}, two built-ins authentications are provided @code{mu_pop3_apop ()} or
@code{mu_pop3_user()}/@code{mu_pop3_pass()}. The @code{mu_pop3_stat()} and @code{mu_pop3_list ()} functions can be use to
@code{mu_pop3_user()}/@code{mu_pop3_pass()}. The @code{mu_pop3_stat()} and @code{mu_pop3_list ()} functions can be use to
get the number and size of messages. The functions @code{mu_pop3_list_all()}, @code{mu_pop3_uidl_all ()} and
@code{mu_pop3_capa()} save the information in an @code{mu_iterator_t}. Downloading of messages is done
@code{mu_pop3_capa()} save the information in an @code{mu_iterator_t}. Downloading of messages is done
via a two methods @code{mu_pop3_retr()} or @code{mu_pop3_top()};
@strong{Caution: Some Internet Service Providers do not permit to leave mail on server and the message will be
deleted once downloaded}.
......@@ -91,7 +91,7 @@ all the functions will return @code{EINPROGRESS} if an other operation is in pro
@subsubsection Callbacks
The POP3 library does not provide any callbacks, the approach is to leave flow control and policy outside of the
library. The functions do minimal state checking, for example when sending RETR with @code{mu_pop3_retr()}
library. The functions do minimal state checking, for example when sending RETR with @code{mu_pop3_retr()}
it is the responsibility of the user to go through the entire buffer of the stream to terminate the RETR command,
any other operation will fail, while the RETR is in progress.
To reset the state or break the downloading, the user should disconnect @code{mu_pop3_disconnect()} and reconnect
......@@ -136,7 +136,7 @@ When a POP3 session is finished, any data use by the library is release.
@deftypefun int mu_pop3_connect (mu_pop3_t @var{pop3})
A connection is established on the carrier, if there was any previous connection it is close first. If non-blocking the
A connection is established on the carrier, if there was any previous connection it is close first. If non-blocking the
function should be recall until the return value is not EAGAIN or EINPROGRESS.
Errors:
......@@ -191,8 +191,8 @@ Errors:
@deftypefun int mu_pop3_apop (mu_pop3_t @var{pop3}, const char *@var{user}, const char *@var{secret})
APOP offers an alternative to USER/PASS authentication. For intermittent use of POP3, like checking for new mail, it is the
preferred way to authenticate. It reduces the risk of password capture. The @var{user} and the shared @var{secret} are pass
APOP offers an alternative to USER/PASS authentication. For intermittent use of POP3, like checking for new mail, it is the
preferred way to authenticate. It reduces the risk of password capture. The @var{user} and the shared @var{secret} are pass
to @code{mu_pop3_apop()}, the MD5 digest is calculated by applying the time-stamp given by the server in the greeting
followed by the @var{secret}.
......@@ -331,7 +331,7 @@ print_message (mu_pop3_t pop3, unsigned int msgno)
@deftypefun int mu_pop3_top (mu_pop3_t @var{pop3}, unsigned int @var{msgno}, unsigned int @var{lines}, mu_stream_t *@var{stream})
If successful @code{stream} should be call to download the header, byte-stuff lines or handle internally, CRLFs are
converted to LF. All other operations will failed until the operation is completed by the caller.
converted to LF. All other operations will failed until the operation is completed by the caller.
Errors:
@table @code
......@@ -410,7 +410,7 @@ Errors:
@deftypefun int mu_pop3_uidl_all (mu_pop3_t @var{pop3}, mu_iterator_t *@var{iterator})
A UIDL command is executed. The call should iterate through the @code{iterator} to fetch the response.
A UIDL command is executed. The call should iterate through the @code{iterator} to fetch the response.
Errors:
@table @code
......@@ -517,7 +517,7 @@ Errors:
@deftypefun int mu_pop3_set_timeout (mu_pop3_t @var{pop3}, int @var{timeout})
Set the timeout time for I/O on the carrier. The default is 10 minutes. The @var{timeout} is given in milliseconds.
Set the timeout time for I/O on the carrier. The default is 10 minutes. The @var{timeout} is given in milliseconds.
Errors:
@table @code
......
......@@ -5,10 +5,10 @@
@c ======================================================================
@c This document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
@c as decided by @set symbols. The PUBLISH rendition does not show
@c notes or marks asking for revision. Most users will prefer having more
@c as decided by @set symbols. The PUBLISH rendition does not show
@c notes or marks asking for revision. Most users will prefer having more
@c information, even if this information is not fully revised for adequacy,
@c so DISTRIB is the default for distributions. The PROOF rendition
@c so DISTRIB is the default for distributions. The PROOF rendition
@c show all marks to the point of ugliness, but is nevertheless useful to
@c those working on the manual itself.
@c ======================================================================
......
......@@ -11,7 +11,7 @@ properly.
@subsubheading POP3
The POP URL scheme contains a POP server, optional port number
and the authentication mechanism. The general form is
and the authentication mechanism. The general form is
@smallexample
@group
......@@ -91,7 +91,7 @@ If @emph{:port} is omitted the default value is 993.
@subsubheading File
Local folder should be handle by this URL. It is preferable to let
Local folder should be handle by this URL. It is preferable to let
the mailbox recognize the type of mailbox and take the appropriate
action.
......
......@@ -124,9 +124,9 @@ $ @kbd{ARGP_HELP_FMT=long-opt-col=16 sieve --help|grep ADDRESS}
@end deftypevr
@deftypevr {Help Output} offset doc-opt-col
Column in which @dfn{doc options} start. A doc option isn't actually
Column in which @dfn{doc options} start. A doc option isn't actually
an option, but rather an arbitrary piece of documentation that is
displayed in much the same manner as the options. For example, in
displayed in much the same manner as the options. For example, in
the output of @command{folder --help}:
@verbatim
......@@ -138,7 +138,7 @@ GNU MH folder
@end verbatim
@noindent
the string @samp{Actions are:} is a doc option. Thus, if you set
the string @samp{Actions are:} is a doc option. Thus, if you set
@kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
will look as follows:
......@@ -172,8 +172,8 @@ Notice, that the description starts on a separate line if
@end deftypevr
@deftypevr {Help Output} offset header-col
Column in which @dfn{group headers} are printed. A group header is a
descriptive text preceding an option group. For example, in the
Column in which @dfn{group headers} are printed. A group header is a
descriptive text preceding an option group. For example, in the
following text:
@verbatim
......
......@@ -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,9 +47,18 @@ 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);
......@@ -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;
......@@ -121,6 +121,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
}
......
......@@ -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,94 +46,73 @@
/* 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))
{
if (mu_scheme_autodetect_p (url))
{
struct stat st;
const char *path;
struct stat st;
const char *path;
mu_url_sget_path (url, &path);
if (stat (path, &st) < 0)
mu_url_sget_path (url, &path);
if (stat (path, &st) < 0)
return 0;
if (S_ISREG (st.st_mode) || S_ISCHR (st.st_mode))
{
if (st.st_size == 0)
{
if (errno == ENOENT)
rc |= MU_FOLDER_ATTRIBUTE_FILE;
return rc;
rc |= MU_FOLDER_ATTRIBUTE_FILE;
}
if (S_ISREG (st.st_mode) || S_ISCHR (st.st_mode))
else if (flags & MU_FOLDER_ATTRIBUTE_FILE)
{
if (st.st_size == 0)
#if 0
/* This effectively sieves out all non-mailbox files,
but it makes mu_folder_enumerate crawl, which is
intolerable for imap4d LIST command. */
int fd = open (path, O_RDONLY);
if (fd != -1)
{
rc |= MU_FOLDER_ATTRIBUTE_FILE;
char buf[5];
if (read (fd, buf, 5) == 5)
if (memcmp (buf, "From ", 5) == 0)
rc |= MU_FOLDER_ATTRIBUTE_FILE;
close (fd);
}
else if (flags & MU_FOLDER_ATTRIBUTE_FILE)
{
#if 0
/* This effectively sieves out all non-mailbox files,
but it makes mu_folder_enumerate crawl, which is
intolerable for imap4d LIST command. */
int fd = open (path, O_RDONLY);
if (fd != -1)
{
char buf[5];
if (read (fd, buf, 5) == 5)
if (memcmp (buf, "From ", 5) == 0)
rc |= MU_FOLDER_ATTRIBUTE_FILE;
close (fd);
}
#else
rc |= MU_FOLDER_ATTRIBUTE_FILE;
rc |= MU_FOLDER_ATTRIBUTE_FILE;
#endif
}
}
if ((flags & MU_FOLDER_ATTRIBUTE_DIRECTORY)
&& S_ISDIR (st.st_mode))
rc |= MU_FOLDER_ATTRIBUTE_DIRECTORY;
}
if ((flags & MU_FOLDER_ATTRIBUTE_DIRECTORY)
&& 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, /* Mailer init. */
_folder_mbox_init, /* Folder init. */
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,8 +16,12 @@
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
items from the message being handled.
......
......@@ -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") },
......