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; }
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; }
/** * 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; }
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); }
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 *) ®ister_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; }
Plugin * plugin_load (const char * filename) { AUDDBG ("Loading plugin: %s.\n", filename); GModule * module = g_module_open (filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); if (! module) { fprintf (stderr, " *** ERROR: %s could not be loaded: %s\n", filename, g_module_error ()); return NULL; } void * ptr; if (! g_module_symbol (module, "get_plugin_info", & ptr)) ptr = NULL; Plugin * (* func) (AudAPITable * table) = ptr; Plugin * header; if (! func || ! (header = func (& api_table)) || header->magic != _AUD_PLUGIN_MAGIC) { fprintf (stderr, " *** ERROR: %s is not a valid Audacious plugin.\n", filename); g_module_close (module); return NULL; } if (header->version < _AUD_PLUGIN_VERSION_MIN || header->version > _AUD_PLUGIN_VERSION) { fprintf (stderr, " *** ERROR: %s is not compatible with this version " "of Audacious.\n", filename); g_module_close (module); return NULL; } if (header->type == PLUGIN_TYPE_TRANSPORT || header->type == PLUGIN_TYPE_PLAYLIST || header->type == PLUGIN_TYPE_INPUT || header->type == PLUGIN_TYPE_EFFECT) { if (PLUGIN_HAS_FUNC (header, init) && ! header->init ()) { fprintf (stderr, " *** ERROR: %s failed to initialize.\n", filename); g_module_close (module); return NULL; } } pthread_mutex_lock (& mutex); LoadedModule * loaded = g_slice_new (LoadedModule); loaded->header = header; loaded->module = module; loaded_modules = g_list_prepend (loaded_modules, loaded); pthread_mutex_unlock (& mutex); return header; }
static gboolean brasero_dvdcss_library_init (BraseroPlugin *plugin) { gpointer address; GModule *module; if (css_ready) return TRUE; /* load libdvdcss library and see the version (mine is 1.2.0) */ module = g_module_open ("libdvdcss.so.2", G_MODULE_BIND_LOCAL); if (!module) goto error_doesnt_exist; if (!g_module_symbol (module, "dvdcss_open", &address)) goto error_version; dvdcss_open = address; if (!g_module_symbol (module, "dvdcss_close", &address)) goto error_version; dvdcss_close = address; if (!g_module_symbol (module, "dvdcss_read", &address)) goto error_version; dvdcss_read = address; if (!g_module_symbol (module, "dvdcss_seek", &address)) goto error_version; dvdcss_seek = address; if (!g_module_symbol (module, "dvdcss_error", &address)) goto error_version; dvdcss_error = address; if (plugin) { g_module_close (module); return TRUE; } css_ready = TRUE; return TRUE; error_doesnt_exist: brasero_plugin_add_error (plugin, BRASERO_PLUGIN_ERROR_MISSING_LIBRARY, "libdvdcss.so.2"); return FALSE; error_version: brasero_plugin_add_error (plugin, BRASERO_PLUGIN_ERROR_LIBRARY_VERSION, "libdvdcss.so.2"); g_module_close (module); return FALSE; }
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; }
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; }
void mateconf_backend_unref(MateConfBackend* backend) { g_return_if_fail(backend != NULL); g_return_if_fail(backend->refcount > 0); if (backend->refcount > 1) { backend->refcount -= 1; } else { GError* error = NULL; (*backend->vtable.shutdown)(&error); if (error != NULL) { g_warning(error->message); g_error_free(error); } if (!g_module_close(backend->module)) g_warning(_("Failed to shut down backend")); g_hash_table_remove(loaded_backends, backend->name); g_free((gchar*)backend->name); /* cast off const */ g_free(backend); } }
DLL_EXPORT_SYM gint rlib_free(rlib *r) { int i; rlib_charencoder_free(r->output_encoder); g_free(r->output_encoder_name); rlib_free_results_and_queries(r); rlib_free_tree(r); xmlCleanupParser(); for (i = 0; i < r->inputs_count; i++) { rlib_charencoder_free(r->inputs[i].input->info.encoder); r->inputs[i].input->input_close(r->inputs[i].input); r->inputs[i].input->free(r->inputs[i].input); if (r->inputs[i].handle != NULL) g_module_close(r->inputs[i].handle); g_free(r->inputs[i].name); } if (r->did_execute && OUTPUT(r)) { OUTPUT(r)->free(r); } ENVIRONMENT(r)->free(r); g_hash_table_destroy(r->output_parameters); g_hash_table_destroy(r->input_metadata); g_hash_table_destroy(r->parameters); rlib_free_follower(r); g_free(r->special_locale); g_free(r->current_locale); g_free(r); return 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; }
static int module_gc (lua_State *L) { GModule **module = luaL_checkudata (L, 1, UD_MODULE); g_module_close (*module); return 0; }
Module* module_load (const gchar *path, const gchar *channel_name) { void (*init) (XfsmSplashConfig *config); Module *module; gchar property_base[512]; XfconfChannel *channel; gchar *dp; gchar *sp; /* load module */ module = g_new0 (Module, 1); #if GLIB_CHECK_VERSION(2,4,0) module->handle = g_module_open (path, G_MODULE_BIND_LOCAL); #else module->handle = g_module_open (path, 0); #endif if (G_UNLIKELY (module->handle == NULL)) goto error0; if (!g_module_symbol (module->handle, "config_init", (gpointer)&init)) goto error1; /* determine engine name */ sp = module->engine = g_path_get_basename (path); if (sp[0] == 'l' && sp[1] == 'i' && sp[2] == 'b') sp += 3; for (dp = module->engine; *sp != '\0'; ++dp, ++sp) { if (*sp == '.') break; else *dp = *sp; } *dp = '\0'; g_snprintf (property_base, sizeof (property_base), "/splash/engines/%s", module->engine); channel = xfconf_channel_new_with_property_base (channel_name, property_base); /* initialize module */ module->config.rc = xfsm_splash_rc_new (channel); g_object_unref (channel); init (&module->config); if (G_UNLIKELY (module->config.name == NULL)) { module_free (module); return NULL; } /* succeed */ return module; error1: g_module_close (module->handle); error0: g_free (module); return NULL; }
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); }
void module_free (Module *module) { if (G_LIKELY (module->config.destroy != NULL)) module->config.destroy (&module->config); if (G_LIKELY (module->config.name != NULL)) g_free (module->config.name); if (G_LIKELY (module->config.description != NULL)) g_free (module->config.description); if (G_LIKELY (module->config.version != NULL)) g_free (module->config.version); if (G_LIKELY (module->config.author != NULL)) g_free (module->config.author); if (G_LIKELY (module->config.homepage != NULL)) g_free (module->config.homepage); xfsm_splash_rc_free (module->config.rc); g_module_close (module->handle); g_free (module->engine); g_free (module); }
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; } } } }
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; }
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 ()); } }
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; }
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; }
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; }
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; }
/** * gpa_printer_list_load_from_module: * @path: * * Load printers from a module **/ static gboolean gpa_printer_list_load_from_module (GPAList *printers, const gchar *path) { GpaModuleInfo info; GModule *handle; gboolean (*init) (GpaModuleInfo *info); gint retval = FALSE; handle = g_module_open (path, G_MODULE_BIND_LAZY); if (!handle) { g_warning ("Can't g_module_open %s\n", path); return retval; } if (!g_module_symbol (handle, "gpa_module_init", (gpointer*) &init)) { g_warning ("Error. Module %s does not contains an init function\n", path); goto module_error; } if (!(init) (&info)) { g_warning ("Could not initialize module %s\n", path); goto module_error; } (info.printer_list_append) (printers, path); retval = TRUE; module_error: g_module_close (handle); return retval; }
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; }
static gboolean panel_applets_manager_dbus_factory_deactivate (PanelAppletsManager *manager, const gchar *iid) { PanelAppletFactoryInfo *info; info = get_applet_factory_info (manager, iid); if (!info) return FALSE; /* Out-of-process applets are deactivated by the session bus */ if (!info->in_process) return TRUE; if (!info->module) return TRUE; info->n_applets--; if (info->n_applets == 0) { /* FIXME: we should close the module here, however applet types * are registered static */ #if 0 g_module_close (info->module); info->module = NULL; #endif } return TRUE; }
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 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; }
char * plugin_load (session *sess, char *filename, char *arg) { GModule *handle = module_load (filename); hexchat_init_func *init_func; hexchat_deinit_func *deinit_func; if (handle == NULL) return (char *)g_module_error (); /* find the init routine hexchat_plugin_init */ if (!g_module_symbol (handle, "hexchat_plugin_init", (gpointer *)&init_func)) { g_module_close (handle); return _("No hexchat_plugin_init symbol; is this really a HexChat plugin?"); } /* find the plugin's deinit routine, if any */ if (!g_module_symbol (handle, "hexchat_plugin_deinit", (gpointer *)&deinit_func)) deinit_func = NULL; /* add it to our linked list */ plugin_add (sess, filename, handle, init_func, deinit_func, arg, FALSE); return NULL; }
static void plugin_dispose (GObject *object) { GigglePluginPriv *priv = GET_PRIV (object); if (priv->manager) { g_object_remove_weak_pointer (G_OBJECT (priv->manager), (gpointer) &priv->manager); priv->manager = NULL; } if (priv->builder) { g_object_unref (priv->builder); priv->builder = NULL; } if (priv->module) { g_module_close (priv->module); priv->module = NULL; } g_ptr_array_foreach (priv->action_groups, (GFunc) g_object_unref, NULL); G_OBJECT_CLASS (giggle_plugin_parent_class)->dispose (object); }