1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Authors: Jeffrey Stedfast <fejj@ximian.com>
5 * Copyright 2003 Ximian, Inc. (www.ximian.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include <sys/types.h>
31 #include "camel-test.h"
34 #include <camel/camel-multipart.h>
35 #include <camel/camel-mime-message.h>
36 #include <camel/camel-stream-fs.h>
37 #include <camel/camel-stream-mem.h>
42 dump_mime_struct (CamelMimePart *mime_part, int depth)
44 CamelDataWrapper *content;
53 content = camel_medium_get_content_object ((CamelMedium *) mime_part);
55 mime_type = camel_data_wrapper_get_mime_type (content);
56 printf ("Content-Type: %s\n", mime_type);
59 if (CAMEL_IS_MULTIPART (content)) {
62 num = camel_multipart_get_number ((CamelMultipart *) content);
64 mime_part = camel_multipart_get_part ((CamelMultipart *) content, index);
65 dump_mime_struct (mime_part, depth + 1);
68 } else if (CAMEL_IS_MIME_MESSAGE (content)) {
69 dump_mime_struct ((CamelMimePart *) content, depth + 1);
74 int main (int argc, char **argv)
80 camel_test_init (argc, argv);
82 camel_test_start ("Message Test Suite");
84 if (!(dir = opendir ("../data/messages")))
87 while ((dent = readdir (dir)) != NULL) {
88 CamelMimeMessage *message;
93 if (dent->d_name[0] == '.')
96 filename = g_strdup_printf ("../data/messages/%s", dent->d_name);
97 if (stat (filename, &st) == -1 || !S_ISREG (st.st_mode)) {
102 if ((fd = open (filename, O_RDONLY)) == -1) {
107 push ("testing message `%s`", filename);
110 stream = camel_stream_fs_new_with_fd (fd);
111 message = camel_mime_message_new ();
112 camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) message, stream);
113 camel_stream_reset (stream);
115 /*dump_mime_struct ((CamelMimePart *) message, 0);*/
116 test_message_compare (message);
118 camel_object_unref (message);
119 camel_object_unref (stream);