From 66dc424c9c809c775e1491299bb2a8c97715865f Mon Sep 17 00:00:00 2001 From: Matthew Loper Date: Wed, 9 Feb 2000 00:48:28 +0000 Subject: + * tests/test-formatter.c (convert_to_html_and_print): Use the + buffer length of the stream to create strings which are then + printed, rather than printing the stream (which might not have a + trailing \0) directly. + + * camel/camel-formatter.c (str_tolower): New function; makes a + string lowercase. svn path=/trunk/; revision=1698 --- tests/test-formatter.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'tests/test-formatter.c') diff --git a/tests/test-formatter.c b/tests/test-formatter.c index b3e0ca76a6..536d3e9bbf 100644 --- a/tests/test-formatter.c +++ b/tests/test-formatter.c @@ -14,16 +14,29 @@ static void convert_to_html_and_print (CamelMimeMessage *msg) { CamelFormatter* cmf = camel_formatter_new(); + gchar* header_str; + gchar* body_str; + CamelStream* header_stream = camel_stream_mem_new (CAMEL_STREAM_FS_WRITE); CamelStream* body_stream = camel_stream_mem_new (CAMEL_STREAM_FS_WRITE); camel_formatter_mime_message_to_html ( cmf, msg, header_stream, body_stream); + + header_str = g_strndup ( + CAMEL_STREAM_MEM (header_stream)->buffer->data, + CAMEL_STREAM_MEM (header_stream)->buffer->len); + body_str = g_strndup ( + CAMEL_STREAM_MEM (body_stream)->buffer->data, + CAMEL_STREAM_MEM (body_stream)->buffer->len); g_print ("Header follows\n----------------------\n%s\n", - (CAMEL_STREAM_MEM(header_stream))->buffer->data); + header_str); g_print ("Body follows\n----------------------\n%s\n", - (CAMEL_STREAM_MEM(body_stream))->buffer->data); + body_str); + + g_free (header_str); + g_free (body_str); } static void @@ -63,12 +76,14 @@ main (int argc, char**argv) printf ("You must create the file mail.test before running this test"); exit(2); } - - camel_data_wrapper_construct_from_stream ( CAMEL_DATA_WRAPPER (message), input_stream); + + camel_data_wrapper_construct_from_stream ( + CAMEL_DATA_WRAPPER (message), input_stream); camel_debug_level = CAMEL_LOG_LEVEL_FULL_DEBUG; convert_to_html_and_print (message); + camel_stream_close (input_stream); gtk_object_unref (GTK_OBJECT (input_stream)); -- cgit v1.2.3