aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>2000-02-15 06:27:54 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-02-15 06:27:54 +0800
commit6cffd8501c17f06066196a19674d6af225ff6381 (patch)
treecc42e7ef4e55ca8bbcf0e879f8b31b35a28289e9
parentfe058b1be72112298e356343f3a8b35fd60a072b (diff)
downloadgsoc2013-evolution-6cffd8501c17f06066196a19674d6af225ff6381.tar
gsoc2013-evolution-6cffd8501c17f06066196a19674d6af225ff6381.tar.gz
gsoc2013-evolution-6cffd8501c17f06066196a19674d6af225ff6381.tar.bz2
gsoc2013-evolution-6cffd8501c17f06066196a19674d6af225ff6381.tar.lz
gsoc2013-evolution-6cffd8501c17f06066196a19674d6af225ff6381.tar.xz
gsoc2013-evolution-6cffd8501c17f06066196a19674d6af225ff6381.tar.zst
gsoc2013-evolution-6cffd8501c17f06066196a19674d6af225ff6381.zip
use the eos stream method. (gmime_read_line_from_stream): ditto.
2000-02-14 bertrand <Bertrand.Guiheneuf@aful.org> * camel/gmime-utils.c (get_header_array_from_stream): use the eos stream method. (gmime_read_line_from_stream): ditto. * camel/camel-stream-fs.h (struct ): add the eof field cosmetics changes. * camel/camel-stream-fs.c (camel_stream_fs_init): set eof. (_read): set eof on end of file. (_eos): implemented. * camel/gmime-utils.c (get_header_array_from_stream): make a blocking version of the header parser. When the fs stream uses gnome-vfs, this should be changed. (gmime_read_line_from_stream): ditto. svn path=/trunk/; revision=1779
-rw-r--r--ChangeLog11
-rw-r--r--camel/camel-stream-fs.c16
-rw-r--r--camel/camel-stream-fs.h42
-rw-r--r--camel/gmime-utils.c5
4 files changed, 54 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 1e17144e80..e6e61671a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2000-02-14 bertrand <Bertrand.Guiheneuf@aful.org>
+ * camel/gmime-utils.c (get_header_array_from_stream): use the
+ eos stream method.
+ (gmime_read_line_from_stream): ditto.
+
+ * camel/camel-stream-fs.h (struct ): add the eof field
+ cosmetics changes.
+
+ * camel/camel-stream-fs.c (camel_stream_fs_init): set eof.
+ (_read): set eof on end of file.
+ (_eos): implemented.
+
* camel/gmime-utils.c (get_header_array_from_stream):
make a blocking version of the header parser.
When the fs stream uses gnome-vfs, this should
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;
}