imap client: improve parsing of BODY[] items.
* include/mailutils/imap.h (mu_imap_fetch_body) <key>: Rename to section. <fields>: New member. * libproto/imap/fetch.c: Rewrite response item parser. * mu/imap.c: Improve fetch_response_printer
Showing
3 changed files
with
7 additions
and
4 deletions
... | @@ -175,7 +175,8 @@ struct mu_imap_fetch_body | ... | @@ -175,7 +175,8 @@ struct mu_imap_fetch_body |
175 | int type; | 175 | int type; |
176 | size_t *partv; | 176 | size_t *partv; |
177 | size_t partc; | 177 | size_t partc; |
178 | char *key; | 178 | char *section; |
179 | mu_list_t fields; | ||
179 | char *text; | 180 | char *text; |
180 | }; | 181 | }; |
181 | 182 | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -241,17 +241,19 @@ fetch_response_printer (void *item, void *data) | ... | @@ -241,17 +241,19 @@ fetch_response_printer (void *item, void *data) |
241 | switch (resp->type) | 241 | switch (resp->type) |
242 | { | 242 | { |
243 | case MU_IMAP_FETCH_BODY: | 243 | case MU_IMAP_FETCH_BODY: |
244 | mu_stream_printf (str, "BODY [%s]", resp->body.key); | 244 | mu_stream_printf (str, "BODY ["); |
245 | if (resp->body.partv) | 245 | if (resp->body.partv) |
246 | { | 246 | { |
247 | size_t i; | 247 | size_t i; |
248 | 248 | ||
249 | mu_stream_printf (str, ", part: "); | ||
250 | for (i = 0; i < resp->body.partc; i++) | 249 | for (i = 0; i < resp->body.partc; i++) |
251 | mu_stream_printf (str, "%lu.", | 250 | mu_stream_printf (str, "%lu.", |
252 | (unsigned long) resp->body.partv[i]); | 251 | (unsigned long) resp->body.partv[i]); |
253 | } | 252 | } |
254 | mu_stream_printf (str, "\nBEGIN%s\nEND\n", resp->body.text); | 253 | if (resp->body.section) |
254 | mu_stream_printf (str, "%s", resp->body.section); | ||
255 | mu_stream_printf (str, "]"); | ||
256 | mu_stream_printf (str, "\nBEGIN\n%s\nEND\n", resp->body.text); | ||
255 | break; | 257 | break; |
256 | 258 | ||
257 | case MU_IMAP_FETCH_BODYSTRUCTURE: | 259 | case MU_IMAP_FETCH_BODYSTRUCTURE: | ... | ... |
-
Please register or sign in to post a comment