throw_verror (XML_PARSE_ERROR, format, ap);
}
+/* Find the attribute named NAME in the set of parsed attributes
+ ATTRIBUTES. Returns NULL if not found. */
+
+struct gdb_xml_value *
+xml_find_attribute (VEC(gdb_xml_value_s) *attributes, const char *name)
+{
+ struct gdb_xml_value *value;
+ int ix;
+
+ for (ix = 0; VEC_iterate (gdb_xml_value_s, attributes, ix, value); ix++)
+ if (strcmp (value->name, name) == 0)
+ return value;
+
+ return NULL;
+}
+
/* Clean up a vector of parsed attribute values. */
static void
gdb_xml_error (parser, _("Required element <%s> is missing"),
element->name);
- /* Call the element processor. */
+ /* Call the element processor. */
if (scope->element != NULL && scope->element->end_handler)
{
char *body;
/* Initialize and return a parser. Register a cleanup to destroy the
parser. */
-struct gdb_xml_parser *
-gdb_xml_create_parser_and_cleanup (const char *name,
- const struct gdb_xml_element *elements,
- void *user_data)
+static struct gdb_xml_parser *
+gdb_xml_create_parser_and_cleanup_1 (const char *name,
+ const struct gdb_xml_element *elements,
+ void *user_data, struct cleanup **old_chain)
{
struct gdb_xml_parser *parser;
struct scope_level start_scope;
+ struct cleanup *dummy;
/* Initialize the parser. */
parser = XZALLOC (struct gdb_xml_parser);
start_scope.elements = elements;
VEC_safe_push (scope_level_s, parser->scopes, &start_scope);
- make_cleanup (gdb_xml_cleanup, parser);
+ if (old_chain == NULL)
+ old_chain = &dummy;
+ *old_chain = make_cleanup (gdb_xml_cleanup, parser);
return parser;
}
+/* Initialize and return a parser. Register a cleanup to destroy the
+ parser. */
+
+struct gdb_xml_parser *
+gdb_xml_create_parser_and_cleanup (const char *name,
+ const struct gdb_xml_element *elements,
+ void *user_data)
+{
+ struct cleanup *old_chain;
+
+ return gdb_xml_create_parser_and_cleanup_1 (name, elements, user_data,
+ &old_chain);
+}
+
/* External entity handler. The only external entities we support
are those compiled into GDB (we do not fetch entities from the
target). */
return -1;
}
+int
+gdb_xml_parse_quick (const char *name, const char *dtd_name,
+ const struct gdb_xml_element *elements,
+ const char *document, void *user_data)
+{
+ struct gdb_xml_parser *parser;
+ struct cleanup *back_to;
+ int result;
+
+ parser = gdb_xml_create_parser_and_cleanup_1 (name, elements,
+ user_data, &back_to);
+ if (dtd_name != NULL)
+ gdb_xml_use_dtd (parser, dtd_name);
+ result = gdb_xml_parse (parser, document);
+
+ do_cleanups (back_to);
+
+ return result;
+}
+
/* Parse a field VALSTR that we expect to contain an integer value.
The integer is returned in *VALP. The string is parsed with an
equivalent to strtoul.
void *user_data, VEC(gdb_xml_value_s) *attributes)
{
struct xinclude_parsing_data *data = user_data;
- char *href = VEC_index (gdb_xml_value_s, attributes, 0)->value;
+ char *href = xml_find_attribute (attributes, "href")->value;
struct cleanup *back_to;
char *text, *output;