author | zautrix <zautrix> | 2005-03-18 20:17:03 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-18 20:17:03 (UTC) |
commit | 9e549686b23b6dffdcbd09c9b10dc2cb795fbcdf (patch) (unidiff) | |
tree | 2528e6cc740225ca0f47d5ac8ff70f7d3bb10621 /libetpan/src/low-level/imap/mailimap_print.c | |
parent | 9319998f20f03dcc217fbb39656755dc65226276 (diff) | |
download | kdepimpi-9e549686b23b6dffdcbd09c9b10dc2cb795fbcdf.zip kdepimpi-9e549686b23b6dffdcbd09c9b10dc2cb795fbcdf.tar.gz kdepimpi-9e549686b23b6dffdcbd09c9b10dc2cb795fbcdf.tar.bz2 |
Initial revision
Diffstat (limited to 'libetpan/src/low-level/imap/mailimap_print.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libetpan/src/low-level/imap/mailimap_print.c | 1615 |
1 files changed, 1615 insertions, 0 deletions
diff --git a/libetpan/src/low-level/imap/mailimap_print.c b/libetpan/src/low-level/imap/mailimap_print.c new file mode 100644 index 0000000..005cf09 --- a/dev/null +++ b/libetpan/src/low-level/imap/mailimap_print.c | |||
@@ -0,0 +1,1615 @@ | |||
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 | #ifdef DEBUG | ||
36 | #include "mailimap_print.h" | ||
37 | |||
38 | #include <stdio.h> | ||
39 | |||
40 | static void mailimap_body_fields_print(struct mailimap_body_fields * | ||
41 | body_fields); | ||
42 | static void mailimap_envelope_print(struct mailimap_envelope * env); | ||
43 | static void mailimap_body_print(struct mailimap_body * body); | ||
44 | static void mailimap_body_fld_enc_print(struct mailimap_body_fld_enc * | ||
45 | fld_enc); | ||
46 | |||
47 | static int indent_size = 0; | ||
48 | |||
49 | static void indent() | ||
50 | { | ||
51 | indent_size ++; | ||
52 | } | ||
53 | |||
54 | static void unindent() | ||
55 | { | ||
56 | indent_size --; | ||
57 | } | ||
58 | |||
59 | static void print_indent() | ||
60 | { | ||
61 | int i; | ||
62 | |||
63 | for (i = 0 ; i < indent_size ; i++) | ||
64 | printf(" "); | ||
65 | } | ||
66 | |||
67 | |||
68 | static void mailimap_body_fld_lang_print(struct mailimap_body_fld_lang * | ||
69 | fld_lang) | ||
70 | { | ||
71 | clistiter * cur; | ||
72 | |||
73 | print_indent(); | ||
74 | printf("body-fld-lang { "); | ||
75 | |||
76 | switch (fld_lang->lg_type) { | ||
77 | case MAILIMAP_BODY_FLD_LANG_SINGLE: | ||
78 | printf("%s ", fld_lang->lg_data.lg_single); | ||
79 | break; | ||
80 | |||
81 | case MAILIMAP_BODY_FLD_LANG_LIST: | ||
82 | for(cur = clist_begin(fld_lang->lg_data.lg_list) ; | ||
83 | cur != NULL ; cur = clist_next(cur)) { | ||
84 | char * lang; | ||
85 | |||
86 | lang = clist_content(cur); | ||
87 | |||
88 | printf("%s ", lang); | ||
89 | } | ||
90 | break; | ||
91 | } | ||
92 | |||
93 | print_indent(); | ||
94 | printf("}\n"); | ||
95 | } | ||
96 | |||
97 | static void | ||
98 | mailimap_single_body_fld_param_print(struct mailimap_single_body_fld_param * | ||
99 | single) | ||
100 | { | ||
101 | printf("(%s = %s)", single->pa_name, single->pa_value); | ||
102 | } | ||
103 | |||
104 | static void mailimap_body_fld_param_print(struct mailimap_body_fld_param * | ||
105 | fld_param) | ||
106 | { | ||
107 | clistiter * cur; | ||
108 | |||
109 | print_indent(); | ||
110 | printf("body-fld-param { "); | ||
111 | |||
112 | for(cur = clist_begin(fld_param->pa_list) ; cur != NULL ; | ||
113 | cur = clist_next(cur)) { | ||
114 | struct mailimap_single_body_fld_param * single; | ||
115 | |||
116 | single = clist_content(cur); | ||
117 | |||
118 | mailimap_single_body_fld_param_print(single); | ||
119 | printf(" "); | ||
120 | } | ||
121 | printf("\n"); | ||
122 | } | ||
123 | |||
124 | static void mailimap_body_fld_dsp_print(struct mailimap_body_fld_dsp * fld_dsp) | ||
125 | { | ||
126 | print_indent(); | ||
127 | printf("body-fld-dsp {\n"); | ||
128 | indent(); | ||
129 | |||
130 | print_indent(); | ||
131 | printf("name { %s }\n", fld_dsp->dsp_type); | ||
132 | |||
133 | mailimap_body_fld_param_print(fld_dsp->dsp_attributes); | ||
134 | |||
135 | unindent(); | ||
136 | print_indent(); | ||
137 | printf("}\n"); | ||
138 | } | ||
139 | |||
140 | static void mailimap_body_extension_list_print(clist * ext_list); | ||
141 | |||
142 | static void mailimap_body_extension_print(struct mailimap_body_extension * ext) | ||
143 | { | ||
144 | print_indent(); | ||
145 | printf("body-extention {\n"); | ||
146 | indent(); | ||
147 | |||
148 | switch (ext->ext_type) { | ||
149 | case MAILIMAP_BODY_EXTENSION_NSTRING: | ||
150 | print_indent(); | ||
151 | printf("%s\n", ext->ext_data.ext_nstring); | ||
152 | break; | ||
153 | case MAILIMAP_BODY_EXTENSION_NUMBER: | ||
154 | print_indent(); | ||
155 | printf("%i\n", ext->ext_data.ext_number); | ||
156 | break; | ||
157 | case MAILIMAP_BODY_EXTENSION_LIST: | ||
158 | mailimap_body_extension_list_print(ext->ext_data.ext_body_extension_list); | ||
159 | break; | ||
160 | } | ||
161 | |||
162 | unindent(); | ||
163 | print_indent(); | ||
164 | printf("}\n"); | ||
165 | |||
166 | } | ||
167 | |||
168 | static void mailimap_body_extension_list_print(clist * ext_list) | ||
169 | { | ||
170 | clistiter * cur; | ||
171 | |||
172 | print_indent(); | ||
173 | printf("body-extention-list {\n"); | ||
174 | indent(); | ||
175 | |||
176 | for (cur = clist_begin(ext_list) ; cur != NULL ; | ||
177 | cur = clist_next(cur)) { | ||
178 | struct mailimap_body_extension * ext; | ||
179 | |||
180 | ext = clist_content(cur); | ||
181 | |||
182 | mailimap_body_extension_print(ext); | ||
183 | } | ||
184 | |||
185 | unindent(); | ||
186 | print_indent(); | ||
187 | printf("}"); | ||
188 | } | ||
189 | |||
190 | static void mailimap_body_ext_1part_print(struct mailimap_body_ext_1part * | ||
191 | body_ext_1part) | ||
192 | { | ||
193 | print_indent(); | ||
194 | printf("body-type-1part {\n"); | ||
195 | indent(); | ||
196 | |||
197 | print_indent(); | ||
198 | printf("md5 { %s }\n", body_ext_1part->bd_md5); | ||
199 | if (body_ext_1part->bd_disposition) { | ||
200 | mailimap_body_fld_dsp_print(body_ext_1part->bd_disposition); | ||
201 | if (body_ext_1part->bd_language) { | ||
202 | mailimap_body_fld_lang_print(body_ext_1part->bd_language); | ||
203 | |||
204 | if (body_ext_1part->bd_extension_list) | ||
205 | mailimap_body_extension_list_print(body_ext_1part->bd_extension_list); | ||
206 | } | ||
207 | } | ||
208 | |||
209 | unindent(); | ||
210 | print_indent(); | ||
211 | printf("}\n"); | ||
212 | } | ||
213 | |||
214 | static void mailimap_body_type_text_print(struct mailimap_body_type_text * | ||
215 | body_type_text) | ||
216 | { | ||
217 | print_indent(); | ||
218 | printf("body-type-text {\n"); | ||
219 | indent(); | ||
220 | |||
221 | print_indent(); | ||
222 | printf("media-text { %s }\n", body_type_text->bd_media_text); | ||
223 | mailimap_body_fields_print(body_type_text->bd_fields); | ||
224 | print_indent(); | ||
225 | printf("lines { %i }\n", body_type_text->bd_lines); | ||
226 | |||
227 | unindent(); | ||
228 | print_indent(); | ||
229 | printf("}\n"); | ||
230 | } | ||
231 | |||
232 | static void mailimap_body_type_msg_print(struct mailimap_body_type_msg * | ||
233 | body_type_msg) | ||
234 | { | ||
235 | print_indent(); | ||
236 | printf("body-type-msg {\n"); | ||
237 | indent(); | ||
238 | |||
239 | mailimap_body_fields_print(body_type_msg->bd_fields); | ||
240 | mailimap_envelope_print(body_type_msg->bd_envelope); | ||
241 | mailimap_body_print(body_type_msg->bd_body); | ||
242 | |||
243 | print_indent(); | ||
244 | printf("lines { %i }\n", body_type_msg->bd_lines); | ||
245 | |||
246 | unindent(); | ||
247 | print_indent(); | ||
248 | printf("}\n"); | ||
249 | } | ||
250 | |||
251 | |||
252 | static void mailimap_body_fld_enc_print(struct mailimap_body_fld_enc * fld_enc) | ||
253 | { | ||
254 | print_indent(); | ||
255 | printf("body-fld-enc { "); | ||
256 | |||
257 | switch (fld_enc->enc_type) { | ||
258 | case MAILIMAP_BODY_FLD_ENC_7BIT: | ||
259 | print_indent(); | ||
260 | printf("7bit"); | ||
261 | break; | ||
262 | case MAILIMAP_BODY_FLD_ENC_8BIT: | ||
263 | printf("8bit"); | ||
264 | break; | ||
265 | case MAILIMAP_BODY_FLD_ENC_BINARY: | ||
266 | printf("binary"); | ||
267 | break; | ||
268 | case MAILIMAP_BODY_FLD_ENC_BASE64: | ||
269 | printf("base64"); | ||
270 | break; | ||
271 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | ||
272 | printf("quoted-printable"); | ||
273 | break; | ||
274 | case MAILIMAP_BODY_FLD_ENC_OTHER: | ||
275 | printf("%s", fld_enc->enc_value); | ||
276 | break; | ||
277 | } | ||
278 | |||
279 | printf("}\n"); | ||
280 | } | ||
281 | |||
282 | static void mailimap_body_fields_print(struct mailimap_body_fields * | ||
283 | body_fields) | ||
284 | { | ||
285 | print_indent(); | ||
286 | printf("body-fields {\n"); | ||
287 | indent(); | ||
288 | |||
289 | mailimap_body_fld_param_print(body_fields->bd_parameter); | ||
290 | |||
291 | print_indent(); | ||
292 | printf("body-fld-id { %s }\n", body_fields->bd_id); | ||
293 | printf("body-fld-desc { %s }\n", body_fields->bd_description); | ||
294 | mailimap_body_fld_enc_print(body_fields->bd_encoding); | ||
295 | printf("body-fld-octets { %i }\n", body_fields->bd_size); | ||
296 | |||
297 | unindent(); | ||
298 | print_indent(); | ||
299 | printf("}\n"); | ||
300 | } | ||
301 | |||
302 | static void mailimap_media_basic_print(struct mailimap_media_basic * | ||
303 | media_basic) | ||
304 | { | ||
305 | print_indent(); | ||
306 | printf("media-basic {"); | ||
307 | |||
308 | switch (media_basic->med_type) { | ||
309 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | ||
310 | printf("application"); | ||
311 | break; | ||
312 | case MAILIMAP_MEDIA_BASIC_AUDIO: | ||
313 | printf("audio"); | ||
314 | break; | ||
315 | case MAILIMAP_MEDIA_BASIC_IMAGE: | ||
316 | printf("image"); | ||
317 | break; | ||
318 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | ||
319 | printf("message"); | ||
320 | break; | ||
321 | case MAILIMAP_MEDIA_BASIC_VIDEO: | ||
322 | printf("video"); | ||
323 | break; | ||
324 | case MAILIMAP_MEDIA_BASIC_OTHER: | ||
325 | printf("%s", media_basic->med_basic_type); | ||
326 | break; | ||
327 | } | ||
328 | printf(" / %s }\n", media_basic->med_subtype); | ||
329 | } | ||
330 | |||
331 | static void mailimap_body_type_basic_print(struct mailimap_body_type_basic * | ||
332 | body_type_basic) | ||
333 | { | ||
334 | print_indent(); | ||
335 | printf("body-type-basic {\n"); | ||
336 | indent(); | ||
337 | |||
338 | mailimap_media_basic_print(body_type_basic->bd_media_basic); | ||
339 | mailimap_body_fields_print(body_type_basic->bd_fields); | ||
340 | |||
341 | unindent(); | ||
342 | print_indent(); | ||
343 | printf("}\n"); | ||
344 | } | ||
345 | |||
346 | static void mailimap_body_type_1part_print(struct mailimap_body_type_1part * | ||
347 | body_type_1part) | ||
348 | { | ||
349 | print_indent(); | ||
350 | printf("body-type-1part {\n"); | ||
351 | indent(); | ||
352 | |||
353 | switch (body_type_1part->bd_type) { | ||
354 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | ||
355 | mailimap_body_type_basic_print(body_type_1part->bd_data.bd_type_basic); | ||
356 | break; | ||
357 | |||
358 | case MAILIMAP_BODY_TYPE_1PART_MSG: | ||
359 | mailimap_body_type_msg_print(body_type_1part->bd_data.bd_type_msg); | ||
360 | break; | ||
361 | |||
362 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | ||
363 | mailimap_body_type_text_print(body_type_1part->bd_data.bd_type_text); | ||
364 | break; | ||
365 | } | ||
366 | |||
367 | if (body_type_1part->bd_ext_1part != NULL) | ||
368 | mailimap_body_ext_1part_print(body_type_1part->bd_ext_1part); | ||
369 | |||
370 | unindent(); | ||
371 | print_indent(); | ||
372 | printf("\n"); | ||
373 | } | ||
374 | |||
375 | static void mailimap_body_ext_mpart(struct mailimap_body_ext_mpart * ext_mpart) | ||
376 | { | ||
377 | print_indent(); | ||
378 | printf("body-ext-mpart {\n"); | ||
379 | indent(); | ||
380 | |||
381 | mailimap_body_fld_param_print(ext_mpart->bd_parameter); | ||
382 | if (ext_mpart->bd_disposition) { | ||
383 | mailimap_body_fld_dsp_print(ext_mpart->bd_disposition); | ||
384 | if (ext_mpart->bd_language) { | ||
385 | mailimap_body_fld_lang_print(ext_mpart->bd_language); | ||
386 | |||
387 | if (ext_mpart->bd_extension_list) | ||
388 | mailimap_body_extension_list_print(ext_mpart->bd_extension_list); | ||
389 | } | ||
390 | } | ||
391 | |||
392 | unindent(); | ||
393 | print_indent(); | ||
394 | printf("\n"); | ||
395 | } | ||
396 | |||
397 | static void mailimap_body_type_mpart_print(struct mailimap_body_type_mpart * | ||
398 | mpart) | ||
399 | { | ||
400 | clistiter * cur; | ||
401 | |||
402 | print_indent(); | ||
403 | printf("body-type-mpart {\n"); | ||
404 | indent(); | ||
405 | |||
406 | for(cur = clist_begin(mpart->bd_list) ; cur != NULL ; | ||
407 | cur = clist_next(cur)) { | ||
408 | struct mailimap_body * body; | ||
409 | |||
410 | body = clist_content(cur); | ||
411 | |||
412 | mailimap_body_print(body); | ||
413 | } | ||
414 | |||
415 | printf("media-subtype { %s }\n", mpart->bd_media_subtype); | ||
416 | |||
417 | if (mpart->bd_ext_mpart) | ||
418 | mailimap_body_ext_mpart(mpart->bd_ext_mpart); | ||
419 | |||
420 | unindent(); | ||
421 | print_indent(); | ||
422 | printf("}\n"); | ||
423 | } | ||
424 | |||
425 | |||
426 | static void mailimap_body_print(struct mailimap_body * body) | ||
427 | { | ||
428 | print_indent(); | ||
429 | printf("body {\n"); | ||
430 | indent(); | ||
431 | |||
432 | switch (body->bd_type) { | ||
433 | case MAILIMAP_BODY_1PART: | ||
434 | mailimap_body_type_1part_print(body->bd_data.bd_body_1part); | ||
435 | break; | ||
436 | case MAILIMAP_BODY_MPART: | ||
437 | mailimap_body_type_mpart_print(body->bd_data.bd_body_mpart); | ||
438 | break; | ||
439 | } | ||
440 | |||
441 | unindent(); | ||
442 | print_indent(); | ||
443 | printf("}\n"); | ||
444 | } | ||
445 | |||
446 | static void mailimap_date_time_print(struct mailimap_date_time * date_time) | ||
447 | { | ||
448 | print_indent(); | ||
449 | printf("date-time { %i/%i/%i - %i:%i:%i %i }\n", | ||
450 | date_time->dt_day, date_time->dt_month, date_time->dt_year, | ||
451 | date_time->dt_hour, date_time->dt_min, date_time->dt_month, | ||
452 | date_time->dt_zone); | ||
453 | } | ||
454 | |||
455 | static void mailimap_address_print(struct mailimap_address * address) | ||
456 | { | ||
457 | print_indent(); | ||
458 | printf("address { name: %s, addr: %s, mailbox: %s, host: %s) }\n", | ||
459 | address->ad_personal_name, address->ad_source_route, | ||
460 | address->ad_mailbox_name, address->ad_host_name); | ||
461 | } | ||
462 | |||
463 | static void mailimap_envelope_address_list_print(clist * address) | ||
464 | { | ||
465 | clistiter * cur; | ||
466 | |||
467 | print_indent(); | ||
468 | printf("envelope-address-list {\n"); | ||
469 | indent(); | ||
470 | |||
471 | for(cur = clist_begin(address) ; cur != NULL ; | ||
472 | cur = clist_next(cur)) { | ||
473 | struct mailimap_address * addr; | ||
474 | |||
475 | addr = clist_content(cur); | ||
476 | |||
477 | mailimap_address_print(addr); | ||
478 | } | ||
479 | |||
480 | unindent(); | ||
481 | print_indent(); | ||
482 | printf("}\n"); | ||
483 | } | ||
484 | |||
485 | static void mailimap_envelope_print(struct mailimap_envelope * env) | ||
486 | { | ||
487 | print_indent(); | ||
488 | printf("envelope {\n"); | ||
489 | indent(); | ||
490 | |||
491 | print_indent(); | ||
492 | printf("date { %s }\n", env->env_date); | ||
493 | |||
494 | print_indent(); | ||
495 | printf("subject { %s }\n", env->env_subject); | ||
496 | |||
497 | print_indent(); | ||
498 | printf("from {\n"); | ||
499 | indent(); | ||
500 | mailimap_envelope_address_list_print(env->env_from->frm_list); | ||
501 | unindent(); | ||
502 | print_indent(); | ||
503 | printf("}\n"); | ||
504 | |||
505 | print_indent(); | ||
506 | printf("sender {\n"); | ||
507 | indent(); | ||
508 | mailimap_envelope_address_list_print(env->env_sender->snd_list); | ||
509 | unindent(); | ||
510 | print_indent(); | ||
511 | printf("}\n"); | ||
512 | |||
513 | print_indent(); | ||
514 | printf("reply-to {\n"); | ||
515 | indent(); | ||
516 | mailimap_envelope_address_list_print(env->env_reply_to->rt_list); | ||
517 | unindent(); | ||
518 | print_indent(); | ||
519 | printf("}\n"); | ||
520 | |||
521 | print_indent(); | ||
522 | printf("to {\n"); | ||
523 | indent(); | ||
524 | mailimap_envelope_address_list_print(env->env_to->to_list); | ||
525 | unindent(); | ||
526 | print_indent(); | ||
527 | printf("}\n"); | ||
528 | |||
529 | print_indent(); | ||
530 | printf("cc {\n"); | ||
531 | indent(); | ||
532 | mailimap_envelope_address_list_print(env->env_cc->cc_list); | ||
533 | unindent(); | ||
534 | print_indent(); | ||
535 | printf("}\n"); | ||
536 | |||
537 | print_indent(); | ||
538 | printf("bcc {\n"); | ||
539 | indent(); | ||
540 | mailimap_envelope_address_list_print(env->env_bcc->bcc_list); | ||
541 | unindent(); | ||
542 | print_indent(); | ||
543 | printf("}\n"); | ||
544 | |||
545 | printf("in-reply-to { %s }\n", env->env_in_reply_to); | ||
546 | printf("message-id { %s }\n", env->env_message_id); | ||
547 | |||
548 | unindent(); | ||
549 | print_indent(); | ||
550 | printf("}\n"); | ||
551 | } | ||
552 | |||
553 | static void mailimap_header_list_print(struct mailimap_header_list * | ||
554 | header_list) | ||
555 | { | ||
556 | clistiter * cur; | ||
557 | |||
558 | print_indent(); | ||
559 | printf("header-list { "); | ||
560 | for(cur = clist_begin(header_list->hdr_list) ; cur != NULL ; | ||
561 | cur = clist_next(cur)) | ||
562 | printf("%s ", (char *) clist_content(cur)); | ||
563 | printf("}\n"); | ||
564 | } | ||
565 | |||
566 | static void mailimap_section_msgtext_print(struct mailimap_section_msgtext * | ||
567 | section_msgtext) | ||
568 | { | ||
569 | print_indent(); | ||
570 | printf("section-msgtext {\n"); | ||
571 | indent(); | ||
572 | |||
573 | switch(section_msgtext->sec_type) { | ||
574 | case MAILIMAP_SECTION_MSGTEXT_HEADER: | ||
575 | print_indent(); | ||
576 | printf("header\n"); | ||
577 | break; | ||
578 | |||
579 | case MAILIMAP_SECTION_MSGTEXT_HEADER_FIELDS: | ||
580 | print_indent(); | ||
581 | printf("header fields {"); | ||
582 | indent(); | ||
583 | mailimap_header_list_print(section_msgtext->sec_header_list); | ||
584 | unindent(); | ||
585 | print_indent(); | ||
586 | printf("}\n"); | ||
587 | break; | ||
588 | |||
589 | case MAILIMAP_SECTION_MSGTEXT_HEADER_FIELDS_NOT: | ||
590 | print_indent(); | ||
591 | printf("header fields not {"); | ||
592 | indent(); | ||
593 | mailimap_header_list_print(section_msgtext->sec_header_list); | ||
594 | unindent(); | ||
595 | print_indent(); | ||
596 | printf("}\n"); | ||
597 | break; | ||
598 | |||
599 | case MAILIMAP_SECTION_MSGTEXT_TEXT: | ||
600 | print_indent(); | ||
601 | printf("text\n"); | ||
602 | break; | ||
603 | } | ||
604 | |||
605 | unindent(); | ||
606 | print_indent(); | ||
607 | printf("}\n"); | ||
608 | } | ||
609 | |||
610 | static void mailimap_section_part_print(struct mailimap_section_part * | ||
611 | section_part) | ||
612 | { | ||
613 | clistiter * cur; | ||
614 | |||
615 | print_indent(); | ||
616 | printf("section-part { "); | ||
617 | |||
618 | for(cur = clist_begin(section_part->sec_id) ; | ||
619 | cur != NULL ; cur = clist_next(cur)) { | ||
620 | printf("%i", * ((uint32_t *) clist_content(cur))); | ||
621 | if (clist_next(cur) != NULL) | ||
622 | printf("."); | ||
623 | } | ||
624 | printf(" }\n"); | ||
625 | } | ||
626 | |||
627 | static void mailimap_section_text_print(struct mailimap_section_text * | ||
628 | section_text) | ||
629 | { | ||
630 | print_indent(); | ||
631 | printf("section-text {\n"); | ||
632 | indent(); | ||
633 | |||
634 | switch (section_text->sec_type) { | ||
635 | case MAILIMAP_SECTION_TEXT_MIME: | ||
636 | print_indent(); | ||
637 | printf("MIME"); | ||
638 | break; | ||
639 | case MAILIMAP_SECTION_TEXT_SECTION_MSGTEXT: | ||
640 | mailimap_section_msgtext_print(section_text->sec_msgtext); | ||
641 | break; | ||
642 | } | ||
643 | |||
644 | unindent(); | ||
645 | print_indent(); | ||
646 | printf("}\n"); | ||
647 | } | ||
648 | |||
649 | static void mailimap_section_spec_print(struct mailimap_section_spec * | ||
650 | section_spec) | ||
651 | { | ||
652 | print_indent(); | ||
653 | printf("section-spec {"); | ||
654 | indent(); | ||
655 | |||
656 | switch(section_spec->sec_type) { | ||
657 | case MAILIMAP_SECTION_SPEC_SECTION_MSGTEXT: | ||
658 | mailimap_section_msgtext_print(section_spec->sec_data.sec_msgtext); | ||
659 | break; | ||
660 | case MAILIMAP_SECTION_SPEC_SECTION_PART: | ||
661 | mailimap_section_part_print(section_spec->sec_data.sec_part); | ||
662 | if (section_spec->sec_text != NULL) | ||
663 | mailimap_section_text_print(section_spec->sec_text); | ||
664 | break; | ||
665 | } | ||
666 | |||
667 | unindent(); | ||
668 | print_indent(); | ||
669 | printf("}\n"); | ||
670 | } | ||
671 | |||
672 | static void mailimap_section_print(struct mailimap_section * section) | ||
673 | { | ||
674 | print_indent(); | ||
675 | printf("section {\n"); | ||
676 | indent(); | ||
677 | |||
678 | if (section != NULL) | ||
679 | if (section->sec_spec != NULL) | ||
680 | mailimap_section_spec_print(section->sec_spec); | ||
681 | |||
682 | unindent(); | ||
683 | print_indent(); | ||
684 | printf("}\n"); | ||
685 | } | ||
686 | |||
687 | static void mailimap_msg_att_body_section_print(struct | ||
688 | mailimap_msg_att_body_section * | ||
689 | msg_att_body_section) | ||
690 | { | ||
691 | print_indent(); | ||
692 | printf("msg-att-body-section {\n"); | ||
693 | indent(); | ||
694 | |||
695 | mailimap_section_print(msg_att_body_section->sec_section); | ||
696 | printf("origin-octet: %i\n", msg_att_body_section->sec_origin_octet); | ||
697 | printf("body-part: %s\n", msg_att_body_section->sec_body_part); | ||
698 | |||
699 | unindent(); | ||
700 | print_indent(); | ||
701 | printf("}\n"); | ||
702 | } | ||
703 | |||
704 | |||
705 | static void mailimap_msg_att_static_print(struct mailimap_msg_att_static * | ||
706 | msg_att_static) | ||
707 | { | ||
708 | print_indent(); | ||
709 | printf("msg-att-static {\n"); | ||
710 | indent(); | ||
711 | |||
712 | switch (msg_att_static->att_type) { | ||
713 | |||
714 | case MAILIMAP_MSG_ATT_ENVELOPE: | ||
715 | print_indent(); | ||
716 | printf("envelope {\n"); | ||
717 | indent(); | ||
718 | print_indent(); | ||
719 | mailimap_envelope_print(msg_att_static->att_data.att_env); | ||
720 | unindent(); | ||
721 | print_indent(); | ||
722 | printf("}\n"); | ||
723 | break; | ||
724 | |||
725 | case MAILIMAP_MSG_ATT_INTERNALDATE: | ||
726 | print_indent(); | ||
727 | printf("internaldate {\n"); | ||
728 | indent(); | ||
729 | print_indent(); | ||
730 | mailimap_date_time_print(msg_att_static->att_data.att_internal_date); | ||
731 | unindent(); | ||
732 | print_indent(); | ||
733 | printf("}\n"); | ||
734 | break; | ||
735 | |||
736 | case MAILIMAP_MSG_ATT_RFC822: | ||
737 | print_indent(); | ||
738 | printf("rfc822 {\n"); | ||
739 | printf("%s\n", msg_att_static->att_data.att_rfc822.att_content); | ||
740 | print_indent(); | ||
741 | printf("}\n"); | ||
742 | break; | ||
743 | |||
744 | case MAILIMAP_MSG_ATT_RFC822_HEADER: | ||
745 | print_indent(); | ||
746 | printf("rfc822-header {\n"); | ||
747 | printf("%s\n", msg_att_static->att_data.att_rfc822_header.att_content); | ||
748 | print_indent(); | ||
749 | printf("}\n"); | ||
750 | break; | ||
751 | |||
752 | case MAILIMAP_MSG_ATT_RFC822_TEXT: | ||
753 | print_indent(); | ||
754 | printf("rfc822-text {\n"); | ||
755 | printf("%s\n", msg_att_static->att_data.att_rfc822_text.att_content); | ||
756 | print_indent(); | ||
757 | printf("}\n"); | ||
758 | break; | ||
759 | |||
760 | case MAILIMAP_MSG_ATT_RFC822_SIZE: | ||
761 | print_indent(); | ||
762 | printf("rfc822-size { %i }\n", msg_att_static->att_data.att_rfc822_size); | ||
763 | break; | ||
764 | |||
765 | case MAILIMAP_MSG_ATT_BODY: | ||
766 | print_indent(); | ||
767 | printf("body {\n"); | ||
768 | indent(); | ||
769 | print_indent(); | ||
770 | mailimap_body_print(msg_att_static->att_data.att_body); | ||
771 | unindent(); | ||
772 | print_indent(); | ||
773 | printf("}\n"); | ||
774 | break; | ||
775 | |||
776 | case MAILIMAP_MSG_ATT_BODYSTRUCTURE: | ||
777 | print_indent(); | ||
778 | printf("bodystructure {\n"); | ||
779 | indent(); | ||
780 | print_indent(); | ||
781 | mailimap_body_print(msg_att_static->att_data.att_bodystructure); | ||
782 | unindent(); | ||
783 | print_indent(); | ||
784 | printf("}\n"); | ||
785 | break; | ||
786 | |||
787 | case MAILIMAP_MSG_ATT_BODY_SECTION: | ||
788 | print_indent(); | ||
789 | printf("body-section {\n"); | ||
790 | indent(); | ||
791 | print_indent(); | ||
792 | mailimap_msg_att_body_section_print(msg_att_static->att_data.att_body_section); | ||
793 | unindent(); | ||
794 | print_indent(); | ||
795 | printf("}\n"); | ||
796 | break; | ||
797 | |||
798 | case MAILIMAP_MSG_ATT_UID: | ||
799 | printf("uid { %i }\n", msg_att_static->att_data.att_uid); | ||
800 | break; | ||
801 | } | ||
802 | |||
803 | unindent(); | ||
804 | print_indent(); | ||
805 | printf("}\n"); | ||
806 | } | ||
807 | |||
808 | static void mailimap_flag_print(struct mailimap_flag * flag); | ||
809 | |||
810 | static void mailimap_flag_fetch_print(struct mailimap_flag_fetch * flag) | ||
811 | { | ||
812 | print_indent(); | ||
813 | printf("flag fetch {\n"); | ||
814 | indent(); | ||
815 | |||
816 | switch (flag->fl_type) { | ||
817 | case MAILIMAP_FLAG_FETCH_RECENT: | ||
818 | printf("recent\n"); | ||
819 | break; | ||
820 | case MAILIMAP_FLAG_FETCH_OTHER: | ||
821 | print_indent(); | ||
822 | printf("flag {\n"); | ||
823 | indent(); | ||
824 | mailimap_flag_print(flag->fl_flag); | ||
825 | unindent(); | ||
826 | print_indent(); | ||
827 | printf("}\n"); | ||
828 | break; | ||
829 | } | ||
830 | |||
831 | unindent(); | ||
832 | print_indent(); | ||
833 | printf("}\n"); | ||
834 | } | ||
835 | |||
836 | static void mailimap_msg_att_dynamic_print(struct mailimap_msg_att_dynamic * | ||
837 | dynamic) | ||
838 | { | ||
839 | clistiter * cur; | ||
840 | |||
841 | print_indent(); | ||
842 | printf("msg-att-dynamic {\n"); | ||
843 | indent(); | ||
844 | |||
845 | for(cur = clist_begin(dynamic->att_list) ; cur != NULL ; | ||
846 | cur = clist_next(cur)) { | ||
847 | struct mailimap_flag_fetch * flag; | ||
848 | |||
849 | flag = (struct mailimap_flag_fetch *) clist_content(cur); | ||
850 | mailimap_flag_fetch_print(flag); | ||
851 | } | ||
852 | |||
853 | unindent(); | ||
854 | print_indent(); | ||
855 | printf("}\n"); | ||
856 | } | ||
857 | |||
858 | static void mailimap_msg_att_item_print(struct mailimap_msg_att_item * item) | ||
859 | { | ||
860 | print_indent(); | ||
861 | printf("msg-att-item {\n"); | ||
862 | indent(); | ||
863 | |||
864 | switch (item->att_type) { | ||
865 | case MAILIMAP_MSG_ATT_ITEM_DYNAMIC: | ||
866 | mailimap_msg_att_dynamic_print(item->att_data.att_dyn); | ||
867 | break; | ||
868 | case MAILIMAP_MSG_ATT_ITEM_STATIC: | ||
869 | mailimap_msg_att_static_print(item->att_data.att_static); | ||
870 | break; | ||
871 | } | ||
872 | |||
873 | unindent(); | ||
874 | print_indent(); | ||
875 | printf("}\n"); | ||
876 | } | ||
877 | |||
878 | static void mailimap_msg_att_print(struct mailimap_msg_att * msg_att) | ||
879 | { | ||
880 | clistiter * cur; | ||
881 | |||
882 | print_indent(); | ||
883 | printf("msg-att {\n"); | ||
884 | indent(); | ||
885 | |||
886 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; | ||
887 | cur = clist_next(cur)) { | ||
888 | struct mailimap_msg_att_item * item; | ||
889 | |||
890 | item = clist_content(cur); | ||
891 | |||
892 | mailimap_msg_att_item_print(item); | ||
893 | } | ||
894 | |||
895 | unindent(); | ||
896 | print_indent(); | ||
897 | printf("}\n"); | ||
898 | } | ||
899 | |||
900 | static void mailimap_message_data_print(struct mailimap_message_data * | ||
901 | msg_data) | ||
902 | { | ||
903 | print_indent(); | ||
904 | printf("message-data {\n"); | ||
905 | indent(); | ||
906 | |||
907 | switch (msg_data->mdt_type) { | ||
908 | case MAILIMAP_MESSAGE_DATA_EXPUNGE: | ||
909 | print_indent(); | ||
910 | printf("expunged { %i }\n", msg_data->mdt_number); | ||
911 | break; | ||
912 | case MAILIMAP_MESSAGE_DATA_FETCH: | ||
913 | print_indent(); | ||
914 | printf("message-number { %i }\n", msg_data->mdt_number); | ||
915 | mailimap_msg_att_print(msg_data->mdt_msg_att); | ||
916 | break; | ||
917 | } | ||
918 | |||
919 | unindent(); | ||
920 | print_indent(); | ||
921 | printf("}\n"); | ||
922 | } | ||
923 | |||
924 | static void mailimap_status_att_print(int status_att) | ||
925 | { | ||
926 | print_indent(); | ||
927 | printf("status-att { "); | ||
928 | |||
929 | switch(status_att) { | ||
930 | case MAILIMAP_STATUS_ATT_MESSAGES: | ||
931 | printf("messages"); | ||
932 | break; | ||
933 | case MAILIMAP_STATUS_ATT_RECENT: | ||
934 | printf("recent"); | ||
935 | break; | ||
936 | case MAILIMAP_STATUS_ATT_UIDNEXT: | ||
937 | printf("uidnext"); | ||
938 | break; | ||
939 | case MAILIMAP_STATUS_ATT_UIDVALIDITY: | ||
940 | printf("status att uidvalidity"); | ||
941 | break; | ||
942 | case MAILIMAP_STATUS_ATT_UNSEEN: | ||
943 | printf("status att unseen"); | ||
944 | break; | ||
945 | } | ||
946 | |||
947 | printf(" \n"); | ||
948 | } | ||
949 | |||
950 | static void | ||
951 | mailimap_status_info_print(struct mailimap_status_info * info) | ||
952 | { | ||
953 | print_indent(); | ||
954 | printf("status-info {\n"); | ||
955 | indent(); | ||
956 | |||
957 | mailimap_status_att_print(info->st_att); | ||
958 | |||
959 | print_indent(); | ||
960 | printf("value { %i }\n", info->st_value); | ||
961 | |||
962 | unindent(); | ||
963 | print_indent(); | ||
964 | printf("}\n"); | ||
965 | } | ||
966 | |||
967 | static void | ||
968 | mailimap_mailbox_data_status_print(struct mailimap_mailbox_data_status * | ||
969 | mb_data_status) | ||
970 | { | ||
971 | clistiter * cur; | ||
972 | |||
973 | print_indent(); | ||
974 | printf("mailbox-data-status {\n"); | ||
975 | indent(); | ||
976 | |||
977 | print_indent(); | ||
978 | printf("mailbox { %s }\n", mb_data_status->st_mailbox); | ||
979 | |||
980 | for(cur = clist_begin(mb_data_status->st_info_list) ; | ||
981 | cur != NULL ; cur = clist_next(cur)) { | ||
982 | struct mailimap_status_info * info; | ||
983 | |||
984 | info = clist_content(cur); | ||
985 | |||
986 | mailimap_status_info_print(info); | ||
987 | } | ||
988 | |||
989 | unindent(); | ||
990 | print_indent(); | ||
991 | printf("}\n"); | ||
992 | } | ||
993 | |||
994 | static void mailimap_mbx_list_oflag_print(struct mailimap_mbx_list_oflag * | ||
995 | oflag) | ||
996 | { | ||
997 | print_indent(); | ||
998 | printf("mbx-list-oflag { "); | ||
999 | |||
1000 | switch (oflag->of_type) { | ||
1001 | case MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS: | ||
1002 | printf("noinferiors"); | ||
1003 | break; | ||
1004 | case MAILIMAP_MBX_LIST_OFLAG_FLAG_EXT: | ||
1005 | printf("%s", oflag->of_flag_ext); | ||
1006 | break; | ||
1007 | } | ||
1008 | |||
1009 | printf(" }\n"); | ||
1010 | } | ||
1011 | |||
1012 | static void mailimap_mbx_list_sflag_print(int sflag) | ||
1013 | { | ||
1014 | print_indent(); | ||
1015 | printf("mbx-list-sflag { "); | ||
1016 | |||
1017 | switch (sflag) { | ||
1018 | case MAILIMAP_MBX_LIST_SFLAG_MARKED: | ||
1019 | printf("marked"); | ||
1020 | break; | ||
1021 | case MAILIMAP_MBX_LIST_SFLAG_NOSELECT: | ||
1022 | printf("noselected"); | ||
1023 | break; | ||
1024 | case MAILIMAP_MBX_LIST_SFLAG_UNMARKED: | ||
1025 | printf("unmarked"); | ||
1026 | break; | ||
1027 | } | ||
1028 | |||
1029 | printf(" }\n"); | ||
1030 | } | ||
1031 | |||
1032 | static void mailimap_mbx_list_flags_print(struct mailimap_mbx_list_flags * | ||
1033 | mbx_list_flags) | ||
1034 | { | ||
1035 | clistiter * cur; | ||
1036 | |||
1037 | print_indent(); | ||
1038 | printf("mbx-list-flags {"); | ||
1039 | indent(); | ||
1040 | |||
1041 | if (mbx_list_flags->mbf_type == MAILIMAP_MBX_LIST_FLAGS_SFLAG) | ||
1042 | mailimap_mbx_list_sflag_print(mbx_list_flags->mbf_sflag); | ||
1043 | |||
1044 | for(cur = clist_begin(mbx_list_flags->mbf_oflags) ; cur != NULL ; | ||
1045 | cur = clist_next(cur)) { | ||
1046 | struct mailimap_mbx_list_oflag * oflag; | ||
1047 | |||
1048 | oflag = clist_content(cur); | ||
1049 | |||
1050 | mailimap_mbx_list_oflag_print(oflag); | ||
1051 | } | ||
1052 | |||
1053 | unindent(); | ||
1054 | print_indent(); | ||
1055 | printf("}\n"); | ||
1056 | } | ||
1057 | |||
1058 | static void mailimap_mailbox_list_print(struct mailimap_mailbox_list * mb_list) | ||
1059 | { | ||
1060 | print_indent(); | ||
1061 | printf("mailbox-list {\n"); | ||
1062 | indent(); | ||
1063 | |||
1064 | mailimap_mbx_list_flags_print(mb_list->mb_flag); | ||
1065 | printf("dir-separator { %c }\n", mb_list->mb_delimiter); | ||
1066 | printf("mailbox { %s }\n", mb_list->mb_name); | ||
1067 | |||
1068 | unindent(); | ||
1069 | print_indent(); | ||
1070 | printf("}\n"); | ||
1071 | } | ||
1072 | |||
1073 | static void mailimap_flag_list_print(struct mailimap_flag_list * flag_list) | ||
1074 | { | ||
1075 | clistiter * cur; | ||
1076 | |||
1077 | print_indent(); | ||
1078 | printf("flag-list {\n"); | ||
1079 | indent(); | ||
1080 | |||
1081 | for(cur = clist_begin(flag_list->fl_list) ; cur != NULL ; | ||
1082 | cur = clist_next(cur)) { | ||
1083 | struct mailimap_flag * flag; | ||
1084 | |||
1085 | flag = clist_content(cur); | ||
1086 | |||
1087 | print_indent(); | ||
1088 | mailimap_flag_print(flag); | ||
1089 | printf("\n"); | ||
1090 | } | ||
1091 | |||
1092 | unindent(); | ||
1093 | print_indent(); | ||
1094 | printf("}\n"); | ||
1095 | } | ||
1096 | |||
1097 | |||
1098 | static void mailimap_mailbox_data_print(struct mailimap_mailbox_data * mb_data) | ||
1099 | { | ||
1100 | clistiter * cur; | ||
1101 | |||
1102 | print_indent(); | ||
1103 | printf("mailbox-data {\n"); | ||
1104 | indent(); | ||
1105 | |||
1106 | switch (mb_data->mbd_type) { | ||
1107 | case MAILIMAP_MAILBOX_DATA_FLAGS: | ||
1108 | print_indent(); | ||
1109 | printf("flags {\n"); | ||
1110 | indent(); | ||
1111 | mailimap_flag_list_print(mb_data->mbd_data.mbd_flags); | ||
1112 | unindent(); | ||
1113 | print_indent(); | ||
1114 | printf("}\n"); | ||
1115 | break; | ||
1116 | |||
1117 | case MAILIMAP_MAILBOX_DATA_LIST: | ||
1118 | print_indent(); | ||
1119 | printf("list {\n"); | ||
1120 | indent(); | ||
1121 | mailimap_mailbox_list_print(mb_data->mbd_data.mbd_list); | ||
1122 | unindent(); | ||
1123 | print_indent(); | ||
1124 | printf("}\n"); | ||
1125 | break; | ||
1126 | |||
1127 | case MAILIMAP_MAILBOX_DATA_LSUB: | ||
1128 | print_indent(); | ||
1129 | printf("lsub {\n"); | ||
1130 | indent(); | ||
1131 | mailimap_mailbox_list_print(mb_data->mbd_data.mbd_lsub); | ||
1132 | unindent(); | ||
1133 | print_indent(); | ||
1134 | printf("}\n"); | ||
1135 | break; | ||
1136 | |||
1137 | case MAILIMAP_MAILBOX_DATA_SEARCH: | ||
1138 | print_indent(); | ||
1139 | printf("search { "); | ||
1140 | for(cur = clist_begin(mb_data->mbd_data.mbd_search) ; | ||
1141 | cur != NULL ; cur = clist_next(cur)) { | ||
1142 | uint32_t * id; | ||
1143 | |||
1144 | id = clist_content(cur); | ||
1145 | printf("%i ", * id); | ||
1146 | } | ||
1147 | printf(" }\n"); | ||
1148 | break; | ||
1149 | |||
1150 | case MAILIMAP_MAILBOX_DATA_STATUS: | ||
1151 | print_indent(); | ||
1152 | printf("status {\n"); | ||
1153 | indent(); | ||
1154 | mailimap_mailbox_data_status_print(mb_data->mbd_data.mbd_status); | ||
1155 | unindent(); | ||
1156 | print_indent(); | ||
1157 | printf("}\n"); | ||
1158 | break; | ||
1159 | |||
1160 | case MAILIMAP_MAILBOX_DATA_EXISTS: | ||
1161 | print_indent(); | ||
1162 | printf("exists { %i }\n", mb_data->mbd_data.mbd_exists); | ||
1163 | break; | ||
1164 | |||
1165 | case MAILIMAP_MAILBOX_DATA_RECENT: | ||
1166 | print_indent(); | ||
1167 | printf("recent { %i }\n", mb_data->mbd_data.mbd_recent); | ||
1168 | break; | ||
1169 | } | ||
1170 | |||
1171 | unindent(); | ||
1172 | print_indent(); | ||
1173 | printf("}\n"); | ||
1174 | } | ||
1175 | |||
1176 | static void | ||
1177 | mailimap_resp_text_code_print(struct mailimap_resp_text_code * text_code); | ||
1178 | |||
1179 | static void mailimap_resp_text_print(struct mailimap_resp_text * resp_text); | ||
1180 | |||
1181 | static void mailimap_resp_cond_bye_print(struct mailimap_resp_cond_bye * | ||
1182 | resp_cond_bye) | ||
1183 | { | ||
1184 | print_indent(); | ||
1185 | printf("resp-cond-bye {\n"); | ||
1186 | indent(); | ||
1187 | mailimap_resp_text_print(resp_cond_bye->rsp_text); | ||
1188 | unindent(); | ||
1189 | print_indent(); | ||
1190 | printf("}\n"); | ||
1191 | } | ||
1192 | |||
1193 | static void mailimap_resp_cond_state_print(struct mailimap_resp_cond_state * | ||
1194 | resp_cond_state) | ||
1195 | { | ||
1196 | print_indent(); | ||
1197 | printf("resp-cond-state {\n"); | ||
1198 | indent(); | ||
1199 | |||
1200 | switch(resp_cond_state->rsp_type) { | ||
1201 | case MAILIMAP_RESP_COND_STATE_OK: | ||
1202 | print_indent(); | ||
1203 | printf("OK\n"); | ||
1204 | break; | ||
1205 | case MAILIMAP_RESP_COND_STATE_NO: | ||
1206 | print_indent(); | ||
1207 | printf("NO\n"); | ||
1208 | break; | ||
1209 | case MAILIMAP_RESP_COND_STATE_BAD: | ||
1210 | print_indent(); | ||
1211 | printf("BAD\n"); | ||
1212 | break; | ||
1213 | } | ||
1214 | |||
1215 | mailimap_resp_text_print(resp_cond_state->rsp_text); | ||
1216 | |||
1217 | unindent(); | ||
1218 | print_indent(); | ||
1219 | printf("}\n"); | ||
1220 | } | ||
1221 | |||
1222 | static void mailimap_capability_data_print(struct mailimap_capability_data * | ||
1223 | cap_data); | ||
1224 | |||
1225 | static void mailimap_response_data_print(struct mailimap_response_data * | ||
1226 | resp_data) | ||
1227 | { | ||
1228 | print_indent(); | ||
1229 | printf("response-data {\n"); | ||
1230 | indent(); | ||
1231 | |||
1232 | switch (resp_data->rsp_type) { | ||
1233 | case MAILIMAP_RESP_DATA_TYPE_COND_STATE: | ||
1234 | mailimap_resp_cond_state_print(resp_data->rsp_data.rsp_cond_state); | ||
1235 | break; | ||
1236 | case MAILIMAP_RESP_DATA_TYPE_COND_BYE: | ||
1237 | mailimap_resp_cond_bye_print(resp_data->rsp_data.rsp_bye); | ||
1238 | break; | ||
1239 | case MAILIMAP_RESP_DATA_TYPE_MAILBOX_DATA: | ||
1240 | mailimap_mailbox_data_print(resp_data->rsp_data.rsp_mailbox_data); | ||
1241 | break; | ||
1242 | case MAILIMAP_RESP_DATA_TYPE_MESSAGE_DATA: | ||
1243 | mailimap_message_data_print(resp_data->rsp_data.rsp_message_data); | ||
1244 | break; | ||
1245 | case MAILIMAP_RESP_DATA_TYPE_CAPABILITY_DATA: | ||
1246 | mailimap_capability_data_print(resp_data->rsp_data.rsp_capability_data); | ||
1247 | break; | ||
1248 | } | ||
1249 | |||
1250 | unindent(); | ||
1251 | print_indent(); | ||
1252 | printf("}\n"); | ||
1253 | } | ||
1254 | |||
1255 | static void mailimap_flag_print(struct mailimap_flag * flag) | ||
1256 | { | ||
1257 | printf("flag { "); | ||
1258 | |||
1259 | switch (flag->fl_type) { | ||
1260 | case MAILIMAP_FLAG_ANSWERED: | ||
1261 | printf("answered"); | ||
1262 | break; | ||
1263 | |||
1264 | case MAILIMAP_FLAG_FLAGGED: | ||
1265 | printf("flagged"); | ||
1266 | break; | ||
1267 | |||
1268 | case MAILIMAP_FLAG_DELETED: | ||
1269 | printf("deleted"); | ||
1270 | break; | ||
1271 | |||
1272 | case MAILIMAP_FLAG_SEEN: | ||
1273 | printf("seen"); | ||
1274 | break; | ||
1275 | |||
1276 | case MAILIMAP_FLAG_DRAFT: | ||
1277 | printf("flag draft"); | ||
1278 | break; | ||
1279 | |||
1280 | case MAILIMAP_FLAG_KEYWORD: | ||
1281 | printf("keyword { %s }", flag->fl_data.fl_keyword); | ||
1282 | break; | ||
1283 | |||
1284 | case MAILIMAP_FLAG_EXTENSION: | ||
1285 | printf("extention { %s }", flag->fl_data.fl_extension); | ||
1286 | break; | ||
1287 | } | ||
1288 | |||
1289 | printf(" }"); | ||
1290 | } | ||
1291 | |||
1292 | static void mailimap_flag_perm_print(struct mailimap_flag_perm * flag_perm) | ||
1293 | { | ||
1294 | print_indent(); | ||
1295 | printf("flag-perm { "); | ||
1296 | |||
1297 | switch (flag_perm->fl_type) { | ||
1298 | case MAILIMAP_FLAG_PERM_FLAG: | ||
1299 | mailimap_flag_print(flag_perm->fl_flag); | ||
1300 | break; | ||
1301 | |||
1302 | case MAILIMAP_FLAG_PERM_ALL: | ||
1303 | printf("all"); | ||
1304 | break; | ||
1305 | } | ||
1306 | |||
1307 | printf(" }\n"); | ||
1308 | } | ||
1309 | |||
1310 | static void mailimap_capability_print(struct mailimap_capability * cap) | ||
1311 | { | ||
1312 | print_indent(); | ||
1313 | printf("capability { "); | ||
1314 | |||
1315 | switch (cap->cap_type) { | ||
1316 | case MAILIMAP_CAPABILITY_AUTH_TYPE: | ||
1317 | printf("auth { %s }", cap->cap_data.cap_auth_type); | ||
1318 | break; | ||
1319 | case MAILIMAP_CAPABILITY_NAME: | ||
1320 | printf("atom { %s }", cap->cap_data.cap_name); | ||
1321 | break; | ||
1322 | } | ||
1323 | |||
1324 | printf(" }\n"); | ||
1325 | } | ||
1326 | |||
1327 | static void mailimap_capability_data_print(struct mailimap_capability_data * | ||
1328 | cap_data) | ||
1329 | { | ||
1330 | clistiter * cur; | ||
1331 | |||
1332 | print_indent(); | ||
1333 | printf("capability-data {\n"); | ||
1334 | indent(); | ||
1335 | |||
1336 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL ; | ||
1337 | cur = clist_next(cur)) { | ||
1338 | struct mailimap_capability * cap; | ||
1339 | |||
1340 | cap = clist_content(cur); | ||
1341 | |||
1342 | mailimap_capability_print(cap); | ||
1343 | } | ||
1344 | |||
1345 | unindent(); | ||
1346 | print_indent(); | ||
1347 | printf("}\n"); | ||
1348 | } | ||
1349 | |||
1350 | static void | ||
1351 | mailimap_resp_text_code_print(struct mailimap_resp_text_code * text_code) | ||
1352 | { | ||
1353 | clistiter * cur; | ||
1354 | |||
1355 | print_indent(); | ||
1356 | printf("resp-text-code {\n"); | ||
1357 | indent(); | ||
1358 | |||
1359 | switch (text_code->rc_type) { | ||
1360 | case MAILIMAP_RESP_TEXT_CODE_BADCHARSET: | ||
1361 | print_indent(); | ||
1362 | printf("badcharset { "); | ||
1363 | for(cur = clist_begin(text_code->rc_data.rc_badcharset) ; cur != NULL ; | ||
1364 | cur = clist_next(cur)) | ||
1365 | printf("%s ", (char *) clist_content(cur)); | ||
1366 | printf("}\n"); | ||
1367 | break; | ||
1368 | |||
1369 | case MAILIMAP_RESP_TEXT_CODE_CAPABILITY_DATA: | ||
1370 | print_indent(); | ||
1371 | printf("capability {\n"); | ||
1372 | indent(); | ||
1373 | mailimap_capability_data_print(text_code->rc_data.rc_cap_data); | ||
1374 | unindent(); | ||
1375 | print_indent(); | ||
1376 | printf("}\n"); | ||
1377 | break; | ||
1378 | |||
1379 | case MAILIMAP_RESP_TEXT_CODE_PERMANENTFLAGS: | ||
1380 | print_indent(); | ||
1381 | printf("permanent-flags {\n"); | ||
1382 | indent(); | ||
1383 | cur = clist_begin(text_code->rc_data.rc_perm_flags); | ||
1384 | while (cur != NULL) { | ||
1385 | mailimap_flag_perm_print(clist_content(cur)); | ||
1386 | cur = clist_next(cur); | ||
1387 | } | ||
1388 | unindent(); | ||
1389 | print_indent(); | ||
1390 | printf("}\n"); | ||
1391 | break; | ||
1392 | |||
1393 | case MAILIMAP_RESP_TEXT_CODE_READ_ONLY: | ||
1394 | print_indent(); | ||
1395 | printf("readonly\n"); | ||
1396 | break; | ||
1397 | |||
1398 | case MAILIMAP_RESP_TEXT_CODE_READ_WRITE: | ||
1399 | print_indent(); | ||
1400 | printf("readwrite\n"); | ||
1401 | break; | ||
1402 | |||
1403 | case MAILIMAP_RESP_TEXT_CODE_TRY_CREATE: | ||
1404 | print_indent(); | ||
1405 | printf("trycreate\n"); | ||
1406 | break; | ||
1407 | |||
1408 | case MAILIMAP_RESP_TEXT_CODE_UIDNEXT: | ||
1409 | print_indent(); | ||
1410 | printf("uidnext { %i }\n", text_code->rc_data.rc_uidnext); | ||
1411 | break; | ||
1412 | |||
1413 | case MAILIMAP_RESP_TEXT_CODE_UIDVALIDITY: | ||
1414 | print_indent(); | ||
1415 | printf("uidvalidity { %i }\n", text_code->rc_data.rc_uidvalidity); | ||
1416 | break; | ||
1417 | |||
1418 | case MAILIMAP_RESP_TEXT_CODE_UNSEEN: | ||
1419 | print_indent(); | ||
1420 | printf("unseen { %i }\n", text_code->rc_data.rc_first_unseen); | ||
1421 | break; | ||
1422 | |||
1423 | case MAILIMAP_RESP_TEXT_CODE_OTHER: | ||
1424 | print_indent(); | ||
1425 | printf("other { %s = %s }\n", | ||
1426 | text_code->rc_data.rc_atom.atom_name, | ||
1427 | text_code->rc_data.rc_atom.atom_value); | ||
1428 | break; | ||
1429 | } | ||
1430 | |||
1431 | unindent(); | ||
1432 | print_indent(); | ||
1433 | printf("}\n"); | ||
1434 | } | ||
1435 | |||
1436 | static void mailimap_resp_text_print(struct mailimap_resp_text * resp_text) | ||
1437 | { | ||
1438 | print_indent(); | ||
1439 | printf("resp-text {\n"); | ||
1440 | indent(); | ||
1441 | |||
1442 | if (resp_text->rsp_code) | ||
1443 | mailimap_resp_text_code_print(resp_text->rsp_code); | ||
1444 | print_indent(); | ||
1445 | printf("text { %s }\n", resp_text->rsp_text); | ||
1446 | |||
1447 | unindent(); | ||
1448 | print_indent(); | ||
1449 | printf("}\n"); | ||
1450 | } | ||
1451 | |||
1452 | static void mailimap_continue_req_print(struct mailimap_continue_req * | ||
1453 | cont_req) | ||
1454 | { | ||
1455 | print_indent(); | ||
1456 | printf("continue-req {\n"); | ||
1457 | indent(); | ||
1458 | |||
1459 | switch (cont_req->cr_type) { | ||
1460 | case MAILIMAP_CONTINUE_REQ_TEXT: | ||
1461 | print_indent(); | ||
1462 | printf("resp-text {\n"); | ||
1463 | indent(); | ||
1464 | mailimap_resp_text_print(cont_req->cr_data.cr_text); | ||
1465 | unindent(); | ||
1466 | print_indent(); | ||
1467 | printf("}\n"); | ||
1468 | break; | ||
1469 | case MAILIMAP_CONTINUE_REQ_BASE64: | ||
1470 | printf("base64 { %s }\n", cont_req->cr_data.cr_base64); | ||
1471 | break; | ||
1472 | } | ||
1473 | |||
1474 | unindent(); | ||
1475 | print_indent(); | ||
1476 | printf("}\n"); | ||
1477 | } | ||
1478 | |||
1479 | static void mailimap_cont_req_or_resp_data_print(struct mailimap_cont_req_or_resp_data * cont_req_or_resp_data) | ||
1480 | { | ||
1481 | print_indent(); | ||
1482 | printf("cont-req-or-resp-data {\n"); | ||
1483 | indent(); | ||
1484 | |||
1485 | switch (cont_req_or_resp_data->rsp_type) { | ||
1486 | case MAILIMAP_RESP_CONT_REQ: | ||
1487 | mailimap_continue_req_print(cont_req_or_resp_data->rsp_data.rsp_cont_req); | ||
1488 | break; | ||
1489 | case MAILIMAP_RESP_RESP_DATA: | ||
1490 | mailimap_response_data_print(cont_req_or_resp_data->rsp_data.rsp_resp_data); | ||
1491 | break; | ||
1492 | } | ||
1493 | |||
1494 | unindent(); | ||
1495 | print_indent(); | ||
1496 | printf("}\n"); | ||
1497 | } | ||
1498 | |||
1499 | static void mailimap_response_tagged_print(struct mailimap_response_tagged * | ||
1500 | tagged) | ||
1501 | { | ||
1502 | print_indent(); | ||
1503 | printf("response-tagged {\n"); | ||
1504 | indent(); | ||
1505 | |||
1506 | print_indent(); | ||
1507 | printf("tag { %s }\n", tagged->rsp_tag); | ||
1508 | mailimap_resp_cond_state_print(tagged->rsp_cond_state); | ||
1509 | |||
1510 | unindent(); | ||
1511 | print_indent(); | ||
1512 | printf("}\n"); | ||
1513 | } | ||
1514 | |||
1515 | static void mailimap_response_fatal_print(struct mailimap_response_fatal * | ||
1516 | fatal) | ||
1517 | { | ||
1518 | print_indent(); | ||
1519 | printf("response-fatal {\n"); | ||
1520 | indent(); | ||
1521 | |||
1522 | mailimap_resp_cond_bye_print(fatal->rsp_bye); | ||
1523 | |||
1524 | unindent(); | ||
1525 | print_indent(); | ||
1526 | printf("}\n"); | ||
1527 | } | ||
1528 | |||
1529 | static void mailimap_response_done_print(struct mailimap_response_done * | ||
1530 | resp_done) | ||
1531 | { | ||
1532 | print_indent(); | ||
1533 | printf("response-done {\n"); | ||
1534 | indent(); | ||
1535 | |||
1536 | switch (resp_done->rsp_type) { | ||
1537 | case MAILIMAP_RESP_DONE_TYPE_TAGGED: | ||
1538 | mailimap_response_tagged_print(resp_done->rsp_data.rsp_tagged); | ||
1539 | break; | ||
1540 | case MAILIMAP_RESP_DONE_TYPE_FATAL: | ||
1541 | mailimap_response_fatal_print(resp_done->rsp_data.rsp_fatal); | ||
1542 | break; | ||
1543 | } | ||
1544 | |||
1545 | unindent(); | ||
1546 | print_indent(); | ||
1547 | printf("}\n"); | ||
1548 | } | ||
1549 | |||
1550 | void mailimap_response_print(struct mailimap_response * resp) | ||
1551 | { | ||
1552 | clistiter * cur; | ||
1553 | |||
1554 | print_indent(); | ||
1555 | printf("response {\n"); | ||
1556 | indent(); | ||
1557 | |||
1558 | for(cur = clist_begin(resp->rsp_cont_req_or_resp_data_list) ; cur != NULL ; | ||
1559 | cur = clist_next(cur)) { | ||
1560 | struct mailimap_cont_req_or_resp_data * resp; | ||
1561 | |||
1562 | resp = clist_content(cur); | ||
1563 | |||
1564 | mailimap_cont_req_or_resp_data_print(resp); | ||
1565 | } | ||
1566 | |||
1567 | mailimap_response_done_print(resp->rsp_resp_done); | ||
1568 | |||
1569 | unindent(); | ||
1570 | print_indent(); | ||
1571 | printf("}\n"); | ||
1572 | } | ||
1573 | |||
1574 | static void mailimap_resp_cond_auth_print(struct mailimap_resp_cond_auth * | ||
1575 | cond_auth) | ||
1576 | { | ||
1577 | print_indent(); | ||
1578 | printf("resp-cond-auth {\n"); | ||
1579 | indent(); | ||
1580 | |||
1581 | switch (cond_auth->rsp_type) { | ||
1582 | case MAILIMAP_RESP_COND_AUTH_OK: | ||
1583 | print_indent(); | ||
1584 | printf("OK\n"); | ||
1585 | case MAILIMAP_RESP_COND_AUTH_PREAUTH: | ||
1586 | print_indent(); | ||
1587 | printf("PREAUTH\n"); | ||
1588 | } | ||
1589 | mailimap_resp_text_print(cond_auth->rsp_text); | ||
1590 | |||
1591 | unindent(); | ||
1592 | print_indent(); | ||
1593 | printf("}\n"); | ||
1594 | } | ||
1595 | |||
1596 | void mailimap_greeting_print(struct mailimap_greeting * greeting) | ||
1597 | { | ||
1598 | print_indent(); | ||
1599 | printf("greeting {\n"); | ||
1600 | indent(); | ||
1601 | |||
1602 | switch(greeting->gr_type) { | ||
1603 | case MAILIMAP_GREETING_RESP_COND_AUTH: | ||
1604 | mailimap_resp_cond_auth_print(greeting->gr_data.gr_auth); | ||
1605 | break; | ||
1606 | case MAILIMAP_GREETING_RESP_COND_BYE: | ||
1607 | mailimap_resp_cond_bye_print(greeting->gr_data.gr_bye); | ||
1608 | break; | ||
1609 | } | ||
1610 | |||
1611 | unindent(); | ||
1612 | print_indent(); | ||
1613 | printf("}\n"); | ||
1614 | } | ||
1615 | #endif | ||