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

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

#include <glib-object.h>
#include "gnome-games.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <archive.h>
#include <archive_entry.h>
#include "games-love-plugin.h"

#define GAMES_LOVE_PACKAGE_BLOCK_SIZE ((gsize) 4096)
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#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;
enum  {
	GAMES_LOVE_PACKAGE_0_PROPERTY,
	GAMES_LOVE_PACKAGE_NUM_PROPERTIES
};
static GParamSpec* games_love_package_properties[GAMES_LOVE_PACKAGE_NUM_PROPERTIES];
#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 GAMES_TYPE_LOVE_ERROR (games_love_error_get_type ())
#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_free0(var) ((var == NULL) ? NULL : (var = (archive_read_free (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 gint GamesLovePackage_private_offset;
static gpointer games_love_package_parent_class = NULL;
static GType games_love_package_type_id = 0;

GType games_love_package_register_type (GTypeModule * module);
VALA_EXTERN GType games_love_package_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesLovePackage* games_love_package_new (GamesUri* uri,
                                          GError** error);
VALA_EXTERN GamesLovePackage* games_love_package_construct (GType object_type,
                                                GamesUri* uri,
                                                GError** error);
VALA_EXTERN gboolean games_love_package_contains_file (GamesLovePackage* self,
                                           const gchar* path_in_archive);
VALA_EXTERN GQuark games_love_error_quark (void);
VALA_EXTERN GType games_love_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* games_love_package_get_file_string (GamesLovePackage* self,
                                           const gchar* path_in_archive);
static void _g_free0_ (gpointer var);
VALA_EXTERN GamesUri* games_love_package_get_uri (GamesLovePackage* self);
VALA_EXTERN gchar* games_love_package_get_config (GamesLovePackage* self,
                                      const gchar* key);
static gchar* games_love_package_parse_string (GamesLovePackage* self,
                                        const gchar* lua_value);
VALA_EXTERN 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,
                          gssize length);
static void games_love_package_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GRegex* _tmp_regex_0 = NULL;

static inline gpointer
games_love_package_get_instance_private (GamesLovePackage* self)
{
	return G_STRUCT_MEMBER_P (self, GamesLovePackage_private_offset);
}

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

gboolean
games_love_package_contains_file (GamesLovePackage* self,
                                  const gchar* path_in_archive)
{
	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_;
	struct archive_entry* entry = NULL;
	gboolean result;
	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;
	_result_ = archive_read_open_filename (_tmp7_, _tmp8_, GAMES_LOVE_PACKAGE_BLOCK_SIZE);
	if (_result_ != ARCHIVE_OK) {
		result = FALSE;
		_archive_read_free0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	while (TRUE) {
		struct archive* _tmp9_;
		struct archive_entry* _tmp10_ = NULL;
		int _tmp11_;
		gchar* file_path = NULL;
		struct archive_entry* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		const gchar* _tmp15_;
		_tmp9_ = archive;
		_tmp11_ = archive_read_next_header (_tmp9_, &_tmp10_);
		entry = _tmp10_;
		if (!(_tmp11_ == ARCHIVE_OK)) {
			break;
		}
		_tmp12_ = entry;
		_tmp13_ = archive_entry_pathname (_tmp12_);
		_tmp14_ = g_strdup (_tmp13_);
		file_path = _tmp14_;
		_tmp15_ = file_path;
		if (g_strcmp0 (_tmp15_, path_in_archive) != 0) {
			_g_free0 (file_path);
			continue;
		}
		result = TRUE;
		_g_free0 (file_path);
		_archive_read_free0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	result = FALSE;
	_archive_read_free0 (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)
{
	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_;
	struct archive_entry* entry = NULL;
	GInputStream* result;
	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;
	_result_ = archive_read_open_filename (_tmp7_, _tmp8_, GAMES_LOVE_PACKAGE_BLOCK_SIZE);
	if (_result_ != ARCHIVE_OK) {
		result = NULL;
		_archive_read_free0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	while (TRUE) {
		struct archive* _tmp9_;
		struct archive_entry* _tmp10_ = NULL;
		int _tmp11_;
		gchar* file_path = NULL;
		struct archive_entry* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		const gchar* _tmp15_;
		la_int64_t size = {0};
		struct archive_entry* _tmp16_;
		struct archive* _tmp17_;
		GInputStream* _tmp18_;
		_tmp9_ = archive;
		_tmp11_ = archive_read_next_header (_tmp9_, &_tmp10_);
		entry = _tmp10_;
		if (!(_tmp11_ == ARCHIVE_OK)) {
			break;
		}
		_tmp12_ = entry;
		_tmp13_ = archive_entry_pathname (_tmp12_);
		_tmp14_ = g_strdup (_tmp13_);
		file_path = _tmp14_;
		_tmp15_ = file_path;
		if (g_strcmp0 (_tmp15_, path_in_archive) != 0) {
			_g_free0 (file_path);
			continue;
		}
		_tmp16_ = entry;
		size = archive_entry_size (_tmp16_);
		_tmp17_ = archive;
		_tmp18_ = games_love_package_read_file_to_input_stream (self, _tmp17_, (gint64) size);
		result = _tmp18_;
		_g_free0 (file_path);
		_archive_read_free0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	result = NULL;
	_archive_read_free0 (archive);
	_g_free0 (path);
	_g_object_unref0 (file);
	return result;
}

gchar*
games_love_package_get_file_string (GamesLovePackage* self,
                                    const gchar* path_in_archive)
{
	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_;
	struct archive_entry* entry = NULL;
	gchar* result;
	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;
	_result_ = archive_read_open_filename (_tmp7_, _tmp8_, GAMES_LOVE_PACKAGE_BLOCK_SIZE);
	if (_result_ != ARCHIVE_OK) {
		result = NULL;
		_archive_read_free0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	while (TRUE) {
		struct archive* _tmp9_;
		struct archive_entry* _tmp10_ = NULL;
		int _tmp11_;
		gchar* file_path = NULL;
		struct archive_entry* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		const gchar* _tmp15_;
		struct archive* _tmp16_;
		gchar* _tmp17_;
		_tmp9_ = archive;
		_tmp11_ = archive_read_next_header (_tmp9_, &_tmp10_);
		entry = _tmp10_;
		if (!(_tmp11_ == ARCHIVE_OK)) {
			break;
		}
		_tmp12_ = entry;
		_tmp13_ = archive_entry_pathname (_tmp12_);
		_tmp14_ = g_strdup (_tmp13_);
		file_path = _tmp14_;
		_tmp15_ = file_path;
		if (g_strcmp0 (_tmp15_, path_in_archive) != 0) {
			_g_free0 (file_path);
			continue;
		}
		_tmp16_ = archive;
		_tmp17_ = games_love_package_read_file_to_string (self, _tmp16_);
		result = _tmp17_;
		_g_free0 (file_path);
		_archive_read_free0 (archive);
		_g_free0 (path);
		_g_object_unref0 (file);
		return result;
	}
	result = NULL;
	_archive_read_free0 (archive);
	_g_free0 (path);
	_g_object_unref0 (file);
	return result;
}

static guint8*
_vala_array_dup1 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

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

static gchar*
games_love_package_read_file_to_string (GamesLovePackage* self,
                                        struct archive* archive)
{
	gchar* content = NULL;
	gchar* _tmp0_;
	guint8* buffer = NULL;
	guint8* _tmp1_;
	gint buffer_length1;
	gint _buffer_size_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (archive != NULL, NULL);
	_tmp0_ = g_strdup ("");
	content = _tmp0_;
	_tmp1_ = g_new0 (guint8, GAMES_LOVE_PACKAGE_BLOCK_SIZE);
	buffer = _tmp1_;
	buffer_length1 = GAMES_LOVE_PACKAGE_BLOCK_SIZE;
	_buffer_size_ = buffer_length1;
	while (TRUE) {
		guint8* _tmp2_;
		gint _tmp2__length1;
		const gchar* _tmp3_;
		guint8* _tmp4_;
		gint _tmp4__length1;
		gchar* _tmp5_;
		_tmp2_ = buffer;
		_tmp2__length1 = buffer_length1;
		if (!(archive_read_data (archive, _tmp2_, (size_t) _tmp2__length1) != ((gssize) 0))) {
			break;
		}
		_tmp3_ = content;
		_tmp4_ = buffer;
		_tmp4__length1 = buffer_length1;
		_tmp5_ = g_strconcat (_tmp3_, (const gchar*) _tmp4_, NULL);
		_g_free0 (content);
		content = _tmp5_;
	}
	result = content;
	buffer = (g_free (buffer), NULL);
	return result;
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

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

static void
games_love_package_class_init (GamesLovePackageClass * klass,
                               gpointer klass_data)
{
	games_love_package_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesLovePackage_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_love_package_finalize;
}

static void
games_love_package_instance_init (GamesLovePackage * self,
                                  gpointer klass)
{
	self->priv = games_love_package_get_instance_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);
	GamesLovePackage_private_offset = sizeof (GamesLovePackagePrivate);
	return games_love_package_type_id;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

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

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

