[asterisk-commits] eliel: branch group/data_api_gsoc2009 r202335 - in /team/group/data_api_gsoc2...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jun 22 09:07:05 CDT 2009
Author: eliel
Date: Mon Jun 22 09:07:02 2009
New Revision: 202335
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=202335
Log:
Add some partial implementations.
Modified:
team/group/data_api_gsoc2009/include/asterisk/data.h
team/group/data_api_gsoc2009/main/data.c
Modified: team/group/data_api_gsoc2009/include/asterisk/data.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/include/asterisk/data.h?view=diff&rev=202335&r1=202334&r2=202335
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Mon Jun 22 09:07:02 2009
@@ -193,7 +193,7 @@
/*!
* \brief Retrieve a subtree from the asterisk data API.
- * \param[in] query
+ * \param[in] query The query structure specifying what nodes to retrieve.
* \retval NULL on error.
* \retval The dynamically allocated requested sub-tree (it needs to be released using
* ast_data_free.
Modified: team/group/data_api_gsoc2009/main/data.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/main/data.c?view=diff&rev=202335&r1=202334&r2=202335
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Mon Jun 22 09:07:02 2009
@@ -117,12 +117,10 @@
* \brief Lock the data registered handlers structure for reading.
* \see data_unlock
*/
-/* XXX: avoid defining functions that at the moment are not being used.
static inline void data_read_lock(void)
{
ast_rwlock_rdlock(&root_data_lock);
}
-*/
/*!
* \internal
@@ -549,6 +547,7 @@
}
/*!
+ * \internal
* \brief Add a child to the specified root node.
* \param[in] root The root node pointer.
* \param[in] child The child to add to the root node.
@@ -558,7 +557,15 @@
ao2_link(root->children, child);
}
-static struct ast_data *data_result_generate(struct data_provider *root_provider,
+/*!
+ * \internal
+ * \brief
+ * \param[in] root_provider
+ * \param[in] parent_node_name
+ * \retval NULL on error.
+ * \retval non-NULL The generated result tree.
+ */
+static struct ast_data *data_result_generate_node(struct data_provider *root_provider,
const char *parent_node_name)
{
struct ast_data *generated, *node;
@@ -584,7 +591,7 @@
/* if this is not a terminal node, generate every child node. */
i = ao2_iterator_init(root_provider->children, 0);
while ((provider = ao2_iterator_next(&i))) {
- generated = data_result_generate(provider, provider->name);
+ generated = data_result_generate_node(provider, provider->name);
if (generated) {
data_result_add_child(node, generated);
}
@@ -592,6 +599,35 @@
}
return node;
+}
+
+/*!
+ * \internal
+ * \brief Generate a result tree based on a query.
+ * \param[in] query The query used to generate the tree.
+ * \retval NULL on error.
+ * \retval non-NULL The generated data result.
+ */
+static struct ast_data *data_result_generate(const struct ast_data_query *query)
+{
+ /* parse the query, and generate the syntax */
+ return NULL;
+}
+
+struct ast_data *ast_data_get(const struct ast_data_query *query)
+{
+ struct ast_data *res;
+
+ data_read_lock();
+ res = data_result_generate(query);
+ data_unlock();
+
+ if (!res) {
+ ast_log(LOG_ERROR, "Unable to get data from %s\n", query->path);
+ return NULL;
+ }
+
+ return res;
}
enum ast_data_type ast_data_get_type(struct ast_data *node, const char *path)
@@ -661,12 +697,6 @@
}
ao2_ref(root, -1);
-}
-
-struct ast_data *ast_data_get(const struct ast_data_query *query)
-{
- /* TODO: implement this. */
- return NULL;
}
/* XXX: test callback */
More information about the asterisk-commits
mailing list