istream-crlf.c revision d4fe93a9c242d745e0cf2e6cc58d5caf265de2a0
/* Copyright (c) 2007-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream-internal.h"
#include "istream-crlf.h"
struct crlf_istream {
struct istream_private istream;
unsigned int pending_cr:1;
unsigned int last_cr:1;
};
{
if (size == 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;
int diff;
if (ret <= 0)
return ret;
/* @UNSAFE */
if (data[0] == '\n') {
} else {
if (cstream->pending_cr) {
/* CR without LF */
return 1;
}
}
if (data[0] != '\r')
}
diff = -1;
if (data[i] == '\r') {
continue;
diff = 0;
break;
}
}
}
if (ret == 0) {
return i_stream_crlf_read_lf(stream);
}
return ret;
}
static const struct stat *
{
}
static struct istream *
{
struct crlf_istream *cstream;
}
{
}
{
}