diff options
Diffstat (limited to 'xps/xps_resource.c')
-rw-r--r-- | xps/xps_resource.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/xps/xps_resource.c b/xps/xps_resource.c index c96f3619..4a084b29 100644 --- a/xps/xps_resource.c +++ b/xps/xps_resource.c @@ -2,7 +2,7 @@ #include "muxps.h" static xml_element * -xps_find_resource(xps_context *ctx, xps_resource *dict, char *name, char **urip) +xps_find_resource(xps_document *doc, xps_resource *dict, char *name, char **urip) { xps_resource *head, *node; for (head = dict; head; head = head->parent) @@ -21,7 +21,7 @@ xps_find_resource(xps_context *ctx, xps_resource *dict, char *name, char **urip) } static xml_element * -xps_parse_resource_reference(xps_context *ctx, xps_resource *dict, char *att, char **urip) +xps_parse_resource_reference(xps_document *doc, xps_resource *dict, char *att, char **urip) { char name[1024]; char *s; @@ -34,16 +34,16 @@ xps_parse_resource_reference(xps_context *ctx, xps_resource *dict, char *att, ch if (s) *s = 0; - return xps_find_resource(ctx, dict, name, urip); + return xps_find_resource(doc, dict, name, urip); } void -xps_resolve_resource_reference(xps_context *ctx, xps_resource *dict, +xps_resolve_resource_reference(xps_document *doc, xps_resource *dict, char **attp, xml_element **tagp, char **urip) { if (*attp) { - xml_element *rsrc = xps_parse_resource_reference(ctx, dict, *attp, urip); + xml_element *rsrc = xps_parse_resource_reference(doc, dict, *attp, urip); if (rsrc) { *attp = NULL; @@ -53,7 +53,7 @@ xps_resolve_resource_reference(xps_context *ctx, xps_resource *dict, } static int -xps_parse_remote_resource_dictionary(xps_context *ctx, xps_resource **dictp, char *base_uri, char *source_att) +xps_parse_remote_resource_dictionary(xps_document *doc, xps_resource **dictp, char *base_uri, char *source_att) { char part_name[1024]; char part_uri[1024]; @@ -65,24 +65,24 @@ xps_parse_remote_resource_dictionary(xps_context *ctx, xps_resource **dictp, cha /* External resource dictionaries MUST NOT reference other resource dictionaries */ xps_absolute_path(part_name, base_uri, source_att, sizeof part_name); - part = xps_read_part(ctx, part_name); + part = xps_read_part(doc, part_name); if (!part) { - return fz_throw("cannot find remote resource part '%s'", part_name); + return fz_error_make("cannot find remote resource part '%s'", part_name); } - xml = xml_parse_document(part->data, part->size); + xml = xml_parse_document(doc->ctx, part->data, part->size); if (!xml) { - xps_free_part(ctx, part); - return fz_rethrow(-1, "cannot parse xml"); + xps_free_part(doc, part); + return fz_error_note(-1, "cannot parse xml"); } if (strcmp(xml_tag(xml), "ResourceDictionary")) { - xml_free_element(xml); - xps_free_part(ctx, part); - return fz_throw("expected ResourceDictionary element (found %s)", xml_tag(xml)); + xml_free_element(doc->ctx, xml); + xps_free_part(doc, part); + return fz_error_make("expected ResourceDictionary element (found %s)", xml_tag(xml)); } fz_strlcpy(part_uri, part_name, sizeof part_uri); @@ -90,24 +90,24 @@ xps_parse_remote_resource_dictionary(xps_context *ctx, xps_resource **dictp, cha if (s) s[1] = 0; - code = xps_parse_resource_dictionary(ctx, &dict, part_uri, xml); + code = xps_parse_resource_dictionary(doc, &dict, part_uri, xml); if (code) { - xml_free_element(xml); - xps_free_part(ctx, part); - return fz_rethrow(code, "cannot parse remote resource dictionary: %s", part_uri); + xml_free_element(doc->ctx, xml); + xps_free_part(doc, part); + return fz_error_note(code, "cannot parse remote resource dictionary: %s", part_uri); } dict->base_xml = xml; /* pass on ownership */ - xps_free_part(ctx, part); + xps_free_part(doc, part); *dictp = dict; return fz_okay; } int -xps_parse_resource_dictionary(xps_context *ctx, xps_resource **dictp, char *base_uri, xml_element *root) +xps_parse_resource_dictionary(xps_document *doc, xps_resource **dictp, char *base_uri, xml_element *root) { xps_resource *head; xps_resource *entry; @@ -119,9 +119,9 @@ xps_parse_resource_dictionary(xps_context *ctx, xps_resource **dictp, char *base source = xml_att(root, "Source"); if (source) { - code = xps_parse_remote_resource_dictionary(ctx, dictp, base_uri, source); + code = xps_parse_remote_resource_dictionary(doc, dictp, base_uri, source); if (code) - return fz_rethrow(code, "cannot parse remote resource dictionary"); + return fz_error_note(code, "cannot parse remote resource dictionary"); return fz_okay; } @@ -132,7 +132,7 @@ xps_parse_resource_dictionary(xps_context *ctx, xps_resource **dictp, char *base key = xml_att(node, "x:Key"); if (key) { - entry = fz_malloc(sizeof(xps_resource)); + entry = fz_malloc(doc->ctx, sizeof(xps_resource)); entry->name = key; entry->base_uri = NULL; entry->base_xml = NULL; @@ -144,26 +144,26 @@ xps_parse_resource_dictionary(xps_context *ctx, xps_resource **dictp, char *base } if (head) - head->base_uri = fz_strdup(base_uri); + head->base_uri = fz_strdup(doc->ctx, base_uri); else - return fz_throw("empty resource dictionary"); + return fz_error_make("empty resource dictionary"); *dictp = head; return fz_okay; } void -xps_free_resource_dictionary(xps_context *ctx, xps_resource *dict) +xps_free_resource_dictionary(xps_document *doc, xps_resource *dict) { xps_resource *next; while (dict) { next = dict->next; if (dict->base_xml) - xml_free_element(dict->base_xml); + xml_free_element(doc->ctx, dict->base_xml); if (dict->base_uri) - fz_free(dict->base_uri); - fz_free(dict); + fz_free(doc->ctx, dict->base_uri); + fz_free(doc->ctx, dict); dict = next; } } |