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,
|
G_OPTION_ARG_CALLBACK, parse_debug,
|
||||||
"Specify debug options to enable", "DEBUG" },
|
"Specify debug options to enable", "DEBUG" },
|
||||||
{ "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin,
|
{ "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,
|
{ "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,
|
{ "nodetach", 'n', G_OPTION_FLAG_REVERSE,
|
||||||
G_OPTION_ARG_NONE, &option_detach,
|
G_OPTION_ARG_NONE, &option_detach,
|
||||||
"Don't run as daemon in background" },
|
"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,
|
static gboolean check_plugin(struct ofono_plugin_desc *desc,
|
||||||
const char *pattern, const char *exclude)
|
char **patterns, char **excludes)
|
||||||
{
|
{
|
||||||
if (exclude != NULL &&
|
if (excludes) {
|
||||||
g_pattern_match_simple(exclude, desc->name) == TRUE) {
|
for (; *excludes; excludes++)
|
||||||
ofono_info("Excluding %s", desc->description);
|
if (g_pattern_match_simple(*excludes, desc->name))
|
||||||
return FALSE;
|
break;
|
||||||
|
if (*excludes) {
|
||||||
|
ofono_info("Excluding %s", desc->description);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pattern != NULL &&
|
if (patterns) {
|
||||||
g_pattern_match_simple(pattern, desc->name) == FALSE) {
|
for (; *patterns; patterns++)
|
||||||
ofono_info("Ignoring %s", desc->description);
|
if (g_pattern_match_simple(*patterns, desc->name))
|
||||||
return FALSE;
|
break;
|
||||||
|
if (!*patterns) {
|
||||||
|
ofono_info("Ignoring %s", desc->description);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
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)
|
int __ofono_plugin_init(const char *pattern, const char *exclude)
|
||||||
{
|
{
|
||||||
|
gchar **patterns = NULL;
|
||||||
|
gchar **excludes = NULL;
|
||||||
GSList *list;
|
GSList *list;
|
||||||
GDir *dir;
|
GDir *dir;
|
||||||
const gchar *file;
|
const gchar *file;
|
||||||
|
@ -101,9 +111,15 @@ int __ofono_plugin_init(const char *pattern, const char *exclude)
|
||||||
|
|
||||||
DBG("");
|
DBG("");
|
||||||
|
|
||||||
|
if (pattern)
|
||||||
|
patterns = g_strsplit_set(pattern, ", ", -1);
|
||||||
|
|
||||||
|
if (exclude)
|
||||||
|
excludes = g_strsplit_set(exclude, ", ", -1);
|
||||||
|
|
||||||
for (i = 0; __ofono_builtin[i]; i++) {
|
for (i = 0; __ofono_builtin[i]; i++) {
|
||||||
if (check_plugin(__ofono_builtin[i],
|
if (check_plugin(__ofono_builtin[i],
|
||||||
pattern, exclude) == FALSE)
|
patterns, excludes) == FALSE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
add_plugin(NULL, __ofono_builtin[i]);
|
add_plugin(NULL, __ofono_builtin[i]);
|
||||||
|
@ -139,7 +155,7 @@ int __ofono_plugin_init(const char *pattern, const char *exclude)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check_plugin(desc, pattern, exclude) == FALSE) {
|
if (check_plugin(desc, patterns, excludes) == FALSE) {
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue