[PATCH 2/3] plugin: Add log update and list functionality accessible from plugins

Jussi Laakkonen <[email protected]>
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
Add plugin log update and list functionality. This is needed for the
dynamically loaded plugins to update logging (enabled/disabled) and to
list the source files. Make the functions accessible from plugins.
---
 include/plugin.h |  5 +++++
 src/plugin.c     | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/plugin.h b/include/plugin.h
index 8d2bb08e..c07ae866 100644
--- a/include/plugin.h
+++ b/include/plugin.h
@@ -100,6 +100,11 @@ struct connman_plugin_desc {
 		};
 #endif
 
+void connman_plugin_log_update(const char *pattern,
+				unsigned int set_flags,
+				unsigned int clear_flags);
+int connman_plugin_log_list(GHashTable *hash);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/plugin.c b/src/plugin.c
index 7d730582..664d8bab 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -103,6 +103,40 @@ static bool check_plugin(struct connman_plugin_desc *desc,
 	return true;
 }
 
+void connman_plugin_log_update(const char *pattern, unsigned int set_flags,
+					unsigned int clear_flags)
+{
+	GSList *list;
+
+	for (list = plugins; list; list = list->next) {
+		struct connman_plugin *plugin = list->data;
+
+		__connman_log_update(plugin->desc->debug_start,
+					plugin->desc->debug_stop,
+					pattern,
+					set_flags,
+					clear_flags);
+	}
+}
+
+int connman_plugin_log_list(GHashTable *hash)
+{
+	GSList *list;
+
+	if (!hash)
+		return -EINVAL;
+
+	for (list = plugins; list; list = list->next) {
+		struct connman_plugin *plugin = list->data;
+
+		__connman_log_list(plugin->desc->debug_start,
+					plugin->desc->debug_stop,
+					hash);
+	}
+
+	return 0;
+}
+
 #include <builtin.h>
 
 int __connman_plugin_init(const char *pattern, const char *exclude)
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.