dovecot-2.2: Added i_stream_last_line_crlf()
dovecot at dovecot.org
dovecot at dovecot.org
Sun Aug 12 06:26:47 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/2e88cfd8b595
changeset: 14875:2e88cfd8b595
user: Timo Sirainen <tss at iki.fi>
date: Sun Aug 12 06:26:35 2012 +0300
description:
Added i_stream_last_line_crlf()
diffstat:
src/lib/istream-private.h | 1 +
src/lib/istream.c | 12 ++++++++++--
src/lib/istream.h | 3 +++
3 files changed, 14 insertions(+), 2 deletions(-)
diffs (55 lines):
diff -r 28283c7dc1e9 -r 2e88cfd8b595 src/lib/istream-private.h
--- a/src/lib/istream-private.h Sun Aug 12 05:42:14 2012 +0300
+++ b/src/lib/istream-private.h Sun Aug 12 06:26:35 2012 +0300
@@ -44,6 +44,7 @@
unsigned int access_counter;
string_t *line_str; /* for i_stream_next_line() if w_buffer == NULL */
+ unsigned int line_crlf:1;
unsigned int return_nolf_line:1;
unsigned int stream_size_passthrough:1; /* stream is parent's size */
};
diff -r 28283c7dc1e9 -r 2e88cfd8b595 src/lib/istream.c
--- a/src/lib/istream.c Sun Aug 12 05:42:14 2012 +0300
+++ b/src/lib/istream.c Sun Aug 12 06:26:35 2012 +0300
@@ -315,10 +315,13 @@
char *ret;
size_t end;
- if (i > 0 && stream->buffer[i-1] == '\r')
+ if (i > 0 && stream->buffer[i-1] == '\r') {
end = i - 1;
- else
+ stream->line_crlf = TRUE;
+ } else {
end = i;
+ stream->line_crlf = FALSE;
+ }
if (stream->w_buffer != NULL) {
/* modify the buffer directly */
@@ -386,6 +389,11 @@
return line;
}
+bool i_stream_last_line_crlf(struct istream *stream)
+{
+ return stream->real_stream->line_crlf;
+}
+
const unsigned char *
i_stream_get_data(const struct istream *stream, size_t *size_r)
{
diff -r 28283c7dc1e9 -r 2e88cfd8b595 src/lib/istream.h
--- a/src/lib/istream.h Sun Aug 12 05:42:14 2012 +0300
+++ b/src/lib/istream.h Sun Aug 12 06:26:35 2012 +0300
@@ -121,6 +121,9 @@
/* Like i_stream_next_line(), but reads for more data if needed. Returns NULL
if more data is needed or error occurred. */
char *i_stream_read_next_line(struct istream *stream);
+/* Returns TRUE if the last line read with i_stream_next_line() ended with
+ CRLF (instead of LF). */
+bool i_stream_last_line_crlf(struct istream *stream);
/* Returns pointer to beginning of read data, or NULL if there's no data
buffered. */
More information about the dovecot-cvs
mailing list