1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
/*
* libEtPan! -- a mail stuff library
*
* Copyright (C) 2001, 2005 - DINH Viet Hoa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the libEtPan! project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* $Id$
*/
#include <libetpan/mailmessage_types.h>
#ifndef MAILMESSAGE_H
#define MAILMESSAGE_H
#ifdef __cplusplus
extern "C" {
#endif
/*
mailmessage_new
This function will initializes a new empty message.
@return a new empty message will be returned.
*/
mailmessage * mailmessage_new(void);
/*
mailmessage_free
This function will release the memory used by this message.
*/
void mailmessage_free(mailmessage * info);
/*
mailmessage_init
This function will initializes a mailmessage structure
with a message from a given session.
@param msg_info This is the message to initialize.
@param session This is the source session of the message. It
can be NULL if the message does not get the information
through the session.
@param driver This is the driver to use for the message.
@param index This is the message number in the session. 0 can
be given if the message is not attached to a session.
@param size is an optional parameter, 0 can be given.
This is informational. This is the size of message content.
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error
*/
int mailmessage_init(mailmessage * msg_info,
mailsession * session,
mailmessage_driver * driver,
uint32_t index, size_t size);
/*
mailmessage_flush
This function will release all the temporary resources that are not
necessary to use the mailmessage structure from memory. These
resources are for example cached information, such as the MIME
structure.
@param info is the message to clean.
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error. We can assume that MAIL_NO_ERROR is always returned.
*/
int mailmessage_flush(mailmessage * info);
/*
mailmessage_check
This function will notify the new value of the flags to the session,
it must be called before mailsession_check_folder() in case the flags have
been changed.
@param info is the message to checkpoint.
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error. We can assume that MAIL_NO_ERROR is always returned.
*/
int mailmessage_check(mailmessage * info);
/*
mailmessage_fetch_result_free
This function releases the memory used by a message returned
by any of the fetch function that returns a (char *).
@param msg_info is the message which the given buffer is from.
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error. We can assume that MAIL_NO_ERROR is always returned.
*/
int mailmessage_fetch_result_free(mailmessage * msg_info,
char * msg);
/*
mailmessage_fetch
This function returns the content of the message (headers and text).
@param msg_info is the message from which we want to fetch information.
@param result The content of the message is returned in (* result)
@param result_len The length of the returned string is stored
in (* result_len).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch(mailmessage * msg_info,
char ** result,
size_t * result_len);
/*
mailmessage_fetch_header
This function returns the header of the message as a string.
@param msg_info is the message from which we want to fetch information.
@param result The header of the message is returned in (* result)
@param result_len The length of the returned string is stored
in (* result_len).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch_header(mailmessage * msg_info,
char ** result,
size_t * result_len);
/*
mailmessage_fetch_body
This function returns the content of the message (without headers).
@param msg_info is the message from which we want to fetch information.
@param result The message text (without headers) is returned
in (* result)
@param result_len The length of the returned string is stored
in (* result_len).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch_body(mailmessage * msg_info,
char ** result, size_t * result_len);
/*
mailmessage_fetch_size
This function returns the size of the message content.
@param msg_info is the message from which we want to fetch information.
@param result The length of the message content is stored in (* result).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch_size(mailmessage * msg_info,
size_t * result);
/*
mailmessage_get_bodystructure
This functions returns the MIME structure of the message.
The returned information MUST not be freed by hand. It is freed by
mailmessage_flush() or mailmessage_free().
@param msg_info is the message from which we want to fetch information.
@param result The MIME structure is stored in (* result).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_get_bodystructure(mailmessage * msg_info,
struct mailmime ** result);
/*
mailmessage_fetch_section
This function returns the content of a MIME part.
@param msg_info is the message from which we want to fetch information.
@param mime is the MIME part identifier.
@param result The content is returned in (* result)
@param result_len The length of the returned string is stored
in (* result_len).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch_section(mailmessage * msg_info,
struct mailmime * mime,
char ** result, size_t * result_len);
/*
mailmessage_fetch_section_header
This function returns the header of the message contained
in the given MIME part.
@param msg_info is the message from which we want to fetch information.
@param mime is the MIME part identifier.
@param result The header is returned in (* result)
@param result_len The length of the returned string is stored
in (* result_len).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch_section_header(mailmessage * msg_info,
struct mailmime * mime,
char ** result,
size_t * result_len);
/*
mailmessage_fetch_section_mime
This function returns the MIME header of the given MIME part.
@param msg_info is the message from which we want to fetch information.
@param mime is the MIME part identifier.
@param result The MIME header is returned in (* result)
@param result_len The length of the returned string is stored
in (* result_len).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch_section_mime(mailmessage * msg_info,
struct mailmime * mime,
char ** result,
size_t * result_len);
/*
mailmessage_fetch_section_body
This function returns the text part of the message contained
in the given MIME part.
@param msg_info is the message from which we want to fetch information.
@param mime is the MIME part identifier.
@param result The message text is returned in (* result)
@param result_len The length of the returned string is stored
in (* result_len).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch_section_body(mailmessage * msg_info,
struct mailmime * mime,
char ** result,
size_t * result_len);
/*
mailmessage_fetch_envelope
This function returns a list of parsed fields of the message,
chosen by the driver.
The returned structure must be freed with mailimf_fields_free().
@param msg_info is the message from which we want to fetch information.
@param result The headers list is returned in (* result)
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_fetch_envelope(mailmessage * msg_info,
struct mailimf_fields ** result);
/*
mailmessage_get_flags
This function returns the flags related to the message.
The returned information MUST not be freed by hand. It is freed by
mailmessage_free().
@param msg_info is the message from which we want to fetch information.
@param result The flags are stored in (* result).
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
int mailmessage_get_flags(mailmessage * msg_info,
struct mail_flags ** result);
/*
mailmessage_resolve_single_fields
This function will use the fields information to fill the single_fields
structure in the mailmessage structure.
@param msg_info This is the msg_info to process.
@return MAIL_NO_ERROR is returned on success, MAIL_ERROR_XXX is returned
on error.
*/
void mailmessage_resolve_single_fields(mailmessage * msg_info);
#ifdef __cplusplus
}
#endif
#endif
|