summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
diff options
context:
space:
mode:
authorPekka Pessi <Pekka.Pessi@nokia.com>2010-09-24 17:22:40 +0300
committerMarcel Holtmann <marcel@holtmann.org>2010-10-04 17:34:50 +0200
commitadb82190908ee9045a08c74d47c16c9c7f5b88f9 (patch)
tree37d7f27e7c7499640fe169c8660c671a17eddc21 /src/plugin.c
parentdc92bfb9a9441b2cf962db76cc18a01597020f60 (diff)
downloadofono-adb82190908ee9045a08c74d47c16c9c7f5b88f9.tar.bz2
Support -p and -P options with list of plugins
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 159014bb..68fe3188 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -72,18 +72,26 @@ static gboolean add_plugin(void *handle, struct ofono_plugin_desc *desc)
}
static gboolean check_plugin(struct ofono_plugin_desc *desc,
- const char *pattern, const char *exclude)
+ char **patterns, char **excludes)
{
- if (exclude != NULL &&
- g_pattern_match_simple(exclude, desc->name) == TRUE) {
- ofono_info("Excluding %s", desc->description);
- return FALSE;
+ if (excludes) {
+ for (; *excludes; excludes++)
+ if (g_pattern_match_simple(*excludes, desc->name))
+ break;
+ if (*excludes) {
+ ofono_info("Excluding %s", desc->description);
+ return FALSE;
+ }
}
- if (pattern != NULL &&
- g_pattern_match_simple(pattern, desc->name) == FALSE) {
- ofono_info("Ignoring %s", desc->description);
- return FALSE;
+ if (patterns) {
+ for (; *patterns; patterns++)
+ if (g_pattern_match_simple(*patterns, desc->name))
+ break;
+ if (!*patterns) {
+ ofono_info("Ignoring %s", desc->description);
+ return FALSE;
+ }
}
return TRUE;
@@ -93,6 +101,8 @@ static gboolean check_plugin(struct ofono_plugin_desc *desc,
int __ofono_plugin_init(const char *pattern, const char *exclude)
{
+ gchar **patterns = NULL;
+ gchar **excludes = NULL;
GSList *list;
GDir *dir;
const gchar *file;
@@ -101,9 +111,15 @@ int __ofono_plugin_init(const char *pattern, const char *exclude)
DBG("");
+ if (pattern)
+ patterns = g_strsplit_set(pattern, ", ", -1);
+
+ if (exclude)
+ excludes = g_strsplit_set(exclude, ", ", -1);
+
for (i = 0; __ofono_builtin[i]; i++) {
if (check_plugin(__ofono_builtin[i],
- pattern, exclude) == FALSE)
+ patterns, excludes) == FALSE)
continue;
add_plugin(NULL, __ofono_builtin[i]);
@@ -139,7 +155,7 @@ int __ofono_plugin_init(const char *pattern, const char *exclude)
continue;
}
- if (check_plugin(desc, pattern, exclude) == FALSE) {
+ if (check_plugin(desc, patterns, excludes) == FALSE) {
dlclose(handle);
continue;
}