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
Showing
9 changed files
with
308 additions
and
128 deletions
doc/body.texi
0 → 100644
1 | The @code{body_t} type contains a @code{header_t}, a content and | ||
2 | optionnaly another @code{body_t} part. | ||
3 | |||
4 | @section Init/Destroy | ||
5 | |||
6 | @deftypefun int body_init (body_t *@var{msg}, const mailbox_t @var{mbx}) | ||
7 | Private. | ||
8 | @end deftypefun | ||
9 | |||
10 | @deftypefun void body_destroy (body_t *@var{msg}) | ||
11 | The ressources allocate for clone @var{msg} are freed. | ||
12 | @end deftypefun | ||
13 | |||
14 | @deftypefun int body_get_header (body_t @var{msg}, header_t *@var{hdr}) | ||
15 | @end deftypefun | ||
16 | |||
17 | @deftypefun int body_get_content (body_t @var{msg}, char *buffer, size_t len, size_t *n) | ||
18 | @end deftypefun | ||
19 | |||
20 | @deftypefun int body_get_type (body_t @var{msg}, char *buffer, size_t len, size_t *n) | ||
21 | @end deftypefun | ||
22 |
1 | So far we plan support for RFC822 and plan for RFC1522. with RFC1522 non ASCII | 1 | So far we plan support for RFC822 and plan for RFC1522. with RFC1522 non ASCII |
2 | characters will be encoded. | 2 | characters will be encoded. |
3 | 3 | ||
4 | @subsubsection Init/Destroy | 4 | @section Init/Destroy |
5 | The header should be initiliaze before any use. | 5 | The header should be initiliaze before any use. |
6 | 6 | ||
7 | @deftypefun int header_init (header_t *@var{hdr}, const char *@var{blurb}, size_t @var{len}, int @var{flag}) | 7 | @deftypefun int header_init (header_t *@var{hdr}, const char *@var{blurb}, size_t @var{len}, int @var{flag}) |
8 | Initialize a @var{hdr} to a supported type. If @var{blurb} is not NULL, it is | 8 | Initialize a @var{hdr} to a supported type. If @var{blurb} is not NULL, it is |
9 | parsed. @var{Flag} can be set to RFC8222 or RFC1522 so far onlyr rfc822 is | 9 | parsed. @var{Flag} can be set to RFC8222 or RFC1522 so far onlyr rfc822 is |
10 | supported. | 10 | supported. |
11 | @end deftypefun | ||
12 | 11 | ||
13 | @defmac MU_HDR_RFC822 | 12 | @defmac MU_HDR_RFC822 |
14 | Supports rfc 822, header style. | 13 | Supports rfc 822, header style. |
... | @@ -18,15 +17,16 @@ Supports rfc 822, header style. | ... | @@ -18,15 +17,16 @@ Supports rfc 822, header style. |
18 | Supports rfc 1522, encoding policy. | 17 | Supports rfc 1522, encoding policy. |
19 | @end defmac | 18 | @end defmac |
20 | 19 | ||
20 | @end deftypefun | ||
21 | |||
21 | @deftypefun void header_destroy (header_t *@var{hdr}) | 22 | @deftypefun void header_destroy (header_t *@var{hdr}) |
22 | The ressources allocate for @var{hdr} or freed. | 23 | The ressources allocate for @var{hdr} are freed. |
23 | @end deftypefun | 24 | @end deftypefun |
24 | 25 | ||
25 | @deftypefun int header_set_value (header_t @var{hdr}, const char *@var{fn}, const char *@var{fv}, size_t n, int @var{replace}) | 26 | @deftypefun int header_set_value (header_t @var{hdr}, const char *@var{fn}, const char *@var{fv}, size_t n, int @var{replace}) |
26 | Set the field-name @var{fn} to field-value @var{fv} of size @var{n} in | 27 | Set the field-name @var{fn} to field-value @var{fv} of size @var{n} in |
27 | @var{hdr}. If @var{replace} is non-zero the initial value is replace, if zero | 28 | @var{hdr}. If @var{replace} is non-zero the initial value is replace, if zero |
28 | it is append. | 29 | it is append. |
29 | @end deftypefun | ||
30 | 30 | ||
31 | Some basic macros is already provided for rfc822. | 31 | Some basic macros is already provided for rfc822. |
32 | 32 | ||
... | @@ -109,6 +109,8 @@ Some basic macros is already provided for rfc822. | ... | @@ -109,6 +109,8 @@ Some basic macros is already provided for rfc822. |
109 | "MIME-Version" | 109 | "MIME-Version" |
110 | @end defmac | 110 | @end defmac |
111 | 111 | ||
112 | @end deftypefun | ||
113 | |||
112 | @deftypefun int header_get_value (header_t @var{hdr}, const char *fn, char *fv, size_t len, size_t *n) | 114 | @deftypefun int header_get_value (header_t @var{hdr}, const char *fn, char *fv, size_t len, size_t *n) |
113 | Value of field-name @var{fn} is return in buffer @var{fv} of size @var{len}. | 115 | Value of field-name @var{fn} is return in buffer @var{fv} of size @var{len}. |
114 | The number of bytes written is put in @var{n}. | 116 | 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 | ... | @@ -131,15 +133,7 @@ Field-name @var{fn} is extract form @var{blurb} of size @var{bl} and put in |
131 | @var{n}. | 133 | @var{n}. |
132 | @end deftypefun | 134 | @end deftypefun |
133 | 135 | ||
134 | @subsection Headers Macros | 136 | @section Headers Regex |
135 | @cindex Headers Macros | ||
136 | |||
137 | @subsection Headers Parsed | ||
138 | @cindex Headers Parsed | ||
139 | |||
140 | Return a hash table, a dictionnary, ??? | ||
141 | |||
142 | @subsection Headers Regex | ||
143 | @cindex Headers Regex | 137 | @cindex Headers Regex |
144 | 138 | ||
145 | Using regular expression ? | 139 | Using regular expression ? | ... | ... |
This diff is collapsed.
Click to expand it.
1 | 1 | ||
2 | Mail Delivery is done here. Nothing is implemented and the API is still shaky. | 2 | Mail Delivery is done here. Nothing is implemented and the API is still shaky. |
3 | 3 | ||
4 | @subsubsection Init/Destroy | 4 | @section Init/Destroy |
5 | 5 | ||
6 | Initialize the mailer object. | 6 | Initialize the mailer object. |
7 | 7 | ||
8 | @deftypefun int mailer_init (mailer_t *@var{mailer}, const char *@var{name}, int @var{flag}) | 8 | @deftypefun int mailer_init (mailer_t *@var{mailer}, const char *@var{name}, int @var{flag}) |
9 | Not Implemented. | 9 | Not Implemented. |
10 | @end deftypefun | ||
11 | 10 | ||
12 | @defmac MU_ML_PROGRAM | 11 | @defmac MU_ML_PROGRAM |
13 | Program like sendmail, mail, mailx to deliver the mail | 12 | Program like sendmail, mail, mailx to deliver the mail |
... | @@ -21,11 +20,14 @@ Contact the host directly with SMTP. | ... | @@ -21,11 +20,14 @@ Contact the host directly with SMTP. |
21 | Use MPP protocol. | 20 | Use MPP protocol. |
22 | @end defmac | 21 | @end defmac |
23 | 22 | ||
23 | @end deftypefun | ||
24 | |||
24 | @deftypefun int mailer_destroy (mailer_r *@var{mailer}) | 25 | @deftypefun int mailer_destroy (mailer_r *@var{mailer}) |
25 | Not Implemented. | 26 | Not Implemented. |
26 | @end deftypefun | 27 | @end deftypefun |
27 | 28 | ||
28 | @subsubsection User/Passwd | 29 | |
30 | @section User/Passwd | ||
29 | 31 | ||
30 | On some mailer like MMP you need to identify. | 32 | On some mailer like MMP you need to identify. |
31 | 33 | ||
... | @@ -37,7 +39,7 @@ Not Implemented. | ... | @@ -37,7 +39,7 @@ Not Implemented. |
37 | Not Implemented. | 39 | Not Implemented. |
38 | @end deftypefun | 40 | @end deftypefun |
39 | 41 | ||
40 | @subsubsection Open/Close | 42 | @section Open/Close |
41 | The mailer is spawn, if it is a program, or the host is contacted. | 43 | The mailer is spawn, if it is a program, or the host is contacted. |
42 | 44 | ||
43 | @deftypefun int mailer_open (mailer_t @var{mailer}, int @var{flag}) | 45 | @deftypefun int mailer_open (mailer_t @var{mailer}, int @var{flag}) |
... | @@ -48,15 +50,15 @@ Not Implemented. | ... | @@ -48,15 +50,15 @@ Not Implemented. |
48 | Not Implemented. | 50 | Not Implemented. |
49 | @end deftypefun | 51 | @end deftypefun |
50 | 52 | ||
51 | @subsubsection Sending | 53 | @section Sending |
52 | 54 | ||
53 | Sending a message. | 55 | Sending a message. |
54 | 56 | ||
55 | @deftypefun int mailer_create_envelope (mailer_t @var{mailer}, size_t *) | 57 | @deftypefun int mailer_new_message (mailer_t @var{mailer}, size_t *) |
56 | Not Implemented. | 58 | Not Implemented. |
57 | @end deftypefun | 59 | @end deftypefun |
58 | 60 | ||
59 | @deftypefun int mailer_set_body (mailer_t @var{mailer}, char *, size_t) | 61 | @deftypefun int mailer_set_content (mailer_t @var{mailer}, char *, size_t) |
60 | Not Implemented. | 62 | Not Implemented. |
61 | @end deftypefun | 63 | @end deftypefun |
62 | 64 | ||
... | @@ -67,11 +69,11 @@ Not Implemented. | ... | @@ -67,11 +69,11 @@ Not Implemented. |
67 | @deftypefun int mailbox_add_attachment (mailer_t, size_t msgno, const char *boundary, const char *header, FILE *file, int encoding) | 69 | @deftypefun int mailbox_add_attachment (mailer_t, size_t msgno, const char *boundary, const char *header, FILE *file, int encoding) |
68 | @end deftypefun | 70 | @end deftypefun |
69 | 71 | ||
70 | @deftypefun int mailer_send_envelope (mailer_t @var{mailer}, size_t) | 72 | @deftypefun int mailer_send_message (mailer_t @var{mailer}, size_t) |
71 | Not Implemented. | 73 | Not Implemented. |
72 | @end deftypefun | 74 | @end deftypefun |
73 | 75 | ||
74 | @subsubsection Timeout | 76 | @section Timeout |
75 | @deftypefun int mailer_set_timeout (mailer_t @var{mailer}, size_t) | 77 | @deftypefun int mailer_set_timeout (mailer_t @var{mailer}, size_t) |
76 | Not Implemented. | 78 | Not Implemented. |
77 | @end deftypefun | 79 | @end deftypefun |
... | @@ -80,42 +82,26 @@ Not Implemented. | ... | @@ -80,42 +82,26 @@ Not Implemented. |
80 | Not Implemented. | 82 | Not Implemented. |
81 | @end deftypefun | 83 | @end deftypefun |
82 | 84 | ||
83 | 85 | @section SMTP | |
84 | @subsection Mailto | ||
85 | @cindex Mailto | ||
86 | The URL mailto: should be supported. | ||
87 | |||
88 | TODO: example of mailto, and mailing lists, | ||
89 | |||
90 | @subsection SMTP | ||
91 | @cindex SMTP | 86 | @cindex SMTP |
92 | 87 | ||
93 | TODO: todo | 88 | TODO: todo |
94 | 89 | ||
95 | @subsection UUCP | 90 | @section UUCP |
96 | @cindex UUCP | 91 | @cindex UUCP |
97 | 92 | ||
98 | Yeurk ! It this to old ? Is it worth it ? | 93 | Yeurk ! It this to old ? Is it worth it ? |
99 | 94 | ||
100 | @subsection Sendmail | 95 | @section Program |
101 | @cindex Sendmail | 96 | @cindex Sendmail |
102 | |||
103 | This is not a protocol, but someone may use it as the mailer, and | ||
104 | we provide the magic. | ||
105 | |||
106 | @subsection mailx | ||
107 | @cindex mailx | 97 | @cindex mailx |
108 | |||
109 | This is not a protocol, but someone may use it as the mailer, and | ||
110 | we provide the magic. | ||
111 | |||
112 | @subsection mail | ||
113 | @cindex mail | 98 | @cindex mail |
114 | 99 | ||
115 | This is not a protocol, but someone may use it as the mailer, and | 100 | This is not a protocol, but on must site the delivery of mail is done via |
116 | we provide the magic. | 101 | a program, @command{/usr/lib/sendmail}, @command{/bin/mailx}, |
102 | @command{/bin/mail}, @dots{} | ||
117 | 103 | ||
118 | @subsection MPP | 104 | @section MPP |
119 | @cindex MPP | 105 | @cindex MPP |
120 | 106 | ||
121 | Mail Posting Protocol. | 107 | Mail Posting Protocol. Not Implemented. | ... | ... |
... | @@ -100,18 +100,19 @@ by the Foundation. | ... | @@ -100,18 +100,19 @@ by the Foundation. |
100 | This document was produced for version @value{VERSION} of @sc{gnu} | 100 | This document was produced for version @value{VERSION} of @sc{gnu} |
101 | @sc{mailutils}. | 101 | @sc{mailutils}. |
102 | @end ifinfo | 102 | @end ifinfo |
103 | |||
104 | @menu | 103 | @menu |
105 | * Introduction:: GNU @sc{Mailutils} Programmer's manual. | 104 | * Introduction:: GNU @sc{mailutils} |
106 | * Mailbox:: Mailbox API. | 105 | * Mailbox:: Mailbox API. |
107 | * Mailer:: Protocol Use to Send Mail. | 106 | * Mailer:: Protocol Use to Send Mail. |
108 | * URL:: Unified Ressource Locator. | 107 | * URL:: Unified Ressource Locator. |
108 | * Message:: Message API. | ||
109 | * Body:: Body API. | ||
109 | * Headers:: Headers API. | 110 | * Headers:: Headers API. |
110 | * Mime:: Mime API. | 111 | * Mime:: Mime API. |
111 | * Encoding:: Encoding API. | 112 | * Encoding:: Encoding API. |
112 | * Reporting Bugs:: Reporting Bugs. | 113 | * Reporting Bugs:: Reporting Bugs. |
113 | * Acknowledgement:: Thanks and Credits. | 114 | * Acknowledgement:: Thanks and Credits. |
114 | * Concept Index:: Topics in this Manual. | 115 | * Concept Index :: |
115 | * Index:: All @sc{Mailutils} Functions. | 116 | * Index:: All @sc{Mailutils} Functions. |
116 | @end menu | 117 | @end menu |
117 | 118 | ||
... | @@ -122,8 +123,37 @@ This document was produced for version @value{VERSION} of @sc{gnu} | ... | @@ -122,8 +123,37 @@ This document was produced for version @value{VERSION} of @sc{gnu} |
122 | 123 | ||
123 | @sc{gnu} @sc{Mailutils} offers a general purpose library aimed to provide | 124 | @sc{gnu} @sc{Mailutils} offers a general purpose library aimed to provide |
124 | a rich set of functions for accessing different mailbox formats and mailers. | 125 | a rich set of functions for accessing different mailbox formats and mailers. |
125 | For example writing a simple from command that will list @var{From} and | 126 | |
126 | @var{Subject} of a folder. | 127 | @example |
128 | @group | ||
129 | USER Client | ||
130 | ------------------- | ||
131 | | | | ||
132 | +-------------+ +-------------+ | ||
133 | | | | ||
134 | /-----------\ /-----------\ | ||
135 | | mailbox_t | | mailer_t | | ||
136 | \-----------/ \-----------/ | ||
137 | | | | ||
138 | +--------------------+------------------+ | ||
139 | | | ||
140 | /------------------\ | ||
141 | | message_t | | ||
142 | \------------------/ | ||
143 | | body_t | header_t| | ||
144 | +------------------+ | ||
145 | | | ||
146 | +--------------------+----------------+ | ||
147 | | | | ||
148 | ------- //////////////// | ||
149 | (_______) // LAN // | ||
150 | (_______) //////////////// | ||
151 | (_______) | ||
152 | @end group | ||
153 | @end example | ||
154 | |||
155 | For example writing a simple @command{from} command that will list @emph{From} | ||
156 | and @emph{Subject} of a folder. | ||
127 | 157 | ||
128 | @example | 158 | @example |
129 | @include sfrom.c.texi | 159 | @include sfrom.c.texi |
... | @@ -136,21 +166,35 @@ For example writing a simple from command that will list @var{From} and | ... | @@ -136,21 +166,35 @@ For example writing a simple from command that will list @var{From} and |
136 | 166 | ||
137 | @include mailbox.texi | 167 | @include mailbox.texi |
138 | 168 | ||
139 | @node Mailer, URL , Mailbox, Top | 169 | @node Mailer, URL, Mailbox, Top |
140 | @comment node-name, next, previous, up | 170 | @comment node-name, next, previous, up |
141 | @chapter Mailer | 171 | @chapter Mailer |
142 | @cindex Mailer | 172 | @cindex Mailer |
143 | 173 | ||
144 | @include mailer.texi | 174 | @include mailer.texi |
145 | 175 | ||
146 | @node URL, Headers , Mailer, Top | 176 | @node URL, Message, Mailer, Top |
147 | @comment node-name, next, previous, up | 177 | @comment node-name, next, previous, up |
148 | @chapter URL | 178 | @chapter URL |
149 | @cindex URL | 179 | @cindex URL |
150 | 180 | ||
151 | @include url.texi | 181 | @include url.texi |
152 | 182 | ||
153 | @node Headers, Mime, URL , Top | 183 | @node Message, Body, URL, Top |
184 | @comment node-name, next, previous, up | ||
185 | @chapter Message | ||
186 | @cindex Message | ||
187 | |||
188 | @include message.texi | ||
189 | |||
190 | @node Body, Headers, Message, Top | ||
191 | @comment node-name, next, previous, up | ||
192 | @chapter Body | ||
193 | @cindex Body | ||
194 | |||
195 | @include body.texi | ||
196 | |||
197 | @node Headers, Mime , Body, Top | ||
154 | @comment node-name, next, previous, up | 198 | @comment node-name, next, previous, up |
155 | @chapter Headers | 199 | @chapter Headers |
156 | @cindex Headers | 200 | @cindex Headers |
... | @@ -159,12 +203,12 @@ For example writing a simple from command that will list @var{From} and | ... | @@ -159,12 +203,12 @@ For example writing a simple from command that will list @var{From} and |
159 | 203 | ||
160 | @node Mime , Encoding, Headers, Top | 204 | @node Mime , Encoding, Headers, Top |
161 | @comment node-name, next, previous, up | 205 | @comment node-name, next, previous, up |
162 | @subsection Mime | 206 | @chapter Mime |
163 | @cindex Mime | 207 | @cindex Mime |
164 | 208 | ||
165 | @include mime.texi | 209 | @include mime.texi |
166 | 210 | ||
167 | @node Encoding, Reporting Bugs, Mime, Top | 211 | @node Encoding, Reporting Bugs, Mime , Top |
168 | @comment node-name, next, previous, up | 212 | @comment node-name, next, previous, up |
169 | @chapter Encoding | 213 | @chapter Encoding |
170 | @cindex Encoding | 214 | @cindex Encoding |
... | @@ -179,14 +223,16 @@ For example writing a simple from command that will list @var{From} and | ... | @@ -179,14 +223,16 @@ For example writing a simple from command that will list @var{From} and |
179 | Email bug reports to @email{bug-mailutils@@gnu.org}. | 223 | Email bug reports to @email{bug-mailutils@@gnu.org}. |
180 | Be sure to include the word ``mailutils'' somewhere in the ``Subject:'' field. | 224 | Be sure to include the word ``mailutils'' somewhere in the ``Subject:'' field. |
181 | 225 | ||
182 | @node Acknowledgement, Concept Index, Reporting Bugs, Top | 226 | @node Acknowledgement, Concept Index , Reporting Bugs, Top |
183 | @comment node-name, next, previous, up | 227 | @comment node-name, next, previous, up |
184 | @chapter Acknowledgement | 228 | @chapter Acknowledgement |
185 | @cindex Acknowledgement | 229 | @cindex Acknowledgement |
186 | 230 | ||
231 | In no particular order, | ||
187 | Jakob Kaivo @email{jkaivo@@ndn.net}, | 232 | Jakob Kaivo @email{jkaivo@@ndn.net}, |
188 | Jeff Bailey @email{jbailey@@gnu.org}, | 233 | Jeff Bailey @email{jbailey@@gnu.org}, |
189 | Sean Perry @email{shaleh@@debian.org}, | 234 | Sean Perry @email{shaleh@@debian.org}, |
235 | Thomas Fletcher @email{thomasf@@qnx.com}. | ||
190 | 236 | ||
191 | @page | 237 | @page |
192 | @node Concept Index , Index, Acknowledgement, Top | 238 | @node Concept Index , Index, Acknowledgement, Top |
... | @@ -198,7 +244,7 @@ This is a general index of all issues discussed in this manual | ... | @@ -198,7 +244,7 @@ This is a general index of all issues discussed in this manual |
198 | @printindex cp | 244 | @printindex cp |
199 | @page | 245 | @page |
200 | 246 | ||
201 | @node Index, , Concept Index, Top | 247 | @node Index, , Concept Index , Top |
202 | @unnumbered Index | 248 | @unnumbered Index |
203 | 249 | ||
204 | This is an alphabetical list of all @sc{mailutils} functions. | 250 | This is an alphabetical list of all @sc{mailutils} functions. | ... | ... |
doc/message.texi
0 → 100644
1 | The @code{message_t} is a convenient way to manipulate messages. It | ||
2 | encapsulates the @code{header_t} attribute and the @code{body_t}. | ||
3 | This type, unless you ask explicitly with @code{message_clone}, only contains | ||
4 | references on how to retrieve the information from the mailbox. | ||
5 | |||
6 | @example | ||
7 | @group | ||
8 | +------------------+ | ||
9 | | message_t | | ||
10 | +------------------+ | ||
11 | | header_t | +----------------+ | ||
12 | | body_t[] *-----|------------+| body_t |----* ..... | ||
13 | | type | +----------------+ | ||
14 | | body_count | | header_t | | ||
15 | +------------------+ | content | | ||
16 | | type | | ||
17 | | next body *---|----//-- | ||
18 | +----------------+ | ||
19 | @end group | ||
20 | @end example | ||
21 | |||
22 | @section Init/Destroy | ||
23 | The common way to obtain a @code{message_t} is by requesting | ||
24 | @code{mailbox_get_message}, or @code{mailbox_create_message} from | ||
25 | a specific type of mailbox, they are not explicitely created. | ||
26 | |||
27 | @example | ||
28 | #include <mailutils.h> | ||
29 | |||
30 | mailbox_t mbx; | ||
31 | message_t msg, clone; | ||
32 | mailbox_init_default (&mbx, NULL); | ||
33 | mailbox_open (mbx, MU_MB_RDONLY); | ||
34 | @dots{} | ||
35 | mailbox_get_message (mbx, msg_no, &msg); | ||
36 | /* before closing I need to make sure | ||
37 | that I have a copy not a reference of the message */ | ||
38 | message_clone (msg, &clone); | ||
39 | /* safe to close/expunge, I got a copy */ | ||
40 | mailbox_close (mbx); | ||
41 | /* ... */ | ||
42 | message_size (clone, &size); | ||
43 | @end example | ||
44 | |||
45 | @deftypefun void message_destroy (message_t *@var{msg}) | ||
46 | The ressources allocate for clone @var{msg} are freed. | ||
47 | @end deftypefun | ||
48 | |||
49 | @deftypefun int message_get_header (message_t @var{msg}, header_t *@var{hdr}) | ||
50 | @end deftypefun | ||
51 | |||
52 | The @code{message_t} provides some methosd to retrieve some well know headers. | ||
53 | @deftypefun int message_get_from (message_t @var{msg}, char *buffer, size_t len, size_t *n) | ||
54 | @end deftypefun | ||
55 | |||
56 | @deftypefun int message_get_to (message_t @var{msg}, char *buffer, size_t len, size_t *n) | ||
57 | @end deftypefun | ||
58 | |||
59 | @deftypefun int message_get_date (message_t @var{msg}, char *buffer, size_t len, size_t *n) | ||
60 | @end deftypefun | ||
61 | |||
62 | @deftypefun int message_get_cc (message_t @var{msg}, char *buffer, size_t len, size_t *n) | ||
63 | @end deftypefun |
... | @@ -3,11 +3,6 @@ | ... | @@ -3,11 +3,6 @@ |
3 | #include <unistd.h> | 3 | #include <unistd.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <mailutils.h> | 5 | #include <mailutils.h> |
6 | #include <paths.h> | ||
7 | |||
8 | #ifndef _PATH_MAILDIR | ||
9 | #define _PATH_MAILDIR "/usr/spool/mail" | ||
10 | #endif | ||
11 | 6 | ||
12 | int main (int argc, char **argv) | 7 | int main (int argc, char **argv) |
13 | @{ | 8 | @{ |
... | @@ -19,32 +14,13 @@ int main (int argc, char **argv) | ... | @@ -19,32 +14,13 @@ int main (int argc, char **argv) |
19 | int status | 14 | int status |
20 | size_t msgno, msg_total, size; | 15 | size_t msgno, msg_total, size; |
21 | 16 | ||
22 | if (argc == 2) | 17 | mail = (argc == 2) ? argv[1] : getenv ("MAIL"); |
23 | @{ | ||
24 | mail = argv[1]; | ||
25 | @} | ||
26 | else | ||
27 | @{ | ||
28 | mail = getenv ("MAIL"); | ||
29 | if (mail == NULL) | ||
30 | @{ | ||
31 | char * user = getlogin (); | ||
32 | size_t len = strlen (_PATH_MAILDIR) | ||
33 | + 1 /* for slash */ + strlen (user) + 1 /* null */; | ||
34 | mail = malloc (len); | ||
35 | if (mail == NULL) | ||
36 | @{ | ||
37 | fprintf (stderr, "malloc failed\n"); | ||
38 | exit (EXIT_FAILURE); | ||
39 | @} | ||
40 | snprintf (mail, len, "%s/%s", _PATH_MAILDIR, user); | ||
41 | @} | ||
42 | @} | ||
43 | 18 | ||
44 | status = mailbox_init (&mbox, mail, 0); | 19 | status = mailbox_init_default (&mbox, mail); |
45 | if (status != 0) | 20 | if (status != 0) |
46 | @{ | 21 | @{ |
47 | fprintf (stderr, "mailbox_init(%s) failed\n", mail); | 22 | fprintf (stderr, "mailbox_init(%s) failed\n", |
23 | mail ? mail : "Default"); | ||
48 | exit (EXIT_FAILURE); | 24 | exit (EXIT_FAILURE); |
49 | @} | 25 | @} |
50 | 26 | ||
... | @@ -65,7 +41,8 @@ int main (int argc, char **argv) | ... | @@ -65,7 +41,8 @@ int main (int argc, char **argv) |
65 | fprintf (stderr, "header corrupted\n"); | 41 | fprintf (stderr, "header corrupted\n"); |
66 | exit (EXIT_FAILURE); | 42 | exit (EXIT_FAILURE); |
67 | @} | 43 | @} |
68 | header_gvalue (buffer, size, MU_HDR_FROM, from, sizeof (from), NULL); | 44 | header_gvalue (buffer, size, MU_HDR_FROM, from, |
45 | sizeof (from), NULL); | ||
69 | header_gvalue (buffer, size, MU_HDR_SUBJECT, subject, | 46 | header_gvalue (buffer, size, MU_HDR_SUBJECT, subject, |
70 | sizeof (subject), NULL); | 47 | sizeof (subject), NULL); |
71 | printf ("%s %s\n", from, subject); | 48 | printf ("%s %s\n", from, subject); | ... | ... |
1 | 1 | ||
2 | @comment See rfc2368, rfc2369, rfc2384 | 2 | @comment See rfc2368, rfc2369, rfc2384 |
3 | Instead of providing different functions to create a mailbox_t and mailer_t the | 3 | A mailbox and mailer can be describe in a URL, the string will contain the |
4 | information is encoded in the form of a URL. | 4 | necessary information to initialize @code{mailbox_t}, or @code{mailer_t} |
5 | |||
6 | @itemize @bullet | ||
7 | @item | ||
8 | POP3 Post Office Protocol, Not Implemented. | ||
9 | @item | ||
10 | IMAP, not implemented | ||
11 | @item | ||
12 | QMAIL, not implemented | ||
13 | @item | ||
14 | Unix mbox | ||
15 | @item | ||
16 | MMDF, not implemented | ||
17 | @item | ||
18 | SMail, not implemented | ||
19 | @end itemize | ||
20 | |||
21 | The URL will contain the necessary information to initialize @code{mailbox_t} | ||
22 | properly. | 5 | properly. |
23 | @subsection POP3 | ||
24 | pop://<user>;AUTH=<auth>@@<hostname>:<port> | ||
25 | 6 | ||
26 | Description of the fields and examples are needed. | 7 | @section POP3 |
8 | The POP URL scheme contains a pop server, optionnal port number | ||
9 | and the authentication mechanism. The genereal form is | ||
10 | |||
11 | @example | ||
12 | @url{pop://user;AUTH=type@@hostname:port} | ||
13 | @url{pop://obelix;AUTH=+APOP@@village.gaulois.org:2000} | ||
14 | @end example | ||
15 | |||
16 | If @emph{:port} is omitted the default value is 110. Different form of | ||
17 | authentication can be specified with @emph{;AUTH=type}. | ||
18 | The special string @emph{;AUTH=*} indicates that the client will use | ||
19 | a default scheme base on the capability of the server. | ||
20 | @example | ||
21 | @url{pop://obelix@@gaulois.org} | ||
22 | @url{pop://asterix;AUTH=*@@france.com} | ||
23 | @url{pop://falbala;AUTH=+APOP@@france.com} | ||
24 | @end example | ||
25 | |||
26 | For more complete information see @cite{rfc2368}. | ||
27 | 27 | ||
28 | @subsection IMAP | 28 | @section IMAP |
29 | imap://..... | 29 | imap://..... |
30 | 30 | ||
31 | Description of the fields and examples are needed. | 31 | Description of the fields and examples are needed. |
32 | 32 | ||
33 | @subsection File | 33 | @section File |
34 | file://path | ||
35 | 34 | ||
36 | Description of the fields and examples are needed. | 35 | Local folder should be handle by this URL. It is preferable to let |
36 | the mailbox recognise the type of mailbox and take the appropriate | ||
37 | action. | ||
37 | 38 | ||
38 | @subsection MMDF | 39 | @example |
39 | mmdf://path | 40 | @url{file://path} |
41 | @url{file://var/mail/user} | ||
42 | @url{file://home/obelix/Mail} | ||
43 | @end example | ||
40 | 44 | ||
41 | Description of the fields and examples are needed. | 45 | For MMDF, MH local mailboxes urls are provided, but it is preferable to |
46 | use @url{file://path} and let the library figure out which one. | ||
42 | 47 | ||
43 | @subsection MH | 48 | @example |
44 | mh://path | 49 | @url{mmdf://path} |
50 | @url{mh://path} | ||
51 | @end example | ||
45 | 52 | ||
46 | Description of the fields and examples are needed. | 53 | @section Mailto |
47 | 54 | ||
48 | @subsection Mailto | 55 | After setting a mailer, @url{mailto:} is use to tell the mailer where |
49 | mailto:// | 56 | and to whom the message is for. |
57 | @example | ||
58 | @url{mailto://hostname} | ||
59 | @end example | ||
50 | 60 | ||
51 | Description of the fields and examples are needed. | 61 | Mailto can be use to generate short messages for example to subscribe |
62 | to mailing lists. | ||
63 | @example | ||
64 | @url{mailto://bug-mailutils@@gnu.org?body=subscribe} | ||
65 | @url{mailto://bug-mailutils@@gnu.org?Subject=hello&body=subscribe} | ||
66 | @end example | ||
52 | 67 | ||
53 | @subsection mmp | 68 | For more complete information see @cite{rfc2368}. |
54 | mmp:// | ||
55 | 69 | ||
56 | Description of the fields and examples are needed. | 70 | @section URL funtions |
71 | |||
72 | Helper functions are provided to retreive and set the @emph{URL} fields. | ||
73 | |||
74 | @deftypefun int url_init (url_t *@var{url}, const char *name) | ||
75 | Initialize and parse the @var{url} | ||
76 | @end deftypefun | ||
77 | |||
78 | @deftypefun void url_destroy (url_t *) | ||
79 | @end deftypefun | ||
80 | |||
81 | @deftp {Data type} struct url_type | ||
82 | @example | ||
83 | @{ | ||
84 | char *scheme; | ||
85 | size_t len; | ||
86 | char *description; | ||
87 | int id; | ||
88 | int (*_init) (url_t *, const char * name); | ||
89 | void (*_destroy) (url_t *); | ||
90 | @}; | ||
91 | @end example | ||
92 | @end deftp | ||
93 | |||
94 | @section Helper functions | ||
95 | |||
96 | @deftypefun int url_list_type (struct url_type @var{list}[], size_t @var{len}, size_t *@var{n}) | ||
97 | @end deftypefun | ||
98 | |||
99 | @deftypefun int url_list_mtype (struct url_type **@var{mlist}, size_t *@var{n}) | ||
100 | @end deftypefun | ||
101 | |||
102 | @deftypefun int url_add_type (struct url_type *@var{utype}) | ||
103 | @end deftypefun | ||
104 | |||
105 | @deftypefun int url_remove_type (const struct url_type *@var{utype}) | ||
106 | @end deftypefun | ||
107 | |||
108 | @deftypefun int url_get_id (const url_t @var{url}, int *@var{id}) | ||
109 | @end deftypefun | ||
110 | |||
111 | @deftypefun int url_get_scheme (const url_t @var{url}, char *@var{schem}, size_t @var{len}, size_t *@var{n}) | ||
112 | @end deftypefun | ||
113 | |||
114 | @deftypefun int url_get_mscheme (const url_t @var{url}, char **@var{scheme}, size_t *@var{n}) | ||
115 | @end deftypefun | ||
116 | |||
117 | @deftypefun int url_get_user (const url_t @var{url}, char *@var{usr}, size_t @var{len}, size_t *@var{n}) | ||
118 | @end deftypefun | ||
119 | |||
120 | @deftypefun int url_get_muser (const url_t @var{url}, char **@var{buf}, size_t *@var{n}) | ||
121 | @end deftypefun | ||
122 | |||
123 | @deftypefun int url_get_passwd (const url_t @var{url}, char *@var{passwd}, size_t @var{len}, size_t *@var{n}) | ||
124 | @end deftypefun | ||
125 | |||
126 | @deftypefun int url_get_mpasswd (const url_t @var{url}, char **@var{buf}, size_t *@var{n}) | ||
127 | @end deftypefun | ||
128 | |||
129 | @deftypefun int url_get_host (const url_t @var{url}, char *@var{host}, size_t @var{len}, size_t *@var{n}) | ||
130 | @end deftypefun | ||
131 | |||
132 | @deftypefun int url_get_mhost (const url_t @var{url}, char **@var{buf}, size_t *@var{n}) | ||
133 | @end deftypefun | ||
134 | |||
135 | @deftypefun int url_get_port (const url_t @var{url}, long *@var{port}) | ||
136 | @end deftypefun | ||
137 | |||
138 | @deftypefun int url_get_path (const url_t @var{url}, char *@var{path}, size_t @var{len}, size_t *@var{n}) | ||
139 | @end deftypefun | ||
140 | |||
141 | @deftypefun int url_get_mpath (const url_t @var{url}, char **@var{buffer}, size_t *@var{len}) | ||
142 | @end deftypefun | ||
143 | |||
144 | @deftypefun int url_get_query (const url_t @var{url}, char *@var{query}, size_t{len}, size_t *@var{n}) | ||
145 | @end deftypefun | ||
146 | |||
147 | @deftypefun int url_get_mquery (const url_t @var{url}, char **@var{buf}, size_t *@var{len}) | ||
148 | @end deftypefun | ||
57 | 149 | ... | ... |
-
Please register or sign in to post a comment