summaryrefslogtreecommitdiff
path: root/src/plugins/plugin.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2019-02-26 20:08:47 +0100
committerSébastien Helleu <flashcode@flashtux.org>2019-02-27 07:46:26 +0100
commit17a218e6b6f1539a0337f03b5c1f7e2728ed5592 (patch)
treefa508375a3963ab584da6114021dd3c745c7ee42 /src/plugins/plugin.c
parentc2859096cbf2030f977c9838af99bf13c8584625 (diff)
downloadweechat-17a218e6b6f1539a0337f03b5c1f7e2728ed5592.zip
core: use function string_match_list for the autoload of plugins
Diffstat (limited to 'src/plugins/plugin.c')
-rw-r--r--src/plugins/plugin.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index d8e82ef25..dd04d1a7d 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -196,7 +196,7 @@ plugin_check_extension_allowed (const char *filename)
int
plugin_check_autoload (const char *filename)
{
- int i, plugin_authorized, plugin_forbidden, length, length_ext;
+ int i, length, length_ext, match;
char *full_name, *ptr_base_name, *base_name, *plugin_name;
/* by default we can auto load all plugins */
@@ -252,33 +252,13 @@ plugin_check_autoload (const char *filename)
if (!plugin_name)
return 1;
- /* browse array and check if plugin is authorized or forbidden */
- plugin_authorized = 0;
- plugin_forbidden = 0;
- for (i = 0; i < plugin_autoload_count; i++)
- {
- if (plugin_autoload_array[i][0] == '!')
- {
- /*
- * negative value: it is used to prevent a plugin from loading
- * for example with "*,!perl", all plugins are loaded, but not perl
- */
- if (string_match (plugin_name, plugin_autoload_array[i] + 1, 0))
- plugin_forbidden = 1;
- }
- else
- {
- if (string_match (plugin_name, plugin_autoload_array[i], 0))
- plugin_authorized = 1;
- }
- }
+ match = string_match_list (plugin_name,
+ (const char **)plugin_autoload_array,
+ 0);
free (plugin_name);
- if (plugin_forbidden)
- return 0;
-
- return plugin_authorized;
+ return match;
}
/*