aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-stream-fs.c
diff options
context:
space:
mode:
authorBertrand Guiheneuf <bertrand@src.gnome.org>2000-03-05 13:33:55 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-03-05 13:33:55 +0800
commitf4b7a4632573de34280e904bfb03a410a1fa1dbf (patch)
treeb7b45a3424645a6836587c214dc5dfb2737239ef /camel/camel-stream-fs.c
parent1208f96fe41fa87dfab2ee0a3b67a822380aeb27 (diff)
downloadgsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.tar
gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.tar.gz
gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.tar.bz2
gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.tar.lz
gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.tar.xz
gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.tar.zst
gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.zip
Tons of fixes to fix things
svn path=/trunk/; revision=2057
Diffstat (limited to 'camel/camel-stream-fs.c')
-rw-r--r--camel/camel-stream-fs.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index 46ccfe6e8f..16c5da2ba6 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -169,11 +169,12 @@ _set_bounds (CamelStreamFs *stream_fs, guint32 inf_bound, guint32 sup_bound)
/* go to the first position */
lseek (stream_fs->fd, inf_bound, SEEK_SET);
- CAMEL_SEEKABLE_STREAM (stream_fs)->cur_pos = inf_bound;
+ CAMEL_SEEKABLE_STREAM (stream_fs)->cur_pos = 0;
- CAMEL_LOG_FULL_DEBUG ("In CamelStreamFs::_set_bounds, "
+ CAMEL_LOG_FULL_DEBUG ("In CamelStreamFs::_set_bounds (%p), "
"setting inf bound to %u, "
"sup bound to %ld, current postion to %u from %u\n",
+ stream_fs,
stream_fs->inf_bound, stream_fs->sup_bound,
CAMEL_SEEKABLE_STREAM (stream_fs)->cur_pos, inf_bound);
@@ -344,11 +345,13 @@ static gint
_read (CamelStream *stream, gchar *buffer, gint n)
{
CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
- gint v;
+ gint v = 0;
gint nb_to_read;
+ g_assert (n);
+
if (stream_fs->sup_bound != -1)
- nb_to_read = MIN (stream_fs->sup_bound - CAMEL_SEEKABLE_STREAM (stream)->cur_pos, n);
+ nb_to_read = MIN (stream_fs->sup_bound - CAMEL_SEEKABLE_STREAM (stream)->cur_pos - stream_fs->inf_bound , n);
else
nb_to_read = n;
@@ -496,10 +499,10 @@ _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy)
break;
case CAMEL_STREAM_CUR:
- if ((stream_fs->sup_bound != -1) && ((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + offset) > stream_fs->sup_bound)) {
+ if ((stream_fs->sup_bound != -1) && ((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + stream_fs->inf_bound + offset) > stream_fs->sup_bound)) {
real_offset = stream_fs->sup_bound;
whence = SEEK_SET;
- } else if ((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + offset) < stream_fs->inf_bound) {
+ } else if ((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + stream_fs->inf_bound + offset) < stream_fs->inf_bound) {
real_offset = stream_fs->inf_bound;
whence = SEEK_SET;
} else
@@ -528,10 +531,10 @@ _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy)
printf ("***** Seeking : real_offset=%d, whence=%d\n", real_offset, whence);
return_position = lseek (stream_fs->fd, real_offset, whence) - stream_fs->inf_bound;
- if (CAMEL_SEEKABLE_STREAM (stream)->cur_pos != return_position)
+ if (((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + stream_fs->inf_bound) != return_position) && stream_fs->eof)
stream_fs->eof = FALSE;
- CAMEL_SEEKABLE_STREAM (stream)->cur_pos = return_position;
+ CAMEL_SEEKABLE_STREAM (stream)->cur_pos = return_position - stream_fs->inf_bound;
return return_position;