/* whitelist.c generated by valac 0.26.2, the Vala compiler
 * generated from whitelist.vala, do not modify */

/*
 Copyright (C) 2014 Christian Dywan <christian@twotoasts.de>
 Copyright (C) 2014 Paweł Forysiuk <tuxator@o2.pl>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 See the file COPYING for the full license text.
*/

#include <glib.h>
#include <glib-object.h>
#include "toolbar-editor.h"
#include <stdlib.h>
#include <string.h>

#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))


static gpointer adblock_whitelist_parent_class = NULL;

enum  {
	ADBLOCK_WHITELIST_DUMMY_PROPERTY
};
static AdblockDirective* adblock_whitelist_real_match (AdblockFeature* base, const gchar* request_uri, const gchar* page_uri, GError** error);
static AdblockDirective* _adblock_directive_dup (AdblockDirective* self);


AdblockWhitelist* adblock_whitelist_construct (GType object_type, AdblockOptions* options) {
	AdblockWhitelist * self = NULL;
	AdblockOptions* _tmp0_ = NULL;
#line 15 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	g_return_val_if_fail (options != NULL, NULL);
#line 16 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	_tmp0_ = options;
#line 16 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	self = (AdblockWhitelist*) adblock_filter_construct (object_type, _tmp0_);
#line 15 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	return self;
#line 47 "whitelist.c"
}


AdblockWhitelist* adblock_whitelist_new (AdblockOptions* options) {
#line 15 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	return adblock_whitelist_construct (ADBLOCK_TYPE_WHITELIST, options);
#line 54 "whitelist.c"
}


static gpointer _g_regex_ref0 (gpointer self) {
#line 21 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	return self ? g_regex_ref (self) : NULL;
#line 61 "whitelist.c"
}


static AdblockDirective* _adblock_directive_dup (AdblockDirective* self) {
	AdblockDirective* dup;
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	dup = g_new0 (AdblockDirective, 1);
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	memcpy (dup, self, sizeof (AdblockDirective));
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	return dup;
#line 73 "whitelist.c"
}


static gpointer __adblock_directive_dup0 (gpointer self) {
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	return self ? _adblock_directive_dup (self) : NULL;
#line 80 "whitelist.c"
}


static AdblockDirective* adblock_whitelist_real_match (AdblockFeature* base, const gchar* request_uri, const gchar* page_uri, GError** error) {
	AdblockWhitelist * self;
	AdblockDirective* result = NULL;
	GHashTable* _tmp0_ = NULL;
	GList* _tmp1_ = NULL;
	GError * _inner_error_ = NULL;
#line 19 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	self = (AdblockWhitelist*) base;
#line 19 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	g_return_val_if_fail (request_uri != NULL, NULL);
#line 19 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	g_return_val_if_fail (page_uri != NULL, NULL);
#line 20 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	_tmp0_ = ((AdblockFilter*) self)->rules;
#line 20 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	_tmp1_ = g_hash_table_get_keys (_tmp0_);
#line 100 "whitelist.c"
	{
		GList* white_collection = NULL;
		GList* white_it = NULL;
#line 20 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
		white_collection = _tmp1_;
#line 20 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
		for (white_it = white_collection; white_it != NULL; white_it = white_it->next) {
#line 108 "whitelist.c"
			const gchar* white = NULL;
#line 20 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
			white = (const gchar*) white_it->data;
#line 112 "whitelist.c"
			{
				GRegex* regex = NULL;
				GHashTable* _tmp2_ = NULL;
				const gchar* _tmp3_ = NULL;
				gconstpointer _tmp4_ = NULL;
				GRegex* _tmp5_ = NULL;
				gboolean _tmp6_ = FALSE;
				GRegex* _tmp7_ = NULL;
				const gchar* _tmp8_ = NULL;
				gboolean _tmp9_ = FALSE;
				GRegex* _tmp10_ = NULL;
				const gchar* _tmp11_ = NULL;
				const gchar* _tmp12_ = NULL;
				gboolean _tmp13_ = FALSE;
#line 21 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp2_ = ((AdblockFilter*) self)->rules;
#line 21 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp3_ = white;
#line 21 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp4_ = g_hash_table_lookup (_tmp2_, _tmp3_);
#line 21 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp5_ = _g_regex_ref0 ((GRegex*) _tmp4_);
#line 21 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				regex = _tmp5_;
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp7_ = regex;
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp8_ = request_uri;
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp9_ = g_regex_match_full (_tmp7_, _tmp8_, (gssize) (-1), 0, 0, NULL, &_inner_error_);
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp6_ = _tmp9_;
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				if (G_UNLIKELY (_inner_error_ != NULL)) {
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					g_propagate_error (error, _inner_error_);
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					_g_regex_unref0 (regex);
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					_g_list_free0 (white_collection);
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					return NULL;
#line 155 "whitelist.c"
				}
#line 22 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				if (!_tmp6_) {
#line 23 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					result = NULL;
#line 23 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					_g_regex_unref0 (regex);
#line 23 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					_g_list_free0 (white_collection);
#line 23 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					return result;
#line 167 "whitelist.c"
				}
#line 24 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp10_ = regex;
#line 24 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp11_ = g_regex_get_pattern (_tmp10_);
#line 24 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp12_ = request_uri;
#line 24 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_tmp13_ = g_regex_match_simple (_tmp11_, _tmp12_, G_REGEX_UNGREEDY, G_REGEX_MATCH_NOTEMPTY);
#line 24 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				if (_tmp13_) {
#line 179 "whitelist.c"
					AdblockDirective _tmp14_ = 0;
					AdblockDirective* _tmp15_ = NULL;
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					_tmp14_ = ADBLOCK_DIRECTIVE_ALLOW;
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					_tmp15_ = __adblock_directive_dup0 (&_tmp14_);
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					result = _tmp15_;
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					_g_regex_unref0 (regex);
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					_g_list_free0 (white_collection);
#line 25 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
					return result;
#line 194 "whitelist.c"
				}
#line 20 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
				_g_regex_unref0 (regex);
#line 198 "whitelist.c"
			}
		}
#line 20 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
		_g_list_free0 (white_collection);
#line 203 "whitelist.c"
	}
#line 27 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	result = NULL;
#line 27 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	return result;
#line 209 "whitelist.c"
}


static void adblock_whitelist_class_init (AdblockWhitelistClass * klass) {
#line 14 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	adblock_whitelist_parent_class = g_type_class_peek_parent (klass);
#line 14 "/usr/src/ports/midori/midori-0.5.10-1.x86_64/src/extensions/adblock/whitelist.vala"
	((AdblockFeatureClass *) klass)->match = adblock_whitelist_real_match;
#line 218 "whitelist.c"
}


static void adblock_whitelist_instance_init (AdblockWhitelist * self) {
}


GType adblock_whitelist_get_type (void) {
	static volatile gsize adblock_whitelist_type_id__volatile = 0;
	if (g_once_init_enter (&adblock_whitelist_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (AdblockWhitelistClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) adblock_whitelist_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AdblockWhitelist), 0, (GInstanceInitFunc) adblock_whitelist_instance_init, NULL };
		GType adblock_whitelist_type_id;
		adblock_whitelist_type_id = g_type_register_static (ADBLOCK_TYPE_FILTER, "AdblockWhitelist", &g_define_type_info, 0);
		g_once_init_leave (&adblock_whitelist_type_id__volatile, adblock_whitelist_type_id);
	}
	return adblock_whitelist_type_id__volatile;
}



