aboutsummaryrefslogtreecommitdiffstats
path: root/camel/gmime-utils.c
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>2000-02-15 06:03:58 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>2000-02-15 06:03:58 +0800
commitfe058b1be72112298e356343f3a8b35fd60a072b (patch)
tree0e2fe60abb27fa6070dc20f1e427b002c6db6f5a /camel/gmime-utils.c
parentd8efd64ed0bc53ad0a74115c1d14a700b3874013 (diff)
downloadgsoc2013-evolution-fe058b1be72112298e356343f3a8b35fd60a072b.tar.gz
gsoc2013-evolution-fe058b1be72112298e356343f3a8b35fd60a072b.tar.zst
gsoc2013-evolution-fe058b1be72112298e356343f3a8b35fd60a072b.zip
make a blocking version of the header parser. When the fs stream uses
2000-02-14 bertrand <Bertrand.Guiheneuf@aful.org> * 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. 2000-02-11 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-stream-fs.c: everywhere, when using the cur_pos field, do it on the CamelSeekableStream object. (_seek): small fix. * camel/camel-seekable-stream.c (camel_seekable_stream_seek): s/camel_stream_seek/camel_seekable_stream_seek/g * camel/camel-seekable-stream.h: (struct ): added a field to store the current position. * camel/camel-seekable-stream.c (camel_seekable_stream_get_current_position): New function. Allows to get the current position of a seekable stream. In fact much more changes, but I am lazy. This is the begining of some major changes in camel. svn path=/trunk/; revision=1778
Diffstat (limited to 'camel/gmime-utils.c')
-rw-r--r--camel/gmime-utils.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c
index 421808a4d4..1b1f1aa1e1 100644
--- a/camel/gmime-utils.c
+++ b/camel/gmime-utils.c
@@ -160,7 +160,11 @@ _store_header_pair_from_string (GArray *header_array, gchar *header_line)
-
+/*
+ this is a blocking version of the
+ header parsing. Need to change when
+ fs streams are non blocking
+*/
GArray *
get_header_array_from_stream (CamelStream *stream)
{
@@ -177,8 +181,6 @@ get_header_array_from_stream (CamelStream *stream)
gboolean end_of_file = FALSE;
GString *header_line=NULL;
- gchar *str_header_line;
-
GArray *header_array;
@@ -215,23 +217,29 @@ get_header_array_from_stream (CamelStream *stream)
default:
if (!crlf) header_line = g_string_append_c (header_line, next_char);
else end_of_header_line = TRUE;
+
}
} else {
- end_of_file=TRUE;
- end_of_header_line = TRUE;
+
+ if (nb_char_read <0) {
+ end_of_file=TRUE;
+ end_of_header_line = TRUE;
+
+ }
}
+
/* if we have read a whole header line, we have also read
the first character of the next line to be sure the
crlf was not followed by a space or a tab char */
if (!end_of_header_line) nb_char_read = camel_stream_read (stream, &next_char, 1);
-
+
} while ( !end_of_header_line );
if ( strlen(header_line->str) ) {
/* str_header_line = g_strdup (header_line->str); */
_store_header_pair_from_string (header_array, header_line->str);
}
g_string_free (header_line, FALSE);
-
+
} while ( (!end_of_headers) && (!end_of_file) );
CAMEL_LOG_FULL_DEBUG ( "gmime-utils:: Leaving get_header_table_from_stream\n");
@@ -239,6 +247,7 @@ get_header_array_from_stream (CamelStream *stream)
}
+
gchar *
gmime_read_line_from_stream (CamelStream *stream)
{
@@ -252,7 +261,9 @@ gmime_read_line_from_stream (CamelStream *stream)
new_line = g_string_new ("");
do {
nb_char_read = camel_stream_read (stream, &next_char, 1);
+
if (nb_char_read>0) {
+
switch (next_char) {
case '\n':
end_of_line = TRUE;
@@ -260,13 +271,22 @@ gmime_read_line_from_stream (CamelStream *stream)
break;
default:
g_string_append_c (new_line, next_char);
+
}
- } else end_of_stream = TRUE;
+ } else {
+
+ if (nb_char_read <0)
+ end_of_stream = TRUE;
+
+ }
} while (!end_of_line && !end_of_stream);
+
if (!end_of_stream)
result = g_strdup (new_line->str);
else result=NULL;
+
g_string_free (new_line, TRUE);
+
return result;
}