summaryrefslogtreecommitdiff
path: root/elock.c
blob: cd775db1076fcc8395875a66b72fe068c6df5784 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*- STANDAR LIBS */
#include <stdio.h>

/* ECORE LIBS */
#include <Ecore.h>

/* ELCOK LIBS */
/*#include "etimer.h"*/

/* ELOCK FUNC DECLARATION */
Ecore_Timer *elock_timer_callback(void *donnee);
/*Ecore_Event_Handler *event_handler;*/
int elock_timer (double laps);
int check_args (int arg);	
int elock_event_handler(int arc, char *arv);
int elock_event_cb (void *data, int ev_type, void *ev);

/* TEMPORARY GLOBAL VARIABLE */
Ecore_Event_Handler *handler1 = NULL;


int main (int argc, char **argv)
{
	int timer_result;
	int event_hand_result;
	double time;
	
	if ( check_args(argc) != 0 )
	{
		fprintf (stdout,"NEED 1 ARGUMENT\n");
		exit(1);
	}


/*	time =  strtod(argv[1], NULL);

	timer_result = elock_timer(time);
	
	if (timer_result != 0)
		fprintf (stdout,"ERROR OF TIMER");
*/		
	event_hand_result = elock_event_handler(argc, argv);
	if (event_hand_result != 0)
		fprintf (stdout,"ERROR OF EVENT HANDLER");

	return 0;
}

int check_args (int arg)
{
	if ( arg == 2 )
	{
		return 0;
	}
	
	return 1;
}

int elock_timer (double laps)
{
	ecore_init();

	ecore_timer_add(laps, elock_timer_callback, NULL);
/*	ecore_timer_add(10,timer_two_cb, NULL);*/

	ecore_main_loop_begin();
	ecore_shutdown();

	return 0;
}

Ecore_Timer *elock_timer_callback(void *donnee)
{
	fprintf(stdout,"1\n");
	fflush(stdout);

	if (donnee)
		ecore_timer_del(donnee);
			
	return 1;
}

int elock_event_handler(int arc, char *arv)
{
	
	ecore_init();
	
	ecore_app_args_set(arc, arv);
	
	handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, elock_event_cb, NULL);
	
	ecore_main_loop_begin();
	
	ecore_shutdown();
	
	return 0;
}

int elock_event_cb (void *data, int ev_type, void *ev)
{
	/*Ecore_Event_Signal_User *ev;*/

	if (handler1)
	{
		ecore_event_handler_del(handler1);
		handler1 = NULL;
	}
	return 0;
}