}
/* Find message_part for section (eg. 1.3.4) */
-static const struct message_part *
-part_find(struct mail *mail, const struct imap_fetch_body_data *body,
- const char **section)
+static int part_find(struct mail *mail, const struct imap_fetch_body_data *body,
+ const struct message_part **part_r, const char **section)
{
const struct message_part *part;
const char *path;
part = mail->get_parts(mail);
if (part == NULL)
- return NULL;
+ return FALSE;
path = body->section;
while (*path >= '0' && *path <= '9' && part != NULL) {
} else {
/* only 1 allowed with non-multipart messages */
if (num != 1)
- return NULL;
+ part = NULL;
}
if (part != NULL &&
}
}
+ *part_r = part;
*section = path;
- return part;
+ return TRUE;
}
/* fetch BODY[1.2] or BODY[1.2.TEXT] */
const struct message_part *part;
const char *section;
- part = part_find(mail, body, §ion);
- if (part == NULL)
+ if (!part_find(mail, body, &part, §ion))
return FALSE;
+ if (part == NULL) {
+ /* part doesn't exist */
+ return o_stream_send_str(ctx->output, ctx->prefix) > 0 &&
+ o_stream_send_str(ctx->output, " NIL") > 0;
+ }
+
stream = mail->get_stream(mail, NULL, NULL);
if (stream == NULL)
return FALSE;