/** * g_mime_shutdown: * * Frees internally allocated tables created in g_mime_init(). Also * calls g_mime_charset_map_shutdown() and g_mime_iconv_shutdown(). **/ void g_mime_shutdown (void) { if (--initialized) return; g_mime_object_type_registry_shutdown (); g_mime_charset_map_shutdown (); g_mime_iconv_utils_shutdown (); g_mime_iconv_shutdown (); #ifdef G_THREADS_ENABLED if (glib_check_version (2, 37, 4) == NULL) { /* The implementation of g_mutex_clear() prior * to glib 2.37.4 did not properly reset the * internal mutex pointer to NULL, so re-initializing * GMime would not properly re-initialize the mutexes. **/ g_mutex_clear (&G_LOCK_NAME (iconv_cache)); g_mutex_clear (&G_LOCK_NAME (iconv_utils)); g_mutex_clear (&G_LOCK_NAME (charset)); g_mutex_clear (&G_LOCK_NAME (msgid)); } #endif }
int main (int argc, const char* argv[]) { GMimeMessage *message; GMimeParser *parser; GMimeStream *stream; const char *file = argv[1]; int fd; if (argc < 2) { printf("No file name given\n"); return 1; } if (argc == 3) { text_only = 1; file = argv[2]; } g_mime_init(0); g_mime_iconv_init(); if ((fd = open(file, O_RDONLY)) == -1) { printf("Error opening file %s\n", file); return 1; } stream = g_mime_stream_fs_new(fd); parser = g_mime_parser_new_with_stream(stream); g_mime_parser_set_scan_from(parser, FALSE); g_object_unref(stream); message = g_mime_parser_construct_message(parser); g_object_unref(parser); if (message) { write_part(message->mime_part); } else { printf("Error constructing message\n"); return 1; } g_mime_iconv_shutdown(); return 0; }