/** * gsf_open_pkg_parse_rel_by_id: * @xin: #GsfXMLIn * @id: target id * @dtd: #GsfXMLInNode * @ns: #GsfXMLInNS * * Convenience function to parse a related part. * * Returns: (transfer full): %NULL on success or a #GError on failure. **/ GError * gsf_open_pkg_parse_rel_by_id (GsfXMLIn *xin, char const *id, GsfXMLInNode const *dtd, GsfXMLInNS const *ns) { GError *res = NULL; GsfInput *cur_stream, *part_stream; g_return_val_if_fail (xin != NULL, NULL); cur_stream = gsf_xml_in_get_input (xin); if (NULL == id) return g_error_new (gsf_input_error_id(), gsf_open_pkg_error_id (), _("Missing id for part in '%s'"), gsf_input_name (cur_stream) ); part_stream = gsf_open_pkg_open_rel_by_id (cur_stream, id, &res); if (NULL != part_stream) { GsfXMLInDoc *doc = gsf_xml_in_doc_new (dtd, ns); if (!gsf_xml_in_doc_parse (doc, part_stream, xin->user_state)) res = g_error_new (gsf_input_error_id(), gsf_open_pkg_error_id (), _("Part '%s' in '%s' from '%s' is corrupt!"), id, gsf_input_name (part_stream), gsf_input_name (cur_stream) ); gsf_xml_in_doc_free (doc); g_object_unref (part_stream); } return res; }
/** * gsf_open_pkg_open_rel_by_type: * @opkg: #GsfInput * @type: target type * @err: optionally %NULL * * New in 1.14.9 * * Open one of @opkg's relationships with type=@type. * * Returns: (transfer full): A new GsfInput or %NULL, and sets @err if possible. **/ GsfInput * gsf_open_pkg_open_rel_by_type (GsfInput *opkg, char const *type, GError **err) { GsfOpenPkgRel *rel = gsf_open_pkg_lookup_rel_by_type (opkg, type); if (rel) return gsf_open_pkg_open_rel (opkg, rel, err); if (err) *err = g_error_new (gsf_input_error_id(), gsf_open_pkg_error_id (), _("Unable to find part with type='%s' for '%s'"), type, gsf_input_name (opkg) ); return NULL; }
/** * gsf_open_pkg_open_rel_by_id : * @opkg : #GsfInput * @id : target id * @err : optionally %NULL * * New in 1.14.7 * * Open @opkg's relation @id * * Returns: A new GsfInput or %NULL, and sets @err if possible. **/ GsfInput * gsf_open_pkg_open_rel_by_id (GsfInput *opkg, char const *id, GError **err) { GsfOpenPkgRel *rel = NULL; GsfOpenPkgRels *rels = gsf_open_pkg_get_rels (opkg); if (NULL != rels && NULL != (rel = g_hash_table_lookup (rels->by_id, id))) return gsf_open_pkg_open_rel (opkg, rel, err); if (err) *err = g_error_new (gsf_input_error_id(), gsf_open_pkg_error_id (), _("Unable to find part id='%s' for '%s'"), id, gsf_input_name (opkg) ); return NULL; }