Fixed macro-name typos.
[platform/core/uifw/at-spi2-atk.git] / cspi / spi-util.c
index e9d736b..f9bb545 100644 (file)
@@ -1,17 +1,43 @@
-#include <string.h>
-#include "spi-util.h"
+#include <stdlib.h>
+#include <cspi/spi-private.h>
 
-
-char *
-string_from_corba_string (CORBA_char *string)
+/**
+ * SPI_freeString:
+ * @s: a character string returned from another at-spi call.
+ *
+ * Free a character string returned from an at-spi call.  Clients of
+ * at-spi should use this function instead of free () or g_free().
+ * This API should not be used to free strings
+ * from other libraries or allocated by the client.
+ **/
+void
+SPI_freeString (char *s)
 {
-  char *newstring;
-  int length;
-
-  length = strlen (string);
-  newstring = (char *) malloc (length+1);
-  strcpy (newstring, string);
-  CORBA_free (string);
-  return newstring;
+  CORBA_free (s);
 }
 
+SPIBoolean
+cspi_check_ev (const char *error_string)
+{
+  CORBA_Environment *ev = cspi_ev ();
+
+  if (ev->_major != CORBA_NO_EXCEPTION)
+    {
+      char *err;
+
+      err = bonobo_exception_get_text (ev);
+
+      fprintf (stderr, "Warning: AT-SPI error: %s: %s\n",
+              error_string, err);
+
+      g_free (err);
+
+      CORBA_exception_free (ev);
+
+      return FALSE;
+    }
+  else
+    {
+      return TRUE;
+    }
+}