author | zautrix <zautrix> | 2004-07-03 16:33:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-03 16:33:12 (UTC) |
commit | e3b89230f065c48c84b48c88edb6eb088374c487 (patch) (unidiff) | |
tree | 162ea2ef909a6f82ccfcedf45d80d6c821174912 /kmicromail/libetpan/imf/mailimf_types.c | |
parent | 2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff) | |
download | kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2 |
Initial revision
Diffstat (limited to 'kmicromail/libetpan/imf/mailimf_types.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libetpan/imf/mailimf_types.c | 868 |
1 files changed, 868 insertions, 0 deletions
diff --git a/kmicromail/libetpan/imf/mailimf_types.c b/kmicromail/libetpan/imf/mailimf_types.c new file mode 100644 index 0000000..fbef8f0 --- a/dev/null +++ b/kmicromail/libetpan/imf/mailimf_types.c | |||
@@ -0,0 +1,868 @@ | |||
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 "mailimf_types.h" | ||
37 | #include "mmapstring.h" | ||
38 | #include <stdlib.h> | ||
39 | |||
40 | void mailimf_atom_free(char * atom) | ||
41 | { | ||
42 | free(atom); | ||
43 | } | ||
44 | |||
45 | void mailimf_dot_atom_free(char * dot_atom) | ||
46 | { | ||
47 | free(dot_atom); | ||
48 | } | ||
49 | |||
50 | void mailimf_dot_atom_text_free(char * dot_atom) | ||
51 | { | ||
52 | free(dot_atom); | ||
53 | } | ||
54 | |||
55 | void mailimf_quoted_string_free(char * quoted_string) | ||
56 | { | ||
57 | free(quoted_string); | ||
58 | } | ||
59 | |||
60 | void mailimf_word_free(char * word) | ||
61 | { | ||
62 | free(word); | ||
63 | } | ||
64 | |||
65 | void mailimf_phrase_free(char * phrase) | ||
66 | { | ||
67 | free(phrase); | ||
68 | } | ||
69 | |||
70 | void mailimf_unstructured_free(char * unstructured) | ||
71 | { | ||
72 | free(unstructured); | ||
73 | } | ||
74 | |||
75 | |||
76 | struct mailimf_date_time * | ||
77 | mailimf_date_time_new(int dt_day, int dt_month, int dt_year, | ||
78 | int dt_hour, int dt_min, int dt_sec, int dt_zone) | ||
79 | { | ||
80 | struct mailimf_date_time * date_time; | ||
81 | |||
82 | date_time = malloc(sizeof(* date_time)); | ||
83 | if (date_time == NULL) | ||
84 | return NULL; | ||
85 | |||
86 | date_time->dt_day = dt_day; | ||
87 | date_time->dt_month = dt_month; | ||
88 | date_time->dt_year = dt_year; | ||
89 | date_time->dt_hour = dt_hour; | ||
90 | date_time->dt_min = dt_min; | ||
91 | date_time->dt_sec = dt_sec; | ||
92 | date_time->dt_zone = dt_zone; | ||
93 | |||
94 | return date_time; | ||
95 | } | ||
96 | |||
97 | |||
98 | void mailimf_date_time_free(struct mailimf_date_time * date_time) | ||
99 | { | ||
100 | free(date_time); | ||
101 | } | ||
102 | |||
103 | |||
104 | |||
105 | |||
106 | struct mailimf_address * | ||
107 | mailimf_address_new(int ad_type, struct mailimf_mailbox * ad_mailbox, | ||
108 | struct mailimf_group * ad_group) | ||
109 | { | ||
110 | struct mailimf_address * address; | ||
111 | |||
112 | address = malloc(sizeof(* address)); | ||
113 | if (address == NULL) | ||
114 | return NULL; | ||
115 | |||
116 | address->ad_type = ad_type; | ||
117 | switch (ad_type) { | ||
118 | case MAILIMF_ADDRESS_MAILBOX: | ||
119 | address->ad_data.ad_mailbox = ad_mailbox; | ||
120 | break; | ||
121 | case MAILIMF_ADDRESS_GROUP: | ||
122 | address->ad_data.ad_group = ad_group; | ||
123 | break; | ||
124 | } | ||
125 | |||
126 | return address; | ||
127 | } | ||
128 | |||
129 | void mailimf_address_free(struct mailimf_address * address) | ||
130 | { | ||
131 | switch (address->ad_type) { | ||
132 | case MAILIMF_ADDRESS_MAILBOX: | ||
133 | mailimf_mailbox_free(address->ad_data.ad_mailbox); | ||
134 | break; | ||
135 | case MAILIMF_ADDRESS_GROUP: | ||
136 | mailimf_group_free(address->ad_data.ad_group); | ||
137 | } | ||
138 | free(address); | ||
139 | } | ||
140 | |||
141 | struct mailimf_mailbox * | ||
142 | mailimf_mailbox_new(char * mb_display_name, char * mb_addr_spec) | ||
143 | { | ||
144 | struct mailimf_mailbox * mb; | ||
145 | |||
146 | mb = malloc(sizeof(* mb)); | ||
147 | if (mb == NULL) | ||
148 | return NULL; | ||
149 | |||
150 | mb->mb_display_name = mb_display_name; | ||
151 | mb->mb_addr_spec = mb_addr_spec; | ||
152 | |||
153 | return mb; | ||
154 | } | ||
155 | |||
156 | void mailimf_mailbox_free(struct mailimf_mailbox * mailbox) | ||
157 | { | ||
158 | if (mailbox->mb_display_name != NULL) | ||
159 | mailimf_display_name_free(mailbox->mb_display_name); | ||
160 | mailimf_addr_spec_free(mailbox->mb_addr_spec); | ||
161 | free(mailbox); | ||
162 | } | ||
163 | |||
164 | |||
165 | void mailimf_angle_addr_free(char * angle_addr) | ||
166 | { | ||
167 | free(angle_addr); | ||
168 | } | ||
169 | |||
170 | |||
171 | struct mailimf_group * | ||
172 | mailimf_group_new(char * grp_display_name, | ||
173 | struct mailimf_mailbox_list * grp_mb_list) | ||
174 | { | ||
175 | struct mailimf_group * group; | ||
176 | |||
177 | group = malloc(sizeof(* group)); | ||
178 | if (group == NULL) | ||
179 | return NULL; | ||
180 | |||
181 | group->grp_display_name = grp_display_name; | ||
182 | group->grp_mb_list = grp_mb_list; | ||
183 | |||
184 | return group; | ||
185 | } | ||
186 | |||
187 | void mailimf_group_free(struct mailimf_group * group) | ||
188 | { | ||
189 | if (group->grp_mb_list) | ||
190 | mailimf_mailbox_list_free(group->grp_mb_list); | ||
191 | mailimf_display_name_free(group->grp_display_name); | ||
192 | free(group); | ||
193 | } | ||
194 | |||
195 | void mailimf_display_name_free(char * display_name) | ||
196 | { | ||
197 | mailimf_phrase_free(display_name); | ||
198 | } | ||
199 | |||
200 | |||
201 | struct mailimf_mailbox_list * | ||
202 | mailimf_mailbox_list_new(clist * mb_list) | ||
203 | { | ||
204 | struct mailimf_mailbox_list * mbl; | ||
205 | |||
206 | mbl = malloc(sizeof(* mbl)); | ||
207 | if (mbl == NULL) | ||
208 | return NULL; | ||
209 | |||
210 | mbl->mb_list = mb_list; | ||
211 | |||
212 | return mbl; | ||
213 | } | ||
214 | |||
215 | void mailimf_mailbox_list_free(struct mailimf_mailbox_list * mb_list) | ||
216 | { | ||
217 | clist_foreach(mb_list->mb_list, (clist_func) mailimf_mailbox_free, NULL); | ||
218 | clist_free(mb_list->mb_list); | ||
219 | free(mb_list); | ||
220 | } | ||
221 | |||
222 | |||
223 | |||
224 | struct mailimf_address_list * | ||
225 | mailimf_address_list_new(clist * ad_list) | ||
226 | { | ||
227 | struct mailimf_address_list * addr_list; | ||
228 | |||
229 | addr_list = malloc(sizeof(* addr_list)); | ||
230 | if (addr_list == NULL) | ||
231 | return NULL; | ||
232 | |||
233 | addr_list->ad_list = ad_list; | ||
234 | |||
235 | return addr_list; | ||
236 | } | ||
237 | |||
238 | void mailimf_address_list_free(struct mailimf_address_list * addr_list) | ||
239 | { | ||
240 | clist_foreach(addr_list->ad_list, (clist_func) mailimf_address_free, NULL); | ||
241 | clist_free(addr_list->ad_list); | ||
242 | free(addr_list); | ||
243 | } | ||
244 | |||
245 | |||
246 | void mailimf_addr_spec_free(char * addr_spec) | ||
247 | { | ||
248 | free(addr_spec); | ||
249 | } | ||
250 | |||
251 | void mailimf_local_part_free(char * local_part) | ||
252 | { | ||
253 | free(local_part); | ||
254 | } | ||
255 | |||
256 | void mailimf_domain_free(char * domain) | ||
257 | { | ||
258 | free(domain); | ||
259 | } | ||
260 | |||
261 | void mailimf_domain_literal_free(char * domain_literal) | ||
262 | { | ||
263 | free(domain_literal); | ||
264 | } | ||
265 | |||
266 | |||
267 | |||
268 | struct mailimf_message * | ||
269 | mailimf_message_new(struct mailimf_fields * msg_fields, | ||
270 | struct mailimf_body * msg_body) | ||
271 | { | ||
272 | struct mailimf_message * message; | ||
273 | |||
274 | message = malloc(sizeof(* message)); | ||
275 | if (message == NULL) | ||
276 | return NULL; | ||
277 | |||
278 | message->msg_fields = msg_fields; | ||
279 | message->msg_body = msg_body; | ||
280 | |||
281 | return message; | ||
282 | } | ||
283 | |||
284 | void mailimf_message_free(struct mailimf_message * message) | ||
285 | { | ||
286 | mailimf_body_free(message->msg_body); | ||
287 | mailimf_fields_free(message->msg_fields); | ||
288 | free(message); | ||
289 | } | ||
290 | |||
291 | |||
292 | struct mailimf_body * mailimf_body_new(const char * bd_text, size_t bd_size) | ||
293 | { | ||
294 | struct mailimf_body * body; | ||
295 | |||
296 | body = malloc(sizeof(* body)); | ||
297 | if (body == NULL) | ||
298 | return NULL; | ||
299 | body->bd_text = bd_text; | ||
300 | body->bd_size = bd_size; | ||
301 | |||
302 | return body; | ||
303 | } | ||
304 | |||
305 | void mailimf_body_free(struct mailimf_body * body) | ||
306 | { | ||
307 | free(body); | ||
308 | } | ||
309 | |||
310 | |||
311 | |||
312 | struct mailimf_field * | ||
313 | mailimf_field_new(int fld_type, | ||
314 | struct mailimf_return * fld_return_path, | ||
315 | struct mailimf_orig_date * fld_resent_date, | ||
316 | struct mailimf_from * fld_resent_from, | ||
317 | struct mailimf_sender * fld_resent_sender, | ||
318 | struct mailimf_to * fld_resent_to, | ||
319 | struct mailimf_cc * fld_resent_cc, | ||
320 | struct mailimf_bcc * fld_resent_bcc, | ||
321 | struct mailimf_message_id * fld_resent_msg_id, | ||
322 | struct mailimf_orig_date * fld_orig_date, | ||
323 | struct mailimf_from * fld_from, | ||
324 | struct mailimf_sender * fld_sender, | ||
325 | struct mailimf_reply_to * fld_reply_to, | ||
326 | struct mailimf_to * fld_to, | ||
327 | struct mailimf_cc * fld_cc, | ||
328 | struct mailimf_bcc * fld_bcc, | ||
329 | struct mailimf_message_id * fld_message_id, | ||
330 | struct mailimf_in_reply_to * fld_in_reply_to, | ||
331 | struct mailimf_references * fld_references, | ||
332 | struct mailimf_subject * fld_subject, | ||
333 | struct mailimf_comments * fld_comments, | ||
334 | struct mailimf_keywords * fld_keywords, | ||
335 | struct mailimf_optional_field * fld_optional_field) | ||
336 | { | ||
337 | struct mailimf_field * field; | ||
338 | |||
339 | field = malloc(sizeof(* field)); | ||
340 | if (field == NULL) | ||
341 | return NULL; | ||
342 | |||
343 | field->fld_type = fld_type; | ||
344 | switch (fld_type) { | ||
345 | case MAILIMF_FIELD_RETURN_PATH: | ||
346 | field->fld_data.fld_return_path = fld_return_path; | ||
347 | break; | ||
348 | case MAILIMF_FIELD_RESENT_DATE: | ||
349 | field->fld_data.fld_resent_date = fld_resent_date; | ||
350 | break; | ||
351 | case MAILIMF_FIELD_RESENT_FROM: | ||
352 | field->fld_data.fld_resent_from = fld_resent_from; | ||
353 | break; | ||
354 | case MAILIMF_FIELD_RESENT_SENDER: | ||
355 | field->fld_data.fld_resent_sender = fld_resent_sender; | ||
356 | break; | ||
357 | case MAILIMF_FIELD_RESENT_TO: | ||
358 | field->fld_data.fld_resent_to = fld_resent_to; | ||
359 | break; | ||
360 | case MAILIMF_FIELD_RESENT_CC: | ||
361 | field->fld_data.fld_resent_cc = fld_resent_cc; | ||
362 | break; | ||
363 | case MAILIMF_FIELD_RESENT_BCC: | ||
364 | field->fld_data.fld_resent_bcc = fld_resent_bcc; | ||
365 | break; | ||
366 | case MAILIMF_FIELD_RESENT_MSG_ID: | ||
367 | field->fld_data.fld_resent_msg_id = fld_resent_msg_id; | ||
368 | break; | ||
369 | case MAILIMF_FIELD_ORIG_DATE: | ||
370 | field->fld_data.fld_orig_date = fld_orig_date; | ||
371 | break; | ||
372 | case MAILIMF_FIELD_FROM: | ||
373 | field->fld_data.fld_from = fld_from; | ||
374 | break; | ||
375 | case MAILIMF_FIELD_SENDER: | ||
376 | field->fld_data.fld_sender = fld_sender; | ||
377 | break; | ||
378 | case MAILIMF_FIELD_REPLY_TO: | ||
379 | field->fld_data.fld_reply_to = fld_reply_to; | ||
380 | break; | ||
381 | case MAILIMF_FIELD_TO: | ||
382 | field->fld_data.fld_to = fld_to; | ||
383 | break; | ||
384 | case MAILIMF_FIELD_CC: | ||
385 | field->fld_data.fld_cc = fld_cc; | ||
386 | break; | ||
387 | case MAILIMF_FIELD_BCC: | ||
388 | field->fld_data.fld_bcc = fld_bcc; | ||
389 | break; | ||
390 | case MAILIMF_FIELD_MESSAGE_ID: | ||
391 | field->fld_data.fld_message_id = fld_message_id; | ||
392 | break; | ||
393 | case MAILIMF_FIELD_IN_REPLY_TO: | ||
394 | field->fld_data.fld_in_reply_to = fld_in_reply_to; | ||
395 | break; | ||
396 | case MAILIMF_FIELD_REFERENCES: | ||
397 | field->fld_data.fld_references = fld_references; | ||
398 | break; | ||
399 | case MAILIMF_FIELD_SUBJECT: | ||
400 | field->fld_data.fld_subject = fld_subject; | ||
401 | break; | ||
402 | case MAILIMF_FIELD_COMMENTS: | ||
403 | field->fld_data.fld_comments = fld_comments; | ||
404 | break; | ||
405 | case MAILIMF_FIELD_KEYWORDS: | ||
406 | field->fld_data.fld_keywords = fld_keywords; | ||
407 | break; | ||
408 | case MAILIMF_FIELD_OPTIONAL_FIELD: | ||
409 | field->fld_data.fld_optional_field = fld_optional_field; | ||
410 | break; | ||
411 | } | ||
412 | |||
413 | return field; | ||
414 | } | ||
415 | |||
416 | void mailimf_field_free(struct mailimf_field * field) | ||
417 | { | ||
418 | switch (field->fld_type) { | ||
419 | case MAILIMF_FIELD_RETURN_PATH: | ||
420 | mailimf_return_free(field->fld_data.fld_return_path); | ||
421 | break; | ||
422 | case MAILIMF_FIELD_RESENT_DATE: | ||
423 | mailimf_orig_date_free(field->fld_data.fld_resent_date); | ||
424 | break; | ||
425 | case MAILIMF_FIELD_RESENT_FROM: | ||
426 | mailimf_from_free(field->fld_data.fld_resent_from); | ||
427 | break; | ||
428 | case MAILIMF_FIELD_RESENT_SENDER: | ||
429 | mailimf_sender_free(field->fld_data.fld_resent_sender); | ||
430 | break; | ||
431 | case MAILIMF_FIELD_RESENT_TO: | ||
432 | mailimf_to_free(field->fld_data.fld_resent_to); | ||
433 | break; | ||
434 | case MAILIMF_FIELD_RESENT_CC: | ||
435 | mailimf_cc_free(field->fld_data.fld_resent_cc); | ||
436 | break; | ||
437 | case MAILIMF_FIELD_RESENT_BCC: | ||
438 | mailimf_bcc_free(field->fld_data.fld_resent_bcc); | ||
439 | break; | ||
440 | case MAILIMF_FIELD_RESENT_MSG_ID: | ||
441 | mailimf_message_id_free(field->fld_data.fld_resent_msg_id); | ||
442 | break; | ||
443 | case MAILIMF_FIELD_ORIG_DATE: | ||
444 | mailimf_orig_date_free(field->fld_data.fld_orig_date); | ||
445 | break; | ||
446 | case MAILIMF_FIELD_FROM: | ||
447 | mailimf_from_free(field->fld_data.fld_from); | ||
448 | break; | ||
449 | case MAILIMF_FIELD_SENDER: | ||
450 | mailimf_sender_free(field->fld_data.fld_sender); | ||
451 | break; | ||
452 | case MAILIMF_FIELD_REPLY_TO: | ||
453 | mailimf_reply_to_free(field->fld_data.fld_reply_to); | ||
454 | break; | ||
455 | case MAILIMF_FIELD_TO: | ||
456 | mailimf_to_free(field->fld_data.fld_to); | ||
457 | break; | ||
458 | case MAILIMF_FIELD_CC: | ||
459 | mailimf_cc_free(field->fld_data.fld_cc); | ||
460 | break; | ||
461 | case MAILIMF_FIELD_BCC: | ||
462 | mailimf_bcc_free(field->fld_data.fld_bcc); | ||
463 | break; | ||
464 | case MAILIMF_FIELD_MESSAGE_ID: | ||
465 | mailimf_message_id_free(field->fld_data.fld_message_id); | ||
466 | break; | ||
467 | case MAILIMF_FIELD_IN_REPLY_TO: | ||
468 | mailimf_in_reply_to_free(field->fld_data.fld_in_reply_to); | ||
469 | break; | ||
470 | case MAILIMF_FIELD_REFERENCES: | ||
471 | mailimf_references_free(field->fld_data.fld_references); | ||
472 | break; | ||
473 | case MAILIMF_FIELD_SUBJECT: | ||
474 | mailimf_subject_free(field->fld_data.fld_subject); | ||
475 | break; | ||
476 | case MAILIMF_FIELD_COMMENTS: | ||
477 | mailimf_comments_free(field->fld_data.fld_comments); | ||
478 | break; | ||
479 | case MAILIMF_FIELD_KEYWORDS: | ||
480 | mailimf_keywords_free(field->fld_data.fld_keywords); | ||
481 | break; | ||
482 | case MAILIMF_FIELD_OPTIONAL_FIELD: | ||
483 | mailimf_optional_field_free(field->fld_data.fld_optional_field); | ||
484 | break; | ||
485 | } | ||
486 | |||
487 | free(field); | ||
488 | } | ||
489 | |||
490 | struct mailimf_fields * mailimf_fields_new(clist * fld_list) | ||
491 | { | ||
492 | struct mailimf_fields * fields; | ||
493 | |||
494 | fields = malloc(sizeof(* fields)); | ||
495 | if (fields == NULL) | ||
496 | return NULL; | ||
497 | |||
498 | fields->fld_list = fld_list; | ||
499 | |||
500 | return fields; | ||
501 | } | ||
502 | |||
503 | void mailimf_fields_free(struct mailimf_fields * fields) | ||
504 | { | ||
505 | if (fields->fld_list != NULL) { | ||
506 | clist_foreach(fields->fld_list, (clist_func) mailimf_field_free, NULL); | ||
507 | clist_free(fields->fld_list); | ||
508 | } | ||
509 | free(fields); | ||
510 | } | ||
511 | |||
512 | |||
513 | struct mailimf_orig_date * mailimf_orig_date_new(struct mailimf_date_time * | ||
514 | dt_date_time) | ||
515 | { | ||
516 | struct mailimf_orig_date * orig_date; | ||
517 | |||
518 | orig_date = malloc(sizeof(* orig_date)); | ||
519 | if (orig_date == NULL) | ||
520 | return NULL; | ||
521 | |||
522 | orig_date->dt_date_time = dt_date_time; | ||
523 | |||
524 | return orig_date; | ||
525 | } | ||
526 | |||
527 | void mailimf_orig_date_free(struct mailimf_orig_date * orig_date) | ||
528 | { | ||
529 | if (orig_date->dt_date_time != NULL) | ||
530 | mailimf_date_time_free(orig_date->dt_date_time); | ||
531 | free(orig_date); | ||
532 | } | ||
533 | |||
534 | struct mailimf_from * | ||
535 | mailimf_from_new(struct mailimf_mailbox_list * frm_mb_list) | ||
536 | { | ||
537 | struct mailimf_from * from; | ||
538 | |||
539 | from = malloc(sizeof(* from)); | ||
540 | if (from == NULL) | ||
541 | return NULL; | ||
542 | |||
543 | from->frm_mb_list = frm_mb_list; | ||
544 | |||
545 | return from; | ||
546 | } | ||
547 | |||
548 | void mailimf_from_free(struct mailimf_from * from) | ||
549 | { | ||
550 | if (from->frm_mb_list != NULL) | ||
551 | mailimf_mailbox_list_free(from->frm_mb_list); | ||
552 | free(from); | ||
553 | } | ||
554 | |||
555 | struct mailimf_sender * mailimf_sender_new(struct mailimf_mailbox * snd_mb) | ||
556 | { | ||
557 | struct mailimf_sender * sender; | ||
558 | |||
559 | sender = malloc(sizeof(* sender)); | ||
560 | if (sender == NULL) | ||
561 | return NULL; | ||
562 | |||
563 | sender->snd_mb = snd_mb; | ||
564 | |||
565 | return sender; | ||
566 | } | ||
567 | |||
568 | void mailimf_sender_free(struct mailimf_sender * sender) | ||
569 | { | ||
570 | if (sender->snd_mb != NULL) | ||
571 | mailimf_mailbox_free(sender->snd_mb); | ||
572 | free(sender); | ||
573 | } | ||
574 | |||
575 | struct mailimf_reply_to * | ||
576 | mailimf_reply_to_new(struct mailimf_address_list * rt_addr_list) | ||
577 | { | ||
578 | struct mailimf_reply_to * reply_to; | ||
579 | |||
580 | reply_to = malloc(sizeof(* reply_to)); | ||
581 | if (reply_to == NULL) | ||
582 | return NULL; | ||
583 | |||
584 | reply_to->rt_addr_list = rt_addr_list; | ||
585 | |||
586 | return reply_to; | ||
587 | } | ||
588 | |||
589 | void mailimf_reply_to_free(struct mailimf_reply_to * reply_to) | ||
590 | { | ||
591 | if (reply_to->rt_addr_list != NULL) | ||
592 | mailimf_address_list_free(reply_to->rt_addr_list); | ||
593 | free(reply_to); | ||
594 | } | ||
595 | |||
596 | struct mailimf_to * mailimf_to_new(struct mailimf_address_list * to_addr_list) | ||
597 | { | ||
598 | struct mailimf_to * to; | ||
599 | |||
600 | to = malloc(sizeof(* to)); | ||
601 | if (to == NULL) | ||
602 | return NULL; | ||
603 | |||
604 | to->to_addr_list = to_addr_list; | ||
605 | |||
606 | return to; | ||
607 | } | ||
608 | |||
609 | void mailimf_to_free(struct mailimf_to * to) | ||
610 | { | ||
611 | if (to->to_addr_list != NULL) | ||
612 | mailimf_address_list_free(to->to_addr_list); | ||
613 | free(to); | ||
614 | } | ||
615 | |||
616 | struct mailimf_cc * mailimf_cc_new(struct mailimf_address_list * cc_addr_list) | ||
617 | { | ||
618 | struct mailimf_cc * cc; | ||
619 | |||
620 | cc = malloc(sizeof(* cc)); | ||
621 | if (cc == NULL) | ||
622 | return NULL; | ||
623 | |||
624 | cc->cc_addr_list = cc_addr_list; | ||
625 | |||
626 | return cc; | ||
627 | } | ||
628 | |||
629 | void mailimf_cc_free(struct mailimf_cc * cc) | ||
630 | { | ||
631 | if (cc->cc_addr_list != NULL) | ||
632 | mailimf_address_list_free(cc->cc_addr_list); | ||
633 | free(cc); | ||
634 | } | ||
635 | |||
636 | struct mailimf_bcc * | ||
637 | mailimf_bcc_new(struct mailimf_address_list * bcc_addr_list) | ||
638 | { | ||
639 | struct mailimf_bcc * bcc; | ||
640 | |||
641 | bcc = malloc(sizeof(* bcc)); | ||
642 | if (bcc == NULL) | ||
643 | return NULL; | ||
644 | |||
645 | bcc->bcc_addr_list = bcc_addr_list; | ||
646 | |||
647 | return bcc; | ||
648 | } | ||
649 | |||
650 | void mailimf_bcc_free(struct mailimf_bcc * bcc) | ||
651 | { | ||
652 | if (bcc->bcc_addr_list != NULL) | ||
653 | mailimf_address_list_free(bcc->bcc_addr_list); | ||
654 | free(bcc); | ||
655 | } | ||
656 | |||
657 | struct mailimf_message_id * mailimf_message_id_new(char * mid_value) | ||
658 | { | ||
659 | struct mailimf_message_id * message_id; | ||
660 | |||
661 | message_id = malloc(sizeof(* message_id)); | ||
662 | if (message_id == NULL) | ||
663 | return NULL; | ||
664 | |||
665 | message_id->mid_value = mid_value; | ||
666 | |||
667 | return message_id; | ||
668 | } | ||
669 | |||
670 | void mailimf_message_id_free(struct mailimf_message_id * message_id) | ||
671 | { | ||
672 | if (message_id->mid_value != NULL) | ||
673 | mailimf_msg_id_free(message_id->mid_value); | ||
674 | free(message_id); | ||
675 | } | ||
676 | |||
677 | struct mailimf_in_reply_to * mailimf_in_reply_to_new(clist * mid_list) | ||
678 | { | ||
679 | struct mailimf_in_reply_to * in_reply_to; | ||
680 | |||
681 | in_reply_to = malloc(sizeof(* in_reply_to)); | ||
682 | if (in_reply_to == NULL) | ||
683 | return NULL; | ||
684 | |||
685 | in_reply_to->mid_list = mid_list; | ||
686 | |||
687 | return in_reply_to; | ||
688 | } | ||
689 | |||
690 | void mailimf_in_reply_to_free(struct mailimf_in_reply_to * in_reply_to) | ||
691 | { | ||
692 | clist_foreach(in_reply_to->mid_list, | ||
693 | (clist_func) mailimf_msg_id_free, NULL); | ||
694 | clist_free(in_reply_to->mid_list); | ||
695 | free(in_reply_to); | ||
696 | } | ||
697 | |||
698 | struct mailimf_references * mailimf_references_new(clist * mid_list) | ||
699 | { | ||
700 | struct mailimf_references * ref; | ||
701 | |||
702 | ref = malloc(sizeof(* ref)); | ||
703 | if (ref == NULL) | ||
704 | return NULL; | ||
705 | |||
706 | ref->mid_list = mid_list; | ||
707 | |||
708 | return ref; | ||
709 | } | ||
710 | |||
711 | void mailimf_references_free(struct mailimf_references * references) | ||
712 | { | ||
713 | clist_foreach(references->mid_list, | ||
714 | (clist_func) mailimf_msg_id_free, NULL); | ||
715 | clist_free(references->mid_list); | ||
716 | free(references); | ||
717 | } | ||
718 | |||
719 | void mailimf_msg_id_free(char * msg_id) | ||
720 | { | ||
721 | free(msg_id); | ||
722 | } | ||
723 | |||
724 | void mailimf_id_left_free(char * id_left) | ||
725 | { | ||
726 | free(id_left); | ||
727 | } | ||
728 | |||
729 | void mailimf_id_right_free(char * id_right) | ||
730 | { | ||
731 | free(id_right); | ||
732 | } | ||
733 | |||
734 | void mailimf_no_fold_quote_free(char * nfq) | ||
735 | { | ||
736 | free(nfq); | ||
737 | } | ||
738 | |||
739 | void mailimf_no_fold_literal_free(char * nfl) | ||
740 | { | ||
741 | free(nfl); | ||
742 | } | ||
743 | |||
744 | struct mailimf_subject * mailimf_subject_new(char * sbj_value) | ||
745 | { | ||
746 | struct mailimf_subject * subject; | ||
747 | |||
748 | subject = malloc(sizeof(* subject)); | ||
749 | if (subject == NULL) | ||
750 | return NULL; | ||
751 | |||
752 | subject->sbj_value = sbj_value; | ||
753 | |||
754 | return subject; | ||
755 | } | ||
756 | |||
757 | void mailimf_subject_free(struct mailimf_subject * subject) | ||
758 | { | ||
759 | mailimf_unstructured_free(subject->sbj_value); | ||
760 | free(subject); | ||
761 | } | ||
762 | |||
763 | struct mailimf_comments * mailimf_comments_new(char * cm_value) | ||
764 | { | ||
765 | struct mailimf_comments * comments; | ||
766 | |||
767 | comments = malloc(sizeof(* comments)); | ||
768 | if (comments == NULL) | ||
769 | return NULL; | ||
770 | |||
771 | comments->cm_value = cm_value; | ||
772 | |||
773 | return comments; | ||
774 | } | ||
775 | |||
776 | void mailimf_comments_free(struct mailimf_comments * comments) | ||
777 | { | ||
778 | mailimf_unstructured_free(comments->cm_value); | ||
779 | free(comments); | ||
780 | } | ||
781 | |||
782 | struct mailimf_keywords * mailimf_keywords_new(clist * kw_list) | ||
783 | { | ||
784 | struct mailimf_keywords * keywords; | ||
785 | |||
786 | keywords = malloc(sizeof(* keywords)); | ||
787 | if (keywords == NULL) | ||
788 | return NULL; | ||
789 | |||
790 | keywords->kw_list = kw_list; | ||
791 | |||
792 | return keywords; | ||
793 | } | ||
794 | |||
795 | void mailimf_keywords_free(struct mailimf_keywords * keywords) | ||
796 | { | ||
797 | clist_foreach(keywords->kw_list, (clist_func) mailimf_phrase_free, NULL); | ||
798 | clist_free(keywords->kw_list); | ||
799 | free(keywords); | ||
800 | } | ||
801 | |||
802 | struct mailimf_return * | ||
803 | mailimf_return_new(struct mailimf_path * ret_path) | ||
804 | { | ||
805 | struct mailimf_return * return_path; | ||
806 | |||
807 | return_path = malloc(sizeof(* return_path)); | ||
808 | if (return_path == NULL) | ||
809 | return NULL; | ||
810 | |||
811 | return_path->ret_path = ret_path; | ||
812 | |||
813 | return return_path; | ||
814 | } | ||
815 | |||
816 | void mailimf_return_free(struct mailimf_return * return_path) | ||
817 | { | ||
818 | mailimf_path_free(return_path->ret_path); | ||
819 | free(return_path); | ||
820 | } | ||
821 | |||
822 | |||
823 | struct mailimf_path * mailimf_path_new(char * pt_addr_spec) | ||
824 | { | ||
825 | struct mailimf_path * path; | ||
826 | |||
827 | path = malloc(sizeof(* path)); | ||
828 | if (path == NULL) | ||
829 | return NULL; | ||
830 | |||
831 | path->pt_addr_spec = pt_addr_spec; | ||
832 | |||
833 | return path; | ||
834 | } | ||
835 | |||
836 | void mailimf_path_free(struct mailimf_path * path) | ||
837 | { | ||
838 | if (path->pt_addr_spec != NULL) | ||
839 | mailimf_addr_spec_free(path->pt_addr_spec); | ||
840 | free(path); | ||
841 | } | ||
842 | |||
843 | struct mailimf_optional_field * | ||
844 | mailimf_optional_field_new(char * fld_name, char * fld_value) | ||
845 | { | ||
846 | struct mailimf_optional_field * opt_field; | ||
847 | |||
848 | opt_field = malloc(sizeof(* opt_field)); | ||
849 | if (opt_field == NULL) | ||
850 | return NULL; | ||
851 | |||
852 | opt_field->fld_name = fld_name; | ||
853 | opt_field->fld_value = fld_value; | ||
854 | |||
855 | return opt_field; | ||
856 | } | ||
857 | |||
858 | void mailimf_optional_field_free(struct mailimf_optional_field * opt_field) | ||
859 | { | ||
860 | mailimf_field_name_free(opt_field->fld_name); | ||
861 | mailimf_unstructured_free(opt_field->fld_value); | ||
862 | free(opt_field); | ||
863 | } | ||
864 | |||
865 | void mailimf_field_name_free(char * field_name) | ||
866 | { | ||
867 | free(field_name); | ||
868 | } | ||