/* compatibility-tool-loader.c generated by valac 0.56.19, the Vala compiler
 * generated from compatibility-tool-loader.vala, do not modify */

#include "protonplus_core.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <sys/stat.h>
#include <gee.h>
#include <glib-object.h>
#include <glib/gstdio.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

enum  {
	PROTON_PLUS_UTILS_VDF_COMPATIBILITY_TOOL_LOADER_0_PROPERTY,
	PROTON_PLUS_UTILS_VDF_COMPATIBILITY_TOOL_LOADER_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_vdf_compatibility_tool_loader_properties[PROTON_PLUS_UTILS_VDF_COMPATIBILITY_TOOL_LOADER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer proton_plus_utils_vdf_compatibility_tool_loader_parent_class = NULL;

static ProtonPlusUtilsVDFVdfEntry* proton_plus_utils_vdf_compatibility_tool_loader_find_compat_tools (ProtonPlusUtilsVDFVdfDocument* document);
static gboolean proton_plus_utils_vdf_compatibility_tool_loader_valid_internal_title (const gchar* value);
static GType proton_plus_utils_vdf_compatibility_tool_loader_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

ProtonPlusModelsCompatibilityTool*
proton_plus_utils_vdf_compatibility_tool_loader_try_from_paths (const gchar* path,
                                                                const gchar* inspection_path,
                                                                gboolean externally_managed)
{
	struct stat root_stat = {0};
	gboolean _tmp0_ = FALSE;
	struct stat _tmp1_ = {0};
	gint _tmp2_;
	gchar* manifest_path = NULL;
	gchar* _tmp4_;
	struct stat manifest_stat = {0};
	gboolean _tmp5_ = FALSE;
	const gchar* _tmp6_;
	struct stat _tmp7_ = {0};
	gint _tmp8_;
	ProtonPlusUtilsVDFVdfDocument* document = NULL;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	ProtonPlusUtilsVDFVdfDocument* _tmp13_;
	ProtonPlusUtilsVDFVdfDocument* _tmp14_;
	ProtonPlusUtilsVDFVdfDocument* _tmp15_;
	ProtonPlusUtilsVDFVdfEntry* compatibility_tools = NULL;
	ProtonPlusUtilsVDFVdfDocument* _tmp16_;
	ProtonPlusUtilsVDFVdfEntry* _tmp17_;
	gboolean _tmp18_ = FALSE;
	ProtonPlusUtilsVDFVdfEntry* _tmp19_;
	ProtonPlusUtilsVDFVdfEntry* definition = NULL;
	ProtonPlusUtilsVDFVdfEntry* _tmp25_;
	GeeArrayList* _tmp26_;
	GeeArrayList* _tmp27_;
	gpointer _tmp28_;
	gchar* internal_title = NULL;
	ProtonPlusUtilsVDFVdfEntry* _tmp29_;
	const gchar* _tmp30_;
	const gchar* _tmp31_;
	gchar* _tmp32_;
	const gchar* _tmp33_;
	ProtonPlusUtilsVDFVdfEntry* display_name = NULL;
	ProtonPlusUtilsVDFVdfEntry* _tmp34_;
	ProtonPlusUtilsVDFVdfEntry* _tmp35_;
	ProtonPlusUtilsVDFVdfEntry* _tmp36_ = NULL;
	ProtonPlusUtilsVDFVdfEntry* _tmp37_;
	const gchar* _tmp38_ = NULL;
	const gchar* _tmp41_ = NULL;
	gchar* display_title = NULL;
	gchar* _tmp43_;
	const gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	gboolean _tmp47_;
	ProtonPlusModelsCompatibilityTool* tool = NULL;
	const gchar* _tmp50_;
	const gchar* _tmp51_;
	ProtonPlusModelsCompatibilityTool* _tmp52_;
	struct stat proton_stat = {0};
	gboolean _tmp53_ = FALSE;
	gchar* _tmp54_;
	gchar* _tmp55_;
	struct stat _tmp56_ = {0};
	gint _tmp57_;
	gboolean _tmp58_;
	ProtonPlusModelsCompatibilityTool* result;
	g_return_val_if_fail (path != NULL, NULL);
	g_return_val_if_fail (inspection_path != NULL, NULL);
	_tmp2_ = lstat (inspection_path, &_tmp1_);
	root_stat = _tmp1_;
	if (_tmp2_ != 0) {
		_tmp0_ = TRUE;
	} else {
		struct stat _tmp3_;
		_tmp3_ = root_stat;
		_tmp0_ = !S_ISDIR (_tmp3_.st_mode);
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	}
	_tmp4_ = g_build_filename (inspection_path, "compatibilitytool.vdf", NULL);
	manifest_path = _tmp4_;
	_tmp6_ = manifest_path;
	_tmp8_ = lstat (_tmp6_, &_tmp7_);
	manifest_stat = _tmp7_;
	if (_tmp8_ != 0) {
		_tmp5_ = TRUE;
	} else {
		struct stat _tmp9_;
		_tmp9_ = manifest_stat;
		_tmp5_ = !S_ISREG (_tmp9_.st_mode);
	}
	if (_tmp5_) {
		result = NULL;
		_g_free0 (manifest_path);
		return result;
	}
	_tmp10_ = manifest_path;
	_tmp11_ = proton_plus_utils_filesystem_get_file_content (_tmp10_, FALSE);
	_tmp12_ = _tmp11_;
	_tmp13_ = proton_plus_utils_vdf_vdf_parser_parse_document (_tmp12_);
	_tmp14_ = _tmp13_;
	_g_free0 (_tmp12_);
	document = _tmp14_;
	_tmp15_ = document;
	if (_tmp15_ == NULL) {
		result = NULL;
		_g_object_unref0 (document);
		_g_free0 (manifest_path);
		return result;
	}
	_tmp16_ = document;
	_tmp17_ = proton_plus_utils_vdf_compatibility_tool_loader_find_compat_tools (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, PROTON_PLUS_UTILS_VDF_TYPE_VDF_DOCUMENT, ProtonPlusUtilsVDFVdfDocument));
	compatibility_tools = _tmp17_;
	_tmp19_ = compatibility_tools;
	if (_tmp19_ == NULL) {
		_tmp18_ = TRUE;
	} else {
		ProtonPlusUtilsVDFVdfEntry* _tmp20_;
		GeeArrayList* _tmp21_;
		GeeArrayList* _tmp22_;
		gint _tmp23_;
		gint _tmp24_;
		_tmp20_ = compatibility_tools;
		_tmp21_ = proton_plus_utils_vdf_vdf_entry_get_children (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp22_);
		_tmp24_ = _tmp23_;
		_tmp18_ = _tmp24_ == 0;
	}
	if (_tmp18_) {
		result = NULL;
		_g_object_unref0 (compatibility_tools);
		_g_object_unref0 (document);
		_g_free0 (manifest_path);
		return result;
	}
	_tmp25_ = compatibility_tools;
	_tmp26_ = proton_plus_utils_vdf_vdf_entry_get_children (_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = gee_abstract_list_get ((GeeAbstractList*) _tmp27_, 0);
	definition = (ProtonPlusUtilsVDFVdfEntry*) _tmp28_;
	_tmp29_ = definition;
	_tmp30_ = proton_plus_utils_vdf_vdf_entry_get_key (_tmp29_);
	_tmp31_ = _tmp30_;
	_tmp32_ = string_strip (_tmp31_);
	internal_title = _tmp32_;
	_tmp33_ = internal_title;
	if (!proton_plus_utils_vdf_compatibility_tool_loader_valid_internal_title (_tmp33_)) {
		result = NULL;
		_g_free0 (internal_title);
		_g_object_unref0 (definition);
		_g_object_unref0 (compatibility_tools);
		_g_object_unref0 (document);
		_g_free0 (manifest_path);
		return result;
	}
	_tmp34_ = definition;
	_tmp35_ = proton_plus_utils_vdf_vdf_entry_get_child (_tmp34_, "display_name");
	display_name = _tmp35_;
	_tmp37_ = display_name;
	_tmp36_ = _tmp37_;
	_tmp38_ = NULL;
	if (_tmp36_ != NULL) {
		const gchar* _tmp39_;
		const gchar* _tmp40_;
		_tmp39_ = proton_plus_utils_vdf_vdf_entry_get_value (_tmp36_);
		_tmp40_ = _tmp39_;
		_tmp38_ = _tmp40_;
	}
	_tmp41_ = _tmp38_;
	if (_tmp41_ == NULL) {
		const gchar* _tmp42_;
		_tmp42_ = internal_title;
		_tmp41_ = _tmp42_;
	}
	_tmp43_ = g_strdup (_tmp41_);
	display_title = _tmp43_;
	_tmp44_ = display_title;
	_tmp45_ = string_strip (_tmp44_);
	_tmp46_ = _tmp45_;
	_tmp47_ = g_strcmp0 (_tmp46_, "") == 0;
	_g_free0 (_tmp46_);
	if (_tmp47_) {
		const gchar* _tmp48_;
		gchar* _tmp49_;
		_tmp48_ = internal_title;
		_tmp49_ = g_strdup (_tmp48_);
		_g_free0 (display_title);
		display_title = _tmp49_;
	}
	_tmp50_ = display_title;
	_tmp51_ = internal_title;
	_tmp52_ = proton_plus_models_compatibility_tool_new (_tmp50_, _tmp51_, path, PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_UNKNOWN, inspection_path, externally_managed);
	tool = _tmp52_;
	_tmp54_ = g_build_filename (inspection_path, "proton", NULL);
	_tmp55_ = _tmp54_;
	_tmp57_ = lstat (_tmp55_, &_tmp56_);
	proton_stat = _tmp56_;
	_tmp58_ = _tmp57_ == 0;
	_g_free0 (_tmp55_);
	if (_tmp58_) {
		struct stat _tmp59_;
		_tmp59_ = proton_stat;
		_tmp53_ = S_ISREG (_tmp59_.st_mode);
	} else {
		_tmp53_ = FALSE;
	}
	if (_tmp53_) {
		ProtonPlusModelsCompatibilityTool* _tmp60_;
		_tmp60_ = tool;
		proton_plus_models_compatibility_tool_set_runtime_kind (_tmp60_, PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_PROTON);
	}
	result = tool;
	_g_free0 (display_title);
	_g_object_unref0 (display_name);
	_g_free0 (internal_title);
	_g_object_unref0 (definition);
	_g_object_unref0 (compatibility_tools);
	_g_object_unref0 (document);
	_g_free0 (manifest_path);
	return result;
}

static ProtonPlusUtilsVDFVdfEntry*
proton_plus_utils_vdf_compatibility_tool_loader_find_compat_tools (ProtonPlusUtilsVDFVdfDocument* document)
{
	ProtonPlusUtilsVDFVdfEntry* compatibility_tools = NULL;
	ProtonPlusUtilsVDFVdfEntry* _tmp0_;
	ProtonPlusUtilsVDFVdfEntry* _tmp1_;
	ProtonPlusUtilsVDFVdfEntry* _tmp2_;
	ProtonPlusUtilsVDFVdfEntry* _tmp3_;
	ProtonPlusUtilsVDFVdfEntry* manifest = NULL;
	ProtonPlusUtilsVDFVdfEntry* _tmp4_;
	ProtonPlusUtilsVDFVdfEntry* _tmp5_;
	ProtonPlusUtilsVDFVdfEntry* _tmp6_;
	ProtonPlusUtilsVDFVdfEntry* _tmp7_ = NULL;
	ProtonPlusUtilsVDFVdfEntry* _tmp8_;
	ProtonPlusUtilsVDFVdfEntry* _tmp9_ = NULL;
	ProtonPlusUtilsVDFVdfEntry* _tmp11_;
	ProtonPlusUtilsVDFVdfEntry* result;
	g_return_val_if_fail (document != NULL, NULL);
	_tmp0_ = proton_plus_utils_vdf_vdf_document_get_root (document);
	_tmp1_ = _tmp0_;
	_tmp2_ = proton_plus_utils_vdf_vdf_entry_get_child (_tmp1_, "compat_tools");
	compatibility_tools = _tmp2_;
	_tmp3_ = compatibility_tools;
	if (_tmp3_ != NULL) {
		result = compatibility_tools;
		return result;
	}
	_tmp4_ = proton_plus_utils_vdf_vdf_document_get_root (document);
	_tmp5_ = _tmp4_;
	_tmp6_ = proton_plus_utils_vdf_vdf_entry_get_child (_tmp5_, "compatibilitytools");
	manifest = _tmp6_;
	_tmp8_ = manifest;
	_tmp7_ = _tmp8_;
	_tmp9_ = NULL;
	if (_tmp7_ != NULL) {
		ProtonPlusUtilsVDFVdfEntry* _tmp10_;
		_tmp10_ = proton_plus_utils_vdf_vdf_entry_get_child (_tmp7_, "compat_tools");
		_g_object_unref0 (_tmp9_);
		_tmp9_ = _tmp10_;
	}
	_tmp11_ = _tmp9_;
	_tmp9_ = NULL;
	result = _tmp11_;
	_g_object_unref0 (_tmp9_);
	_g_object_unref0 (manifest);
	_g_object_unref0 (compatibility_tools);
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

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

ProtonPlusModelsCompatibilityTool*
proton_plus_utils_vdf_compatibility_tool_loader_from_path (const gchar* path)
{
	ProtonPlusModelsCompatibilityTool* parsed = NULL;
	ProtonPlusModelsCompatibilityTool* _tmp0_;
	ProtonPlusModelsCompatibilityTool* _tmp1_;
	gchar* fallback_title = NULL;
	gchar* _tmp4_;
	ProtonPlusModelsCompatibilityTool* tool = NULL;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	ProtonPlusModelsCompatibilityTool* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gboolean _tmp10_;
	gchar* compatibilitytoolvdf_path = NULL;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* content = NULL;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	gchar* start_text = NULL;
	gchar* _tmp17_;
	gint start_pos = 0;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	ProtonPlusModelsCompatibilityTool* result;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = proton_plus_utils_vdf_compatibility_tool_loader_try_from_paths (path, path, FALSE);
	parsed = _tmp0_;
	_tmp1_ = parsed;
	if (_tmp1_ != NULL) {
		ProtonPlusModelsCompatibilityTool* _tmp2_;
		ProtonPlusModelsCompatibilityTool* _tmp3_;
		_tmp2_ = parsed;
		_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, PROTON_PLUS_MODELS_TYPE_COMPATIBILITY_TOOL, ProtonPlusModelsCompatibilityTool));
		result = _tmp3_;
		_g_object_unref0 (parsed);
		return result;
	}
	_tmp4_ = g_path_get_basename (path);
	fallback_title = _tmp4_;
	_tmp5_ = fallback_title;
	_tmp6_ = fallback_title;
	_tmp7_ = proton_plus_models_compatibility_tool_new (_tmp5_, _tmp6_, path, PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_UNKNOWN, "", FALSE);
	tool = _tmp7_;
	_tmp8_ = g_build_filename (path, "proton", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_file_test (_tmp9_, G_FILE_TEST_IS_REGULAR);
	_g_free0 (_tmp9_);
	if (_tmp10_) {
		ProtonPlusModelsCompatibilityTool* _tmp11_;
		_tmp11_ = tool;
		proton_plus_models_compatibility_tool_set_runtime_kind (_tmp11_, PROTON_PLUS_MODELS_COMPATIBILITY_TOOL_RUNTIME_KIND_PROTON);
	}
	_tmp12_ = g_strdup_printf ("%s/compatibilitytool.vdf", path);
	compatibilitytoolvdf_path = _tmp12_;
	_tmp13_ = compatibilitytoolvdf_path;
	if (!g_file_test (_tmp13_, G_FILE_TEST_IS_REGULAR)) {
		result = tool;
		_g_free0 (compatibilitytoolvdf_path);
		_g_free0 (fallback_title);
		_g_object_unref0 (parsed);
		return result;
	}
	_tmp14_ = compatibilitytoolvdf_path;
	_tmp15_ = proton_plus_utils_filesystem_get_file_content (_tmp14_, FALSE);
	content = _tmp15_;
	_tmp16_ = content;
	if (g_strcmp0 (_tmp16_, "") == 0) {
		result = tool;
		_g_free0 (content);
		_g_free0 (compatibilitytoolvdf_path);
		_g_free0 (fallback_title);
		_g_object_unref0 (parsed);
		return result;
	}
	_tmp17_ = g_strdup ("display_name\" \"");
	start_text = _tmp17_;
	_tmp18_ = content;
	_tmp19_ = start_text;
	start_pos = string_index_of (_tmp18_, _tmp19_, 0);
	if (start_pos != -1) {
		const gchar* _tmp20_;
		gint _tmp21_;
		gint _tmp22_;
		gint end_pos = 0;
		const gchar* _tmp23_;
		_tmp20_ = start_text;
		_tmp21_ = strlen (_tmp20_);
		_tmp22_ = _tmp21_;
		start_pos += _tmp22_;
		_tmp23_ = content;
		end_pos = string_index_of (_tmp23_, "\"", start_pos);
		if (end_pos != -1) {
			ProtonPlusModelsCompatibilityTool* _tmp24_;
			const gchar* _tmp25_;
			gchar* _tmp26_;
			gchar* _tmp27_;
			_tmp24_ = tool;
			_tmp25_ = content;
			_tmp26_ = string_substring (_tmp25_, (glong) start_pos, (glong) (end_pos - start_pos));
			_tmp27_ = _tmp26_;
			proton_plus_models_compatibility_tool_set_display_title (_tmp24_, _tmp27_);
			_g_free0 (_tmp27_);
		}
	}
	_tmp28_ = g_strdup ("compat_tools\"");
	_g_free0 (start_text);
	start_text = _tmp28_;
	_tmp29_ = content;
	_tmp30_ = start_text;
	start_pos = string_index_of (_tmp29_, _tmp30_, 0);
	if (start_pos != -1) {
		const gchar* _tmp31_;
		gint _tmp32_;
		gint _tmp33_;
		const gchar* _tmp34_;
		_tmp31_ = start_text;
		_tmp32_ = strlen (_tmp31_);
		_tmp33_ = _tmp32_;
		start_pos += _tmp33_;
		_tmp34_ = content;
		start_pos = string_index_of (_tmp34_, "\"", start_pos);
		if (start_pos != -1) {
			gint _tmp35_;
			gint _tmp36_;
			gint end_pos = 0;
			const gchar* _tmp37_;
			_tmp35_ = strlen ("\"");
			_tmp36_ = _tmp35_;
			start_pos += _tmp36_;
			_tmp37_ = content;
			end_pos = string_index_of (_tmp37_, "\" // Internal name of this tool", start_pos);
			if (end_pos != -1) {
				ProtonPlusModelsCompatibilityTool* _tmp38_;
				const gchar* _tmp39_;
				gchar* _tmp40_;
				gchar* _tmp41_;
				_tmp38_ = tool;
				_tmp39_ = content;
				_tmp40_ = string_substring (_tmp39_, (glong) start_pos, (glong) (end_pos - start_pos));
				_tmp41_ = _tmp40_;
				proton_plus_models_compatibility_tool_set_internal_title (_tmp38_, _tmp41_);
				_g_free0 (_tmp41_);
			}
		}
	}
	result = tool;
	_g_free0 (start_text);
	_g_free0 (content);
	_g_free0 (compatibilitytoolvdf_path);
	_g_free0 (fallback_title);
	_g_object_unref0 (parsed);
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

static gboolean
proton_plus_utils_vdf_compatibility_tool_loader_valid_internal_title (const gchar* value)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean result;
	g_return_val_if_fail (value != NULL, FALSE);
	if (g_strcmp0 (value, "") == 0) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = g_strcmp0 (value, ".") == 0;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = g_strcmp0 (value, "..") == 0;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = string_contains (value, "/");
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = string_contains (value, "\\");
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				gint _tmp6_;
				gint _tmp7_;
				gboolean _tmp8_ = FALSE;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = index;
					index = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				_tmp6_ = strlen (value);
				_tmp7_ = _tmp6_;
				if (!(index < _tmp7_)) {
					break;
				}
				if (((gint) string_get (value, (glong) index)) < 0x20) {
					_tmp8_ = TRUE;
				} else {
					_tmp8_ = ((gint) string_get (value, (glong) index)) == 0x7f;
				}
				if (_tmp8_) {
					result = FALSE;
					return result;
				}
			}
		}
	}
	result = TRUE;
	return result;
}

ProtonPlusUtilsVDFCompatibilityToolLoader*
proton_plus_utils_vdf_compatibility_tool_loader_construct (GType object_type)
{
	ProtonPlusUtilsVDFCompatibilityToolLoader * self = NULL;
	self = (ProtonPlusUtilsVDFCompatibilityToolLoader*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusUtilsVDFCompatibilityToolLoader*
proton_plus_utils_vdf_compatibility_tool_loader_new (void)
{
	return proton_plus_utils_vdf_compatibility_tool_loader_construct (PROTON_PLUS_UTILS_VDF_TYPE_COMPATIBILITY_TOOL_LOADER);
}

static void
proton_plus_utils_vdf_compatibility_tool_loader_class_init (ProtonPlusUtilsVDFCompatibilityToolLoaderClass * klass,
                                                            gpointer klass_data)
{
	proton_plus_utils_vdf_compatibility_tool_loader_parent_class = g_type_class_peek_parent (klass);
}

static void
proton_plus_utils_vdf_compatibility_tool_loader_instance_init (ProtonPlusUtilsVDFCompatibilityToolLoader * self,
                                                               gpointer klass)
{
}

static GType
proton_plus_utils_vdf_compatibility_tool_loader_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsVDFCompatibilityToolLoaderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_vdf_compatibility_tool_loader_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsVDFCompatibilityToolLoader), 0, (GInstanceInitFunc) proton_plus_utils_vdf_compatibility_tool_loader_instance_init, NULL };
	GType proton_plus_utils_vdf_compatibility_tool_loader_type_id;
	proton_plus_utils_vdf_compatibility_tool_loader_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsVDFCompatibilityToolLoader", &g_define_type_info, 0);
	return proton_plus_utils_vdf_compatibility_tool_loader_type_id;
}

GType
proton_plus_utils_vdf_compatibility_tool_loader_get_type (void)
{
	static volatile gsize proton_plus_utils_vdf_compatibility_tool_loader_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_vdf_compatibility_tool_loader_type_id__once)) {
		GType proton_plus_utils_vdf_compatibility_tool_loader_type_id;
		proton_plus_utils_vdf_compatibility_tool_loader_type_id = proton_plus_utils_vdf_compatibility_tool_loader_get_type_once ();
		g_once_init_leave (&proton_plus_utils_vdf_compatibility_tool_loader_type_id__once, proton_plus_utils_vdf_compatibility_tool_loader_type_id);
	}
	return proton_plus_utils_vdf_compatibility_tool_loader_type_id__once;
}

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

