* m68k-tdep.c (m68k_ps_type): New.
[deliverable/binutils-gdb.git] / gdb / xml-support.c
index 1a31db4805b4e2532af446cb45749a98d51ca556..49a10d72d56f6974d033072831148fa4deda3fd4 100644 (file)
 
 #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;
@@ -29,17 +34,14 @@ 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
@@ -631,6 +633,14 @@ gdb_xml_parse_attr_ulongest (struct gdb_xml_parser *parser,
   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
@@ -645,7 +655,7 @@ gdb_xml_parse_attr_enum (struct gdb_xml_parser *parser,
   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)
@@ -870,6 +880,7 @@ xml_process_xincludes (const char *name, const char *text,
   do_cleanups (back_to);
   return result;
 }
+#endif /* HAVE_LIBEXPAT */
 \f
 
 /* Return an XML document which was compiled into GDB, from
@@ -887,7 +898,36 @@ fetch_xml_builtin (const char *filename)
   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,
This page took 0.024887 seconds and 4 git commands to generate.