2 * Copyright © 2009 Carl Worth
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see http://www.gnu.org/licenses/ .
17 * Author: Carl Worth <cworth@cworth.org>
25 #include <gmime/gmime.h>
27 #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
30 print_header (const char *name, const char *value)
34 printf ("\t%s", value);
39 main (int argc, char **argv)
43 GMimeMessage *message;
48 const char *sup_entry_headers[] = {
61 fprintf (stderr, "Usage: %s <mail-message>\n",
68 file = fopen (filename, "r");
70 fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));
76 stream = g_mime_stream_file_new (file);
78 parser = g_mime_parser_new_with_stream (stream);
80 message = g_mime_parser_construct_message (parser);
82 value = g_mime_message_get_message_id (message);
83 print_header ("message_id", value);
85 for (i = 0; i < ARRAY_SIZE (sup_entry_headers); i++) {
86 value = g_mime_object_get_header (GMIME_OBJECT (message),
87 sup_entry_headers[i]);
88 print_header (sup_entry_headers[i], value);
91 g_object_unref (message);
92 g_object_unref (parser);
93 g_object_unref (stream);