/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "ostream-private.h"
#include "ostream-dot.h"
enum dot_ostream_state {
STREAM_STATE_INIT = 0,
};
struct dot_ostream {
bool force_extra_crlf;
};
{
int ret;
return 1;
/* make space for the dot line */
if (ret < 0)
return ret;
}
}
!dstream->force_extra_crlf) {
} else {
}
return 1;
}
static int
{
int ret;
return ret;
}
return o_stream_flush_parent(stream);
}
static void
{
if (close_parent)
}
static ssize_t
{
unsigned int count, i;
/* error / we still couldn't flush existing data to
parent stream. */
return ret;
}
/* check for dots */
p = data;
char add = 0;
/* none */
case STREAM_STATE_NONE:
switch (*p) {
case '\n':
/* add missing CR */
add = '\r';
break;
case '\r':
break;
}
break;
/* got CR */
case STREAM_STATE_CR:
switch (*p) {
case '\r':
break;
case '\n':
break;
default:
break;
}
break;
/* got CRLF, or the first line */
case STREAM_STATE_INIT:
case STREAM_STATE_CRLF:
switch (*p) {
case '\r':
break;
case '\n':
/* add missing CR */
add = '\r';
break;
case '.':
/* add dot */
add = '.';
/* fall through */
default:
break;
}
break;
case STREAM_STATE_DONE:
i_unreached();
}
if (add != 0) {
if (chunk > 0) {
/* forward chunk to new iovec */
data = p;
}
/* insert byte (substitute one with pair) */
data++;
max_bytes -= 2;
added++;
sent++;
}
}
if (max_bytes == 0)
break;
if (chunk > 0) {
}
}
/* send */
if (count == 0) {
ret = 0;
return -1;
}
/* all must be sent */
return sent;
}
struct ostream *
{
/* ostream-dot is always used inside another ostream that shouldn't
get finished when the "." line is written. Disable it here so all
of the callers don't have to set this. */
}