libgda r3324 - in trunk: . doc/C/tmpl libgda libgda/handlers providers/postgres providers/sybase



Author: vivien
Date: Tue Feb 17 17:19:41 2009
New Revision: 3324
URL: http://svn.gnome.org/viewvc/libgda?rev=3324&view=rev

Log:
2009-02-17  Vivien Malerba <malerba gnome-db org>

	* configure.in:
	* providers/sybase/main.c:
	* Makefile.w32: removed any obsolete reference to bonobo,
	for bug #571879
	* libgda/gda-value.[ch]:
	* libgda/handlers/gda-handler-bin.c:
	* providers/postgres/gda-postgres-handler-bin.c:
	  - fixed gda_string_to_binary() and gda_string_to_blob(),
	    for bug #572028
	  - removed the const from gda_value_take_binary() and
	    gda_value_take_blob()


Modified:
   trunk/ChangeLog
   trunk/Makefile.w32
   trunk/configure.in
   trunk/doc/C/tmpl/gda-value.sgml
   trunk/libgda/gda-value.c
   trunk/libgda/gda-value.h
   trunk/libgda/handlers/gda-handler-bin.c
   trunk/providers/postgres/gda-postgres-handler-bin.c
   trunk/providers/sybase/main.c

Modified: trunk/Makefile.w32
==============================================================================
--- trunk/Makefile.w32	(original)
+++ trunk/Makefile.w32	Tue Feb 17 17:19:41 2009
@@ -37,7 +37,6 @@
 	-DPACKAGE_BUGREPORT=\"\" \
 	-DPACKAGE=\"libgda\" \
 	-DVERSION=\"1.1.6\" \
-	-DBONOBO_EXPLICIT_TRANSLATION_DOMAIN=\"libgda-2\" \
 	-DSTDC_HEADERS=1 \
 	-DHAVE_SYS_TYPES_H=1 \
 	-DHAVE_SYS_STAT_H=1 \

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Feb 17 17:19:41 2009
@@ -49,8 +49,6 @@
 AC_CHECK_SIZEOF(unsigned int,0)
 AC_CHECK_SIZEOF(unsigned long int,0)
 
-AC_DEFINE_UNQUOTED(BONOBO_EXPLICIT_TRANSLATION_DOMAIN, "libgda-$LIBGDA_ABI_VERSION")
-
 dnl **********************
 dnl Cross compilation test
 dnl **********************

Modified: trunk/doc/C/tmpl/gda-value.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-value.sgml	(original)
+++ trunk/doc/C/tmpl/gda-value.sgml	Tue Feb 17 17:19:41 2009
@@ -278,7 +278,6 @@
 </para>
 
 @str: 
- bin: 
 @Returns: 
 
 

Modified: trunk/libgda/gda-value.c
==============================================================================
--- trunk/libgda/gda-value.c	(original)
+++ trunk/libgda/gda-value.c	Tue Feb 17 17:19:41 2009
@@ -217,16 +217,20 @@
 		}
 	}
 	else if (type == GDA_TYPE_BINARY) {
-		GdaBinary binary;
-		retval = gda_string_to_binary (as_string, &binary);
-		if (retval)
-			gda_value_set_binary (value, &binary);
+		GdaBinary *bin;
+		bin = gda_string_to_binary (as_string);
+		if (bin) {
+			gda_value_take_binary (value, bin);
+			retval = TRUE;
+		}
 	}
 	else if (type == GDA_TYPE_BLOB) {
-		GdaBlob blob;
-		retval = gda_string_to_blob (as_string, &blob);
-		if (retval)
-			gda_value_set_blob (value, &blob);
+		GdaBlob *blob;
+		blob = gda_string_to_blob (as_string);
+		if (blob) {
+			gda_value_take_blob (value, blob);
+			retval = TRUE;
+		}
 	}
 
 
@@ -256,7 +260,7 @@
 string_to_binary (const GValue *src, GValue *dest) 
 {
 	/* FIXME: add more checks*/
-	GdaBinary *binary;
+	GdaBinary *bin;
 	const gchar *as_string;
 	
 	g_return_if_fail (G_VALUE_HOLDS_STRING (src) &&
@@ -264,9 +268,9 @@
 	
 	as_string = g_value_get_string (src);
 	
-	binary = g_new0 (GdaBinary, 1);
-	gda_string_to_binary (as_string, binary);
-	gda_value_take_binary (dest, binary);
+	bin = gda_string_to_binary (as_string);
+	g_return_if_fail (bin);
+	gda_value_take_binary (dest, bin);
 }
 
 static void 
@@ -361,8 +365,8 @@
 	
 	as_string = g_value_get_string (src);
 	
-	blob = g_new0 (GdaBlob, 1);
-	gda_string_to_blob (as_string, blob);
+	blob = gda_string_to_blob (as_string);
+	g_return_if_fail (blob);
 	gda_value_take_blob (dest, blob);
 }
 
@@ -1418,7 +1422,7 @@
  * argument is not copied, but used as-is and it should be considered owned by @value.
  */
 void
-gda_value_take_binary (GValue *value, const GdaBinary *binary)
+gda_value_take_binary (GValue *value, GdaBinary *binary)
 {
 	g_return_if_fail (value);
 	g_return_if_fail (binary);
@@ -1474,7 +1478,7 @@
  * argument is not copied, but used as-is and it should be considered owned by @value.
  */
 void
-gda_value_take_blob (GValue *value, const GdaBlob *blob)
+gda_value_take_blob (GValue *value, GdaBlob *blob)
 {
 	g_return_if_fail (value);
 	g_return_if_fail (blob);
@@ -2562,24 +2566,25 @@
 /**
  * gda_string_to_binary
  * @str: a string to convert
- * @bin: a non filled @GdaBinary structure
  *
  * Performs the reverse of gda_binary_to_string().
  *
- * Returns: TRUE if no error were found in @str, or FALSE otherwise
+ * Returns: a new #GdaBinary if no error were found in @str, or NULL otherwise
  */
-gboolean
-gda_string_to_binary (const gchar *str, GdaBinary *bin)
+GdaBinary *
+gda_string_to_binary (const gchar *str)
 {
+	GdaBinary *bin;
 	glong len = 0, total;
 	gchar *ptr;
 	gchar *retval;
 	glong offset = 0;
 
 	if (!str) {
+		bin = g_new0 (GdaBinary, 1);
 		bin->data = NULL;
 		bin->binary_length = 0;
-		return TRUE;
+		return bin;
 	}
 
 	total = strlen (str);
@@ -2603,7 +2608,7 @@
 				}
 				else {
 					g_free (retval);
-					return FALSE;
+					return NULL;
 				}
 			}
 		}
@@ -2614,10 +2619,11 @@
 		len ++;
 	}
 
+	bin = g_new0 (GdaBinary, 1);
 	bin->data = (guchar*)retval;
 	bin->binary_length = len;
 
-	return TRUE;
+	return bin;
 }
 
 /**
@@ -2644,17 +2650,25 @@
 /**
  * gda_string_to_blob
  * @str: a string to convert
- * @blob: a non filled @GdaBlob structure
  *
  * Performs the reverse of gda_blob_to_string().
  *
- * Returns: TRUE if no error were found in @str, or FALSE otherwise
+ * Returns: a new #gdaBlob if no error were found in @str, or NULL otherwise
  */
-gboolean
-gda_string_to_blob (const gchar *str, GdaBlob *blob)
+GdaBlob *
+gda_string_to_blob (const gchar *str)
 {
-	gboolean retval;
-	retval = gda_string_to_binary (str, (GdaBinary*) blob);
-	blob->op = NULL;
-	return retval;
+	GdaBinary *bin;
+	bin = gda_string_to_binary (str);
+	if (bin) {
+		GdaBlob *blob;
+		blob = g_new0 (GdaBlob, 1);
+		((GdaBinary*) blob)->data = bin->data;
+		((GdaBinary*) blob)->binary_length = bin->binary_length;
+		blob->op = NULL;
+		g_free (bin);
+		return blob;
+	}
+	else
+		return NULL;
 }

Modified: trunk/libgda/gda-value.h
==============================================================================
--- trunk/libgda/gda-value.h	(original)
+++ trunk/libgda/gda-value.h	Tue Feb 17 17:19:41 2009
@@ -126,11 +126,11 @@
 
 G_CONST_RETURN GdaBinary         *gda_value_get_binary (const GValue *value);
 void                              gda_value_set_binary (GValue *value, const GdaBinary *binary);
-void                              gda_value_take_binary (GValue *value, const GdaBinary *binary);
+void                              gda_value_take_binary (GValue *value, GdaBinary *binary);
 
 G_CONST_RETURN GdaBlob           *gda_value_get_blob (const GValue *value);
 void                              gda_value_set_blob (GValue *value, const GdaBlob *blob);
-void                              gda_value_take_blob (GValue *value, const GdaBlob *blob);
+void                              gda_value_take_blob (GValue *value, GdaBlob *blob);
 
 G_CONST_RETURN GdaGeometricPoint *gda_value_get_geometric_point (const GValue *value);
 void                              gda_value_set_geometric_point (GValue *value, const GdaGeometricPoint *val);
@@ -162,10 +162,10 @@
 xmlNodePtr                        gda_value_to_xml (const GValue *value);
 
 gchar                            *gda_binary_to_string (const GdaBinary *bin, guint maxlen);
-gboolean                          gda_string_to_binary (const gchar *str, GdaBinary *bin);
+GdaBinary                        *gda_string_to_binary (const gchar *str);
 
 gchar                            *gda_blob_to_string (GdaBlob *blob, guint maxlen);
-gboolean                          gda_string_to_blob (const gchar *str, GdaBlob *blob);
+GdaBlob                          *gda_string_to_blob (const gchar *str);
 
 /* Custom data types */
 

Modified: trunk/libgda/handlers/gda-handler-bin.c
==============================================================================
--- trunk/libgda/handlers/gda-handler-bin.c	(original)
+++ trunk/libgda/handlers/gda-handler-bin.c	Tue Feb 17 17:19:41 2009
@@ -266,16 +266,17 @@
 {
 	GdaHandlerBin *hdl;
 	GValue *value = NULL;
-	GdaBinary bin;
 
 	g_return_val_if_fail (iface && GDA_IS_HANDLER_BIN (iface), NULL);
 	hdl = GDA_HANDLER_BIN (iface);
 	g_return_val_if_fail (hdl->priv, NULL);
 
 	if (type == GDA_TYPE_BINARY) {
-		if (gda_string_to_binary (str, &bin)) {
-			value = gda_value_new_binary (bin.data, bin.binary_length);
-			g_free (bin.data);
+		GdaBinary *bin;
+		bin = gda_string_to_binary (str);
+		if (bin) {
+			value = gda_value_new (GDA_TYPE_BINARY);
+			gda_value_take_binary (value, bin);
 		}
 	}
 

Modified: trunk/providers/postgres/gda-postgres-handler-bin.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-handler-bin.c	(original)
+++ trunk/providers/postgres/gda-postgres-handler-bin.c	Tue Feb 17 17:19:41 2009
@@ -293,16 +293,17 @@
 {
 	GdaPostgresHandlerBin *hdl;
 	GValue *value = NULL;
-	GdaBinary bin;
 
 	g_return_val_if_fail (iface && GDA_IS_POSTGRES_HANDLER_BIN (iface), NULL);
 	hdl = GDA_POSTGRES_HANDLER_BIN (iface);
 	g_return_val_if_fail (hdl->priv, NULL);
 
 	if (type == GDA_TYPE_BINARY) {
-		if (gda_string_to_binary (str, &bin)) {
-			value = gda_value_new_binary (bin.data, bin.binary_length);
-			g_free (bin.data);
+		GdaBinary *bin;
+		bin = gda_string_to_binary (str);
+		if (bin) {
+			value = gda_value_new (GDA_TYPE_BINARY);
+			gda_value_take_binary (value, bin);
 		}
 	}
 

Modified: trunk/providers/sybase/main.c
==============================================================================
--- trunk/providers/sybase/main.c	(original)
+++ trunk/providers/sybase/main.c	Tue Feb 17 17:19:41 2009
@@ -24,7 +24,6 @@
  */
 
 #include <config.h>
-/* #include <bonobo/bonobo-i18n.h> */
 #include "libgda/libgda.h"
 #include "gda-sybase.h"
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]