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


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <sys/inotify.h>
#include <fsobasics.h>
#include <glib/gstdio.h>

#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))


extern GMainLoop* loop;
GMainLoop* loop = NULL;

#define TEST_FILENAME "./this-testfile-no-content"
void myCallback (int flags, guint32 cookie, const gchar* name);
void test_inotifier_add (void);
static void _myCallback_fso_framework_inotify_notifier_func (int flags, guint32 cookie, const gchar* name, gpointer self);
static gboolean __lambda2_ (void);
static gboolean ___lambda2__gsource_func (gpointer self);
void test_inotifier_remove (void);
void _vala_main (gchar** args, int args_length1);
static void _test_inotifier_add_gcallback (void);
static void _test_inotifier_remove_gcallback (void);


void myCallback (int flags, guint32 cookie, const gchar* name) {
	int _tmp0_;
	guint32 _tmp1_;
	const gchar* _tmp2_;
	GMainLoop* _tmp3_;
	_tmp0_ = flags;
	_tmp1_ = cookie;
	_tmp2_ = name;
	g_debug ("testinotifier.vala:29: got callback %d, %d, %s", (gint) _tmp0_, (gint) _tmp1_, _tmp2_);
	_tmp3_ = loop;
	g_main_loop_quit (_tmp3_);
}


static void _myCallback_fso_framework_inotify_notifier_func (int flags, guint32 cookie, const gchar* name, gpointer self) {
	myCallback (flags, cookie, name);
}


static gboolean __lambda2_ (void) {
	gboolean result = FALSE;
	fso_framework_file_handling_write ("Dutty Content", TEST_FILENAME, FALSE);
	result = FALSE;
	return result;
}


static gboolean ___lambda2__gsource_func (gpointer self) {
	gboolean result;
	result = __lambda2_ ();
	return result;
}


void test_inotifier_add (void) {
	GMainLoop* _tmp0_;
	GMainLoop* _tmp1_;
	fso_framework_file_handling_write ("Hello World", TEST_FILENAME, TRUE);
	fso_framework_inotifier_add (TEST_FILENAME, IN_MODIFY, _myCallback_fso_framework_inotify_notifier_func, NULL);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1, ___lambda2__gsource_func, NULL, NULL);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (loop);
	loop = _tmp0_;
	_tmp1_ = loop;
	g_main_loop_run (_tmp1_);
	g_unlink (TEST_FILENAME);
}


void test_inotifier_remove (void) {
	guint _tmp0_ = 0U;
	guint handle;
	fso_framework_file_handling_write ("Hello World", TEST_FILENAME, TRUE);
	fso_framework_inotifier_remove ((guint) 123456);
	_tmp0_ = fso_framework_inotifier_add (TEST_FILENAME, IN_CREATE, _myCallback_fso_framework_inotify_notifier_func, NULL);
	handle = _tmp0_;
	fso_framework_inotifier_remove (handle);
	g_unlink (TEST_FILENAME);
}


static void _test_inotifier_add_gcallback (void) {
	test_inotifier_add ();
}


static void _test_inotifier_remove_gcallback (void) {
	test_inotifier_remove ();
}


void _vala_main (gchar** args, int args_length1) {
	g_test_init (&args_length1, &args, NULL);
	g_test_add_func ("/INotifier/Add", _test_inotifier_add_gcallback);
	g_test_add_func ("/INotifier/Remove", _test_inotifier_remove_gcallback);
	g_test_run ();
}


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



