From 0f02f72a8e871f79c8230b9bc954c9db66dbd34b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 21 Jan 2009 21:42:41 +0100 Subject: [PATCH] Add extra options to exclude devices and plugins --- src/connman.h | 5 +++-- src/element.c | 3 ++- src/main.c | 14 +++++++++++--- src/plugin.c | 13 +++++++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/connman.h b/src/connman.h index 58f57ff..4238234 100644 --- a/src/connman.h +++ b/src/connman.h @@ -62,7 +62,7 @@ gboolean __connman_debug_enabled(void); #include -int __connman_plugin_init(const char *pattern); +int __connman_plugin_init(const char *pattern, const char *exclude); void __connman_plugin_cleanup(void); #include @@ -100,7 +100,8 @@ void __connman_driver_rescan(struct connman_driver *driver); #include -int __connman_element_init(DBusConnection *conn, const char *device); +int __connman_element_init(DBusConnection *conn, const char *device, + const char *nodevice); void __connman_element_start(void); void __connman_element_stop(void); void __connman_element_cleanup(void); diff --git a/src/element.c b/src/element.c index 0a6a037..2f1aa43 100644 --- a/src/element.c +++ b/src/element.c @@ -1177,7 +1177,8 @@ int connman_element_set_enabled(struct connman_element *element, return 0; } -int __connman_element_init(DBusConnection *conn, const char *device) +int __connman_element_init(DBusConnection *conn, const char *device, + const char *nodevice) { struct connman_element *element; diff --git a/src/main.c b/src/main.c index 5da7c86..581446e 100644 --- a/src/main.c +++ b/src/main.c @@ -52,6 +52,8 @@ static void disconnect_callback(DBusConnection *conn, void *user_data) static gchar *option_device = NULL; static gchar *option_plugin = NULL; +static gchar *option_nodevice = NULL; +static gchar *option_noplugin = NULL; static gboolean option_detach = TRUE; static gboolean option_compat = FALSE; static gboolean option_debug = FALSE; @@ -60,9 +62,13 @@ static gboolean option_version = FALSE; static GOptionEntry options[] = { { "device", 'i', 0, G_OPTION_ARG_STRING, &option_device, - "Specify network device/interface", "DEV" }, + "Specify networking device or interface", "DEV" }, + { "nodevice", 'I', 0, G_OPTION_ARG_STRING, &option_nodevice, + "Specify networking interface to ignore", "DEV" }, { "plugin", 'p', 0, G_OPTION_ARG_STRING, &option_plugin, "Specify plugins to load", "NAME" }, + { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin, + "Specify plugins not to load", "NAME" }, { "nodaemon", 'n', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &option_detach, "Don't fork daemon to background" }, @@ -164,7 +170,7 @@ int main(int argc, char *argv[]) __connman_dbus_init(conn); __connman_storage_init(); - __connman_element_init(conn, option_device); + __connman_element_init(conn, option_device, option_nodevice); __connman_agent_init(conn); __connman_manager_init(conn, option_compat); @@ -174,12 +180,14 @@ int main(int argc, char *argv[]) __connman_rtnl_init(); __connman_udev_init(); - __connman_plugin_init(option_plugin); + __connman_plugin_init(option_plugin, option_noplugin); __connman_element_start(); g_free(option_device); g_free(option_plugin); + g_free(option_nodevice); + g_free(option_noplugin); memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_term; diff --git a/src/plugin.c b/src/plugin.c index 7fb7d44..59d3572 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -43,8 +43,10 @@ static gboolean add_plugin(void *handle, struct connman_plugin_desc *desc) if (desc->init == NULL) return FALSE; - if (g_str_equal(desc->version, CONNMAN_VERSION) == FALSE) + if (g_str_equal(desc->version, CONNMAN_VERSION) == FALSE) { + DBG("version mismatch for %s", desc->description); return FALSE; + } plugin = g_try_new0(struct connman_plugin, 1); if (plugin == NULL) @@ -63,7 +65,7 @@ static gboolean add_plugin(void *handle, struct connman_plugin_desc *desc) return TRUE; } -int __connman_plugin_init(const char *pattern) +int __connman_plugin_init(const char *pattern, const char *exclude) { GDir *dir; const gchar *file; @@ -100,6 +102,13 @@ int __connman_plugin_init(const char *pattern) 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); -- 2.7.4