aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
Diffstat (limited to 'camel')
-rw-r--r--camel/camel-stream-fs.c16
-rw-r--r--camel/camel-stream-fs.h42
-rw-r--r--camel/gmime-utils.c5
3 files changed, 43 insertions, 20 deletions
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index e816f88b6b..4571687ca7 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -43,7 +43,7 @@ static CamelSeekableStreamClass *parent_class=NULL;
static gint _read (CamelStream *stream, gchar *buffer, gint n);
static gint _write (CamelStream *stream, const gchar *buffer, gint n);
static void _flush (CamelStream *stream);
-static gint _available (CamelStream *stream);
+static gboolean _available (CamelStream *stream);
static gboolean _eos (CamelStream *stream);
static void _close (CamelStream *stream);
static gint _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
@@ -93,6 +93,7 @@ camel_stream_fs_init (gpointer object, gpointer klass)
CamelStreamFs *stream = CAMEL_STREAM_FS (object);
stream->name = NULL;
+ stream->eof = FALSE;
}
@@ -357,6 +358,9 @@ _read (CamelStream *stream, gchar *buffer, gint n)
else
CAMEL_SEEKABLE_STREAM (stream)->cur_pos += v;
+ if (v == 0)
+ stream_fs->eof = TRUE;
+
return v;
}
@@ -430,11 +434,11 @@ _flush (CamelStream *stream)
*
* Return value: the number of bytes available
**/
-static gint
+static gboolean
_available (CamelStream *stream)
{
g_warning ("Not implemented yet");
- return -1;
+ return FALSE;
}
@@ -449,8 +453,10 @@ _available (CamelStream *stream)
static gboolean
_eos (CamelStream *stream)
{
- g_warning ("Not implemented yet");
- return FALSE;
+ CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream);
+
+ g_assert (stream_fs);
+ return stream_fs->eof;
}
diff --git a/camel/camel-stream-fs.h b/camel/camel-stream-fs.h
index 2e7dfd946f..79c7874c74 100644
--- a/camel/camel-stream-fs.h
+++ b/camel/camel-stream-fs.h
@@ -47,6 +47,7 @@ typedef enum
{
CAMEL_STREAM_FS_READ = 1,
CAMEL_STREAM_FS_WRITE = 2
+
} CamelStreamFsMode;
@@ -55,8 +56,9 @@ typedef struct
CamelSeekableStream parent_object;
- gchar *name; /* name of the underlying file */
- gint fd; /* file descriptor on the underlying file */
+ gchar *name; /* name of the underlying file */
+ gboolean eof; /* are we at the end of the file ? */
+ gint fd; /* file descriptor on the underlying file */
guint32 inf_bound; /* first valid position */
gint32 sup_bound; /* last valid position, -1 means, no sup bound */
@@ -68,11 +70,20 @@ typedef struct {
CamelSeekableStreamClass parent_class;
/* Virtual methods */
- void (*init_with_fd) (CamelStreamFs *stream_fs, int fd);
- void (*init_with_fd_and_bounds) (CamelStreamFs *stream_fs, int fd, guint32 inf_bound, gint32 sup_bound);
- void (*init_with_name) (CamelStreamFs *stream_fs, const gchar *name, CamelStreamFsMode mode);
- void (*init_with_name_and_bounds) (CamelStreamFs *stream_fs, const gchar *name,
- CamelStreamFsMode mode, guint32 inf_bound, gint32 sup_bound);
+ void (*init_with_fd) (CamelStreamFs *stream_fs,
+ int fd);
+ void (*init_with_fd_and_bounds) (CamelStreamFs *stream_fs,
+ int fd, guint32 inf_bound,
+ gint32 sup_bound);
+
+ void (*init_with_name) (CamelStreamFs *stream_fs,
+ const gchar *name,
+ CamelStreamFsMode mode);
+ void (*init_with_name_and_bounds) (CamelStreamFs *stream_fs,
+ const gchar *name,
+ CamelStreamFsMode mode,
+ guint32 inf_bound,
+ gint32 sup_bound);
} CamelStreamFsClass;
@@ -83,12 +94,17 @@ GtkType camel_stream_fs_get_type (void);
/* public methods */
-CamelStream *camel_stream_fs_new_with_name (const gchar *name, CamelStreamFsMode mode);
-CamelStream *camel_stream_fs_new_with_name_and_bounds (const gchar *name, CamelStreamFsMode mode,
- guint32 inf_bound, gint32 sup_bound);
-CamelStream *camel_stream_fs_new_with_fd (int fd);
-CamelStream *camel_stream_fs_new_with_fd_and_bounds (int fd,
- guint32 inf_bound, gint32 sup_bound);
+CamelStream * camel_stream_fs_new_with_name (const gchar *name,
+ CamelStreamFsMode mode);
+CamelStream * camel_stream_fs_new_with_name_and_bounds (const gchar *name,
+ CamelStreamFsMode mode,
+ guint32 inf_bound,
+ gint32 sup_bound);
+
+CamelStream * camel_stream_fs_new_with_fd (int fd);
+CamelStream * camel_stream_fs_new_with_fd_and_bounds (int fd,
+ guint32 inf_bound,
+ gint32 sup_bound);
#ifdef __cplusplus
}
diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c
index 1b1f1aa1e1..7ceb0219ec 100644
--- a/camel/gmime-utils.c
+++ b/camel/gmime-utils.c
@@ -221,7 +221,8 @@ get_header_array_from_stream (CamelStream *stream)
}
} else {
- if (nb_char_read <0) {
+ if (camel_stream_eos (stream)) {
+
end_of_file=TRUE;
end_of_header_line = TRUE;
@@ -275,7 +276,7 @@ gmime_read_line_from_stream (CamelStream *stream)
}
} else {
- if (nb_char_read <0)
+ if (camel_stream_eos (stream))
end_of_stream = TRUE;
}