static int imapc_mail_get_headers(struct mail *_mail, const char *field, bool decode_to_utf8, const char *const **value_r) { struct mailbox_header_lookup_ctx *headers; const char *header_names[2]; struct istream *input; int ret; header_names[0] = field; header_names[1] = NULL; headers = mailbox_header_lookup_init(_mail->box, header_names); ret = mail_get_header_stream(_mail, headers, &input); mailbox_header_lookup_unref(&headers); if (ret < 0) return -1; /* the header should cached now. */ return index_mail_get_headers(_mail, field, decode_to_utf8, value_r); }
static int imapc_mail_get_headers(struct mail *_mail, const char *field, bool decode_to_utf8, const char *const **value_r) { struct mailbox_header_lookup_ctx *headers; const char *header_names[2]; const unsigned char *data; size_t size; struct istream *input; int ret; header_names[0] = field; header_names[1] = NULL; headers = mailbox_header_lookup_init(_mail->box, header_names); ret = mail_get_header_stream(_mail, headers, &input); mailbox_header_lookup_unref(&headers); if (ret < 0) return -1; while (i_stream_read_data(input, &data, &size, 0) > 0) i_stream_skip(input, size); /* the header should cached now. */ return index_mail_get_headers(_mail, field, decode_to_utf8, value_r); }