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


#include <glib.h>
#include <glib-object.h>
#include <fsobasics.h>
#include <linux/rtnetlink.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Block1Data Block1Data;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))

struct _Block1Data {
	int _ref_count_;
	GMainLoop* loop;
};



void test_netlinknotifier_add_match (void);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda2_ (Block1Data* _data1_, GHashTable* properties);
static void ___lambda2__fso_framework_netlink_notifier_func (GHashTable* properties, gpointer self);
static gboolean __lambda3_ (void);
static gboolean ___lambda3__gsource_func (gpointer self);
void _vala_main (gchar** args, int args_length1);


/**
 * Copyright (C) 2009-2012 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
 *
 * 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.

 * This library 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
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 **/
static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (void * _userdata_) {
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		_g_main_loop_unref0 (_data1_->loop);
		g_slice_free (Block1Data, _data1_);
	}
}


static void __lambda2_ (Block1Data* _data1_, GHashTable* properties) {
	g_return_if_fail (properties != NULL);
	g_main_loop_quit (_data1_->loop);
}


static void ___lambda2__fso_framework_netlink_notifier_func (GHashTable* properties, gpointer self) {
	__lambda2_ (self, properties);
}


static gboolean __lambda3_ (void) {
	gboolean result = FALSE;
	system ("sudo route add -host 1.2.3.4 lo; sleep 1; sudo route del -host 1.2.3.4" \
" lo");
	result = FALSE;
	return result;
}


static gboolean ___lambda3__gsource_func (gpointer self) {
	gboolean result;
	result = __lambda3_ ();
	return result;
}


void test_netlinknotifier_add_match (void) {
	Block1Data* _data1_;
	GMainLoop* _tmp0_;
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_data1_->loop = _tmp0_;
	fso_framework_base_netlink_notifier_addMatch ((guint16) RTM_NEWROUTE, ___lambda2__fso_framework_netlink_notifier_func, _data1_);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1, ___lambda3__gsource_func, NULL, NULL);
	g_main_loop_run (_data1_->loop);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}


void _vala_main (gchar** args, int args_length1) {
	g_test_init (&args_length1, &args, NULL);
	g_test_run ();
}


int main (int argc, char ** argv) {
	g_thread_init (NULL);
	g_type_init ();
	_vala_main (argv, argc);
	return 0;
}



