/* love-package.c generated by valac 0.36.9, the Vala compiler
 * generated from love-package.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <glib.h>
#include <glib-object.h>
#include <libgnome-games.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <archive.h>
#include <archive_entry.h>


#define GAMES_TYPE_LOVE_PACKAGE (games_love_package_get_type ())
#define GAMES_LOVE_PACKAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackage))
#define GAMES_LOVE_PACKAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackageClass))
#define GAMES_IS_LOVE_PACKAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LOVE_PACKAGE))
#define GAMES_IS_LOVE_PACKAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LOVE_PACKAGE))
#define GAMES_LOVE_PACKAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackageClass))

typedef struct _GamesLovePackage GamesLovePackage;
typedef struct _GamesLovePackageClass GamesLovePackageClass;
typedef struct _GamesLovePackagePrivate GamesLovePackagePrivate;
#define _games_uri_unref0(var) ((var == NULL) ? NULL : (var = (games_uri_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _archive_read_finish0(var) ((var == NULL) ? NULL : (var = (archive_read_finish (var), NULL)))

struct _GamesLovePackage {
	GObject parent_instance;
	GamesLovePackagePrivate * priv;
};

struct _GamesLovePackageClass {
	GObjectClass parent_class;
};

struct _GamesLovePackagePrivate {
	GamesUri* uri;
	GHashTable* config;
};

typedef enum  {
	GAMES_LOVE_ERROR_INVALID_PACKAGE
} GamesLoveError;
#define GAMES_LOVE_ERROR games_love_error_quark ()

static gpointer games_love_package_parent_class = NULL;
static GType games_love_package_type_id = 0;

GType games_love_package_get_type (void) G_GNUC_CONST;
#define GAMES_LOVE_PACKAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_LOVE_PACKAGE, GamesLovePackagePrivate))
enum  {
	GAMES_LOVE_PACKAGE_0_PROPERTY
};
#define GAMES_LOVE_PACKAGE_BLOCK_SIZE ((gsize) 4096)
GamesLovePackage* games_love_package_new (GamesUri* uri, GError** error);
GamesLovePackage* games_love_package_construct (GType object_type, GamesUri* uri, GError** error);
gboolean games_love_package_contains_file (GamesLovePackage* self, const gchar* path_in_archive);
GQuark games_love_error_quark (void);
gchar* games_love_package_get_file_string (GamesLovePackage* self, const gchar* path_in_archive);
static void _g_free0_ (gpointer var);
GamesUri* games_love_package_get_uri (GamesLovePackage* self);
gchar* games_love_package_get_config (GamesLovePackage* self, const gchar* key);
static gchar* games_love_package_parse_string (GamesLovePackage* self, const gchar* lua_value);
GInputStream* games_love_package_get_file_input_stream (GamesLovePackage* self, const gchar* path_in_archive);
static GInputStream* games_love_package_read_file_to_input_stream (GamesLovePackage* self, struct archive* archive, gint64 size);
static gchar* games_love_package_read_file_to_string (GamesLovePackage* self, struct archive* archive);
static guint8* _vala_array_dup1 (guint8* self, int length);
static void games_love_package_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);

static GRegex* _tmp_regex_0 = NULL;

static gpointer _games_uri_ref0 (gpointer self) {
	return self ? games_uri_ref (self) : NULL;
}


static inline GRegex* _thread_safe_regex_init (GRegex** re, const gchar * pattern, GRegexMatchFlags match_options) {
	if (g_once_init_enter ((volatile gsize*) re)) {
		GRegex* val = g_regex_new (pattern, match_options, 0, NULL);
		g_once_init_leave ((volatile gsize*) re, (gsize) val);
	}
	return *re;
}


static gpointer _g_regex_ref0 (gpointer self) {
	return self ? g_regex_ref (self) : NULL;
}


static void _g_free0_ (gpointer var) {
	var = (g_free (var), NULL);
}


GamesLovePackage* games_love_package_construct (GType object_type, GamesUri* uri, GError** error) {
	GamesLovePackage * self = NULL;
	GamesUri* _tmp0_;
	GamesUri* _tmp1_;
	gboolean _tmp2_;
	gchar* config_file = NULL;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	GRegex* regex = NULL;
	GRegex* _tmp15_;
	GHashFunc _tmp16_;
	GEqualFunc _tmp17_;
	GHashTable* _tmp18_;
	gchar** lines = NULL;
	const gchar* _tmp19_;
	gchar** _tmp20_;
	gchar** _tmp21_;
	gint lines_length1;
	gint _lines_size_;
	GMatchInfo* match_info = NULL;
	gchar** _tmp22_;
	gint _tmp22__length1;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (uri != NULL, NULL);
	self = (GamesLovePackage*) g_object_new (object_type, NULL);
	_tmp0_ = uri;
	_tmp1_ = _games_uri_ref0 (_tmp0_);
	_games_uri_unref0 (self->priv->uri);
	self->priv->uri = _tmp1_;
	_tmp2_ = games_love_package_contains_file (self, "main.lua");
	if (!_tmp2_) {
		GamesUri* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		GError* _tmp6_;
		GError* _tmp7_;
		_tmp3_ = uri;
		_tmp4_ = games_uri_to_string (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = g_error_new (GAMES_LOVE_ERROR, GAMES_LOVE_ERROR_INVALID_PACKAGE, _ ("This doesn’t represent a valid LÖVE package: “%s”."), _tmp5_);
		_tmp7_ = _tmp6_;
		_g_free0 (_tmp5_);
		_inner_error_ = _tmp7_;
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp8_ = games_love_package_get_file_string (self, "conf.lua");
	config_file = _tmp8_;
	_tmp9_ = config_file;
	if (_tmp9_ == NULL) {
		GamesUri* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		GError* _tmp13_;
		GError* _tmp14_;
		_tmp10_ = uri;
		_tmp11_ = games_uri_to_string (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_error_new (GAMES_LOVE_ERROR, GAMES_LOVE_ERROR_INVALID_PACKAGE, _ ("This doesn’t represent a valid LÖVE package: “%s”."), _tmp12_);
		_tmp14_ = _tmp13_;
		_g_free0 (_tmp12_);
		_inner_error_ = _tmp14_;
		g_propagate_error (error, _inner_error_);
		_g_free0 (config_file);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp15_ = _g_regex_ref0 (_thread_safe_regex_init (&_tmp_regex_0, "^\\s*[^\\s]+\\.([^\\s\\.]+)\\s*=\\s*(.+?)\\s*$", 0));
	regex = _tmp15_;
	_tmp16_ = g_str_hash;
	_tmp17_ = g_str_equal;
	_tmp18_ = g_hash_table_new_full (_tmp16_, _tmp17_, _g_free0_, _g_free0_);
	_g_hash_table_unref0 (self->priv->config);
	self->priv->config = _tmp18_;
	_tmp19_ = config_file;
	_tmp21_ = _tmp20_ = g_strsplit (_tmp19_, "\n", 0);
	lines = _tmp21_;
	lines_length1 = _vala_array_length (_tmp20_);
	_lines_size_ = lines_length1;
	_tmp22_ = lines;
	_tmp22__length1 = lines_length1;
	{
		gchar** line_collection = NULL;
		gint line_collection_length1 = 0;
		gint _line_collection_size_ = 0;
		gint line_it = 0;
		line_collection = _tmp22_;
		line_collection_length1 = _tmp22__length1;
		for (line_it = 0; line_it < _tmp22__length1; line_it = line_it + 1) {
			gchar* _tmp23_;
			gchar* line = NULL;
			_tmp23_ = g_strdup (line_collection[line_it]);
			line = _tmp23_;
			{
				GRegex* _tmp24_;
				const gchar* _tmp25_;
				GMatchInfo* _tmp26_ = NULL;
				gboolean _tmp27_;
				_tmp24_ = regex;
				_tmp25_ = line;
				_tmp27_ = g_regex_match (_tmp24_, _tmp25_, G_REGEX_MATCH_ANCHORED, &_tmp26_);
				_g_match_info_unref0 (match_info);
				match_info = _tmp26_;
				if (_tmp27_) {
					gchar* key = NULL;
					GMatchInfo* _tmp28_;
					gchar* _tmp29_;
					gchar* lua_value = NULL;
					GMatchInfo* _tmp30_;
					gchar* _tmp31_;
					GHashTable* _tmp32_;
					const gchar* _tmp33_;
					gchar* _tmp34_;
					const gchar* _tmp35_;
					gchar* _tmp36_;
					_tmp28_ = match_info;
					_tmp29_ = g_match_info_fetch (_tmp28_, 1);
					key = _tmp29_;
					_tmp30_ = match_info;
					_tmp31_ = g_match_info_fetch (_tmp30_, 2);
					lua_value = _tmp31_;
					_tmp32_ = self->priv->config;
					_tmp33_ = key;
					_tmp34_ = g_strdup (_tmp33_);
					_tmp35_ = lua_value;
					_tmp36_ = g_strdup (_tmp35_);
					g_hash_table_insert (_tmp32_, _tmp34_, _tmp36_);
					_g_free0 (lua_value);
					_g_free0 (key);
				}
				_g_free0 (line);
			}
		}
	}
	_g_match_info_unref0 (match_info);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	_g_regex_unref0 (regex);
	_g_free0 (config_file);
	return self;
}


GamesLovePackage* games_love_package_new (GamesUri* uri, GError** error) {
	return games_love_package_construct (GAMES_TYPE_LOVE_PACKAGE, uri, error);
}


GamesUri* games_love_package_get_uri (GamesLovePackage* self) {
	GamesUri* result = NULL;
	GamesUri* _tmp0_;
	GamesUri* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->uri;
	_tmp1_ = _games_uri_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}


gchar* games_love_package_get_config (GamesLovePackage* self, const gchar* key) {
	gchar* result = NULL;
	GHashTable* _tmp0_;
	const gchar* _tmp1_;
	gboolean _tmp2_;
	GHashTable* _tmp3_;
	const gchar* _tmp4_;
	gconstpointer _tmp5_;
	gchar* _tmp6_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	_tmp0_ = self->priv->config;
	_tmp1_ = key;
	_tmp2_ = g_hash_table_contains (_tmp0_, _tmp1_);
	if (!_tmp2_) {
		result = NULL;
		return result;
	}
	_tmp3_ = self->priv->config;
	_tmp4_ = key;
	_tmp5_ = g_hash_table_lookup (_tmp3_, _tmp4_);
	_tmp6_ = games_love_package_parse_string (self, (const gchar*) _tmp5_);
	result = _tmp6_;
	return result;
}


gboolean games_love_package_contains_file (GamesLovePackage* self, const gchar* path_in_archive) {
	gboolean result = FALSE;
	GFile* file = NULL;
	GamesUri* _tmp0_;
	GFile* _tmp1_;
	gchar* path = NULL;
	GFile* _tmp2_;
	gchar* _tmp3_;
	struct archive* archive = NULL;
	struct archive* _tmp4_;
	struct archive* _tmp5_;
	struct archive* _tmp6_;
	int _result_ = 0;
	struct archive* _tmp7_;
	const gchar* _tmp8_;
	int _tmp9_;
	int _tmp10_;
	struct archive_entry* entry = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (path_in_archive != NULL, FALSE);
	_tmp0_ = self->priv->uri;
	_tmp1_ = games_uri_to_file (_tmp0_);
	file = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = g_file_get_path (_tmp2_);
	path = _tmp3_;
	_tmp4_ = archive_read_new ();
	archive = _tmp4_;
	_tmp5_ = archive;
	archive_read_support_filter_all (_tmp5_);
	_tmp6_ = archive;
	archive_read_support_format_all (_tmp6_);
	_tmp7_ = archive;
	_tmp8_ = path;
	_tmp9_ = archive_read_open_filename (_tmp7_, _tmp8_, GAMES_LOVE_PACKAGE_BLOCK_SIZE);
	_result_ = _tmp9_;
	_tmp10_ = _result_;
	if (_tmp10_ != ARCHIVE_OK) {
		result = FALSE;
		_archive_read_finish0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	while (TRUE) {
		struct archive* _tmp11_;
		struct archive_entry* _tmp12_ = NULL;
		int _tmp13_;
		gchar* file_path = NULL;
		struct archive_entry* _tmp14_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		_tmp11_ = archive;
		_tmp13_ = archive_read_next_header (_tmp11_, &_tmp12_);
		entry = _tmp12_;
		if (!(_tmp13_ == ARCHIVE_OK)) {
			break;
		}
		_tmp14_ = entry;
		_tmp15_ = archive_entry_pathname (_tmp14_);
		_tmp16_ = g_strdup (_tmp15_);
		file_path = _tmp16_;
		_tmp17_ = file_path;
		_tmp18_ = path_in_archive;
		if (g_strcmp0 (_tmp17_, _tmp18_) != 0) {
			_g_free0 (file_path);
			continue;
		}
		result = TRUE;
		_g_free0 (file_path);
		_archive_read_finish0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	result = FALSE;
	_archive_read_finish0 (archive);
	_g_free0 (path);
	_g_object_unref0 (file);
	return result;
}


GInputStream* games_love_package_get_file_input_stream (GamesLovePackage* self, const gchar* path_in_archive) {
	GInputStream* result = NULL;
	GFile* file = NULL;
	GamesUri* _tmp0_;
	GFile* _tmp1_;
	gchar* path = NULL;
	GFile* _tmp2_;
	gchar* _tmp3_;
	struct archive* archive = NULL;
	struct archive* _tmp4_;
	struct archive* _tmp5_;
	struct archive* _tmp6_;
	int _result_ = 0;
	struct archive* _tmp7_;
	const gchar* _tmp8_;
	int _tmp9_;
	int _tmp10_;
	struct archive_entry* entry = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (path_in_archive != NULL, NULL);
	_tmp0_ = self->priv->uri;
	_tmp1_ = games_uri_to_file (_tmp0_);
	file = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = g_file_get_path (_tmp2_);
	path = _tmp3_;
	_tmp4_ = archive_read_new ();
	archive = _tmp4_;
	_tmp5_ = archive;
	archive_read_support_filter_all (_tmp5_);
	_tmp6_ = archive;
	archive_read_support_format_all (_tmp6_);
	_tmp7_ = archive;
	_tmp8_ = path;
	_tmp9_ = archive_read_open_filename (_tmp7_, _tmp8_, GAMES_LOVE_PACKAGE_BLOCK_SIZE);
	_result_ = _tmp9_;
	_tmp10_ = _result_;
	if (_tmp10_ != ARCHIVE_OK) {
		result = NULL;
		_archive_read_finish0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	while (TRUE) {
		struct archive* _tmp11_;
		struct archive_entry* _tmp12_ = NULL;
		int _tmp13_;
		gchar* file_path = NULL;
		struct archive_entry* _tmp14_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		gint64 size = 0LL;
		struct archive_entry* _tmp19_;
		gint64 _tmp20_;
		struct archive* _tmp21_;
		gint64 _tmp22_;
		GInputStream* _tmp23_;
		_tmp11_ = archive;
		_tmp13_ = archive_read_next_header (_tmp11_, &_tmp12_);
		entry = _tmp12_;
		if (!(_tmp13_ == ARCHIVE_OK)) {
			break;
		}
		_tmp14_ = entry;
		_tmp15_ = archive_entry_pathname (_tmp14_);
		_tmp16_ = g_strdup (_tmp15_);
		file_path = _tmp16_;
		_tmp17_ = file_path;
		_tmp18_ = path_in_archive;
		if (g_strcmp0 (_tmp17_, _tmp18_) != 0) {
			_g_free0 (file_path);
			continue;
		}
		_tmp19_ = entry;
		_tmp20_ = archive_entry_size (_tmp19_);
		size = _tmp20_;
		_tmp21_ = archive;
		_tmp22_ = size;
		_tmp23_ = games_love_package_read_file_to_input_stream (self, _tmp21_, _tmp22_);
		result = _tmp23_;
		_g_free0 (file_path);
		_archive_read_finish0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	result = NULL;
	_archive_read_finish0 (archive);
	_g_free0 (path);
	_g_object_unref0 (file);
	return result;
}


gchar* games_love_package_get_file_string (GamesLovePackage* self, const gchar* path_in_archive) {
	gchar* result = NULL;
	GFile* file = NULL;
	GamesUri* _tmp0_;
	GFile* _tmp1_;
	gchar* path = NULL;
	GFile* _tmp2_;
	gchar* _tmp3_;
	struct archive* archive = NULL;
	struct archive* _tmp4_;
	struct archive* _tmp5_;
	struct archive* _tmp6_;
	int _result_ = 0;
	struct archive* _tmp7_;
	const gchar* _tmp8_;
	int _tmp9_;
	int _tmp10_;
	struct archive_entry* entry = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (path_in_archive != NULL, NULL);
	_tmp0_ = self->priv->uri;
	_tmp1_ = games_uri_to_file (_tmp0_);
	file = _tmp1_;
	_tmp2_ = file;
	_tmp3_ = g_file_get_path (_tmp2_);
	path = _tmp3_;
	_tmp4_ = archive_read_new ();
	archive = _tmp4_;
	_tmp5_ = archive;
	archive_read_support_filter_all (_tmp5_);
	_tmp6_ = archive;
	archive_read_support_format_all (_tmp6_);
	_tmp7_ = archive;
	_tmp8_ = path;
	_tmp9_ = archive_read_open_filename (_tmp7_, _tmp8_, GAMES_LOVE_PACKAGE_BLOCK_SIZE);
	_result_ = _tmp9_;
	_tmp10_ = _result_;
	if (_tmp10_ != ARCHIVE_OK) {
		result = NULL;
		_archive_read_finish0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	while (TRUE) {
		struct archive* _tmp11_;
		struct archive_entry* _tmp12_ = NULL;
		int _tmp13_;
		gchar* file_path = NULL;
		struct archive_entry* _tmp14_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		struct archive* _tmp19_;
		gchar* _tmp20_;
		_tmp11_ = archive;
		_tmp13_ = archive_read_next_header (_tmp11_, &_tmp12_);
		entry = _tmp12_;
		if (!(_tmp13_ == ARCHIVE_OK)) {
			break;
		}
		_tmp14_ = entry;
		_tmp15_ = archive_entry_pathname (_tmp14_);
		_tmp16_ = g_strdup (_tmp15_);
		file_path = _tmp16_;
		_tmp17_ = file_path;
		_tmp18_ = path_in_archive;
		if (g_strcmp0 (_tmp17_, _tmp18_) != 0) {
			_g_free0 (file_path);
			continue;
		}
		_tmp19_ = archive;
		_tmp20_ = games_love_package_read_file_to_string (self, _tmp19_);
		result = _tmp20_;
		_g_free0 (file_path);
		_archive_read_finish0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	result = NULL;
	_archive_read_finish0 (archive);
	_g_free0 (path);
	_g_object_unref0 (file);
	return result;
}


static guint8* _vala_array_dup1 (guint8* self, int length) {
	return g_memdup (self, length * sizeof (guint8));
}


static GInputStream* games_love_package_read_file_to_input_stream (GamesLovePackage* self, struct archive* archive, gint64 size) {
	GInputStream* result = NULL;
	guint8* content = NULL;
	gint64 _tmp0_;
	guint8* _tmp1_;
	gint content_length1;
	gint _content_size_;
	struct archive* _tmp2_;
	gint64 _tmp3_;
	guint8* _tmp4_;
	gint _tmp4__length1;
	GDestroyNotify _tmp5_;
	GMemoryInputStream* _tmp6_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (archive != NULL, NULL);
	_tmp0_ = size;
	_tmp1_ = g_new0 (guint8, _tmp0_);
	content = _tmp1_;
	content_length1 = _tmp0_;
	_content_size_ = content_length1;
	_tmp2_ = archive;
	_tmp3_ = size;
	archive_read_data (_tmp2_, content, (gsize) _tmp3_);
	_tmp4_ = (content != NULL) ? _vala_array_dup1 (content, content_length1) : ((gpointer) content);
	_tmp4__length1 = content_length1;
	_tmp5_ = g_free;
	_tmp6_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_tmp4_, _tmp4__length1, _tmp5_);
	result = (GInputStream*) _tmp6_;
	content = (g_free (content), NULL);
	return result;
}


static gchar* games_love_package_read_file_to_string (GamesLovePackage* self, struct archive* archive) {
	gchar* result = NULL;
	gchar* content = NULL;
	gchar* _tmp0_;
	gchar buffer[GAMES_LOVE_PACKAGE_BLOCK_SIZE] = {0};
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (archive != NULL, NULL);
	_tmp0_ = g_strdup ("");
	content = _tmp0_;
	while (TRUE) {
		struct archive* _tmp1_;
		gssize _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp1_ = archive;
		_tmp2_ = archive_read_data (_tmp1_, buffer, GAMES_LOVE_PACKAGE_BLOCK_SIZE);
		if (!(_tmp2_ != ((gssize) 0))) {
			break;
		}
		_tmp3_ = content;
		_tmp4_ = g_strconcat (_tmp3_, (const gchar*) buffer, NULL);
		_g_free0 (content);
		content = _tmp4_;
	}
	result = content;
	return result;
}


static gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	glong _tmp2_;
	glong _tmp5_;
	gboolean _tmp8_ = FALSE;
	glong _tmp9_;
	gboolean _tmp12_ = FALSE;
	glong _tmp13_;
	glong _tmp16_;
	glong _tmp17_;
	glong _tmp18_;
	glong _tmp19_;
	glong _tmp20_;
	gchar* _tmp21_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	_tmp2_ = start;
	if (_tmp2_ < ((glong) 0)) {
		glong _tmp3_;
		glong _tmp4_;
		_tmp3_ = string_length;
		_tmp4_ = start;
		start = _tmp3_ + _tmp4_;
	}
	_tmp5_ = end;
	if (_tmp5_ < ((glong) 0)) {
		glong _tmp6_;
		glong _tmp7_;
		_tmp6_ = string_length;
		_tmp7_ = end;
		end = _tmp6_ + _tmp7_;
	}
	_tmp9_ = start;
	if (_tmp9_ >= ((glong) 0)) {
		glong _tmp10_;
		glong _tmp11_;
		_tmp10_ = start;
		_tmp11_ = string_length;
		_tmp8_ = _tmp10_ <= _tmp11_;
	} else {
		_tmp8_ = FALSE;
	}
	g_return_val_if_fail (_tmp8_, NULL);
	_tmp13_ = end;
	if (_tmp13_ >= ((glong) 0)) {
		glong _tmp14_;
		glong _tmp15_;
		_tmp14_ = end;
		_tmp15_ = string_length;
		_tmp12_ = _tmp14_ <= _tmp15_;
	} else {
		_tmp12_ = FALSE;
	}
	g_return_val_if_fail (_tmp12_, NULL);
	_tmp16_ = start;
	_tmp17_ = end;
	g_return_val_if_fail (_tmp16_ <= _tmp17_, NULL);
	_tmp18_ = start;
	_tmp19_ = end;
	_tmp20_ = start;
	_tmp21_ = g_strndup (((gchar*) self) + _tmp18_, (gsize) (_tmp19_ - _tmp20_));
	result = _tmp21_;
	return result;
}


static gchar* games_love_package_parse_string (GamesLovePackage* self, const gchar* lua_value) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	const gchar* _tmp3_;
	gboolean _tmp4_;
	const gchar* _tmp5_;
	gboolean _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (lua_value != NULL, NULL);
	_tmp0_ = lua_value;
	_tmp1_ = strlen (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ < 2) {
		result = NULL;
		return result;
	}
	_tmp3_ = lua_value;
	_tmp4_ = g_str_has_prefix (_tmp3_, "\"");
	if (!_tmp4_) {
		result = NULL;
		return result;
	}
	_tmp5_ = lua_value;
	_tmp6_ = g_str_has_suffix (_tmp5_, "\"");
	if (!_tmp6_) {
		result = NULL;
		return result;
	}
	_tmp7_ = lua_value;
	_tmp8_ = string_slice (_tmp7_, (glong) 1, (glong) -1);
	result = _tmp8_;
	return result;
}


static void games_love_package_class_init (GamesLovePackageClass * klass) {
	games_love_package_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesLovePackagePrivate));
	G_OBJECT_CLASS (klass)->finalize = games_love_package_finalize;
}


static void games_love_package_instance_init (GamesLovePackage * self) {
	self->priv = GAMES_LOVE_PACKAGE_GET_PRIVATE (self);
}


static void games_love_package_finalize (GObject * obj) {
	GamesLovePackage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_LOVE_PACKAGE, GamesLovePackage);
	_games_uri_unref0 (self->priv->uri);
	_g_hash_table_unref0 (self->priv->config);
	G_OBJECT_CLASS (games_love_package_parent_class)->finalize (obj);
}


GType games_love_package_get_type (void) {
	return games_love_package_type_id;
}


GType games_love_package_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesLovePackageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_love_package_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesLovePackage), 0, (GInstanceInitFunc) games_love_package_instance_init, NULL };
	games_love_package_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesLovePackage", &g_define_type_info, 0);
	return games_love_package_type_id;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


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



