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

#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <config.h>
#include <stdio.h>
#include "wixl.h"
#include <gio/gio.h>

#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

typedef enum  {
	WIXL_ARCH_X86 = 0,
	WIXL_ARCH_INTEL = 0,
	WIXL_ARCH_IA64 = 1,
	WIXL_ARCH_INTEL64 = 1,
	WIXL_ARCH_X64
} WixlArch;

#define WIXL_TYPE_ARCH (wixl_arch_get_type ())
typedef enum  {
	WIXL_EXTENSION_UI = 0
} WixlExtension;

#define WIXL_TYPE_EXTENSION (wixl_extension_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define WIXL_TYPE_WIX_BUILDER (wixl_wix_builder_get_type ())
#define WIXL_WIX_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIXL_TYPE_WIX_BUILDER, WixlWixBuilder))
#define WIXL_WIX_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIXL_TYPE_WIX_BUILDER, WixlWixBuilderClass))
#define WIXL_IS_WIX_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIXL_TYPE_WIX_BUILDER))
#define WIXL_IS_WIX_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIXL_TYPE_WIX_BUILDER))
#define WIXL_WIX_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIXL_TYPE_WIX_BUILDER, WixlWixBuilderClass))

typedef struct _WixlWixBuilder WixlWixBuilder;
typedef struct _WixlWixBuilderClass WixlWixBuilderClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define WIXL_TYPE_MSI_DATABASE (wixl_msi_database_get_type ())
#define WIXL_MSI_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIXL_TYPE_MSI_DATABASE, WixlMsiDatabase))
#define WIXL_MSI_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIXL_TYPE_MSI_DATABASE, WixlMsiDatabaseClass))
#define WIXL_IS_MSI_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIXL_TYPE_MSI_DATABASE))
#define WIXL_IS_MSI_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIXL_TYPE_MSI_DATABASE))
#define WIXL_MSI_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIXL_TYPE_MSI_DATABASE, WixlMsiDatabaseClass))

typedef struct _WixlMsiDatabase WixlMsiDatabase;
typedef struct _WixlMsiDatabaseClass WixlMsiDatabaseClass;

VALA_EXTERN gboolean wixl_version;
gboolean wixl_version = FALSE;
VALA_EXTERN gboolean wixl_verbose;
gboolean wixl_verbose = FALSE;
VALA_EXTERN gboolean wixl_preproc;
gboolean wixl_preproc = FALSE;
VALA_EXTERN gchar* wixl_output;
gchar* wixl_output = NULL;
VALA_EXTERN gchar** wixl_files;
gchar** wixl_files = NULL;
VALA_EXTERN gchar** wixl_defines;
gchar** wixl_defines = NULL;
VALA_EXTERN gchar** wixl_opt_includedirs;
gchar** wixl_opt_includedirs = NULL;
VALA_EXTERN gchar** wixl_opt_extensions;
gchar** wixl_opt_extensions = NULL;
VALA_EXTERN gchar** wixl_includedirs;
VALA_EXTERN gint wixl_includedirs_length1;
gchar** wixl_includedirs = NULL;
gint wixl_includedirs_length1 = 0;
static gint _wixl_includedirs_size_ = 0;
VALA_EXTERN gchar* wixl_wxidir;
gchar* wixl_wxidir = NULL;
VALA_EXTERN gchar* wixl_extdir;
gchar* wixl_extdir = NULL;
VALA_EXTERN WixlArch wixl_arch;
WixlArch wixl_arch = WIXL_ARCH_X86;
VALA_EXTERN WixlExtension* wixl_extensions;
VALA_EXTERN gint wixl_extensions_length1;
WixlExtension* wixl_extensions = NULL;
gint wixl_extensions_length1 = 0;
static gint _wixl_extensions_size_ = 0;

VALA_EXTERN GType wixl_arch_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType wixl_extension_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gboolean wixl_parse_arch (const gchar* option_name,
                          const gchar* value,
                          void* data,
                          GError** error);
VALA_EXTERN WixlArch wixl_arch_from_string (const gchar* s,
                                GError** error);
static gint wixl_main (gchar** args,
                gint args_length1);
static gchar** _vala_array_dup7 (gchar** self,
                          gssize length);
static void _vala_array_add10 (gchar** * array,
                        gint* length,
                        gint* size,
                        gchar* value);
VALA_EXTERN WixlExtension wixl_extension_from_string (const gchar* s,
                                          GError** error);
static void _vala_array_add11 (WixlExtension* * array,
                        gint* length,
                        gint* size,
                        WixlExtension value);
VALA_EXTERN GType wixl_wix_builder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN WixlWixBuilder* wixl_wix_builder_new (gchar** includedirs,
                                      gint includedirs_length1,
                                      WixlArch arch,
                                      WixlExtension* extensions,
                                      gint extensions_length1,
                                      const gchar* extdir);
VALA_EXTERN WixlWixBuilder* wixl_wix_builder_construct (GType object_type,
                                            gchar** includedirs,
                                            gint includedirs_length1,
                                            WixlArch arch,
                                            WixlExtension* extensions,
                                            gint extensions_length1,
                                            const gchar* extdir);
VALA_EXTERN void wixl_wix_builder_define_variable (WixlWixBuilder* self,
                                       const gchar* name,
                                       const gchar* value);
VALA_EXTERN void wixl_wix_builder_load_file (WixlWixBuilder* self,
                                 GFile* file,
                                 gboolean preproc_only,
                                 GError** error);
VALA_EXTERN void wixl_wix_builder_add_path (WixlWixBuilder* self,
                                const gchar* p);
VALA_EXTERN GType wixl_msi_database_get_type (void) G_GNUC_CONST ;
VALA_EXTERN WixlMsiDatabase* wixl_wix_builder_build (WixlWixBuilder* self,
                                         GError** error);
VALA_EXTERN void wixl_msi_database_build (WixlMsiDatabase* self,
                              const gchar* filename,
                              GError** error);
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);

const GOptionEntry WIXL_options[12] = {{"version", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &wixl_version, N_ ("Display version number"), NULL}, {"verbose", 'v', (gint) 0, G_OPTION_ARG_NONE, &wixl_verbose, N_ ("Verbose output"), NULL}, {"output", 'o', (gint) 0, G_OPTION_ARG_FILENAME, &wixl_output, N_ ("Output file"), NULL}, {"define", 'D', (gint) 0, G_OPTION_ARG_STRING_ARRAY, &wixl_defines, N_ ("Define variable"), NULL}, {"arch", 'a', (gint) 0, G_OPTION_ARG_CALLBACK, (void*) wixl_parse_arch, N_ ("Target architecture"), NULL}, {"includedir", 'I', (gint) 0, G_OPTION_ARG_STRING_ARRAY, &wixl_opt_includedirs, N_ ("Include directory"), NULL}, {"extdir", (gchar) 0, (gint) 0, G_OPTION_ARG_STRING, &wixl_extdir, N_ ("System extension directory"), NULL}, {"wxidir", (gchar) 0, (gint) 0, G_OPTION_ARG_STRING, &wixl_wxidir, N_ ("System include directory"), NULL}, {"only-preproc", 'E', (gint) 0, G_OPTION_ARG_NONE, &wixl_preproc, N_ ("Stop after the preprocessing stage"), NULL}, {"ext", (gchar) 0, (gint) 0, G_OPTION_ARG_STRING_ARRAY, &wixl_opt_extensions, N_ ("Specify an extension"), NULL}, {"", (gchar) 0, (gint) 0, G_OPTION_ARG_FILENAME_ARRAY, &wixl_files, NULL, N_ ("INPUT_FILE1 [INPUT_FILE2]...")}, {NULL}};

gboolean
wixl_parse_arch (const gchar* option_name,
                 const gchar* value,
                 void* data,
                 GError** error)
{
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (option_name != NULL, FALSE);
	g_return_val_if_fail (value != NULL, FALSE);
	{
		WixlArch _tmp0_ = 0;
		_tmp0_ = wixl_arch_from_string (value, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		wixl_arch = _tmp0_;
	}
	goto __finally0;
	__catch0_g_error:
	{
		gchar* _tmp1_;
		gchar* _tmp2_;
		GError* _tmp3_;
		GError* _tmp4_;
		g_clear_error (&_inner_error0_);
		_tmp1_ = g_strdup_printf (_ ("arch of type '%s' is not supported"), value);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_error_new_literal (G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, _tmp2_);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		_inner_error0_ = _tmp4_;
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_OPTION_ERROR) {
			gboolean _tmp5_ = FALSE;
			g_propagate_error (error, _inner_error0_);
			return _tmp5_;
		} else {
			gboolean _tmp6_ = FALSE;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp6_;
		}
	}
	result = TRUE;
	return result;
}

static gchar**
_vala_array_dup7 (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 void
_vala_array_add10 (gchar** * array,
                   gint* length,
                   gint* size,
                   gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

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 void
_vala_array_add11 (WixlExtension* * array,
                   gint* length,
                   gint* size,
                   WixlExtension value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (WixlExtension, *array, *size);
	}
	(*array)[(*length)++] = value;
}

static gint
wixl_main (gchar** args,
           gint args_length1)
{
	gchar* parameter_string = NULL;
	gchar* _tmp0_;
	GOptionContext* opt_context = NULL;
	const gchar* _tmp1_;
	GOptionContext* _tmp2_;
	GOptionContext* _tmp3_;
	GOptionContext* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	gchar** _tmp18_;
	gint _tmp18__length1;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gboolean _tmp24_ = FALSE;
	const gchar* _tmp25_;
	gchar** _tmp34_;
	gint _tmp34__length1;
	GError* _inner_error0_ = NULL;
	gint result;
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	g_set_application_name ("wixl");
	_tmp0_ = g_strdup (_ ("- a msi building tool"));
	parameter_string = _tmp0_;
	_tmp1_ = parameter_string;
	_tmp2_ = g_option_context_new (_tmp1_);
	opt_context = _tmp2_;
	_tmp3_ = opt_context;
	g_option_context_set_help_enabled (_tmp3_, TRUE);
	_tmp4_ = opt_context;
	g_option_context_add_main_entries (_tmp4_, WIXL_options, NULL);
	_tmp5_ = g_build_filename (DATADIR, "wixl-" PACKAGE_VERSION, "include", NULL);
	_g_free0 (wixl_wxidir);
	wixl_wxidir = _tmp5_;
	_tmp6_ = g_build_filename (DATADIR, "wixl-" PACKAGE_VERSION, "ext", NULL);
	_g_free0 (wixl_extdir);
	wixl_extdir = _tmp6_;
	{
		GOptionContext* _tmp7_;
		_tmp7_ = opt_context;
		g_option_context_parse (_tmp7_, (gint*) (&args_length1), &args, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gint _tmp8_ = -1;
			if (g_error_matches (_inner_error0_, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE)) {
				goto __catch0_g_option_error_bad_value;
			}
			if (_inner_error0_->domain == G_OPTION_ERROR) {
				goto __catch0_g_option_error;
			}
			_g_option_context_free0 (opt_context);
			_g_free0 (parameter_string);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp8_;
		}
	}
	goto __finally0;
	__catch0_g_option_error_bad_value:
	{
		GError* err = NULL;
		FILE* _tmp9_;
		GError* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = stderr;
		_tmp10_ = err;
		_tmp11_ = _tmp10_->message;
		_tmp12_ = g_strconcat (_tmp11_, "\n", NULL);
		_tmp13_ = _tmp12_;
		fprintf (_tmp9_, "%s", _tmp13_);
		_g_free0 (_tmp13_);
		exit (1);
		_g_error_free0 (err);
	}
	goto __finally0;
	__catch0_g_option_error:
	{
		GError* _error_ = NULL;
		GError* _tmp14_;
		const gchar* _tmp15_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp14_ = _error_;
		_tmp15_ = _tmp14_->message;
		g_warning ("wixl.vala:69: %s", _tmp15_);
		_g_error_free0 (_error_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp16_ = -1;
		_g_option_context_free0 (opt_context);
		_g_free0 (parameter_string);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp16_;
	}
	_tmp17_ = wixl_opt_includedirs;
	_tmp17__length1 = _vala_array_length (wixl_opt_includedirs);
	_tmp18_ = (_tmp17_ != NULL) ? _vala_array_dup7 (_tmp17_, _tmp17__length1) : _tmp17_;
	_tmp18__length1 = _tmp17__length1;
	wixl_includedirs = (_vala_array_free (wixl_includedirs, wixl_includedirs_length1, (GDestroyNotify) g_free), NULL);
	wixl_includedirs = _tmp18_;
	wixl_includedirs_length1 = _tmp18__length1;
	_wixl_includedirs_size_ = wixl_includedirs_length1;
	_tmp19_ = wixl_wxidir;
	_tmp20_ = g_strdup (_tmp19_);
	_vala_array_add10 (&wixl_includedirs, &wixl_includedirs_length1, &_wixl_includedirs_size_, _tmp20_);
	if (wixl_version) {
		FILE* _tmp21_;
		_tmp21_ = stdout;
		fprintf (_tmp21_, "%s\n", PACKAGE_VERSION);
		exit (0);
	}
	_tmp22_ = wixl_files;
	_tmp22__length1 = _vala_array_length (wixl_files);
	if (_tmp22__length1 < 1) {
		FILE* _tmp23_;
		_tmp23_ = stderr;
		fprintf (_tmp23_, "%s", _ ("Please specify input files.\n"));
		exit (1);
	}
	_tmp25_ = wixl_output;
	if (_tmp25_ == NULL) {
		_tmp24_ = !wixl_preproc;
	} else {
		_tmp24_ = FALSE;
	}
	if (_tmp24_) {
		gchar** _tmp26_;
		gint _tmp26__length1;
		const gchar* _tmp27_;
		_tmp26_ = wixl_files;
		_tmp26__length1 = _vala_array_length (wixl_files);
		_tmp27_ = _tmp26_[0];
		if (g_str_has_suffix (_tmp27_, ".wxs")) {
			gchar** _tmp28_;
			gint _tmp28__length1;
			const gchar* _tmp29_;
			gchar* _tmp30_;
			gchar* _tmp31_;
			gchar* _tmp32_;
			_tmp28_ = wixl_files;
			_tmp28__length1 = _vala_array_length (wixl_files);
			_tmp29_ = _tmp28_[0];
			_tmp30_ = string_slice (_tmp29_, (glong) 0, (glong) -4);
			_tmp31_ = _tmp30_;
			_tmp32_ = g_strconcat (_tmp31_, ".msi", NULL);
			_g_free0 (wixl_output);
			wixl_output = _tmp32_;
			_g_free0 (_tmp31_);
		} else {
			FILE* _tmp33_;
			_tmp33_ = stderr;
			fprintf (_tmp33_, "%s", _ ("Please specify the output file.\n"));
			exit (1);
		}
	}
	_tmp34_ = wixl_opt_extensions;
	_tmp34__length1 = _vala_array_length (wixl_opt_extensions);
	{
		gchar** i_collection = NULL;
		gint i_collection_length1 = 0;
		gint _i_collection_size_ = 0;
		gint i_it = 0;
		i_collection = _tmp34_;
		i_collection_length1 = _tmp34__length1;
		for (i_it = 0; i_it < i_collection_length1; i_it = i_it + 1) {
			gchar* _tmp35_;
			gchar* i = NULL;
			_tmp35_ = g_strdup (i_collection[i_it]);
			i = _tmp35_;
			{
				{
					WixlExtension extension = 0;
					const gchar* _tmp36_;
					_tmp36_ = i;
					extension = wixl_extension_from_string (_tmp36_, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch1_g_error;
					}
					_vala_array_add11 (&wixl_extensions, &wixl_extensions_length1, &_wixl_extensions_size_, extension);
				}
				goto __finally1;
				__catch1_g_error:
				{
					FILE* _tmp37_;
					const gchar* _tmp38_;
					gchar* _tmp39_;
					gchar* _tmp40_;
					g_clear_error (&_inner_error0_);
					_tmp37_ = stderr;
					_tmp38_ = i;
					_tmp39_ = g_strdup_printf (_ ("Extension of type '%s' is not supported.\n"), _tmp38_);
					_tmp40_ = _tmp39_;
					fprintf (_tmp37_, "%s", _tmp40_);
					_g_free0 (_tmp40_);
					exit (1);
				}
				__finally1:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					gint _tmp41_ = -1;
					_g_free0 (i);
					_g_option_context_free0 (opt_context);
					_g_free0 (parameter_string);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return _tmp41_;
				}
				_g_free0 (i);
			}
		}
	}
	{
		WixlWixBuilder* builder = NULL;
		gchar** _tmp42_;
		gint _tmp42__length1;
		WixlExtension* _tmp43_;
		gint _tmp43__length1;
		const gchar* _tmp44_;
		WixlWixBuilder* _tmp45_;
		gchar** _tmp46_;
		gint _tmp46__length1;
		gchar** _tmp62_;
		gint _tmp62__length1;
		WixlMsiDatabase* msi = NULL;
		WixlWixBuilder* _tmp76_;
		WixlMsiDatabase* _tmp77_;
		WixlMsiDatabase* _tmp79_;
		const gchar* _tmp80_;
		_tmp42_ = wixl_includedirs;
		_tmp42__length1 = wixl_includedirs_length1;
		_tmp43_ = wixl_extensions;
		_tmp43__length1 = wixl_extensions_length1;
		_tmp44_ = wixl_extdir;
		_tmp45_ = wixl_wix_builder_new (_tmp42_, _tmp42__length1, wixl_arch, _tmp43_, _tmp43__length1, _tmp44_);
		builder = _tmp45_;
		_tmp46_ = wixl_defines;
		_tmp46__length1 = _vala_array_length (wixl_defines);
		{
			gchar** d_collection = NULL;
			gint d_collection_length1 = 0;
			gint _d_collection_size_ = 0;
			gint d_it = 0;
			d_collection = _tmp46_;
			d_collection_length1 = _tmp46__length1;
			for (d_it = 0; d_it < d_collection_length1; d_it = d_it + 1) {
				gchar* _tmp47_;
				gchar* d = NULL;
				_tmp47_ = g_strdup (d_collection[d_it]);
				d = _tmp47_;
				{
					gchar** def = NULL;
					const gchar* _tmp48_;
					gchar** _tmp49_;
					gchar** _tmp50_;
					gint def_length1;
					gint _def_size_;
					gchar* name = NULL;
					gchar** _tmp51_;
					gint _tmp51__length1;
					const gchar* _tmp52_;
					gchar* _tmp53_;
					const gchar* _tmp54_ = NULL;
					gchar** _tmp55_;
					gint _tmp55__length1;
					gchar* value = NULL;
					gchar* _tmp58_;
					WixlWixBuilder* _tmp59_;
					const gchar* _tmp60_;
					const gchar* _tmp61_;
					_tmp48_ = d;
					_tmp50_ = _tmp49_ = g_strsplit (_tmp48_, "=", 2);
					def = _tmp50_;
					def_length1 = _vala_array_length (_tmp49_);
					_def_size_ = def_length1;
					_tmp51_ = def;
					_tmp51__length1 = def_length1;
					_tmp52_ = _tmp51_[0];
					_tmp53_ = g_strdup (_tmp52_);
					name = _tmp53_;
					_tmp55_ = def;
					_tmp55__length1 = def_length1;
					if (_tmp55__length1 == 2) {
						gchar** _tmp56_;
						gint _tmp56__length1;
						const gchar* _tmp57_;
						_tmp56_ = def;
						_tmp56__length1 = def_length1;
						_tmp57_ = _tmp56_[1];
						_tmp54_ = _tmp57_;
					} else {
						_tmp54_ = "1";
					}
					_tmp58_ = g_strdup (_tmp54_);
					value = _tmp58_;
					_tmp59_ = builder;
					_tmp60_ = name;
					_tmp61_ = value;
					wixl_wix_builder_define_variable (_tmp59_, _tmp60_, _tmp61_);
					_g_free0 (value);
					_g_free0 (name);
					def = (_vala_array_free (def, def_length1, (GDestroyNotify) g_free), NULL);
					_g_free0 (d);
				}
			}
		}
		_tmp62_ = wixl_files;
		_tmp62__length1 = _vala_array_length (wixl_files);
		{
			gchar** arg_collection = NULL;
			gint arg_collection_length1 = 0;
			gint _arg_collection_size_ = 0;
			gint arg_it = 0;
			arg_collection = _tmp62_;
			arg_collection_length1 = _tmp62__length1;
			for (arg_it = 0; arg_it < arg_collection_length1; arg_it = arg_it + 1) {
				gchar* _tmp63_;
				gchar* arg = NULL;
				_tmp63_ = g_strdup (arg_collection[arg_it]);
				arg = _tmp63_;
				{
					GFile* file = NULL;
					const gchar* _tmp65_;
					GFile* _tmp66_;
					WixlWixBuilder* _tmp67_;
					GFile* _tmp68_;
					WixlWixBuilder* _tmp69_;
					GFile* _tmp70_;
					GFile* _tmp71_;
					GFile* _tmp72_;
					gchar* _tmp73_;
					gchar* _tmp74_;
					if (wixl_verbose) {
						const gchar* _tmp64_;
						_tmp64_ = arg;
						g_print (_ ("Loading %s...\n"), _tmp64_);
					}
					_tmp65_ = arg;
					_tmp66_ = g_file_new_for_commandline_arg (_tmp65_);
					file = _tmp66_;
					_tmp67_ = builder;
					_tmp68_ = file;
					wixl_wix_builder_load_file (_tmp67_, _tmp68_, wixl_preproc, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_g_object_unref0 (file);
						_g_free0 (arg);
						_g_object_unref0 (builder);
						goto __catch2_g_error;
					}
					_tmp69_ = builder;
					_tmp70_ = file;
					_tmp71_ = g_file_get_parent (_tmp70_);
					_tmp72_ = _tmp71_;
					_tmp73_ = g_file_get_path (_tmp72_);
					_tmp74_ = _tmp73_;
					wixl_wix_builder_add_path (_tmp69_, _tmp74_);
					_g_free0 (_tmp74_);
					_g_object_unref0 (_tmp72_);
					_g_object_unref0 (file);
					_g_free0 (arg);
				}
			}
		}
		if (wixl_preproc) {
			result = 0;
			_g_object_unref0 (builder);
			_g_option_context_free0 (opt_context);
			_g_free0 (parameter_string);
			return result;
		}
		if (wixl_verbose) {
			const gchar* _tmp75_;
			_tmp75_ = wixl_output;
			g_print (_ ("Building %s...\n"), _tmp75_);
		}
		_tmp76_ = builder;
		_tmp77_ = wixl_wix_builder_build (_tmp76_, &_inner_error0_);
		msi = _tmp77_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (builder);
			goto __catch2_g_error;
		}
		if (wixl_verbose) {
			const gchar* _tmp78_;
			_tmp78_ = wixl_output;
			g_print (_ ("Writing %s...\n"), _tmp78_);
		}
		_tmp79_ = msi;
		_tmp80_ = wixl_output;
		wixl_msi_database_build (_tmp79_, _tmp80_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (msi);
			_g_object_unref0 (builder);
			goto __catch2_g_error;
		}
		_g_object_unref0 (msi);
		_g_object_unref0 (builder);
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp81_;
		const gchar* _tmp82_;
		gchar* _tmp83_;
		gchar* _tmp84_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp81_ = _error_;
		_tmp82_ = _tmp81_->message;
		_tmp83_ = g_strconcat (_tmp82_, "\n", NULL);
		_tmp84_ = _tmp83_;
		g_printerr ("%s", _tmp84_);
		_g_free0 (_tmp84_);
		result = 1;
		_g_error_free0 (_error_);
		_g_option_context_free0 (opt_context);
		_g_free0 (parameter_string);
		return result;
	}
	__finally2:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp85_ = -1;
		_g_option_context_free0 (opt_context);
		_g_free0 (parameter_string);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp85_;
	}
	result = 0;
	_g_option_context_free0 (opt_context);
	_g_free0 (parameter_string);
	return result;
}

int
main (int argc,
      char ** argv)
{
	return wixl_main (argv, argc);
}

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;
}

