summaryrefslogblamecommitdiff
path: root/elock.c
blob: cd775db1076fcc8395875a66b72fe068c6df5784 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                            

                                                

                                





                                                       


                                



                              





                                                     
 
                                      

                                         
        
                              






                                                            



                        
                       


                         
        






                             
                                                          







                                                 
                                               


                              



                                        


                 


























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