changeset 3239:904a268921af HEAD

Added seekable variable to struct istream.
author Timo Sirainen <tss@iki.fi>
date Mon, 28 Mar 2005 16:06:43 +0300
parents 889a584bd953
children a6af023db10d
files src/lib-mail/istream-header-filter.c src/lib/istream-data.c src/lib/istream-file.c src/lib/istream-limit.c src/lib/istream-mmap.c src/lib/istream.h
diffstat 6 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-mail/istream-header-filter.c	Sun Mar 27 19:38:38 2005 +0300
+++ b/src/lib-mail/istream-header-filter.c	Mon Mar 28 16:06:43 2005 +0300
@@ -310,5 +310,6 @@
 	mstream->istream.read = _read;
 	mstream->istream.seek = _seek;
 
+	mstream->istream.istream.seekable = input->seekable;
 	return _i_stream_create(&mstream->istream, pool, -1, 0);
 }
--- a/src/lib/istream-data.c	Sun Mar 27 19:38:38 2005 +0300
+++ b/src/lib/istream-data.c	Mon Mar 28 16:06:43 2005 +0300
@@ -50,5 +50,6 @@
 	stream->seek = _seek;
 	stream->get_size = _get_size;
 
+	stream->istream.seekable = TRUE;
 	return _i_stream_create(stream, pool, -1, 0);
 }
--- a/src/lib/istream-file.c	Sun Mar 27 19:38:38 2005 +0300
+++ b/src/lib/istream-file.c	Mon Mar 28 16:06:43 2005 +0300
@@ -160,7 +160,7 @@
 {
 	struct file_istream *fstream = (struct file_istream *) stream;
 
-	if (!fstream->file) {
+	if (!stream->istream.seekable) {
 		if (v_offset < stream->istream.v_offset) {
 			stream->istream.stream_errno = ESPIPE;
 			return;
@@ -203,8 +203,10 @@
 	fstream->istream.get_size = _get_size;
 
 	/* get size of fd if it's a file */
-	if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode))
+	if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
 		fstream->file = TRUE;
+		fstream->istream.istream.seekable = TRUE;
+	}
 
 	return _i_stream_create(&fstream->istream, pool, fd, 0);
 }
--- a/src/lib/istream-limit.c	Sun Mar 27 19:38:38 2005 +0300
+++ b/src/lib/istream-limit.c	Mon Mar 28 16:06:43 2005 +0300
@@ -122,6 +122,7 @@
 	lstream->istream.seek = _seek;
 	lstream->istream.get_size = _get_size;
 
+	lstream->istream.istream.seekable = input->seekable;
 	return _i_stream_create(&lstream->istream, pool, i_stream_get_fd(input),
 				input->real_stream->abs_start_offset +
 				v_start_offset);
--- a/src/lib/istream-mmap.c	Sun Mar 27 19:38:38 2005 +0300
+++ b/src/lib/istream-mmap.c	Mon Mar 28 16:06:43 2005 +0300
@@ -202,5 +202,6 @@
 
 	istream = _i_stream_create(&mstream->istream, pool, fd, start_offset);
 	istream->mmaped = TRUE;
+	istream->seekable = TRUE;
 	return istream;
 }
--- a/src/lib/istream.h	Sun Mar 27 19:38:38 2005 +0300
+++ b/src/lib/istream.h	Mon Mar 28 16:06:43 2005 +0300
@@ -7,6 +7,7 @@
 	int stream_errno;
 	unsigned int mmaped:1; /* be careful when copying data */
 	unsigned int closed:1;
+	unsigned int seekable:1; /* we can seek() backwards */
 	unsigned int eof:1; /* read() has reached to end of file
 	                       (but may still be data available in buffer) */