Пример #1
0
int main (int argc, char *argv[]) {
	char *locale_dir = NULL;


#ifdef GW_DEBUG_MODE
#ifdef HAVE_GTK20
	g_mem_set_vtable ( glib_mem_profiler_table);
#endif

	gw_am_log_msg ( 0, __FILE__, __LINE__, __PRETTY_FUNCTION__, "application is starting ==> memory status : ");
	g_mem_profile ( );
#endif


#ifdef ENABLE_NLS
#ifdef GW_DEBUG_MODE
	gw_am_log_msg ( 0, __FILE__, __LINE__, __PRETTY_FUNCTION__, "NLS enabled");
#endif
	setlocale ( LC_ALL, "");
	if ( (locale_dir = gw_package_get_locale_dir ( )) != NULL) {
#ifdef GW_DEBUG_MODE
		gw_am_log_msg ( 0, __FILE__, __LINE__, __PRETTY_FUNCTION__, "Locale is %s", locale_dir);
#endif

		bindtextdomain ( PACKAGE, locale_dir);
		textdomain ( PACKAGE);
		g_free ( locale_dir);
	}
#endif

	gtk_set_locale ( );

//	g_log_set_handler ( "Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL);
//	g_log_set_handler ( "Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL);
	gtk_init ( &argc, &argv);

#ifdef GW_DEBUG_MODE
	gw_am_log_msg ( 0, __FILE__, __LINE__, __PRETTY_FUNCTION__, "application is initializing ==> memory status : ");
	g_mem_profile ( );
#endif

	gw_am_init ( argc, argv);

#ifdef GW_DEBUG_MODE
	gw_am_log_msg ( 0, __FILE__, __LINE__, __PRETTY_FUNCTION__, "application is loading catalog ==> memory status : ");
	g_mem_profile ( );
#endif

	/* Enter the main loop */
	gtk_main ( );

#ifdef GW_DEBUG_MODE
	gw_am_log_msg ( 0, __FILE__, __LINE__, __PRETTY_FUNCTION__, "application is exited ==> memory status : ");
	g_mem_profile ( );
#endif

	return 0;
}
Пример #2
0
gw_tm_t* gw_tm_init()
{
	int rc;
	int um_tm_pipe[2];
	
    /* ------------------------------------------------------------ */
    /* 1.- Execution Manager Initialization                         */
    /* ------------------------------------------------------------ */
        
    pthread_mutex_init(&(gw_tm.mutex),(pthread_mutexattr_t *) NULL);

    pthread_mutex_lock(&(gw_tm.mutex));

    rc = pipe(um_tm_pipe);
    if ( rc == -1)
    	return NULL;
    	
    gw_tm.um_tm_pipe_r = um_tm_pipe[0];
    gw_tm.um_tm_pipe_w = um_tm_pipe[1];   
    
    fcntl(gw_tm.um_tm_pipe_r, F_SETFD, FD_CLOEXEC);
    fcntl(gw_tm.um_tm_pipe_w, F_SETFD, FD_CLOEXEC);
        
    gw_tm.dm_am = NULL;
    
    /* ---------------------------------------------------- */
    /* 2.- Init Action Manager                              */
    /* ---------------------------------------------------- */

    gw_am_init(&(gw_tm.am));

    gw_am_register(GW_ACTION_FINALIZE, GW_ACTION_SEQUENTIAL, gw_tm_finalize,
            &(gw_tm.am));                

    gw_am_register(GW_ACTION_TIMER, GW_ACTION_SEQUENTIAL, gw_tm_timer,
            &(gw_tm.am));            
                  
    gw_am_register("GW_TM_PROLOG", GW_ACTION_SEQUENTIAL, gw_tm_prolog,
            &(gw_tm.am));
            
    gw_am_register("GW_TM_EPILOG", GW_ACTION_SEQUENTIAL, gw_tm_epilog,
            &(gw_tm.am));       

    pthread_mutex_unlock(&(gw_tm.mutex));

    /* ------------------------------------------------------------ */
    
    return &(gw_tm);
}
Пример #3
0
gw_um_t* gw_um_init()
{
    /* ------------------------------------------------------------ */
    /* 1.- Information Manager Initialization                       */
    /* ------------------------------------------------------------ */
        
    pthread_mutex_init(&(gw_um.mutex),(pthread_mutexattr_t *) NULL);

    pthread_mutex_lock(&(gw_um.mutex));

    /* ---------------------------------------------------- */
    /* 2.- Init Action Manager                              */
    /* ---------------------------------------------------- */

    gw_am_init(&(gw_um.am));

    /* ---------------------------------------------------- */
    /* 2.1- Information Manager Actions                     */
    /*      a.- Discover                                    */
    /*      b.- Monitor                                     */
    /* ---------------------------------------------------- */

    gw_am_register(GW_ACTION_FINALIZE, 
                   GW_ACTION_SEQUENTIAL, 
                   gw_um_finalize,
                   &(gw_um.am));

    gw_am_register(GW_ACTION_TIMER, 
                   GW_ACTION_SEQUENTIAL, 
                   gw_um_timer,
                   &(gw_um.am));

    pthread_mutex_unlock(&(gw_um.mutex));

    /* ------------------------------------------------------------ */
    
    return &(gw_um);
}
Пример #4
0
gw_im_t* gw_im_init()
{        
    pthread_mutex_init(&(gw_im.mutex),(pthread_mutexattr_t *) NULL);

    pthread_mutex_lock(&(gw_im.mutex));

    /* ----------------------------------------------------- */
    /* Initialize IM structure                               */
    /* ----------------------------------------------------- */    

    gw_im.registered_mads = 0;

    gw_im.dm_am = NULL;

    gw_am_init(&(gw_im.am));

    /* ----------------------------------------------------- */
    /* Register IM events                                    */
    /*   - FINALIZE                                          */
    /*   - TIMER                                             */
    /* ----------------------------------------------------- */    

    gw_am_register(GW_ACTION_FINALIZE, 
                   GW_ACTION_SEQUENTIAL, 
                   gw_im_finalize,
                   &(gw_im.am));

    gw_am_register(GW_ACTION_TIMER, 
                   GW_ACTION_SEQUENTIAL, 
                   gw_im_timer,
                   &(gw_im.am));

    /* ---------------------------------------------------- */

    pthread_mutex_unlock(&(gw_im.mutex));
    
    return &(gw_im);
}
Пример #5
0
gw_em_t* gw_em_init()
{
    int rc;
    int um_em_pipe[2];
	
    /* ------------------------------------------------------------ */
    /* 1.- Execution Manager Initialization                         */
    /* ------------------------------------------------------------ */
        
    pthread_mutex_init(&(gw_em.mutex),(pthread_mutexattr_t *) NULL);

    pthread_mutex_lock(&(gw_em.mutex));
    
    rc = pipe(um_em_pipe);
    if ( rc == -1)
    	return NULL;
    	
    gw_em.um_em_pipe_r = um_em_pipe[0];
    gw_em.um_em_pipe_w = um_em_pipe[1];
    
    fcntl(gw_em.um_em_pipe_r, F_SETFD, FD_CLOEXEC);
    fcntl(gw_em.um_em_pipe_w, F_SETFD, FD_CLOEXEC);    

    gw_em.dm_am = NULL;

    /* ---------------------------------------------------- */
    /* 2.- Init Action Manager                              */
    /* ---------------------------------------------------- */

    gw_am_init(&(gw_em.am));

    /* ---------------------------------------------------- */
    /* 2.1- Execution Manager Actions                       */
    /*      a.- Finalize                                    */
    /*      b.- Poll (Timer action)                         */
    /*      c.- Submit                                      */
    /*      d.- Cancel                                      */
    /* ---------------------------------------------------- */

    gw_am_register(GW_ACTION_FINALIZE, 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_finalize,
                   &(gw_em.am));
                   
    gw_am_register(GW_ACTION_TIMER, 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_timer,
                   &(gw_em.am));
                   
    gw_am_register("GW_EM_SUBMIT", 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_submit,
                   &(gw_em.am));
                                      
    gw_am_register("GW_EM_CANCEL", 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_cancel,
                   &(gw_em.am));

    /* ---------------------------------------------------- */
    /* 2.1- Execution Manager State-transtion Actions       */
    /*      a.- pending                                     */
    /*      b.- active                                      */
    /*      c.- suspended                                   */
    /*      d.- failed                                      */
    /* ---------------------------------------------------- */

    gw_am_register("GW_EM_STATE_PENDING", 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_pending,
                   &(gw_em.am));

    gw_am_register("GW_EM_STATE_ACTIVE", 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_active,
                   &(gw_em.am));

    gw_am_register("GW_EM_STATE_SUSPENDED", 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_suspended, 
                   &(gw_em.am));


    gw_am_register("GW_EM_STATE_DONE", 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_done,
                   &(gw_em.am));
                   
    gw_am_register("GW_EM_STATE_FAILED", 
                   GW_ACTION_SEQUENTIAL, 
                   gw_em_failed,
                   &(gw_em.am));

    pthread_mutex_unlock(&(gw_em.mutex));

    return &(gw_em);
}