Modified Files:
body.texi headers.texi mailbox.texi mailer.texi mailutils.texi message.texi sfrom.c.texi url.texi updating.
Showing
8 changed files
with
253 additions
and
109 deletions
... | @@ -3,20 +3,49 @@ optionnaly another @code{body_t} part. | ... | @@ -3,20 +3,49 @@ optionnaly another @code{body_t} part. |
3 | 3 | ||
4 | @section Init/Destroy | 4 | @section Init/Destroy |
5 | 5 | ||
6 | @deftypefun int body_init (body_t *@var{msg}, const mailbox_t @var{mbx}) | 6 | @deftypefun int body_init (body_t *@var{bdy}) |
7 | Private. | 7 | Initialize an object @var{bdy}. |
8 | @end deftypefun | 8 | @end deftypefun |
9 | 9 | ||
10 | @deftypefun void body_destroy (body_t *@var{msg}) | 10 | @deftypefun void body_destroy (body_t *@var{bdy}) |
11 | The ressources allocate for clone @var{msg} are freed. | 11 | The ressources allocate are @var{bdy} freed. |
12 | @end deftypefun | 12 | @end deftypefun |
13 | 13 | ||
14 | @deftypefun int body_get_header (body_t @var{msg}, header_t *@var{hdr}) | 14 | @section Attributes |
15 | The body can cary header attributes if it is a mime. They also come | ||
16 | with the matching "set". | ||
17 | |||
18 | @deftypefun int body_get_header (body_t @var{bdy}, header_t *@var{hdr}) | ||
19 | @end deftypefun | ||
20 | @deftypefun int body_get_content_type (body_t @var{bdy}, char *@var{type}, size_t @var{len}) | ||
21 | @end deftypefun | ||
22 | @deftypefun int body_get_content_description (body_t @var{bdy}, char *@var{type}, size_t @var{len}) | ||
15 | @end deftypefun | 23 | @end deftypefun |
24 | @deftypefun int body_get_content_encoding (body_t @var{bdy}, char *@var{type}, size_t @var{len}) | ||
25 | @end deftypefun | ||
26 | |||
27 | @section Attachements | ||
16 | 28 | ||
17 | @deftypefun int body_get_content (body_t @var{msg}, char *buffer, size_t len, size_t *n) | 29 | @deftypefun int body_set_filename (body_t @var{bdy}, char *file) |
30 | Associate the body with a @var{file}. | ||
31 | @end deftypefun | ||
32 | @deftypefun int body_set_FILE (body_t @var{bdy}, FILE *fp) | ||
33 | Associate the body with a FILE *@var{fp}. | ||
18 | @end deftypefun | 34 | @end deftypefun |
19 | 35 | ||
20 | @deftypefun int body_get_type (body_t @var{msg}, char *buffer, size_t len, size_t *n) | 36 | @deftypefun int body_get_content (body_t @var{bdy}, off_t @var{offset}, char *buffer, size_t len, size_t *n) |
21 | @end deftypefun | 37 | @end deftypefun |
22 | 38 | ||
39 | @section Sub parts | ||
40 | A body may contain another body | ||
41 | @deftypefun int body_is_multipart (body_t @var{bdy}) | ||
42 | Return non-zero value if body has a second part. | ||
43 | @end deftypefun | ||
44 | @deftypefun int body_get_body (body_t @var{bdy}, body_t *@var{sub}) | ||
45 | Return the sub part in @var{bdy}. | ||
46 | @end deftypefun | ||
47 | @deftypefun int body_set_body (body_t @var{bdy}, body_t *@var{sub}) | ||
48 | Set a sub part for @var{bdy}. | ||
49 | @end deftypefun | ||
50 | |||
51 | ... | ... |
... | @@ -57,7 +57,7 @@ Some basic macros is already provided for rfc822. | ... | @@ -57,7 +57,7 @@ Some basic macros is already provided for rfc822. |
57 | @defmac MU_HDR_RESENT_SENDER | 57 | @defmac MU_HDR_RESENT_SENDER |
58 | "Resent-SENDER" | 58 | "Resent-SENDER" |
59 | @end defmac | 59 | @end defmac |
60 | @defmac MU_HDR_TOs | 60 | @defmac MU_HDR_TO |
61 | "To" | 61 | "To" |
62 | @end defmac | 62 | @end defmac |
63 | @defmac MU_HDR_RESENT_TO | 63 | @defmac MU_HDR_RESENT_TO | ... | ... |
... | @@ -12,8 +12,8 @@ Initializing and destroying a mailbox_t object. | ... | @@ -12,8 +12,8 @@ Initializing and destroying a mailbox_t object. |
12 | 12 | ||
13 | @deftypefun int mailbox_init (mailbox_t *@var{mbx}, const char * @var{url}, int @var{id}) | 13 | @deftypefun int mailbox_init (mailbox_t *@var{mbx}, const char * @var{url}, int @var{id}) |
14 | Based on the type of the @var{url}, @var{mbx} is initialize to a known type, | 14 | Based on the type of the @var{url}, @var{mbx} is initialize to a known type, |
15 | if @var{id} is not zero, it represents the id of the mailbox. The @var{id} | 15 | if @var{id} is not zero, it represents the id of the mailbox, it will be use |
16 | will be use instead of doing heuristic search on the @var{url}. | 16 | instead of doing heuristic search on the @var{url}. |
17 | @example | 17 | @example |
18 | #include <mailutils.h> | 18 | #include <mailutils.h> |
19 | @dots{} | 19 | @dots{} |
... | @@ -26,9 +26,9 @@ mailbox_init (&mbox, "file:///home/bar/.hiddenmail/bar", 0); | ... | @@ -26,9 +26,9 @@ mailbox_init (&mbox, "file:///home/bar/.hiddenmail/bar", 0); |
26 | @end deftypefun | 26 | @end deftypefun |
27 | 27 | ||
28 | @deftypefun int mailbox_init_default (mailbox_t *@var{mbx}, const char * @var{user}) | 28 | @deftypefun int mailbox_init_default (mailbox_t *@var{mbx}, const char * @var{user}) |
29 | Initialize the default mailbox of the system as set by the mail adminstrator. | 29 | Initialize the default mailbox of the system as set by the mail administrator. |
30 | It could be hardcoded or override by a configuration | 30 | It could be hardcoded or override by a configuration |
31 | @file{$sysconfig/mailutils.conf}. | 31 | @file{$@{sysconfig@}/mailutils.conf}. |
32 | @example | 32 | @example |
33 | #include <mailutils.h> | 33 | #include <mailutils.h> |
34 | @dots{} | 34 | @dots{} |
... | @@ -138,7 +138,7 @@ main () | ... | @@ -138,7 +138,7 @@ main () |
138 | sleep (NAP); | 138 | sleep (NAP); |
139 | 139 | ||
140 | /* It is a good habit to close the resources. | 140 | /* It is a good habit to close the resources. |
141 | A mailbox could be a remote host and the locking | 141 | A mailbox could be on a remote host and the locking |
142 | may interfere with normal delivery, for example with | 142 | may interfere with normal delivery, for example with |
143 | POP, the lock is hold during the entire session. | 143 | POP, the lock is hold during the entire session. |
144 | */ | 144 | */ |
... | @@ -150,8 +150,8 @@ main () | ... | @@ -150,8 +150,8 @@ main () |
150 | @end example | 150 | @end example |
151 | 151 | ||
152 | @section Deletion | 152 | @section Deletion |
153 | Messages can be marked for deletion but the action of removing them is only | 153 | Messages can be marked for deletion but destructive action is only taken |
154 | taken when @code{mailbox_expunge} is called. | 154 | when @code{mailbox_expunge} is called. |
155 | 155 | ||
156 | @deftypefun int mailbox_delete (mailbox_t @var{mbx}, size_t @var{msgno}) | 156 | @deftypefun int mailbox_delete (mailbox_t @var{mbx}, size_t @var{msgno}) |
157 | Mark message @var{msgno} for deletion. | 157 | Mark message @var{msgno} for deletion. |
... | @@ -162,7 +162,7 @@ UnMark message @var{msgno} for deletion. | ... | @@ -162,7 +162,7 @@ UnMark message @var{msgno} for deletion. |
162 | @end deftypefun | 162 | @end deftypefun |
163 | 163 | ||
164 | @deftypefun int mailbox_is_deleted (mailbox_t @var{mbx}, size_t @var{msgno}) | 164 | @deftypefun int mailbox_is_deleted (mailbox_t @var{mbx}, size_t @var{msgno}) |
165 | Return 1 if message @var{msgno} is mark deleted. | 165 | Return non-zero if message @var{msgno} is mark deleted. |
166 | @end deftypefun | 166 | @end deftypefun |
167 | 167 | ||
168 | @deftypefun int mailbox_num_deleted (mailbox_t @var{mbx}) | 168 | @deftypefun int mailbox_num_deleted (mailbox_t @var{mbx}) |
... | @@ -171,13 +171,13 @@ Return the number of Mailbox marked to be delete. | ... | @@ -171,13 +171,13 @@ Return the number of Mailbox marked to be delete. |
171 | 171 | ||
172 | @deftypefun int mailbox_expunge (mailbox_t @var{mbx}) | 172 | @deftypefun int mailbox_expunge (mailbox_t @var{mbx}) |
173 | All messages marked for deletion will be removed and the mailbox updated, | 173 | All messages marked for deletion will be removed and the mailbox updated, |
174 | and notification functions executed. | 174 | and notification functions of all messages for @var{mbx} executed. |
175 | @end deftypefun | 175 | @end deftypefun |
176 | 176 | ||
177 | @section Message | 177 | @section Message |
178 | Messages are object that hold the offsets of the message in the mailbox. | 178 | @code{message_t} are objects that hold the offsets of the message in the |
179 | Certain mailboxes allow new messages to be appended the existing folder, | 179 | mailbox. Certain mailboxes allow new messages to be appended to the existing |
180 | int this case the stream must be @code{mailbox_open} with the proper | 180 | folder, in this case the stream must be @code{mailbox_open} with the proper |
181 | permission. | 181 | permission. |
182 | 182 | ||
183 | @deftypefun int mailbox_new_message (mailbox_t @var{mbx}, message_t *@var{msg}) | 183 | @deftypefun int mailbox_new_message (mailbox_t @var{mbx}, message_t *@var{msg}) |
... | @@ -193,7 +193,8 @@ If @var{destroy} is set non-zero @code{message_destroy} will be call after deliv | ... | @@ -193,7 +193,8 @@ If @var{destroy} is set non-zero @code{message_destroy} will be call after deliv |
193 | @deftypefun int mailbox_get_message (mailbox_t @var{mbx}, size_t @var{msgno}, message_t *@var{msg}) | 193 | @deftypefun int mailbox_get_message (mailbox_t @var{mbx}, size_t @var{msgno}, message_t *@var{msg}) |
194 | @var{msg} is initialize, be warn when doing @code{mailbox_expunge} the | 194 | @var{msg} is initialize, be warn when doing @code{mailbox_expunge} the |
195 | offsets to the mailbox are losts and accessing the @var{msg} is undefined. | 195 | offsets to the mailbox are losts and accessing the @var{msg} is undefined. |
196 | To prevent this, it is possible to @code{message_clone} or set a notification. | 196 | To prevent this, it is possible to @code{message_clone} or set a notification |
197 | to take appropriate action. | ||
197 | @end deftypefun | 198 | @end deftypefun |
198 | 199 | ||
199 | @deftypefun int mailbox_destroy_message (mailbox_t @var{mbx}, message_t @var{msg}) | 200 | @deftypefun int mailbox_destroy_message (mailbox_t @var{mbx}, message_t @var{msg}) |
... | @@ -215,25 +216,25 @@ Low level Reading funtions for contents and headers. | ... | @@ -215,25 +216,25 @@ Low level Reading funtions for contents and headers. |
215 | @comment @var{body} will be append, otherwise it will overwrite any existing one. | 216 | @comment @var{body} will be append, otherwise it will overwrite any existing one. |
216 | @comment @end deftypefun | 217 | @comment @end deftypefun |
217 | 218 | ||
218 | @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}) | 219 | @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{nread}) |
219 | Read the body of message @var{msgno} starting at offset @var{off} in | 220 | Read the body of message @var{msgno} starting at offset @var{off} in |
220 | @var{buffer} of size @var{len}. The number of bytes read is returned in | 221 | @var{buffer} of size @var{len}. The number of bytes read is returned in |
221 | @var{nread}. | 222 | @var{nread}. |
222 | @end deftypefun | 223 | @end deftypefun |
223 | 224 | ||
224 | @deftypefun int mailbox_get_mcontent (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read}) | 225 | @deftypefun int mailbox_get_mcontent (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{nread}) |
225 | A buffer is allocated with @code{malloc(3)} return memory containing the body | 226 | A buffer is allocated with @code{malloc(3)} return memory containing the body |
226 | of message @var{msgno} starting at offset @var{off} in @var{buffer}. | 227 | of message @var{msgno} starting at offset @var{off} in @var{buffer}. |
227 | The number of bytes read is returned in @var{nread}. | 228 | The number of bytes read is returned in @var{nread}. |
228 | @end deftypefun | 229 | @end deftypefun |
229 | 230 | ||
230 | @deftypefun int mailbox_get_header (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char *@var{buffer}, size_t @var{len}, size_t *@var{read}) | 231 | @deftypefun int mailbox_get_header (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char *@var{buffer}, size_t @var{len}, size_t *@var{nread}) |
231 | Read the header of message @var{msgno} starting at offset @var{off} in | 232 | Read the header of message @var{msgno} starting at offset @var{off} in |
232 | @var{buffer} of size @var{len}. The number of bytes read is returned | 233 | @var{buffer} of size @var{len}. The number of bytes read is returned |
233 | in @var{nread}. | 234 | in @var{nread}. |
234 | @end deftypefun | 235 | @end deftypefun |
235 | 236 | ||
236 | @deftypefun int mailbox_get_mheader (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read}) | 237 | @deftypefun int mailbox_get_mheader (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{nread}) |
237 | A buffer allocate with @code{malloc(3)} is return containing the header of | 238 | A buffer allocate with @code{malloc(3)} is return containing the header of |
238 | message @var{msgno} starting at offset @var{off} in @var{buffer}. | 239 | message @var{msgno} starting at offset @var{off} in @var{buffer}. |
239 | The number of bytes read is returned in @var{nread}. | 240 | The number of bytes read is returned in @var{nread}. |
... | @@ -251,7 +252,6 @@ locking to provide synchronisation to the mailbox_t object. | ... | @@ -251,7 +252,6 @@ locking to provide synchronisation to the mailbox_t object. |
251 | Grab the lock. In some cases, i.e Unix mbox this may involve creating | 252 | Grab the lock. In some cases, i.e Unix mbox this may involve creating |
252 | a .lock file in the spool directory. | 253 | a .lock file in the spool directory. |
253 | @comment Say something about permission the program be gid on some OS. | 254 | @comment Say something about permission the program be gid on some OS. |
254 | |||
255 | @defmac MU_MB_RDLOCK | 255 | @defmac MU_MB_RDLOCK |
256 | Read lock. | 256 | Read lock. |
257 | @end defmac | 257 | @end defmac |
... | @@ -261,7 +261,6 @@ Write lock. | ... | @@ -261,7 +261,6 @@ Write lock. |
261 | @defmac MU_MB_RWLOCK | 261 | @defmac MU_MB_RWLOCK |
262 | Read/Write lock. | 262 | Read/Write lock. |
263 | @end defmac | 263 | @end defmac |
264 | |||
265 | @end deftypefun | 264 | @end deftypefun |
266 | 265 | ||
267 | Note on many mailboxes, RDLOCK is a noop. | 266 | Note on many mailboxes, RDLOCK is a noop. |
... | @@ -349,7 +348,8 @@ Note that all locks are held, and @var{notification} should be very small and | ... | @@ -349,7 +348,8 @@ Note that all locks are held, and @var{notification} should be very small and |
349 | simple, it should not access or do any action on the mailbox doing this may | 348 | simple, it should not access or do any action on the mailbox doing this may |
350 | cause undefined behaviour. | 349 | cause undefined behaviour. |
351 | @end deftypefun | 350 | @end deftypefun |
352 | 351 | @deftypefun int mailbox_set_msg_destroy_cb (mailbox_t @var{mbx}, int (*@var{notification}) (mailbox_t @var{mbx}, message_t @var{msg}, void *@var{arg})) | |
352 | @end deftypefun | ||
353 | 353 | ||
354 | @section Registration and Type | 354 | @section Registration and Type |
355 | 355 | ||
... | @@ -369,8 +369,8 @@ or add you own to the list. | ... | @@ -369,8 +369,8 @@ or add you own to the list. |
369 | @end deftp | 369 | @end deftp |
370 | 370 | ||
371 | @deftypefun int mailbox_list_type (struct mailbox_type *@var{mtype}, size_t @var{len}, size_t *@var{n}) | 371 | @deftypefun int mailbox_list_type (struct mailbox_type *@var{mtype}, size_t @var{len}, size_t *@var{n}) |
372 | The @var{mtype} array will be initialize with the list of builtin up to | 372 | The @var{mtype} array will be initialize with the list of builtins up to |
373 | @var{len}. The number of struct maiblox_type is put in @var{n}. | 373 | @var{len}. The number of struct mailbox_type is put in @var{n}. |
374 | @end deftypefun | 374 | @end deftypefun |
375 | 375 | ||
376 | @deftypefun int mailbox_list_mtype (struct mailbox_type **@var{mtype}, size_t *@var{n}) | 376 | @deftypefun int mailbox_list_mtype (struct mailbox_type **@var{mtype}, size_t *@var{n}) |
... | @@ -386,7 +386,7 @@ Remove a mailbox @var{mtype} to the list of builtin. | ... | @@ -386,7 +386,7 @@ Remove a mailbox @var{mtype} to the list of builtin. |
386 | @end deftypefun | 386 | @end deftypefun |
387 | 387 | ||
388 | @deftypefun int mailbox_get_type (struct mailbox_type **@var{mtype}, int @var{urlid}) | 388 | @deftypefun int mailbox_get_type (struct mailbox_type **@var{mtype}, int @var{urlid}) |
389 | Base on the URL @var{urlid} return the mailbox_type. | 389 | Base on the @var{urlid} return the mailbox_type. |
390 | @end deftypefun | 390 | @end deftypefun |
391 | 391 | ||
392 | @deftypefun int mailbox_get_name_type (mailbox_t @var{mbx}, int *@var{mbxid}, char *@var{name}, size_t @var{len}, size_t *@var{n}) | 392 | @deftypefun int mailbox_get_name_type (mailbox_t @var{mbx}, int *@var{mbxid}, char *@var{name}, size_t @var{len}, size_t *@var{n}) |
... | @@ -423,7 +423,7 @@ struct mailbox_type mbx_ftp = | ... | @@ -423,7 +423,7 @@ struct mailbox_type mbx_ftp = |
423 | @{ | 423 | @{ |
424 | "FTP MBOX", /* name type */ | 424 | "FTP MBOX", /* name type */ |
425 | (int)&mbx_ftp, /* need a uniq id */ | 425 | (int)&mbx_ftp, /* need a uniq id */ |
426 | &url_unix_type, /* url id */ | 426 | &url_ftp, /* url id */ |
427 | mailbox_unix_init, /* constructor */ | 427 | mailbox_unix_init, /* constructor */ |
428 | mailbox_unix_destroy /* destructor */ | 428 | mailbox_unix_destroy /* destructor */ |
429 | @}; | 429 | @}; | ... | ... |
1 | 1 | ||
2 | Mail Delivery is done here. Nothing is implemented and the API is still shaky. | 2 | The API is still shaky. |
3 | 3 | ||
4 | @section Init/Destroy | 4 | @section Init/Destroy |
5 | 5 | ||
... | @@ -26,28 +26,13 @@ Use MPP protocol. | ... | @@ -26,28 +26,13 @@ Use MPP protocol. |
26 | Not Implemented. | 26 | Not Implemented. |
27 | @end deftypefun | 27 | @end deftypefun |
28 | 28 | ||
29 | |||
30 | @section User/Passwd | ||
31 | |||
32 | On some mailer like MMP you need to identify. | ||
33 | |||
34 | @deftypefun int mailer_user (mailer_t @var{mailer}, const char *@var{user}) | ||
35 | Not Implemented. | ||
36 | @end deftypefun | ||
37 | |||
38 | @deftypefun int mailer_passwd (mailer_t @var{mailer}, const char *@var{passwd}) | ||
39 | Not Implemented. | ||
40 | @end deftypefun | ||
41 | |||
42 | @section Open/Close | 29 | @section Open/Close |
43 | The mailer is spawn, if it is a program, or the host is contacted. | ||
44 | 30 | ||
45 | @deftypefun int mailer_open (mailer_t @var{mailer}, int @var{flag}) | 31 | @deftypefun int mailer_open (mailer_t @var{mailer}, int @var{flag}) |
46 | Not Implemented. | 32 | On mailer program, it is a @code{stat(2)} or ping a server for smtp. |
47 | @end deftypefun | 33 | @end deftypefun |
48 | |||
49 | @deftypefun int mailer_close (mailer_t @var{mailer}) | 34 | @deftypefun int mailer_close (mailer_t @var{mailer}) |
50 | Not Implemented. | 35 | Noop on most mailers. |
51 | @end deftypefun | 36 | @end deftypefun |
52 | 37 | ||
53 | @section Sending | 38 | @section Sending |
... | @@ -58,34 +43,20 @@ Sending a message. | ... | @@ -58,34 +43,20 @@ Sending a message. |
58 | Not Implemented. | 43 | Not Implemented. |
59 | @end deftypefun | 44 | @end deftypefun |
60 | 45 | ||
61 | @deftypefun int mailer_set_content (mailer_t @var{mailer}, char *, size_t) | 46 | @deftypefun int mailer_send (mailer_t @var{mailer}, message_t @var{msg}, int destroy) |
62 | Not Implemented. | 47 | @var{msg} is delivered |
63 | @end deftypefun | 48 | @end deftypefun |
64 | 49 | ||
65 | @deftypefun int mailer_set_header (mailer_t @var{mailer}, char *, size_t) | 50 | @section Notification |
66 | Not Implemented. | 51 | @deftypefun int mailer_set_delivery_cb (mailer_t @var{mailer}, message_t @var{msg}, int *@var{notification}(mailer_t @var{mailer}, int @var{status}, size_t @var{msgno}, void *@var{arg}) |
67 | @end deftypefun | 52 | On delivery @code{notification (mailer, status, msgno, arg)} is |
68 | 53 | executed. | |
69 | @deftypefun int mailbox_add_attachment (mailer_t, size_t msgno, const char *boundary, const char *header, FILE *file, int encoding) | ||
70 | @end deftypefun | ||
71 | |||
72 | @deftypefun int mailer_send_message (mailer_t @var{mailer}, size_t) | ||
73 | Not Implemented. | ||
74 | @end deftypefun | ||
75 | |||
76 | @section Timeout | ||
77 | @deftypefun int mailer_set_timeout (mailer_t @var{mailer}, size_t) | ||
78 | Not Implemented. | ||
79 | @end deftypefun | ||
80 | |||
81 | @deftypefun int mailer_get_timeout (mailer_t @var{mailer}, size_t) | ||
82 | Not Implemented. | ||
83 | @end deftypefun | 54 | @end deftypefun |
84 | 55 | ||
85 | @section SMTP | 56 | @section SMTP |
86 | @cindex SMTP | 57 | @cindex SMTP |
87 | 58 | ||
88 | TODO: todo | 59 | TODO: describe protocol, url, mailto url etc .. |
89 | 60 | ||
90 | @section UUCP | 61 | @section UUCP |
91 | @cindex UUCP | 62 | @cindex UUCP | ... | ... |
... | @@ -141,11 +141,11 @@ a rich set of functions for accessing different mailbox formats and mailers. | ... | @@ -141,11 +141,11 @@ a rich set of functions for accessing different mailbox formats and mailers. |
141 | ---------- | +-----------------+ +-->+----------+ | 141 | ---------- | +-----------------+ +-->+----------+ |
142 | | | user | | 142 | | | user | |
143 | message_t | | passwd | | 143 | message_t | | passwd | |
144 | +--------------+<------+ header_t +----------+ | 144 | +--------------+<------+ header_t +----------+ |
145 | | header_t *-|-----------------------+->+-----------------+ | 145 | | header_t *-|-----------------------+-->+---------------+ |
146 | +--------------+ body_t | | name/value[0] | | 146 | +--------------+ body_t | | name/val[0] | |
147 | | body_t[0] *-|----->+-------------+ | | ... | | 147 | | body_t[0] *-|----->+-------------+ | | ... | |
148 | | body_t[1] | | header_t *-|--+ +-----------------+ | 148 | | body_t[1] | | header_t *-|--+ +---------------+ |
149 | | ... | +-------------+ | 149 | | ... | +-------------+ |
150 | +--------------+ | content | | 150 | +--------------+ | content | |
151 | | next_body | | 151 | | next_body | | ... | ... |
1 | The @code{message_t} is a convenient way to manipulate messages. It | 1 | The @code{message_t} object is a convenient way to manipulate messages. It |
2 | encapsulates the @code{header_t} attribute and the @code{body_t}. | 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 | 3 | This type, unless you ask explicitly with @code{message_clone}, only contains |
4 | references on how to retrieve the information from the mailbox. | 4 | references on how to retrieve the information from the mailbox. |
5 | 5 | ||
6 | @example | 6 | @example |
7 | @group | 7 | @group |
8 | +------------------+ | 8 | message_t |
9 | | message_t | | 9 | +----------+ +------>+-----------------------+ |
10 | +------------------+ | 10 | |3 | | | header_t | |
11 | | header_t | +----------------+ | 11 | +----------+ | | |-----------------------| |
12 | | body_t[] *-----|------------+| body_t |----* ..... | 12 | |2 *-|-|---+ | body_t [0] | |
13 | | type | +----------------+ | 13 | +----------+ | | | body_t [1] | |
14 | | body_count | | header_t | | 14 | |1 | | | | ... | |
15 | +------------------+ | content | | 15 | +----------+ | |-+ | ... | |
16 | | type | | 16 | | 0 | | | | ... | |
17 | | next body *---|----//-- | 17 | | | | | | | |
18 | +----------------+ | 18 | | | |-+ | | |
19 | | |-+ | | | ||
20 | | | | | | ||
21 | +----------+ +-----------------------+ | ||
19 | @end group | 22 | @end group |
20 | @end example | 23 | @end example |
21 | 24 | ||
22 | @section Init/Destroy | 25 | @section Init/Destroy |
23 | The common way to obtain a @code{message_t} is by requesting | 26 | The common way to obtain a @code{message_t} is by requesting |
24 | @code{mailbox_get_message}, or @code{mailbox_create_message} from | 27 | @code{mailbox_get_message}, or @code{mailbox_new_message} from |
25 | a specific type of mailbox, they are not explicitely created. | 28 | a specific type of mailbox, they are not explicitly created. |
26 | 29 | ||
27 | @example | 30 | @example |
28 | #include <mailutils.h> | 31 | #include <mailutils.h> |
32 | #include <stdio.h> | ||
33 | #include <string.h> | ||
29 | 34 | ||
30 | mailbox_t mbx; | 35 | static int |
31 | message_t msg, clone; | 36 | ack (mailer, int status, message_t msg, void *arg) |
32 | mailbox_init_default (&mbx, NULL); | 37 | @{ |
33 | mailbox_open (mbx, MU_MB_RDONLY); | 38 | if (status == 0) |
34 | @dots{} | 39 | printf ("Ok message sent\n"); |
35 | mailbox_get_message (mbx, msg_no, &msg); | 40 | else |
36 | /* before closing I need to make sure | 41 | printf ("Error failed to deliver\n"); |
37 | that I have a copy not a reference of the message */ | 42 | return 0; |
38 | message_clone (msg, &clone); | 43 | @} |
39 | /* safe to close/expunge, I got a copy */ | 44 | |
40 | mailbox_close (mbx); | 45 | #define CONTENT "A GNU Generation\n" |
41 | /* ... */ | 46 | |
42 | message_size (clone, &size); | 47 | int main () |
48 | @{ | ||
49 | mailer_t mailer; | ||
50 | message_t msg; | ||
51 | body_t bd; | ||
52 | |||
53 | mailer_init_default (&mailer, NULL); | ||
54 | mailer_new_message (&msg); | ||
55 | |||
56 | message_set_to (msg, "bug-mailutils@@gnu.org", 0); | ||
57 | message_set_subject (msg, "What is our generation ?", 0); | ||
58 | message_set_body (msg, CONTENT, strlen (CONTENT), 0); | ||
59 | |||
60 | mailer_set_delivery_cb (mailer, msg, ack, NULL); | ||
61 | mailer_send (mailer, msg, 1/* destroy */); | ||
62 | return 0; | ||
63 | @} | ||
43 | @end example | 64 | @end example |
44 | 65 | ||
45 | @deftypefun void message_destroy (message_t *@var{msg}) | 66 | @deftypefun void message_destroy (message_t *@var{msg}) |
46 | The ressources allocate for clone @var{msg} are freed. | 67 | The resources allocated when cloning @var{msg} are freed. |
47 | @end deftypefun | 68 | @end deftypefun |
48 | 69 | ||
70 | @section Header attributes | ||
71 | The @code{message_t} type provides some functions to set/retrieve some well | ||
72 | know header attributes. | ||
73 | |||
49 | @deftypefun int message_get_header (message_t @var{msg}, header_t *@var{hdr}) | 74 | @deftypefun int message_get_header (message_t @var{msg}, header_t *@var{hdr}) |
75 | Copy the @var{msg} header in @var{hdr}. | ||
76 | @end deftypefun | ||
77 | |||
78 | @deftypefun int message_set_header (message_t @var{msg}, header_t @var{hdr}) | ||
79 | Make a copy of @var{hdr} and set the @var{msg}, any previous header is freed. | ||
50 | @end deftypefun | 80 | @end deftypefun |
51 | 81 | ||
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) | 82 | @deftypefun int message_get_from (message_t @var{msg}, char *buffer, size_t len, size_t *n) |
54 | @end deftypefun | 83 | @end deftypefun |
84 | @deftypefun int message_set_from (message_t @var{msg}, char *buffer, size_t len) | ||
85 | @end deftypefun | ||
55 | 86 | ||
56 | @deftypefun int message_get_to (message_t @var{msg}, char *buffer, size_t len, size_t *n) | 87 | @deftypefun int message_get_to (message_t @var{msg}, char *buffer, size_t len, size_t *n) |
57 | @end deftypefun | 88 | @end deftypefun |
89 | @deftypefun int message_set_to (message_t @var{msg}, char *buffer, size_t len) | ||
90 | @end deftypefun | ||
58 | 91 | ||
59 | @deftypefun int message_get_date (message_t @var{msg}, char *buffer, size_t len, size_t *n) | 92 | @deftypefun int message_get_subject (message_t @var{msg}, char *buffer, size_t len, size_t *n) |
93 | @end deftypefun | ||
94 | @deftypefun int message_set_subject (message_t @var{msg}, char *buffer, size_t len) | ||
60 | @end deftypefun | 95 | @end deftypefun |
61 | 96 | ||
62 | @deftypefun int message_get_cc (message_t @var{msg}, char *buffer, size_t len, size_t *n) | 97 | @deftypefun int message_get_cc (message_t @var{msg}, char *buffer, size_t len, size_t *n) |
63 | @end deftypefun | 98 | @end deftypefun |
99 | @deftypefun int message_set_cc (message_t @var{msg}, char *buffer, size_t len) | ||
100 | @end deftypefun | ||
101 | |||
102 | @deftypefun int message_get_bcc (message_t @var{msg}, char *buffer, size_t len, size_t *n) | ||
103 | @end deftypefun | ||
104 | @deftypefun int message_set_bcc (message_t @var{msg}, char *buffer, size_t len) | ||
105 | @end deftypefun | ||
106 | |||
107 | @deftypefun int message_is_mime (message_t @var{msg}) | ||
108 | Return non-zero value if message is multi-part. | ||
109 | @end deftypefun | ||
110 | |||
111 | @deftypefun int message_set_mime (message_t @var{msg}) | ||
112 | By default mime is use for more then one body, but it can be set | ||
113 | explicitly to mime. | ||
114 | @end deftypefun | ||
115 | |||
116 | @section Content | ||
117 | |||
118 | @deftypefun int message_get_body (message_t @var{msg}, int @var{num}, body_t *@var{body}) | ||
119 | Copy body number @var{num} of @var{msg} to @var{body}. | ||
120 | @end deftypefun | ||
121 | |||
122 | @deftypefun int message_set_body (message_t @var{msg}, int *@var{num}, body_t @var{body}) | ||
123 | Copy @var{body} to @var{msg}, @var{num} is set. | ||
124 | @end deftypefun | ||
125 | |||
126 | @deftypefun int message_set_content (message_t @var{msg}, char *@var{content}, size_t @var{len}) | ||
127 | Add @var{content} to the first body. | ||
128 | @end deftypefun | ||
129 | |||
130 | @section Miscellany | ||
131 | |||
132 | @deftypefun int message_is_delete (message_t @var{msg}) | ||
133 | Return non-zero value if mark for deletion. | ||
134 | @end deftypefun | ||
135 | |||
136 | @deftypefun int message_get_mailbox (message_t @var{msg}, mailbox_t *mbx) | ||
137 | If @var{msg} is associated with a mailbox, set @var{mbx} and return | ||
138 | zero, otherwise @var{mbx} is unmodified and non-zero value is return. | ||
139 | @end deftypefun | ||
140 | |||
141 | @deftypefun int message_get_mailer (message_t @var{msg}, mailer_t *ml) | ||
142 | If @var{msg} is associated with a mailer, set @var{mbx} and return | ||
143 | zero, otherwise @var{ml} is unmodified and non-zero value is return. | ||
144 | @end deftypefun | ||
145 | |||
146 | @deftypefun int message_get_mid (message_t @var{msg}, char **mid) | ||
147 | Set @var{mid} to the message ID. | ||
148 | @end deftypefun | ||
149 | |||
150 | @deftypefun int message_get_msg_number (message_t @var{msg}, size_t *number) | ||
151 | Set @var{number} to the @var{msg} in the mailbox. | ||
152 | @end deftypefun | ||
153 | |||
154 | @deftypefun int message_get_body_count (message_t @var{msg}, size_t *number) | ||
155 | Put the body count in @var{number}. | ||
156 | @end deftypefun | ... | ... |
1 | /* sfrom, Simple From */ | 1 | /* sfrom, Simple From */ |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <unistd.h> | 3 | #include <unistd.h> |
4 | #include <stdlib.h> | ||
4 | #include <string.h> | 5 | #include <string.h> |
5 | #include <mailutils.h> | 6 | #include <mailutils.h> |
6 | 7 | ||
... | @@ -35,7 +36,7 @@ int main (int argc, char **argv) | ... | @@ -35,7 +36,7 @@ int main (int argc, char **argv) |
35 | 36 | ||
36 | for (msgno = 0; msgno < msg_total; msgno++) | 37 | for (msgno = 0; msgno < msg_total; msgno++) |
37 | @{ | 38 | @{ |
38 | if (mailbox_get_header (mbox, msgno, buffer, | 39 | if (mailbox_get_header (mbox, msgno, 0, buffer, |
39 | sizeof (buffer), &size) != 0) | 40 | sizeof (buffer), &size) != 0) |
40 | @{ | 41 | @{ |
41 | fprintf (stderr, "header corrupted\n"); | 42 | fprintf (stderr, "header corrupted\n"); | ... | ... |
... | @@ -91,7 +91,7 @@ Initialize and parse the @var{url} | ... | @@ -91,7 +91,7 @@ Initialize and parse the @var{url} |
91 | @end example | 91 | @end example |
92 | @end deftp | 92 | @end deftp |
93 | 93 | ||
94 | @section Helper functions | 94 | @section URL registration |
95 | 95 | ||
96 | @deftypefun int url_list_type (struct url_type @var{list}[], size_t @var{len}, size_t *@var{n}) | 96 | @deftypefun int url_list_type (struct url_type @var{list}[], size_t @var{len}, size_t *@var{n}) |
97 | @end deftypefun | 97 | @end deftypefun |
... | @@ -108,6 +108,57 @@ Initialize and parse the @var{url} | ... | @@ -108,6 +108,57 @@ Initialize and parse the @var{url} |
108 | @deftypefun int url_get_id (const url_t @var{url}, int *@var{id}) | 108 | @deftypefun int url_get_id (const url_t @var{url}, int *@var{id}) |
109 | @end deftypefun | 109 | @end deftypefun |
110 | 110 | ||
111 | @section Helper functions | ||
112 | |||
113 | @example | ||
114 | #include <url.h> | ||
115 | #include <stdio.h> | ||
116 | #include <string.h> | ||
117 | |||
118 | int main () | ||
119 | @{ | ||
120 | char str[1024]; | ||
121 | char buffer[1024]; | ||
122 | long port = -1; | ||
123 | url_t u; | ||
124 | |||
125 | while (fgets (str, sizeof (str), stdin) != NULL) | ||
126 | @{ | ||
127 | str[strlen (str) - 1] = '\0'; /* chop newline */ | ||
128 | if (url_init (&u, str) != 0) | ||
129 | @{ | ||
130 | printf ("%s --> FAILED\n", str); | ||
131 | continue; | ||
132 | @} | ||
133 | printf ("%s --> SUCCESS\n", str); | ||
134 | |||
135 | url_get_scheme (u, buffer, len, NULL); | ||
136 | printf ("\tscheme <%s>\n", buffer); | ||
137 | |||
138 | url_get_user (u, buffer, len, NULL); | ||
139 | printf ("\tuser <%s>\n", buffer); | ||
140 | |||
141 | url_get_passwd (u, buffer, len, NULL); | ||
142 | printf ("\tpasswd <%s>\n", buffer); | ||
143 | |||
144 | url_get_host (u, buffer, len, NULL); | ||
145 | printf ("\thost <%s>\n", buffer); | ||
146 | |||
147 | url_get_port (u, &port); | ||
148 | printf ("\tport %ld\n", port); | ||
149 | |||
150 | url_get_path (u, buffer, len, NULL); | ||
151 | printf ("\tpath <%s>\n", buffer); | ||
152 | |||
153 | url_get_query (u, buffer, len, NULL); | ||
154 | printf ("\tquery <%s>\n", buffer); | ||
155 | |||
156 | url_destroy (&u); | ||
157 | @} | ||
158 | return 0; | ||
159 | @} | ||
160 | @end example | ||
161 | |||
111 | @deftypefun int url_get_scheme (const url_t @var{url}, char *@var{schem}, size_t @var{len}, size_t *@var{n}) | 162 | @deftypefun int url_get_scheme (const url_t @var{url}, char *@var{schem}, size_t @var{len}, size_t *@var{n}) |
112 | @end deftypefun | 163 | @end deftypefun |
113 | 164 | ||
... | @@ -146,4 +197,3 @@ Initialize and parse the @var{url} | ... | @@ -146,4 +197,3 @@ Initialize and parse the @var{url} |
146 | 197 | ||
147 | @deftypefun int url_get_mquery (const url_t @var{url}, char **@var{buf}, size_t *@var{len}) | 198 | @deftypefun int url_get_mquery (const url_t @var{url}, char **@var{buf}, size_t *@var{len}) |
148 | @end deftypefun | 199 | @end deftypefun |
149 | ... | ... |
-
Please register or sign in to post a comment