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
447 additions
and
178 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 ? | ... | ... |
1 | Mail boxes come in different formats and may be on a remote hosts, | 1 | Mail boxes come in different formats and may be on a remote hosts, |
2 | only accessible through a Mail Delivery Agent(MDA). Regardeless | 2 | only accessible through Mail Delivery Agent(MDA). Regardeless |
3 | of the format and the protocol use, some common actions are needed like | 3 | of the format and the protocol use, some common actions are needed like |
4 | reading, saving, deleting, scanning ... Those actions are provided via a | 4 | reading, saving, deleting, scanning ... Those actions are provided via a |
5 | unify API mailbox_t. | 5 | unify API mailbox_t. |
6 | 6 | ||
7 | All functions of the mailbox_t API return 0 if succesfull or non-zero | 7 | All functions of the mailbox_t API return 0 if succesfull or non-zero |
8 | otherwise. Unless they specify otherwise. | 8 | for failure, unless specify otherwise. |
9 | 9 | ||
10 | @subsubsection Init/Destroy | 10 | @section Init/Destroy |
11 | Initializing and destroying a mailbox_t object. | 11 | 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. The @var{id} |
16 | will be use instead of doing heuristic search on the @var{url}. | 16 | will be use instead of doing heuristic search on the @var{url}. |
17 | @end deftypefun | ||
18 | @example | 17 | @example |
19 | #include <mailutils.h> | 18 | #include <mailutils.h> |
20 | @dot{} | 19 | @dots{} |
21 | mailbox_t foo, popmbx, bar; | 20 | mailbox_t foo, popmbx, bar; |
21 | /* same as @url{file:///var/mail/foo} */ | ||
22 | mailbox_init (&mbox, "/var/mail/foo", 0); | 22 | mailbox_init (&mbox, "/var/mail/foo", 0); |
23 | mailbox_init (&mbox, "pop://popserver.bar.com/foo, 0); | 23 | mailbox_init (&mbox, "pop://popserver.bar.com/foo", 0); |
24 | mailbox_init (&mbox, "file:///home/bar/.hiddenmail/bar", 0); | 24 | mailbox_init (&mbox, "file:///home/bar/.hiddenmail/bar", 0); |
25 | @end example | 25 | @end example |
26 | @end deftypefun | ||
27 | |||
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. | ||
30 | It could be hardcoded or override by a configuration | ||
31 | @file{$sysconfig/mailutils.conf}. | ||
32 | @example | ||
33 | #include <mailutils.h> | ||
34 | @dots{} | ||
35 | /* If the default mailbox on this system is @file{/var/mail} */ | ||
36 | |||
37 | mailbox_t mbx; | ||
38 | |||
39 | /* sets the mailbox name to @url{file:///var/mail/foo} */ | ||
40 | mailbox_init_default (&mbx, "foo"); | ||
41 | |||
42 | /* | ||
43 | If the user is log as @emph{bar}, sets the mailbox name | ||
44 | to @url{file:///var/mail/bar} | ||
45 | */ | ||
46 | mailbox_init_default (&mbx, NULL); | ||
47 | @end example | ||
48 | @end deftypefun | ||
26 | 49 | ||
27 | @deftypefun int mailbox_destroy (mailbox_t *@var{mbx}) | 50 | @deftypefun int mailbox_destroy (mailbox_t *@var{mbx}) |
28 | All ressources allocated is release if the stream is not open, | 51 | All ressources allocated are release. If the stream is not open, |
29 | @code{mailbox_close} is call. | 52 | @code{mailbox_close} is call. |
30 | @end deftypefun | 53 | @end deftypefun |
31 | 54 | ||
32 | @subsubsection Open/Close | 55 | @section Open/Close |
33 | Opening and closing mailbox can be done any number of times. But be warned | 56 | Opening and closing mailbox can be done any number of times. But be warned |
34 | on some cases like POP3, when opening, the lock can be persistent until | 57 | on some cases like POP3, when opening, the lock can be persistent until |
35 | the stream is closed as required by the RFC. | 58 | the stream is closed as required by the RFC. |
36 | 59 | ||
37 | @deftypefun int mailbox_open (mailbox_t @var{mbx}, int @var{flag}) | 60 | @deftypefun int mailbox_open (mailbox_t @var{mbx}, int @var{flag}) |
38 | Open the mailbox box stream. This funtion will call @code{mailbox_scan}. | 61 | Open the mailbox box stream. This funtion will call @code{mailbox_scan}. |
39 | @end deftypefun | ||
40 | 62 | ||
41 | @defmac MU_MB_RDONLY | 63 | @defmac MU_MB_RDONLY |
42 | Stream is open read-only. | 64 | Stream is open read-only. |
... | @@ -48,20 +70,86 @@ Stream is open write-only. | ... | @@ -48,20 +70,86 @@ Stream is open write-only. |
48 | Stream is open read-write. | 70 | Stream is open read-write. |
49 | @end defmac | 71 | @end defmac |
50 | @defmac MU_MB_CREAT | 72 | @defmac MU_MB_CREAT |
51 | If file does not exist it is created. May be a noop on remote hosts mailbox. | 73 | If Folder does not exist it is created. May be a noop on remote hosts mailbox. |
52 | @end defmac | 74 | @end defmac |
53 | @defmac MU_MB_APPEND | 75 | @defmac MU_MB_APPEND |
54 | The stream is opened in append mode. | 76 | The stream is opened in append mode. |
55 | @end defmac | 77 | @end defmac |
56 | @defmac MU_MB_ONONBLOCK | 78 | @defmac MU_MB_ONONBLOCK |
57 | For sockets, open() nonblocking. | 79 | For sockets, open() nonblocking. Not supported. |
58 | @end defmac | 80 | @end defmac |
81 | @end deftypefun | ||
59 | 82 | ||
60 | @deftypefun int mailbox_close (mailbox_t @var{mbx}) | 83 | @deftypefun int mailbox_close (mailbox_t @var{mbx}) |
61 | Close the streams and release the locks. | 84 | Close the streams and release the locks. |
62 | @end deftypefun | 85 | @end deftypefun |
63 | 86 | ||
64 | @subsubsection Deletion | 87 | @deftypefun int mailbox_is_open (mailbox_t @var{mbx}) |
88 | Return a non-zero value if the stream is open, zero otherwise. | ||
89 | @end deftypefun | ||
90 | |||
91 | This is a very simple implementation of Unix @command{biff}. | ||
92 | |||
93 | @example | ||
94 | #include <mailutils.h> | ||
95 | #include <unistd.h> | ||
96 | #include <stdio.h> | ||
97 | #include <stdlib.h> | ||
98 | |||
99 | #define NAP 120 | ||
100 | |||
101 | int | ||
102 | main () | ||
103 | @{ | ||
104 | mailbox_t mbx; | ||
105 | size_t size = 0, size2 = 0; | ||
106 | |||
107 | if (mailbox_init_default (&mbx, NULL) != 0) | ||
108 | @{ | ||
109 | fprintf ("Can't initiliaze system mailbox\n"); | ||
110 | exit (EXIT_FAILURE); | ||
111 | @} | ||
112 | /* the open may fail if no mailbox was created, | ||
113 | will check this later */ | ||
114 | mailbox_open (mbx, MU_MB_RDONLY); | ||
115 | mailbox_size (mbx, &size); | ||
116 | for (;;) | ||
117 | @{ | ||
118 | if (! mailbox_is_open (mbx)) | ||
119 | @{ | ||
120 | if (mailbox_open (mbx, MU_MB_RDONLY) != 0); | ||
121 | @{ | ||
122 | //fprintf (stderr, "Not exist ?\n"); | ||
123 | @} | ||
124 | @} | ||
125 | else | ||
126 | @{ | ||
127 | if (mailbox_size (mbx, &size2) == 0) | ||
128 | @{ | ||
129 | if (size2 > size) | ||
130 | @{ | ||
131 | printf ("You got mail\a\n"); | ||
132 | @} | ||
133 | size = size2; | ||
134 | @} | ||
135 | @} | ||
136 | |||
137 | /* rest a while */ | ||
138 | sleep (NAP); | ||
139 | |||
140 | /* It is a good habit to close the resources. | ||
141 | A mailbox could be a remote host and the locking | ||
142 | may interfere with normal delivery, for example with | ||
143 | POP, the lock is hold during the entire session. | ||
144 | */ | ||
145 | mailbox_close (mbx); | ||
146 | @} | ||
147 | |||
148 | return 0; | ||
149 | @} | ||
150 | @end example | ||
151 | |||
152 | @section Deletion | ||
65 | Messages can be marked for deletion but the action of removing them is only | 153 | Messages can be marked for deletion but the action of removing them is only |
66 | taken when @code{mailbox_expunge} is called. | 154 | taken when @code{mailbox_expunge} is called. |
67 | 155 | ||
... | @@ -85,11 +173,11 @@ All messages marked for deletion will be removed and the mailbox updated. | ... | @@ -85,11 +173,11 @@ All messages marked for deletion will be removed and the mailbox updated. |
85 | Return the number of Mailbox marked to be delete. | 173 | Return the number of Mailbox marked to be delete. |
86 | @end deftypefun | 174 | @end deftypefun |
87 | 175 | ||
88 | @subsubsection New Message | 176 | @section New Message |
89 | Certain mailboxes allow new messages to be appended the existing folder. | 177 | Certain mailboxes allow new messages to be appended the existing folder. |
90 | The stream must be @code{mailbox_open} with the proper permission. | 178 | The stream must be @code{mailbox_open} with the proper permission. |
91 | 179 | ||
92 | @deftypefun int mailbox_create_envelope (mailbox_t @var{mbx}, size_t *@var{msgno}) | 180 | @deftypefun int mailbox_new_message (mailbox_t @var{mbx}, size_t *@var{msgno}) |
93 | Create an envelope, @var{msgno} will contain a uniq number for this envelope. | 181 | Create an envelope, @var{msgno} will contain a uniq number for this envelope. |
94 | @end deftypefun | 182 | @end deftypefun |
95 | 183 | ||
... | @@ -104,7 +192,7 @@ Fill the body of new envelope @var{msgno}. If @var{replace} is zero the buffer | ... | @@ -104,7 +192,7 @@ Fill the body of new envelope @var{msgno}. If @var{replace} is zero the buffer |
104 | @var{body} will be append, otherwise it will overwrite any existing one. | 192 | @var{body} will be append, otherwise it will overwrite any existing one. |
105 | @end deftypefun | 193 | @end deftypefun |
106 | 194 | ||
107 | @deftypefun int mailbox_append (mailbox_t @var{mbx}, size_t @var{msgno}, int @var{destroy}) | 195 | @deftypefun int mailbox_append_message (mailbox_t @var{mbx}, size_t @var{msgno}, int @var{destroy}) |
108 | @var{msgno} given from @code{mailbox_envelope} will be append to | 196 | @var{msgno} given from @code{mailbox_envelope} will be append to |
109 | the mailbox. When appending the header may be modified. In the case of | 197 | the mailbox. When appending the header may be modified. In the case of |
110 | Unix Mbox, the header "From " is prepend. If @var{destroy} is set non-zero | 198 | 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 | ... | @@ -116,16 +204,16 @@ Ressources allocated to envelope @var{msgno} will be release. This function |
116 | should be call after @code{mailbox_append}. | 204 | should be call after @code{mailbox_append}. |
117 | @end deftypefun | 205 | @end deftypefun |
118 | 206 | ||
119 | @subsubsection Reading | 207 | @section Reading |
120 | Reading the message body and header. | 208 | Reading the message body and header. |
121 | 209 | ||
122 | @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}) | 210 | @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}) |
123 | Read the body of message @var{msgno} starting at offset @var{off} in | 211 | Read the body of message @var{msgno} starting at offset @var{off} in |
124 | @var{buffer} of size @var{len}. The number of bytes read is returned in | 212 | @var{buffer} of size @var{len}. The number of bytes read is returned in |
125 | @var{nread}. | 213 | @var{nread}. |
126 | @end deftypefun | 214 | @end deftypefun |
127 | 215 | ||
128 | @deftypefun int mailbox_get_mbody (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read}) | 216 | @deftypefun int mailbox_get_mcontent (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read}) |
129 | A buffer is allocated with @code{malloc(3)} return memory containing the body | 217 | A buffer is allocated with @code{malloc(3)} return memory containing the body |
130 | of message @var{msgno} starting at offset @var{off} in @var{buffer}. | 218 | of message @var{msgno} starting at offset @var{off} in @var{buffer}. |
131 | The number of bytes read is returned in @var{nread}. | 219 | 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}. | ... | @@ -143,7 +231,7 @@ message @var{msgno} starting at offset @var{off} in @var{buffer}. |
143 | The number of bytes read is returned in @var{nread}. | 231 | The number of bytes read is returned in @var{nread}. |
144 | @end deftypefun | 232 | @end deftypefun |
145 | 233 | ||
146 | @subsubsection Locking | 234 | @section Locking |
147 | Most mailboxes provide locking before changing the content. Functions | 235 | Most mailboxes provide locking before changing the content. Functions |
148 | will grab the lock before doing any destructive action. The Locking functions | 236 | will grab the lock before doing any destructive action. The Locking functions |
149 | are provided for accesssing the folder outside the API, in that case the | 237 | 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. | ... | @@ -154,7 +242,6 @@ locking to provide synchronisation to the mailbox_t object. |
154 | Grab the lock. In some cases, i.e Unix mbox this may involve creating | 242 | Grab the lock. In some cases, i.e Unix mbox this may involve creating |
155 | a .lock file in the spool directory. | 243 | a .lock file in the spool directory. |
156 | @comment Say something about permission the program be gid on some OS. | 244 | @comment Say something about permission the program be gid on some OS. |
157 | @end deftypefun | ||
158 | 245 | ||
159 | @defmac MU_MB_RDLOCK | 246 | @defmac MU_MB_RDLOCK |
160 | Read lock. | 247 | Read lock. |
... | @@ -166,13 +253,15 @@ Write lock. | ... | @@ -166,13 +253,15 @@ Write lock. |
166 | Read/Write lock. | 253 | Read/Write lock. |
167 | @end defmac | 254 | @end defmac |
168 | 255 | ||
256 | @end deftypefun | ||
257 | |||
169 | Note on many mailbox, RDLOCK is a noop. | 258 | Note on many mailbox, RDLOCK is a noop. |
170 | 259 | ||
171 | @deftypefun int mailbox_unlock (mailbox_t @var{mbx}) | 260 | @deftypefun int mailbox_unlock (mailbox_t @var{mbx}) |
172 | Release the lock. | 261 | Release the lock. |
173 | @end deftypefun | 262 | @end deftypefun |
174 | 263 | ||
175 | @subsubsection Owner/Group | 264 | @section Owner/Group |
176 | Most mailboxes provide locking before changing their content, Ownership | 265 | Most mailboxes provide locking before changing their content, Ownership |
177 | and group. When creating certain mailbox, you can set the owner/group. | 266 | and group. When creating certain mailbox, you can set the owner/group. |
178 | 267 | ||
... | @@ -185,7 +274,7 @@ Set the group to @var{gid}. If the Mailbox was not @code{mailbox_open} | ... | @@ -185,7 +274,7 @@ Set the group to @var{gid}. If the Mailbox was not @code{mailbox_open} |
185 | the action is delayed until the stream is opened. | 274 | the action is delayed until the stream is opened. |
186 | @end deftypefun | 275 | @end deftypefun |
187 | 276 | ||
188 | @subsubsection Scanning | 277 | @section Scanning |
189 | 278 | ||
190 | Scan is done explicitely on @code{mailbox_open}. | 279 | Scan is done explicitely on @code{mailbox_open}. |
191 | 280 | ||
... | @@ -214,7 +303,7 @@ For message @var{msgno} set @var{header} size and @var{body} size. | ... | @@ -214,7 +303,7 @@ For message @var{msgno} set @var{header} size and @var{body} size. |
214 | Return the number of messages in @var{mbx}. | 303 | Return the number of messages in @var{mbx}. |
215 | @end deftypefun | 304 | @end deftypefun |
216 | 305 | ||
217 | @subsubsection Timeout/Notification | 306 | @section Timeout/Notification |
218 | Setting timeout and notifications. @code{mailbox_scan} can be called | 307 | Setting timeout and notifications. @code{mailbox_scan} can be called |
219 | periodically to see if new messages have arrived, if the number of | 308 | periodically to see if new messages have arrived, if the number of |
220 | total messages has changed the notification function is called. By default | 309 | total messages has changed the notification function is called. By default |
... | @@ -236,7 +325,7 @@ Not Implemented. | ... | @@ -236,7 +325,7 @@ Not Implemented. |
236 | Not Implemented. | 325 | Not Implemented. |
237 | @end deftypefun | 326 | @end deftypefun |
238 | 327 | ||
239 | @subsubsection Registration and Type | 328 | @section Registration and Type |
240 | 329 | ||
241 | Mailbox_t comes with a certain number of builtin types, you can query them | 330 | Mailbox_t comes with a certain number of builtin types, you can query them |
242 | or add you own to the list. | 331 | or add you own to the list. |
... | @@ -270,45 +359,45 @@ Add a mailbox @var{mtype} to the list of builtin. | ... | @@ -270,45 +359,45 @@ Add a mailbox @var{mtype} to the list of builtin. |
270 | Remove a mailbox @var{mtype} to the list of builtin. | 359 | Remove a mailbox @var{mtype} to the list of builtin. |
271 | @end deftypefun | 360 | @end deftypefun |
272 | 361 | ||
273 | @deftypefun int mailbox_get_type (struct mailbox_type **@var{mtype}, int @var{id}) | 362 | @deftypefun int mailbox_get_type (struct mailbox_type **@var{mtype}, int @var{urlid}) |
274 | Base ont the URL @var{id} return the mailbox_type. | 363 | Base on the URL @var{urlid} return the mailbox_type. |
275 | @end deftypefun | 364 | @end deftypefun |
276 | 365 | ||
277 | @deftypefun int mailbox_get_name (mailbox_t @var{mbx}, int *@var{id}, char *@var{name}, size_t @var{len}, size_t *@var{n}) | 366 | @deftypefun int mailbox_get_name (mailbox_t @var{mbx}, int *@var{mbxid}, char *@var{name}, size_t @var{len}, size_t *@var{n}) |
278 | Return the name of mailbox identify by @var{id}, in buffer @var{name} of size | 367 | Return the name of mailbox identify by @var{mbxid}, in buffer @var{name} of |
279 | @var{len}. The number of byte is put in @var{n}. | 368 | size @var{len}. The number of byte is put in @var{n}. |
280 | @end deftypefun | 369 | @end deftypefun |
281 | 370 | ||
282 | @deftypefun int mailbox_get_mname (mailbox_t, int *id, char **name, size_t *n) | 371 | @deftypefun int mailbox_get_mname (mailbox_t @var{mbx}, int *@var{mbxid}, char **@var{name}, size_t *@var{n}) |
283 | Return the name of mailbox identify by @var{id}, in a @code{malloc(3)} buffer | 372 | Return the name of mailbox identify by @var{mbxid}, in a @code{malloc(3)} |
284 | @var{name} of size @var{n}. | 373 | buffer @var{name} of size @var{n}. |
285 | @end deftypefun | 374 | @end deftypefun |
286 | 375 | ||
287 | All mailbox implementations provide this minimum set of the API. | 376 | All mailbox implementations provide this minimum set of the API. |
288 | 377 | ||
289 | @subsection Unix Mbox | 378 | @section Unix Mbox |
290 | @cindex Unix Mbox | 379 | @cindex Unix Mbox |
291 | 380 | ||
292 | TODO: describe particularities : | 381 | TODO: describe particularities : |
293 | locking policy, appending envelope, describe the flags use in _open(..), etc... | 382 | locking policy, appending envelope, describe the flags use in _open(..), etc... |
294 | 383 | ||
295 | @subsection POP3 Mbox | 384 | @section POP3 Mbox |
296 | @cindex POP3 Mbox | 385 | @cindex POP3 Mbox |
297 | 386 | ||
298 | TODO: describe timeout policies, describe the flags use in _open(..), | 387 | TODO: describe timeout policies, describe the flags use in _open(..), |
299 | describe different authorisation supported. | 388 | describe different authorisation supported. |
300 | 389 | ||
301 | @subsection IMAP Mbox | 390 | @section IMAP Mbox |
302 | @cindex IMAP Mbox | 391 | @cindex IMAP Mbox |
303 | 392 | ||
304 | Not implemented. | 393 | Not implemented. |
305 | 394 | ||
306 | @subsection QMail Mbox | 395 | @section QMail Mbox |
307 | @cindex QMail Mbox | 396 | @cindex QMail Mbox |
308 | 397 | ||
309 | Not implemented. | 398 | Not implemented. |
310 | 399 | ||
311 | @subsection MMDF Mbox | 400 | @section MMDF Mbox |
312 | @cindex MMDF Mbox | 401 | @cindex MMDF Mbox |
313 | 402 | ||
314 | Not implemented. | 403 | Not implemented. | ... | ... |
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,30 +100,60 @@ by the Foundation. | ... | @@ -100,30 +100,60 @@ 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. |
109 | * Headers:: Headers API. | 108 | * Message:: Message API. |
110 | * Mime:: Mime API. | 109 | * Body:: Body API. |
111 | * Encoding:: Encoding API. | 110 | * Headers:: Headers API. |
112 | * Reporting Bugs:: Reporting Bugs. | 111 | * Mime:: Mime API. |
113 | * Acknowledgement:: Thanks and Credits. | 112 | * Encoding:: Encoding API. |
114 | * Concept Index:: Topics in this Manual. | 113 | * Reporting Bugs:: Reporting Bugs. |
115 | * Index:: All @sc{Mailutils} Functions. | 114 | * Acknowledgement:: Thanks and Credits. |
115 | * Concept Index :: | ||
116 | * Index:: All @sc{Mailutils} Functions. | ||
116 | @end menu | 117 | @end menu |
117 | 118 | ||
118 | @node Introduction, Mailbox, Top, Top | 119 | @node Introduction, Mailbox, Top, Top |
119 | @comment node-name, next, previous, up | 120 | @comment node-name, next, previous, up |
120 | @chapter Introduction | 121 | @chapter Introduction |
121 | @cindex Introduction | 122 | @cindex Introduction |
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 | ||
187 | Jakob Kaivo @email{jkaivo@@ndn.net}, | 231 | In no particular order, |
188 | Jeff Bailey @email{jbailey@@gnu.org}, | 232 | Jakob Kaivo @email{jkaivo@@ndn.net}, |
189 | Sean Perry @email{shaleh@@debian.org}, | 233 | Jeff Bailey @email{jbailey@@gnu.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