smf_message.h
Go to the documentation of this file.
1 /* spmfilter - mail filtering framework
2  * Copyright (C) 2009-2012 Axel Steiner and SpaceNet AG
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 3 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
26 #ifndef _SMF_MESSAGE_H
27 #define _SMF_MESSAGE_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <cmime.h>
34 
35 #include "smf_core.h"
36 #include "smf_email_address.h"
37 #include "smf_header.h"
38 #include "smf_list.h"
39 #include "smf_part.h"
40 
45 typedef CMimeMessage_T SMFMessage_T;
46 
51 typedef enum _SMFMultipartType {
58 
64 SMFMessage_T *smf_message_new(void);
65 
71 void smf_message_free(SMFMessage_T *message);
72 
79 void smf_message_set_sender(SMFMessage_T *message, const char *sender);
80 
87 SMFEmailAddress_T *smf_message_get_sender(SMFMessage_T *message);
88 
95 char *smf_message_get_sender_string(SMFMessage_T *message);
96 
103 void smf_message_set_message_id(SMFMessage_T *message, const char *message_id);
104 
111 char *smf_message_get_message_id(SMFMessage_T *message);
112 
118 char *smf_message_generate_message_id(void);
119 
127 int smf_message_set_header(SMFMessage_T *message, const char *header);
128 
140 int smf_message_update_header(SMFMessage_T *message, const char *header, const char *value);
141 
153 int smf_message_add_header(SMFMessage_T *message, const char *header, const char *value);
154 
162 SMFHeader_T *smf_message_get_header(SMFMessage_T *message, const char *header);
163 
170 SMFList_T *smf_message_get_headers(SMFMessage_T *message);
171 
179 int smf_message_remove_header(SMFMessage_T *message, const char *header_name);
180 
189 int smf_message_add_recipient(SMFMessage_T *message, const char *recipient, SMFEmailAddressType_T t);
190 
197 SMFList_T *smf_message_get_recipients(SMFMessage_T *message);
198 
205 void smf_message_set_content_type(SMFMessage_T *message, const char *s);
206 
213 char *smf_message_get_content_type(SMFMessage_T *message);
214 
221 void smf_message_set_content_transfer_encoding(SMFMessage_T *message, const char *s);
222 
229 char *smf_message_get_content_transfer_encoding(SMFMessage_T *message);
230 
237 void smf_message_set_content_id(SMFMessage_T *message, const char *s);
238 
245 char *smf_message_get_content_id(SMFMessage_T *message);
246 
257 void smf_message_set_mime_version(SMFMessage_T *message, const char *s);
258 
265 char *smf_message_get_mime_version(SMFMessage_T *message);
266 
273 void smf_message_set_date(SMFMessage_T *message, const char *s);
274 
281 char *smf_message_get_date(SMFMessage_T *message);
282 
289 int smf_message_set_date_now(SMFMessage_T *message);
290 
297 void smf_message_set_boundary(SMFMessage_T *message, const char *boundary);
298 
305 char *smf_message_get_boundary(SMFMessage_T *message);
306 
312 char *smf_message_generate_boundary(void);
313 
319 void smf_message_add_generated_boundary(SMFMessage_T *message);
320 
327 void smf_message_set_subject(SMFMessage_T *message, const char *s);
328 
335 char *smf_message_get_subject(SMFMessage_T *message);
336 
346 int smf_message_from_file(SMFMessage_T **message, const char *filename, int header_only);
347 
355 int smf_message_to_file(SMFMessage_T *message, const char *filename);
356 
364 int smf_message_to_fd(SMFMessage_T *message, int fd);
365 
372 char *smf_message_to_string(SMFMessage_T *message);
373 
383 int smf_message_from_string(SMFMessage_T **message, const char *content, int header_only);
384 
391 void smf_message_prepend_subject(SMFMessage_T *message, const char *s);
392 
399 void smf_message_append_subject(SMFMessage_T *message, const char *s);
400 
408 int smf_message_set_body(SMFMessage_T *message, const char *content);
409 
417 int smf_message_append_part(SMFMessage_T *message, SMFPart_T *part);
418 
425  int smf_message_get_part_count(SMFMessage_T *message);
426 
433 void smf_message_add_attachment(SMFMessage_T *message, char *attachment);
434 
443 SMFMessage_T *smf_message_create_skeleton(const char *sender, const char *recipient, const char *subject);
444 
454 int smf_message_add_child_part(SMFMessage_T *message, SMFPart_T *part, SMFPart_T *child, SMFMultipartType_T subtype);
455 
462 SMFPart_T *smf_message_part_first(SMFMessage_T *message);
463 
470 SMFPart_T *smf_message_part_last(SMFMessage_T *message);
471 
482 int smf_message_write_skip_header(FILE *src, FILE *dest);
483 
484 #ifdef __cplusplus
485 }
486 #endif
487 
488 #endif /* _SMF_MESSAGE_H */