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
int type;
size_t *partv;
size_t partc;
char *key;
char *section;
mu_list_t fields;
char *text;
};
......
......@@ -241,17 +241,19 @@ fetch_response_printer (void *item, void *data)
switch (resp->type)
{
case MU_IMAP_FETCH_BODY:
mu_stream_printf (str, "BODY [%s]", resp->body.key);
mu_stream_printf (str, "BODY [");
if (resp->body.partv)
{
size_t i;
mu_stream_printf (str, ", part: ");
for (i = 0; i < resp->body.partc; i++)
mu_stream_printf (str, "%lu.",
(unsigned long) resp->body.partv[i]);
}
mu_stream_printf (str, "\nBEGIN%s\nEND\n", resp->body.text);
if (resp->body.section)
mu_stream_printf (str, "%s", resp->body.section);
mu_stream_printf (str, "]");
mu_stream_printf (str, "\nBEGIN\n%s\nEND\n", resp->body.text);
break;
case MU_IMAP_FETCH_BODYSTRUCTURE:
......