#include <stdio.h>

#define HAVE_TIMEZONE 
#include <gmime/gmime.h>

int main (int argc, char *argv[])
{
	GMimeStream *file_stream, *stream;
	GMimeParser *parser;
	GMimeMessage *msg;
	char *pch;
	const char * cpch;
	FILE *fp = fopen (argv[1], "r");

	if (fp == NULL)
		return 1;

	g_mime_init (0);

	file_stream = g_mime_stream_file_new (fp);
	stream = g_mime_stream_buffer_new (file_stream, GMIME_STREAM_BUFFER_BLOCK_READ);
	g_object_unref (file_stream);

	parser = g_mime_parser_new ();
	g_mime_parser_init_with_stream (parser, stream);

	msg = g_mime_parser_construct_message (parser);
	g_object_unref (parser);

	pch = g_mime_message_get_headers (msg);
	printf ("Headers: [%s]\n", pch);
	g_free (pch);

	printf ("-----------------\n");

	cpch = g_mime_message_get_header (msg, "Subject");
	printf ("g_mime_message_get_header: %s\n", cpch);
	g_free (pch);

	cpch = g_mime_message_get_subject (msg);
	printf ("g_mime_message_get_subject: %s\n", cpch);

	return 0;	
}
