1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 00:33:13 +02:00

api: add info "plugin_loaded"

This commit is contained in:
Sébastien Helleu
2024-02-19 18:29:21 +01:00
parent f19808cedd
commit a167322d8b
17 changed files with 281 additions and 137 deletions
+37
View File
@@ -1179,6 +1179,39 @@ error:
return NULL;
}
/*
* Returns WeeChat info "plugin_loaded".
*/
char *
plugin_api_info_plugin_loaded_cb (const void *pointer, void *data,
const char *info_name,
const char *arguments)
{
struct t_weechat_plugin *ptr_plugin;
/* make C compiler happy */
(void) pointer;
(void) data;
(void) info_name;
if (!arguments || !arguments[0])
return NULL;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
if (strcmp (ptr_plugin->name, arguments) == 0)
{
/* plugin loaded */
return strdup ("1");
}
}
/* plugin not loaded */
return NULL;
}
/*
* Returns secured data hashtable.
*/
@@ -2234,6 +2267,10 @@ plugin_api_info_init ()
"timestamp (optional, current time by default), number of "
"passwords before/after to test (optional, 0 by default)"),
&plugin_api_info_totp_validate_cb, NULL, NULL);
hook_info (NULL, "plugin_loaded",
N_("1 if plugin is loaded"),
N_("plugin name"),
&plugin_api_info_plugin_loaded_cb, NULL, NULL);
/* WeeChat core info_hashtable hooks */
hook_info_hashtable (NULL,