static void
xfsm_splash_screen_load (XfsmSplashScreen *splash,
                         const gchar      *engine)
{
  void (*init) (XfsmSplashEngine *engine);
  gchar *filename;

  filename = g_module_build_path (LIBDIR "/xfce4/session/splash-engines", engine);
  splash->module = g_module_open (filename, G_MODULE_BIND_LOCAL);
  g_free (filename);

  if (G_LIKELY (splash->module != NULL))
    {
      if (g_module_symbol (splash->module, "engine_init", (gpointer)&init))
        {
          init (&splash->engine);
        }
      else
        {
          g_module_close (splash->module);
          splash->module = NULL;
        }
    }
  else
    {
      g_warning ("Unable to load engine \"%s\": %s", engine, g_module_error ());
    }
}
Esempio n. 2
0
static MMPlugin *
load_plugin (const gchar *path)
{
    MMPlugin *plugin = NULL;
    GModule *module;
    MMPluginCreateFunc plugin_create_func;
    gint *major_plugin_version;
    gint *minor_plugin_version;
    gchar *path_display;

    /* Get printable UTF-8 string of the path */
    path_display = g_filename_display_name (path);

    module = g_module_open (path, G_MODULE_BIND_LAZY);
    if (!module) {
        g_warning ("Could not load plugin '%s': %s", path_display, g_module_error ());
        goto out;
    }

    if (!g_module_symbol (module, "mm_plugin_major_version", (gpointer *) &major_plugin_version)) {
        g_warning ("Could not load plugin '%s': Missing major version info", path_display);
        goto out;
    }

    if (*major_plugin_version != MM_PLUGIN_MAJOR_VERSION) {
        g_warning ("Could not load plugin '%s': Plugin major version %d, %d is required",
                   path_display, *major_plugin_version, MM_PLUGIN_MAJOR_VERSION);
        goto out;
    }

    if (!g_module_symbol (module, "mm_plugin_minor_version", (gpointer *) &minor_plugin_version)) {
        g_warning ("Could not load plugin '%s': Missing minor version info", path_display);
        goto out;
    }

    if (*minor_plugin_version != MM_PLUGIN_MINOR_VERSION) {
        g_warning ("Could not load plugin '%s': Plugin minor version %d, %d is required",
                   path_display, *minor_plugin_version, MM_PLUGIN_MINOR_VERSION);
        goto out;
    }

    if (!g_module_symbol (module, "mm_plugin_create", (gpointer *) &plugin_create_func)) {
        g_warning ("Could not load plugin '%s': %s", path_display, g_module_error ());
        goto out;
    }

    plugin = (*plugin_create_func) ();
    if (plugin) {
        g_object_weak_ref (G_OBJECT (plugin), (GWeakNotify) g_module_close, module);
    } else
        mm_warn ("Could not load plugin '%s': initialization failed", path_display);

out:
    if (module && !plugin)
        g_module_close (module);

    g_free (path_display);

    return plugin;
}
Esempio n. 3
0
File: ms.c Progetto: AlekSi/Jabbin
gint ms_load_plugin(gchar *path)
{
#ifdef HAVE_GLIB
	g_module_open(path,0);
#endif
	return 0;
}
Esempio n. 4
0
void StarDictPlugins::get_plugin_info(const char *filename, StarDictPlugInType &plugin_type, std::string &info_xml, bool &can_configure)
{
	GModule *module;
	module = g_module_open (filename, G_MODULE_BIND_LAZY);
	if (!module) {
		g_print("Load %s failed!\n", filename);
		return;
	}
	union {
		stardict_plugin_init_func_t stardict_plugin_init;
		gpointer stardict_plugin_init_avoid_warning;
	} func;
	func.stardict_plugin_init = 0;
	if (!g_module_symbol (module, "stardict_plugin_init", (gpointer *)&(func.stardict_plugin_init_avoid_warning))) {
		g_print("Load %s failed: No stardict_plugin_init func!\n", filename);
		g_module_close (module);
		return;
	}
	StarDictPlugInObject *plugin_obj = new StarDictPlugInObject();
	bool failed = func.stardict_plugin_init(plugin_obj, app_dirs);
	if (failed) {
		g_print("Load %s failed!\n", filename);
		g_module_close (module);
		delete plugin_obj;
		return;
	}
	plugin_type = plugin_obj->type;
	info_xml = plugin_obj->info_xml;
	can_configure = (plugin_obj->configure_func != NULL);
	delete plugin_obj;
	g_module_close (module);
}
Esempio n. 5
0
static gpointer
load_self_module (gpointer user_data)
{
  module_self = g_module_open (NULL, G_MODULE_BIND_LAZY);

  return NULL;
}
static gboolean
pluma_object_module_load (GTypeModule *gmodule)
{
	PlumaObjectModule *module = PLUMA_OBJECT_MODULE (gmodule);
	PlumaObjectModuleRegisterFunc register_func;
	gchar *path;

	pluma_debug_message (DEBUG_PLUGINS, "Loading %s module from %s",
			     module->priv->module_name, module->priv->path);

	path = g_module_build_path (module->priv->path, module->priv->module_name);
	g_return_val_if_fail (path != NULL, FALSE);
	pluma_debug_message (DEBUG_PLUGINS, "Module filename: %s", path);

	module->priv->library = g_module_open (path, 
					       G_MODULE_BIND_LAZY);
	g_free (path);

	if (module->priv->library == NULL)
	{
		g_warning ("%s: %s", module->priv->module_name, g_module_error());

		return FALSE;
	}

	/* extract symbols from the lib */
	if (!g_module_symbol (module->priv->library, module->priv->type_registration,
			      (void *) &register_func))
	{
		g_warning ("%s: %s", module->priv->module_name, g_module_error());
		g_module_close (module->priv->library);

		return FALSE;
	}

	/* symbol can still be NULL even though g_module_symbol
	 * returned TRUE */
	if (register_func == NULL)
	{
		g_warning ("Symbol '%s' should not be NULL", module->priv->type_registration);
		g_module_close (module->priv->library);

		return FALSE;
	}

	module->priv->type = register_func (gmodule);

	if (module->priv->type == 0)
	{
		g_warning ("Invalid object contained by module %s", module->priv->module_name);
		return FALSE;
	}

	if (module->priv->resident)
	{
		g_module_make_resident (module->priv->library);
	}

	return TRUE;
}
static gboolean
nautilus_module_load (GTypeModule *gmodule)
{
	NautilusModule *module;
	
	module = NAUTILUS_MODULE (gmodule);
	
	module->library = g_module_open (module->path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);

	if (!module->library) {
		g_warning ("%s", g_module_error ());
		return FALSE;
	}

	if (!g_module_symbol (module->library,
			      "nautilus_module_initialize",
			      (gpointer *)&module->initialize) ||
	    !g_module_symbol (module->library,
			      "nautilus_module_shutdown",
			      (gpointer *)&module->shutdown) ||
	    !g_module_symbol (module->library,
			      "nautilus_module_list_types",
			      (gpointer *)&module->list_types)) {

		g_warning ("%s", g_module_error ());
		g_module_close (module->library);
		
		return FALSE;
	}

	module->initialize (gmodule);
	
	return TRUE;
}
Esempio n. 8
0
static void
ToolsCoreInitializeDebug(ToolsServiceState *state)
{
   RpcDebugLibData *libdata;
   RpcDebugInitializeFn initFn;

   state->debugLib = g_module_open(MODULE_NAME(vmrpcdbg), G_MODULE_BIND_LOCAL);
   if (state->debugLib == NULL) {
      g_error("Cannot load vmrpcdbg library.\n");
   }

   if (!g_module_symbol(state->debugLib,
                        "RpcDebug_Initialize",
                        (gpointer *) &initFn)) {
      g_error("Cannot find symbol: RpcDebug_Initialize\n");
   }

   libdata = initFn(&state->ctx, state->debugPlugin);
   ASSERT(libdata != NULL);
   ASSERT(libdata->debugPlugin != NULL);

   state->debugData = libdata;
#if defined(_WIN32)
   VMTools_AttachConsole();
#endif
}
Esempio n. 9
0
void plugin_load (const char * filename)
{
    GModule *module;
    Plugin * (* func) (AudAPITable * table);

    AUDDBG ("Loading plugin: %s.\n", filename);

    if (!(module = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL)))
    {
        printf("Failed to load plugin (%s): %s\n", filename, g_module_error());
        return;
    }

    /* v2 plugin loading */
    if (g_module_symbol (module, "get_plugin_info", (void *) & func))
    {
        Plugin * header = func (& api_table);
        g_return_if_fail (header != NULL);
        plugin2_process(header, module, filename);
        return;
    }

    printf("Invalid plugin (%s)\n", filename);
    g_module_close(module);
}
Esempio n. 10
0
/* FIXME: It would be better to just fix the flags using RTLD_NOLOAD because
 * the libraries are surely loaded. */
static gboolean
reload_libraries(void)
{
    /* Do not do it on Win32 because the libs must be fully resolved there and
     * because the library names are different (with -0). */
#ifndef G_OS_WIN32
    static const gchar *const gwyddion_libs[] = {
        "libgwyddion2", "libgwyprocess2", "libgwydraw2", "libgwydgets2",
        "libgwymodule2", "libgwyapp2",
    };
    guint i;

    for (i = 0; i < G_N_ELEMENTS(gwyddion_libs); i++) {
        gchar *filename = g_strconcat(gwyddion_libs[i],
                                      ".", GWY_SHARED_LIBRARY_EXTENSION,
                                      NULL);
        GModule *modhandle = g_module_open(filename, G_MODULE_BIND_LAZY);
        if (!modhandle) {
            gchar *excstr = g_strdup_printf("Cannot dlopen() %s.", filename);
            PyErr_SetString(PyExc_ImportError, excstr);
            g_free(excstr);
            return FALSE;
        }
        g_module_make_resident(modhandle);
        g_free(filename);
    }
#endif

    return TRUE;
}
void GuiModuleFactory::RegisterGuiPlugin(string filename) {
    typedef string (* GetTypeFunc)();
    typedef Gui* (* CreateFunc)( Module* mod );
    GetTypeFunc  GetType;
    CreateFunc   Create;
    // GError       **error;

    filename = "./plugins/" + filename;

    GModule*  gm = g_module_open( filename.c_str(), G_MODULE_BIND_MASK );
    if( gm!=NULL ) {
        if( g_module_symbol( gm, "GetGuiType", (gpointer *)&GetType ) == TRUE ) {
            if( g_module_symbol( gm, "CreateGui", (gpointer *)&Create ) == TRUE ) {
                RegisterGui( GetType(), Create );
            }
            else {
                TRACE( "GuiModuleFactory::RegisterGuiPlugin - Nie znaleziono "
                       "CreateGui() w %s\n", filename.c_str() );
            }
        }
        else {
            TRACE( "MGuiModuleFactory::RegisterGuiPlugin - Nie znaleziono CreateGui() w pliku %s\n",
                   filename.c_str() );
        }
    }
}
Esempio n. 12
0
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;
}
static void 
open_libbeagle (void)
{
  static gboolean done = FALSE;

  if (!done)
    {
      int i;
      GModule *beagle;
      
      done = TRUE;
 
      beagle = g_module_open ("libbeagle.so.1", G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
      if (!beagle)
	return;
      
      for (i = 0; i < G_N_ELEMENTS (beagle_dl_mapping); i++)
	{
	  if (!g_module_symbol (beagle, beagle_dl_mapping[i].fn_name,
				beagle_dl_mapping[i].fn_ptr_ref))
	    {
	      g_warning ("Missing symbol '%s' in libbeagle\n",
			 beagle_dl_mapping[i].fn_name);
	      g_module_close (beagle);

	      for (i = 0; i < G_N_ELEMENTS (beagle_dl_mapping); i++)
		beagle_dl_mapping[i].fn_ptr_ref = NULL;

	      return;
	    }
	}
    }
}
Esempio n. 14
0
static gboolean
a11y_invoke_module (const char *module_path)
{
  GModule    *handle;
  void      (*invoke_fn) (void);

  if (!module_path)
    {
      g_warning ("Accessibility: invalid module path (NULL)");

      return FALSE;
    }

  if (!(handle = g_module_open (module_path, 0)))
    {
      g_warning ("Accessibility: failed to load module '%s': '%s'",
                 module_path, g_module_error ());

      return FALSE;
    }

  if (!g_module_symbol (handle, INIT_METHOD, (gpointer *)&invoke_fn))
    {
      g_warning ("Accessibility: error library '%s' does not include "
                 "method '%s' required for accessibility support",
                 module_path, INIT_METHOD);
      g_module_close (handle);

      return FALSE;
    }

  invoke_fn ();

  return TRUE;
}
Esempio n. 15
0
// TBD: Support a comma separated list of plugin directories.
static void rehash_loaders()
{
    GError *error = NULL;
    const gchar * giv_plugin_dir = PACKAGE_PLUGIN_DIR;
#ifdef G_OS_WIN32
    // Hardcoded path relative to installation dir on Windows
    gchar giv_win32_plugin_dir[512];
    sprintf(giv_win32_plugin_dir, "%s/plugins",
            g_win32_get_package_installation_directory_of_module(NULL));
    giv_plugin_dir = giv_win32_plugin_dir;
#endif

    if (getenv("GIV_PLUGIN_DIR"))
        giv_plugin_dir = (const char*)getenv("GIV_PLUGIN_DIR");

    // No matter of we succeed or not, we will not automatically
    // call this function again.
    giv_image_loaded_loaders = TRUE;
    GDir *plugin_dir = g_dir_open(giv_plugin_dir,
                                  0,
                                  &error);

    // No directory found, ok, just ignore it.
    if (error) {
        fprintf(stderr, "plugin dir error: %s\n", error->message);
        g_error_free(error);
        return;
    }

    const gchar *name;
    while( (name=g_dir_read_name(plugin_dir)) ) {
      //        printf("name = %s\n", name);
        // Try to load it as a module if it ends with ".dll"
        // or ".so".
        gchar *extension = g_strrstr(name, ".");
        if (!extension)
            continue;
        extension++;
        if (g_ascii_strncasecmp(G_MODULE_SUFFIX,
                                extension,
                                strlen(G_MODULE_SUFFIX))==0) {
            gchar *module_name = g_strndup(name, extension-name-1);
            gchar *module_path = g_strdup_printf("%s/%s",
                                                 giv_plugin_dir,
                                                 name);

            GModule *module = g_module_open (module_path, G_MODULE_BIND_MASK);

            if (module) {
                givimage_loaders = g_slist_prepend(givimage_loaders,
                                                   module);
            }
            else
                fprintf(stderr, "Failed loading module %s\n", module_path);
            g_free(module_path);
            g_free(module_name);
        }
    }
    g_dir_close(plugin_dir);
}
Esempio n. 16
0
/* *****************************************************************************
 * load and initialize and external module
 */
gboolean nav_init (const gchar *mod_path, const gchar *mod_name)
{
    gchar *t_path;

    nav_close ();

    t_path = g_module_build_path (mod_path, mod_name);
    nav_module = g_module_open (t_path, G_MODULE_BIND_LAZY);
    if (!nav_module)
    {
        g_print (_("WARNING: %s\n"), g_module_error ());
        return FALSE;
    }
    if (!g_module_symbol (nav_module, "calculate_route", (gpointer *)&calculate_route))
    {
        g_print (_("ERROR: %s\n"), g_module_error ());
        nav_close ();
        return FALSE;
    }
    if (calculate_route == NULL)
    {
        g_print (_("ERROR: Missing symbol \"calculate_route\" in navigation module '%s'\n"),
                 g_module_name (nav_module));
        nav_close ();
        return FALSE;
    }

    g_print (_("Navigation module '%s' successfully loaded.\n"), g_module_name (nav_module));

    return TRUE;
}
Esempio n. 17
0
static gboolean
_cogl_renderer_choose_driver (CoglRenderer *renderer,
                              GError **error)
{
  const char *driver_name = g_getenv ("COGL_DRIVER");
  const char *libgl_name;

#ifdef HAVE_COGL_GL
  if (driver_name == NULL || !strcmp (driver_name, "gl"))
    {
      renderer->driver = COGL_DRIVER_GL;
      libgl_name = COGL_GL_LIBNAME;
      goto found;
    }
#endif

#ifdef HAVE_COGL_GLES2
  if (driver_name == NULL || !strcmp (driver_name, "gles2"))
    {
      renderer->driver = COGL_DRIVER_GLES2;
      libgl_name = COGL_GLES2_LIBNAME;
      goto found;
    }
#endif

#ifdef HAVE_COGL_GLES
  if (driver_name == NULL || !strcmp (driver_name, "gles1"))
    {
      renderer->driver = COGL_DRIVER_GLES1;
      libgl_name = COGL_GLES1_LIBNAME;
      goto found;
    }
#endif

  g_set_error (error,
               COGL_DRIVER_ERROR,
               COGL_DRIVER_ERROR_NO_SUITABLE_DRIVER_FOUND,
               "No suitable driver found");
  return FALSE;

 found:

#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY

  renderer->libgl_module = g_module_open (libgl_name,
                                          G_MODULE_BIND_LAZY);

  if (renderer->libgl_module == NULL)
    {
      g_set_error (error, COGL_DRIVER_ERROR,
                   COGL_DRIVER_ERROR_FAILED_TO_LOAD_LIBRARY,
                   "Failed to dynamically open the GL library \"%s\"",
                   libgl_name);
      return FALSE;
    }

#endif /* HAVE_DIRECTLY_LINKED_GL_LIBRARY */

  return TRUE;
}
Esempio n. 18
0
/**
 * gck_module_initialize:
 * @path: The file system path to the PKCS#11 module to load.
 * @reserved: Extra arguments for the PKCS#11 module, should usually be NULL.
 * @reserved_options: No options are currently available.
 * @err: A location to store an error resulting from a failed load.
 *
 * Load and initialize a PKCS#11 module represented by a GckModule object.
 *
 * Return value: The loaded PKCS#11 module or NULL if failed.
 **/
GckModule*
gck_module_initialize (const gchar *path, gpointer reserved, guint reserved_options, GError **err)
{
	CK_C_GetFunctionList get_function_list;
	CK_FUNCTION_LIST_PTR funcs;
	GModule *module;
	GckModule *self;
	CK_RV rv;

	g_return_val_if_fail (path != NULL, NULL);
	g_return_val_if_fail (!err || !*err, NULL);

	/* Load the actual module */
	module = g_module_open (path, 0);
	if (!module) {
		g_set_error (err, GCK_ERROR, (int)CKR_GCK_MODULE_PROBLEM,
		             "Error loading pkcs11 module: %s", g_module_error ());
		return NULL;
	}

	/* Get the entry point */
	if (!g_module_symbol (module, "C_GetFunctionList", (void**)&get_function_list)) {
		g_set_error (err, GCK_ERROR, (int)CKR_GCK_MODULE_PROBLEM,
		             "Invalid pkcs11 module: %s", g_module_error ());
		g_module_close (module);
		return NULL;
	}

	/* Get the function list */
	rv = (get_function_list) (&funcs);
	if (rv != CKR_OK) {
		g_set_error (err, GCK_ERROR, rv, "Couldn't get pkcs11 function list: %s",
		             gck_message_from_rv (rv));
		g_module_close (module);
		return NULL;
	}

	self = g_object_new (GCK_TYPE_MODULE, "functions", funcs, "path", path, NULL);
	self->pv->module = module;

	memset (&self->pv->init_args, 0, sizeof (self->pv->init_args));
	self->pv->init_args.flags = CKF_OS_LOCKING_OK;
	self->pv->init_args.CreateMutex = create_mutex;
	self->pv->init_args.DestroyMutex = destroy_mutex;
	self->pv->init_args.LockMutex = lock_mutex;
	self->pv->init_args.UnlockMutex = unlock_mutex;
	self->pv->init_args.pReserved = reserved;

	/* Now initialize the module */
	rv = (self->pv->funcs->C_Initialize) (&self->pv->init_args);
	if (rv != CKR_OK) {
		g_set_error (err, GCK_ERROR, rv, "Couldn't initialize module: %s",
		             gck_message_from_rv (rv));
		g_object_unref (self);
		return NULL;
	}

	self->pv->initialized = TRUE;
	return self;
}
Esempio n. 19
0
void
init_cups(void)
{
    const char *libcups[] = { "libcups", "libcups.so", "libcups.so.1", "libcups.so.2", NULL };

    if (!(cups_dests_get && cups_dests_free)) {
        int i;
        
        for (i = 0; libcups[i] != NULL; i++) {
            cups = g_module_open(libcups[i], G_MODULE_BIND_LAZY);
            if (cups)
                break; 
        }
        
        if (!cups) {
	    cups_init = FALSE;
	    return;
	}

	if (!g_module_symbol(cups, "cupsGetDests", (gpointer) & cups_dests_get)
	    || !g_module_symbol(cups, "cupsFreeDests", (gpointer) & cups_dests_free)) {
            g_module_close(cups);
	    cups_init = FALSE;
	}
    }
    
    cups_init = TRUE;
}
static gboolean
panel_applets_manager_dbus_factory_activate (PanelAppletsManager *manager,
        const gchar         *iid)
{
    PanelAppletFactoryInfo *info;
    ActivateAppletFunc      activate_applet;

    info = get_applet_factory_info (manager, iid);
    if (!info)
        return FALSE;

    /* Out-of-process applets are activated by the session bus */
    if (!info->in_process)
        return TRUE;

    if (info->module) {
        if (info->n_applets == 0) {
            if (info->activate_applet () != 0) {
                g_warning ("Failed to reactivate factory %s\n", iid);
                return FALSE;
            }
        }
        info->n_applets++;

        return TRUE;
    }

    info->module = g_module_open (info->location, G_MODULE_BIND_LAZY);
    if (!info->module) {
        /* FIXME: use a GError? */
        g_warning ("Failed to load applet %s: %s\n",
                   iid, g_module_error ());
        return FALSE;
    }

    if (!g_module_symbol (info->module, "_panel_applet_shlib_factory", (gpointer *) &activate_applet)) {
        /* FIXME: use a GError? */
        g_warning ("Failed to load applet %s: %s\n",
                   iid, g_module_error ());
        g_module_close (info->module);
        info->module = NULL;

        return FALSE;
    }

    /* Activate the applet */
    if (activate_applet () != 0) {
        /* FIXME: use a GError? */
        g_warning ("Failed to load applet %s\n", iid);
        g_module_close (info->module);
        info->module = NULL;

        return FALSE;
    }
    info->activate_applet = activate_applet;

    info->n_applets = 1;

    return TRUE;
}
Esempio n. 21
0
/* test for g_module_open (NULL, ...) */
RESULT
test_module_symbol_null ()
{
	gpointer proc = GINT_TO_POINTER (42);

	GModule *m = g_module_open (NULL, G_MODULE_BIND_LAZY);

	if (m == NULL)
		return FAILED ("bind to main module failed. #0");

	if (g_module_symbol (m, "__unlikely_\nexistent__", &proc))
		return FAILED ("non-existent symbol lookup failed. #1");

	if (proc)
		return FAILED ("non-existent symbol lookup failed. #2");

	if (!g_module_symbol (m, EXTERNAL_SYMBOL, &proc))
		return FAILED ("external lookup failed. #3");

	if (!proc)
		return FAILED ("external lookup failed. #4");

	if (!g_module_symbol (m, "dummy_test_export", &proc))
		return FAILED ("in-proc lookup failed. #5");

	if (!proc)
		return FAILED ("in-proc lookup failed. #6");

	if (!g_module_close (m))
		return FAILED ("close failed. #7");

	return OK;
}
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;
}
Esempio n. 23
0
static void * open_module (const char * path)
{
    GModule * handle = g_module_open (path, G_MODULE_BIND_LOCAL);
    if (! handle)
    {
        fprintf (stderr, "ladspa: Failed to open module %s: %s\n", path, g_module_error ());
        return NULL;
    }

    void * sym;
    if (! g_module_symbol (handle, "ladspa_descriptor", & sym))
    {
        fprintf (stderr, "ladspa: Not a valid LADSPA module: %s\n", path);
        g_module_close (handle);
        return NULL;
    }

    LADSPA_Descriptor_Function descfun = (LADSPA_Descriptor_Function) sym;

    const LADSPA_Descriptor * desc;
    for (int i = 0; (desc = descfun (i)); i ++)
    {
        PluginData * plugin = open_plugin (path, desc);
        if (plugin)
            index_append (plugins, plugin);
    }

    return handle;
}
Esempio n. 24
0
static int  pipeline_set_ruta(pipeline_t* p, const char * elemento, const char *ruta, const char *dir) {
  elemento_t *dato = g_hash_table_lookup(p->m_modulos, elemento);
  int dev = 0;
  if (ruta) {
    if (dato->m_handler)      {
      g_module_close(dato->m_handler);
    }
    char *ruta_modulo = g_module_build_path(dir, ruta);
    dato->m_handler = g_module_open(ruta_modulo, G_MODULE_BIND_LAZY);

    if (dato->m_handler) {
      typedef modulo_t *(*funcion_modulo_t) ();
      funcion_modulo_t f;
      if(g_module_symbol(dato->m_handler, "get_modulo", (gpointer *)&f) != TRUE) {
	dev = -1;
      }
      else {
	dato->m_modulo = f ? f() : 0;
	dato->m_modulo->m_tabla = g_hash_table_new(g_str_hash, g_str_equal);
      }
    }    
    else {      
      dev = -1;
    }
    pipeline_salida_error(p, "Pipeline", "Bibliotecas", g_module_error());
  }
  else {
    dev = -1;
  }
  return dev;
}
Esempio n. 25
0
static void
sweep_plugin_init (const gchar * path)
{
  GModule * module;
  sw_plugin * m_plugin;
  gpointer  m_plugin_ptr;
  GList * gl;

  module = g_module_open (path, G_MODULE_BIND_LAZY);

  if (!module) {
#ifdef DEBUG
    fprintf (stderr, "sweep_plugin_init: Error opening %s: %s\n",
	     path, g_module_error());
#endif
    return;
  }

  if (g_module_symbol (module, "plugin", &m_plugin_ptr)) {
	m_plugin = (sw_plugin *)m_plugin_ptr;
	module_list = g_list_append (module_list, m_plugin);
    for (gl = m_plugin->plugin_init (); gl; gl = gl->next) {
      plugins = g_list_insert_sorted (plugins, (sw_procedure *)gl->data,
				      (GCompareFunc)cmp_proc_names);
    }
  }
}
Esempio n. 26
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;
}
Esempio n. 27
0
File: main.c Progetto: dsd/fprintd
static gboolean
load_storage_module (const char *module_name)
{
	GModule *module;
	char *filename;

	filename = g_module_build_path (PLUGINDIR, module_name);
	module = g_module_open (filename, 0);
	g_free (filename);
	if (module == NULL)
		return FALSE;

	if (!g_module_symbol (module, "init", (gpointer *) &store.init) ||
	    !g_module_symbol (module, "deinit", (gpointer *) &store.deinit) ||
	    !g_module_symbol (module, "print_data_save", (gpointer *) &store.print_data_save) ||
	    !g_module_symbol (module, "print_data_load", (gpointer *) &store.print_data_load) ||
	    !g_module_symbol (module, "print_data_delete", (gpointer *) &store.print_data_delete) ||
	    !g_module_symbol (module, "discover_prints", (gpointer *) &store.discover_prints)) {
	    	g_module_close (module);
	    	return FALSE;
	}

	g_module_make_resident (module);

	return TRUE;
}
Esempio n. 28
0
static gboolean
parole_module_load (GTypeModule *gtype_module)
{
    ParoleProviderModule *module;
    
    module = PAROLE_PROVIDER_MODULE (gtype_module);
    
    module->library = g_module_open (gtype_module->name, G_MODULE_BIND_LOCAL);

    if ( G_UNLIKELY (module->library == NULL) )
    {
        g_critical ("Failed to load plugin : %s", g_module_error ());
        return FALSE;
    }
    
    if ( !g_module_symbol (module->library, "parole_plugin_initialize", (gpointer) &module->initialize) || 
         !g_module_symbol (module->library, "parole_plugin_shutdown", (gpointer) &module->shutdown))
    {
        g_critical ("Plugin %s missing required symbols", gtype_module->name);
        g_module_close (module->library);
        return FALSE;
    }
    
    TRACE ("Loading module %s", gtype_module->name);
    
    module->provider_type = (*module->initialize) (module);
    module->active = TRUE;
    
    TRACE ("Finished loading module %s", gtype_module->name);
    
    return TRUE;
}
Esempio n. 29
0
static int
dt_imageio_load_module_storage (dt_imageio_module_storage_t *module, const char *libname, const char *plugin_name)
{
    module->widget = NULL;
    g_strlcpy(module->plugin_name, plugin_name, 20);
    module->module = g_module_open(libname, G_MODULE_BIND_LAZY);
    if(!module->module) goto error;
    int (*version)();
    if(!g_module_symbol(module->module, "dt_module_dt_version", (gpointer)&(version))) goto error;
    if(version() != dt_version())
    {
        fprintf(stderr, "[imageio_load_module] `%s' is compiled for another version of dt (module %d (%s) != dt %d (%s)) !\n", libname, abs(version()), version() < 0 ? "debug" : "opt", abs(dt_version()), dt_version() < 0 ? "debug" : "opt");
        goto error;
    }
    if(!g_module_symbol(module->module, "name",                   (gpointer)&(module->name)))                   goto error;
    if(!g_module_symbol(module->module, "gui_reset",              (gpointer)&(module->gui_reset)))              goto error;
    if(!g_module_symbol(module->module, "gui_init",               (gpointer)&(module->gui_init)))               goto error;
    if(!g_module_symbol(module->module, "gui_cleanup",            (gpointer)&(module->gui_cleanup)))            goto error;

    if(!g_module_symbol(module->module, "store",                  (gpointer)&(module->store)))                  goto error;
    if(!g_module_symbol(module->module, "get_params",             (gpointer)&(module->get_params)))             goto error;
    if(!g_module_symbol(module->module, "free_params",            (gpointer)&(module->free_params)))            goto error;
    if(!g_module_symbol(module->module, "finalize_store",         (gpointer)&(module->finalize_store)))         module->finalize_store = NULL;
    if(!g_module_symbol(module->module, "set_params",             (gpointer)&(module->set_params)))             goto error;

    if(!g_module_symbol(module->module, "supported",              (gpointer)&(module->supported)))              module->supported = _default_supported;
    if(!g_module_symbol(module->module, "dimension",              (gpointer)&(module->dimension)))            	module->dimension = _default_storage_dimension;
    if(!g_module_symbol(module->module, "recommended_dimension",  (gpointer)&(module->recommended_dimension)))  module->recommended_dimension = _default_storage_dimension;

    return 0;
error:
    fprintf(stderr, "[imageio_load_module] failed to open storage `%s': %s\n", plugin_name, g_module_error());
    if(module->module) g_module_close(module->module);
    return 1;
}
Esempio n. 30
0
File: plugin.c Progetto: n2i/xvnkb
char *
plugin_load (session *sess, char *filename, char *arg)
{
	void *handle;
	gpointer init_func;     // => xchat_init_func
	gpointer deinit_func;   // => xchat_deinit_func

	/* load the plugin */
	handle = g_module_open (filename, 0);
	if (handle == NULL)
		return (char *)g_module_error ();

	/* find the init routine xchat_plugin_init */
	if (!g_module_symbol (handle, "xchat_plugin_init", &init_func))
	{
		g_module_close (handle);
		return _("No xchat_plugin_init symbol; is this really an xchat plugin?");
	}

	/* find the plugin's deinit routine, if any */
	if (!g_module_symbol (handle, "xchat_plugin_deinit", &deinit_func))
		deinit_func = NULL;


	/* add it to our linked list */
	plugin_add (sess, filename, handle, init_func, deinit_func, arg, FALSE);

	return NULL;
}