[asterisk-commits] eliel: branch eliel/data_api_providers_gsoc2010 r281465 - /team/eliel/data_ap...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 9 16:36:35 CDT 2010


Author: eliel
Date: Mon Aug  9 16:36:31 2010
New Revision: 281465

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=281465
Log:
Implements the /asterisk/core/modules AstData API node.


Modified:
    team/eliel/data_api_providers_gsoc2010/main/cli.c

Modified: team/eliel/data_api_providers_gsoc2010/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/main/cli.c?view=diff&rev=281465&r1=281464&r2=281465
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/main/cli.c (original)
+++ team/eliel/data_api_providers_gsoc2010/main/cli.c Mon Aug  9 16:36:31 2010
@@ -1793,6 +1793,51 @@
 	return 0;
 }
 
+AST_MUTEX_DEFINE_STATIC(modules_data_root_lock);
+static struct ast_data *modules_data_root;
+static const struct ast_data_search *modules_data_search;
+
+static int data_modlist_modentry(const char *module, const char *description, int usecnt, const char *like)
+{
+
+	struct ast_data *data_module;
+
+	data_module = ast_data_add_node(modules_data_root, "module");
+	if (!data_module) {
+		return -1;
+	}
+
+	ast_data_add_str(data_module, "name", module);
+	ast_data_add_str(data_module, "description", description);
+	ast_data_add_int(data_module, "use_count", usecnt);
+
+	if (!ast_data_search_match(modules_data_search, data_module)) {
+		ast_data_remove_node(modules_data_root, data_module);
+	}
+
+	return 0;
+}
+
+/*!
+ * \internal
+ * \brief Callback used to generate the uptime tree.
+ * \param[in] search The search pattern tree.
+ * \retval <0 on error.
+ * \retval 0 The generated tree.
+ */
+static int modules_data_provider_get(const struct ast_data_search *search,
+	struct ast_data *data_root)
+{
+
+	ast_mutex_lock(&modules_data_root_lock);
+	modules_data_root = data_root;
+	modules_data_search = search;
+	ast_update_module_list(data_modlist_modentry, NULL);
+	ast_mutex_unlock(&modules_data_root_lock);
+
+	return 0;
+}
+
 /*!
  * \internal
  * \brief Callback used to generate the uptime tree.
@@ -1823,8 +1868,14 @@
 	.get = uptime_data_provider_get
 };
 
+static const struct ast_data_handler modules_data_provider = {
+	.version = AST_DATA_HANDLER_VERSION,
+	.get = modules_data_provider_get
+};
+
 static const struct ast_data_entry cli_data_providers[] = {
 	AST_DATA_ENTRY("/asterisk/core/uptime", &uptime_data_provider),
+	AST_DATA_ENTRY("/asterisk/core/modules", &modules_data_provider),
 };
 
 /*! \brief initialize the _full_cmd string in * each of the builtins. */




More information about the asterisk-commits mailing list