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

/*
 *  Copyright (C) 2019-2025 Guillaume Benoit <guillaume@manjaro.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a get of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <stdio.h>
#include <glib-object.h>
#include <alpm.h>
#include <alpm_list.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
#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 TYPE_ALPM_CONFIG (alpm_config_get_type ())
#define ALPM_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ALPM_CONFIG, AlpmConfig))
#define ALPM_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ALPM_CONFIG, AlpmConfigClass))
#define IS_ALPM_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ALPM_CONFIG))
#define IS_ALPM_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ALPM_CONFIG))
#define ALPM_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ALPM_CONFIG, AlpmConfigClass))

typedef struct _AlpmConfig AlpmConfig;
typedef struct _AlpmConfigClass AlpmConfigClass;
#define _alpm_release0(var) ((var == NULL) ? NULL : (var = (alpm_release (var), NULL)))
#define _alpm_config_unref0(var) ((var == NULL) ? NULL : (var = (alpm_config_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

static gint _vala_main (gchar** args,
                 gint args_length1);
VALA_EXTERN gpointer alpm_config_ref (gpointer instance);
VALA_EXTERN void alpm_config_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_alpm_config (const gchar* name,
                                    const gchar* nick,
                                    const gchar* blurb,
                                    GType object_type,
                                    GParamFlags flags);
VALA_EXTERN void value_set_alpm_config (GValue* value,
                            gpointer v_object);
VALA_EXTERN void value_take_alpm_config (GValue* value,
                             gpointer v_object);
VALA_EXTERN gpointer value_get_alpm_config (const GValue* value);
VALA_EXTERN GType alpm_config_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AlpmConfig, alpm_config_unref)
VALA_EXTERN AlpmConfig* alpm_config_new (const gchar* path);
VALA_EXTERN AlpmConfig* alpm_config_construct (GType object_type,
                                   const gchar* path);
VALA_EXTERN alpm_handle_t* alpm_config_get_handle (AlpmConfig* self,
                                       gboolean files_db,
                                       gboolean tmp_db,
                                       gboolean copy_dbs);
VALA_EXTERN void alpm_config_register_syncdbs (AlpmConfig* self,
                                   alpm_handle_t* handle);

static gint
_vala_main (gchar** args,
            gint args_length1)
{
	AlpmConfig* alpm_config = NULL;
	AlpmConfig* _tmp1_;
	alpm_handle_t* alpm_handle = NULL;
	AlpmConfig* _tmp2_;
	alpm_handle_t* _tmp3_;
	alpm_handle_t* _tmp4_;
	AlpmConfig* _tmp5_;
	alpm_handle_t* _tmp6_;
	const gchar* depend = NULL;
	const gchar* _tmp7_;
	alpm_list_t* syncdbs = NULL;
	alpm_handle_t* _tmp8_;
	alpm_list_t* _tmp9_;
	alpm_list_t* _tmp10_;
	gint result;
	if (args_length1 != 2) {
		FILE* _tmp0_;
		_tmp0_ = stdout;
		fprintf (_tmp0_, "Error: one dependecy argument needed\n");
		result = 1;
		return result;
	}
	_tmp1_ = alpm_config_new ("/etc/pacman.conf");
	alpm_config = _tmp1_;
	_tmp2_ = alpm_config;
	_tmp3_ = alpm_config_get_handle (_tmp2_, FALSE, FALSE, TRUE);
	alpm_handle = _tmp3_;
	_tmp4_ = alpm_handle;
	if (_tmp4_ == NULL) {
		result = 1;
		_alpm_release0 (alpm_handle);
		_alpm_config_unref0 (alpm_config);
		return result;
	}
	_tmp5_ = alpm_config;
	_tmp6_ = alpm_handle;
	alpm_config_register_syncdbs (_tmp5_, _tmp6_);
	_tmp7_ = args[1];
	depend = _tmp7_;
	_tmp8_ = alpm_handle;
	_tmp9_ = alpm_get_syncdbs (_tmp8_);
	_tmp10_ = _tmp9_;
	syncdbs = _tmp10_;
	while (TRUE) {
		alpm_list_t* _tmp11_;
		alpm_db_t* db = NULL;
		alpm_list_t* _tmp12_;
		gconstpointer _tmp13_;
		alpm_list_t* cache = NULL;
		alpm_db_t* _tmp14_;
		alpm_list_t* _tmp15_;
		alpm_list_t* _tmp16_;
		_tmp11_ = syncdbs;
		if (!(_tmp11_ != NULL)) {
			break;
		}
		_tmp12_ = syncdbs;
		_tmp13_ = _tmp12_->data;
		db = (alpm_db_t*) _tmp13_;
		_tmp14_ = db;
		_tmp15_ = alpm_db_get_pkgcache (_tmp14_);
		_tmp16_ = _tmp15_;
		cache = _tmp16_;
		while (TRUE) {
			alpm_list_t* _tmp17_;
			alpm_pkg_t* pkg = NULL;
			alpm_list_t* _tmp18_;
			gconstpointer _tmp19_;
			alpm_list_t* depends = NULL;
			alpm_pkg_t* _tmp20_;
			alpm_list_t* _tmp21_;
			alpm_list_t* _tmp22_;
			alpm_pkg_t* _tmp42_;
			alpm_list_t* _tmp43_;
			alpm_list_t* _tmp44_;
			alpm_pkg_t* _tmp64_;
			alpm_list_t* _tmp65_;
			alpm_list_t* _tmp66_;
			alpm_pkg_t* _tmp86_;
			alpm_list_t* _tmp87_;
			alpm_list_t* _tmp88_;
			_tmp17_ = cache;
			if (!(_tmp17_ != NULL)) {
				break;
			}
			_tmp18_ = cache;
			_tmp19_ = _tmp18_->data;
			pkg = (alpm_pkg_t*) _tmp19_;
			_tmp20_ = pkg;
			_tmp21_ = alpm_pkg_get_depends (_tmp20_);
			_tmp22_ = _tmp21_;
			depends = _tmp22_;
			while (TRUE) {
				alpm_list_t* _tmp23_;
				alpm_depend_t* dep = NULL;
				alpm_list_t* _tmp24_;
				gconstpointer _tmp25_;
				alpm_depend_t* _tmp26_;
				const gchar* _tmp27_;
				const gchar* _tmp28_;
				_tmp23_ = depends;
				if (!(_tmp23_ != NULL)) {
					break;
				}
				_tmp24_ = depends;
				_tmp25_ = _tmp24_->data;
				dep = (alpm_depend_t*) _tmp25_;
				_tmp26_ = dep;
				_tmp27_ = _tmp26_->name;
				_tmp28_ = depend;
				if (g_strcmp0 (_tmp27_, _tmp28_) == 0) {
					FILE* _tmp29_;
					alpm_db_t* _tmp30_;
					const gchar* _tmp31_;
					const gchar* _tmp32_;
					alpm_pkg_t* _tmp33_;
					const gchar* _tmp34_;
					const gchar* _tmp35_;
					alpm_depend_t* _tmp36_;
					gchar* _tmp37_;
					gchar* _tmp38_;
					alpm_pkg_t* _tmp39_;
					const gchar* _tmp40_;
					const gchar* _tmp41_;
					_tmp29_ = stdout;
					_tmp30_ = db;
					_tmp31_ = alpm_db_get_name (_tmp30_);
					_tmp32_ = _tmp31_;
					_tmp33_ = pkg;
					_tmp34_ = alpm_pkg_get_name (_tmp33_);
					_tmp35_ = _tmp34_;
					_tmp36_ = dep;
					_tmp37_ = alpm_dep_compute_string (_tmp36_);
					_tmp38_ = _tmp37_;
					_tmp39_ = pkg;
					_tmp40_ = alpm_pkg_get_packager (_tmp39_);
					_tmp41_ = _tmp40_;
					fprintf (_tmp29_, "%s/%s depends on %s (built by %s)\n", _tmp32_, _tmp35_, _tmp38_, _tmp41_);
					_g_free0 (_tmp38_);
				}
				depends = alpm_list_next (depends);
			}
			_tmp42_ = pkg;
			_tmp43_ = alpm_pkg_get_optdepends (_tmp42_);
			_tmp44_ = _tmp43_;
			depends = _tmp44_;
			while (TRUE) {
				alpm_list_t* _tmp45_;
				alpm_depend_t* dep = NULL;
				alpm_list_t* _tmp46_;
				gconstpointer _tmp47_;
				alpm_depend_t* _tmp48_;
				const gchar* _tmp49_;
				const gchar* _tmp50_;
				_tmp45_ = depends;
				if (!(_tmp45_ != NULL)) {
					break;
				}
				_tmp46_ = depends;
				_tmp47_ = _tmp46_->data;
				dep = (alpm_depend_t*) _tmp47_;
				_tmp48_ = dep;
				_tmp49_ = _tmp48_->name;
				_tmp50_ = depend;
				if (g_strcmp0 (_tmp49_, _tmp50_) == 0) {
					FILE* _tmp51_;
					alpm_db_t* _tmp52_;
					const gchar* _tmp53_;
					const gchar* _tmp54_;
					alpm_pkg_t* _tmp55_;
					const gchar* _tmp56_;
					const gchar* _tmp57_;
					alpm_depend_t* _tmp58_;
					gchar* _tmp59_;
					gchar* _tmp60_;
					alpm_pkg_t* _tmp61_;
					const gchar* _tmp62_;
					const gchar* _tmp63_;
					_tmp51_ = stdout;
					_tmp52_ = db;
					_tmp53_ = alpm_db_get_name (_tmp52_);
					_tmp54_ = _tmp53_;
					_tmp55_ = pkg;
					_tmp56_ = alpm_pkg_get_name (_tmp55_);
					_tmp57_ = _tmp56_;
					_tmp58_ = dep;
					_tmp59_ = alpm_dep_compute_string (_tmp58_);
					_tmp60_ = _tmp59_;
					_tmp61_ = pkg;
					_tmp62_ = alpm_pkg_get_packager (_tmp61_);
					_tmp63_ = _tmp62_;
					fprintf (_tmp51_, "%s/%s optionally depends on %s (built by %s)\n", _tmp54_, _tmp57_, _tmp60_, _tmp63_);
					_g_free0 (_tmp60_);
				}
				depends = alpm_list_next (depends);
			}
			_tmp64_ = pkg;
			_tmp65_ = alpm_pkg_get_makedepends (_tmp64_);
			_tmp66_ = _tmp65_;
			depends = _tmp66_;
			while (TRUE) {
				alpm_list_t* _tmp67_;
				alpm_depend_t* dep = NULL;
				alpm_list_t* _tmp68_;
				gconstpointer _tmp69_;
				alpm_depend_t* _tmp70_;
				const gchar* _tmp71_;
				const gchar* _tmp72_;
				_tmp67_ = depends;
				if (!(_tmp67_ != NULL)) {
					break;
				}
				_tmp68_ = depends;
				_tmp69_ = _tmp68_->data;
				dep = (alpm_depend_t*) _tmp69_;
				_tmp70_ = dep;
				_tmp71_ = _tmp70_->name;
				_tmp72_ = depend;
				if (g_strcmp0 (_tmp71_, _tmp72_) == 0) {
					FILE* _tmp73_;
					alpm_db_t* _tmp74_;
					const gchar* _tmp75_;
					const gchar* _tmp76_;
					alpm_pkg_t* _tmp77_;
					const gchar* _tmp78_;
					const gchar* _tmp79_;
					alpm_depend_t* _tmp80_;
					gchar* _tmp81_;
					gchar* _tmp82_;
					alpm_pkg_t* _tmp83_;
					const gchar* _tmp84_;
					const gchar* _tmp85_;
					_tmp73_ = stdout;
					_tmp74_ = db;
					_tmp75_ = alpm_db_get_name (_tmp74_);
					_tmp76_ = _tmp75_;
					_tmp77_ = pkg;
					_tmp78_ = alpm_pkg_get_name (_tmp77_);
					_tmp79_ = _tmp78_;
					_tmp80_ = dep;
					_tmp81_ = alpm_dep_compute_string (_tmp80_);
					_tmp82_ = _tmp81_;
					_tmp83_ = pkg;
					_tmp84_ = alpm_pkg_get_packager (_tmp83_);
					_tmp85_ = _tmp84_;
					fprintf (_tmp73_, "%s/%s make depends on %s (built by %s)\n", _tmp76_, _tmp79_, _tmp82_, _tmp85_);
					_g_free0 (_tmp82_);
				}
				depends = alpm_list_next (depends);
			}
			_tmp86_ = pkg;
			_tmp87_ = alpm_pkg_get_checkdepends (_tmp86_);
			_tmp88_ = _tmp87_;
			depends = _tmp88_;
			while (TRUE) {
				alpm_list_t* _tmp89_;
				alpm_depend_t* dep = NULL;
				alpm_list_t* _tmp90_;
				gconstpointer _tmp91_;
				alpm_depend_t* _tmp92_;
				const gchar* _tmp93_;
				const gchar* _tmp94_;
				_tmp89_ = depends;
				if (!(_tmp89_ != NULL)) {
					break;
				}
				_tmp90_ = depends;
				_tmp91_ = _tmp90_->data;
				dep = (alpm_depend_t*) _tmp91_;
				_tmp92_ = dep;
				_tmp93_ = _tmp92_->name;
				_tmp94_ = depend;
				if (g_strcmp0 (_tmp93_, _tmp94_) == 0) {
					FILE* _tmp95_;
					alpm_db_t* _tmp96_;
					const gchar* _tmp97_;
					const gchar* _tmp98_;
					alpm_pkg_t* _tmp99_;
					const gchar* _tmp100_;
					const gchar* _tmp101_;
					alpm_depend_t* _tmp102_;
					gchar* _tmp103_;
					gchar* _tmp104_;
					alpm_pkg_t* _tmp105_;
					const gchar* _tmp106_;
					const gchar* _tmp107_;
					_tmp95_ = stdout;
					_tmp96_ = db;
					_tmp97_ = alpm_db_get_name (_tmp96_);
					_tmp98_ = _tmp97_;
					_tmp99_ = pkg;
					_tmp100_ = alpm_pkg_get_name (_tmp99_);
					_tmp101_ = _tmp100_;
					_tmp102_ = dep;
					_tmp103_ = alpm_dep_compute_string (_tmp102_);
					_tmp104_ = _tmp103_;
					_tmp105_ = pkg;
					_tmp106_ = alpm_pkg_get_packager (_tmp105_);
					_tmp107_ = _tmp106_;
					fprintf (_tmp95_, "%s/%s check depends on %s (built by %s)\n", _tmp98_, _tmp101_, _tmp104_, _tmp107_);
					_g_free0 (_tmp104_);
				}
				depends = alpm_list_next (depends);
			}
			cache = alpm_list_next (cache);
		}
		syncdbs = alpm_list_next (syncdbs);
	}
	result = 0;
	_alpm_release0 (alpm_handle);
	_alpm_config_unref0 (alpm_config);
	return result;
}

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

