aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBertrand Guiheneuf <bertrand@src.gnome.org>1999-06-14 20:50:58 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-06-14 20:50:58 +0800
commit8050e311c1eb5e79da7bc1e4000e893cf2629991 (patch)
treea93bed4555693baddb4eda08ac1176962bab3519
parenta29ed28dd0a4f1e310a93df7d3f90351f727f02d (diff)
downloadgsoc2013-evolution-8050e311c1eb5e79da7bc1e4000e893cf2629991.tar
gsoc2013-evolution-8050e311c1eb5e79da7bc1e4000e893cf2629991.tar.gz
gsoc2013-evolution-8050e311c1eb5e79da7bc1e4000e893cf2629991.tar.bz2
gsoc2013-evolution-8050e311c1eb5e79da7bc1e4000e893cf2629991.tar.lz
gsoc2013-evolution-8050e311c1eb5e79da7bc1e4000e893cf2629991.tar.xz
gsoc2013-evolution-8050e311c1eb5e79da7bc1e4000e893cf2629991.tar.zst
gsoc2013-evolution-8050e311c1eb5e79da7bc1e4000e893cf2629991.zip
tmp sync. Does ot even compile
svn path=/trunk/; revision=978
-rw-r--r--camel/camel-data-wrapper.h12
-rw-r--r--camel/gmime-utils.c40
-rw-r--r--camel/gmime-utils.h7
3 files changed, 35 insertions, 24 deletions
diff --git a/camel/camel-data-wrapper.h b/camel/camel-data-wrapper.h
index 7dc4be2cea..61a37d8444 100644
--- a/camel/camel-data-wrapper.h
+++ b/camel/camel-data-wrapper.h
@@ -57,9 +57,7 @@ typedef struct {
GtkObjectClass parent_class;
/* Virtual methods */
- void (*write_to_buffer) (CamelDataWrapper *data_wrapper, gchar *buffer);
- void (*write_to_file) (CamelDataWrapper *data_wrapper, FILE *file);
- void (*construct_from_buffer) (CamelDataWrapper *data_wrapper, gchar *buffer, guint size);
+ void (*write_to_stream) (CamelDataWrapper *data_wrapper, CamelStream stream);
void (*construct_from_file) (CamelDataWrapper *data_wrapper, FILE *file, guint size);
} CamelDataWrapperClass;
@@ -71,10 +69,10 @@ GtkType camel_data_wrapper_get_type (void);
/* public methods */
-void camel_data_wrapper_write_to_buffer(CamelDataWrapper *data_wrapper, gchar *buffer);
-void camel_data_wrapper_write_to_file(CamelDataWrapper *data_wrapper, FILE *file);
-void camel_data_wrapper_construct_from_buffer(CamelDataWrapper *data_wrapper, gchar *buffer, guint size);
-void camel_data_wrapper_construct_from_file (CamelDataWrapper *data_wrapper, FILE *file, guint size);
+void camel_data_wrapper_write_to_buffer (CamelDataWrapper *data_wrapper, gchar *buffer);
+void camel_data_wrapper_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
+void camel_data_wrapper_construct_from_buffer (CamelDataWrapper *data_wrapper, gchar *buffer, guint size);
+void camel_data_wrapper_construct_from_file (CamelDataWrapper *data_wrapper, CamelStream *stream, guint size);
#ifdef __cplusplus
}
diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c
index 591706adc6..ce605ade05 100644
--- a/camel/gmime-utils.c
+++ b/camel/gmime-utils.c
@@ -26,40 +26,52 @@
#include "gmime-utils.h"
#include "gstring-util.h"
#include "camel-log.h"
+#include "camel-stream.h"
void
-gmime_write_header_pair_to_file (FILE* file, gchar* name, GString *value)
+gmime_write_header_pair_to_stream (CamelStream *stream, gchar* name, GString *value)
{
g_assert(name);
+ g_assert(value);
+ g_assert(value->str);
- if ((value) && (value->str))
- fprintf(file, "%s: %s\n", name, value->str);
+ GString *strtmp;
+ guint len;
+
+ len = strlen (name) + strlen (value->str) +3;
+ /* 3 is for ": " and "\n" */
+ strtmp = g_string_sized_new (len);
+
+ sprintf(strtmp->str, "%s: %s\n", name, value->str);
+ camel_stream_write (stream, strtmp->str, len);
+
+ g_string_free (strtmp, FALSE);
}
static void
-_write_one_header_to_file (gpointer key, gpointer value, gpointer user_data)
+_write_one_header_to_stream (gpointer key, gpointer value, gpointer user_data)
{
GString *header_name = (GString *)key;
GString *header_value = (GString *)value;
- FILE *file = (FILE *)user_data;
+ CamelStream *stream = (CamelStream *)user_data;
if ( (header_name) && (header_name->str) &&
(header_value) && (header_value->str) )
- fprintf(file, "%s: %s\n", header_name->str, header_value->str);
+ gmime_write_header_pair_to_stream (stream, header_name->str, header_value);
}
void
-write_header_table_to_file (FILE *file, GHashTable *header_table)
+write_header_table_to_stream (CamelStream *stream, GHashTable *header_table)
{
g_hash_table_foreach (header_table,
- _write_one_header_to_file,
- (gpointer)file);
+ _write_one_header_to_stream,
+ (gpointer)stream);
}
void
-write_header_with_glist_to_file (FILE *file, gchar *header_name, GList *header_values)
+write_header_with_glist_to_stream (CamelStream *stream, gchar *header_name, GList *header_values)
{
GString *current;
@@ -69,17 +81,19 @@ write_header_with_glist_to_file (FILE *file, gchar *header_name, GList *header_v
gboolean first;
fprintf(file, "%s: ", header_name);
+ camel_stream_write (stream, header_name, strlen (header_name) );
+ camel_stream_write (stream, ": ", 2);
first = TRUE;
while (header_values) {
current = (GString *)header_values->data;
if ( (current) && (current->str) ) {
- if (!first) fprintf(file, ", ");
+ if (!first) camel_stream_write (stream, ", ", 2);
else first = FALSE;
- fprintf(file, "%s", current->str);
+ camel_stream_write (stream, current->str, strlen (current->str));
}
header_values = g_list_next(header_values);
}
- fprintf(file, "\n");
+ camel_stream_write (stream, "\n", 1);
}
}
diff --git a/camel/gmime-utils.h b/camel/gmime-utils.h
index 428bb8afee..6ed47b816c 100644
--- a/camel/gmime-utils.h
+++ b/camel/gmime-utils.h
@@ -35,11 +35,10 @@ extern "C" {
#include <stdio.h>
#include <camel-stream.h>
-void gmime_write_header_pair_to_file (FILE* file, gchar* name, GString *value);
-void write_header_table_to_file (FILE *file, GHashTable *header_table);
-void write_header_with_glist_to_file (FILE *file, gchar *header_name, GList *header_values);
+void gmime_write_header_pair_to_stream (CamelStream *stream, gchar* name, GString *value);
+void write_header_table_to_stream (CamelStream *stream, GHashTable *header_table);
+void write_header_with_glist_to_stream (CamelStream *stream, gchar *header_name, GList *header_values);
-GHashTable *get_header_table_from_file (FILE *file);
GHashTable *get_header_table_from_stream (CamelStream *stream);