summaryrefslogtreecommitdiffabout
path: root/libetpan/include/libetpan/mailimf.h
Unidiff
Diffstat (limited to 'libetpan/include/libetpan/mailimf.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libetpan/include/libetpan/mailimf.h347
1 files changed, 347 insertions, 0 deletions
diff --git a/libetpan/include/libetpan/mailimf.h b/libetpan/include/libetpan/mailimf.h
new file mode 100644
index 0000000..c2231dd
--- a/dev/null
+++ b/libetpan/include/libetpan/mailimf.h
@@ -0,0 +1,347 @@
1/*
2 * libEtPan! -- a mail stuff library
3 *
4 * Copyright (C) 2001, 2005 - DINH Viet Hoa
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the libEtPan! project nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32/*
33 * $Id$
34 */
35
36#ifndef MAILIMF_H
37
38#define MAILIMF_H
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#include <libetpan/mailimf_types.h>
45#include <libetpan/mailimf_write_generic.h>
46#include <libetpan/mailimf_write_file.h>
47#include <libetpan/mailimf_write_mem.h>
48#include <libetpan/mailimf_types_helper.h>
49
50#include <inttypes.h>
51#include <sys/types.h>
52
53/*
54 mailimf_message_parse will parse the given message
55
56 @param message this is a string containing the message content
57 @param length this is the size of the given string
58 @param index this is a pointer to the start of the message in
59 the given string, (* index) is modified to point at the end
60 of the parsed data
61 @param result the result of the parse operation is stored in
62 (* result)
63
64 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
65*/
66
67int mailimf_message_parse(const char * message, size_t length,
68 size_t * index,
69 struct mailimf_message ** result);
70
71/*
72 mailimf_body_parse will parse the given text part of a message
73
74 @param message this is a string containing the message text part
75 @param length this is the size of the given string
76 @param index this is a pointer to the start of the message text part in
77 the given string, (* index) is modified to point at the end
78 of the parsed data
79 @param result the result of the parse operation is stored in
80 (* result)
81
82 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
83*/
84
85int mailimf_body_parse(const char * message, size_t length,
86 size_t * index,
87 struct mailimf_body ** result);
88
89/*
90 mailimf_fields_parse will parse the given header fields
91
92 @param message this is a string containing the header fields
93 @param length this is the size of the given string
94 @param index this is a pointer to the start of the header fields in
95 the given string, (* index) is modified to point at the end
96 of the parsed data
97 @param result the result of the parse operation is stored in
98 (* result)
99
100 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
101*/
102
103int mailimf_fields_parse(const char * message, size_t length,
104 size_t * index,
105 struct mailimf_fields ** result);
106
107/*
108 mailimf_mailbox_list_parse will parse the given mailbox list
109
110 @param message this is a string containing the mailbox list
111 @param length this is the size of the given string
112 @param index this is a pointer to the start of the mailbox list in
113 the given string, (* index) is modified to point at the end
114 of the parsed data
115 @param result the result of the parse operation is stored in
116 (* result)
117
118 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
119*/
120
121int
122mailimf_mailbox_list_parse(const char * message, size_t length,
123 size_t * index,
124 struct mailimf_mailbox_list ** result);
125
126/*
127 mailimf_address_list_parse will parse the given address list
128
129 @param message this is a string containing the address list
130 @param length this is the size of the given string
131 @param index this is a pointer to the start of the address list in
132 the given string, (* index) is modified to point at the end
133 of the parsed data
134 @param result the result of the parse operation is stored in
135 (* result)
136
137 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
138*/
139
140int
141mailimf_address_list_parse(const char * message, size_t length,
142 size_t * index,
143 struct mailimf_address_list ** result);
144
145/*
146 mailimf_address_parse will parse the given address
147
148 @param message this is a string containing the address
149 @param length this is the size of the given string
150 @param index this is a pointer to the start of the address in
151 the given string, (* index) is modified to point at the end
152 of the parsed data
153 @param result the result of the parse operation is stored in
154 (* result)
155
156 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
157*/
158
159int mailimf_address_parse(const char * message, size_t length,
160 size_t * index,
161 struct mailimf_address ** result);
162
163/*
164 mailimf_mailbox_parse will parse the given address
165
166 @param message this is a string containing the mailbox
167 @param length this is the size of the given string
168 @param index this is a pointer to the start of the mailbox in
169 the given string, (* index) is modified to point at the end
170 of the parsed data
171 @param result the result of the parse operation is stored in
172 (* result)
173
174 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
175*/
176
177int mailimf_mailbox_parse(const char * message, size_t length,
178 size_t * index,
179 struct mailimf_mailbox ** result);
180
181/*
182 mailimf_date_time_parse will parse the given RFC 2822 date
183
184 @param message this is a string containing the date
185 @param length this is the size of the given string
186 @param index this is a pointer to the start of the date in
187 the given string, (* index) is modified to point at the end
188 of the parsed data
189 @param result the result of the parse operation is stored in
190 (* result)
191
192 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
193*/
194
195int mailimf_date_time_parse(const char * message, size_t length,
196 size_t * index,
197 struct mailimf_date_time ** result);
198
199/*
200 mailimf_envelope_fields_parse will parse the given fields (Date,
201 From, Sender, Reply-To, To, Cc, Bcc, Message-ID, In-Reply-To,
202 References and Subject)
203
204 @param message this is a string containing the header fields
205 @param length this is the size of the given string
206 @param index this is a pointer to the start of the header fields in
207 the given string, (* index) is modified to point at the end
208 of the parsed data
209 @param result the result of the parse operation is stored in
210 (* result)
211
212 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
213*/
214
215int mailimf_envelope_fields_parse(const char * message, size_t length,
216 size_t * index,
217 struct mailimf_fields ** result);
218
219/*
220 mailimf_ignore_field_parse will skip the given field
221
222 @param message this is a string containing the header field
223 @param length this is the size of the given string
224 @param index this is a pointer to the start of the header field in
225 the given string, (* index) is modified to point at the end
226 of the parsed data
227
228 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
229*/
230
231
232int mailimf_ignore_field_parse(const char * message, size_t length,
233 size_t * index);
234
235/*
236 mailimf_envelope_fields will parse the given fields (Date,
237 From, Sender, Reply-To, To, Cc, Bcc, Message-ID, In-Reply-To,
238 References and Subject), other fields will be added as optional
239 fields.
240
241 @param message this is a string containing the header fields
242 @param length this is the size of the given string
243 @param index this is a pointer to the start of the header fields in
244 the given string, (* index) is modified to point at the end
245 of the parsed data
246 @param result the result of the parse operation is stored in
247 (* result)
248
249 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
250*/
251
252
253int
254mailimf_envelope_and_optional_fields_parse(const char * message, size_t length,
255 size_t * index,
256 struct mailimf_fields ** result);
257
258/*
259 mailimf_envelope_fields will parse the given fields as optional
260 fields.
261
262 @param message this is a string containing the header fields
263 @param length this is the size of the given string
264 @param index this is a pointer to the start of the header fields in
265 the given string, (* index) is modified to point at the end
266 of the parsed data
267 @param result the result of the parse operation is stored in
268 (* result)
269
270 @return MAILIMF_NO_ERROR on success, MAILIMF_ERROR_XXX on error
271*/
272
273int
274mailimf_optional_fields_parse(const char * message, size_t length,
275 size_t * index,
276 struct mailimf_fields ** result);
277
278
279/* internal use, exported for MIME */
280
281int mailimf_fws_parse(const char * message, size_t length, size_t * index);
282
283int mailimf_cfws_parse(const char * message, size_t length,
284 size_t * index);
285
286int mailimf_char_parse(const char * message, size_t length,
287 size_t * index, char token);
288
289int mailimf_unstrict_char_parse(const char * message, size_t length,
290 size_t * index, char token);
291
292int mailimf_crlf_parse(const char * message, size_t length, size_t * index);
293
294int
295mailimf_custom_string_parse(const char * message, size_t length,
296 size_t * index, char ** result,
297 int (* is_custom_char)(char));
298
299int
300mailimf_token_case_insensitive_len_parse(const char * message, size_t length,
301 size_t * index, char * token,
302 size_t token_length);
303
304#define mailimf_token_case_insensitive_parse(message, length, index, token) \
305 mailimf_token_case_insensitive_len_parse(message, length, index, token, \
306 sizeof(token) - 1)
307
308int mailimf_quoted_string_parse(const char * message, size_t length,
309 size_t * index, char ** result);
310
311int
312mailimf_number_parse(const char * message, size_t length,
313 size_t * index, uint32_t * result);
314
315int mailimf_msg_id_parse(const char * message, size_t length,
316 size_t * index,
317 char ** result);
318
319int mailimf_msg_id_list_parse(const char * message, size_t length,
320 size_t * index, clist ** result);
321
322int mailimf_word_parse(const char * message, size_t length,
323 size_t * index, char ** result);
324
325int mailimf_atom_parse(const char * message, size_t length,
326 size_t * index, char ** result);
327
328int mailimf_fws_atom_parse(const char * message, size_t length,
329 size_t * index, char ** result);
330
331int mailimf_fws_word_parse(const char * message, size_t length,
332 size_t * index, char ** result);
333
334int mailimf_fws_quoted_string_parse(const char * message, size_t length,
335 size_t * index, char ** result);
336
337/* exported for IMAP */
338
339int mailimf_references_parse(const char * message, size_t length,
340 size_t * index,
341 struct mailimf_references ** result);
342
343#ifdef __cplusplus
344}
345#endif
346
347#endif