summaryrefslogtreecommitdiffabout
path: root/libetpan/src/low-level/imap/mailimap_types.c
Unidiff
Diffstat (limited to 'libetpan/src/low-level/imap/mailimap_types.c') (more/less context) (ignore whitespace changes)
-rw-r--r--libetpan/src/low-level/imap/mailimap_types.c2961
1 files changed, 2961 insertions, 0 deletions
diff --git a/libetpan/src/low-level/imap/mailimap_types.c b/libetpan/src/low-level/imap/mailimap_types.c
new file mode 100644
index 0000000..5889f32
--- a/dev/null
+++ b/libetpan/src/low-level/imap/mailimap_types.c
@@ -0,0 +1,2961 @@
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#include "mailimap_types.h"
37#include "mmapstring.h"
38#include "mail.h"
39
40#include <stdlib.h>
41
42/* ************************************************************************* */
43/* ************************************************************************* */
44/* ************************************************************************* */
45/* ************************************************************************* */
46/* ************************************************************************* */
47/* ************************************************************************* */
48
49
50
51
52
53
54/* from parser */
55
56
57uint32_t * mailimap_number_alloc_new(uint32_t number)
58{
59 uint32_t * pnumber;
60
61 pnumber = malloc(sizeof(* pnumber));
62 if (pnumber == NULL)
63 return NULL;
64
65 * pnumber = number;
66
67 return pnumber;
68}
69
70void mailimap_number_alloc_free(uint32_t * pnumber)
71{
72 free(pnumber);
73}
74
75
76/* ************************************************************************* */
77
78
79struct mailimap_address *
80mailimap_address_new(char * ad_personal_name, char * ad_source_route,
81 char * ad_mailbox_name, char * ad_host_name)
82{
83 struct mailimap_address * addr;
84
85 addr = malloc(sizeof(* addr));
86 if (addr == NULL)
87 return NULL;
88
89 addr->ad_personal_name = ad_personal_name;
90 addr->ad_source_route = ad_source_route;
91 addr->ad_mailbox_name = ad_mailbox_name;
92 addr->ad_host_name = ad_host_name;
93
94 return addr;
95}
96
97void mailimap_address_free(struct mailimap_address * addr)
98{
99 mailimap_addr_host_free(addr->ad_host_name);
100 mailimap_addr_mailbox_free(addr->ad_mailbox_name);
101 mailimap_addr_adl_free(addr->ad_source_route);
102 mailimap_addr_name_free(addr->ad_personal_name);
103 free(addr);
104}
105
106void mailimap_addr_host_free(char * addr_host)
107{
108 mailimap_nstring_free(addr_host);
109}
110
111void mailimap_addr_mailbox_free(char * addr_mailbox)
112{
113 mailimap_nstring_free(addr_mailbox);
114}
115
116void mailimap_addr_adl_free(char * addr_adl)
117{
118 mailimap_nstring_free(addr_adl);
119}
120
121void mailimap_addr_name_free(char * addr_name)
122{
123 mailimap_nstring_free(addr_name);
124}
125
126
127
128
129
130/*
131struct mailimap_astring *
132mailimap_astring_new(gint type,
133 gchar * atom_astring,
134 gchar * string)
135{
136 struct mailimap_astring * astring;
137
138 astring = g_new(struct mailimap_astring, 1);
139 if (astring == NULL)
140 return FALSE;
141
142 astring->type = type;
143 astring->atom_astring = atom_astring;
144 astring->string = string;
145
146 return astring;
147}
148
149void mailimap_astring_free(struct mailimap_astring * astring)
150{
151 if (astring->atom_astring)
152 mailimap_atom_astring_free(astring->atom_astring);
153 if (astring->string)
154 mailimap_string_free(astring->string);
155 free(astring);
156}
157*/
158
159void mailimap_astring_free(char * astring)
160{
161 if (mmap_string_unref(astring) != 0)
162 free(astring);
163}
164
165static void mailimap_custom_string_free(char * str)
166{
167 free(str);
168}
169
170
171void mailimap_atom_free(char * atom)
172{
173 free(atom);
174}
175
176
177
178
179void mailimap_auth_type_free(char * auth_type)
180{
181 mailimap_atom_free(auth_type);
182}
183
184
185
186
187
188void mailimap_base64_free(char * base64)
189{
190 free(base64);
191}
192
193
194
195
196struct mailimap_body *
197mailimap_body_new(int bd_type,
198 struct mailimap_body_type_1part * bd_body_1part,
199 struct mailimap_body_type_mpart * bd_body_mpart)
200{
201 struct mailimap_body * body;
202
203 body = malloc(sizeof(* body));
204 if (body == NULL)
205 return NULL;
206
207 body->bd_type = bd_type;
208 switch (bd_type) {
209 case MAILIMAP_BODY_1PART:
210 body->bd_data.bd_body_1part = bd_body_1part;
211 break;
212 case MAILIMAP_BODY_MPART:
213 body->bd_data.bd_body_mpart = bd_body_mpart;
214 break;
215 }
216
217 return body;
218}
219
220void mailimap_body_free(struct mailimap_body * body)
221{
222 switch (body->bd_type) {
223 case MAILIMAP_BODY_1PART:
224 mailimap_body_type_1part_free(body->bd_data.bd_body_1part);
225 break;
226 case MAILIMAP_BODY_MPART:
227 mailimap_body_type_mpart_free(body->bd_data.bd_body_mpart);
228 break;
229 }
230 free(body);
231}
232
233
234struct mailimap_body_extension *
235mailimap_body_extension_new(int ext_type, char * ext_nstring,
236 uint32_t ext_number,
237 clist * ext_body_extension_list)
238{
239 struct mailimap_body_extension * body_extension;
240
241 body_extension = malloc(sizeof(* body_extension));
242 if (body_extension == NULL)
243 return NULL;
244
245 body_extension->ext_type = ext_type;
246 switch (ext_type) {
247 case MAILIMAP_BODY_EXTENSION_NSTRING:
248 body_extension->ext_data.ext_nstring = ext_nstring;
249 break;
250 case MAILIMAP_BODY_EXTENSION_NUMBER:
251 body_extension->ext_data.ext_number = ext_number;
252 break;
253 case MAILIMAP_BODY_EXTENSION_LIST:
254 body_extension->ext_data.ext_body_extension_list = ext_body_extension_list;
255 break;
256 }
257
258 return body_extension;
259}
260
261static void
262mailimap_body_ext_list_free(clist * body_ext_list);
263
264void mailimap_body_extension_free(struct mailimap_body_extension * be)
265{
266 switch (be->ext_type) {
267 case MAILIMAP_BODY_EXTENSION_NSTRING:
268 mailimap_nstring_free(be->ext_data.ext_nstring);
269 break;
270 case MAILIMAP_BODY_EXTENSION_LIST:
271 mailimap_body_ext_list_free(be->ext_data.ext_body_extension_list);
272 break;
273 }
274
275 free(be);
276}
277
278
279static void
280mailimap_body_ext_list_free(clist * body_ext_list)
281{
282 clist_foreach(body_ext_list, (clist_func) mailimap_body_extension_free,
283 NULL);
284 clist_free(body_ext_list);
285}
286
287
288struct mailimap_body_ext_1part *
289mailimap_body_ext_1part_new(char * bd_md5,
290 struct mailimap_body_fld_dsp * bd_disposition,
291 struct mailimap_body_fld_lang * bd_language,
292 clist * bd_extension_list)
293{
294 struct mailimap_body_ext_1part * body_ext_1part;
295
296 body_ext_1part = malloc(sizeof(* body_ext_1part));
297 if (body_ext_1part == NULL)
298 return NULL;
299
300 body_ext_1part->bd_md5 = bd_md5;
301 body_ext_1part->bd_disposition = bd_disposition;
302 body_ext_1part->bd_language = bd_language;
303 body_ext_1part->bd_extension_list = bd_extension_list;
304
305 return body_ext_1part;
306}
307
308void
309mailimap_body_ext_1part_free(struct mailimap_body_ext_1part * body_ext_1part)
310{
311 mailimap_body_fld_md5_free(body_ext_1part->bd_md5);
312 if (body_ext_1part->bd_disposition)
313 mailimap_body_fld_dsp_free(body_ext_1part->bd_disposition);
314 if (body_ext_1part->bd_language)
315 mailimap_body_fld_lang_free(body_ext_1part->bd_language);
316 if (body_ext_1part->bd_extension_list)
317 mailimap_body_ext_list_free(body_ext_1part->bd_extension_list);
318
319 free(body_ext_1part);
320}
321
322struct mailimap_body_ext_mpart *
323mailimap_body_ext_mpart_new(struct mailimap_body_fld_param * bd_parameter,
324 struct mailimap_body_fld_dsp * bd_disposition,
325 struct mailimap_body_fld_lang * bd_language,
326 clist * bd_extension_list)
327{
328 struct mailimap_body_ext_mpart * body_ext_mpart;
329
330 body_ext_mpart = malloc(sizeof(* body_ext_mpart));
331 if (body_ext_mpart == NULL)
332 return NULL;
333
334 body_ext_mpart->bd_parameter = bd_parameter;
335 body_ext_mpart->bd_disposition = bd_disposition;
336 body_ext_mpart->bd_language = bd_language;
337 body_ext_mpart->bd_extension_list = bd_extension_list;
338
339 return body_ext_mpart;
340}
341
342void
343mailimap_body_ext_mpart_free(struct mailimap_body_ext_mpart * body_ext_mpart)
344{
345 if (body_ext_mpart->bd_parameter != NULL)
346 mailimap_body_fld_param_free(body_ext_mpart->bd_parameter);
347 if (body_ext_mpart->bd_disposition)
348 mailimap_body_fld_dsp_free(body_ext_mpart->bd_disposition);
349 if (body_ext_mpart->bd_language)
350 mailimap_body_fld_lang_free(body_ext_mpart->bd_language);
351 if (body_ext_mpart->bd_extension_list)
352 mailimap_body_ext_list_free(body_ext_mpart->bd_extension_list);
353 free(body_ext_mpart);
354}
355
356
357struct mailimap_body_fields *
358mailimap_body_fields_new(struct mailimap_body_fld_param * bd_parameter,
359 char * bd_id,
360 char * bd_description,
361 struct mailimap_body_fld_enc * bd_encoding,
362 uint32_t bd_size)
363{
364 struct mailimap_body_fields * body_fields;
365
366 body_fields = malloc(sizeof(* body_fields));
367 if (body_fields == NULL)
368 return NULL;
369 body_fields->bd_parameter = bd_parameter;
370 body_fields->bd_id = bd_id;
371 body_fields->bd_description = bd_description;
372 body_fields->bd_encoding = bd_encoding;
373 body_fields->bd_size = bd_size;
374
375 return body_fields;
376}
377
378void
379mailimap_body_fields_free(struct mailimap_body_fields * body_fields)
380{
381 if (body_fields->bd_parameter != NULL)
382 mailimap_body_fld_param_free(body_fields->bd_parameter);
383 mailimap_body_fld_id_free(body_fields->bd_id);
384 mailimap_body_fld_desc_free(body_fields->bd_description);
385 mailimap_body_fld_enc_free(body_fields->bd_encoding);
386 free(body_fields);
387}
388
389
390
391
392
393
394void mailimap_body_fld_desc_free(char * body_fld_desc)
395{
396 mailimap_nstring_free(body_fld_desc);
397}
398
399
400
401
402struct mailimap_body_fld_dsp *
403mailimap_body_fld_dsp_new(char * dsp_type,
404 struct mailimap_body_fld_param * dsp_attributes)
405{
406 struct mailimap_body_fld_dsp * body_fld_dsp;
407
408 body_fld_dsp = malloc(sizeof(* body_fld_dsp));
409 if (body_fld_dsp == NULL)
410 return NULL;
411
412 body_fld_dsp->dsp_type = dsp_type;
413 body_fld_dsp->dsp_attributes = dsp_attributes;
414
415 return body_fld_dsp;
416}
417
418void mailimap_body_fld_dsp_free(struct mailimap_body_fld_dsp * bfd)
419{
420 if (bfd->dsp_type != NULL)
421 mailimap_string_free(bfd->dsp_type);
422 if (bfd->dsp_attributes != NULL)
423 mailimap_body_fld_param_free(bfd->dsp_attributes);
424 free(bfd);
425}
426
427
428
429struct mailimap_body_fld_enc *
430mailimap_body_fld_enc_new(int enc_type, char * enc_value)
431{
432 struct mailimap_body_fld_enc * body_fld_enc;
433
434 body_fld_enc = malloc(sizeof(* body_fld_enc));
435 if (body_fld_enc == NULL)
436 return NULL;
437
438 body_fld_enc->enc_type = enc_type;
439 body_fld_enc->enc_value = enc_value;
440
441 return body_fld_enc;
442}
443
444void mailimap_body_fld_enc_free(struct mailimap_body_fld_enc * bfe)
445{
446 if (bfe->enc_value)
447 mailimap_string_free(bfe->enc_value);
448 free(bfe);
449}
450
451
452
453void mailimap_body_fld_id_free(char * body_fld_id)
454{
455 mailimap_nstring_free(body_fld_id);
456}
457
458
459
460struct mailimap_body_fld_lang *
461mailimap_body_fld_lang_new(int lg_type, char * lg_single, clist * lg_list)
462{
463 struct mailimap_body_fld_lang * fld_lang;
464
465 fld_lang = malloc(sizeof(* fld_lang));
466 if (fld_lang == NULL)
467 return NULL;
468
469 fld_lang->lg_type = lg_type;
470 switch (lg_type) {
471 case MAILIMAP_BODY_FLD_LANG_SINGLE:
472 fld_lang->lg_data.lg_single = lg_single;
473 break;
474 case MAILIMAP_BODY_FLD_LANG_LIST:
475 fld_lang->lg_data.lg_list = lg_list;
476 break;
477 }
478
479 return fld_lang;
480}
481
482void
483mailimap_body_fld_lang_free(struct mailimap_body_fld_lang * fld_lang)
484{
485 switch (fld_lang->lg_type) {
486 case MAILIMAP_BODY_FLD_LANG_SINGLE:
487 mailimap_nstring_free(fld_lang->lg_data.lg_single);
488 break;
489 case MAILIMAP_BODY_FLD_LANG_LIST:
490 clist_foreach(fld_lang->lg_data.lg_list,
491 (clist_func) mailimap_string_free, NULL);
492 clist_free(fld_lang->lg_data.lg_list);
493 break;
494 }
495 free(fld_lang);
496}
497
498
499
500void mailimap_body_fld_md5_free(char * body_fld_md5)
501{
502 mailimap_nstring_free(body_fld_md5);
503}
504
505
506
507struct mailimap_single_body_fld_param *
508mailimap_single_body_fld_param_new(char * pa_name, char * pa_value)
509{
510 struct mailimap_single_body_fld_param * param;
511
512 param = malloc(sizeof(* param));
513 if (param == NULL)
514 return NULL;
515 param->pa_name = pa_name;
516 param->pa_value = pa_value;
517
518 return param;
519}
520
521void
522mailimap_single_body_fld_param_free(struct mailimap_single_body_fld_param * p)
523{
524 mailimap_string_free(p->pa_name);
525 mailimap_string_free(p->pa_value);
526 free(p);
527}
528
529
530struct mailimap_body_fld_param *
531mailimap_body_fld_param_new(clist * pa_list)
532{
533 struct mailimap_body_fld_param * fld_param;
534
535 fld_param = malloc(sizeof(* fld_param));
536 if (fld_param == NULL)
537 return NULL;
538 fld_param->pa_list = pa_list;
539
540 return fld_param;
541}
542
543void
544mailimap_body_fld_param_free(struct mailimap_body_fld_param * fld_param)
545{
546 clist_foreach(fld_param->pa_list,
547 (clist_func) mailimap_single_body_fld_param_free, NULL);
548 clist_free(fld_param->pa_list);
549 free(fld_param);
550}
551
552
553struct mailimap_body_type_1part *
554mailimap_body_type_1part_new(int bd_type,
555 struct mailimap_body_type_basic * bd_type_basic,
556 struct mailimap_body_type_msg * bd_type_msg,
557 struct mailimap_body_type_text * bd_type_text,
558 struct mailimap_body_ext_1part * bd_ext_1part)
559{
560 struct mailimap_body_type_1part * body_type_1part;
561
562 body_type_1part = malloc(sizeof(* body_type_1part));
563 if (body_type_1part == NULL)
564 return NULL;
565
566 body_type_1part->bd_type = bd_type;
567 switch (bd_type) {
568 case MAILIMAP_BODY_TYPE_1PART_BASIC:
569 body_type_1part->bd_data.bd_type_basic = bd_type_basic;
570 break;
571 case MAILIMAP_BODY_TYPE_1PART_MSG:
572 body_type_1part->bd_data.bd_type_msg = bd_type_msg;
573 break;
574 case MAILIMAP_BODY_TYPE_1PART_TEXT:
575 body_type_1part->bd_data.bd_type_text = bd_type_text;
576 break;
577 }
578 body_type_1part->bd_ext_1part = bd_ext_1part;
579
580 return body_type_1part;
581}
582
583void
584mailimap_body_type_1part_free(struct mailimap_body_type_1part * bt1p)
585{
586 switch (bt1p->bd_type) {
587 case MAILIMAP_BODY_TYPE_1PART_BASIC:
588 mailimap_body_type_basic_free(bt1p->bd_data.bd_type_basic);
589 break;
590 case MAILIMAP_BODY_TYPE_1PART_MSG:
591 mailimap_body_type_msg_free(bt1p->bd_data.bd_type_msg);
592 break;
593 case MAILIMAP_BODY_TYPE_1PART_TEXT:
594 mailimap_body_type_text_free(bt1p->bd_data.bd_type_text);
595 break;
596 }
597 if (bt1p->bd_ext_1part)
598 mailimap_body_ext_1part_free(bt1p->bd_ext_1part);
599
600 free(bt1p);
601}
602
603
604
605struct mailimap_body_type_basic *
606mailimap_body_type_basic_new(struct mailimap_media_basic * bd_media_basic,
607 struct mailimap_body_fields * bd_fields)
608{
609 struct mailimap_body_type_basic * body_type_basic;
610
611 body_type_basic = malloc(sizeof(* body_type_basic));
612 if (body_type_basic == NULL)
613 return NULL;
614
615 body_type_basic->bd_media_basic = bd_media_basic;
616 body_type_basic->bd_fields = bd_fields;
617
618 return body_type_basic;
619}
620
621void mailimap_body_type_basic_free(struct mailimap_body_type_basic *
622 body_type_basic)
623{
624 mailimap_media_basic_free(body_type_basic->bd_media_basic);
625 mailimap_body_fields_free(body_type_basic->bd_fields);
626 free(body_type_basic);
627}
628
629
630struct mailimap_body_type_mpart *
631mailimap_body_type_mpart_new(clist * bd_list, char * bd_media_subtype,
632 struct mailimap_body_ext_mpart * bd_ext_mpart)
633{
634 struct mailimap_body_type_mpart * body_type_mpart;
635
636 body_type_mpart = malloc(sizeof(* body_type_mpart));
637 if (body_type_mpart == NULL)
638 return NULL;
639
640 body_type_mpart->bd_list = bd_list;
641 body_type_mpart->bd_media_subtype = bd_media_subtype;
642 body_type_mpart->bd_ext_mpart = bd_ext_mpart;
643
644 return body_type_mpart;
645}
646
647void mailimap_body_type_mpart_free(struct mailimap_body_type_mpart *
648 body_type_mpart)
649{
650 clist_foreach(body_type_mpart->bd_list,
651 (clist_func) mailimap_body_free, NULL);
652 clist_free(body_type_mpart->bd_list);
653 mailimap_media_subtype_free(body_type_mpart->bd_media_subtype);
654 if (body_type_mpart->bd_ext_mpart)
655 mailimap_body_ext_mpart_free(body_type_mpart->bd_ext_mpart);
656
657 free(body_type_mpart);
658}
659
660
661struct mailimap_body_type_msg *
662mailimap_body_type_msg_new(struct mailimap_body_fields * bd_fields,
663 struct mailimap_envelope * bd_envelope,
664 struct mailimap_body * bd_body,
665 uint32_t bd_lines)
666{
667 struct mailimap_body_type_msg * body_type_msg;
668
669 body_type_msg = malloc(sizeof(* body_type_msg));
670 if (body_type_msg == NULL)
671 return NULL;
672
673 body_type_msg->bd_fields = bd_fields;
674 body_type_msg->bd_envelope = bd_envelope;
675 body_type_msg->bd_body = bd_body;
676 body_type_msg->bd_lines = bd_lines;
677
678 return body_type_msg;
679}
680
681void
682mailimap_body_type_msg_free(struct mailimap_body_type_msg * body_type_msg)
683{
684 mailimap_body_fields_free(body_type_msg->bd_fields);
685 mailimap_envelope_free(body_type_msg->bd_envelope);
686 mailimap_body_free(body_type_msg->bd_body);
687 free(body_type_msg);
688}
689
690
691
692struct mailimap_body_type_text *
693mailimap_body_type_text_new(char * bd_media_text,
694 struct mailimap_body_fields * bd_fields,
695 uint32_t bd_lines)
696{
697 struct mailimap_body_type_text * body_type_text;
698
699 body_type_text = malloc(sizeof(* body_type_text));
700 if (body_type_text == NULL)
701 return NULL;
702
703 body_type_text->bd_media_text = bd_media_text;
704 body_type_text->bd_fields = bd_fields;
705 body_type_text->bd_lines = bd_lines;
706
707 return body_type_text;
708}
709
710void
711mailimap_body_type_text_free(struct mailimap_body_type_text * body_type_text)
712{
713 mailimap_media_text_free(body_type_text->bd_media_text);
714 mailimap_body_fields_free(body_type_text->bd_fields);
715 free(body_type_text);
716}
717
718
719
720struct mailimap_capability *
721mailimap_capability_new(int cap_type, char * cap_auth_type, char * cap_name)
722{
723 struct mailimap_capability * cap;
724
725 cap = malloc(sizeof(* cap));
726 if (cap == NULL)
727 return NULL;
728 cap->cap_type = cap_type;
729 switch (cap_type) {
730 case MAILIMAP_CAPABILITY_AUTH_TYPE:
731 cap->cap_data.cap_auth_type = cap_auth_type;
732 break;
733 case MAILIMAP_CAPABILITY_NAME:
734 cap->cap_data.cap_name = cap_name;
735 break;
736 }
737
738 return cap;
739}
740
741void mailimap_capability_free(struct mailimap_capability * c)
742{
743 switch (c->cap_type) {
744 case MAILIMAP_CAPABILITY_AUTH_TYPE:
745 free(c->cap_data.cap_auth_type);
746 break;
747 case MAILIMAP_CAPABILITY_NAME:
748 free(c->cap_data.cap_name);
749 break;
750 }
751 free(c);
752}
753
754
755struct mailimap_capability_data *
756mailimap_capability_data_new(clist * cap_list)
757{
758 struct mailimap_capability_data * cap_data;
759
760 cap_data = malloc(sizeof(* cap_data));
761 if (cap_data == NULL)
762 return NULL;
763
764 cap_data->cap_list = cap_list;
765
766 return cap_data;
767}
768
769void
770mailimap_capability_data_free(struct mailimap_capability_data * cap_data)
771{
772 if (cap_data->cap_list) {
773 clist_foreach(cap_data->cap_list,
774 (clist_func) mailimap_capability_free, NULL);
775 clist_free(cap_data->cap_list);
776 }
777 free(cap_data);
778}
779
780
781
782
783struct mailimap_continue_req *
784mailimap_continue_req_new(int cr_type, struct mailimap_resp_text * cr_text,
785 char * cr_base64)
786{
787 struct mailimap_continue_req * cont_req;
788
789 cont_req = malloc(sizeof(* cont_req));
790 if (cont_req == NULL)
791 return NULL;
792 cont_req->cr_type = cr_type;
793 switch (cr_type) {
794 case MAILIMAP_CONTINUE_REQ_TEXT:
795 cont_req->cr_data.cr_text = cr_text;
796 break;
797 case MAILIMAP_CONTINUE_REQ_BASE64:
798 cont_req->cr_data.cr_base64 = cr_base64;
799 break;
800 }
801
802 return cont_req;
803}
804
805void mailimap_continue_req_free(struct mailimap_continue_req * cont_req)
806{
807 switch (cont_req->cr_type) {
808 case MAILIMAP_CONTINUE_REQ_TEXT:
809 mailimap_resp_text_free(cont_req->cr_data.cr_text);
810 break;
811 case MAILIMAP_CONTINUE_REQ_BASE64:
812 mailimap_base64_free(cont_req->cr_data.cr_base64);
813 break;
814 }
815 free(cont_req);
816}
817
818struct mailimap_date_time *
819mailimap_date_time_new(int dt_day, int dt_month, int dt_year, int dt_hour,
820 int dt_min, int dt_sec, int dt_zone)
821{
822 struct mailimap_date_time * date_time;
823
824 date_time = malloc(sizeof(* date_time));
825 if (date_time == NULL)
826 return NULL;
827
828 date_time->dt_day = dt_day;
829 date_time->dt_month = dt_month;
830 date_time->dt_year = dt_year;
831 date_time->dt_hour = dt_hour;
832 date_time->dt_min = dt_min;
833 date_time->dt_day = dt_sec;
834 date_time->dt_zone = dt_zone;
835
836 return date_time;
837}
838
839void mailimap_date_time_free(struct mailimap_date_time * date_time)
840{
841 free(date_time);
842}
843
844
845
846struct mailimap_envelope *
847mailimap_envelope_new(char * env_date, char * env_subject,
848 struct mailimap_env_from * env_from,
849 struct mailimap_env_sender * env_sender,
850 struct mailimap_env_reply_to * env_reply_to,
851 struct mailimap_env_to * env_to,
852 struct mailimap_env_cc* env_cc,
853 struct mailimap_env_bcc * env_bcc,
854 char * env_in_reply_to, char * env_message_id)
855{
856 struct mailimap_envelope * env;
857
858 env = malloc(sizeof(* env));
859 if (env == NULL)
860 return NULL;
861
862 env->env_date = env_date;
863 env->env_subject = env_subject;
864 env->env_from = env_from;
865 env->env_sender = env_sender;
866 env->env_reply_to = env_reply_to;
867 env->env_to = env_to;
868 env->env_cc = env_cc;
869 env->env_bcc = env_bcc;
870 env->env_in_reply_to = env_in_reply_to;
871 env->env_message_id = env_message_id;
872
873 return env;
874}
875
876
877void mailimap_envelope_free(struct mailimap_envelope * env)
878{
879 if (env->env_date)
880 mailimap_env_date_free(env->env_date);
881 if (env->env_subject)
882 mailimap_env_subject_free(env->env_subject);
883 if (env->env_from)
884 mailimap_env_from_free(env->env_from);
885 if (env->env_sender)
886 mailimap_env_sender_free(env->env_sender);
887 if (env->env_reply_to)
888 mailimap_env_reply_to_free(env->env_reply_to);
889 if (env->env_to)
890 mailimap_env_to_free(env->env_to);
891 if (env->env_cc)
892 mailimap_env_cc_free(env->env_cc);
893 if (env->env_bcc)
894 mailimap_env_bcc_free(env->env_bcc);
895 if (env->env_in_reply_to)
896 mailimap_env_in_reply_to_free(env->env_in_reply_to);
897 if (env->env_message_id)
898 mailimap_env_message_id_free(env->env_message_id);
899
900 free(env);
901}
902
903
904static void mailimap_address_list_free(clist * addr_list)
905{
906 if (addr_list != NULL) {
907 clist_foreach(addr_list, (clist_func) mailimap_address_free, NULL);
908 clist_free(addr_list);
909 }
910}
911
912
913struct mailimap_env_bcc * mailimap_env_bcc_new(clist * bcc_list)
914{
915 struct mailimap_env_bcc * env_bcc;
916
917 env_bcc = malloc(sizeof(* env_bcc));
918 if (env_bcc == NULL)
919 return NULL;
920 env_bcc->bcc_list = bcc_list;
921
922 return env_bcc;
923}
924
925void mailimap_env_bcc_free(struct mailimap_env_bcc * env_bcc)
926{
927 mailimap_address_list_free(env_bcc->bcc_list);
928 free(env_bcc);
929}
930
931
932struct mailimap_env_cc * mailimap_env_cc_new(clist * cc_list)
933{
934 struct mailimap_env_cc * env_cc;
935
936 env_cc = malloc(sizeof(* env_cc));
937 if (env_cc == NULL)
938 return NULL;
939 env_cc->cc_list = cc_list;
940
941 return env_cc;
942}
943
944void mailimap_env_cc_free(struct mailimap_env_cc * env_cc)
945{
946 mailimap_address_list_free(env_cc->cc_list);
947 free(env_cc);
948}
949
950
951void mailimap_env_date_free(char * date)
952{
953 mailimap_nstring_free(date);
954}
955
956
957struct mailimap_env_from * mailimap_env_from_new(clist * frm_list)
958{
959 struct mailimap_env_from * env_from;
960
961 env_from = malloc(sizeof(* env_from));
962 if (env_from == NULL)
963 return NULL;
964 env_from->frm_list = frm_list;
965
966 return env_from;
967}
968
969void mailimap_env_from_free(struct mailimap_env_from * env_from)
970{
971 mailimap_address_list_free(env_from->frm_list);
972 free(env_from);
973}
974
975
976void mailimap_env_in_reply_to_free(char * in_reply_to)
977{
978 mailimap_nstring_free(in_reply_to);
979}
980
981void mailimap_env_message_id_free(char * message_id)
982{
983 mailimap_nstring_free(message_id);
984}
985
986struct mailimap_env_reply_to * mailimap_env_reply_to_new(clist * rt_list)
987{
988 struct mailimap_env_reply_to * env_reply_to;
989
990 env_reply_to = malloc(sizeof(* env_reply_to));
991 if (env_reply_to == NULL)
992 return NULL;
993 env_reply_to->rt_list = rt_list;
994
995 return env_reply_to;
996}
997
998void
999mailimap_env_reply_to_free(struct mailimap_env_reply_to * env_reply_to)
1000{
1001 mailimap_address_list_free(env_reply_to->rt_list);
1002 free(env_reply_to);
1003}
1004
1005struct mailimap_env_sender * mailimap_env_sender_new(clist * snd_list)
1006{
1007 struct mailimap_env_sender * env_sender;
1008
1009 env_sender = malloc(sizeof(* env_sender));
1010 if (env_sender == NULL)
1011 return NULL;
1012 env_sender->snd_list = snd_list;
1013
1014 return env_sender;
1015}
1016
1017void mailimap_env_sender_free(struct mailimap_env_sender * env_sender)
1018{
1019 mailimap_address_list_free(env_sender->snd_list);
1020 free(env_sender);
1021}
1022
1023void mailimap_env_subject_free(char * subject)
1024{
1025 mailimap_nstring_free(subject);
1026}
1027
1028struct mailimap_env_to * mailimap_env_to_new(clist * to_list)
1029{
1030 struct mailimap_env_to * env_to;
1031
1032 env_to = malloc(sizeof(* env_to));
1033 if (env_to == NULL)
1034 return NULL;
1035 env_to->to_list = to_list;
1036
1037 return env_to;
1038}
1039
1040void mailimap_env_to_free(struct mailimap_env_to * env_to)
1041{
1042 mailimap_address_list_free(env_to->to_list);
1043 free(env_to);
1044}
1045
1046
1047
1048struct mailimap_flag * mailimap_flag_new(int fl_type,
1049 char * fl_keyword, char * fl_extension)
1050{
1051 struct mailimap_flag * f;
1052
1053 f = malloc(sizeof(* f));
1054 if (f == NULL)
1055 return NULL;
1056 f->fl_type = fl_type;
1057 switch (fl_type) {
1058 case MAILIMAP_FLAG_KEYWORD:
1059 f->fl_data.fl_keyword = fl_keyword;
1060 break;
1061 case MAILIMAP_FLAG_EXTENSION:
1062 f->fl_data.fl_extension = fl_extension;
1063 break;
1064 }
1065
1066 return f;
1067}
1068
1069void mailimap_flag_free(struct mailimap_flag * f)
1070{
1071 switch (f->fl_type) {
1072 case MAILIMAP_FLAG_KEYWORD:
1073 mailimap_flag_keyword_free(f->fl_data.fl_keyword);
1074 break;
1075 case MAILIMAP_FLAG_EXTENSION:
1076 mailimap_flag_extension_free(f->fl_data.fl_extension);
1077 break;
1078 }
1079 free(f);
1080}
1081
1082
1083
1084void mailimap_flag_extension_free(char * flag_extension)
1085{
1086 mailimap_atom_free(flag_extension);
1087}
1088
1089
1090
1091struct mailimap_flag_fetch *
1092mailimap_flag_fetch_new(int fl_type, struct mailimap_flag * fl_flag)
1093{
1094 struct mailimap_flag_fetch * flag_fetch;
1095
1096 flag_fetch = malloc(sizeof(* flag_fetch));
1097 if (flag_fetch == NULL)
1098 return NULL;
1099
1100 flag_fetch->fl_type = fl_type;
1101 flag_fetch->fl_flag = fl_flag;
1102
1103 return flag_fetch;
1104}
1105
1106void mailimap_flag_fetch_free(struct mailimap_flag_fetch * flag_fetch)
1107{
1108 if (flag_fetch->fl_flag)
1109 mailimap_flag_free(flag_fetch->fl_flag);
1110 free(flag_fetch);
1111}
1112
1113
1114
1115void mailimap_flag_keyword_free(char * flag_keyword)
1116{
1117 mailimap_atom_free(flag_keyword);
1118}
1119
1120
1121
1122
1123struct mailimap_flag_list *
1124mailimap_flag_list_new(clist * fl_list)
1125{
1126 struct mailimap_flag_list * flag_list;
1127
1128 flag_list = malloc(sizeof(* flag_list));
1129 if (flag_list == NULL)
1130 return NULL;
1131 flag_list->fl_list = fl_list;
1132
1133 return flag_list;
1134}
1135
1136void mailimap_flag_list_free(struct mailimap_flag_list * flag_list)
1137{
1138 clist_foreach(flag_list->fl_list, (clist_func) mailimap_flag_free, NULL);
1139 clist_free(flag_list->fl_list);
1140 free(flag_list);
1141}
1142
1143
1144
1145
1146
1147struct mailimap_flag_perm *
1148mailimap_flag_perm_new(int fl_type, struct mailimap_flag * fl_flag)
1149{
1150 struct mailimap_flag_perm * flag_perm;
1151
1152 flag_perm = malloc(sizeof(* flag_perm));
1153 if (flag_perm == NULL)
1154 return NULL;
1155
1156 flag_perm->fl_type = fl_type;
1157 flag_perm->fl_flag = fl_flag;
1158
1159 return flag_perm;
1160}
1161
1162void mailimap_flag_perm_free(struct mailimap_flag_perm * flag_perm)
1163{
1164 if (flag_perm->fl_flag != NULL)
1165 mailimap_flag_free(flag_perm->fl_flag);
1166 free(flag_perm);
1167}
1168
1169
1170
1171
1172struct mailimap_greeting *
1173mailimap_greeting_new(int gr_type,
1174 struct mailimap_resp_cond_auth * gr_auth,
1175 struct mailimap_resp_cond_bye * gr_bye)
1176{
1177 struct mailimap_greeting * greeting;
1178
1179 greeting = malloc(sizeof(* greeting));
1180 if (greeting == NULL)
1181 return NULL;
1182 greeting->gr_type = gr_type;
1183 switch (gr_type) {
1184 case MAILIMAP_GREETING_RESP_COND_AUTH:
1185 greeting->gr_data.gr_auth = gr_auth;
1186 break;
1187 case MAILIMAP_GREETING_RESP_COND_BYE:
1188 greeting->gr_data.gr_bye = gr_bye;
1189 break;
1190 }
1191
1192 return greeting;
1193}
1194
1195void mailimap_greeting_free(struct mailimap_greeting * greeting)
1196{
1197 switch (greeting->gr_type) {
1198 case MAILIMAP_GREETING_RESP_COND_AUTH:
1199 mailimap_resp_cond_auth_free(greeting->gr_data.gr_auth);
1200 break;
1201 case MAILIMAP_GREETING_RESP_COND_BYE:
1202 mailimap_resp_cond_bye_free(greeting->gr_data.gr_bye);
1203 break;
1204 }
1205 free(greeting);
1206}
1207
1208
1209
1210void
1211mailimap_header_fld_name_free(char * header_fld_name)
1212{
1213 mailimap_astring_free(header_fld_name);
1214}
1215
1216
1217
1218struct mailimap_header_list *
1219mailimap_header_list_new(clist * hdr_list)
1220{
1221 struct mailimap_header_list * header_list;
1222
1223 header_list = malloc(sizeof(* header_list));
1224 if (header_list == NULL)
1225 return NULL;
1226
1227 header_list->hdr_list = hdr_list;
1228
1229 return header_list;
1230}
1231
1232void
1233mailimap_header_list_free(struct mailimap_header_list * header_list)
1234{
1235 clist_foreach(header_list->hdr_list,
1236 (clist_func) mailimap_header_fld_name_free,
1237 NULL);
1238 clist_free(header_list->hdr_list);
1239 free(header_list);
1240}
1241
1242
1243
1244void mailimap_literal_free(char * literal)
1245{
1246 /* free(literal); */
1247 mmap_string_unref(literal);
1248}
1249
1250void mailimap_mailbox_free(char * mb)
1251{
1252 mailimap_astring_free(mb);
1253}
1254
1255
1256
1257
1258struct mailimap_status_info *
1259mailimap_status_info_new(int st_att, uint32_t st_value)
1260{
1261 struct mailimap_status_info * info;
1262
1263 info = malloc(sizeof(* info));
1264 if (info == NULL)
1265 return NULL;
1266 info->st_att = st_att;
1267 info->st_value = st_value;
1268
1269 return info;
1270}
1271
1272void mailimap_status_info_free(struct mailimap_status_info * info)
1273{
1274 free(info);
1275}
1276
1277
1278
1279struct mailimap_mailbox_data_status *
1280mailimap_mailbox_data_status_new(char * st_mailbox,
1281 clist * st_info_list)
1282{
1283 struct mailimap_mailbox_data_status * mb_data_status;
1284
1285 mb_data_status = malloc(sizeof(* mb_data_status));
1286 if (mb_data_status == NULL)
1287 return NULL;
1288 mb_data_status->st_mailbox = st_mailbox;
1289 mb_data_status->st_info_list = st_info_list;
1290
1291 return mb_data_status;
1292}
1293
1294void
1295mailimap_mailbox_data_search_free(clist * data_search)
1296{
1297 clist_foreach(data_search, (clist_func) mailimap_number_alloc_free, NULL);
1298 clist_free(data_search);
1299}
1300
1301void
1302mailimap_mailbox_data_status_free(struct mailimap_mailbox_data_status * info)
1303{
1304 mailimap_mailbox_free(info->st_mailbox);
1305 clist_foreach(info->st_info_list, (clist_func) mailimap_status_info_free,
1306 NULL);
1307 clist_free(info->st_info_list);
1308 free(info);
1309}
1310
1311
1312static void
1313mailimap_mailbox_data_flags_free(struct mailimap_flag_list * flag_list)
1314{
1315 mailimap_flag_list_free(flag_list);
1316}
1317
1318static void
1319mailimap_mailbox_data_list_free(struct mailimap_mailbox_list * mb_list)
1320{
1321 mailimap_mailbox_list_free(mb_list);
1322}
1323
1324static void
1325mailimap_mailbox_data_lsub_free(struct mailimap_mailbox_list * mb_lsub)
1326{
1327 mailimap_mailbox_list_free(mb_lsub);
1328}
1329
1330
1331
1332
1333
1334
1335struct mailimap_mailbox_data *
1336mailimap_mailbox_data_new(int mbd_type, struct mailimap_flag_list * mbd_flags,
1337 struct mailimap_mailbox_list * mbd_list,
1338 struct mailimap_mailbox_list * mbd_lsub,
1339 clist * mbd_search,
1340 struct mailimap_mailbox_data_status * mbd_status,
1341 uint32_t mbd_exists,
1342 uint32_t mbd_recent)
1343{
1344 struct mailimap_mailbox_data * data;
1345
1346 data = malloc(sizeof(* data));
1347 if (data == NULL)
1348 return NULL;
1349
1350 data->mbd_type = mbd_type;
1351 switch (mbd_type) {
1352 case MAILIMAP_MAILBOX_DATA_FLAGS:
1353 data->mbd_data.mbd_flags = mbd_flags;
1354 break;
1355 case MAILIMAP_MAILBOX_DATA_LIST:
1356 data->mbd_data.mbd_list = mbd_list;
1357 break;
1358 case MAILIMAP_MAILBOX_DATA_LSUB:
1359 data->mbd_data.mbd_lsub = mbd_lsub;
1360 break;
1361 case MAILIMAP_MAILBOX_DATA_SEARCH:
1362 data->mbd_data.mbd_search = mbd_search;
1363 break;
1364 case MAILIMAP_MAILBOX_DATA_STATUS:
1365 data->mbd_data.mbd_status = mbd_status;
1366 break;
1367 case MAILIMAP_MAILBOX_DATA_EXISTS:
1368 data->mbd_data.mbd_exists = mbd_exists;
1369 break;
1370 case MAILIMAP_MAILBOX_DATA_RECENT:
1371 data->mbd_data.mbd_recent = mbd_recent;
1372 break;
1373 }
1374
1375 return data;
1376}
1377
1378void
1379mailimap_mailbox_data_free(struct mailimap_mailbox_data * mb_data)
1380{
1381 switch (mb_data->mbd_type) {
1382 case MAILIMAP_MAILBOX_DATA_FLAGS:
1383 if (mb_data->mbd_data.mbd_flags != NULL)
1384 mailimap_mailbox_data_flags_free(mb_data->mbd_data.mbd_flags);
1385 break;
1386 case MAILIMAP_MAILBOX_DATA_LIST:
1387 if (mb_data->mbd_data.mbd_list != NULL)
1388 mailimap_mailbox_data_list_free(mb_data->mbd_data.mbd_list);
1389 break;
1390 case MAILIMAP_MAILBOX_DATA_LSUB:
1391 if (mb_data->mbd_data.mbd_lsub != NULL)
1392 mailimap_mailbox_data_lsub_free(mb_data->mbd_data.mbd_lsub);
1393 break;
1394 case MAILIMAP_MAILBOX_DATA_SEARCH:
1395 if (mb_data->mbd_data.mbd_search != NULL)
1396 mailimap_mailbox_data_search_free(mb_data->mbd_data.mbd_search);
1397 break;
1398 case MAILIMAP_MAILBOX_DATA_STATUS:
1399 if (mb_data->mbd_data.mbd_status != NULL)
1400 mailimap_mailbox_data_status_free(mb_data->mbd_data.mbd_status);
1401 break;
1402 }
1403 free(mb_data);
1404}
1405
1406
1407
1408
1409
1410struct mailimap_mbx_list_flags *
1411mailimap_mbx_list_flags_new(int mbf_type, clist * mbf_oflags,
1412 int mbf_sflag)
1413{
1414 struct mailimap_mbx_list_flags * mbx_list_flags;
1415
1416 mbx_list_flags = malloc(sizeof(* mbx_list_flags));
1417 if (mbx_list_flags == NULL)
1418 return NULL;
1419
1420 mbx_list_flags->mbf_type = mbf_type;
1421 mbx_list_flags->mbf_oflags = mbf_oflags;
1422 mbx_list_flags->mbf_sflag = mbf_sflag;
1423
1424 return mbx_list_flags;
1425}
1426
1427void
1428mailimap_mbx_list_flags_free(struct mailimap_mbx_list_flags * mbx_list_flags)
1429{
1430 clist_foreach(mbx_list_flags->mbf_oflags,
1431 (clist_func) mailimap_mbx_list_oflag_free,
1432 NULL);
1433 clist_free(mbx_list_flags->mbf_oflags);
1434
1435 free(mbx_list_flags);
1436}
1437
1438
1439struct mailimap_mbx_list_oflag *
1440mailimap_mbx_list_oflag_new(int of_type, char * of_flag_ext)
1441{
1442 struct mailimap_mbx_list_oflag * oflag;
1443
1444 oflag = malloc(sizeof(* oflag));
1445 if (oflag == NULL)
1446 return NULL;
1447
1448 oflag->of_type = of_type;
1449 oflag->of_flag_ext = of_flag_ext;
1450
1451 return oflag;
1452}
1453
1454void
1455mailimap_mbx_list_oflag_free(struct mailimap_mbx_list_oflag * oflag)
1456{
1457 if (oflag->of_flag_ext != NULL)
1458 mailimap_flag_extension_free(oflag->of_flag_ext);
1459 free(oflag);
1460}
1461
1462
1463
1464struct mailimap_mailbox_list *
1465mailimap_mailbox_list_new(struct mailimap_mbx_list_flags * mbx_flags,
1466 char mb_delimiter, char * mb_name)
1467{
1468 struct mailimap_mailbox_list * mb_list;
1469
1470 mb_list = malloc(sizeof(* mb_list));
1471 if (mb_list == NULL)
1472 return NULL;
1473
1474 mb_list->mb_flag = mbx_flags;
1475 mb_list->mb_delimiter = mb_delimiter;
1476 mb_list->mb_name = mb_name;
1477
1478 return mb_list;
1479}
1480
1481void
1482mailimap_mailbox_list_free(struct mailimap_mailbox_list * mb_list)
1483{
1484 if (mb_list->mb_flag != NULL)
1485 mailimap_mbx_list_flags_free(mb_list->mb_flag);
1486 if (mb_list->mb_name != NULL)
1487 mailimap_mailbox_free(mb_list->mb_name);
1488 free(mb_list);
1489}
1490
1491
1492
1493struct mailimap_media_basic *
1494mailimap_media_basic_new(int med_type,
1495 char * med_basic_type, char * med_subtype)
1496{
1497 struct mailimap_media_basic * media_basic;
1498
1499 media_basic = malloc(sizeof(* media_basic));
1500 if (media_basic == NULL)
1501 return NULL;
1502 media_basic->med_type = med_type;
1503 media_basic->med_basic_type = med_basic_type;
1504 media_basic->med_subtype = med_subtype;
1505
1506 return media_basic;
1507}
1508
1509void
1510mailimap_media_basic_free(struct mailimap_media_basic * media_basic)
1511{
1512 mailimap_string_free(media_basic->med_basic_type);
1513 mailimap_media_subtype_free(media_basic->med_subtype);
1514 free(media_basic);
1515}
1516
1517
1518
1519void mailimap_media_subtype_free(char * media_subtype)
1520{
1521 mmap_string_unref(media_subtype);
1522}
1523
1524
1525void mailimap_media_text_free(char * media_text)
1526{
1527 mailimap_media_subtype_free(media_text);
1528}
1529
1530
1531
1532struct mailimap_message_data *
1533mailimap_message_data_new(uint32_t mdt_number, int mdt_type,
1534 struct mailimap_msg_att * mdt_msg_att)
1535{
1536 struct mailimap_message_data * msg_data;
1537
1538 msg_data = malloc(sizeof(* msg_data));
1539 if (msg_data == NULL)
1540 free(msg_data);
1541
1542 msg_data->mdt_number = mdt_number;
1543 msg_data->mdt_type = mdt_type;
1544 msg_data->mdt_msg_att = mdt_msg_att;
1545
1546 return msg_data;
1547}
1548
1549void
1550mailimap_message_data_free(struct mailimap_message_data * msg_data)
1551{
1552 if (msg_data->mdt_msg_att != NULL)
1553 mailimap_msg_att_free(msg_data->mdt_msg_att);
1554 free(msg_data);
1555}
1556
1557
1558
1559
1560struct mailimap_msg_att_item *
1561mailimap_msg_att_item_new(int att_type,
1562 struct mailimap_msg_att_dynamic * att_dyn,
1563 struct mailimap_msg_att_static * att_static)
1564{
1565 struct mailimap_msg_att_item * item;
1566
1567 item = malloc(sizeof(* item));
1568 if (item == NULL)
1569 return item;
1570
1571 item->att_type = att_type;
1572 switch (att_type) {
1573 case MAILIMAP_MSG_ATT_ITEM_DYNAMIC:
1574 item->att_data.att_dyn = att_dyn;
1575 break;
1576 case MAILIMAP_MSG_ATT_ITEM_STATIC:
1577 item->att_data.att_static = att_static;
1578 break;
1579 }
1580
1581 return item;
1582}
1583
1584void
1585mailimap_msg_att_item_free(struct mailimap_msg_att_item * item)
1586{
1587 switch (item->att_type) {
1588 case MAILIMAP_MSG_ATT_ITEM_DYNAMIC:
1589 mailimap_msg_att_dynamic_free(item->att_data.att_dyn);
1590 break;
1591 case MAILIMAP_MSG_ATT_ITEM_STATIC:
1592 mailimap_msg_att_static_free(item->att_data.att_static);
1593 break;
1594 }
1595 free(item);
1596}
1597
1598
1599struct mailimap_msg_att *
1600mailimap_msg_att_new(clist * att_list)
1601{
1602 struct mailimap_msg_att * msg_att;
1603
1604 msg_att = malloc(sizeof(* msg_att));
1605 if (msg_att == NULL)
1606 return NULL;
1607
1608 msg_att->att_list = att_list;
1609 msg_att->att_number = 0;
1610
1611 return msg_att;
1612}
1613
1614void mailimap_msg_att_free(struct mailimap_msg_att * msg_att)
1615{
1616 clist_foreach(msg_att->att_list,
1617 (clist_func) mailimap_msg_att_item_free, NULL);
1618 clist_free(msg_att->att_list);
1619 free(msg_att);
1620}
1621
1622
1623
1624struct mailimap_msg_att_dynamic *
1625mailimap_msg_att_dynamic_new(clist * att_list)
1626{
1627 struct mailimap_msg_att_dynamic * msg_att_dyn;
1628
1629 msg_att_dyn = malloc(sizeof(* msg_att_dyn));
1630 if (msg_att_dyn == NULL)
1631 return NULL;
1632
1633 msg_att_dyn->att_list = att_list;
1634
1635 return msg_att_dyn;
1636}
1637
1638void
1639mailimap_msg_att_dynamic_free(struct mailimap_msg_att_dynamic * msg_att_dyn)
1640{
1641 if (msg_att_dyn->att_list != NULL) {
1642 clist_foreach(msg_att_dyn->att_list,
1643 (clist_func) mailimap_flag_fetch_free,
1644 NULL);
1645 clist_free(msg_att_dyn->att_list);
1646 }
1647 free(msg_att_dyn);
1648}
1649
1650
1651struct mailimap_msg_att_body_section *
1652mailimap_msg_att_body_section_new(struct mailimap_section * sec_section,
1653 uint32_t sec_origin_octet,
1654 char * sec_body_part,
1655 size_t sec_length)
1656{
1657 struct mailimap_msg_att_body_section * msg_att_body_section;
1658
1659 msg_att_body_section = malloc(sizeof(* msg_att_body_section));
1660 if (msg_att_body_section == NULL)
1661 return NULL;
1662
1663 msg_att_body_section->sec_section = sec_section;
1664 msg_att_body_section->sec_origin_octet = sec_origin_octet;
1665 msg_att_body_section->sec_body_part = sec_body_part;
1666 msg_att_body_section->sec_length = sec_length;
1667
1668 return msg_att_body_section;
1669}
1670
1671void
1672mailimap_msg_att_body_section_free(struct mailimap_msg_att_body_section *
1673 msg_att_body_section)
1674{
1675 if (msg_att_body_section->sec_section != NULL)
1676 mailimap_section_free(msg_att_body_section->sec_section);
1677 if (msg_att_body_section->sec_body_part != NULL)
1678 mailimap_nstring_free(msg_att_body_section->sec_body_part);
1679 free(msg_att_body_section);
1680}
1681
1682
1683
1684
1685
1686
1687void mailimap_msg_att_envelope_free(struct mailimap_envelope * env)
1688{
1689 mailimap_envelope_free(env);
1690}
1691
1692void
1693mailimap_msg_att_internaldate_free(struct mailimap_date_time * date_time)
1694{
1695 mailimap_date_time_free(date_time);
1696}
1697
1698void
1699mailimap_msg_att_rfc822_free(char * str)
1700{
1701 mailimap_nstring_free(str);
1702}
1703
1704
1705void
1706mailimap_msg_att_rfc822_header_free(char * str)
1707{
1708 mailimap_nstring_free(str);
1709}
1710
1711void
1712mailimap_msg_att_rfc822_text_free(char * str)
1713{
1714 mailimap_nstring_free(str);
1715}
1716
1717void
1718mailimap_msg_att_body_free(struct mailimap_body * body)
1719{
1720 mailimap_body_free(body);
1721}
1722
1723void
1724mailimap_msg_att_bodystructure_free(struct mailimap_body * body)
1725{
1726 mailimap_body_free(body);
1727}
1728
1729
1730
1731struct mailimap_msg_att_static *
1732mailimap_msg_att_static_new(int att_type, struct mailimap_envelope * att_env,
1733 struct mailimap_date_time * att_internal_date,
1734 char * att_rfc822,
1735 char * att_rfc822_header,
1736 char * att_rfc822_text,
1737 size_t att_length,
1738 uint32_t att_rfc822_size,
1739 struct mailimap_body * att_bodystructure,
1740 struct mailimap_body * att_body,
1741 struct mailimap_msg_att_body_section * att_body_section,
1742 uint32_t att_uid)
1743{
1744 struct mailimap_msg_att_static * item;
1745
1746 item = malloc(sizeof(* item));
1747 if (item == NULL)
1748 return FALSE;
1749
1750 item->att_type = att_type;
1751 switch (att_type) {
1752 case MAILIMAP_MSG_ATT_ENVELOPE:
1753 item->att_data.att_env = att_env;
1754 break;
1755 case MAILIMAP_MSG_ATT_INTERNALDATE:
1756 item->att_data.att_internal_date = att_internal_date;
1757 break;
1758 case MAILIMAP_MSG_ATT_RFC822:
1759 item->att_data.att_rfc822.att_content = att_rfc822;
1760 item->att_data.att_rfc822.att_length = att_length;
1761 break;
1762 case MAILIMAP_MSG_ATT_RFC822_HEADER:
1763 item->att_data.att_rfc822_header.att_content = att_rfc822_header;
1764 item->att_data.att_rfc822_header.att_length = att_length;
1765 break;
1766 case MAILIMAP_MSG_ATT_RFC822_TEXT:
1767 item->att_data.att_rfc822_text.att_content = att_rfc822_text;
1768 item->att_data.att_rfc822_text.att_length = att_length;
1769 break;
1770 case MAILIMAP_MSG_ATT_RFC822_SIZE:
1771 item->att_data.att_rfc822_size = att_rfc822_size;
1772 break;
1773 case MAILIMAP_MSG_ATT_BODY:
1774 item->att_data.att_body = att_body;
1775 break;
1776 case MAILIMAP_MSG_ATT_BODYSTRUCTURE:
1777 item->att_data.att_bodystructure = att_bodystructure;
1778 break;
1779 case MAILIMAP_MSG_ATT_BODY_SECTION:
1780 item->att_data.att_body_section = att_body_section;
1781 break;
1782 case MAILIMAP_MSG_ATT_UID:
1783 item->att_data.att_uid = att_uid;
1784 break;
1785 }
1786
1787 return item;
1788}
1789
1790void
1791mailimap_msg_att_static_free(struct mailimap_msg_att_static * item)
1792{
1793 switch (item->att_type) {
1794 case MAILIMAP_MSG_ATT_ENVELOPE:
1795 if (item->att_data.att_env != NULL)
1796 mailimap_msg_att_envelope_free(item->att_data.att_env);
1797 break;
1798 case MAILIMAP_MSG_ATT_INTERNALDATE:
1799 if (item->att_data.att_internal_date != NULL)
1800 mailimap_msg_att_internaldate_free(item->att_data.att_internal_date);
1801 break;
1802 case MAILIMAP_MSG_ATT_RFC822:
1803 if (item->att_data.att_rfc822.att_content != NULL)
1804 mailimap_msg_att_rfc822_free(item->att_data.att_rfc822.att_content);
1805 break;
1806 case MAILIMAP_MSG_ATT_RFC822_HEADER:
1807 if (item->att_data.att_rfc822_header.att_content != NULL)
1808 mailimap_msg_att_rfc822_header_free(item->att_data.att_rfc822_header.att_content);
1809 break;
1810 case MAILIMAP_MSG_ATT_RFC822_TEXT:
1811 if (item->att_data.att_rfc822_text.att_content != NULL)
1812 mailimap_msg_att_rfc822_text_free(item->att_data.att_rfc822_text.att_content);
1813 break;
1814 case MAILIMAP_MSG_ATT_BODYSTRUCTURE:
1815 if (item->att_data.att_bodystructure != NULL)
1816 mailimap_msg_att_bodystructure_free(item->att_data.att_bodystructure);
1817 break;
1818 case MAILIMAP_MSG_ATT_BODY:
1819 if (item->att_data.att_body != NULL)
1820 mailimap_msg_att_body_free(item->att_data.att_body);
1821 break;
1822 case MAILIMAP_MSG_ATT_BODY_SECTION:
1823 if (item->att_data.att_body_section != NULL)
1824 mailimap_msg_att_body_section_free(item->att_data.att_body_section);
1825 break;
1826 }
1827 free(item);
1828}
1829
1830
1831
1832
1833void mailimap_nstring_free(char * str)
1834{
1835 if (str != NULL)
1836 mailimap_string_free(str);
1837}
1838
1839
1840
1841
1842
1843
1844
1845struct mailimap_cont_req_or_resp_data *
1846mailimap_cont_req_or_resp_data_new(int rsp_type,
1847 struct mailimap_continue_req * rsp_cont_req,
1848 struct mailimap_response_data * rsp_resp_data)
1849{
1850 struct mailimap_cont_req_or_resp_data * cont_req_or_resp_data;
1851
1852 cont_req_or_resp_data = malloc(sizeof(* cont_req_or_resp_data));
1853 if (cont_req_or_resp_data == NULL)
1854 return NULL;
1855
1856 cont_req_or_resp_data->rsp_type = rsp_type;
1857 switch (rsp_type) {
1858 case MAILIMAP_RESP_CONT_REQ:
1859 cont_req_or_resp_data->rsp_data.rsp_cont_req = rsp_cont_req;
1860 break;
1861 case MAILIMAP_RESP_RESP_DATA:
1862 cont_req_or_resp_data->rsp_data.rsp_resp_data = rsp_resp_data;
1863 break;
1864 }
1865
1866 return cont_req_or_resp_data;
1867}
1868
1869void
1870mailimap_cont_req_or_resp_data_free(struct mailimap_cont_req_or_resp_data *
1871 cont_req_or_resp_data)
1872{
1873 switch (cont_req_or_resp_data->rsp_type) {
1874 case MAILIMAP_RESP_CONT_REQ:
1875 if (cont_req_or_resp_data->rsp_data.rsp_cont_req != NULL)
1876 mailimap_continue_req_free(cont_req_or_resp_data->rsp_data.rsp_cont_req);
1877 break;
1878 case MAILIMAP_RESP_RESP_DATA:
1879 if (cont_req_or_resp_data->rsp_data.rsp_resp_data != NULL)
1880 mailimap_response_data_free(cont_req_or_resp_data->rsp_data.rsp_resp_data);
1881 break;
1882 }
1883 free(cont_req_or_resp_data);
1884}
1885
1886
1887
1888
1889struct mailimap_response *
1890mailimap_response_new(clist * rsp_cont_req_or_resp_data_list,
1891 struct mailimap_response_done * rsp_resp_done)
1892{
1893 struct mailimap_response * resp;
1894
1895 resp = malloc(sizeof(* resp));
1896 if (resp == NULL)
1897 return NULL;
1898
1899 resp->rsp_cont_req_or_resp_data_list = rsp_cont_req_or_resp_data_list;
1900 resp->rsp_resp_done = rsp_resp_done;
1901
1902 return resp;
1903}
1904
1905void
1906mailimap_response_free(struct mailimap_response * resp)
1907{
1908 if (resp->rsp_cont_req_or_resp_data_list != NULL) {
1909 clist_foreach(resp->rsp_cont_req_or_resp_data_list,
1910 (clist_func) mailimap_cont_req_or_resp_data_free, NULL);
1911 clist_free(resp->rsp_cont_req_or_resp_data_list);
1912 }
1913 mailimap_response_done_free(resp->rsp_resp_done);
1914 free(resp);
1915}
1916
1917
1918
1919struct mailimap_response_data *
1920mailimap_response_data_new(int rsp_type,
1921 struct mailimap_resp_cond_state * rsp_cond_state,
1922 struct mailimap_resp_cond_bye * rsp_bye,
1923 struct mailimap_mailbox_data * rsp_mailbox_data,
1924 struct mailimap_message_data * rsp_message_data,
1925 struct mailimap_capability_data * rsp_capability_data)
1926{
1927 struct mailimap_response_data * resp_data;
1928
1929 resp_data = malloc(sizeof(* resp_data));
1930 if (resp_data == NULL)
1931 return NULL;
1932 resp_data->rsp_type = rsp_type;
1933
1934 switch (rsp_type) {
1935 case MAILIMAP_RESP_DATA_TYPE_COND_STATE:
1936 resp_data->rsp_data.rsp_cond_state = rsp_cond_state;
1937 break;
1938 case MAILIMAP_RESP_DATA_TYPE_COND_BYE:
1939 resp_data->rsp_data.rsp_bye = rsp_bye;
1940 break;
1941 case MAILIMAP_RESP_DATA_TYPE_MAILBOX_DATA:
1942 resp_data->rsp_data.rsp_mailbox_data = rsp_mailbox_data;
1943 break;
1944 case MAILIMAP_RESP_DATA_TYPE_MESSAGE_DATA:
1945 resp_data->rsp_data.rsp_message_data = rsp_message_data;
1946 break;
1947 case MAILIMAP_RESP_DATA_TYPE_CAPABILITY_DATA:
1948 resp_data->rsp_data.rsp_capability_data = rsp_capability_data;
1949 break;
1950 }
1951
1952 return resp_data;
1953}
1954
1955void
1956mailimap_response_data_free(struct mailimap_response_data * resp_data)
1957{
1958 switch (resp_data->rsp_type) {
1959 case MAILIMAP_RESP_DATA_TYPE_COND_STATE:
1960 if (resp_data->rsp_data.rsp_cond_state != NULL)
1961 mailimap_resp_cond_state_free(resp_data->rsp_data.rsp_cond_state);
1962 break;
1963 case MAILIMAP_RESP_DATA_TYPE_COND_BYE:
1964 if (resp_data->rsp_data.rsp_bye != NULL)
1965 mailimap_resp_cond_bye_free(resp_data->rsp_data.rsp_bye);
1966 break;
1967 case MAILIMAP_RESP_DATA_TYPE_MAILBOX_DATA:
1968 if (resp_data->rsp_data.rsp_mailbox_data != NULL)
1969 mailimap_mailbox_data_free(resp_data->rsp_data.rsp_mailbox_data);
1970 break;
1971 case MAILIMAP_RESP_DATA_TYPE_MESSAGE_DATA:
1972 if (resp_data->rsp_data.rsp_message_data != NULL)
1973 mailimap_message_data_free(resp_data->rsp_data.rsp_message_data);
1974 break;
1975 case MAILIMAP_RESP_DATA_TYPE_CAPABILITY_DATA:
1976 if (resp_data->rsp_data.rsp_capability_data != NULL)
1977 mailimap_capability_data_free(resp_data->rsp_data.rsp_capability_data);
1978 break;
1979 }
1980 free(resp_data);
1981}
1982
1983
1984
1985struct mailimap_response_done *
1986mailimap_response_done_new(int rsp_type,
1987 struct mailimap_response_tagged * rsp_tagged,
1988 struct mailimap_response_fatal * rsp_fatal)
1989{
1990 struct mailimap_response_done * resp_done;
1991
1992 resp_done = malloc(sizeof(* resp_done));
1993 if (resp_done == NULL)
1994 return NULL;
1995
1996 resp_done->rsp_type = rsp_type;
1997 switch (rsp_type) {
1998 case MAILIMAP_RESP_DONE_TYPE_TAGGED:
1999 resp_done->rsp_data.rsp_tagged = rsp_tagged;
2000 break;
2001 case MAILIMAP_RESP_DONE_TYPE_FATAL:
2002 resp_done->rsp_data.rsp_fatal = rsp_fatal;
2003 break;
2004 }
2005
2006 return resp_done;
2007}
2008
2009void mailimap_response_done_free(struct mailimap_response_done *
2010 resp_done)
2011{
2012 switch (resp_done->rsp_type) {
2013 case MAILIMAP_RESP_DONE_TYPE_TAGGED:
2014 mailimap_response_tagged_free(resp_done->rsp_data.rsp_tagged);
2015 break;
2016 case MAILIMAP_RESP_DONE_TYPE_FATAL:
2017 mailimap_response_fatal_free(resp_done->rsp_data.rsp_fatal);
2018 break;
2019 }
2020 free(resp_done);
2021}
2022
2023struct mailimap_response_fatal *
2024mailimap_response_fatal_new(struct mailimap_resp_cond_bye * rsp_bye)
2025{
2026 struct mailimap_response_fatal * resp_fatal;
2027
2028 resp_fatal = malloc(sizeof(* resp_fatal));
2029 if (resp_fatal == NULL)
2030 return NULL;
2031
2032 resp_fatal->rsp_bye = rsp_bye;
2033
2034 return NULL;
2035}
2036
2037void mailimap_response_fatal_free(struct mailimap_response_fatal * resp_fatal)
2038{
2039 mailimap_resp_cond_bye_free(resp_fatal->rsp_bye);
2040 free(resp_fatal);
2041}
2042
2043struct mailimap_response_tagged *
2044mailimap_response_tagged_new(char * rsp_tag,
2045 struct mailimap_resp_cond_state * rsp_cond_state)
2046{
2047 struct mailimap_response_tagged * resp_tagged;
2048
2049 resp_tagged = malloc(sizeof(* resp_tagged));
2050 if (resp_tagged == NULL)
2051 return NULL;
2052
2053 resp_tagged->rsp_tag = rsp_tag;
2054 resp_tagged->rsp_cond_state = rsp_cond_state;
2055
2056 return resp_tagged;
2057}
2058
2059void
2060mailimap_response_tagged_free(struct mailimap_response_tagged * tagged)
2061{
2062 mailimap_tag_free(tagged->rsp_tag);
2063 mailimap_resp_cond_state_free(tagged->rsp_cond_state);
2064 free(tagged);
2065}
2066
2067
2068
2069struct mailimap_resp_cond_auth *
2070mailimap_resp_cond_auth_new(int rsp_type,
2071 struct mailimap_resp_text * rsp_text)
2072{
2073 struct mailimap_resp_cond_auth * cond_auth;
2074
2075 cond_auth = malloc(sizeof(* cond_auth));
2076 if (cond_auth == NULL)
2077 return NULL;
2078
2079 cond_auth->rsp_type = rsp_type;
2080 cond_auth->rsp_text = rsp_text;
2081
2082 return cond_auth;
2083}
2084
2085void
2086mailimap_resp_cond_auth_free(struct mailimap_resp_cond_auth * cond_auth)
2087{
2088 mailimap_resp_text_free(cond_auth->rsp_text);
2089 free(cond_auth);
2090}
2091
2092
2093
2094struct mailimap_resp_cond_bye *
2095mailimap_resp_cond_bye_new(struct mailimap_resp_text * rsp_text)
2096{
2097 struct mailimap_resp_cond_bye * cond_bye;
2098
2099 cond_bye = malloc(sizeof(* cond_bye));
2100 if (cond_bye == NULL)
2101 return NULL;
2102
2103 cond_bye->rsp_text = rsp_text;
2104
2105 return cond_bye;
2106}
2107
2108
2109void
2110mailimap_resp_cond_bye_free(struct mailimap_resp_cond_bye * cond_bye)
2111{
2112 mailimap_resp_text_free(cond_bye->rsp_text);
2113 free(cond_bye);
2114}
2115
2116
2117struct mailimap_resp_cond_state *
2118mailimap_resp_cond_state_new(int rsp_type,
2119 struct mailimap_resp_text * rsp_text)
2120{
2121 struct mailimap_resp_cond_state * cond_state;
2122
2123 cond_state = malloc(sizeof(* cond_state));
2124 if (cond_state == NULL)
2125 return NULL;
2126
2127 cond_state->rsp_type = rsp_type;
2128 cond_state->rsp_text = rsp_text;
2129
2130 return cond_state;
2131}
2132
2133void
2134mailimap_resp_cond_state_free(struct mailimap_resp_cond_state * cond_state)
2135{
2136 mailimap_resp_text_free(cond_state->rsp_text);
2137 free(cond_state);
2138}
2139
2140
2141struct mailimap_resp_text *
2142mailimap_resp_text_new(struct mailimap_resp_text_code * rsp_code,
2143 char * rsp_text)
2144{
2145 struct mailimap_resp_text * resp_text;
2146
2147 resp_text = malloc(sizeof(* resp_text));
2148 if (resp_text == NULL)
2149 return NULL;
2150
2151 resp_text->rsp_code = rsp_code;
2152 resp_text->rsp_text = rsp_text;
2153
2154 return resp_text;
2155}
2156
2157void mailimap_resp_text_free(struct mailimap_resp_text * resp_text)
2158{
2159 if (resp_text->rsp_code)
2160 mailimap_resp_text_code_free(resp_text->rsp_code);
2161 if (resp_text->rsp_text)
2162 mailimap_text_free(resp_text->rsp_text);
2163 free(resp_text);
2164}
2165
2166
2167
2168
2169struct mailimap_resp_text_code *
2170mailimap_resp_text_code_new(int rc_type, clist * rc_badcharset,
2171 struct mailimap_capability_data * rc_cap_data,
2172 clist * rc_perm_flags,
2173 uint32_t rc_uidnext, uint32_t rc_uidvalidity,
2174 uint32_t rc_first_unseen, char * rc_atom, char * rc_atom_value)
2175{
2176 struct mailimap_resp_text_code * resp_text_code;
2177
2178 resp_text_code = malloc(sizeof(* resp_text_code));
2179 if (resp_text_code == NULL)
2180 return NULL;
2181
2182 resp_text_code->rc_type = rc_type;
2183 switch (rc_type) {
2184 case MAILIMAP_RESP_TEXT_CODE_BADCHARSET:
2185 resp_text_code->rc_data.rc_badcharset = rc_badcharset;
2186 break;
2187 case MAILIMAP_RESP_TEXT_CODE_CAPABILITY_DATA:
2188 resp_text_code->rc_data.rc_cap_data = rc_cap_data;
2189 break;
2190 case MAILIMAP_RESP_TEXT_CODE_PERMANENTFLAGS:
2191 resp_text_code->rc_data.rc_perm_flags = rc_perm_flags;
2192 break;
2193 case MAILIMAP_RESP_TEXT_CODE_UIDNEXT:
2194 resp_text_code->rc_data.rc_uidnext = rc_uidnext;
2195 break;
2196 case MAILIMAP_RESP_TEXT_CODE_UIDVALIDITY:
2197 resp_text_code->rc_data.rc_uidvalidity = rc_uidvalidity;
2198 break;
2199 case MAILIMAP_RESP_TEXT_CODE_UNSEEN:
2200 resp_text_code->rc_data.rc_first_unseen = rc_first_unseen;
2201 break;
2202 case MAILIMAP_RESP_TEXT_CODE_OTHER:
2203 resp_text_code->rc_data.rc_atom.atom_name = rc_atom;
2204 resp_text_code->rc_data.rc_atom.atom_value = rc_atom_value;
2205 break;
2206 }
2207
2208 return resp_text_code;
2209}
2210
2211void
2212mailimap_resp_text_code_free(struct mailimap_resp_text_code * resp_text_code)
2213{
2214 switch (resp_text_code->rc_type) {
2215 case MAILIMAP_RESP_TEXT_CODE_BADCHARSET:
2216 if (resp_text_code->rc_data.rc_badcharset != NULL) {
2217 clist_foreach(resp_text_code->rc_data.rc_badcharset,
2218 (clist_func) mailimap_astring_free,
2219 NULL);
2220 clist_free(resp_text_code->rc_data.rc_badcharset);
2221 }
2222 break;
2223 case MAILIMAP_RESP_TEXT_CODE_CAPABILITY_DATA:
2224 if (resp_text_code->rc_data.rc_cap_data != NULL)
2225 mailimap_capability_data_free(resp_text_code->rc_data.rc_cap_data);
2226 break;
2227 case MAILIMAP_RESP_TEXT_CODE_PERMANENTFLAGS:
2228 if (resp_text_code->rc_data.rc_perm_flags != NULL) {
2229 clist_foreach(resp_text_code->rc_data.rc_perm_flags,
2230 (clist_func) mailimap_flag_perm_free, NULL);
2231 clist_free(resp_text_code->rc_data.rc_perm_flags);
2232 }
2233 break;
2234 case MAILIMAP_RESP_TEXT_CODE_OTHER:
2235 if (resp_text_code->rc_data.rc_atom.atom_name != NULL)
2236 mailimap_atom_free(resp_text_code->rc_data.rc_atom.atom_name);
2237 if (resp_text_code->rc_data.rc_atom.atom_value != NULL)
2238 mailimap_custom_string_free(resp_text_code->rc_data.rc_atom.atom_value);
2239 break;
2240 }
2241 free(resp_text_code);
2242}
2243
2244
2245struct mailimap_section *
2246mailimap_section_new(struct mailimap_section_spec * sec_spec)
2247{
2248 struct mailimap_section * section;
2249
2250 section = malloc(sizeof(* section));
2251 if (section == NULL)
2252 return NULL;
2253
2254 section->sec_spec = sec_spec;
2255
2256 return section;
2257}
2258
2259void mailimap_section_free(struct mailimap_section * section)
2260{
2261 if (section->sec_spec != NULL)
2262 mailimap_section_spec_free(section->sec_spec);
2263 free(section);
2264}
2265
2266
2267
2268struct mailimap_section_msgtext *
2269mailimap_section_msgtext_new(int sec_type,
2270 struct mailimap_header_list * sec_header_list)
2271{
2272 struct mailimap_section_msgtext * msgtext;
2273
2274 msgtext = malloc(sizeof(* msgtext));
2275 if (msgtext == NULL)
2276 return FALSE;
2277
2278 msgtext->sec_type = sec_type;
2279 msgtext->sec_header_list = sec_header_list;
2280
2281 return msgtext;
2282}
2283
2284void
2285mailimap_section_msgtext_free(struct mailimap_section_msgtext * msgtext)
2286{
2287 if (msgtext->sec_header_list != NULL)
2288 mailimap_header_list_free(msgtext->sec_header_list);
2289 free(msgtext);
2290}
2291
2292
2293struct mailimap_section_part *
2294mailimap_section_part_new(clist * sec_id)
2295{
2296 struct mailimap_section_part * section_part;
2297
2298 section_part = malloc(sizeof(* section_part));
2299 if (section_part == NULL)
2300 return NULL;
2301
2302 section_part->sec_id = sec_id;
2303
2304 return section_part;
2305}
2306
2307void
2308mailimap_section_part_free(struct mailimap_section_part * section_part)
2309{
2310 clist_foreach(section_part->sec_id,
2311 (clist_func) mailimap_number_alloc_free, NULL);
2312 clist_free(section_part->sec_id);
2313 free(section_part);
2314}
2315
2316
2317struct mailimap_section_spec *
2318mailimap_section_spec_new(int sec_type,
2319 struct mailimap_section_msgtext * sec_msgtext,
2320 struct mailimap_section_part * sec_part,
2321 struct mailimap_section_text * sec_text)
2322{
2323 struct mailimap_section_spec * section_spec;
2324
2325 section_spec = malloc(sizeof(* section_spec));
2326 if (section_spec == NULL)
2327 return NULL;
2328
2329 section_spec->sec_type = sec_type;
2330 switch (sec_type) {
2331 case MAILIMAP_SECTION_SPEC_SECTION_MSGTEXT:
2332 section_spec->sec_data.sec_msgtext = sec_msgtext;
2333 break;
2334 case MAILIMAP_SECTION_SPEC_SECTION_PART:
2335 section_spec->sec_data.sec_part = sec_part;
2336 break;
2337 }
2338 section_spec->sec_text = sec_text;
2339
2340 return section_spec;
2341}
2342
2343void
2344mailimap_section_spec_free(struct mailimap_section_spec * section_spec)
2345{
2346 if (section_spec->sec_text)
2347 mailimap_section_text_free(section_spec->sec_text);
2348
2349 switch (section_spec->sec_type) {
2350 case MAILIMAP_SECTION_SPEC_SECTION_PART:
2351 if (section_spec->sec_data.sec_part != NULL)
2352 mailimap_section_part_free(section_spec->sec_data.sec_part);
2353 break;
2354 case MAILIMAP_SECTION_SPEC_SECTION_MSGTEXT:
2355 /* handle case where it can be detached */
2356 if (section_spec->sec_data.sec_msgtext != NULL)
2357 mailimap_section_msgtext_free(section_spec->sec_data.sec_msgtext);
2358 break;
2359 }
2360 free(section_spec);
2361}
2362
2363
2364struct mailimap_section_text *
2365mailimap_section_text_new(int sec_type,
2366 struct mailimap_section_msgtext * sec_msgtext)
2367{
2368 struct mailimap_section_text * section_text;
2369
2370 section_text = malloc(sizeof(* section_text));
2371 if (section_text == NULL)
2372 return NULL;
2373
2374 section_text->sec_type = sec_type;
2375 section_text->sec_msgtext = sec_msgtext;
2376
2377 return section_text;
2378}
2379
2380void
2381mailimap_section_text_free(struct mailimap_section_text * section_text)
2382{
2383 if (section_text->sec_msgtext != NULL)
2384 mailimap_section_msgtext_free(section_text->sec_msgtext);
2385 free(section_text);
2386}
2387
2388
2389
2390
2391void
2392mailimap_string_free(char * str)
2393{
2394 mmap_string_unref(str);
2395}
2396
2397
2398
2399
2400
2401void mailimap_tag_free(char * tag)
2402{
2403 mailimap_custom_string_free(tag);
2404}
2405
2406
2407void mailimap_text_free(char * text)
2408{
2409 mailimap_custom_string_free(text);
2410}
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433/* ************************************************************************* */
2434/* ************************************************************************* */
2435/* ************************************************************************* */
2436/* ************************************************************************* */
2437/* ************************************************************************* */
2438/* ************************************************************************* */
2439
2440
2441
2442
2443
2444
2445/* sender only */
2446
2447
2448/* COPY FETCH SEARCH STORE */
2449/* set */
2450
2451struct mailimap_set_item *
2452mailimap_set_item_new(uint32_t set_first, uint32_t set_last)
2453{
2454 struct mailimap_set_item * item;
2455
2456 item = malloc(sizeof(* item));
2457 if (item == NULL)
2458 return NULL;
2459
2460 item->set_first = set_first;
2461 item->set_last = set_last;
2462
2463 return item;
2464}
2465
2466void mailimap_set_item_free(struct mailimap_set_item * set_item)
2467{
2468 free(set_item);
2469}
2470
2471struct mailimap_set * mailimap_set_new(clist * set_list)
2472{
2473 struct mailimap_set * set;
2474
2475 set = malloc(sizeof(* set));
2476 if (set == NULL)
2477 return NULL;
2478
2479 set->set_list = set_list;
2480
2481 return set;
2482}
2483
2484void mailimap_set_free(struct mailimap_set * set)
2485{
2486 clist_foreach(set->set_list, (clist_func) mailimap_set_item_free, NULL);
2487 clist_free(set->set_list);
2488 free(set);
2489}
2490
2491/* SEARCH with date key */
2492/* date */
2493
2494struct mailimap_date *
2495mailimap_date_new(int dt_day, int dt_month, int dt_year)
2496{
2497 struct mailimap_date * date;
2498
2499 date = malloc(sizeof(* date));
2500 if (date == NULL)
2501 return NULL;
2502
2503 date->dt_day = dt_day;
2504 date->dt_month = dt_month;
2505 date->dt_year = dt_year;
2506
2507 return date;
2508}
2509
2510void mailimap_date_free(struct mailimap_date * date)
2511{
2512 free(date);
2513}
2514
2515
2516
2517struct mailimap_fetch_att *
2518mailimap_fetch_att_new(int att_type, struct mailimap_section * att_section,
2519 uint32_t att_offset, uint32_t att_size)
2520{
2521 struct mailimap_fetch_att * fetch_att;
2522
2523 fetch_att = malloc(sizeof(* fetch_att));
2524 if (fetch_att == NULL)
2525 return NULL;
2526 fetch_att->att_type = att_type;
2527 fetch_att->att_section = att_section;
2528 fetch_att->att_offset = att_offset;
2529 fetch_att->att_size = att_size;
2530
2531 return fetch_att;
2532}
2533
2534void mailimap_fetch_att_free(struct mailimap_fetch_att * fetch_att)
2535{
2536 if (fetch_att->att_section != NULL)
2537 mailimap_section_free(fetch_att->att_section);
2538 free(fetch_att);
2539}
2540
2541
2542
2543struct mailimap_fetch_type *
2544mailimap_fetch_type_new(int ft_type,
2545 struct mailimap_fetch_att * ft_fetch_att,
2546 clist * ft_fetch_att_list)
2547{
2548 struct mailimap_fetch_type * fetch_type;
2549
2550 fetch_type = malloc(sizeof(* fetch_type));
2551 if (fetch_type == NULL)
2552 return NULL;
2553 fetch_type->ft_type = ft_type;
2554 switch (ft_type) {
2555 case MAILIMAP_FETCH_TYPE_FETCH_ATT:
2556 fetch_type->ft_data.ft_fetch_att = ft_fetch_att;
2557 break;
2558 case MAILIMAP_FETCH_TYPE_FETCH_ATT_LIST:
2559 fetch_type->ft_data.ft_fetch_att_list = ft_fetch_att_list;
2560 break;
2561 }
2562
2563 return fetch_type;
2564}
2565
2566void mailimap_fetch_type_free(struct mailimap_fetch_type * fetch_type)
2567{
2568 switch (fetch_type->ft_type) {
2569 case MAILIMAP_FETCH_TYPE_FETCH_ATT:
2570 mailimap_fetch_att_free(fetch_type->ft_data.ft_fetch_att);
2571 break;
2572 case MAILIMAP_FETCH_TYPE_FETCH_ATT_LIST:
2573 clist_foreach(fetch_type->ft_data.ft_fetch_att_list,
2574 (clist_func) mailimap_fetch_att_free, NULL);
2575 clist_free(fetch_type->ft_data.ft_fetch_att_list);
2576 break;
2577 }
2578 free(fetch_type);
2579}
2580
2581
2582
2583
2584struct mailimap_store_att_flags *
2585mailimap_store_att_flags_new(int fl_sign, int fl_silent,
2586 struct mailimap_flag_list * fl_flag_list)
2587{
2588 struct mailimap_store_att_flags * store_att_flags;
2589
2590 store_att_flags = malloc(sizeof(* store_att_flags));
2591 if (store_att_flags == NULL)
2592 return NULL;
2593
2594 store_att_flags->fl_sign = fl_sign;
2595 store_att_flags->fl_silent = fl_silent;
2596 store_att_flags->fl_flag_list = fl_flag_list;
2597
2598 return store_att_flags;
2599}
2600
2601void mailimap_store_att_flags_free(struct mailimap_store_att_flags *
2602 store_att_flags)
2603{
2604 mailimap_flag_list_free(store_att_flags->fl_flag_list);
2605 free(store_att_flags);
2606}
2607
2608
2609struct mailimap_search_key *
2610mailimap_search_key_new(int sk_type,
2611 char * sk_bcc, struct mailimap_date * sk_before, char * sk_body,
2612 char * sk_cc, char * sk_from, char * sk_keyword,
2613 struct mailimap_date * sk_on, struct mailimap_date * sk_since,
2614 char * sk_subject, char * sk_text, char * sk_to,
2615 char * sk_unkeyword, char * sk_header_name,
2616 char * sk_header_value, uint32_t sk_larger,
2617 struct mailimap_search_key * sk_not,
2618 struct mailimap_search_key * sk_or1,
2619 struct mailimap_search_key * sk_or2,
2620 struct mailimap_date * sk_sentbefore,
2621 struct mailimap_date * sk_senton,
2622 struct mailimap_date * sk_sentsince,
2623 uint32_t sk_smaller, struct mailimap_set * sk_uid,
2624 struct mailimap_set * sk_set, clist * sk_multiple)
2625{
2626 struct mailimap_search_key * key;
2627
2628 key = malloc(sizeof(* key));
2629 if (key == NULL)
2630 return NULL;
2631
2632 key->sk_type = sk_type;
2633 switch (sk_type) {
2634 case MAILIMAP_SEARCH_KEY_BCC:
2635 key->sk_data.sk_bcc = sk_bcc;
2636 break;
2637 case MAILIMAP_SEARCH_KEY_BEFORE:
2638 key->sk_data.sk_before = sk_before;
2639 break;
2640 case MAILIMAP_SEARCH_KEY_BODY:
2641 key->sk_data.sk_body = sk_body;
2642 break;
2643 case MAILIMAP_SEARCH_KEY_CC:
2644 key->sk_data.sk_cc = sk_cc;
2645 break;
2646 case MAILIMAP_SEARCH_KEY_FROM:
2647 key->sk_data.sk_from = sk_from;
2648 break;
2649 case MAILIMAP_SEARCH_KEY_KEYWORD:
2650 key->sk_data.sk_keyword = sk_keyword;
2651 break;
2652 case MAILIMAP_SEARCH_KEY_ON:
2653 key->sk_data.sk_on = sk_on;
2654 break;
2655 case MAILIMAP_SEARCH_KEY_SINCE:
2656 key->sk_data.sk_since = sk_since;
2657 break;
2658 case MAILIMAP_SEARCH_KEY_SUBJECT:
2659 key->sk_data.sk_subject = sk_subject;
2660 break;
2661 case MAILIMAP_SEARCH_KEY_TEXT:
2662 key->sk_data.sk_text = sk_text;
2663 break;
2664 case MAILIMAP_SEARCH_KEY_TO:
2665 key->sk_data.sk_to = sk_to;
2666 break;
2667 case MAILIMAP_SEARCH_KEY_UNKEYWORD:
2668 key->sk_data.sk_unkeyword = sk_unkeyword;
2669 break;
2670 case MAILIMAP_SEARCH_KEY_HEADER:
2671 key->sk_data.sk_header.sk_header_name = sk_header_name;
2672 key->sk_data.sk_header.sk_header_value = sk_header_value;
2673 break;
2674 case MAILIMAP_SEARCH_KEY_LARGER:
2675 key->sk_data.sk_larger = sk_larger;
2676 break;
2677 case MAILIMAP_SEARCH_KEY_NOT:
2678 key->sk_data.sk_not = sk_not;
2679 break;
2680 case MAILIMAP_SEARCH_KEY_OR:
2681 key->sk_data.sk_or.sk_or1 = sk_or1;
2682 key->sk_data.sk_or.sk_or2 = sk_or2;
2683 break;
2684 case MAILIMAP_SEARCH_KEY_SENTBEFORE:
2685 key->sk_data.sk_sentbefore = sk_sentbefore;
2686 break;
2687 case MAILIMAP_SEARCH_KEY_SENTON:
2688 key->sk_data.sk_senton = sk_senton;
2689 break;
2690 case MAILIMAP_SEARCH_KEY_SENTSINCE:
2691 key->sk_data.sk_sentsince = sk_sentsince;
2692 break;
2693 case MAILIMAP_SEARCH_KEY_SMALLER:
2694 key->sk_data.sk_smaller = sk_smaller;
2695 break;
2696 case MAILIMAP_SEARCH_KEY_UID:
2697 key->sk_data.sk_uid = sk_uid;
2698 break;
2699 case MAILIMAP_SEARCH_KEY_SET:
2700 key->sk_data.sk_set = sk_set;
2701 break;
2702 case MAILIMAP_SEARCH_KEY_MULTIPLE:
2703 key->sk_data.sk_multiple = sk_multiple;
2704 break;
2705 }
2706 return key;
2707}
2708
2709
2710void mailimap_search_key_free(struct mailimap_search_key * key)
2711{
2712 switch (key->sk_type) {
2713 case MAILIMAP_SEARCH_KEY_BCC:
2714 mailimap_astring_free(key->sk_data.sk_bcc);
2715 break;
2716 case MAILIMAP_SEARCH_KEY_BEFORE:
2717 mailimap_date_free(key->sk_data.sk_before);
2718 break;
2719 case MAILIMAP_SEARCH_KEY_BODY:
2720 mailimap_astring_free(key->sk_data.sk_body);
2721 break;
2722 case MAILIMAP_SEARCH_KEY_CC:
2723 mailimap_astring_free(key->sk_data.sk_cc);
2724 break;
2725 case MAILIMAP_SEARCH_KEY_FROM:
2726 mailimap_astring_free(key->sk_data.sk_from);
2727 break;
2728 case MAILIMAP_SEARCH_KEY_KEYWORD:
2729 mailimap_flag_keyword_free(key->sk_data.sk_keyword);
2730 break;
2731 case MAILIMAP_SEARCH_KEY_ON:
2732 mailimap_date_free(key->sk_data.sk_on);
2733 break;
2734 case MAILIMAP_SEARCH_KEY_SINCE:
2735 mailimap_date_free(key->sk_data.sk_since);
2736 break;
2737 case MAILIMAP_SEARCH_KEY_SUBJECT:
2738 mailimap_astring_free(key->sk_data.sk_subject);
2739 break;
2740 case MAILIMAP_SEARCH_KEY_TEXT:
2741 mailimap_astring_free(key->sk_data.sk_text);
2742 break;
2743 case MAILIMAP_SEARCH_KEY_TO:
2744 mailimap_astring_free(key->sk_data.sk_to);
2745 break;
2746 case MAILIMAP_SEARCH_KEY_UNKEYWORD:
2747 mailimap_flag_keyword_free(key->sk_data.sk_unkeyword);
2748 break;
2749 case MAILIMAP_SEARCH_KEY_HEADER:
2750 mailimap_header_fld_name_free(key->sk_data.sk_header.sk_header_name);
2751 mailimap_astring_free(key->sk_data.sk_header.sk_header_value);
2752 break;
2753 case MAILIMAP_SEARCH_KEY_NOT:
2754 mailimap_search_key_free(key->sk_data.sk_not);
2755 break;
2756 case MAILIMAP_SEARCH_KEY_OR:
2757 mailimap_search_key_free(key->sk_data.sk_or.sk_or1);
2758 mailimap_search_key_free(key->sk_data.sk_or.sk_or2);
2759 break;
2760 case MAILIMAP_SEARCH_KEY_SENTBEFORE:
2761 mailimap_date_free(key->sk_data.sk_sentbefore);
2762 break;
2763 case MAILIMAP_SEARCH_KEY_SENTON:
2764 mailimap_date_free(key->sk_data.sk_senton);
2765 break;
2766 case MAILIMAP_SEARCH_KEY_SENTSINCE:
2767 mailimap_date_free(key->sk_data.sk_sentsince);
2768 break;
2769 case MAILIMAP_SEARCH_KEY_UID:
2770 mailimap_set_free(key->sk_data.sk_uid);
2771 break;
2772 case MAILIMAP_SEARCH_KEY_SET:
2773 mailimap_set_free(key->sk_data.sk_set);
2774 break;
2775 case MAILIMAP_SEARCH_KEY_MULTIPLE:
2776 clist_foreach(key->sk_data.sk_multiple,
2777 (clist_func) mailimap_search_key_free, NULL);
2778 clist_free(key->sk_data.sk_multiple);
2779 break;
2780 }
2781
2782 free(key);
2783}
2784
2785
2786
2787
2788
2789
2790
2791
2792struct mailimap_status_att_list *
2793mailimap_status_att_list_new(clist * att_list)
2794{
2795 struct mailimap_status_att_list * status_att_list;
2796
2797 status_att_list = malloc(sizeof(* status_att_list));
2798 if (status_att_list == NULL)
2799 return NULL;
2800 status_att_list->att_list = att_list;
2801
2802 return status_att_list;
2803}
2804
2805void mailimap_status_att_list_free(struct mailimap_status_att_list *
2806 status_att_list)
2807{
2808 clist_foreach(status_att_list->att_list, (clist_func) free, NULL);
2809 clist_free(status_att_list->att_list);
2810 free(status_att_list);
2811}
2812
2813
2814
2815
2816/* main */
2817
2818
2819struct mailimap_selection_info *
2820mailimap_selection_info_new(void)
2821{
2822 struct mailimap_selection_info * sel_info;
2823
2824 sel_info = malloc(sizeof(* sel_info));
2825 if (sel_info == NULL)
2826 return NULL;
2827
2828 sel_info->sel_perm_flags = NULL;
2829 sel_info->sel_perm = MAILIMAP_MAILBOX_READWRITE;
2830 sel_info->sel_uidnext = 0;
2831 sel_info->sel_uidvalidity = 0;
2832 sel_info->sel_first_unseen = 0;
2833 sel_info->sel_flags = NULL;
2834 sel_info->sel_exists = 0;
2835 sel_info->sel_recent = 0;
2836 sel_info->sel_unseen = 0;
2837
2838 return sel_info;
2839}
2840
2841void
2842mailimap_selection_info_free(struct mailimap_selection_info * sel_info)
2843{
2844 if (sel_info->sel_perm_flags != NULL) {
2845 clist_foreach(sel_info->sel_perm_flags,
2846 (clist_func) mailimap_flag_perm_free, NULL);
2847 clist_free(sel_info->sel_perm_flags);
2848 }
2849 if (sel_info->sel_flags)
2850 mailimap_flag_list_free(sel_info->sel_flags);
2851
2852 free(sel_info);
2853}
2854
2855struct mailimap_connection_info *
2856mailimap_connection_info_new(void)
2857{
2858 struct mailimap_connection_info * conn_info;
2859
2860 conn_info = malloc(sizeof(* conn_info));
2861 if (conn_info == NULL)
2862 return NULL;
2863
2864 conn_info->imap_capability = NULL;
2865
2866 return conn_info;
2867}
2868
2869void
2870mailimap_connection_info_free(struct mailimap_connection_info * conn_info)
2871{
2872 if (conn_info->imap_capability != NULL)
2873 mailimap_capability_data_free(conn_info->imap_capability);
2874 free(conn_info);
2875}
2876
2877struct mailimap_response_info *
2878mailimap_response_info_new(void)
2879{
2880 struct mailimap_response_info * resp_info;
2881
2882 resp_info = malloc(sizeof(* resp_info));
2883 if (resp_info == NULL)
2884 goto err;
2885
2886 resp_info->rsp_alert = NULL;
2887 resp_info->rsp_parse = NULL;
2888 resp_info->rsp_badcharset = NULL;
2889 resp_info->rsp_trycreate = FALSE;
2890 resp_info->rsp_mailbox_list = clist_new();
2891 if (resp_info->rsp_mailbox_list == NULL)
2892 goto free;
2893 resp_info->rsp_mailbox_lsub = clist_new();
2894 if (resp_info->rsp_mailbox_lsub == NULL)
2895 goto free_mb_list;
2896 resp_info->rsp_search_result = clist_new();
2897 if (resp_info->rsp_search_result == NULL)
2898 goto free_mb_lsub;
2899 resp_info->rsp_status = NULL;
2900 resp_info->rsp_expunged = clist_new();
2901 if (resp_info->rsp_expunged == NULL)
2902 goto free_search_result;
2903 resp_info->rsp_fetch_list = clist_new();
2904 if (resp_info->rsp_fetch_list == NULL)
2905 goto free_expunged;
2906
2907 return resp_info;
2908
2909 free_expunged:
2910 clist_free(resp_info->rsp_expunged);
2911 free_search_result:
2912 clist_free(resp_info->rsp_search_result);
2913 free_mb_lsub:
2914 clist_free(resp_info->rsp_mailbox_lsub);
2915 free_mb_list:
2916 clist_free(resp_info->rsp_mailbox_list);
2917 free:
2918 free(resp_info);
2919 err:
2920 return NULL;
2921}
2922
2923void
2924mailimap_response_info_free(struct mailimap_response_info * resp_info)
2925{
2926 if (resp_info->rsp_alert != NULL)
2927 free(resp_info->rsp_alert);
2928 if (resp_info->rsp_parse != NULL)
2929 free(resp_info->rsp_parse);
2930 if (resp_info->rsp_badcharset != NULL) {
2931 clist_foreach(resp_info->rsp_badcharset,
2932 (clist_func) mailimap_astring_free, NULL);
2933 clist_free(resp_info->rsp_badcharset);
2934 }
2935 if (resp_info->rsp_mailbox_list != NULL) {
2936 clist_foreach(resp_info->rsp_mailbox_list,
2937 (clist_func) mailimap_mailbox_list_free, NULL);
2938 clist_free(resp_info->rsp_mailbox_list);
2939 }
2940 if (resp_info->rsp_mailbox_lsub != NULL) {
2941 clist_foreach(resp_info->rsp_mailbox_lsub,
2942 (clist_func) mailimap_mailbox_list_free, NULL);
2943 clist_free(resp_info->rsp_mailbox_lsub);
2944 }
2945 if (resp_info->rsp_search_result != NULL)
2946 mailimap_mailbox_data_search_free(resp_info->rsp_search_result);
2947 if (resp_info->rsp_status != NULL)
2948 mailimap_mailbox_data_status_free(resp_info->rsp_status);
2949 if (resp_info->rsp_expunged != NULL) {
2950 clist_foreach(resp_info->rsp_expunged,
2951 (clist_func) mailimap_number_alloc_free, NULL);
2952 clist_free(resp_info->rsp_expunged);
2953 }
2954 if (resp_info->rsp_fetch_list != NULL) {
2955 clist_foreach(resp_info->rsp_fetch_list,
2956 (clist_func) mailimap_msg_att_free, NULL);
2957 clist_free(resp_info->rsp_fetch_list);
2958 }
2959
2960 free(resp_info);
2961}