* remote-fileio.c (remote_fileio_return_success): Take a gdb_byte
[deliverable/binutils-gdb.git] / gdb / kod.c
index 0a90677746c39f5eb4d76c2dfe5ad16003dfab4e..ff4849441931bc17bd629d664b2f4dc7fe0e7d10 100644 (file)
--- a/gdb/kod.c
+++ b/gdb/kod.c
@@ -1,5 +1,5 @@
 /* Kernel Object Display generic routines and callbacks
-   Copyright 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
 
    Written by Fernando Nasser <fnasser@cygnus.com> for Cygnus Solutions.
 
@@ -17,8 +17,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "command.h"
@@ -87,11 +87,13 @@ gdb_kod_display (char *arg)
 static void
 gdb_kod_query (char *arg, char *result, int *maxsiz)
 {
-  int bufsiz = 0;
+  LONGEST bufsiz = 0;
 
-  /* Check if current target has remote_query capabilities.
-     If not, it does not have kod either.  */
-  if (! current_target.to_query)
+  /* Check if current target has remote_query capabilities.  If not,
+     it does not have kod either.  */
+  bufsiz = target_read_partial (&current_target, TARGET_OBJECT_KOD,
+                               NULL, NULL, 0, 0);
+  if (bufsiz < 0)
     {
       strcpy (result,
               "ERR: Kernel Object Display not supported by current target\n");
@@ -99,7 +101,6 @@ gdb_kod_query (char *arg, char *result, int *maxsiz)
     }
 
   /* Just get the maximum buffer size.  */
-  target_query ((int) 'K', 0, 0, &bufsiz);
 
   /* Check if *we* were called just for getting the buffer size.  */
   if (*maxsiz == 0)
@@ -116,10 +117,11 @@ gdb_kod_query (char *arg, char *result, int *maxsiz)
   /* See if buffer can hold the query (usually it can, as the query is
      short).  */
   if (strlen (arg) >= bufsiz)
-    error ("kod: query argument too long");
+    error (_("kod: query argument too long"));
 
   /* Send actual request.  */
-  if (target_query ((int) 'K', arg, result, &bufsiz))
+  if (target_read_partial (&current_target, TARGET_OBJECT_KOD,
+                          arg, result, 0, bufsiz) < 0)
     strcpy (result, "ERR: remote query failed");
 }
 
@@ -132,9 +134,6 @@ kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
 {
   char *p;
 
-  if (command->type != set_cmd)
-    return;
-
   /* If we had already had an open OS, close it.  */
   if (gdb_kod_close)
     (*gdb_kod_close) ();
@@ -143,9 +142,8 @@ kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
   if (old_operating_system)
     {
       delete_cmd (old_operating_system, &infolist);
-      free (old_operating_system);
+      xfree (old_operating_system);
     }
-  old_operating_system = xstrdup (operating_system);
 
   if (! operating_system || ! *operating_system)
     {
@@ -160,13 +158,15 @@ kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
     {
       char *kodlib;
 
+      old_operating_system = xstrdup (operating_system);
+
       load_kod_library (operating_system);
 
       kodlib = (*gdb_kod_open) (gdb_kod_display, gdb_kod_query);
 
       /* Add kod related info commands to gdb.  */
       add_info (operating_system, info_kod_command,
-               "Displays information about Kernel Objects.");
+               _("Displays information about Kernel Objects."));
 
       p = strrchr (kodlib, '-');
       if (p != NULL)
@@ -175,7 +175,7 @@ kod_set_os (char *arg, int from_tty, struct cmd_list_element *command)
        p = "Unknown KOD library";
       printf_filtered ("%s - %s\n", operating_system, p);
 
-      free (kodlib);
+      xfree (kodlib);
     }
 }
 
@@ -212,18 +212,18 @@ load_kod_library (char *lib)
       gdb_kod_close = cisco_kod_close;
     }
   else
-    error ("Unknown operating system: %s\n", operating_system);
+    error (_("Unknown operating system: %s."), operating_system);
 }
 
 void
-_initialize_kod ()
+_initialize_kod (void)
 {
   struct cmd_list_element *c;
 
-  c = add_set_cmd ("os", no_class, var_string,
-                  (char *) &operating_system,
-                  "Set operating system",
-                  &setlist);
-  c->function.sfunc = kod_set_os;
-  add_show_from_set (c, &showlist);
+  add_setshow_string_cmd ("os", no_class, &operating_system, _("\
+Set operating system"), _("\
+Show operating system"), NULL,
+                         kod_set_os,
+                         NULL, /* FIXME: i18n: */
+                         &setlist, &showlist);
 }
This page took 0.040525 seconds and 4 git commands to generate.