Exemplo n.º 1
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;
}
Exemplo n.º 2
0
static gboolean
plugin_check_version(GModule *module)
{
	gint (*version_check)(gint) = NULL;

	g_module_symbol(module, "plugin_version_check", (void *) &version_check);

	if (G_UNLIKELY(! version_check))
	{
		geany_debug("Plugin \"%s\" has no plugin_version_check() function - ignoring plugin!",
				g_module_name(module));
		return FALSE;
	}
	else
	{
		gint result = version_check(GEANY_ABI_VERSION);

		if (result < 0)
		{
			msgwin_status_add(_("The plugin \"%s\" is not binary compatible with this "
				"release of Geany - please recompile it."), g_module_name(module));
			geany_debug("Plugin \"%s\" is not binary compatible with this "
				"release of Geany - recompile it.", g_module_name(module));
			return FALSE;
		}
		if (result > GEANY_API_VERSION)
		{
			geany_debug("Plugin \"%s\" requires a newer version of Geany (API >= v%d).",
				g_module_name(module), result);
			return FALSE;
		}
	}
	return TRUE;
}
Exemplo n.º 3
0
static guint
queue_opened_module_library(GModule *mod,
                            const GwyModuleLibraryRecord *records,
                            GwyErrorList **errorlist)
{
    GHashTable *modules = ensure_module_table();
    GError *error = NULL;
    guint count = 0, i;

    for (i = 0; records[i].name; i++) {
        GQuark qname = g_quark_from_string(records[i].name);
        if (!module_name_is_valid(records[i].name, &error)) {
            log_module_failure(error, qname, g_module_name(mod), TRUE);
            gwy_error_list_propagate(errorlist, error);
            continue;
        }

        ModuleInfo *modinfo = NULL;
        if (!(modinfo = fill_module_info(records[i].info, qname, mod, TRUE,
                                         &error))) {
            log_module_failure(error, qname, g_module_name(mod), TRUE);
            gwy_error_list_propagate(errorlist, error);
            continue;
        }

        if (!handle_overriding(modinfo, &error)) {
            log_module_failure(error, qname, g_module_name(mod), TRUE);
            gwy_error_list_propagate(errorlist, error);
            module_info_free(modinfo);
            continue;
        }

        gpointer key = GUINT_TO_POINTER(qname);
        g_hash_table_insert(modules, key, modinfo);
        count++;
    }

    if (count)
        return count;

    if (!i) {
        g_set_error(&error, GWY_MODULE_ERROR, GWY_MODULE_ERROR_EMPTY_LIBRARY,
                    _("Module library ‘%s’ is empty."),
                    g_module_name(mod));
        log_module_failure(error, 0, g_module_name(mod), TRUE);
        gwy_error_list_propagate(errorlist, error);
    }
    // We should have at least error logged for this library one way or
    // another when we choose to fail.
    close_module(mod, NULL);

    return 0;
}
Exemplo n.º 4
0
/**
 * Close module.
 *
 * @param module The GModule should be closed
 *
 * @return TRUE on success, on failure a warning will be logged.
 */
gboolean
u_module_close (GModule *module)
{
  g_return_val_if_fail (module != NULL, FALSE);

  g_message ("Closing module %s.", g_module_name (module));
  if (!g_module_close (module))
    {
      g_warning ("Couldn't close module %s: %s", g_module_name (module), g_module_error ());
      return FALSE;
    }

  return TRUE;
}
Exemplo n.º 5
0
WS_DLL_PUBLIC void
plugins_get_descriptions(plugin_description_callback callback, void *user_data)
{
    type_callback_info info;

    info.types = NULL; /* F**K LLVM UP THE ASS WITH A RED HOT POKER */
    for (info.pt_plug = plugin_list; info.pt_plug != NULL;
         info.pt_plug = info.pt_plug->next)
    {
        info.sep = "";
        info.types = g_string_new(""); 

        /*
         * Build a list of all the plugin types.
         */
        g_slist_foreach(plugin_types, add_plugin_type_description, &info);

        /*
         * And hand the information to the callback.
         */
        callback(info.pt_plug->name, info.pt_plug->version, info.types->str,
                 g_module_name(info.pt_plug->handle), user_data);

        g_string_free(info.types, TRUE);
    }
}
Exemplo n.º 6
0
// -----------------------------------------------------------------------------
bool lib::destroy(LoadLib* pLLib)
{
	DEBUGLOGB;

	bool ret = false;

	if( pLLib )
	{
		g_pShared = pLLib->pShared;
		g_pSymbs  = pLLib->pSymbs;
		g_nSymbs  = pLLib->nSymbs;
		g_iSymb   = pLLib->iSymb;

		DEBUGLOGP("  module is %s\n", g_pShared ? g_module_name(g_pShared) : "null");

		ret = free();

		pLLib->pShared = g_pShared;
		pLLib->pSymbs  = g_pSymbs;
		pLLib->nSymbs  = g_nSymbs;
		pLLib->iSymb   = g_iSymb;

		delete pLLib;
	}

	DEBUGLOGE;
	return ret;
}
Exemplo n.º 7
0
static bool q2_api_init (GModule *module, q2_game_exports_t **game_exports) {
  q2_game_exports_t * (*q2_get_game_api) (q2_engine_exports_t *engine_exports);
  gpointer *p = (gpointer *)&q2_get_game_api;
  const char *name = g_module_name(module);
  const char *symbol = "GetGameAPI";

  if (!g_module_symbol(module, symbol, p) || !q2_get_game_api) {
    g_critical("%s: invalid symbol %s", name, symbol);
    return false;
  }

  if (!(*game_exports = q2_get_game_api(&exports))) {
    g_critical("%s: %s returned NULL", name, symbol);
    return false;
  }

  if ((*game_exports)->api_version != QUAKE2_GAME_API_VERSION) {
    g_critical("%s: different API versions (need %i, got %i)", name, QUAKE2_GAME_API_VERSION, (*game_exports)->api_version);
    return false;
  }

  (*game_exports)->init();

  return true;
}
Exemplo n.º 8
0
WS_DLL_PUBLIC void
plugins_get_descriptions(plugin_description_callback callback, void *user_data)
{
    type_callback_info info;

    info.types = NULL; /* Certain compiler suites need a init state for this variable */
    for (info.pt_plug = plugin_list; info.pt_plug != NULL;
         info.pt_plug = info.pt_plug->next)
    {
        info.sep = "";
        info.types = g_string_new("");

        /*
         * Build a list of all the plugin types.
         */
        g_slist_foreach(plugin_types, add_plugin_type_description, &info);

        /*
         * And hand the information to the callback.
         */
        callback(info.pt_plug->name, info.pt_plug->version, info.types->str,
                 g_module_name(info.pt_plug->handle), user_data);

        g_string_free(info.types, TRUE);
    }
}
Exemplo n.º 9
0
// -----------------------------------------------------------------------------
bool lib::func(LoadLib* pLLib, gpointer* sfunc)
{
	DEBUGLOGB;

	bool ret = false;

	if( pLLib )
	{
		g_pShared = pLLib->pShared;
		g_pSymbs  = pLLib->pSymbs;
		g_nSymbs  = pLLib->nSymbs;
		g_iSymb   = pLLib->iSymb;

		DEBUGLOGP("  module is %s\n", g_pShared ? g_module_name(g_pShared) : "null");

		ret = func(sfunc);

		pLLib->pShared = g_pShared;
		pLLib->pSymbs  = g_pSymbs;
		pLLib->nSymbs  = g_nSymbs;
		pLLib->iSymb   = g_iSymb;
	}

	DEBUGLOGE;
	return ret;
}
Exemplo n.º 10
0
static gboolean
handle_overriding(ModuleInfo *modinfo,
                  GError **error)
{
    GHashTable *modules = ensure_module_table();
    gpointer key = GUINT_TO_POINTER(modinfo->qname);
    ModuleInfo *othermodinfo = NULL;

    if (!(othermodinfo = g_hash_table_lookup(modules, key)))
        return TRUE;

    if (othermodinfo->did_type_registration) {
        g_set_error(error, GWY_MODULE_ERROR, GWY_MODULE_ERROR_DUPLICATE_MODULE,
                    // TRANSLATORS: Error message.
                    _("Module ‘%s’ was already registered from ‘%s’ and "
                      "can no longer be overriden by ‘%s’."),
                    g_quark_to_string(modinfo->qname),
                    g_module_name(othermodinfo->mod),
                    g_module_name(modinfo->mod));
        return FALSE;
    }

    // Override the previous module, stealing its priority.
    GError *err = NULL;
    g_set_error(&err, GWY_MODULE_ERROR, GWY_MODULE_ERROR_OVERRIDEN,
                // TRANSLATORS: Error message.
                _("Module ‘%s’ loaded from ‘%s’ was overriden by ‘%s’."),
                g_quark_to_string(modinfo->qname),
                g_module_name(othermodinfo->mod),
                g_module_name(modinfo->mod));
    // This makes a copy of everything
    log_module_failure(err,
                       othermodinfo->qname, g_module_name(othermodinfo->mod),
                       othermodinfo->from_library);
    g_clear_error(&err);

    if (!othermodinfo->from_library) {
        g_module_close(othermodinfo->mod);
        othermodinfo->mod = NULL;
    }

    modinfo->priority = othermodinfo->priority;
    g_hash_table_remove(modules, key);

    return TRUE;
}
Exemplo n.º 11
0
// @module_info can come from either a separate module or a library here.
static ModuleInfo*
fill_module_info(const GwyModuleInfo *module_info,
                 GQuark qname,
                 GModule *mod,
                 gboolean from_library,
                 GError **error)
{
    if (module_info->abi_version != GWY_MODULE_ABI_VERSION) {
        g_set_error(error, GWY_MODULE_ERROR, GWY_MODULE_ERROR_ABI,
                    // TRANSLATORS: Error message.
                    _("Module ABI version %u of ‘%s’ differs from %u."),
                    module_info->abi_version,
                    g_module_name(mod),
                    GWY_MODULE_ABI_VERSION);
        return NULL;
    }

    if (module_info->ntypes && !module_info->types) {
        g_set_error(error, GWY_MODULE_ERROR, GWY_MODULE_ERROR_TYPES,
                    // TRANSLATORS: Error message.
                    _("Module ‘%s’ declares non-zero number of types but it "
                      "does not provide any."),
                    g_module_name(mod));
        return NULL;
    }

    if (err_unset_metadata(error, module_info->author, "author",
                           mod)
        || err_unset_metadata(error, module_info->version, "version",
                              mod)
        || err_unset_metadata(error, module_info->copyright, "copyright",
                              mod)
        || err_unset_metadata(error, module_info->date, "date",
                              mod)
        || err_unset_metadata(error, module_info->description, "description",
                              mod))
        return NULL;

    ModuleInfo *modinfo = g_slice_new0(ModuleInfo);
    modinfo->module_info = module_info;
    modinfo->mod = mod;
    modinfo->qname = qname;
    modinfo->from_library = from_library;
    modinfo->priority = module_priority++;
    return modinfo;
}
Exemplo n.º 12
0
static int
RpcDebugRun(ToolsAppCtx *ctx,
            gpointer runMainLoop,
            gpointer runData,
            RpcDebugLibData *ldata)
{
   CU_ErrorCode err;
   CU_Suite *suite;
   CU_Test *test;

   ASSERT(runMainLoop != NULL);
   ASSERT(ldata != NULL);

   err = CU_initialize_registry();
   ASSERT(err == CUE_SUCCESS);

   suite = CU_add_suite(g_module_name(gPlugin), NULL, NULL);
   ASSERT(suite != NULL);

   test = CU_add_test(suite, g_module_name(gPlugin), RpcDebugRunLoop);
   ASSERT_NOT_IMPLEMENTED(test != NULL);

   gLibRunData.ctx = ctx;
   gLibRunData.libData = ldata;
   gLibRunData.mainLoop = runMainLoop;
   gLibRunData.loopData = runData;

   err = CU_basic_run_tests();

   /* Clean up internal library / debug plugin state. */
   ASSERT(g_atomic_int_get(&gLibRunData.refCount) >= 0);

   if (gPlugin != NULL) {
      g_module_close(gPlugin);
      gPlugin = NULL;
   }

   if (CU_get_failure_list() != NULL) {
      err = 1;
   }

   CU_cleanup_registry();
   memset(&gLibRunData, 0, sizeof gLibRunData);
   return (int) err;
}
Exemplo n.º 13
0
static gboolean
get_file_metadata (TrackerExtractTask  *task,
                   TrackerExtractInfo **info_out)
{
	TrackerExtractInfo *info;
	GFile *file;
	gchar *mime_used = NULL;
	gint items = 0;

	*info_out = NULL;

	file = g_file_new_for_uri (task->file);
	info = tracker_extract_info_new (file, task->mimetype, task->graph);
	g_object_unref (file);

	if (task->mimetype && *task->mimetype) {
		/* We know the mime */
		mime_used = g_strdup (task->mimetype);
	} else {
		tracker_extract_info_unref (info);
		return FALSE;
	}

	/* Now we have sanity checked everything, actually get the
	 * data we need from the extractors.
	 */
	if (mime_used) {
		if (task->cur_func) {
			TrackerSparqlBuilder *statements;

			g_debug ("Using %s...", g_module_name (task->cur_module));

			(task->cur_func) (info);

			statements = tracker_extract_info_get_metadata_builder (info);
			items = tracker_sparql_builder_get_length (statements);

			if (items > 0) {
				tracker_sparql_builder_insert_close (statements);
				task->success = TRUE;
			}
		}

		g_free (mime_used);
	}

	g_debug ("Done (%d objects added)\n", items);

	if (items == 0) {
		tracker_extract_info_unref (info);
		info = NULL;
	}

	*info_out = info;

	return (items > 0);
}
Exemplo n.º 14
0
/* Close the module as an idle function so that we know
   it's all cleaned up */
static gboolean
module_destroy_in_idle_helper (gpointer data)
{
	GModule * module = (GModule *)data;
	if (module != NULL) {
		g_debug("Unloading module: %s", g_module_name(module));
		g_module_close(module);
	}
	return FALSE;
}
Exemplo n.º 15
0
/* Prevent the same plugin filename being loaded more than once.
 * Note: g_module_name always returns the .so name, even when Plugin::filename is a .la file. */
static gboolean
plugin_loaded(GModule *module)
{
	gchar *basename_module, *basename_loaded;
	GList *item;

	basename_module = g_path_get_basename(g_module_name(module));
	for (item = plugin_list; item != NULL; item = g_list_next(item))
	{
		basename_loaded = g_path_get_basename(
			g_module_name(((Plugin*)item->data)->module));

		if (utils_str_equal(basename_module, basename_loaded))
		{
			g_free(basename_loaded);
			g_free(basename_module);
			return TRUE;
		}
		g_free(basename_loaded);
	}
	/* Look also through the list of active plugins. This prevents problems when we have the same
	 * plugin in libdir/geany/ AND in configdir/plugins/ and the one in libdir/geany/ is loaded
	 * as active plugin. The plugin manager list would only take the one in configdir/geany/ and
	 * the plugin manager would list both plugins. Additionally, unloading the active plugin
	 * would cause a crash. */
	for (item = active_plugin_list; item != NULL; item = g_list_next(item))
	{
		basename_loaded = g_path_get_basename(g_module_name(((Plugin*)item->data)->module));

		if (utils_str_equal(basename_module, basename_loaded))
		{
			g_free(basename_loaded);
			g_free(basename_module);
			return TRUE;
		}
		g_free(basename_loaded);
	}
	g_free(basename_module);
	return FALSE;
}
Exemplo n.º 16
0
static gboolean
egl_vtable_try_load_library (EglVTable * vtable, const gchar * name)
{
  if (vtable->base.handle.p)
    g_module_close (vtable->base.handle.p);
  vtable->base.handle.p = g_module_open (name,
      G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
  if (!vtable->base.handle.p)
    return FALSE;

  GST_DEBUG ("loaded backend: %s", g_module_name (vtable->base.handle.p));
  return TRUE;
}
Exemplo n.º 17
0
static gboolean
err_unset_metadata(GError **error,
                   const gchar *metadata,
                   const gchar *name,
                   GModule *mod)
{
    if (metadata && *metadata)
        return FALSE;

    g_set_error(error, GWY_MODULE_ERROR, GWY_MODULE_ERROR_METADATA,
                _("Module ‘%s’ metadata does not define field ‘%s’."),
                g_module_name(mod), name);
    return TRUE;
}
Exemplo n.º 18
0
/* *****************************************************************************
 * call the external module and insert the calculated route into gpsdrive
 */
gboolean nav_get_route (gdouble slat, gdouble slon, gdouble elat, gdouble elon, gint type)
{
    navigation_struct *data;
    gint i = 0;

    if (!nav_module)
        return FALSE;

    if (mydebug > 20)
        g_print (_("Calculating route with external module '%s'\n"), g_module_name (nav_module));

    /* calculate fast car route if type value is not valid */
    if (type > NAVTYPE_N_TYPES)
        type = NAVTYPE_CAR_FAST;

    /* trying to get route from external module */
    data = calculate_route (slat, slon, elat, elon, type, NULL);

    if (data == NULL)
    {
        g_print (_("ERROR in external navigation module...\n"));
        popup_error (NULL, _("No route found!"));
        return FALSE;
    }

    /* init new gpsdrive route list and fill it from route data */
    route_init ("Calculated route", "using external module", NULL);

    while (data[i-1].number != -1)
    {
        if (mydebug > 30)
        {
            g_print ("------ Routepoint %d ------\n", data[i].number);
            g_print ("  lat: %.6f / lon: %.6f\n", data[i].lat, data[i].lon);
            g_print ("  %d : %s\n", data[i].type, data[i].name);
            g_print ("  %s\n", data[i].instruction);
        }
        if (data[i].type >= NAV_N_ELEMENTS)
            data[i].type = NAV_ROUTEPOINT;
        add_arbitrary_point_to_route
        (data[i].name, data[i].instruction, routing_types[data[i].type],
         data[i].lat, data[i].lon);
        i++;
    };

    g_free (data);

    return TRUE;
}
Exemplo n.º 19
0
/* *****************************************************************************
 * unload an external navigation module
 */
gboolean nav_close (void)
{
    if (nav_module)
    {
        if (mydebug > 10)
            g_print (_("Closing navigation module '%s'\n"), g_module_name (nav_module));

        if (!g_module_close (nav_module))
        {
            g_print (_("ERROR: %s\n"), g_module_error ());
            return FALSE;
        }
    }

    return TRUE;
}
Exemplo n.º 20
0
/*
 * Dump plugin info to stdout. Copied from ui/gtk/plugins_dlg.c:plugins_scan.
 */
void
plugins_dump_all(void)
{
#ifdef HAVE_PLUGINS
    plugin     *pt_plug;
    const char *sep;
#endif
#ifdef HAVE_LUA
    wslua_plugin  *lua_plug;
#endif

#ifdef HAVE_PLUGINS
    for (pt_plug = plugin_list; pt_plug != NULL; pt_plug = pt_plug->next)
    {
        sep = "";

	printf("%s\t%s\t", pt_plug->name, pt_plug->version);
        if (pt_plug->register_protoinfo)
        {
            printf("dissector");
            sep = ", ";
        }
        if (pt_plug->register_tap_listener)
        {
            printf("%stap", sep);
            sep = ", ";
        }
        if (pt_plug->register_wtap_module)
        {
            printf("%sfile format", sep);
            sep = ", ";
        }
        if (pt_plug->register_codec_module)
        {
            printf("%scodec", sep);
        }
	printf("\t%s\n", g_module_name(pt_plug->handle));
    }
#endif

#ifdef HAVE_LUA
    for (lua_plug = wslua_plugin_list; lua_plug != NULL; lua_plug = lua_plug->next)
    {
        printf("%s\t%s\tlua script\t%s\n", lua_plug->name, lua_plug->version, lua_plug->filename);
    }
#endif
}
Exemplo n.º 21
0
G_MODULE_EXPORT gchar* g_module_check_init(GModule *module)
{
	gchar			*libfilename;

	// preload libutil for use with this module.
	if(g_module_open("libutil.so",G_MODULE_BIND_LAZY)==NULL)
 		return "\ncould not preload libutil.so";

   // preload libvterm for use with this module
   if(g_module_open("libvterm.so",G_MODULE_BIND_LAZY)==NULL)
      return "\ncould not preload libvterm.so";

	/*	register with vwm 	*/
	libfilename=(gchar*)g_module_name(module);
	vwm_module_add("Tools","VTerm",vwmterm_init,NULL,libfilename);

	return NULL;
}
Exemplo n.º 22
0
static void
report_statistics (GObject *object)
{
	TrackerExtractPrivate *priv;
	GHashTableIter iter;
	gpointer key, value;

	priv = TRACKER_EXTRACT_GET_PRIVATE (object);

	g_mutex_lock (&priv->task_mutex);

	g_message ("--------------------------------------------------");
	g_message ("Statistics:");

	g_hash_table_iter_init (&iter, priv->statistics_data);

	while (g_hash_table_iter_next (&iter, &key, &value)) {
		GModule *module = key;
		StatisticsData *data = value;

		if (data->extracted_count > 0 || data->failed_count > 0) {
			const gchar *name, *name_without_path;

			name = g_module_name (module);
			name_without_path = strrchr (name, G_DIR_SEPARATOR) + 1;

			g_message ("    Module:'%s', extracted:%d, failures:%d",
			           name_without_path,
			           data->extracted_count,
			           data->failed_count);
		}
	}

	g_message ("Unhandled files: %d", priv->unhandled_count);

	if (priv->unhandled_count == 0 &&
	    g_hash_table_size (priv->statistics_data) < 1) {
		g_message ("    No files handled");
	}

	g_message ("--------------------------------------------------");

	g_mutex_unlock (&priv->task_mutex);
}
Exemplo n.º 23
0
/**
 * gwy_module_register_types:
 * @errorlist: (allow-none):
 *             Location to store possible errors.
 *             Errors from %GWY_MODULE_ERROR domain can occur.
 *
 * Registers extension types from all modules that were loaded but their types
 * were not registered yet.
 *
 * Returns: The number of new types registered.
 **/
guint
gwy_module_register_types(GwyErrorList **errorlist)
{
    GPtrArray *todo_list = gather_unregistered_modules();
    if (!todo_list)
        return 0;

    GHashTable *libraries_seen = g_hash_table_new(g_str_hash, g_str_equal);
    guint count = 0;
    for (guint i = 0; i < todo_list->len; i++) {
        ModuleInfo *modinfo = g_ptr_array_index(todo_list, i);
        const GwyModuleInfo *module_info = modinfo->module_info;
        for (guint j = 0; j < module_info->ntypes; j++) {
            GError *error = NULL;
            if (register_one_type(module_info->types + j,
                                  modinfo->qname,
                                  &error)) {
                count++;
            }
            if (error) {
                // TODO: log the error somewhere
                gwy_error_list_propagate(errorlist, error);
            }
        }

        if (modinfo->from_library) {
            const gchar *path = g_module_name(modinfo->mod);
            if (!g_hash_table_lookup(libraries_seen, path)) {
                g_module_make_resident(modinfo->mod);
                g_hash_table_insert(libraries_seen, (gpointer)path,
                                    GUINT_TO_POINTER(TRUE));
            }
        }
        else {
            g_module_make_resident(modinfo->mod);
        }
        modinfo->did_type_registration = TRUE;
    }

    g_hash_table_unref(libraries_seen);
    g_ptr_array_free(todo_list, TRUE);

    return count;
}
Exemplo n.º 24
0
static void
infinoted_plugin_manager_unload_plugin(InfinotedPluginManager* manager,
                                       InfinotedPluginInstance* instance)
{
  InfinotedPluginManagerPrivate* priv;
  InfinotedPluginManagerForeachConnectionData data;
  InfBrowserIter root;

  priv = INFINOTED_PLUGIN_MANAGER_PRIVATE(manager);
  priv->plugins = g_slist_remove(priv->plugins, instance);

  /* Unregister all sessions with the plugin */
  inf_browser_get_root(INF_BROWSER(priv->directory), &root);
  infinoted_plugin_manager_walk_directory(
    manager,
    &root,
    instance,
    infinoted_plugin_manager_remove_session
  );

  /* Unregister all connections with the plugin */
  data.manager = manager;
  data.instance = instance;
  infd_directory_foreach_connection(
    priv->directory,
    infinoted_plugin_manager_unload_plugin_foreach_connection_func,
    &data
  );

  if(instance->plugin->on_deinitialize != NULL)
    instance->plugin->on_deinitialize(instance+1);

  infinoted_log_info(
    priv->log,
    _("Unloaded plugin \"%s\" from \"%s\""),
    instance->plugin->name,
    g_module_name(instance->module)
  );

  g_module_close(instance->module);
  g_free(instance);
}
Exemplo n.º 25
0
static gboolean
filter_module (TrackerExtract *extract,
               GModule        *module)
{
	TrackerExtractPrivate *priv;
	gchar *module_basename, *filter_name;
	gboolean filter;

	priv = TRACKER_EXTRACT_GET_PRIVATE (extract);

	if (!priv->force_module) {
		return FALSE;
	}

	/* Module name is the full path to it */
	module_basename = g_path_get_basename (g_module_name (module));

	if (g_str_has_prefix (priv->force_module, "lib") &&
	    g_str_has_suffix (priv->force_module, "." G_MODULE_SUFFIX)) {
		filter_name = g_strdup (priv->force_module);
	} else {
		filter_name = g_strdup_printf ("libextract-%s.so",
		                               priv->force_module);
	}

	filter = strcmp (module_basename, filter_name) != 0;

	if (filter) {
		g_debug ("Module filtered out '%s' (due to --force-module='%s')",
		         module_basename,
		         filter_name);
	} else {
		g_debug ("Module used '%s' (due to --force-module='%s')",
		         module_basename,
		         filter_name);
	}

	g_free (module_basename);
	g_free (filter_name);

	return filter;
}
Exemplo n.º 26
0
static gconstpointer
find_module_info(GModule *mod,
                 const gchar *module_info_symbol,
                 GError **error)
{
    // This gets the pointer to the pointer.  Dereference it once if non-NULL.
    gpointer ppinfo;
    if (g_module_symbol(mod, module_info_symbol, &ppinfo) && ppinfo) {
        gpointer *pinfo = ppinfo;
        gpointer info = *pinfo;
        if (info)
            return info;
    }

    g_set_error(error, GWY_MODULE_ERROR, GWY_MODULE_ERROR_INFO,
                // TRANSLATORS: Error message.
                _("Cannot find module info ‘%s’ in ‘%s’."),
                module_info_symbol, g_module_name(mod));
    return NULL;
}
Exemplo n.º 27
0
static void
close_module(GModule *mod, const gchar *filename)
{
    gchar *modfilename = NULL;

    // We cannot get the file name after we close the module, even
    // unsuccessfull, because it may be freed.
    if (!filename) {
        modfilename = g_strdup(g_module_name(mod));
        filename = modfilename;
    }

    if (g_module_close(mod)) {
        GWY_FREE(modfilename);
        return;
    }

    g_warning("Cannot close module ‘%s’: %s", filename, g_module_error());
    GWY_FREE(modfilename);
}
Exemplo n.º 28
0
// -----------------------------------------------------------------------------
bool lib::load(LoadLib* pLLib, const char* name, const char* sufx, symb* symbs, size_t nsymbs)
{
	DEBUGLOGB;

	bool ret = false;

	if( pLLib )
	{
		ret = load(name, sufx, symbs, nsymbs);

		pLLib->pShared = g_pShared;
		pLLib->pSymbs  = g_pSymbs;
		pLLib->nSymbs  = g_nSymbs;
		pLLib->iSymb   = g_iSymb;

		DEBUGLOGP("  module is %s\n", g_pShared ? g_module_name(g_pShared) : "null");
	}

	DEBUGLOGE;
	return ret;
}
Exemplo n.º 29
0
void plugin_manager_open(void)
{
    GSList *list, *cur;
    SylPluginInfo *info;
    GModule *module;
    const gchar *filename;

    if (!pm_window.window)
        plugin_manager_create();
    else
        gtk_window_present(GTK_WINDOW(pm_window.window));

    list = syl_plugin_get_module_list();

    gtk_list_store_clear(pm_window.store);

    for (cur = list; cur != NULL; cur = cur->next) {
        module = (GModule *)cur->data;

        filename = g_module_name(module);
        info = syl_plugin_get_info(module);
        if (info) {
            debug_print("------------------------------\n");
            debug_print("filename      : %s\n", filename);
            debug_print("plugin name   : %s\n", info->name);
            debug_print("plugin version: %s\n", info->version);
            debug_print("plugin author : %s\n", info->author);
            debug_print("description   : %s\n", info->description ? info->description : "");
            debug_print("------------------------------\n");
            plugin_manager_set_list_row(NULL, info, filename);
        } else {
            debug_print("info not found: %s\n", filename);
        }
    }

    gtk_widget_show(pm_window.window);
    manage_window_focus_in(pm_window.window, NULL, NULL);

    syl_plugin_signal_emit("plugin-manager-open", pm_window.window);
}
Exemplo n.º 30
0
gboolean daemon_plugin_registrar_Load (DaemonPluginRegistrar* self) {
	gboolean result = FALSE;
	GModule* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	void* function = NULL;
	void* _tmp2_ = NULL;
	DaemonPluginRegistrarRegisterPluginFunction _tmp3_;
	DaemonPluginRegistrarRegisterPluginFunction _register_;
	void* _register__target = NULL;
	GDestroyNotify _register__target_destroy_notify = NULL;
	GType _tmp4_;
	const gchar* _tmp5_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	daemon_global_log_ColorMessage (DAEMON_CONSOLE_COLORS_Green, "Loading plugin with path: '%s'\n", self->priv->_Path);
	_tmp0_ = g_module_open (self->priv->_Path, G_MODULE_BIND_LAZY);
	_g_module_close0 (self->priv->_module);
	self->priv->_module = _tmp0_;
	if (self->priv->_module == NULL) {
		result = FALSE;
		return result;
	}
	_tmp1_ = g_module_name (self->priv->_module);
	fprintf (stdout, "Loaded module: '%s'\n", _tmp1_);
	g_module_symbol (self->priv->_module, "register_plugin", &_tmp2_);
	function = _tmp2_;
	_tmp3_ = (DaemonPluginRegistrarRegisterPluginFunction) function;
	_register_ = _tmp3_;
	_register__target = NULL;
	_register__target_destroy_notify = NULL;
	_tmp4_ = _register_ (self->priv->_module, _register__target);
	self->priv->_type = _tmp4_;
	_tmp5_ = g_type_name (self->priv->_type);
	daemon_global_log_ColorMessage (DAEMON_CONSOLE_COLORS_Green, "Plugin type: %s\n\n", _tmp5_);
	result = TRUE;
	(_register__target_destroy_notify == NULL) ? NULL : (_register__target_destroy_notify (_register__target), NULL);
	_register_ = NULL;
	_register__target = NULL;
	_register__target_destroy_notify = NULL;
	return result;
}