[couchdb-glib] Convert custom structs to real GType's



commit 5f1febadd87baaaacfaf0f37d08c99ee58f85579
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Fri Jun 12 01:48:18 2009 +0200

    Convert custom structs to real GType's

 couchdb-glib/Makefile.am     |    5 +-
 couchdb-glib/couchdb-glib.h  |   41 +++------
 couchdb-glib/couchdb-types.c |  213 ++++++++++++++++++++++++++++++++++++++++++
 couchdb-glib/couchdb-types.h |   64 +++++++++++++
 couchdb-glib/couchdb.c       |   47 ++-------
 couchdb-glib/utils.h         |   35 +++++++
 tests/Makefile.am            |    5 +-
 tests/test-list-databases.c  |   30 ++++--
 8 files changed, 362 insertions(+), 78 deletions(-)
---
diff --git a/couchdb-glib/Makefile.am b/couchdb-glib/Makefile.am
index 8aa0e04..6f12519 100644
--- a/couchdb-glib/Makefile.am
+++ b/couchdb-glib/Makefile.am
@@ -6,10 +6,13 @@ lib_LTLIBRARIES = libcouchdb-glib-1.0.la
 libcouchdb_glib_1_0_la_SOURCES =	\
 	couchdb.c			\
 	couchdb-document.c		\
+	couchdb-types.c			\
 	utils.c				\
 	utils.h
 
 hdir = $(includedir)/couchdb-glib-1.0
-h_DATA = couchdb-glib.h
+h_DATA = 				\
+	couchdb-glib.h			\
+	couchdb-types.h
 
 EXTRA_DIST = $(h_DATA)
diff --git a/couchdb-glib/couchdb-glib.h b/couchdb-glib/couchdb-glib.h
index bb5f8d4..5d08762 100644
--- a/couchdb-glib/couchdb-glib.h
+++ b/couchdb-glib/couchdb-glib.h
@@ -22,7 +22,7 @@
 #ifndef __COUCHDB_GLIB_H__
 #define __COUCHDB_GLIB_H__
 
-#include <glib-object.h>
+#include <couchdb-types.h>
 
 #define COUCHDB_TYPE                (couchdb_get_type ())
 #define COUCHDB(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), COUCHDB_TYPE, CouchDB))
@@ -43,31 +43,17 @@ CouchDB *couchdb_new (const char *hostname);
  * Databases API
  */
 
-GSList *couchdb_list_databases (CouchDB *couchdb, GError **error);
-void    couchdb_free_database_list (GSList *dblist);
-
-typedef struct {
-	char *dbname;
-	gint doc_count;
-	gint doc_del_count;
-	gint update_seq;
-	gboolean compact_running;
-	gint disk_size;
-} CouchDBDatabaseInfo;
+GSList              *couchdb_list_databases (CouchDB *couchdb, GError **error);
+void                 couchdb_free_database_list (GSList *dblist);
 
 CouchDBDatabaseInfo *couchdb_get_database_info (CouchDB *couchdb, const char *dbname, GError **error);
-void                 couchdb_free_database_info (CouchDBDatabaseInfo *dbinfo);
 
-gboolean couchdb_create_database (CouchDB *couchdb, const char *dbname, GError **error);
-gboolean couchdb_delete_database (CouchDB *couchdb, const char *dbname, GError **error);
+gboolean             couchdb_create_database (CouchDB *couchdb, const char *dbname, GError **error);
+gboolean             couchdb_delete_database (CouchDB *couchdb, const char *dbname, GError **error);
 
 /*
  * Documents API
  */
-typedef struct {
-	char *docid;
-	char *current_revision;
-} CouchDBDocumentInfo;
 
 #define COUCHDB_TYPE_DOCUMENT                (couchdb_document_get_type ())
 #define COUCHDB_DOCUMENT(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), COUCHDB_TYPE_DOCUMENT, CouchDBDocument))
@@ -83,7 +69,6 @@ typedef struct {
 
 GSList *couchdb_list_documents (CouchDB *couchdb, const char *dbname, GError **error);
 void    couchdb_free_document_list (GSList *doclist);
-void    couchdb_free_document_info (CouchDBDocumentInfo *docinfo);
 
 CouchDBDocument *couchdb_document_new (CouchDB *couchdb);
 CouchDBDocument *couchdb_document_get (CouchDB *couchdb,
@@ -95,14 +80,14 @@ void             couchdb_document_set_id (CouchDBDocument *document, const char
 
 const char      *couchdb_document_get_revision (CouchDBDocument *document);
 
-gboolean    couchdb_document_get_boolean_field (CouchDBDocument *document, const char *field);
-void        couchdb_document_set_boolean_field (CouchDBDocument *document, const char *field, gboolean value);
-gint        couchdb_document_get_int_field (CouchDBDocument *document, const char *field);
-void        couchdb_document_set_int_field (CouchDBDocument *document, const char *field, gint value);
-gdouble     couchdb_document_get_double_field (CouchDBDocument *document, const char *field);
-void        couchdb_document_set_double_field (CouchDBDocument *document, const char *field, gdouble value);
-const char *couchdb_document_get_string_field (CouchDBDocument *document, const char *field);
-void        couchdb_document_set_string_field (CouchDBDocument *document, const char *field, const char *value);
+gboolean         couchdb_document_get_boolean_field (CouchDBDocument *document, const char *field);
+void             couchdb_document_set_boolean_field (CouchDBDocument *document, const char *field, gboolean value);
+gint             couchdb_document_get_int_field (CouchDBDocument *document, const char *field);
+void             couchdb_document_set_int_field (CouchDBDocument *document, const char *field, gint value);
+gdouble          couchdb_document_get_double_field (CouchDBDocument *document, const char *field);
+void             couchdb_document_set_double_field (CouchDBDocument *document, const char *field, gdouble value);
+const char      *couchdb_document_get_string_field (CouchDBDocument *document, const char *field);
+void             couchdb_document_set_string_field (CouchDBDocument *document, const char *field, const char *value);
 
 char            *couchdb_document_to_string (CouchDBDocument *document);
 
diff --git a/couchdb-glib/couchdb-types.c b/couchdb-glib/couchdb-types.c
new file mode 100644
index 0000000..2a0ff4d
--- /dev/null
+++ b/couchdb-glib/couchdb-types.c
@@ -0,0 +1,213 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com)
+ *
+ * Authors: Rodrigo Moya <rodrigo moya canonical com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "couchdb-glib.h"
+#include "utils.h"
+
+/*
+ * CouchDBDatabaseInfo object
+ */
+
+GType
+couchdb_database_info_get_type (void)
+{
+	static GType object_type = 0;
+
+	if (G_UNLIKELY (!object_type))
+		object_type = g_boxed_type_register_static (g_intern_static_string ("CouchDBDatabaseInfo"),
+							    (GBoxedCopyFunc) couchdb_database_info_ref,
+							    (GBoxedFreeFunc) couchdb_database_info_unref);
+
+	return object_type;
+}
+
+CouchDBDatabaseInfo *
+couchdb_database_info_new (const char *dbname,
+			   gint doc_count,
+			   gint doc_del_count,
+			   gint update_seq,
+			   gboolean compact_running,
+			   gint disk_size)
+{
+	CouchDBDatabaseInfo *dbinfo;
+
+	dbinfo = g_slice_new (CouchDBDatabaseInfo);
+	dbinfo->ref_count = 1;
+	dbinfo->dbname = g_strdup (dbname);
+	dbinfo->doc_count = doc_count;
+	dbinfo->doc_del_count = doc_del_count;
+	dbinfo->update_seq = update_seq;
+	dbinfo->compact_running = compact_running;
+	dbinfo->disk_size = disk_size;
+
+	return dbinfo;
+}
+
+CouchDBDatabaseInfo *
+couchdb_database_info_ref (CouchDBDatabaseInfo *dbinfo)
+{
+	g_return_val_if_fail (dbinfo != NULL, NULL);
+	g_return_val_if_fail (dbinfo->ref_count > 0, NULL);
+
+	g_atomic_int_exchange_and_add (&dbinfo->ref_count, 1);
+
+	return dbinfo;
+}
+
+void
+couchdb_database_info_unref (CouchDBDatabaseInfo *dbinfo)
+{
+	gint old_ref;
+
+	g_return_if_fail (dbinfo != NULL);
+	g_return_if_fail (dbinfo->ref_count > 0);
+
+	old_ref = g_atomic_int_get (&dbinfo->ref_count);
+	if (old_ref > 1)
+		g_atomic_int_compare_and_exchange (&dbinfo->ref_count, old_ref, old_ref - 1);
+	else {
+		g_free (dbinfo->dbname);
+		g_slice_free (CouchDBDatabaseInfo, dbinfo);
+	}
+}
+
+const char *
+couchdb_database_info_get_dbname (CouchDBDatabaseInfo *dbinfo)
+{
+	g_return_val_if_fail (dbinfo != NULL, NULL);
+
+	return (const char *) dbinfo->dbname;
+}
+
+gint
+couchdb_database_info_get_documents_count (CouchDBDatabaseInfo *dbinfo)
+{
+	g_return_val_if_fail (dbinfo != NULL, 0);
+
+	return dbinfo->doc_count;
+}
+
+gint
+couchdb_database_info_get_deleted_documents_count (CouchDBDatabaseInfo *dbinfo)
+{
+	g_return_val_if_fail (dbinfo != NULL, 0);
+
+	return dbinfo->doc_del_count;
+}
+
+gint
+couchdb_database_info_get_update_sequence (CouchDBDatabaseInfo *dbinfo)
+{
+	g_return_val_if_fail (dbinfo != NULL, 0);
+
+	return dbinfo->update_seq;
+}
+
+gboolean
+couchdb_database_info_is_compact_running (CouchDBDatabaseInfo *dbinfo)
+{
+	g_return_val_if_fail (dbinfo != NULL, FALSE);
+
+	return dbinfo->compact_running;
+}
+
+gint
+couchdb_database_info_get_disk_size (CouchDBDatabaseInfo *dbinfo)
+{
+	g_return_val_if_fail (dbinfo != NULL, 0);
+
+	return dbinfo->disk_size;
+}
+
+/*
+ * CouchDBDocumentInfo object
+ */
+
+GType
+couchdb_document_info_get_type (void)
+{
+	static GType object_type = 0;
+
+	if (G_UNLIKELY (!object_type))
+		object_type = g_boxed_type_register_static (g_intern_static_string ("CouchDBDocumentInfo"),
+							    (GBoxedCopyFunc) couchdb_document_info_ref,
+							    (GBoxedFreeFunc) couchdb_document_info_unref);
+
+	return object_type;
+}
+
+CouchDBDocumentInfo *
+couchdb_document_info_new (const char *docid, const char *revision)
+{
+	CouchDBDocumentInfo *doc_info;
+
+	doc_info = g_slice_new (CouchDBDocumentInfo);
+	doc_info->ref_count = 1;
+	doc_info->docid = g_strdup (docid);
+	doc_info->revision = g_strdup (revision);
+
+	return doc_info;
+}
+
+CouchDBDocumentInfo *
+couchdb_document_info_ref (CouchDBDocumentInfo *doc_info)
+{
+	g_return_val_if_fail (doc_info != NULL, NULL);
+	g_return_val_if_fail (doc_info->ref_count > 0, NULL);
+
+	g_atomic_int_exchange_and_add (&doc_info->ref_count, 1);
+
+	return doc_info;
+}
+
+void
+couchdb_document_info_unref (CouchDBDocumentInfo *doc_info)
+{
+	gint old_ref;
+
+	g_return_if_fail (doc_info != NULL);
+	g_return_if_fail (doc_info->ref_count > 0);
+
+	old_ref = g_atomic_int_get (&doc_info->ref_count);
+	if (old_ref > 1)
+		g_atomic_int_compare_and_exchange (&doc_info->ref_count, old_ref, old_ref - 1);
+	else {
+		g_free (doc_info->docid);
+		g_free (doc_info->revision);
+		g_slice_free (CouchDBDocumentInfo, doc_info);
+	}
+}
+
+const char *
+couchdb_document_info_get_docid (CouchDBDocumentInfo *doc_info)
+{
+	g_return_val_if_fail (doc_info != NULL, NULL);
+
+	return (const char *) doc_info->docid;
+}
+
+const char *
+couchdb_document_info_get_revision (CouchDBDocumentInfo *doc_info)
+{
+	g_return_val_if_fail (doc_info != NULL, NULL);
+
+	return (const char *) doc_info->revision;
+}
diff --git a/couchdb-glib/couchdb-types.h b/couchdb-glib/couchdb-types.h
new file mode 100644
index 0000000..a500298
--- /dev/null
+++ b/couchdb-glib/couchdb-types.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com)
+ *
+ * Authors: Rodrigo Moya <rodrigo moya canonical com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __COUCHDB_TYPES_H__
+#define __COUCHDB_TYPES_H__
+
+#include <glib-object.h>
+
+#define COUCHDB_TYPE_OBJECT        (couchdb_object_get_type ())
+#define COUCHDB_TYPE_DATABASE_INFO (couchdb_database_info_get_type ())
+#define COUCHDB_TYPE_DOCUMENT_INFO (couchdb_document_info_get_type ())
+
+typedef struct _CouchDBObject CouchDBObject;
+typedef struct _CouchDBDatabaseInfo CouchDBDatabaseInfo;
+typedef struct _CouchDBDocumentInfo CouchDBDocumentInfo;
+
+/*
+ * CouchDBObject
+ */
+GType couchdb_object_get_type (void);
+
+/*
+ * CouchDBDatabaseInfo
+ */
+GType                couchdb_database_info_get_type (void);
+CouchDBDatabaseInfo *couchdb_database_info_ref (CouchDBDatabaseInfo *dbinfo);
+void                 couchdb_database_info_unref (CouchDBDatabaseInfo *dbinfo);
+
+const char          *couchdb_database_info_get_dbname (CouchDBDatabaseInfo *dbinfo);
+gint                 couchdb_database_info_get_documents_count (CouchDBDatabaseInfo *dbinfo);
+gint                 couchdb_database_info_get_deleted_documents_count (CouchDBDatabaseInfo *dbinfo);
+gint                 couchdb_database_info_get_update_sequence (CouchDBDatabaseInfo *dbinfo);
+gboolean             couchdb_database_info_is_compact_running (CouchDBDatabaseInfo *dbinfo);
+gint                 couchdb_database_info_get_disk_size (CouchDBDatabaseInfo *dbinfo);
+
+/*
+ * CouchDBDocumentInfo
+ */
+GType                couchdb_document_info_get_type (void);
+CouchDBDocumentInfo *couchdb_document_info_ref (CouchDBDocumentInfo *doc_info);
+void                 couchdb_document_info_unref (CouchDBDocumentInfo *doc_info);
+
+const char          *couchdb_document_info_get_docid (CouchDBDocumentInfo *doc_info);
+const char          *couchdb_document_info_get_revision (CouchDBDocumentInfo *doc_info);
+
+#endif
diff --git a/couchdb-glib/couchdb.c b/couchdb-glib/couchdb.c
index f5d4c3d..8e0a829 100644
--- a/couchdb-glib/couchdb.c
+++ b/couchdb-glib/couchdb.c
@@ -121,15 +121,12 @@ couchdb_get_database_info (CouchDB *couchdb, const char *dbname, GError **error)
 		if (json_node_get_node_type (root_node) == JSON_NODE_OBJECT) {
 			JsonObject *object = json_node_get_object (root_node);
 
-			if (!result)
-				result = g_new0 (CouchDBDatabaseInfo, 1);
-
-			result->dbname = g_strdup (json_object_get_string_member (object, "db_name"));
-			result->doc_count = json_object_get_int_member (object, "doc_count");
-			result->doc_del_count = json_object_get_int_member (object, "doc_del_count");
-			result->update_seq = json_object_get_int_member (object, "update_seq");
-			result->compact_running = json_object_get_boolean_member (object, "compact_running");
-			result->disk_size = json_object_get_int_member (object, "disk_size");
+			result = couchdb_database_info_new (json_object_get_string_member (object, "db_name"),
+							    json_object_get_int_member (object, "doc_count"),
+							    json_object_get_int_member (object, "doc_del_count"),
+							    json_object_get_int_member (object, "update_seq"),
+							    json_object_get_boolean_member (object, "compact_running"),
+							    json_object_get_int_member (object, "disk_size"));
 		}
 		
 		g_object_unref (G_OBJECT (parser));
@@ -138,15 +135,6 @@ couchdb_get_database_info (CouchDB *couchdb, const char *dbname, GError **error)
 	return result;
 }
 
-void
-couchdb_free_database_info (CouchDBDatabaseInfo *dbinfo)
-{
-	g_return_if_fail (dbinfo != NULL);
-
-	g_free (dbinfo->dbname);
-	g_free (dbinfo);
-}
-
 gboolean
 couchdb_create_database (CouchDB *couchdb, const char *dbname, GError **error)
 {
@@ -208,7 +196,7 @@ couchdb_free_database_list (GSList *dblist)
 {
 	g_return_if_fail (dblist != NULL);
 
-	g_slist_foreach (dblist, (GFunc) g_free, NULL);
+	g_slist_foreach (dblist, (GFunc) couchdb_database_info_unref, NULL);
 	g_slist_free (dblist);
 }
 
@@ -234,9 +222,7 @@ couchdb_list_documents (CouchDB *couchdb, const char *dbname, GError **error)
 
 			rows = json_object_get_array_member (
 				json_node_get_object (root_node), "rows");
-			for (i = 0;
-			     i < json_array_get_length (rows);
-			     i++) {
+			for (i = 0; i < json_array_get_length (rows); i++) {
 				JsonObject *doc;
 				CouchDBDocumentInfo *doc_info;
 
@@ -244,10 +230,8 @@ couchdb_list_documents (CouchDB *couchdb, const char *dbname, GError **error)
 				if (!doc)
 					continue;
 
-				doc_info = g_new0 (CouchDBDocumentInfo, 1);
-				doc_info->docid = g_strdup (
-					json_object_get_string_member (doc, "id"));
-				doc_info->current_revision = g_strdup (
+				doc_info = couchdb_document_info_new (
+					json_object_get_string_member (doc, "id"),
 					json_object_get_string_member (
 						json_object_get_object_member (doc, "value"),
 						"rev"));
@@ -266,15 +250,6 @@ couchdb_free_document_list (GSList *doclist)
 {
 	g_return_if_fail (doclist != NULL);
 
-	g_slist_foreach (doclist, (GFunc) couchdb_free_document_info, NULL);
+	g_slist_foreach (doclist, (GFunc) couchdb_document_info_unref, NULL);
 	g_slist_free (doclist);
 }
-
-void
-couchdb_free_document_info (CouchDBDocumentInfo *docinfo)
-{
-	g_return_if_fail (docinfo != NULL);
-
-	g_free (docinfo->docid);
-	g_free (docinfo->current_revision);
-}
diff --git a/couchdb-glib/utils.h b/couchdb-glib/utils.h
index 6c9c3a9..fbfbba5 100644
--- a/couchdb-glib/utils.h
+++ b/couchdb-glib/utils.h
@@ -32,6 +32,41 @@ struct _CouchDB {
 	SoupSession *http_session;
 };
 
+struct _CouchDBObject {
+	JsonNode *root_node;
+};
+
+struct _CouchDBDatabaseInfo {
+	gint ref_count;
+
+	char *dbname;
+	gint doc_count;
+	gint doc_del_count;
+	gint update_seq;
+	gboolean compact_running;
+	gint disk_size;
+};
+
+CouchDBDatabaseInfo *couchdb_database_info_new (const char *dbname,
+						gint doc_count,
+						gint doc_del_count,
+						gint update_seq,
+						gboolean compact_running,
+						gint disk_size);
+
+struct _CouchDBDocumentInfo {
+	gint ref_count;
+
+	char *docid;
+	char *revision;
+};
+
+CouchDBDocumentInfo *couchdb_document_info_new (const char *docid, const char *revision);
+
+/*
+ * Utility functions
+ */
+
 JsonParser *send_message_and_parse (CouchDB *couchdb,
 				    const char *method,
 				    const char *url,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3824854..72f83fa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,6 @@
 INCLUDES =			\
-	$(COUCHDB_GLIB_CFLAGS)
+	$(COUCHDB_GLIB_CFLAGS)	\
+	-I$(top_srcdir)/couchdb-glib
 
 noinst_PROGRAMS = 		\
 	test-list-databases
@@ -7,4 +8,4 @@ noinst_PROGRAMS = 		\
 test_list_databases_SOURCES = test-list-databases.c
 test_list_databases_LDADD = 	\
 	$(COUCHDB_GLIB_LIBS)	\
-	$(top_builddir)/couchdb-glib/libcouchdb-glib.la
+	$(top_builddir)/couchdb-glib/libcouchdb-glib-1.0.la
diff --git a/tests/test-list-databases.c b/tests/test-list-databases.c
index 3403335..e12babb 100644
--- a/tests/test-list-databases.c
+++ b/tests/test-list-databases.c
@@ -19,7 +19,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#include "../couchdb-glib/couchdb-glib.h"
+#include <couchdb-glib.h>
 
 int
 main (int argc, char *argv[])
@@ -48,14 +48,20 @@ main (int argc, char *argv[])
 		g_print ("Found database %s\n", (const char *) sl->data);
 		dbinfo = couchdb_get_database_info (couchdb, (const char *) sl->data, &error);
 		if (dbinfo) {
-			g_print ("\tDatabase name: %s\n", dbinfo->dbname);
-			g_print ("\t# of documents: %d\n", dbinfo->doc_count);
-			g_print ("\t# of deleted documents: %d\n", dbinfo->doc_del_count);
-			g_print ("\tUpdate sequence: %d\n", dbinfo->update_seq);
-			g_print ("\tCompact running?: %s\n", dbinfo->compact_running ? "True" : "False");
-			g_print ("\tDisk size: %d\n", dbinfo->disk_size);
-
-			couchdb_free_database_info (dbinfo);
+			g_print ("\tDatabase name: %s\n",
+				 couchdb_database_info_get_dbname (dbinfo));
+			g_print ("\t# of documents: %d\n",
+				 couchdb_database_info_get_documents_count (dbinfo));
+			g_print ("\t# of deleted documents: %d\n",
+				 couchdb_database_info_get_deleted_documents_count (dbinfo));
+			g_print ("\tUpdate sequence: %d\n",
+				 couchdb_database_info_get_update_sequence (dbinfo));
+			g_print ("\tCompact running?: %s\n",
+				 couchdb_database_info_is_compact_running (dbinfo) ? "True" : "False");
+			g_print ("\tDisk size: %d\n",
+				 couchdb_database_info_get_disk_size (dbinfo));
+
+			couchdb_database_info_unref (dbinfo);
 		} else {
 			g_print ("Could not retrieve info for database %s\n", (const char *) sl->data);
 		}
@@ -74,7 +80,7 @@ main (int argc, char *argv[])
 				error = NULL;
 				document = couchdb_document_get (couchdb,
 								 (const char *) sl->data,
-								 doc_info->docid,
+								 couchdb_document_info_get_docid (doc_info),
 								 error);
 				if (document) {
 					char *json;
@@ -89,7 +95,9 @@ main (int argc, char *argv[])
 
 					g_object_unref (G_OBJECT (document));
 				} else {
-					g_print ("\t\t%s\t(rev: %s)\n", doc_info->docid, doc_info->current_revision);
+					g_print ("\t\t%s\t(rev: %s)\n",
+						 couchdb_document_info_get_docid (doc_info),
+						 couchdb_document_info_get_revision (doc_info));
 				}
 			}
 		} else {



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