/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-private.h"
#include "istream-crlf.h"
struct crlf_istream {
};
{
if (size == 0) {
if (ret <= 0) {
return ret;
}
}
return -2;
return 1;
}
{
if (ret <= 0)
return ret;
/* at least one byte was read */
/* @UNSAFE: add missing CRs */
if (*src == '\n') {
*dest++ = '\r';
*dest++ = '\n';
src++;
}
}
/* copy data up to LF */
if (copy_len > 0) {
}
break;
/* add the CR if necessary and copy the LF.
(src >= data+1, because data[0]=='\n' was
handled before this loop) */
*dest++ = '\r';
break;
*dest++ = '\n';
src++;
}
return ret;
}
{
const unsigned char *data, *p;
bool pending_cr;
if (ret <= 0)
return ret;
/* @UNSAFE */
/* \r\n -> \n
\r<anything> -> \r<anything>
\r\r\n -> \r\n */
if (data[i] == '\r') {
if (pending_cr) {
/* \r\r */
} else {
pending_cr = TRUE;
}
i++;
} else if (data[i] == '\n') {
/* [\r]\n */
pending_cr = FALSE;
i++;
} else if (pending_cr) {
/* \r<anything> */
pending_cr = FALSE;
} else {
/* copy everything until the next \r */
if (p != NULL)
i += max;
}
}
if (ret == 0) {
return i_stream_crlf_read_lf(stream);
}
return ret;
}
static struct istream *
{
i_stream_get_fd(input), 0);
}
{
}
{
}