Commit 98ca43a0 98ca43a049365269e4052170eba3103a8d35e20b by Sergey Poznyakoff

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
1 parent 827a4ba2
...@@ -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
......
...@@ -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:
......