gchar * enclosure_to_string (enclosurePtr enclosure) { return enclosure_values_to_string (enclosure->url, enclosure->mime, enclosure->size, enclosure->downloaded); }
/* Note: this function is called for both item and feed context */ static gchar * atom10_parse_link (xmlNodePtr cur, feedParserCtxtPtr ctxt, struct atom10ParserState *state) { gchar *href, *alternate = NULL; href = xml_get_ns_attribute (cur, "href", NULL); if (href) { xmlChar *baseURL = xmlNodeGetBase (cur->doc, cur); gchar *url, *relation, *type, *escTitle = NULL, *title; const gchar *feedURL = subscription_get_homepage (ctxt->subscription); if (!baseURL && feedURL && feedURL[0] != '|' && strstr (feedURL, "://")) baseURL = xmlStrdup (BAD_CAST (feedURL)); url = (gchar *)common_build_url (href, (gchar *)baseURL); type = xml_get_ns_attribute (cur, "type", NULL); relation = xml_get_ns_attribute (cur, "rel", NULL); title = xml_get_ns_attribute (cur, "title", NULL); if (title) escTitle = g_markup_escape_text (title, -1); if (!xmlHasNsProp (cur, BAD_CAST"rel", NULL) || !relation || g_str_equal (relation, BAD_CAST"alternate")) alternate = g_strdup (url); else if (g_str_equal (relation, "replies")) { if (!type || g_str_equal (type, BAD_CAST"application/atom+xml")) { gchar *commentUri = (gchar *)common_build_url ((gchar *)url, subscription_get_homepage (ctxt->subscription)); if (ctxt->item) metadata_list_set (&ctxt->item->metadata, "commentFeedUri", commentUri); g_free (commentUri); } } else if (g_str_equal (relation, "enclosure")) { if (ctxt->item) { gsize length = 0; gchar *lengthStr = xml_get_ns_attribute (cur, "length", NULL); if (lengthStr) length = atol (lengthStr); g_free (lengthStr); gchar *encStr = enclosure_values_to_string (url, type, length, FALSE /* not yet downloaded */); ctxt->item->metadata = metadata_list_append (ctxt->item->metadata, "enclosure", encStr); ctxt->item->hasEnclosure = TRUE; g_free (encStr); } } else if (g_str_equal (relation, "related") || g_str_equal (relation, "via")) { if (ctxt->item) ctxt->item->metadata = metadata_list_append (ctxt->item->metadata, relation, url); } else { /* g_warning ("Unhandled Atom link with unexpected relation \"%s\"\n", relation); */ } xmlFree (title); xmlFree (baseURL); g_free (escTitle); g_free (url); g_free(relation); g_free(type); g_free(href); } else { /* FIXME: @href is required, this document is not valid Atom */; } return alternate; }