IdolPlParserResult idol_pl_parser_add_opml (IdolPlParser *parser, GFile *file, GFile *base_file, IdolPlParseData *parse_data, gpointer data) { #ifndef HAVE_GMIME WARN_NO_GMIME; #else xml_node_t* doc; char *contents, *uri; gsize size; if (g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) == FALSE) return IDOL_PL_PARSER_RESULT_ERROR; doc = idol_pl_parser_parse_xml_relaxed (contents, size); if (doc == NULL) { g_free (contents); return IDOL_PL_PARSER_RESULT_ERROR; } /* If the document has no name */ if (doc->name == NULL || g_ascii_strcasecmp (doc->name , "opml") != 0) { g_free (contents); xml_parser_free_tree (doc); return IDOL_PL_PARSER_RESULT_ERROR; } uri = g_file_get_uri (file); parse_opml_head_body (parser, uri, doc); g_free (uri); g_free (contents); xml_parser_free_tree (doc); return IDOL_PL_PARSER_RESULT_SUCCESS; #endif /* !HAVE_GMIME */ }
TotemPlParserResult totem_pl_parser_add_opml (TotemPlParser *parser, GFile *file, GFile *base_file, TotemPlParseData *parse_data, gpointer data) { xml_node_t* doc; char *contents, *uri; gsize size; if (g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) == FALSE) return TOTEM_PL_PARSER_RESULT_ERROR; doc = totem_pl_parser_parse_xml_relaxed (contents, size); if (doc == NULL) { g_free (contents); return TOTEM_PL_PARSER_RESULT_ERROR; } /* If the document has no name */ if (doc->name == NULL || g_ascii_strcasecmp (doc->name , "opml") != 0) { g_free (contents); xml_parser_free_tree (doc); return TOTEM_PL_PARSER_RESULT_ERROR; } uri = g_file_get_uri (file); parse_opml_head_body (parser, uri, doc); g_free (uri); g_free (contents); xml_parser_free_tree (doc); return TOTEM_PL_PARSER_RESULT_SUCCESS; }