G_MODULE_EXPORT gboolean
swfdec_mozilla_make_sure_this_thing_stays_in_memory (void)
{
  static gboolean inited = FALSE;
  GModule *module;
  gpointer check;
    
  if (inited)
    return TRUE;
  if (!g_module_supported ())
    return FALSE;
  module = g_module_open (PLUGIN_FILE, 0);
  if (module == NULL)
    return FALSE;
  /* now load this function name to be sure it we've loaded ourselves */
  if (!g_module_symbol (module, "swfdec_mozilla_make_sure_this_thing_stays_in_memory", &check) ||
      check != swfdec_mozilla_make_sure_this_thing_stays_in_memory) {
    g_module_close (module);
    return FALSE;
  }
  g_module_make_resident (module);
  g_module_close (module);
  inited = TRUE;
  return TRUE;
}
Exemple #2
0
gboolean
rb_plugins_engine_init (RBShell *shell)
{
	g_return_val_if_fail (rb_plugins == NULL, FALSE);

	if (!g_module_supported ())
	{
		g_warning ("rb is not able to initialize the plugins engine.");
		return FALSE;
	}
	rb_profile_start ("plugins engine init");

	rb_plugins = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)rb_plugin_info_free);

	rb_plugins_shell = shell;
	g_object_ref (G_OBJECT (rb_plugins_shell));
#ifdef ENABLE_PYTHON
	rb_python_module_init_python ();
#endif

	rb_plugins_engine_load_all ();

	garbage_collect_id = g_timeout_add_seconds_full (G_PRIORITY_LOW, 20, garbage_collect_cb, NULL, NULL);

	rb_profile_end ("plugins engine init");

	return TRUE;
}
Exemple #3
0
gboolean
eom_plugin_engine_init (void)
{
	eom_debug (DEBUG_PLUGINS);

	g_return_val_if_fail (eom_plugins_list == NULL, FALSE);

	if (!g_module_supported ()) {
		g_warning ("eom is not able to initialize the plugins engine.");

		return FALSE;
	}

	eom_plugin_engine_settings = g_settings_new (EOM_CONF_PLUGINS);

	g_signal_connect (eom_plugin_engine_settings,
			  "changed::" EOM_CONF_PLUGINS_ACTIVE_PLUGINS,
			  G_CALLBACK (eom_plugin_engine_active_plugins_changed),
			  NULL);

	eom_plugin_engine_get_active_plugins ();

	eom_plugin_engine_load_all ();

	return TRUE;
}
void remmina_plugin_manager_init(void)
{
	GDir *dir;
	const gchar *name, *ptr;
	gchar *fullpath;

	remmina_plugin_table = g_ptr_array_new();

	if (!g_module_supported())
	{
		g_print("Dynamic loading of plugins is not supported in this platform!\n");
		return;
	}

	dir = g_dir_open(REMMINA_PLUGINDIR, 0, NULL);
	if (dir == NULL)
		return;
	while ((name = g_dir_read_name(dir)) != NULL)
	{
		if ((ptr = strrchr(name, '.')) == NULL)
			continue;
		ptr++;
		if (g_strcmp0(ptr, G_MODULE_SUFFIX) != 0)
			continue; fullpath = g_strdup_printf(REMMINA_PLUGINDIR "/%s", name);
		remmina_plugin_manager_load_plugin(fullpath);
		g_free(fullpath);
	}
	g_dir_close(dir);
}
/*! @brief dlopen()s a format plugin
 * 
 * The get_info() function on the format plugin gets called
 * 
 * @param env The environment in which to open the plugin
 * @param path Where to find this plugin
 * @param error Pointer to a error struct
 * @return Pointer to the plugin on success, NULL otherwise
 * 
 */
osync_bool osync_module_load(OSyncModule *module, const char *path, OSyncError **error)
{
  osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, module, path, error);
  osync_assert(module);
  osync_assert(!module->module);
	
  if (!g_module_supported()) {
    osync_error_set(error, OSYNC_ERROR_GENERIC, "This platform does not support loading of modules");
    goto error;
  }

  /* Try to open the module or fail if an error occurs */
  module->module = g_module_open(path, 0);
  if (!module->module) {
    osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open module %s: %s", path, g_module_error());
    goto error;
  }
	
  module->path = g_strdup(path);
	
  osync_trace(TRACE_EXIT, "%s", __func__);
  return TRUE;

 error:
  osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
  return FALSE;
}
Exemple #6
0
static int module_load_full(const char *path, const char *rootmodule,
			    const char *submodule, int start, int end,
			    char **prefixes)
{
	MODULE_REC *module;
        int status, try_prefixes;

	if (!g_module_supported())
		return FALSE;

	module = module_find(rootmodule);
	if (module != NULL && (strcmp(submodule, rootmodule) == 0 ||
			       module_file_find(module, submodule) != NULL)) {
                /* module is already loaded */
		module_error(MODULE_ERROR_ALREADY_LOADED, NULL,
			     rootmodule, submodule);
                return FALSE;
	}

	/* check if the given module exists.. */
	try_prefixes = strcmp(rootmodule, submodule) == 0;
	status = module_load_name(path, rootmodule, submodule, try_prefixes);
	if (status == -1 && try_prefixes) {
		/* nope, try loading the module_core,
		   fe_module, etc. */
		status = module_load_prefixes(path, rootmodule,
					      start, end, prefixes);
	}

	return status > 0;
}
Exemple #7
0
gboolean init_plugins(const char *plugin_dir)
{
	gboolean ret = TRUE;

	if (!g_module_supported()) {
		log_global(LOG_WARNING, "DSO's not supported on this platform. Not loading any plugins");
	} else {
		const char *name;
		GDir *dir = g_dir_open(plugin_dir, 0, NULL);
		if (!dir) {
			log_global(LOG_WARNING, "Plugin dir does not exist, not loading plugins");
			return FALSE;
		}

		while ((name = g_dir_read_name(dir))) {
			if (strcmp(name + strlen(name) - strlen(G_MODULE_SUFFIX), G_MODULE_SUFFIX) != 0)
				continue;

			if (!load_plugin(plugin_dir, name))
				ret = FALSE;
		}

		g_dir_close(dir);
	}

	return ret;
}
Exemple #8
0
/**
 * gimp_module_db_load:
 * @db:          A #GimpModuleDB.
 * @module_path: A #G_SEARCHPATH_SEPARATOR delimited list of directories
 *               to load modules from.
 *
 * Scans the directories contained in @module_path and creates a
 * #GimpModule instance for every loadable module contained in the
 * directories.
 **/
void
gimp_module_db_load (GimpModuleDB *db,
                     const gchar  *module_path)
{
  g_return_if_fail (GIMP_IS_MODULE_DB (db));
  g_return_if_fail (module_path != NULL);

  if (g_module_supported ())
    {
      GList *path;
      GList *list;

      path = gimp_config_path_expand_to_files (module_path, NULL);

      for (list = path; list; list = g_list_next (list))
        {
          gimp_module_db_load_directory (db, list->data);
        }

      g_list_free_full (path, (GDestroyNotify) g_object_unref);
    }

  if (DUMP_DB)
    g_list_foreach (db->modules, gimp_module_db_module_dump_func, NULL);
}
Exemple #9
0
void
init_plugins (void)
{
  if (g_module_supported ()) {
    init_dynamic_plugins ();
  }
}
static void
pluma_plugins_engine_init (PlumaPluginsEngine *engine)
{
	pluma_debug (DEBUG_PLUGINS);

	if (!g_module_supported ())
	{
		g_warning ("pluma is not able to initialize the plugins engine.");
		return;
	}

	engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
						    PLUMA_TYPE_PLUGINS_ENGINE,
						    PlumaPluginsEnginePrivate);

	load_all_plugins (engine);

	/* make sure that the first reactivation will read active plugins
	   from the prefs */
	engine->priv->activate_from_prefs = TRUE;

	/* mapping from loadername -> loader object */
	engine->priv->loaders = g_hash_table_new_full (hash_lowercase,
						       equal_lowercase,
						       (GDestroyNotify)g_free,
						       (GDestroyNotify)loader_destroy);
}
Exemple #11
0
gint
main (gint argc, gchar **argv)
{
	hashfs_backend_t *backend;

	hashfs_config_init();
	if (!hashfs_db_init(FALSE))
		HASHFS_ERROR("Unable to open database");

	if (g_module_supported()) {
		hashfs_backends_load("/usr/local/lib/hashfs");
		hashfs_backends_load("./_build_/default/src/backends/anidb/");
	} else {
		HASHFS_LOG("This platform does not support loading modules");

		return 0;
	}

	if (argc > 1)
		hashfs_cmd(main_cmds, argv[1], argc, argv);
	else
		hashfs_cmd(main_cmds, "help", argc, argv);


	hashfs_backends_destroy();
	hashfs_config_destroy();
	hashfs_db_destroy();

	return 0;
}
GHashTable* gen_cnode_module_init(){
    GHashTable* modules = NULL;
    //gen_cnode_module_t* bifs = NULL;
    

    if( !g_module_supported() ){
        fprintf(stderr, "g_module not supported!\n");
        goto gen_cnode_module_open_exit;
    }   

    modules = g_hash_table_new_full( g_str_hash, 
                                     g_str_equal,
                                     g_free,
                                     NULL );

    /*bifs = g_new0( gen_cnode_module_t, 1 );
    bifs->state = (struct gen_cnode_lib_state_s *)modules;
    bifs->funcs = g_hash_table_new_full( g_str_hash,
                                         g_str_equal,
                                         g_free,
                                         NULL );
    
    //Iterate through BIFs to build up gen_cnode module info
    for( i=0; gen_cnode_bifs[i]; i++ ){
         gen_cnode_bif_t* bif = gen_cnode_bifs[i];
         g_hash_table_insert( bifs->funcs, bif->name, (void*)bif->fp );
    }

    //Add gen_cnode entry
    g_hash_table_insert( modules, (void*)"gen_cnode", (void*)bifs );*/

    gen_cnode_module_open_exit:
    return modules;
}
Exemple #13
0
void PluginManager::loadLibrary(const char* library)
{    
    GModule *module = NULL;
    rsGetPluginFunc getPluginFunc = NULL;

    /* Check whether glib is compiled with plugin support */
    if(g_module_supported() == FALSE) {
        throw runtime_error("GLib is not compiled with module support which is necessary to load the tools");
    }

    module = g_module_open(library, G_MODULE_BIND_MASK);

    /* Check whether the plugin was loaded successfully */
    if(module == NULL) {
        throw runtime_error( (string("Library '") + string(library) + string("' could not be opened, because of the following error: ") + string(g_module_error())).c_str() );
    }

    /* Load the symbol and assign it to our function pointer */
    if(g_module_symbol(module, "rsGetPlugin", (gpointer *) &getPluginFunc) == FALSE) {
        throw runtime_error( (string("Library '") + string(library) + string("' could not be loaded, due to the following error: ") + string(g_module_error()) ).c_str() );
    }

    /* acquire the plugin */
    Plugin *plugin = getPluginFunc();
    registerPlugin(plugin);

    //if(g_module_close(module) == FALSE) {
    //    throw runtime_error( (string("Library '") + string(library) + string("' could not be closed, due to the following error: ") + string(g_module_error()) ).c_str() );
    //}
}
osync_bool osync_module_load(OSyncModule *module, const char *path, OSyncError **error)
{
	osync_trace(TRACE_ENTRY, "%s(%p, %s, %p)", __func__, module, path, error);
	osync_assert(module);
	osync_assert(!module->module);
	
	if (!g_module_supported()) {
		osync_error_set(error, OSYNC_ERROR_GENERIC, "This platform does not support loading of modules");
		goto error;
	}

	/* Try to open the module or fail if an error occurs.
	 *
	 * Do local bind to avoid symbol-clashing - i.e. plugins having the same
	 * functions name - e.g. finalize().
	 *
	 * Don't do lazy binding, otherwise symbols of kdepim-sync can't get loaded.
	 * Related to C++ and dlopen?
	 */
	module->module = g_module_open(path, G_MODULE_BIND_LOCAL);
	if (!module->module) {
		osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to open module %s: %s", path, g_module_error());
		goto error;
	}
	
	module->path = osync_strdup(path);
	
	osync_trace(TRACE_EXIT, "%s", __func__);
	return TRUE;

 error:
	osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
	return FALSE;
}
/**
 * initialize the basic components of the chassis
 */
int chassis_frontend_init_glib() {
	const gchar *check_str = NULL;
#if 0
	g_mem_set_vtable(glib_mem_profiler_table);
#endif

	if (!GLIB_CHECK_VERSION(2, 6, 0)) {
		g_critical("the glib header are too old, need at least 2.6.0, got: %d.%d.%d", 
				GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);

		return -1;
	}

	check_str = glib_check_version(GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);

	if (check_str) {
		g_critical("%s, got: lib=%d.%d.%d, headers=%d.%d.%d", 
			check_str,
			glib_major_version, glib_minor_version, glib_micro_version,
			GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);

		return -1;
	}

	if (!g_module_supported()) {
		g_critical("loading modules is not supported on this platform");
		return -1;
	}

	g_thread_init(NULL);

	return 0;
}
ModuleFactory::ModuleFactory() {
	RegisterModuleType( Constant::GetTypeStatic(), Constant::Create );
	RegisterModuleType( MWavetableOsc::GetTypeStatic(), MWavetableOsc::Create );
	RegisterModuleType( Sum::GetTypeStatic(), Sum::Create );
	RegisterModuleType( Slider::GetTypeStatic(), Slider::Create );
	RegisterModuleType( Gain::GetTypeStatic(), Gain::Create );
	RegisterModuleType( Multiplication::GetTypeStatic(), Multiplication::Create );
	RegisterModuleType( Filter12dB::GetTypeStatic(), Filter12dB::Create );
	RegisterModuleType( Noise::GetTypeStatic(), Noise::Create );
	RegisterModuleType( TextFileOut::GetTypeStatic(), TextFileOut::Create );
	RegisterModuleType( MGate::GetTypeStatic(), MGate::Create );
	RegisterModuleType( MMonitor::GetTypeStatic(), MMonitor::Create );
	RegisterModuleType( MADSRLinear::GetTypeStatic(), MADSRLinear::Create );
	RegisterModuleType( MSinOsc::GetTypeStatic(), MSinOsc::Create );
    RegisterModuleType( MMonitorGraph::GetTypeStatic(), MMonitorGraph::Create );
    RegisterModuleType( Delay::GetTypeStatic(), Delay::Create );
    RegisterModuleType( MFeedbackDelay::GetTypeStatic(), MFeedbackDelay::Create );
    RegisterModuleType( MVariableDelay::GetTypeStatic(), MVariableDelay::Create );
    RegisterModuleType( FFT::GetTypeStatic(), FFT::Create );
    RegisterModuleType( MModule::GetTypeStatic(), MModule::Create );
    RegisterModuleType( MAllpassFilter::GetTypeStatic(), MAllpassFilter::Create );
    
	if ( g_module_supported() == TRUE ) {
    	RegisterAllPlugins();
    }
}
Exemple #17
0
static int qemu_rbd_load_libs(void)
{
    if (librbd_loaded) {
        return 0;
    }

    if (!g_module_supported()) {
        error_report("modules are not supported on this platform: %s",
                     g_module_error());
        return -1;
    }

    librbd_handle = g_module_open("/usr/lib64/qemu/librbd.so.1", 0);
    if (!librbd_handle) {
        error_report("error loading librbd: %s", g_module_error());
        return -1;
    }

    /*
     * Due to c++ templates used in librbd/librados and their
     * dependencies, and linker duplicate trimming rules, closing
     * librbd would leave it mapped. Make this explicit.
     */
    g_module_make_resident(librbd_handle);

    if (qemu_rbd_set_mandatory_functions() < 0) {
        return -1;
    }
    qemu_rbd_set_optional_functions();
    librbd_loaded = true;

    return 0;
}
gboolean module_init (void)
{
	if (!g_module_supported()) {
		LOCATION_LOGW("module is not supported");
		return FALSE;
	}
	return TRUE;
}
Exemple #19
0
void moloch_plugins_load(char **plugins) {

    if (!config.pluginsDir)
        return;

    if (!plugins)
        return;

    if (!g_module_supported ()) {
        LOG("ERROR - glib compiled without module support");
        return;
    }

    moloch_add_can_quit((MolochCanQuitFunc)moloch_plugins_outstanding, "plugin outstanding");

    int         i;

    for (i = 0; plugins[i]; i++) {
        const char *name = plugins[i];

        int d;
        GModule *plugin = 0;
        for (d = 0; config.pluginsDir[d]; d++) {
            gchar   *path = g_build_filename (config.pluginsDir[d], name, NULL);

            if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
                g_free (path);
                continue;
            }

            plugin = g_module_open (path, 0); /*G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);*/

            if (!plugin) {
                LOG("ERROR - Couldn't load plugin %s from '%s'\n%s", name, path, g_module_error());
                g_free (path);
                continue;
            }

            g_free (path);
            break;
        }

        if (!plugin) {
            LOG("WARNING - plugin '%s' not found", name);
            continue;
        }

        MolochPluginInitFunc plugin_init;

        if (!g_module_symbol(plugin, "moloch_plugin_init", (gpointer *)(char*)&plugin_init) || plugin_init == NULL) {
            LOG("ERROR - Module %s doesn't have a moloch_plugin_init", name);
            continue;
        }

        plugin_init();
    }
}
Exemple #20
0
void
eventd_plugins_load(EventdCoreContext *core, EventdCoreInterface *interface)
{
    const gchar *env_whitelist;
    const gchar *env_blacklist;
    const gchar *env_base_dir;
    gchar **whitelist = NULL;
    gchar **blacklist = NULL;
    gchar *plugins_dir;

    if ( ! g_module_supported() )
    {
        g_warning("Couldn't load plugins: %s", g_module_error());
        return;
    }

    plugins = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, _eventd_plugins_plugin_free);

    env_whitelist = g_getenv("EVENTD_PLUGINS_WHITELIST");
    if ( env_whitelist != NULL )
        whitelist = g_strsplit(env_whitelist, ",", 0);

    env_blacklist = g_getenv("EVENTD_PLUGINS_BLACKLIST");
    if ( env_blacklist != NULL )
        blacklist = g_strsplit(env_blacklist, ",", 0);

    env_base_dir = g_getenv("EVENTD_PLUGINS_DIR");
    if ( env_base_dir != NULL )
    {
        if ( env_base_dir[0] == '~' )
            plugins_dir = g_build_filename(g_get_home_dir(), env_base_dir+2, NULL);
        else
            plugins_dir = g_build_filename(env_base_dir,  NULL);

        if ( g_file_test(plugins_dir, G_FILE_TEST_IS_DIR) )
            _eventd_plugins_load_dir(core, interface, plugins_dir, whitelist, blacklist);
        g_free(plugins_dir);
    }

    plugins_dir = g_build_filename(g_get_user_data_dir(), PACKAGE_NAME, "plugins", NULL);
    if ( g_file_test(plugins_dir, G_FILE_TEST_IS_DIR) )
        _eventd_plugins_load_dir(core, interface, plugins_dir, whitelist, blacklist);
    g_free(plugins_dir);

    plugins_dir = g_build_filename(DATADIR, PACKAGE_NAME, "plugins", NULL);
    if ( g_file_test(plugins_dir, G_FILE_TEST_IS_DIR) )
        _eventd_plugins_load_dir(core, interface, plugins_dir, whitelist, blacklist);
    g_free(plugins_dir);

    plugins_dir = g_build_filename(LIBDIR, PACKAGE_NAME, "plugins", NULL);
    if ( g_file_test(plugins_dir, G_FILE_TEST_IS_DIR) )
        _eventd_plugins_load_dir(core, interface, plugins_dir, whitelist, blacklist);
    g_free(plugins_dir);

    g_strfreev(blacklist);
    g_strfreev(whitelist);
}
pipeline_t * pipeline_cargar(const char *ruta, funcion_error_t funcion_error, const void *dato) 
{
    xmlDocPtr doc;
    xmlNodePtr cur;
    xmlValidCtxt cvp;
    pipeline_t *p;

    if(!g_module_supported()) {
      return 0;
    }
    
    doc = xmlParseFile(ruta);
    if (doc == NULL) {
	return 0;
    }
    
    cvp.userData = (void *) stderr;
    cvp.error    = (xmlValidityErrorFunc) fprintf;
    cvp.warning  = (xmlValidityWarningFunc) fprintf;
    if (!xmlValidateDocument(&cvp, doc)) {
      return 0;
    }
    cur = xmlDocGetRootElement(doc);
    if (cur == NULL) {
	xmlFreeDoc(doc);
	return 0;
    }
    if (xmlStrcmp(cur->name, (const xmlChar *) "pipeline")) {
	xmlFreeDoc(doc);
	return 0;
    }

    chdir(g_path_get_dirname(ruta));
    p = (pipeline_t*)malloc(sizeof(pipeline_t));
    p->m_modulos = g_hash_table_new_full(g_str_hash, g_str_equal, /*pipeline_borrar_cadena*/0, pipeline_borrar_elemento);
    p->m_funcion_error = funcion_error;
    p->m_dato_funcion_error = (gpointer)dato;
    p->m_nombres = 0;
    cur = cur->xmlChildrenNode;
    cur = cur->next;
    while (cur != NULL) {
	if ((!xmlStrcmp(cur->name, (const xmlChar *) "modulo"))) {
	  p = pipeline_leer_xml(p, doc, cur/*, dir*/);
	    if(p == 0) {
	      xmlFreeDoc(doc);
	      pipeline_borrar(p);
	      return 0;
	    }
	}
	cur = cur->next;
    }
    xmlFreeDoc(doc);
    p->m_nombres = (char **)realloc(p->m_nombres, sizeof(char **) * (g_hash_table_size(p->m_modulos) + 1));
    p->m_nombres[g_hash_table_size(p->m_modulos)] = 0;
    return p;
}
Exemple #22
0
void moloch_plugins_init()
{
    HASH_INIT(p_, plugins, moloch_string_hash, moloch_string_cmp);

    if (!config.pluginsDir)
        return;

    if (!config.plugins)
        return;

    if (!g_module_supported ()) {
        LOG("ERROR - glib compiled without module support");
        return;
    }

    int         i;

    for (i = 0; config.plugins[i]; i++) {
        const char *name = config.plugins[i];

        int d;
        GModule *plugin = 0;
        for (d = 0; config.pluginsDir[d]; d++) {
            gchar   *path = g_build_filename (config.pluginsDir[d], name, NULL);

            if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
                g_free (path);
                continue;
            }

            plugin = g_module_open (path, 0); /*G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);*/

            if (!plugin) {
                LOG("ERROR - Couldn't load plugin %s from '%s'\n%s", name, path, g_module_error());
                g_free (path);
                continue;
            }

            g_free (path);
            break;
        }

        if (!plugin)
            continue;

        MolochPluginInitFunc plugin_init;

        if (!g_module_symbol(plugin, "moloch_plugin_init", (gpointer *)(char*)&plugin_init) || plugin_init == NULL) {
            LOG("ERROR - Module %s doesn't have a moloch_plugin_init", name);
            continue;
        }

        plugin_init();
    }
}
Exemple #23
0
/* Load all plugins in a directory ... look for '.plg' suffix. Error if we had
 * any probs.
 */
static int
vips_load_plugins( const char *fmt, ... )
{
        va_list ap;
        char dir_name[VIPS_PATH_MAX];
        GDir *dir;
	const char *name;
        int result;

	/* Silently succeed if we can't do modules.
	 */
	if( !g_module_supported() )
		return( 0 );

        va_start( ap, fmt );
        (void) vips_vsnprintf( dir_name, VIPS_PATH_MAX - 1, fmt, ap );
        va_end( ap );

#ifdef DEBUG
	printf( "vips_load_plugins: searching \"%s\"\n", dir_name );
#endif /*DEBUG*/

        if( !(dir = g_dir_open( dir_name, 0, NULL )) ) 
		/* Silent success for dir not there.
		 */
                return( 0 );

        result = 0;
        while( (name = g_dir_read_name( dir )) )
                if( vips_ispostfix( name, ".plg" ) ) { 
			char path[VIPS_PATH_MAX];
			GModule *module;

			vips_snprintf( path, VIPS_PATH_MAX - 1, 
				"%s" G_DIR_SEPARATOR_S "%s", dir_name, name );

#ifdef DEBUG
			printf( "vips_load_plugins: loading \"%s\"\n", path );
#endif /*DEBUG*/

			module = g_module_open( path, G_MODULE_BIND_LAZY );
			if( !module ) {
				vips_warn( "vips_init", 
					_( "unable to load \"%s\" -- %s" ), 
					path, 
					g_module_error() ); 
				result = -1;
			}
                }
        g_dir_close( dir );

	return( result );
}
Exemple #24
0
static void
file_manager__load_plugins ()
{
	FileTypePluginPtr plugin = NULL;
	GError* error = NULL;

	if(!g_module_supported()) g_error("Modules not supported! (%s)", g_module_error());

	int found = 0;

	char* plugin_path = g_strdup_printf("%s:%s", "../lib/file_manager/filetypes/.libs", PLUGIN_PATH);
	gchar** paths = g_strsplit(plugin_path, ":", 0);
	g_free(plugin_path);
	char* path;
	int i = 0;
	while((path = paths[i++])){
		if(!g_file_test(path, G_FILE_TEST_EXISTS)) continue;

		dbg(1, "scanning for plugins (%s) ...", path);
		GDir* dir = g_dir_open(path, 0, &error);
		if (!error) {
			const gchar* filename = g_dir_read_name(dir);
			while (filename) {
				dbg(1, "testing %s...", filename);
				gchar* filepath = g_build_filename(path, filename, NULL);
				// filter files with correct library suffix
				if(!strncmp(G_MODULE_SUFFIX, filename + strlen(filename) - strlen(G_MODULE_SUFFIX), strlen(G_MODULE_SUFFIX))) {
					// If we find one, try to load plugin info and if this was successful try to invoke the specific plugin
					// type loader. If the second loading went well add the plugin to the plugin list.
					if (!(plugin = file_manager__plugin_load(filepath))) {
						dbg(0, "'%s' failed to load.", filename);
					} else {
						found++;
						plugin->init();
						plugins = g_slist_append(plugins, plugin);
					}
				} else {
					dbg(2, "-> no library suffix");
				}
				g_free(filepath);
				filename = g_dir_read_name(dir);
			}
			g_dir_close(dir);
		} else {
			gwarn("dir='%s' failed. %s", path, error->message);
			g_error_free(error);
			error = NULL;
		}
	}
	g_strfreev(paths);

	dbg(1, "filetype plugins loaded: %i.", found);
}
void main_ui_create_show_tests ()
{
	DEBUG_IF (1, "%d", g_module_supported ());
	PtrMainUI main_ui = NULL;
	main_ui_create (&main_ui);
	main_ui_show (main_ui);
	GtkWindow* window = main_ui_get_window (main_ui);
	g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (main_ui_std_destroy), main_ui);
	
	
	gtk_main();
}
Exemple #26
0
EventdWsModule *
eventd_ws_init(void)
{
    if ( ! g_module_supported() )
        return NULL;

    EventdWsModule *ws = NULL;
    gchar **dirs, **dir;
    dirs = evhelpers_dirs_get_lib("MODULES", "modules" G_DIR_SEPARATOR_S MODULES_VERSION);
    for ( dir = dirs ; ( ws == NULL ) && ( *dir != NULL ) ; ++dir )
        ws = _eventd_ws_module_load_dir(*dir);
    g_free(dirs);
    return ws;
}
Exemple #27
0
static gboolean get_fpointer(char *cmd, ei_x_buff *xbuf, gpointer* poi) {
  extern GModule* gmod;
  
  if ( ! g_module_supported() ) g_critical("gtkNode requires working gmodule");
  
  if ( ! gmod ) gmod = g_module_open(NULL,0); /* "gtknode_gtk.so" */
  
  if ( g_module_symbol(gmod, cmd, poi) ) return TRUE;
  
  g_warning("could not find '%s'.", cmd);
  gn_enc_2_error(xbuf, "no_such_function");
  ei_x_encode_atom(xbuf, cmd);
  return FALSE;
}
Exemple #28
0
int main (int argc, 
          char *argv[])
{
  GModule *module;
  PrintMessageFunc print_the_message;
  PrintAnotherFunc print_another_one;
  gchar *text = "This is some text";

  /* Make sure module loading is supported on the user's machine. */
  g_assert (g_module_supported ());

  /* Open the library and resolve symbols only when necessary. */
  module = g_module_open ("/usr/lib/plugin.so", G_MODULE_BIND_LAZY);

  if (!module)
  {
    g_error ("Error: %s\n", (gchar*) g_module_error ());
    return -1;
  }

  /* Load the print_the_message() function. */
  if (!g_module_symbol (module, "print_the_message", 
                        (gpointer*) &print_the_message))
  {
    g_error ("Error: %s\n", (gchar*) g_module_error ());
    return -1;
  } 

  /* Load the destroy_the_evidence() function. */
  if (!g_module_symbol (module, "print_another_one", 
                        (gpointer*) &print_another_one))
  {
    g_error ("Error: %s\n", (gchar*) g_module_error ());
    return -1;
  }

  /* Run both loaded functions since there were no errors reported loading
   * neither the module nor the symbols. */
  print_the_message ((gpointer) text);
  print_another_one ("Another Message!");

  /* Close the module and free allocated resources. */
  if (!g_module_close (module))
    g_error ("Error: %s\n", (gchar*) g_module_error ());

  return 0;
}
Exemple #29
0
/**
 * gegl_module_db_load:
 * @db:          A #GeglModuleDB.
 * @module_path: A #G_SEARCHPATH_SEPARATOR delimited list of directories
 *               to load modules from.
 *
 * Scans the directories contained in @module_path using
 * gegl_datafiles_read_directories() and creates a #GeglModule
 * instance for every loadable module contained in the directories.
 **/
void
gegl_module_db_load (GeglModuleDB *db,
                     const gchar  *module_path)
{
  g_return_if_fail (GEGL_IS_MODULE_DB (db));
  g_return_if_fail (module_path != NULL);

  if (g_module_supported ())
    gegl_datafiles_read_directories (module_path,
                                     G_FILE_TEST_EXISTS,
                                     gegl_module_db_module_initialize,
                                     db);

#ifdef DUMP_DB
  g_list_foreach (db->modules, gegl_module_db_dump_module, NULL);
#endif
}
GuiModuleFactory::GuiModuleFactory() {
    RegisterGui( GConstant::GetTypeStatic(), GConstant::Create );
    RegisterGui( GSlider::GetTypeStatic(), GSlider::Create );
    RegisterGui( GGate::GetTypeStatic(), GGate::Create );
    RegisterGui( GMonitor::GetTypeStatic(), GMonitor::Create );
    RegisterGui( GFilter::GetTypeStatic(), GFilter::Create );
    RegisterGui( GGain::GetTypeStatic(), GGain::Create );
    RegisterGui( GADSR::GetTypeStatic(), GADSR::Create );
    //RegisterGui( GFFT::GetTypeStatic(), GFFT::Create );
    RegisterGui( GMonitorGraph::GetTypeStatic(), GMonitorGraph::Create );
    RegisterGui( GDelay::GetTypeStatic(), GDelay::Create );
    RegisterGui( GFeedbackDelay::GetTypeStatic(), GFeedbackDelay::Create );
    RegisterGui( GVariableDelay::GetTypeStatic(), GVariableDelay::Create );
    if ( g_module_supported() == TRUE ) {
        RegisterAllGuiPlugins();
    }
}