/* command-personas.c generated by valac 0.56.3, the Vala compiler
 * generated from command-personas.vala, do not modify */

/*
 * Copyright (C) 2010 Collabora Ltd.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library 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 Lesser 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, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *       Philip Withnall <philip.withnall@collabora.co.uk>
 */

#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include "folks/folks.h"
#include <stdio.h>
#include <readline/readline.h>

#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define FOLKS_INSPECT_TYPE_COMMAND (folks_inspect_command_get_type ())
#define FOLKS_INSPECT_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommand))
#define FOLKS_INSPECT_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommandClass))
#define FOLKS_INSPECT_IS_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_TYPE_COMMAND))
#define FOLKS_INSPECT_IS_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_TYPE_COMMAND))
#define FOLKS_INSPECT_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_TYPE_COMMAND, FolksInspectCommandClass))

typedef struct _FolksInspectCommand FolksInspectCommand;
typedef struct _FolksInspectCommandClass FolksInspectCommandClass;
typedef struct _FolksInspectCommandPrivate FolksInspectCommandPrivate;

#define FOLKS_INSPECT_TYPE_CLIENT (folks_inspect_client_get_type ())
#define FOLKS_INSPECT_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClient))
#define FOLKS_INSPECT_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClientClass))
#define FOLKS_INSPECT_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_TYPE_CLIENT))
#define FOLKS_INSPECT_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_TYPE_CLIENT))
#define FOLKS_INSPECT_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_TYPE_CLIENT, FolksInspectClientClass))

typedef struct _FolksInspectClient FolksInspectClient;
typedef struct _FolksInspectClientClass FolksInspectClientClass;

#define FOLKS_INSPECT_COMMANDS_TYPE_PERSONAS (folks_inspect_commands_personas_get_type ())
#define FOLKS_INSPECT_COMMANDS_PERSONAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_INSPECT_COMMANDS_TYPE_PERSONAS, FolksInspectCommandsPersonas))
#define FOLKS_INSPECT_COMMANDS_PERSONAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOLKS_INSPECT_COMMANDS_TYPE_PERSONAS, FolksInspectCommandsPersonasClass))
#define FOLKS_INSPECT_COMMANDS_IS_PERSONAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_INSPECT_COMMANDS_TYPE_PERSONAS))
#define FOLKS_INSPECT_COMMANDS_IS_PERSONAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOLKS_INSPECT_COMMANDS_TYPE_PERSONAS))
#define FOLKS_INSPECT_COMMANDS_PERSONAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOLKS_INSPECT_COMMANDS_TYPE_PERSONAS, FolksInspectCommandsPersonasClass))

typedef struct _FolksInspectCommandsPersonas FolksInspectCommandsPersonas;
typedef struct _FolksInspectCommandsPersonasClass FolksInspectCommandsPersonasClass;
typedef struct _FolksInspectCommandsPersonasPrivate FolksInspectCommandsPersonasPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _folks_inspect_command_unref0(var) ((var == NULL) ? NULL : (var = (folks_inspect_command_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _FolksInspectCommandsPersonasRunData FolksInspectCommandsPersonasRunData;

struct _FolksInspectCommand {
	GTypeInstance parent_instance;
	volatile int ref_count;
	FolksInspectCommandPrivate * priv;
	FolksInspectClient* client;
};

struct _FolksInspectCommandClass {
	GTypeClass parent_class;
	void (*finalize) (FolksInspectCommand *self);
	void (*run) (FolksInspectCommand* self, const gchar* command_string, GAsyncReadyCallback _callback_, gpointer _user_data_);
	gint (*run_finish) (FolksInspectCommand* self, GAsyncResult* _res_);
	gchar** (*complete_subcommand) (FolksInspectCommand* self, const gchar* subcommand, gint* result_length1);
	const gchar* (*get_name) (FolksInspectCommand* self);
	const gchar* (*get_description) (FolksInspectCommand* self);
	const gchar* (*get_help) (FolksInspectCommand* self);
};

struct _FolksInspectCommandsPersonas {
	FolksInspectCommand parent_instance;
	FolksInspectCommandsPersonasPrivate * priv;
};

struct _FolksInspectCommandsPersonasClass {
	FolksInspectCommandClass parent_class;
};

struct _FolksInspectCommandsPersonasRunData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FolksInspectCommandsPersonas* self;
	gchar* command_string;
	gint result;
	gboolean found_persona;
	GeeIterator* _individual_it;
	FolksInspectClient* _tmp0_;
	FolksIndividualAggregator* _tmp1_;
	FolksIndividualAggregator* _tmp2_;
	GeeMap* _tmp3_;
	GeeMap* _tmp4_;
	GeeCollection* _tmp5_;
	GeeCollection* _tmp6_;
	GeeCollection* _tmp7_;
	GeeIterator* _tmp8_;
	GeeIterator* _tmp9_;
	GeeIterator* _tmp10_;
	FolksIndividual* individual;
	GeeIterator* _tmp11_;
	gpointer _tmp12_;
	GeeIterator* _persona_it;
	FolksIndividual* _tmp13_;
	GeeSet* _tmp14_;
	GeeSet* _tmp15_;
	GeeIterator* _tmp16_;
	GeeIterator* _tmp17_;
	FolksPersona* persona;
	GeeIterator* _tmp18_;
	gpointer _tmp19_;
	gboolean _tmp20_;
	FolksPersona* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	FolksPersona* _tmp24_;
	gboolean _tmp25_;
};

static gpointer folks_inspect_commands_personas_parent_class = NULL;

VALA_EXTERN gpointer folks_inspect_command_ref (gpointer instance);
VALA_EXTERN void folks_inspect_command_unref (gpointer instance);
VALA_EXTERN GParamSpec* folks_inspect_param_spec_command (const gchar* name,
                                              const gchar* nick,
                                              const gchar* blurb,
                                              GType object_type,
                                              GParamFlags flags);
VALA_EXTERN void folks_inspect_value_set_command (GValue* value,
                                      gpointer v_object);
VALA_EXTERN void folks_inspect_value_take_command (GValue* value,
                                       gpointer v_object);
VALA_EXTERN gpointer folks_inspect_value_get_command (const GValue* value);
VALA_EXTERN GType folks_inspect_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FolksInspectCommand, folks_inspect_command_unref)
VALA_EXTERN GType folks_inspect_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FolksInspectClient, g_object_unref)
VALA_EXTERN GType folks_inspect_commands_personas_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FolksInspectCommandsPersonas, folks_inspect_command_unref)
VALA_EXTERN void folks_inspect_command_run (FolksInspectCommand* self,
                                const gchar* command_string,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN gint folks_inspect_command_run_finish (FolksInspectCommand* self,
                                       GAsyncResult* _res_);
VALA_EXTERN gchar** folks_inspect_command_complete_subcommand (FolksInspectCommand* self,
                                                   const gchar* subcommand,
                                                   gint* result_length1);
VALA_EXTERN const gchar* folks_inspect_command_get_name (FolksInspectCommand* self);
VALA_EXTERN const gchar* folks_inspect_command_get_description (FolksInspectCommand* self);
VALA_EXTERN const gchar* folks_inspect_command_get_help (FolksInspectCommand* self);
VALA_EXTERN FolksInspectCommandsPersonas* folks_inspect_commands_personas_new (FolksInspectClient* client);
VALA_EXTERN FolksInspectCommandsPersonas* folks_inspect_commands_personas_construct (GType object_type,
                                                                         FolksInspectClient* client);
VALA_EXTERN FolksInspectCommand* folks_inspect_command_construct (GType object_type,
                                                      FolksInspectClient* client);
static void folks_inspect_commands_personas_real_run_data_free (gpointer _data);
static void folks_inspect_commands_personas_real_run (FolksInspectCommand* base,
                                               const gchar* command_string,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static gboolean folks_inspect_commands_personas_real_run_co (FolksInspectCommandsPersonasRunData* _data_);
VALA_EXTERN FolksIndividualAggregator* folks_inspect_client_get_aggregator (FolksInspectClient* self);
VALA_EXTERN void folks_inspect_utils_print_persona (FolksPersona* persona);
VALA_EXTERN void folks_inspect_utils_print_blank_line (void);
VALA_EXTERN void folks_inspect_utils_print_line (const gchar* format,
                                     ...)  G_GNUC_PRINTF(1,2) ;
static gchar** folks_inspect_commands_personas_real_complete_subcommand (FolksInspectCommand* base,
                                                                  const gchar* subcommand,
                                                                  gint* result_length1);
VALA_EXTERN gchar* folks_inspect_utils_persona_uid_completion_cb (const gchar* word,
                                                      gint state);
static gchar* _folks_inspect_utils_persona_uid_completion_cb_rl_compentry_func_t (const gchar* str,
                                                                           gint a);
static gchar** _vala_array_dup10 (gchar** self,
                           gssize length);
static GType folks_inspect_commands_personas_get_type_once (void);
static gssize _vala_array_length (gpointer array);

FolksInspectCommandsPersonas*
folks_inspect_commands_personas_construct (GType object_type,
                                           FolksInspectClient* client)
{
	FolksInspectCommandsPersonas* self = NULL;
	g_return_val_if_fail (client != NULL, NULL);
	self = (FolksInspectCommandsPersonas*) folks_inspect_command_construct (object_type, client);
	return self;
}

FolksInspectCommandsPersonas*
folks_inspect_commands_personas_new (FolksInspectClient* client)
{
	return folks_inspect_commands_personas_construct (FOLKS_INSPECT_COMMANDS_TYPE_PERSONAS, client);
}

static void
folks_inspect_commands_personas_real_run_data_free (gpointer _data)
{
	FolksInspectCommandsPersonasRunData* _data_;
	_data_ = _data;
	_g_free0 (_data_->command_string);
	_folks_inspect_command_unref0 (_data_->self);
	g_slice_free (FolksInspectCommandsPersonasRunData, _data_);
}

static gpointer
_folks_inspect_command_ref0 (gpointer self)
{
	return self ? folks_inspect_command_ref (self) : NULL;
}

static void
folks_inspect_commands_personas_real_run (FolksInspectCommand* base,
                                          const gchar* command_string,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	FolksInspectCommandsPersonas * self;
	FolksInspectCommandsPersonasRunData* _data_;
	FolksInspectCommandsPersonas* _tmp0_;
	gchar* _tmp1_;
	self = (FolksInspectCommandsPersonas*) base;
	_data_ = g_slice_new0 (FolksInspectCommandsPersonasRunData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, folks_inspect_commands_personas_real_run_data_free);
	_tmp0_ = _folks_inspect_command_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (command_string);
	_g_free0 (_data_->command_string);
	_data_->command_string = _tmp1_;
	folks_inspect_commands_personas_real_run_co (_data_);
}

static gint
folks_inspect_commands_personas_run_finish (FolksInspectCommand* base,
                                            GAsyncResult* _res_)
{
	gint result;
	FolksInspectCommandsPersonasRunData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static gboolean
folks_inspect_commands_personas_real_run_co (FolksInspectCommandsPersonasRunData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->found_persona = FALSE;
	{
		_data_->_tmp0_ = ((FolksInspectCommand*) _data_->self)->client;
		_data_->_tmp1_ = folks_inspect_client_get_aggregator (_data_->_tmp0_);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp3_ = folks_individual_aggregator_get_individuals (_data_->_tmp2_);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = gee_map_get_values (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_g_object_unref0 (_data_->_tmp7_);
		_data_->_individual_it = _data_->_tmp9_;
		while (TRUE) {
			_data_->_tmp10_ = _data_->_individual_it;
			if (!gee_iterator_next (_data_->_tmp10_)) {
				break;
			}
			_data_->_tmp11_ = _data_->_individual_it;
			_data_->_tmp12_ = gee_iterator_get (_data_->_tmp11_);
			_data_->individual = (FolksIndividual*) _data_->_tmp12_;
			{
				_data_->_tmp13_ = _data_->individual;
				_data_->_tmp14_ = folks_individual_get_personas (_data_->_tmp13_);
				_data_->_tmp15_ = _data_->_tmp14_;
				_data_->_tmp16_ = gee_iterable_iterator ((GeeIterable*) _data_->_tmp15_);
				_data_->_persona_it = _data_->_tmp16_;
				while (TRUE) {
					_data_->_tmp17_ = _data_->_persona_it;
					if (!gee_iterator_next (_data_->_tmp17_)) {
						break;
					}
					_data_->_tmp18_ = _data_->_persona_it;
					_data_->_tmp19_ = gee_iterator_get (_data_->_tmp18_);
					_data_->persona = (FolksPersona*) _data_->_tmp19_;
					if (_data_->command_string != NULL) {
						_data_->_tmp21_ = _data_->persona;
						_data_->_tmp22_ = folks_persona_get_uid (_data_->_tmp21_);
						_data_->_tmp23_ = _data_->_tmp22_;
						_data_->_tmp20_ = g_strcmp0 (_data_->_tmp23_, _data_->command_string) != 0;
					} else {
						_data_->_tmp20_ = FALSE;
					}
					if (_data_->_tmp20_) {
						_g_object_unref0 (_data_->persona);
						continue;
					}
					_data_->_tmp24_ = _data_->persona;
					folks_inspect_utils_print_persona (_data_->_tmp24_);
					if (_data_->command_string == NULL) {
						folks_inspect_utils_print_blank_line ();
					} else {
						_data_->found_persona = TRUE;
					}
					_g_object_unref0 (_data_->persona);
				}
				_g_object_unref0 (_data_->_persona_it);
			}
			_g_object_unref0 (_data_->individual);
		}
		_g_object_unref0 (_data_->_individual_it);
	}
	if (!_data_->found_persona) {
		_data_->_tmp25_ = _data_->command_string != NULL;
	} else {
		_data_->_tmp25_ = FALSE;
	}
	if (_data_->_tmp25_) {
		folks_inspect_utils_print_line ("Unrecognised persona UID '%s'.", _data_->command_string);
		_data_->result = 1;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = 0;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gchar*
_folks_inspect_utils_persona_uid_completion_cb_rl_compentry_func_t (const gchar* str,
                                                                    gint a)
{
	gchar* result;
	result = folks_inspect_utils_persona_uid_completion_cb (str, a);
	return result;
}

static gchar**
_vala_array_dup10 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static gchar**
folks_inspect_commands_personas_real_complete_subcommand (FolksInspectCommand* base,
                                                          const gchar* subcommand,
                                                          gint* result_length1)
{
	FolksInspectCommandsPersonas * self;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gchar** result;
	self = (FolksInspectCommandsPersonas*) base;
	g_return_val_if_fail (subcommand != NULL, NULL);
	_tmp1_ = _tmp0_ = rl_completion_matches (subcommand, _folks_inspect_utils_persona_uid_completion_cb_rl_compentry_func_t);
	_tmp2_ = (_tmp1_ != NULL) ? _vala_array_dup10 (_tmp1_, _vala_array_length (_tmp0_)) : _tmp1_;
	_tmp2__length1 = _vala_array_length (_tmp0_);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = _tmp2__length1;
	if (result_length1) {
		*result_length1 = _tmp3__length1;
	}
	result = _tmp3_;
	return result;
}

static const gchar*
folks_inspect_commands_personas_real_get_name (FolksInspectCommand* base)
{
	const gchar* result;
	FolksInspectCommandsPersonas* self;
	self = (FolksInspectCommandsPersonas*) base;
	result = "personas";
	return result;
}

static const gchar*
folks_inspect_commands_personas_real_get_description (FolksInspectCommand* base)
{
	const gchar* result;
	FolksInspectCommandsPersonas* self;
	self = (FolksInspectCommandsPersonas*) base;
	result = "Inspect the personas currently present in the aggregator";
	return result;
}

static const gchar*
folks_inspect_commands_personas_real_get_help (FolksInspectCommand* base)
{
	const gchar* result;
	FolksInspectCommandsPersonas* self;
	self = (FolksInspectCommandsPersonas*) base;
	result = "personas                  List all known personas.\n" "personas [persona UID]    Display the details of the " "specified persona.";
	return result;
}

static void
folks_inspect_commands_personas_class_init (FolksInspectCommandsPersonasClass * klass,
                                            gpointer klass_data)
{
	folks_inspect_commands_personas_parent_class = g_type_class_peek_parent (klass);
	((FolksInspectCommandClass *) klass)->run = (void (*) (FolksInspectCommand*, const gchar*, GAsyncReadyCallback, gpointer)) folks_inspect_commands_personas_real_run;
	((FolksInspectCommandClass *) klass)->run_finish = (gint (*) (FolksInspectCommand*, GAsyncResult*)) folks_inspect_commands_personas_run_finish;
	((FolksInspectCommandClass *) klass)->complete_subcommand = (gchar** (*) (FolksInspectCommand*, const gchar*, gint*)) folks_inspect_commands_personas_real_complete_subcommand;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_name = folks_inspect_commands_personas_real_get_name;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_description = folks_inspect_commands_personas_real_get_description;
	FOLKS_INSPECT_COMMAND_CLASS (klass)->get_help = folks_inspect_commands_personas_real_get_help;
}

static void
folks_inspect_commands_personas_instance_init (FolksInspectCommandsPersonas * self,
                                               gpointer klass)
{
}

static GType
folks_inspect_commands_personas_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FolksInspectCommandsPersonasClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) folks_inspect_commands_personas_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FolksInspectCommandsPersonas), 0, (GInstanceInitFunc) folks_inspect_commands_personas_instance_init, NULL };
	GType folks_inspect_commands_personas_type_id;
	folks_inspect_commands_personas_type_id = g_type_register_static (FOLKS_INSPECT_TYPE_COMMAND, "FolksInspectCommandsPersonas", &g_define_type_info, 0);
	return folks_inspect_commands_personas_type_id;
}

GType
folks_inspect_commands_personas_get_type (void)
{
	static volatile gsize folks_inspect_commands_personas_type_id__once = 0;
	if (g_once_init_enter (&folks_inspect_commands_personas_type_id__once)) {
		GType folks_inspect_commands_personas_type_id;
		folks_inspect_commands_personas_type_id = folks_inspect_commands_personas_get_type_once ();
		g_once_init_leave (&folks_inspect_commands_personas_type_id__once, folks_inspect_commands_personas_type_id);
	}
	return folks_inspect_commands_personas_type_id__once;
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

