static int doveadm_http_server_istream_read(struct client_connection_http *conn)
{
- while (i_stream_read(conn->cmd_param->value.v_istream) > 0)
- i_stream_skip(conn->cmd_param->value.v_istream, i_stream_get_data_size(conn->cmd_param->value.v_istream));
+ const unsigned char *data;
+ size_t size;
+
+ while (i_stream_read_more(conn->cmd_param->value.v_istream, &data, &size) > 0)
+ i_stream_skip(conn->cmd_param->value.v_istream, size);
if (!conn->cmd_param->value.v_istream->eof)
return 0;
mailbox_transaction_rollback(&trans);
return -1;
}
- while ((ret = i_stream_read(input)) > 0 || ret == -2) {
+ do {
if (mailbox_save_continue(save_ctx) < 0) {
save_failed = TRUE;
ret = -1;
break;
}
- }
+ } while ((ret = i_stream_read(input)) > 0);
i_assert(ret == -1);
if (input->stream_errno != 0) {
static void doveadm_mail_cmd_input_input(struct doveadm_mail_cmd_context *ctx)
{
- while (i_stream_read(ctx->cmd_input) > 0)
- i_stream_skip(ctx->cmd_input, i_stream_get_data_size(ctx->cmd_input));
+ const unsigned char *data;
+ size_t size;
+
+ while (i_stream_read_more(ctx->cmd_input, &data, &size) > 0)
+ i_stream_skip(ctx->cmd_input, size);
if (!ctx->cmd_input->eof)
return;
unsigned char md5_result[MD5_RESULTLEN];
const unsigned char *data;
size_t size;
+ ssize_t sret;
int ret = 0;
hdr_ctx = mailbox_header_lookup_init(mail->box, hashed_headers);
md5_init(&md5_ctx);
memset(&hash_ctx, 0, sizeof(hash_ctx));
- while (!i_stream_is_eof(input)) {
- if (i_stream_read_data(input, &data, &size, 0) == -1)
- break;
- if (size == 0)
- break;
+ while ((sret = i_stream_read_more(input, &data, &size)) > 0) {
message_header_hash_more(&hash_ctx, &hash_method_md5, &md5_ctx,
version, data, size);
i_stream_skip(input, size);
}
+ i_assert(sret == -1);
if (input->stream_errno != 0)
ret = -1;
i_stream_unref(&input);
/* add this input stream to chain */
i_stream_chain_append(ctx->catchain, mpresult.input);
/* save by reading the chain stream */
- while (!i_stream_is_eof(mpresult.input)) {
+ do {
ret = i_stream_read(mpresult.input);
i_assert(ret != 0); /* we can handle only blocking input here */
- if (mailbox_save_continue(ctx->save_ctx) < 0 || ret == -1)
- break;
- }
+ } while (mailbox_save_continue(ctx->save_ctx) == 0 && ret != -1);
if (mpresult.input->stream_errno != 0) {
errno = mpresult.input->stream_errno;
stream->pos = stream->skip;
} else {
/* read and cache forward */
+ ssize_t ret;
+
do {
size_t avail = stream->pos - stream->skip;
}
i_stream_skip(&stream->istream, avail);
- } while (i_stream_read(&stream->istream) >= 0);
+ } while ((ret = i_stream_read(&stream->istream)) > 0);
+ i_assert(ret == -1);
if (stream->istream.v_offset != v_offset) {
/* some failure, we've broken it */
if (zstream->stream_size == (uoff_t)-1) {
uoff_t old_offset = stream->istream.v_offset;
+ ssize_t ret;
do {
size = i_stream_get_data_size(&stream->istream);
i_stream_skip(&stream->istream, size);
- } while (i_stream_read(&stream->istream) > 0);
+ } while ((ret = i_stream_read(&stream->istream)) > 0);
+ i_assert(ret == -1);
i_stream_seek(&stream->istream, old_offset);
if (zstream->stream_size == (uoff_t)-1)
stream->pos = stream->skip;
} else {
/* read and cache forward */
+ ssize_t ret;
+
do {
size_t avail = stream->pos - stream->skip;
}
i_stream_skip(&stream->istream, avail);
- } while (i_stream_read(&stream->istream) >= 0);
+ } while ((ret = i_stream_read(&stream->istream)) > 0);
+ i_assert(ret == -1);
if (stream->istream.v_offset != v_offset) {
/* some failure, we've broken it */
if (zstream->stream_size == (uoff_t)-1) {
uoff_t old_offset = stream->istream.v_offset;
+ ssize_t ret;
do {
size = i_stream_get_data_size(&stream->istream);
i_stream_skip(&stream->istream, size);
- } while (i_stream_read(&stream->istream) > 0);
+ } while ((ret = i_stream_read(&stream->istream)) > 0);
+ i_assert(ret == -1);
i_stream_seek(&stream->istream, old_offset);
if (zstream->stream_size == (uoff_t)-1)
stream->pos = stream->skip;
} else {
/* read and cache forward */
+ ssize_t ret;
+
do {
size_t avail = stream->pos - stream->skip;
}
i_stream_skip(&stream->istream, avail);
- } while (i_stream_read(&stream->istream) >= 0);
+ } while ((ret = i_stream_read(&stream->istream)) > 0);
+ i_assert(ret == -1);
if (stream->istream.v_offset != v_offset) {
/* some failure, we've broken it */
if (zstream->stream_size == (uoff_t)-1) {
uoff_t old_offset = stream->istream.v_offset;
+ ssize_t ret;
do {
size = i_stream_get_data_size(&stream->istream);
i_stream_skip(&stream->istream, size);
- } while (i_stream_read(&stream->istream) > 0);
+ } while ((ret = i_stream_read(&stream->istream)) > 0);
+ i_assert(ret == -1);
i_stream_seek(&stream->istream, old_offset);
if (zstream->stream_size == (uoff_t)-1)
stream->pos = stream->skip;
} else {
/* read and cache forward */
+ ssize_t ret;
+
do {
size_t avail = stream->pos - stream->skip;
}
i_stream_skip(&stream->istream, avail);
- } while (i_stream_read(&stream->istream) >= 0);
+ } while ((ret = i_stream_read(&stream->istream)) > 0);
+ i_assert(ret == -1);
if (stream->istream.v_offset != v_offset) {
/* some failure, we've broken it */
if (zstream->stream_size == (uoff_t)-1) {
uoff_t old_offset = stream->istream.v_offset;
+ ssize_t ret;
do {
size = i_stream_get_data_size(&stream->istream);
i_stream_skip(&stream->istream, size);
- } while (i_stream_read(&stream->istream) > 0);
+ } while ((ret = i_stream_read(&stream->istream)) > 0);
+ i_assert(ret == -1);
i_stream_seek(&stream->istream, old_offset);
if (zstream->stream_size == (uoff_t)-1)
file = fs_file_init(dict->fs, fs_dict_get_full_key(dict, key),
FS_OPEN_MODE_READONLY);
input = fs_read_stream(file, IO_BLOCK_SIZE);
- i_stream_read(input);
+ (void)i_stream_read(input);
str = str_new(pool, i_stream_get_data_size(input)+1);
while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) {
if (conn->ssl_iostream != NULL &&
!ssl_iostream_is_handshaked(conn->ssl_iostream)) {
/* finish SSL negotiation by reading from input stream */
- while ((ret=i_stream_read(conn->conn.input)) > 0) {
+ while ((ret=i_stream_read(conn->conn.input)) > 0 || ret == -2) {
if (ssl_iostream_is_handshaked(conn->ssl_iostream))
break;
}
o_stream_cork(output);
hash_format_reset(astream->set.hash_format);
- while ((ret = i_stream_read(base64_input)) > 0) {
- data = i_stream_get_data(base64_input, &size);
+ while ((ret = i_stream_read_more(base64_input, &data, &size)) > 0) {
buffer_set_used_size(buf, 0);
if (base64_decode(data, size, &size, buf) < 0) {
i_error("istream-attachment: BUG: "
do {
ret = i_stream_read(attach->input);
- if (ret > 0) {
+ if (ret > 0 || ret == -2) {
data = i_stream_get_data(attach->input, &size);
o_stream_nsend(ctx->data.output, data, size);
i_stream_skip(attach->input, size);
return mbox_save_body(ctx);
}
- while ((ret = i_stream_read(ctx->input)) > 0) {
- data = i_stream_get_data(ctx->input, &size);
+ while ((ret = i_stream_read_more(ctx->input, &data, &size)) > 0) {
for (i = 0; i < size; i++) {
if (data[i] == '\n' &&
((i == 0 && ctx->last_char == '\n') ||
if (mailbox_save_begin(_ctx, input) < 0)
return -1;
+ ssize_t ret;
do {
if (mailbox_save_continue(ctx) < 0)
break;
- } while (i_stream_read(input) != -1);
+ ret = i_stream_read(input);
+ i_assert(ret != 0);
+ } while (ret != -1);
if (input->stream_errno != 0) {
mail_storage_set_critical(ctx->transaction->box->storage,
if (size >= stream->pos)
break;
- if (i_stream_read(sstream->fd_input) <= 0) {
+ ssize_t ret;
+ if ((ret = i_stream_read(sstream->fd_input)) <= 0) {
+ i_assert(ret != 0);
i_error("istream-seekable: Couldn't read back "
- "in-memory input %s",
- i_stream_get_name(&stream->istream));
+ "in-memory input %s: %s",
+ i_stream_get_name(&stream->istream),
+ ret == -2 ? "buffer full" :
+ i_stream_get_error(sstream->fd_input));
i_stream_destroy(&sstream->fd_input);
return -1;
}