headers.texi mailbox.texi mailer.texi mailutils.texi
sfrom.c.texi url.texi updated.
Showing
6 changed files
with
348 additions
and
60 deletions
1 | So far we plan support for RFC822 and RFC1522; | 1 | So far we plan support for RFC822 and plan for RFC1522. with RFC1522 non ASCII |
2 | characters will be encoded. | ||
3 | |||
4 | @subsubsection Init/Destroy | ||
5 | The header should be initiliaze before any use. | ||
2 | 6 | ||
3 | @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}) |
4 | 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 |
5 | 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 |
6 | supported. | 10 | supported. |
7 | @end deftypefun | 11 | @end deftypefun |
12 | |||
13 | @defmac MU_HDR_RFC822 | ||
14 | Supports rfc 822, header style. | ||
15 | @end defmac | ||
16 | |||
17 | @defmac MU_HDR_RFC1522 | ||
18 | Supports rfc 1522, encoding policy. | ||
19 | @end defmac | ||
20 | |||
8 | @deftypefun void header_destroy (header_t *@var{hdr}) | 21 | @deftypefun void header_destroy (header_t *@var{hdr}) |
9 | The ressources allocate for @var{hdr} or freed. | 22 | The ressources allocate for @var{hdr} or freed. |
10 | @end deftypefun | 23 | @end deftypefun |
... | @@ -15,6 +28,87 @@ Set the field-name @var{fn} to field-value @var{fv} of size @var{n} in | ... | @@ -15,6 +28,87 @@ Set the field-name @var{fn} to field-value @var{fv} of size @var{n} in |
15 | it is append. | 28 | it is append. |
16 | @end deftypefun | 29 | @end deftypefun |
17 | 30 | ||
31 | Some basic macros is already provided for rfc822. | ||
32 | |||
33 | @defmac MU_HDR_UNIX_FROM | ||
34 | "From " | ||
35 | @end defmac | ||
36 | @defmac MU_HDR_RETURN_PATH | ||
37 | "Return-Path" | ||
38 | @end defmac | ||
39 | @defmac MU_HDR_RECEIVED | ||
40 | "Received" | ||
41 | @end defmac | ||
42 | @defmac MU_HDR_DATE | ||
43 | "Date" | ||
44 | @end defmac | ||
45 | @defmac MU_HDR_FROM | ||
46 | "From" | ||
47 | @end defmac | ||
48 | @defmac MU_HDR_RESENT_FROM | ||
49 | "Resent-From" | ||
50 | @end defmac | ||
51 | @defmac MU_HDR_SUBJECT | ||
52 | "Subject" | ||
53 | @end defmac | ||
54 | @defmac MU_HDR_SENDER | ||
55 | "Sender" | ||
56 | @end defmac | ||
57 | @defmac MU_HDR_RESENT_SENDER | ||
58 | "Resent-SENDER" | ||
59 | @end defmac | ||
60 | @defmac MU_HDR_TOs | ||
61 | "To" | ||
62 | @end defmac | ||
63 | @defmac MU_HDR_RESENT_TO | ||
64 | "Resent-To" | ||
65 | @end defmac | ||
66 | @defmac MU_HDR_CC | ||
67 | "Cc" | ||
68 | @end defmac | ||
69 | @defmac MU_HDR_RESENT_CC | ||
70 | "Resent-Cc" | ||
71 | @end defmac | ||
72 | @defmac MU_HDR_BCC | ||
73 | "Bcc" | ||
74 | @end defmac | ||
75 | @defmac MU_HDR_RESENT_BCC | ||
76 | "Resent-Bcc" | ||
77 | @end defmac | ||
78 | @defmac MU_HDR_REPLY_TO | ||
79 | "Reply-To" | ||
80 | @end defmac | ||
81 | @defmac MU_HDR_RESENT_REPLY_TO | ||
82 | "Resent-Reply-To" | ||
83 | @end defmac | ||
84 | @defmac MU_HDR_MESSAGE_ID | ||
85 | "Message-ID" | ||
86 | @end defmac | ||
87 | @defmac MU_HDR_RESENT_MESSAGE_ID | ||
88 | "Resent-Message-ID" | ||
89 | @end defmac | ||
90 | @defmac MU_HDR_IN_REPLY_TO | ||
91 | "In-Reply-To" | ||
92 | @end defmac | ||
93 | @defmac MU_HDR_ENCRYPTED | ||
94 | "Encrypted" | ||
95 | @end defmac | ||
96 | @defmac MU_HDR_PRECEDENCE | ||
97 | "Precedence" | ||
98 | @end defmac | ||
99 | @defmac MU_HDR_STATUS | ||
100 | "Status" | ||
101 | @end defmac | ||
102 | @defmac MU_HDR_CONTENT_LENGTH | ||
103 | "Content-Length" | ||
104 | @end defmac | ||
105 | @defmac MU_HDR_CONTENT_TYPE | ||
106 | "Content-Type" | ||
107 | @end defmac | ||
108 | @defmac MU_HDR_MIME_VERSION | ||
109 | "MIME-Version" | ||
110 | @end defmac | ||
111 | |||
18 | @deftypefun int header_get_value (header_t @var{hdr}, const char *fn, char *fv, size_t len, size_t *n) | 112 | @deftypefun int header_get_value (header_t @var{hdr}, const char *fn, char *fv, size_t len, size_t *n) |
19 | Value of field-name @var{fn} is return in buffer @var{fv} of size @var{len}. | 113 | Value of field-name @var{fn} is return in buffer @var{fv} of size @var{len}. |
20 | The number of bytes written is put in @var{n}. | 114 | The number of bytes written is put in @var{n}. | ... | ... |
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 a 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, scaning ... 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. | 8 | otherwise. Unless specity otherwise. |
9 | 9 | ||
10 | @subsubsection Init/Destroy | ||
10 | Initializing and destroying a mailbox_t object. | 11 | Initializing and destroying a mailbox_t object. |
11 | 12 | ||
12 | @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}) |
... | @@ -17,41 +18,68 @@ will be use instead of doing heuristic search on the @var{url}. | ... | @@ -17,41 +18,68 @@ will be use instead of doing heuristic search on the @var{url}. |
17 | 18 | ||
18 | @deftypefun int mailbox_destroy (mailbox_t *@var{mbx}) | 19 | @deftypefun int mailbox_destroy (mailbox_t *@var{mbx}) |
19 | All ressources allocated is release if the stream is not open, | 20 | All ressources allocated is release if the stream is not open, |
20 | @code{mailbox_close()} is call. | 21 | @code{mailbox_close} is call. |
21 | @end deftypefun | 22 | @end deftypefun |
22 | 23 | ||
24 | @subsubsection Open/Close | ||
23 | Opening and closing mailbox can be done any number of times. But be warn | 25 | Opening and closing mailbox can be done any number of times. But be warn |
24 | on some cases like POP3, when opening, the lock can be persistent until | 26 | on some cases like POP3, when opening, the lock can be persistent until |
25 | the stream is close as required by the RFC. | 27 | the stream is close as required by the RFC. |
26 | 28 | ||
27 | @deftypefun int mailbox_open (mailbox_t @var{mbx}, int @var{flag}) | 29 | @deftypefun int mailbox_open (mailbox_t @var{mbx}, int @var{flag}) |
28 | Open the mailbox box stream. This funtion will call @code{mailbox_scan()}. | 30 | Open the mailbox box stream. This funtion will call @code{mailbox_scan}. |
29 | @end deftypefun | 31 | @end deftypefun |
30 | 32 | ||
33 | @defmac MU_MB_RDONLY | ||
34 | Stream is open read-only. | ||
35 | @end defmac | ||
36 | @defmac MU_MB_WRONLY | ||
37 | Stream is open write-only. | ||
38 | @end defmac | ||
39 | @defmac MU_MB_RDWR | ||
40 | Stream is open read-write. | ||
41 | @end defmac | ||
42 | @defmac MU_MB_CREAT | ||
43 | If file does not exist it is created. Maybe a noop on remote hosts mailbox. | ||
44 | @end defmac | ||
45 | @defmac MU_MB_APPEND | ||
46 | The stream is open in append mode. | ||
47 | @end defmac | ||
48 | @defmac MU_MB_ONONBLOCK | ||
49 | For sockets, open() nonblocking. | ||
50 | @end defmac | ||
51 | |||
31 | @deftypefun int mailbox_close (mailbox_t @var{mbx}) | 52 | @deftypefun int mailbox_close (mailbox_t @var{mbx}) |
32 | Close the streams and release the locks. | 53 | Close the streams and release the locks. |
33 | @end deftypefun | 54 | @end deftypefun |
34 | 55 | ||
56 | @subsubsection Deletion | ||
35 | Message can be mark for deletion but the action of removing them is only | 57 | Message can be mark for deletion but the action of removing them is only |
36 | taken when calling @code{mailbox_expunge()}. | 58 | taken when calling @code{mailbox_expunge}. |
37 | 59 | ||
38 | @deftypefun int mailbox_delete (mailbox_t @var{mbx}, size_t @var{msgno}) | 60 | @deftypefun int mailbox_delete (mailbox_t @var{mbx}, size_t @var{msgno}) |
39 | Mark @var{msgno} for deletion. | 61 | Mark message @var{msgno} for deletion. |
40 | @end deftypefun | 62 | @end deftypefun |
41 | 63 | ||
42 | @deftypefun int mailbox_undelete (mailbox_t @var{mbx}, size_t @var{msgno}) | 64 | @deftypefun int mailbox_undelete (mailbox_t @var{mbx}, size_t @var{msgno}) |
43 | UnMark @var{msgno} for deletion. | 65 | UnMark message @var{msgno} for deletion. |
44 | @end deftypefun | 66 | @end deftypefun |
45 | 67 | ||
46 | @deftypefun int mailbox_is_deleted (mailbox_t @var{mbx}, size_t @var{msgno}) | 68 | @deftypefun int mailbox_is_deleted (mailbox_t @var{mbx}, size_t @var{msgno}) |
47 | Return 1 if @var{msgno} is mark deleted. | 69 | Return 1 if message @var{msgno} is mark deleted. |
48 | @end deftypefun | 70 | @end deftypefun |
49 | 71 | ||
50 | @deftypefun int mailbox_expunge (mailbox_t @var{mbx}) | 72 | @deftypefun int mailbox_expunge (mailbox_t @var{mbx}) |
51 | All msgs marked for deletion will be remove and the mailbox updated. | 73 | All messages marked for deletion will be remove and the mailbox updated. |
74 | @end deftypefun | ||
75 | |||
76 | @deftypefun int mailbox_num_deleted (mailbox_t @var{mbx}) | ||
77 | Return the number of Mailbox mark to be delete. | ||
52 | @end deftypefun | 78 | @end deftypefun |
53 | 79 | ||
80 | @subsubsection New Message | ||
54 | Certain mailboxes allow to append new messages to the existing folder. | 81 | Certain mailboxes allow to append new messages to the existing folder. |
82 | The stream must be @code{mailbox_open} with the proper permission. | ||
55 | 83 | ||
56 | @deftypefun int mailbox_create_envelope (mailbox_t @var{mbx}, size_t *@var{msgno}) | 84 | @deftypefun int mailbox_create_envelope (mailbox_t @var{mbx}, size_t *@var{msgno}) |
57 | Create an envelope, @var{msgno} will contain a uniq number for this envelope. | 85 | Create an envelope, @var{msgno} will contain a uniq number for this envelope. |
... | @@ -68,16 +96,19 @@ Fill the body of new envelope @var{msgno}. If @var{replace} is zero the buffer | ... | @@ -68,16 +96,19 @@ Fill the body of new envelope @var{msgno}. If @var{replace} is zero the buffer |
68 | @var{body} will be append, otherwise it will overwrite any existing one. | 96 | @var{body} will be append, otherwise it will overwrite any existing one. |
69 | @end deftypefun | 97 | @end deftypefun |
70 | 98 | ||
71 | @deftypefun int mailbox_append (mailbox_t @var{mbx}, size_t @var{msgno}) | 99 | @deftypefun int mailbox_append (mailbox_t @var{mbx}, size_t @var{msgno}, int @var{destroy}) |
72 | @var{msgno} given from @code{mailbox_new_message()} will be append to | 100 | @var{msgno} given from @code{mailbox_envelope} will be append to |
73 | the mailbox. | 101 | the mailbox. When appending the header may be modified. In the case of |
102 | Unix Mbox, the header "From " is prepend. If @var{destroy} is set non-zero | ||
103 | @code{mailbox_destroy_envelope} will be call after delivery. | ||
74 | @end deftypefun | 104 | @end deftypefun |
75 | 105 | ||
76 | @deftypefun int mailbox_destroy_envelope (mailbox_t @var{mbx}, size_t @var{msgno}) | 106 | @deftypefun int mailbox_destroy_envelope (mailbox_t @var{mbx}, size_t @var{msgno}) |
77 | Ressources allocated to envelope @var{msgno} will be release. This function | 107 | Ressources allocated to envelope @var{msgno} will be release. This function |
78 | should be call after @code{mailbox_append()}. | 108 | should be call after @code{mailbox_append}. |
79 | @end deftypefun | 109 | @end deftypefun |
80 | 110 | ||
111 | @subsubsection Reading | ||
81 | Reading the message body and header. | 112 | Reading the message body and header. |
82 | 113 | ||
83 | @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}) | 114 | @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}) |
... | @@ -85,27 +116,30 @@ Read the body of message @var{msgno} starting at offset @var{off} in | ... | @@ -85,27 +116,30 @@ Read the body of message @var{msgno} starting at offset @var{off} in |
85 | @var{buffer} of size @var{len}. The number of byte read is return in | 116 | @var{buffer} of size @var{len}. The number of byte read is return in |
86 | @var{nread}. | 117 | @var{nread}. |
87 | @end deftypefun | 118 | @end deftypefun |
119 | |||
88 | @deftypefun int mailbox_get_mbody (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read}) | 120 | @deftypefun int mailbox_get_mbody (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read}) |
89 | A buffer allocate with @code{malloc()} is return containing the body of | 121 | A buffer allocate with @code{malloc(3)} is return containing the body of |
90 | message @var{msgno} starting at offset @var{off} in @var{buffer}. | 122 | message @var{msgno} starting at offset @var{off} in @var{buffer}. |
91 | The number of byte read is return in @var{nread}. | 123 | The number of byte read is return in @var{nread}. |
92 | @end deftypefun | 124 | @end deftypefun |
93 | 125 | ||
94 | @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}) | 126 | @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}) |
95 | Read the header of message @var{msgno} starting at offset @var{off} in | 127 | Read the header of message @var{msgno} starting at offset @var{off} in |
96 | @var{buffer} of size @var{len}. The number of byte read is return in | 128 | @var{buffer} of size @var{len}. The number of byte read is return |
97 | @var{nread}. | 129 | in @var{nread}. |
98 | @end deftypefun | 130 | @end deftypefun |
131 | |||
99 | @deftypefun int mailbox_get_mheader (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read}) | 132 | @deftypefun int mailbox_get_mheader (mailbox_t @var{mbx}, size_t @var{msgno}, off_t @var{off}, char **@var{buffer}, size_t *@var{read}) |
100 | A buffer allocate with @code{malloc()} is return containing the header of | 133 | A buffer allocate with @code{malloc(3)} is return containing the header of |
101 | message @var{msgno} starting at offset @var{off} in @var{buffer}. | 134 | message @var{msgno} starting at offset @var{off} in @var{buffer}. |
102 | The number of byte read is return in @var{nread}. | 135 | The number of byte read is return in @var{nread}. |
103 | @end deftypefun | 136 | @end deftypefun |
104 | 137 | ||
105 | Most mailbox provides locking before changing there content. functions | 138 | @subsubsection Locking |
106 | will grab the lock before doing any destructive action. They are also | 139 | Most mailbox provides locking before changing the content. Functions |
107 | provide here for accesssing the folder outside the API in that case the | 140 | will grab the lock before doing any destructive action. The Locking functions |
108 | lock should be grab and unlock. There is also another level of internal | 141 | are provided for accesssing the folder outside the API, in that case the |
142 | lock should be grab and release. There is also another level of internal | ||
109 | locking to provide synchronisation to the mailbox_t object. | 143 | locking to provide synchronisation to the mailbox_t object. |
110 | 144 | ||
111 | @deftypefun int mailbox_lock (mailbox_t @var{mbx}, int @var{flag}) | 145 | @deftypefun int mailbox_lock (mailbox_t @var{mbx}, int @var{flag}) |
... | @@ -113,23 +147,70 @@ Grab the lock. In some case, i.e Unix mbox this may involve creating | ... | @@ -113,23 +147,70 @@ Grab the lock. In some case, i.e Unix mbox this may involve creating |
113 | a .lock file in the spool directory. | 147 | a .lock file in the spool directory. |
114 | @end deftypefun | 148 | @end deftypefun |
115 | 149 | ||
150 | @defmac MU_MB_RDLOCK | ||
151 | Read lock. | ||
152 | @end defmac | ||
153 | @defmac MU_MB_WRLOCK | ||
154 | Write lock. | ||
155 | @end defmac | ||
156 | @defmac MU_MB_RWLOCK | ||
157 | Read/Write lock. | ||
158 | @end defmac | ||
159 | |||
160 | Note on many mailbox, RDLOCK is a noop. | ||
161 | |||
116 | @deftypefun int mailbox_unlock (mailbox_t @var{mbx}) | 162 | @deftypefun int mailbox_unlock (mailbox_t @var{mbx}) |
117 | Release the lock. | 163 | Release the lock. |
118 | @end deftypefun | 164 | @end deftypefun |
119 | 165 | ||
166 | @subsubsection Owner/Group | ||
167 | Most mailbox provides locking before changing there content. functions | ||
120 | Ownership and group. When creating certain mailbox, you can set the | 168 | Ownership and group. When creating certain mailbox, you can set the |
121 | owner/group. | 169 | owner/group. |
122 | 170 | ||
123 | @deftypefun int mailbox_set_owner (mailbox_t @var{mbx}, uid_t @var{uid}) | 171 | @deftypefun int mailbox_set_owner (mailbox_t @var{mbx}, uid_t @var{uid}) |
124 | Set the owner to @var{uid}. If the Mailbox was not @code{mailbox_open()} | 172 | Set the owner to @var{uid}. If the Mailbox was not @code{mailbox_open} |
125 | the action is delayed until the stream is open. | 173 | the action is delayed until the stream is open. |
126 | @end deftypefun | 174 | @end deftypefun |
127 | @deftypefun int mailbox_set_group (mailbox_t @var{mbx}, gid_t @var{gid}) | 175 | @deftypefun int mailbox_set_group (mailbox_t @var{mbx}, gid_t @var{gid}) |
128 | Set the group to @var{gid}. If the Mailbox was not @code{mailbox_open()} | 176 | Set the group to @var{gid}. If the Mailbox was not @code{mailbox_open} |
129 | the action is delayed until the stream is open. | 177 | the action is delayed until the stream is open. |
130 | @end deftypefun | 178 | @end deftypefun |
131 | 179 | ||
132 | Setting timeout and notifications. | 180 | @subsubsection Scanning |
181 | |||
182 | Scan is done explexitely on @code{mailbox_open}. | ||
183 | |||
184 | @deftypefun int mailbox_scan (mailbox_t @var{mbx}, size_t *@var{msgs}) | ||
185 | The mailbox is parse and @var{msgs} if not NULL contain the message count. | ||
186 | @end deftypefun | ||
187 | |||
188 | @deftypefun int mailbox_scan_progress (mailbox_t @var{mbx}, int (*@var{progress}) (mailbox_t @var{mbx}, int @var{count}, void *@var{arg}), void *@var{arg}) | ||
189 | When doing @var{mailbox_scan}, function @var{progress}(@var{mbx}, @var{count}, | ||
190 | @var{arg}) is call for each new message. | ||
191 | @end deftypefun | ||
192 | |||
193 | @deftypefun int mailbox_is_updated (mailbox_t @var{mbx}) | ||
194 | Return 1 if @var{mbx} is up to date 0 otherwise. | ||
195 | @end deftypefun | ||
196 | |||
197 | @deftypefun int mailbox_size (mailbox_t @var{mbx}, offt_t *@var{size}) | ||
198 | @var{size} is assign the mailbox total size. | ||
199 | @end deftypefun | ||
200 | |||
201 | @deftypefun int mailbox_get_size (mailbox_t @var{mbx}, size_t @var{msgno}, size_t *@var{header}, size_t *@var{body}) | ||
202 | For message @var{msgno} set @var{header} size and @var{body} size. | ||
203 | @end deftypefun | ||
204 | |||
205 | @deftypefun int mailbox_count (mailbox_t @var{mbx}) | ||
206 | Return the number of messages in @var{mbx}. | ||
207 | @end deftypefun | ||
208 | |||
209 | @subsubsection Timeout/Notification | ||
210 | Setting timeout and notifications. @code{mailbox_scan} can be call | ||
211 | periodically to see if new messages have arrive, if the number of | ||
212 | total messages have change the notification function is call. By default | ||
213 | they are disable. | ||
133 | 214 | ||
134 | @deftypefun int mailbox_set_timeout (mailbox_t @var{mbx}, size_t @var{millis}) | 215 | @deftypefun int mailbox_set_timeout (mailbox_t @var{mbx}, size_t @var{millis}) |
135 | Not Implemented. | 216 | Not Implemented. |
... | @@ -143,48 +224,71 @@ Not Implemented. | ... | @@ -143,48 +224,71 @@ Not Implemented. |
143 | @deftypefun int mailbox_get_refresh (mailbox_t @var{mbx}, size_t @var{millis}) | 224 | @deftypefun int mailbox_get_refresh (mailbox_t @var{mbx}, size_t @var{millis}) |
144 | Not Implemented. | 225 | Not Implemented. |
145 | @end deftypefun | 226 | @end deftypefun |
146 | @deftypefun int mailbox_set_notification (mailbox_t @var{mbx}, ...) | 227 | @deftypefun int mailbox_set_notification (mailbox_t @var{mbx}, int (*@var{notification}) (mailbox_t @var{mbx}, void *@var{arg}), void *@var{arg}) |
147 | Not Implemented. | 228 | Not Implemented. |
148 | @end deftypefun | 229 | @end deftypefun |
149 | 230 | ||
231 | @subsubsection Registration and Type | ||
232 | |||
233 | Mailbox_t comes with a certain number of builtin types, you can query them | ||
234 | or add you own to the list. | ||
235 | |||
236 | @deftp {Data type} struct mailbox_type | ||
237 | @example | ||
238 | @{ | ||
239 | char *name; | ||
240 | int id; | ||
241 | struct url_type *utype; | ||
242 | int (*_init) __P ((mailbox_t *, const char *name)); | ||
243 | void (*_destroy) __P ((mailbox_t *)); | ||
244 | @}; | ||
245 | @end example | ||
246 | @end deftp | ||
247 | |||
248 | @deftypefun int mailbox_list_type (struct mailbox_type *@var{mtype}, size_t @var{len}, size_t *@var{n}) | ||
249 | The @var{mtype} array will be initialize with the list of builtin up to | ||
250 | @var{len}. The number of struct maiblox_type is put in @var{n}. | ||
251 | @end deftypefun | ||
150 | 252 | ||
151 | Instead of providing different functions to create a mailbox_t the | 253 | @deftypefun int mailbox_list_mtype (struct mailbox_type **@var{mtype}, size_t *@var{n}) |
152 | information is encoded in the form of a URL. | 254 | An array of size @var{n} is @code{malloc(3)} to hold the builtin list. |
255 | @end deftypefun | ||
256 | |||
257 | @deftypefun int mailbox_add_type (struct mailbox_type *@var{mtype}) | ||
258 | Add a mailbox @var{mtype} to the list of builtin. | ||
259 | @end deftypefun | ||
260 | |||
261 | @deftypefun int mailbox_remove_type (struct mailbox_type *@var{mtype}) | ||
262 | Remove a mailbox @var{mtype} to the list of builtin. | ||
263 | @end deftypefun | ||
153 | 264 | ||
154 | @table @samp | 265 | @deftypefun int mailbox_get_type (struct mailbox_type **@var{mtype}, int @var{id}) |
155 | @item POP3 Post Office Protocol, Not Implemented. | 266 | Base ont the URL @var{id} return the mailbox_type. |
156 | pop://<user>;AUTH=<auth>@@<host>:<port> | 267 | @end deftypefun |
157 | @item IMAP, not implemented | ||
158 | imap:// | ||
159 | @item QMAIL, not implemented | ||
160 | qmail:// | ||
161 | @item Unix mbox | ||
162 | file:// | ||
163 | @item MMDF, not implemented | ||
164 | mmdf:// | ||
165 | @item SMail, not implemented | ||
166 | smail:// | ||
167 | @end table | ||
168 | 268 | ||
169 | The URL will contain the necessary information to initialize @code{mailbox_t} | 269 | @deftypefun int mailbox_get_name (mailbox_t @var{mbx}, int *@var{id}, char *@var{name}, size_t @var{len}, size_t *@var{n}) |
170 | properly. | 270 | Return the name of mailbox identify by @var{id}, in buffer @var{name} of size |
271 | @var{len}. The number of byte is put in @var{n}. | ||
272 | @end deftypefun | ||
171 | 273 | ||
274 | @deftypefun int mailbox_get_mname (mailbox_t, int *id, char **name, size_t *n) | ||
275 | Return the name of mailbox identify by @var{id}, in a @code{malloc(3)} buffer | ||
276 | @var{name} of size @var{n}. | ||
277 | @end deftypefun | ||
172 | 278 | ||
173 | All mailbox implementations provide this minimum set of the API and more | 279 | All mailbox implementations provide this minimum set of the API. |
174 | if need be. | ||
175 | 280 | ||
176 | @subsection Unix Mbox | 281 | @subsection Unix Mbox |
177 | @cindex Unix Mbox | 282 | @cindex Unix Mbox |
178 | 283 | ||
179 | TODO: describe particularities and mail locking policy, | 284 | TODO: describe particularities : |
180 | describe the flags use in _open(..); | 285 | locking policy, appending envelope, describe the flags use in _open(..), etc... |
181 | 286 | ||
182 | @subsection POP3 Mbox | 287 | @subsection POP3 Mbox |
183 | @cindex POP3 Mbox | 288 | @cindex POP3 Mbox |
184 | 289 | ||
185 | TODO: describe timeout policies, | 290 | TODO: describe timeout policies, describe the flags use in _open(..), |
186 | describe the flags use in _open(..), | 291 | describe different authorisation supported. |
187 | describe Different authorisation supported. | ||
188 | 292 | ||
189 | @subsection IMAP Mbox | 293 | @subsection IMAP Mbox |
190 | @cindex IMAP Mbox | 294 | @cindex IMAP Mbox | ... | ... |
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 | ||
5 | |||
6 | Initialize the mailer object. | ||
7 | |||
4 | @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}) |
5 | Not Implemented. | 9 | Not Implemented. |
6 | @end deftypefun | 10 | @end deftypefun |
7 | 11 | ||
12 | @defmac MU_ML_PROGRAM | ||
13 | Program like sendmail, mail, mailx to deliver the mail | ||
14 | @end defmac | ||
15 | |||
16 | @defmac MU_ML_SMTP | ||
17 | Contact the host directly with SMTP. | ||
18 | @end defmac | ||
19 | |||
20 | @defmac MU_ML_MPP | ||
21 | Use MPP protocol. | ||
22 | @end defmac | ||
23 | |||
8 | @deftypefun int mailer_destroy (mailer_r *@var{mailer}) | 24 | @deftypefun int mailer_destroy (mailer_r *@var{mailer}) |
9 | Not Implemented. | 25 | Not Implemented. |
10 | @end deftypefun | 26 | @end deftypefun |
11 | 27 | ||
28 | @subsubsection User/Passwd | ||
29 | |||
30 | On some mailer like MMP you need to identify. | ||
31 | |||
12 | @deftypefun int mailer_user (mailer_t @var{mailer}, const char *@var{user}) | 32 | @deftypefun int mailer_user (mailer_t @var{mailer}, const char *@var{user}) |
13 | Not Implemented. | 33 | Not Implemented. |
14 | @end deftypefun | 34 | @end deftypefun |
... | @@ -17,6 +37,9 @@ Not Implemented. | ... | @@ -17,6 +37,9 @@ Not Implemented. |
17 | Not Implemented. | 37 | Not Implemented. |
18 | @end deftypefun | 38 | @end deftypefun |
19 | 39 | ||
40 | @subsubsection Open/Close | ||
41 | The mailer is spawn, if it is a program, or the host is contacted. | ||
42 | |||
20 | @deftypefun int mailer_open (mailer_t @var{mailer}, int @var{flag}) | 43 | @deftypefun int mailer_open (mailer_t @var{mailer}, int @var{flag}) |
21 | Not Implemented. | 44 | Not Implemented. |
22 | @end deftypefun | 45 | @end deftypefun |
... | @@ -25,6 +48,14 @@ Not Implemented. | ... | @@ -25,6 +48,14 @@ Not Implemented. |
25 | Not Implemented. | 48 | Not Implemented. |
26 | @end deftypefun | 49 | @end deftypefun |
27 | 50 | ||
51 | @subsubsection Sending | ||
52 | |||
53 | Sending a message. | ||
54 | |||
55 | @deftypefun int mailer_create_envelope (mailer_t @var{mailer}, size_t *) | ||
56 | Not Implemented. | ||
57 | @end deftypefun | ||
58 | |||
28 | @deftypefun int mailer_set_body (mailer_t @var{mailer}, char *, size_t) | 59 | @deftypefun int mailer_set_body (mailer_t @var{mailer}, char *, size_t) |
29 | Not Implemented. | 60 | Not Implemented. |
30 | @end deftypefun | 61 | @end deftypefun |
... | @@ -33,22 +64,26 @@ Not Implemented. | ... | @@ -33,22 +64,26 @@ Not Implemented. |
33 | Not Implemented. | 64 | Not Implemented. |
34 | @end deftypefun | 65 | @end deftypefun |
35 | 66 | ||
36 | @deftypefun int mailer_set_timeout (mailer_t @var{mailer}, size_t) | 67 | @deftypefun int mailbox_add_attachment (mailer_t, size_t msgno, const char *boundary, const char *header, FILE *file, int encoding) |
68 | @end deftypefun | ||
69 | |||
70 | @deftypefun int mailer_send_envelope (mailer_t @var{mailer}, size_t) | ||
37 | Not Implemented. | 71 | Not Implemented. |
38 | @end deftypefun | 72 | @end deftypefun |
39 | 73 | ||
40 | @deftypefun int mailer_get_timeout (mailer_t @var{mailer}, size_t) | 74 | @subsubsection Timeout |
75 | @deftypefun int mailer_set_timeout (mailer_t @var{mailer}, size_t) | ||
41 | Not Implemented. | 76 | Not Implemented. |
42 | @end deftypefun | 77 | @end deftypefun |
43 | 78 | ||
44 | @deftypefun int mailer_send_envelope (mailer_t @var{mailer}, size_t) | 79 | @deftypefun int mailer_get_timeout (mailer_t @var{mailer}, size_t) |
45 | Not Implemented. | 80 | Not Implemented. |
46 | @end deftypefun | 81 | @end deftypefun |
47 | 82 | ||
48 | 83 | ||
49 | @subsection Mailto | 84 | @subsection Mailto |
50 | @cindex Mailto | 85 | @cindex Mailto |
51 | The URL mailto: is supported. | 86 | The URL mailto: should be supported. |
52 | 87 | ||
53 | TODO: example of mailto, and mailing lists, | 88 | TODO: example of mailto, and mailing lists, |
54 | 89 | ... | ... |
... | @@ -35,7 +35,7 @@ Published by the Free Software Foundation, | ... | @@ -35,7 +35,7 @@ Published by the Free Software Foundation, |
35 | 59 Temple Place - Suite 330 | 35 | 59 Temple Place - Suite 330 |
36 | Boston, MA 02111-1307, USA | 36 | Boston, MA 02111-1307, USA |
37 | 37 | ||
38 | Copyright 1999 Free Software Foundation, Inc. | 38 | Copyright 1999, 2000 Free Software Foundation, Inc. |
39 | 39 | ||
40 | Permission is granted to make and distribute verbatim copies of | 40 | Permission is granted to make and distribute verbatim copies of |
41 | this manual provided the copyright notice and this permission notice | 41 | this manual provided the copyright notice and this permission notice | ... | ... |
... | @@ -14,9 +14,10 @@ int main (int argc, char **argv) | ... | @@ -14,9 +14,10 @@ int main (int argc, char **argv) |
14 | char buffer[1024]; | 14 | char buffer[1024]; |
15 | char from[64]; | 15 | char from[64]; |
16 | char subject[64]; | 16 | char subject[64]; |
17 | char *header; | 17 | char *mail; |
18 | mailbox_t mbox; | 18 | mailbox_t mbox; |
19 | int status, id, msg_no; | 19 | int status |
20 | size_t msgno, msg_total, size; | ||
20 | 21 | ||
21 | if (argc == 2) | 22 | if (argc == 2) |
22 | @{ | 23 | @{ |
... | @@ -28,7 +29,7 @@ int main (int argc, char **argv) | ... | @@ -28,7 +29,7 @@ int main (int argc, char **argv) |
28 | if (mail == NULL) | 29 | if (mail == NULL) |
29 | @{ | 30 | @{ |
30 | char * user = getlogin (); | 31 | char * user = getlogin (); |
31 | int len = strlen (_PATH_MAILDIR) + strlen (user) + 1; | 32 | size_t len = strlen (_PATH_MAILDIR) + strlen (user) + 1; |
32 | mail = malloc (len); | 33 | mail = malloc (len); |
33 | if (mail == NULL) | 34 | if (mail == NULL) |
34 | @{ | 35 | @{ | ... | ... |
1 | 1 | ||
2 | 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 | ||
4 | information is encoded in the form of a URL. | ||
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. | ||
23 | @subsection POP3 | ||
24 | pop://<user>;AUTH=<auth>@@<hostname>:<port> | ||
25 | |||
26 | Description of the fields and examples are needed. | ||
27 | |||
28 | @subsection IMAP | ||
29 | imap://..... | ||
30 | |||
31 | Description of the fields and examples are needed. | ||
32 | |||
33 | @subsection File | ||
34 | file://path | ||
35 | |||
36 | Description of the fields and examples are needed. | ||
37 | |||
38 | @subsection MMDF | ||
39 | mmdf://path | ||
40 | |||
41 | Description of the fields and examples are needed. | ||
42 | |||
43 | @subsection MH | ||
44 | mh://path | ||
45 | |||
46 | Description of the fields and examples are needed. | ||
47 | |||
48 | @subsection Mailto | ||
49 | mailto:// | ||
50 | |||
51 | Description of the fields and examples are needed. | ||
52 | |||
53 | @subsection mmp | ||
54 | mmp:// | ||
55 | |||
56 | Description of the fields and examples are needed. | ||
3 | 57 | ... | ... |
-
Please register or sign in to post a comment