Diffstat (limited to 'kmicromail/libetpan/generic/mailmessage_types.c') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libetpan/generic/mailmessage_types.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/kmicromail/libetpan/generic/mailmessage_types.c b/kmicromail/libetpan/generic/mailmessage_types.c new file mode 100644 index 0000000..9f8c355 --- a/dev/null +++ b/kmicromail/libetpan/generic/mailmessage_types.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * libEtPan! -- a mail stuff library | ||
3 | * | ||
4 | * Copyright (C) 2001, 2002 - 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 REGENTS 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 REGENTS 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 | #include "mailmessage_types.h" | ||
37 | |||
38 | #include "mail.h" | ||
39 | |||
40 | #include <stdlib.h> | ||
41 | #include <string.h> | ||
42 | |||
43 | mailmessage * mailmessage_new(void) | ||
44 | { | ||
45 | mailmessage * msg_info; | ||
46 | |||
47 | msg_info = malloc(sizeof(* msg_info)); | ||
48 | if (msg_info == NULL) | ||
49 | goto err; | ||
50 | |||
51 | msg_info->msg_driver = NULL; | ||
52 | msg_info->msg_session = NULL; | ||
53 | msg_info->msg_index = 0; | ||
54 | msg_info->msg_uid = NULL; | ||
55 | |||
56 | msg_info->msg_cached = FALSE; | ||
57 | msg_info->msg_size = 0; | ||
58 | msg_info->msg_fields = NULL; | ||
59 | memset(&msg_info->msg_single_fields, | ||
60 | 0, sizeof(struct mailimf_single_fields)); | ||
61 | msg_info->msg_resolved = FALSE; | ||
62 | msg_info->msg_flags = NULL; | ||
63 | |||
64 | msg_info->msg_mime = NULL; | ||
65 | msg_info->msg_data = NULL; | ||
66 | |||
67 | msg_info->msg_folder = NULL; | ||
68 | msg_info->msg_user_data = NULL; | ||
69 | |||
70 | return msg_info; | ||
71 | |||
72 | err: | ||
73 | return NULL; | ||
74 | } | ||
75 | |||
76 | void mailmessage_free(mailmessage * msg_info) | ||
77 | { | ||
78 | if (msg_info->msg_driver != NULL) { | ||
79 | if (msg_info->msg_driver->msg_uninitialize != NULL) | ||
80 | msg_info->msg_driver->msg_uninitialize(msg_info); | ||
81 | } | ||
82 | |||
83 | if (msg_info->msg_fields != NULL) | ||
84 | mailimf_fields_free(msg_info->msg_fields); | ||
85 | if (msg_info->msg_mime != NULL) | ||
86 | mailmime_free(msg_info->msg_mime); | ||
87 | if (msg_info->msg_flags != NULL) | ||
88 | mail_flags_free(msg_info->msg_flags); | ||
89 | if (msg_info->msg_uid != NULL) | ||
90 | free(msg_info->msg_uid); | ||
91 | free(msg_info); | ||
92 | } | ||