#include "defs.h"
#include "gdbcmd.h"
+#include "exceptions.h"
+#include "xml-support.h"
+
+#include "gdb_string.h"
+#include "safe-ctype.h"
/* Debugging flag. */
static int debug_xml;
available. */
#ifdef HAVE_LIBEXPAT
-#include "exceptions.h"
-#include "xml-support.h"
-
#include "gdb_expat.h"
-#include "gdb_string.h"
-#include "safe-ctype.h"
/* The maximum depth of <xi:include> nesting. No need to be miserly,
we just want to avoid running out of stack on loops. */
#define MAX_XINCLUDE_DEPTH 30
+/* Simplified XML parser infrastructure. */
+
/* A parsing level -- used to keep track of the current element
nesting. */
struct scope_level
return ret;
}
+/* A handler_data for yes/no boolean values. */
+
+const struct gdb_xml_enum gdb_xml_enums_boolean[] = {
+ { "yes", 1 },
+ { "no", 0 },
+ { NULL, 0 }
+};
+
/* Map NAME to VALUE. A struct gdb_xml_enum * should be saved as the
value of handler_data when using gdb_xml_parse_attr_enum to parse a
fixed list of possible strings. The list is terminated by an entry
void *ret;
for (enums = attribute->handler_data; enums->name != NULL; enums++)
- if (strcmp (enums->name, value) == 0)
+ if (strcasecmp (enums->name, value) == 0)
break;
if (enums->name == NULL)
do_cleanups (back_to);
return result;
}
+#endif /* HAVE_LIBEXPAT */
\f
/* Return an XML document which was compiled into GDB, from
return NULL;
}
-#endif /* HAVE_LIBEXPAT */
+/* A to_xfer_partial helper function which reads XML files which were
+ compiled into GDB. The target may call this function from its own
+ to_xfer_partial handler, after converting object and annex to the
+ appropriate filename. */
+
+LONGEST
+xml_builtin_xfer_partial (const char *filename,
+ gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST offset, LONGEST len)
+{
+ const char *buf;
+ LONGEST len_avail;
+
+ gdb_assert (readbuf != NULL && writebuf == NULL);
+ gdb_assert (filename != NULL);
+
+ buf = fetch_xml_builtin (filename);
+ if (buf == NULL)
+ return -1;
+
+ len_avail = strlen (buf);
+ if (offset >= len_avail)
+ return 0;
+
+ if (len > len_avail - offset)
+ len = len_avail - offset;
+ memcpy (readbuf, buf + offset, len);
+ return len;
+}
+\f
static void
show_debug_xml (struct ui_file *file, int from_tty,