summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-05-01 09:13:37 -0700
committerMarcel Holtmann <marcel@holtmann.org>2009-05-01 09:13:37 -0700
commit8cbe9b1d129c7651b185788197ac423758b86590 (patch)
tree3950c6442cef489c286800dfd12ec53fe8058421
parentf47ba233b60652cda14e4aa543b8d43f177f2d17 (diff)
downloadconnman-8cbe9b1d129c7651b185788197ac423758b86590.tar.gz
connman-8cbe9b1d129c7651b185788197ac423758b86590.tar.bz2
connman-8cbe9b1d129c7651b185788197ac423758b86590.zip
Add pattern and exclude matching for builtin plugins
-rw-r--r--src/plugin.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 23caa0a8..9af616f7 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -76,6 +76,24 @@ static gboolean add_plugin(void *handle, struct connman_plugin_desc *desc)
#include "builtin.h"
+static gboolean check_plugin(struct connman_plugin_desc *desc,
+ const char *pattern, const char *exclude)
+{
+ if (exclude != NULL &&
+ g_pattern_match_simple(exclude, desc->name) == TRUE) {
+ DBG("excluding %s", desc->description);
+ return FALSE;
+ }
+
+ if (pattern != NULL &&
+ g_pattern_match_simple(pattern, desc->name) == FALSE) {
+ DBG("ignoring %s", desc->description);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
int __connman_plugin_init(const char *pattern, const char *exclude)
{
GSList *list;
@@ -86,8 +104,13 @@ int __connman_plugin_init(const char *pattern, const char *exclude)
DBG("");
- for (i = 0; __connman_builtin[i]; i++)
+ for (i = 0; __connman_builtin[i]; i++) {
+ if (check_plugin(__connman_builtin[i],
+ pattern, exclude) == FALSE)
+ continue;
+
add_plugin(NULL, __connman_builtin[i]);
+ }
dir = g_dir_open(PLUGINDIR, 0, NULL);
if (dir != NULL) {
@@ -118,16 +141,7 @@ int __connman_plugin_init(const char *pattern, const char *exclude)
continue;
}
- if (exclude != NULL && g_pattern_match_simple(exclude,
- desc->name) == TRUE) {
- DBG("excluding %s", desc->description);
- dlclose(handle);
- continue;
- }
-
- if (pattern != NULL && g_pattern_match_simple(pattern,
- desc->name) == FALSE) {
- DBG("ignoring %s", desc->description);
+ if (check_plugin(desc, pattern, exclude) == FALSE) {
dlclose(handle);
continue;
}