Ejemplo n.º 1
0
static int plugin_free(xchat_plugin *pl, int do_deinit, int allow_refuse)
{
	GSList *list, *next;
	xchat_hook *hook;
	xchat_deinit_func *deinit_func;

	// fake plugin added by xchat_plugingui_add()
	if (pl->fake)
		goto xit;

	// run the plugin's deinit routine, if any
	if (do_deinit && pl->deinit_callback != nullptr)
	{
		deinit_func = (xchat_deinit_func*)pl->deinit_callback;
		if (!deinit_func(pl) && allow_refuse)
			return FALSE;
	}

	// remove all of this plugin's hooks
	list = hook_list;
	while (list)
	{
		hook = (xchat_hook*)list->data;
		next = list->next;
		if (hook->pl == pl)
			xchat_unhook(nullptr, hook);
		list = next;
	}

#ifdef USE_PLUGIN
	if (pl->handle)
#ifdef USE_GMODULE
		g_module_close((GModule*)pl->handle);
#else
		dlclose(pl->handle);
#endif
#endif

xit:
	if (pl->free_strings)
	{
		if (pl->name)
			free(pl->name);
		if (pl->desc)
			free(pl->desc);
		if (pl->version)
			free(pl->version);
	}
	if (pl->filename)
		free(pl->filename);
	free(pl);

	plugin_list = g_slist_remove(plugin_list, pl);

#ifdef USE_PLUGIN
	fe_pluginlist_update();
#endif

	return TRUE;
}
Ejemplo n.º 2
0
static int
plugin_free (hexchat_plugin *pl, int do_deinit, int allow_refuse)
{
	GSList *list, *next;
	hexchat_hook *hook;
	hexchat_deinit_func *deinit_func;

	/* fake plugin added by hexchat_plugingui_add() */
	if (pl->fake)
		goto xit;

	/* run the plugin's deinit routine, if any */
	if (do_deinit && pl->deinit_callback != NULL)
	{
		deinit_func = pl->deinit_callback;
		if (!deinit_func (pl) && allow_refuse)
			return FALSE;
	}

	/* remove all of this plugin's hooks */
	list = hook_list;
	while (list)
	{
		hook = list->data;
		next = list->next;
		if (hook->pl == pl)
			hexchat_unhook (NULL, hook);
		list = next;
	}

#ifdef USE_PLUGIN
	if (pl->handle)
		g_module_close (pl->handle);
#endif

xit:
	if (pl->free_strings)
	{
		if (pl->name)
			free (pl->name);
		if (pl->desc)
			free (pl->desc);
		if (pl->version)
			free (pl->version);
	}
	if (pl->filename)
		free ((char *)pl->filename);
	free (pl);

	plugin_list = g_slist_remove (plugin_list, pl);

#ifdef USE_PLUGIN
	fe_pluginlist_update ();
#endif

	return TRUE;
}