aboutsummaryrefslogtreecommitdiffstats
path: root/camel/gmime-utils.c
diff options
context:
space:
mode:
authorBertrand Guiheneuf <bertrand@src.gnome.org>1999-05-30 22:02:36 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-05-30 22:02:36 +0800
commitd32ba2a70aebd94d176f73a64bc83ed59038e835 (patch)
tree8f0b1cdba89abe63ef364e07694d2606d54d5e11 /camel/gmime-utils.c
parent1d01c8dad13eeab68241617b0ca981a8582b8215 (diff)
downloadgsoc2013-evolution-d32ba2a70aebd94d176f73a64bc83ed59038e835.tar
gsoc2013-evolution-d32ba2a70aebd94d176f73a64bc83ed59038e835.tar.gz
gsoc2013-evolution-d32ba2a70aebd94d176f73a64bc83ed59038e835.tar.bz2
gsoc2013-evolution-d32ba2a70aebd94d176f73a64bc83ed59038e835.tar.lz
gsoc2013-evolution-d32ba2a70aebd94d176f73a64bc83ed59038e835.tar.xz
gsoc2013-evolution-d32ba2a70aebd94d176f73a64bc83ed59038e835.tar.zst
gsoc2013-evolution-d32ba2a70aebd94d176f73a64bc83ed59038e835.zip
sync
svn path=/trunk/; revision=959
Diffstat (limited to 'camel/gmime-utils.c')
-rw-r--r--camel/gmime-utils.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c
index 92d04d5bf8..b2d95e439e 100644
--- a/camel/gmime-utils.c
+++ b/camel/gmime-utils.c
@@ -171,3 +171,60 @@ get_header_table_from_file (FILE *file)
}
+GHashTable *
+get_header_table_from_stream (GnomeStream *stream)
+{
+ int next_char;
+
+ gboolean crlf = FALSE;
+ gboolean end_of_header_line = FALSE;
+ gboolean end_of_headers = FALSE;
+ gboolean end_of_file = FALSE;
+ GString *header_line=NULL;
+ GHashTable *header_table;
+
+ header_table = g_hash_table_new (g_string_hash, g_string_equal_for_hash);
+ //next_char = fgetc (file);
+ do {
+ header_line = g_string_new("");
+ end_of_header_line = FALSE;
+ crlf = FALSE;
+
+ /* read a whole header line */
+ do {
+ switch (next_char) {
+ case EOF:
+ end_of_file=TRUE;
+ end_of_header_line = TRUE;
+ break;
+ case '\n': /* a blank line means end of headers */
+ if (crlf) {
+ end_of_headers=TRUE;
+ end_of_header_line = TRUE;
+ }
+ else crlf = TRUE;
+ break;
+ case ' ':
+ case 't':
+ if (crlf) crlf = FALSE;
+
+ default:
+ if (!crlf) header_line = g_string_append_c (header_line, next_char);
+ else 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) next_char = fgetc (file);
+
+ } while ( !end_of_header_line );
+ if ( strlen(header_line->str) )
+ _store_header_pair_from_gstring (header_table, header_line);
+ g_string_free (header_line, FALSE);
+
+ } while ( (!end_of_headers) && (!end_of_file) );
+
+ return header_table;
+}
+
+