string_t *name;
buffer_t *value_buf;
- size_t skip;
enum message_header_parser_flags flags;
unsigned int skip_line:1;
{
struct message_header_parser_ctx *ctx = *_ctx;
- i_stream_skip(ctx->input, ctx->skip);
buffer_free(&ctx->value_buf);
str_free(&ctx->name);
i_free(ctx);
{
struct message_header_line *line = &ctx->line;
const unsigned char *msg;
- size_t i, size, startpos, colon_pos, parse_size;
+ size_t i, size, startpos, colon_pos, parse_size, skip = 0;
int ret;
bool continued, continues, last_no_newline, last_crlf;
bool no_newline, crlf_newline;
if (line->eoh)
return -1;
- if (ctx->skip > 0) {
- i_stream_skip(ctx->input, ctx->skip);
- ctx->skip = 0;
- }
-
if (line->continues)
colon_pos = 0;
else {
if (startpos > 0) {
/* header ended unexpectedly. */
no_newline = TRUE;
- ctx->skip = startpos;
+ skip = startpos;
break;
}
/* error / EOF with no bytes */
+ i_assert(skip == 0);
return -1;
}
if (ctx->hdr_size != NULL)
ctx->hdr_size->lines++;
if (msg[0] == '\r') {
- ctx->skip = 2;
+ skip = 2;
crlf_newline = TRUE;
} else {
- ctx->skip = 1;
+ skip = 1;
if (ctx->hdr_size != NULL)
ctx->hdr_size->virtual_size++;
}
}
if (ret == 0 && !ctx->input->eof) {
/* stream is nonblocking - need more data */
+ i_assert(skip == 0);
return 0;
}
i_assert(size > 0);
continues = TRUE;
}
no_newline = TRUE;
- ctx->skip = size;
+ skip = size;
break;
}
crlf_newline = TRUE;
}
- ctx->skip = i+1;
+ skip = i+1;
break;
}
line->use_full_value = FALSE;
if (ctx->hdr_size != NULL) {
- ctx->hdr_size->physical_size += ctx->skip;
- ctx->hdr_size->virtual_size += ctx->skip;
+ ctx->hdr_size->physical_size += skip;
+ ctx->hdr_size->virtual_size += skip;
}
+ i_stream_skip(ctx->input, skip);
*hdr_r = line;
return 1;