mirror of git://git.sysmocom.de/ofono
Support -p and -P options with list of plugins
This commit is contained in:
parent
dc92bfb9a9
commit
adb8219090
|
@ -114,9 +114,9 @@ static GOptionEntry options[] = {
|
|||
G_OPTION_ARG_CALLBACK, parse_debug,
|
||||
"Specify debug options to enable", "DEBUG" },
|
||||
{ "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin,
|
||||
"Specify plugins to load", "NAME" },
|
||||
"Specify plugins to load", "NAME,..," },
|
||||
{ "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin,
|
||||
"Specify plugins not to load", "NAME" },
|
||||
"Specify plugins not to load", "NAME,..." },
|
||||
{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
|
||||
G_OPTION_ARG_NONE, &option_detach,
|
||||
"Don't run as daemon in background" },
|
||||
|
|
38
src/plugin.c
38
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue