Commit 0fe6a874 0fe6a874807c5711a60738e2a502498126dbd2cb by Alain Magloire

Modified Files:

 	encoding.texi headers.texi mailbox.texi mailer.texi
 	mailutils.texi sfrom.c.texi url.texi
updating
Added Files:
 	body.texi message.texi
updating
1 parent 831780e1
The @code{body_t} type contains a @code{header_t}, a content and
optionnaly another @code{body_t} part.
@section Init/Destroy
@deftypefun int body_init (body_t *@var{msg}, const mailbox_t @var{mbx})
Private.
@end deftypefun
@deftypefun void body_destroy (body_t *@var{msg})
The ressources allocate for clone @var{msg} are freed.
@end deftypefun
@deftypefun int body_get_header (body_t @var{msg}, header_t *@var{hdr})
@end deftypefun
@deftypefun int body_get_content (body_t @var{msg}, char *buffer, size_t len, size_t *n)
@end deftypefun
@deftypefun int body_get_type (body_t @var{msg}, char *buffer, size_t len, size_t *n)
@end deftypefun
@subsection RFC1522
@section RFC1522
@cindex RFC1522
@subsection Quoted Printable
@section Quoted Printable
@cindex Quoted Printable
@subsection Base64
@section Base64
@cindex Base64
......
So far we plan support for RFC822 and plan for RFC1522. with RFC1522 non ASCII
characters will be encoded.
@subsubsection Init/Destroy
@section Init/Destroy
The header should be initiliaze before any use.
@deftypefun int header_init (header_t *@var{hdr}, const char *@var{blurb}, size_t @var{len}, int @var{flag})
Initialize a @var{hdr} to a supported type. If @var{blurb} is not NULL, it is
parsed. @var{Flag} can be set to RFC8222 or RFC1522 so far onlyr rfc822 is
supported.
@end deftypefun
@defmac MU_HDR_RFC822
Supports rfc 822, header style.
......@@ -18,15 +17,16 @@ Supports rfc 822, header style.
Supports rfc 1522, encoding policy.
@end defmac
@end deftypefun
@deftypefun void header_destroy (header_t *@var{hdr})
The ressources allocate for @var{hdr} or freed.
The ressources allocate for @var{hdr} are freed.
@end deftypefun
@deftypefun int header_set_value (header_t @var{hdr}, const char *@var{fn}, const char *@var{fv}, size_t n, int @var{replace})
Set the field-name @var{fn} to field-value @var{fv} of size @var{n} in
@var{hdr}. If @var{replace} is non-zero the initial value is replace, if zero
it is append.
@end deftypefun
Some basic macros is already provided for rfc822.
......@@ -109,6 +109,8 @@ Some basic macros is already provided for rfc822.
"MIME-Version"
@end defmac
@end deftypefun
@deftypefun int header_get_value (header_t @var{hdr}, const char *fn, char *fv, size_t len, size_t *n)
Value of field-name @var{fn} is return in buffer @var{fv} of size @var{len}.
The number of bytes written is put in @var{n}.
......@@ -131,15 +133,7 @@ Field-name @var{fn} is extract form @var{blurb} of size @var{bl} and put in
@var{n}.
@end deftypefun
@subsection Headers Macros
@cindex Headers Macros
@subsection Headers Parsed
@cindex Headers Parsed
Return a hash table, a dictionnary, ???
@subsection Headers Regex
@section Headers Regex
@cindex Headers Regex
Using regular expression ?
......
Mail boxes come in different formats and may be on a remote hosts,
only accessible through a Mail Delivery Agent(MDA). Regardeless
only accessible through Mail Delivery Agent(MDA). Regardeless
of the format and the protocol use, some common actions are needed like
reading, saving, deleting, scanning ... Those actions are provided via a
unify API mailbox_t.
All functions of the mailbox_t API return 0 if succesfull or non-zero
otherwise. Unless they specify otherwise.
for failure, unless specify otherwise.
@subsubsection Init/Destroy
@section Init/Destroy
Initializing and destroying a mailbox_t object.
@deftypefun int mailbox_init (mailbox_t *@var{mbx}, const char * @var{url}, int @var{id})
Based on the type of the @var{url}, @var{mbx} is initialize to a known type,
if @var{id} is not zero, it represents the id of the mailbox. The @var{id}
will be use instead of doing heuristic search on the @var{url}.
@end deftypefun
@example
#include <mailutils.h>
@dot{}
@dots{}
mailbox_t foo, popmbx, bar;
/* same as @url{file:///var/mail/foo} */
mailbox_init (&mbox, "/var/mail/foo", 0);
mailbox_init (&mbox, "pop://popserver.bar.com/foo, 0);
mailbox_init (&mbox, "pop://popserver.bar.com/foo", 0);
mailbox_init (&mbox, "file:///home/bar/.hiddenmail/bar", 0);
@end example
@end deftypefun
@deftypefun int mailbox_init_default (mailbox_t *@var{mbx}, const char * @var{user})
Initialize the default mailbox of the system as set by the mail adminstrator.
It could be hardcoded or override by a configuration
@file{$sysconfig/mailutils.conf}.
@example
#include <mailutils.h>
@dots{}
/* If the default mailbox on this system is @file{/var/mail} */
mailbox_t mbx;
/* sets the mailbox name to @url{file:///var/mail/foo} */
mailbox_init_default (&mbx, "foo");
/*
If the user is log as @emph{bar}, sets the mailbox name
to @url{file:///var/mail/bar}
*/
mailbox_init_default (&mbx, NULL);
@end example
@end deftypefun
@deftypefun int mailbox_destroy (mailbox_t *@var{mbx})
All ressources allocated is release if the stream is not open,
All ressources allocated are release. If the stream is not open,
@code{mailbox_close} is call.
@end deftypefun
@subsubsection Open/Close
@section Open/Close
Opening and closing mailbox can be done any number of times. But be warned
on some cases like POP3, when opening, the lock can be persistent until
the stream is closed as required by the RFC.
@deftypefun int mailbox_open (mailbox_t @var{mbx}, int @var{flag})
Open the mailbox box stream. This funtion will call @code{mailbox_scan}.
@end deftypefun
@defmac MU_MB_RDONLY
Stream is open read-only.
......@@ -48,20 +70,86 @@ Stream is open write-only.
Stream is open read-write.
@end defmac
@defmac MU_MB_CREAT
If file does not exist it is created. May be a noop on remote hosts mailbox.
If Folder does not exist it is created. May be a noop on remote hosts mailbox.
@end defmac
@defmac MU_MB_APPEND
The stream is opened in append mode.
@end defmac
@defmac MU_MB_ONONBLOCK
For sockets, open() nonblocking.
For sockets, open() nonblocking. Not supported.
@end defmac
@end deftypefun
@deftypefun int mailbox_close (mailbox_t @var{mbx})
Close the streams and release the locks.
@end deftypefun
@subsubsection Deletion
@deftypefun int mailbox_is_open (mailbox_t @var{mbx})
Return a non-zero value if the stream is open, zero otherwise.
@end deftypefun
This is a very simple implementation of Unix @command{biff}.
@example
#include <mailutils.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#define NAP 120
int
main ()
@{
mailbox_t mbx;
size_t size = 0, size2 = 0;
if (mailbox_init_default (&mbx, NULL) != 0)
@{
fprintf ("Can't initiliaze system mailbox\n");
exit (EXIT_FAILURE);
@}
/* the open may fail if no mailbox was created,
will check this later */
mailbox_open (mbx, MU_MB_RDONLY);
mailbox_size (mbx, &size);
for (;;)
@{
if (! mailbox_is_open (mbx))
@{
if (mailbox_open (mbx, MU_MB_RDONLY) != 0);
@{
//fprintf (stderr, "Not exist ?\n");
@}
@}
else
@{
if (mailbox_size (mbx, &size2) == 0)
@{
if (size2 > size)
@{
printf ("You got mail\a\n");
@}
size = size2;
@}
@}
/* rest a while */
sleep (NAP);
/* It is a good habit to close the resources.
A mailbox could be a remote host and the locking
may interfere with normal delivery, for example with
POP, the lock is hold during the entire session.
*/
mailbox_close (mbx);
@}
return 0;
@}
@end example
@section Deletion
Messages can be marked for deletion but the action of removing them is only
taken when @code{mailbox_expunge} is called.
......@@ -85,11 +173,11 @@ All messages marked for deletion will be removed and the mailbox updated.
Return the number of Mailbox marked to be delete.
@end deftypefun
@subsubsection New Message
@section New Message
Certain mailboxes allow new messages to be appended the existing folder.
The stream must be @code{mailbox_open} with the proper permission.
@deftypefun int mailbox_create_envelope (mailbox_t @var{mbx}, size_t *@var{msgno})
@deftypefun int mailbox_new_message (mailbox_t @var{mbx}, size_t *@var{msgno})
Create an envelope, @var{msgno} will contain a uniq number for this envelope.
@end deftypefun
......@@ -104,7 +192,7 @@ Fill the body of new envelope @var{msgno}. If @var{replace} is zero the buffer
@var{body} will be append, otherwise it will overwrite any existing one.
@end deftypefun
@deftypefun int mailbox_append (mailbox_t @var{mbx}, size_t @var{msgno}, int @var{destroy})
@deftypefun int mailbox_append_message (mailbox_t @var{mbx}, size_t @var{msgno}, int @var{destroy})
@var{msgno} given from @code{mailbox_envelope} will be append to
the mailbox. When appending the header may be modified. In the case of
Unix Mbox, the header "From " is prepend. If @var{destroy} is set non-zero
......@@ -116,16 +204,16 @@ Ressources allocated to envelope @var{msgno} will be release. This function
should be call after @code{mailbox_append}.
@end deftypefun
@subsubsection Reading
@section Reading
Reading the message body and header.
@deftypefun int mailbox_get_body (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char *@var{buffer}, size_t @var{len}, size_t *@var{read})
@deftypefun int mailbox_get_content (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char *@var{buffer}, size_t @var{len}, size_t *@var{read})
Read the body of message @var{msgno} starting at offset @var{off} in
@var{buffer} of size @var{len}. The number of bytes read is returned in
@var{nread}.
@end deftypefun
@deftypefun int mailbox_get_mbody (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read})
@deftypefun int mailbox_get_mcontent (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read})
A buffer is allocated with @code{malloc(3)} return memory containing the body
of message @var{msgno} starting at offset @var{off} in @var{buffer}.
The number of bytes read is returned in @var{nread}.
......@@ -143,7 +231,7 @@ message @var{msgno} starting at offset @var{off} in @var{buffer}.
The number of bytes read is returned in @var{nread}.
@end deftypefun
@subsubsection Locking
@section Locking
Most mailboxes provide locking before changing the content. Functions
will grab the lock before doing any destructive action. The Locking functions
are provided for accesssing the folder outside the API, in that case the
......@@ -154,7 +242,6 @@ locking to provide synchronisation to the mailbox_t object.
Grab the lock. In some cases, i.e Unix mbox this may involve creating
a .lock file in the spool directory.
@comment Say something about permission the program be gid on some OS.
@end deftypefun
@defmac MU_MB_RDLOCK
Read lock.
......@@ -166,13 +253,15 @@ Write lock.
Read/Write lock.
@end defmac
@end deftypefun
Note on many mailbox, RDLOCK is a noop.
@deftypefun int mailbox_unlock (mailbox_t @var{mbx})
Release the lock.
@end deftypefun
@subsubsection Owner/Group
@section Owner/Group
Most mailboxes provide locking before changing their content, Ownership
and group. When creating certain mailbox, you can set the owner/group.
......@@ -185,7 +274,7 @@ Set the group to @var{gid}. If the Mailbox was not @code{mailbox_open}
the action is delayed until the stream is opened.
@end deftypefun
@subsubsection Scanning
@section Scanning
Scan is done explicitely on @code{mailbox_open}.
......@@ -214,7 +303,7 @@ For message @var{msgno} set @var{header} size and @var{body} size.
Return the number of messages in @var{mbx}.
@end deftypefun
@subsubsection Timeout/Notification
@section Timeout/Notification
Setting timeout and notifications. @code{mailbox_scan} can be called
periodically to see if new messages have arrived, if the number of
total messages has changed the notification function is called. By default
......@@ -236,7 +325,7 @@ Not Implemented.
Not Implemented.
@end deftypefun
@subsubsection Registration and Type
@section Registration and Type
Mailbox_t comes with a certain number of builtin types, you can query them
or add you own to the list.
......@@ -270,45 +359,45 @@ Add a mailbox @var{mtype} to the list of builtin.
Remove a mailbox @var{mtype} to the list of builtin.
@end deftypefun
@deftypefun int mailbox_get_type (struct mailbox_type **@var{mtype}, int @var{id})
Base ont the URL @var{id} return the mailbox_type.
@deftypefun int mailbox_get_type (struct mailbox_type **@var{mtype}, int @var{urlid})
Base on the URL @var{urlid} return the mailbox_type.
@end deftypefun
@deftypefun int mailbox_get_name (mailbox_t @var{mbx}, int *@var{id}, char *@var{name}, size_t @var{len}, size_t *@var{n})
Return the name of mailbox identify by @var{id}, in buffer @var{name} of size
@var{len}. The number of byte is put in @var{n}.
@deftypefun int mailbox_get_name (mailbox_t @var{mbx}, int *@var{mbxid}, char *@var{name}, size_t @var{len}, size_t *@var{n})
Return the name of mailbox identify by @var{mbxid}, in buffer @var{name} of
size @var{len}. The number of byte is put in @var{n}.
@end deftypefun
@deftypefun int mailbox_get_mname (mailbox_t, int *id, char **name, size_t *n)
Return the name of mailbox identify by @var{id}, in a @code{malloc(3)} buffer
@var{name} of size @var{n}.
@deftypefun int mailbox_get_mname (mailbox_t @var{mbx}, int *@var{mbxid}, char **@var{name}, size_t *@var{n})
Return the name of mailbox identify by @var{mbxid}, in a @code{malloc(3)}
buffer @var{name} of size @var{n}.
@end deftypefun
All mailbox implementations provide this minimum set of the API.
@subsection Unix Mbox
@section Unix Mbox
@cindex Unix Mbox
TODO: describe particularities :
locking policy, appending envelope, describe the flags use in _open(..), etc...
@subsection POP3 Mbox
@section POP3 Mbox
@cindex POP3 Mbox
TODO: describe timeout policies, describe the flags use in _open(..),
describe different authorisation supported.
@subsection IMAP Mbox
@section IMAP Mbox
@cindex IMAP Mbox
Not implemented.
@subsection QMail Mbox
@section QMail Mbox
@cindex QMail Mbox
Not implemented.
@subsection MMDF Mbox
@section MMDF Mbox
@cindex MMDF Mbox
Not implemented.
......
Mail Delivery is done here. Nothing is implemented and the API is still shaky.
@subsubsection Init/Destroy
@section Init/Destroy
Initialize the mailer object.
@deftypefun int mailer_init (mailer_t *@var{mailer}, const char *@var{name}, int @var{flag})
Not Implemented.
@end deftypefun
@defmac MU_ML_PROGRAM
Program like sendmail, mail, mailx to deliver the mail
......@@ -21,11 +20,14 @@ Contact the host directly with SMTP.
Use MPP protocol.
@end defmac
@end deftypefun
@deftypefun int mailer_destroy (mailer_r *@var{mailer})
Not Implemented.
@end deftypefun
@subsubsection User/Passwd
@section User/Passwd
On some mailer like MMP you need to identify.
......@@ -37,7 +39,7 @@ Not Implemented.
Not Implemented.
@end deftypefun
@subsubsection Open/Close
@section Open/Close
The mailer is spawn, if it is a program, or the host is contacted.
@deftypefun int mailer_open (mailer_t @var{mailer}, int @var{flag})
......@@ -48,15 +50,15 @@ Not Implemented.
Not Implemented.
@end deftypefun
@subsubsection Sending
@section Sending
Sending a message.
@deftypefun int mailer_create_envelope (mailer_t @var{mailer}, size_t *)
@deftypefun int mailer_new_message (mailer_t @var{mailer}, size_t *)
Not Implemented.
@end deftypefun
@deftypefun int mailer_set_body (mailer_t @var{mailer}, char *, size_t)
@deftypefun int mailer_set_content (mailer_t @var{mailer}, char *, size_t)
Not Implemented.
@end deftypefun
......@@ -67,11 +69,11 @@ Not Implemented.
@deftypefun int mailbox_add_attachment (mailer_t, size_t msgno, const char *boundary, const char *header, FILE *file, int encoding)
@end deftypefun
@deftypefun int mailer_send_envelope (mailer_t @var{mailer}, size_t)
@deftypefun int mailer_send_message (mailer_t @var{mailer}, size_t)
Not Implemented.
@end deftypefun
@subsubsection Timeout
@section Timeout
@deftypefun int mailer_set_timeout (mailer_t @var{mailer}, size_t)
Not Implemented.
@end deftypefun
......@@ -80,42 +82,26 @@ Not Implemented.
Not Implemented.
@end deftypefun
@subsection Mailto
@cindex Mailto
The URL mailto: should be supported.
TODO: example of mailto, and mailing lists,
@subsection SMTP
@section SMTP
@cindex SMTP
TODO: todo
@subsection UUCP
@section UUCP
@cindex UUCP
Yeurk ! It this to old ? Is it worth it ?
@subsection Sendmail
@section Program
@cindex Sendmail
This is not a protocol, but someone may use it as the mailer, and
we provide the magic.
@subsection mailx
@cindex mailx
This is not a protocol, but someone may use it as the mailer, and
we provide the magic.
@subsection mail
@cindex mail
This is not a protocol, but someone may use it as the mailer, and
we provide the magic.
This is not a protocol, but on must site the delivery of mail is done via
a program, @command{/usr/lib/sendmail}, @command{/bin/mailx},
@command{/bin/mail}, @dots{}
@subsection MPP
@section MPP
@cindex MPP
Mail Posting Protocol.
Mail Posting Protocol. Not Implemented.
......
......@@ -100,18 +100,19 @@ by the Foundation.
This document was produced for version @value{VERSION} of @sc{gnu}
@sc{mailutils}.
@end ifinfo
@menu
* Introduction:: GNU @sc{Mailutils} Programmer's manual.
* Introduction:: GNU @sc{mailutils}
* Mailbox:: Mailbox API.
* Mailer:: Protocol Use to Send Mail.
* URL:: Unified Ressource Locator.
* Message:: Message API.
* Body:: Body API.
* Headers:: Headers API.
* Mime:: Mime API.
* Encoding:: Encoding API.
* Reporting Bugs:: Reporting Bugs.
* Acknowledgement:: Thanks and Credits.
* Concept Index:: Topics in this Manual.
* Concept Index ::
* Index:: All @sc{Mailutils} Functions.
@end menu
......@@ -122,8 +123,37 @@ This document was produced for version @value{VERSION} of @sc{gnu}
@sc{gnu} @sc{Mailutils} offers a general purpose library aimed to provide
a rich set of functions for accessing different mailbox formats and mailers.
For example writing a simple from command that will list @var{From} and
@var{Subject} of a folder.
@example
@group
USER Client
-------------------
| |
+-------------+ +-------------+
| |
/-----------\ /-----------\
| mailbox_t | | mailer_t |
\-----------/ \-----------/
| |
+--------------------+------------------+
|
/------------------\
| message_t |
\------------------/
| body_t | header_t|
+------------------+
|
+--------------------+----------------+
| |
------- ////////////////
(_______) // LAN //
(_______) ////////////////
(_______)
@end group
@end example
For example writing a simple @command{from} command that will list @emph{From}
and @emph{Subject} of a folder.
@example
@include sfrom.c.texi
......@@ -136,21 +166,35 @@ For example writing a simple from command that will list @var{From} and
@include mailbox.texi
@node Mailer, URL , Mailbox, Top
@node Mailer, URL, Mailbox, Top
@comment node-name, next, previous, up
@chapter Mailer
@cindex Mailer
@include mailer.texi
@node URL, Headers , Mailer, Top
@node URL, Message, Mailer, Top
@comment node-name, next, previous, up
@chapter URL
@cindex URL
@include url.texi
@node Headers, Mime, URL , Top
@node Message, Body, URL, Top
@comment node-name, next, previous, up
@chapter Message
@cindex Message
@include message.texi
@node Body, Headers, Message, Top
@comment node-name, next, previous, up
@chapter Body
@cindex Body
@include body.texi
@node Headers, Mime , Body, Top
@comment node-name, next, previous, up
@chapter Headers
@cindex Headers
......@@ -159,12 +203,12 @@ For example writing a simple from command that will list @var{From} and
@node Mime , Encoding, Headers, Top
@comment node-name, next, previous, up
@subsection Mime
@chapter Mime
@cindex Mime
@include mime.texi
@node Encoding, Reporting Bugs, Mime, Top
@node Encoding, Reporting Bugs, Mime , Top
@comment node-name, next, previous, up
@chapter Encoding
@cindex Encoding
......@@ -179,14 +223,16 @@ For example writing a simple from command that will list @var{From} and
Email bug reports to @email{bug-mailutils@@gnu.org}.
Be sure to include the word ``mailutils'' somewhere in the ``Subject:'' field.
@node Acknowledgement, Concept Index, Reporting Bugs, Top
@node Acknowledgement, Concept Index , Reporting Bugs, Top
@comment node-name, next, previous, up
@chapter Acknowledgement
@cindex Acknowledgement
In no particular order,
Jakob Kaivo @email{jkaivo@@ndn.net},
Jeff Bailey @email{jbailey@@gnu.org},
Sean Perry @email{shaleh@@debian.org},
Thomas Fletcher @email{thomasf@@qnx.com}.
@page
@node Concept Index , Index, Acknowledgement, Top
......@@ -198,7 +244,7 @@ This is a general index of all issues discussed in this manual
@printindex cp
@page
@node Index, , Concept Index, Top
@node Index, , Concept Index , Top
@unnumbered Index
This is an alphabetical list of all @sc{mailutils} functions.
......
The @code{message_t} is a convenient way to manipulate messages. It
encapsulates the @code{header_t} attribute and the @code{body_t}.
This type, unless you ask explicitly with @code{message_clone}, only contains
references on how to retrieve the information from the mailbox.
@example
@group
+------------------+
| message_t |
+------------------+
| header_t | +----------------+
| body_t[] *-----|------------+| body_t |----* .....
| type | +----------------+
| body_count | | header_t |
+------------------+ | content |
| type |
| next body *---|----//--
+----------------+
@end group
@end example
@section Init/Destroy
The common way to obtain a @code{message_t} is by requesting
@code{mailbox_get_message}, or @code{mailbox_create_message} from
a specific type of mailbox, they are not explicitely created.
@example
#include <mailutils.h>
mailbox_t mbx;
message_t msg, clone;
mailbox_init_default (&mbx, NULL);
mailbox_open (mbx, MU_MB_RDONLY);
@dots{}
mailbox_get_message (mbx, msg_no, &msg);
/* before closing I need to make sure
that I have a copy not a reference of the message */
message_clone (msg, &clone);
/* safe to close/expunge, I got a copy */
mailbox_close (mbx);
/* ... */
message_size (clone, &size);
@end example
@deftypefun void message_destroy (message_t *@var{msg})
The ressources allocate for clone @var{msg} are freed.
@end deftypefun
@deftypefun int message_get_header (message_t @var{msg}, header_t *@var{hdr})
@end deftypefun
The @code{message_t} provides some methosd to retrieve some well know headers.
@deftypefun int message_get_from (message_t @var{msg}, char *buffer, size_t len, size_t *n)
@end deftypefun
@deftypefun int message_get_to (message_t @var{msg}, char *buffer, size_t len, size_t *n)
@end deftypefun
@deftypefun int message_get_date (message_t @var{msg}, char *buffer, size_t len, size_t *n)
@end deftypefun
@deftypefun int message_get_cc (message_t @var{msg}, char *buffer, size_t len, size_t *n)
@end deftypefun
......@@ -3,11 +3,6 @@
#include <unistd.h>
#include <string.h>
#include <mailutils.h>
#include <paths.h>
#ifndef _PATH_MAILDIR
#define _PATH_MAILDIR "/usr/spool/mail"
#endif
int main (int argc, char **argv)
@{
......@@ -19,32 +14,13 @@ int main (int argc, char **argv)
int status
size_t msgno, msg_total, size;
if (argc == 2)
@{
mail = argv[1];
@}
else
@{
mail = getenv ("MAIL");
if (mail == NULL)
@{
char * user = getlogin ();
size_t len = strlen (_PATH_MAILDIR)
+ 1 /* for slash */ + strlen (user) + 1 /* null */;
mail = malloc (len);
if (mail == NULL)
@{
fprintf (stderr, "malloc failed\n");
exit (EXIT_FAILURE);
@}
snprintf (mail, len, "%s/%s", _PATH_MAILDIR, user);
@}
@}
mail = (argc == 2) ? argv[1] : getenv ("MAIL");
status = mailbox_init (&mbox, mail, 0);
status = mailbox_init_default (&mbox, mail);
if (status != 0)
@{
fprintf (stderr, "mailbox_init(%s) failed\n", mail);
fprintf (stderr, "mailbox_init(%s) failed\n",
mail ? mail : "Default");
exit (EXIT_FAILURE);
@}
......@@ -65,7 +41,8 @@ int main (int argc, char **argv)
fprintf (stderr, "header corrupted\n");
exit (EXIT_FAILURE);
@}
header_gvalue (buffer, size, MU_HDR_FROM, from, sizeof (from), NULL);
header_gvalue (buffer, size, MU_HDR_FROM, from,
sizeof (from), NULL);
header_gvalue (buffer, size, MU_HDR_SUBJECT, subject,
sizeof (subject), NULL);
printf ("%s %s\n", from, subject);
......
@comment See rfc2368, rfc2369, rfc2384
Instead of providing different functions to create a mailbox_t and mailer_t the
information is encoded in the form of a URL.
@itemize @bullet
@item
POP3 Post Office Protocol, Not Implemented.
@item
IMAP, not implemented
@item
QMAIL, not implemented
@item
Unix mbox
@item
MMDF, not implemented
@item
SMail, not implemented
@end itemize
The URL will contain the necessary information to initialize @code{mailbox_t}
A mailbox and mailer can be describe in a URL, the string will contain the
necessary information to initialize @code{mailbox_t}, or @code{mailer_t}
properly.
@subsection POP3
pop://<user>;AUTH=<auth>@@<hostname>:<port>
Description of the fields and examples are needed.
@section POP3
The POP URL scheme contains a pop server, optionnal port number
and the authentication mechanism. The genereal form is
@example
@url{pop://user;AUTH=type@@hostname:port}
@url{pop://obelix;AUTH=+APOP@@village.gaulois.org:2000}
@end example
If @emph{:port} is omitted the default value is 110. Different form of
authentication can be specified with @emph{;AUTH=type}.
The special string @emph{;AUTH=*} indicates that the client will use
a default scheme base on the capability of the server.
@example
@url{pop://obelix@@gaulois.org}
@url{pop://asterix;AUTH=*@@france.com}
@url{pop://falbala;AUTH=+APOP@@france.com}
@end example
For more complete information see @cite{rfc2368}.
@subsection IMAP
@section IMAP
imap://.....
Description of the fields and examples are needed.
@subsection File
file://path
@section File
Description of the fields and examples are needed.
Local folder should be handle by this URL. It is preferable to let
the mailbox recognise the type of mailbox and take the appropriate
action.
@subsection MMDF
mmdf://path
@example
@url{file://path}
@url{file://var/mail/user}
@url{file://home/obelix/Mail}
@end example
Description of the fields and examples are needed.
For MMDF, MH local mailboxes urls are provided, but it is preferable to
use @url{file://path} and let the library figure out which one.
@subsection MH
mh://path
@example
@url{mmdf://path}
@url{mh://path}
@end example
Description of the fields and examples are needed.
@section Mailto
@subsection Mailto
mailto://
After setting a mailer, @url{mailto:} is use to tell the mailer where
and to whom the message is for.
@example
@url{mailto://hostname}
@end example
Description of the fields and examples are needed.
Mailto can be use to generate short messages for example to subscribe
to mailing lists.
@example
@url{mailto://bug-mailutils@@gnu.org?body=subscribe}
@url{mailto://bug-mailutils@@gnu.org?Subject=hello&body=subscribe}
@end example
@subsection mmp
mmp://
For more complete information see @cite{rfc2368}.
Description of the fields and examples are needed.
@section URL funtions
Helper functions are provided to retreive and set the @emph{URL} fields.
@deftypefun int url_init (url_t *@var{url}, const char *name)
Initialize and parse the @var{url}
@end deftypefun
@deftypefun void url_destroy (url_t *)
@end deftypefun
@deftp {Data type} struct url_type
@example
@{
char *scheme;
size_t len;
char *description;
int id;
int (*_init) (url_t *, const char * name);
void (*_destroy) (url_t *);
@};
@end example
@end deftp
@section Helper functions
@deftypefun int url_list_type (struct url_type @var{list}[], size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_list_mtype (struct url_type **@var{mlist}, size_t *@var{n})
@end deftypefun
@deftypefun int url_add_type (struct url_type *@var{utype})
@end deftypefun
@deftypefun int url_remove_type (const struct url_type *@var{utype})
@end deftypefun
@deftypefun int url_get_id (const url_t @var{url}, int *@var{id})
@end deftypefun
@deftypefun int url_get_scheme (const url_t @var{url}, char *@var{schem}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mscheme (const url_t @var{url}, char **@var{scheme}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_user (const url_t @var{url}, char *@var{usr}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_muser (const url_t @var{url}, char **@var{buf}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_passwd (const url_t @var{url}, char *@var{passwd}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mpasswd (const url_t @var{url}, char **@var{buf}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_host (const url_t @var{url}, char *@var{host}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mhost (const url_t @var{url}, char **@var{buf}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_port (const url_t @var{url}, long *@var{port})
@end deftypefun
@deftypefun int url_get_path (const url_t @var{url}, char *@var{path}, size_t @var{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mpath (const url_t @var{url}, char **@var{buffer}, size_t *@var{len})
@end deftypefun
@deftypefun int url_get_query (const url_t @var{url}, char *@var{query}, size_t{len}, size_t *@var{n})
@end deftypefun
@deftypefun int url_get_mquery (const url_t @var{url}, char **@var{buf}, size_t *@var{len})
@end deftypefun
......