Mercurial > dovecot > core-2.2
changeset 1764:fbb28b07c60f HEAD
Write envelope, body and bodystructure directly into output stream.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 08 Sep 2003 04:46:14 +0300 |
parents | 32bfcbe2a006 |
children | 6c0c2ff2c113 |
files | src/imap/imap-fetch.c |
diffstat | 1 files changed, 54 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-fetch.c Mon Sep 08 04:29:07 2003 +0300 +++ b/src/imap/imap-fetch.c Mon Sep 08 04:46:14 2003 +0300 @@ -88,7 +88,20 @@ if (body == NULL) return FALSE; - str_printfa(ctx->str, "BODY (%s) ", body); + if (ctx->first) { + if (o_stream_send_str(ctx->output, "BODY (") < 0) + return FALSE; + ctx->first = FALSE; + } else { + if (o_stream_send_str(ctx->output, " BODY(") < 0) + return FALSE; + } + + if (o_stream_send_str(ctx->output, body) < 0) + return FALSE; + + if (o_stream_send(ctx->output, ")", 1) < 0) + return FALSE; return TRUE; } @@ -101,7 +114,20 @@ if (bodystructure == NULL) return FALSE; - str_printfa(ctx->str, "BODYSTRUCTURE (%s) ", bodystructure); + if (ctx->first) { + if (o_stream_send_str(ctx->output, "BODYSTRUCTURE (") < 0) + return FALSE; + ctx->first = FALSE; + } else { + if (o_stream_send_str(ctx->output, " BODYSTRUCTURE(") < 0) + return FALSE; + } + + if (o_stream_send_str(ctx->output, bodystructure) < 0) + return FALSE; + + if (o_stream_send(ctx->output, ")", 1) < 0) + return FALSE; return TRUE; } @@ -113,7 +139,20 @@ if (envelope == NULL) return FALSE; - str_printfa(ctx->str, "ENVELOPE (%s) ", envelope); + if (ctx->first) { + if (o_stream_send_str(ctx->output, "ENVELOPE (") < 0) + return FALSE; + ctx->first = FALSE; + } else { + if (o_stream_send_str(ctx->output, " ENVELOPE(") < 0) + return FALSE; + } + + if (o_stream_send_str(ctx->output, envelope) < 0) + return FALSE; + + if (o_stream_send(ctx->output, ")", 1) < 0) + return FALSE; return TRUE; } @@ -233,15 +272,6 @@ if (ctx->fetch_data & MAIL_FETCH_SIZE) if (!fetch_rfc822_size(ctx, mail)) break; - if (ctx->fetch_data & MAIL_FETCH_IMAP_BODY) - if (!fetch_body(ctx, mail)) - break; - if (ctx->fetch_data & MAIL_FETCH_IMAP_BODYSTRUCTURE) - if (!fetch_bodystructure(ctx, mail)) - break; - if (ctx->fetch_data & MAIL_FETCH_IMAP_ENVELOPE) - if(!fetch_envelope(ctx, mail)) - break; /* send the data written into temp string */ len = str_len(ctx->str); @@ -254,6 +284,18 @@ data_written = TRUE; + /* medium size data .. seems to be faster without + putting through string */ + if (ctx->fetch_data & MAIL_FETCH_IMAP_BODY) + if (!fetch_body(ctx, mail)) + break; + if (ctx->fetch_data & MAIL_FETCH_IMAP_BODYSTRUCTURE) + if (!fetch_bodystructure(ctx, mail)) + break; + if (ctx->fetch_data & MAIL_FETCH_IMAP_ENVELOPE) + if(!fetch_envelope(ctx, mail)) + break; + /* large data */ if (ctx->imap_data & IMAP_FETCH_RFC822) if (!fetch_send_rfc822(ctx, mail))