imap-fetch.c revision a77bddd704784189944b731f5ce774bfb4440e0b
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (C) 2002 Timo Sirainen */
2bc963ea051ddacefe0fa5e26280e8ef853fd6c6Timo Sirainenconst char *const *imap_fetch_get_body_fields(const char *fields)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen /* array ends at ")" element */
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen for (field = dest = field_list; *field != NULL; field++) {
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic void fetch_uid(struct imap_fetch_context *ctx, struct mail *mail)
2bc963ea051ddacefe0fa5e26280e8ef853fd6c6Timo Sirainenstatic int fetch_flags(struct imap_fetch_context *ctx, struct mail *mail,
a326f9da3c18a4ccfb28e72f87161eaf3624eaf2Timo Sirainen str_printfa(ctx->str, "FLAGS (%s) ", imap_write_flags(flags));
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic int fetch_internaldate(struct imap_fetch_context *ctx, struct mail *mail)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen str_printfa(ctx->str, "INTERNALDATE \"%s\" ", imap_to_datetime(time));
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic int fetch_rfc822_size(struct imap_fetch_context *ctx, struct mail *mail)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen str_printfa(ctx->str, "RFC822.SIZE %"PRIuUOFF_T" ", size);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic int fetch_body(struct imap_fetch_context *ctx, struct mail *mail)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen body = mail->get_special(mail, MAIL_FETCH_IMAP_BODY);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (o_stream_send_str(ctx->output, "BODY (") < 0)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (o_stream_send_str(ctx->output, " BODY (") < 0)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic int fetch_bodystructure(struct imap_fetch_context *ctx,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen bodystructure = mail->get_special(mail, MAIL_FETCH_IMAP_BODYSTRUCTURE);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (o_stream_send_str(ctx->output, "BODYSTRUCTURE (") < 0)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (o_stream_send_str(ctx->output, " BODYSTRUCTURE (") < 0)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (o_stream_send_str(ctx->output, bodystructure) < 0)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic int fetch_envelope(struct imap_fetch_context *ctx, struct mail *mail)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen envelope = mail->get_special(mail, MAIL_FETCH_IMAP_ENVELOPE);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (o_stream_send_str(ctx->output, "ENVELOPE (") < 0)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen if (o_stream_send_str(ctx->output, " ENVELOPE (") < 0)
f818f91a2e6ee003aaa83323acd74008aa1276d9Timo Sirainen if (o_stream_send_str(ctx->output, envelope) < 0)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic int fetch_send_rfc822(struct imap_fetch_context *ctx, struct mail *mail)
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen const char *str;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen stream = mail->get_stream(mail, &hdr_size, &body_size);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen str = t_strdup_printf(" RFC822 {%"PRIuUOFF_T"}\r\n",
f818f91a2e6ee003aaa83323acd74008aa1276d9Timo Sirainen return message_send(ctx->output, stream, &body_size,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic int fetch_send_rfc822_header(struct imap_fetch_context *ctx,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen const char *str;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen stream = mail->get_stream(mail, &hdr_size, NULL);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen str = t_strdup_printf(" RFC822.HEADER {%"PRIuUOFF_T"}\r\n",
83228b3f9f6ee8c62a61902e0203af9760f7b9b7Timo Sirainen return message_send(ctx->output, stream, &hdr_size,
83228b3f9f6ee8c62a61902e0203af9760f7b9b7Timo Sirainenstatic int fetch_send_rfc822_text(struct imap_fetch_context *ctx,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen const char *str;
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen stream = mail->get_stream(mail, &hdr_size, &body_size);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen str = t_strdup_printf(" RFC822.TEXT {%"PRIuUOFF_T"}\r\n",
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen i_stream_seek(stream, hdr_size.physical_size);
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainen return message_send(ctx->output, stream, &body_size,
5ef28f68edef46f69961b19b7c1dcd8ec5a955e8Timo Sirainenstatic int fetch_mail(struct imap_fetch_context *ctx, struct mail *mail)
f818f91a2e6ee003aaa83323acd74008aa1276d9Timo Sirainen int failed, data_written, seen_updated = FALSE;
return FALSE;
return FALSE;
t_push();
if (data_written) {
t_pop();
return !failed;
int all_found;
arr++;