[asterisk-commits] bbryant: branch group/data_api_gsoc2009 r205663 - /team/group/data_api_gsoc20...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 9 14:21:16 CDT 2009
Author: bbryant
Date: Thu Jul 9 14:21:13 2009
New Revision: 205663
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=205663
Log:
Add a new function (data_filter_add_result_child) to the data API.
Modified:
team/group/data_api_gsoc2009/main/data.c
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=205663&r1=205662&r2=205663
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Thu Jul 9 14:21:13 2009
@@ -1177,6 +1177,36 @@
/*!
* \internal
+ */
+static int data_filter_add_result_child(struct data_filter_list *flist,
+ const char *pathroot,
+ struct ast_data *node,
+ struct ast_data *generated)
+{
+ int found = 0;
+ struct data_filter_node *fnode, *fnode2;
+
+ AST_LIST_TRAVERSE(flist, fnode, next) {
+ if (!strcasecmp(fnode->name, pathroot)) {
+ AST_LIST_TRAVERSE(&(fnode->children), fnode2, next) {
+ if (!strcasecmp(fnode->name, generated->name)) {
+ data_result_add_child(node, generated);
+ found = 1;
+ break;
+ }
+ }
+
+ if (found) {
+ break;
+ }
+ }
+ }
+
+ return found;
+}
+
+/*!
+ * \internal
* \brief Generate all the tree from a specified provider.
* \param[in] query The query executed.
* \param[in] root_provider The provider specified in the path of the query.
@@ -1190,12 +1220,10 @@
struct data_filter_list *flist,
const struct ast_data_search *search)
{
- int found;
char *pathtmp;
struct ast_data *generated, *node;
struct ao2_iterator i;
struct data_provider *provider;
- struct data_filter_node *fnode, *fnode2;
struct ast_data_search *search_child = NULL;
node = data_result_create(parent_node_name);
@@ -1217,23 +1245,7 @@
generated = root_provider->handler->get(search);
if (generated) {
pathtmp = data_filter_get_last_leaf(parent_node_name);
-
- AST_LIST_TRAVERSE(flist, fnode, next) {
- if (!strcasecmp(fnode->name, pathtmp)) {
- AST_LIST_TRAVERSE(&(fnode->children), fnode2, next) {
- if (!strcasecmp(fnode->name, generated->name)) {
- data_result_add_child(node, generated);
- found = 1;
- break;
- }
- }
-
- if (found) {
- break;
- }
- }
- }
-
+ data_filter_add_result_child(flist, pathtmp, node, generated);
ao2_ref(generated, -1);
}
@@ -1255,24 +1267,8 @@
ao2_ref(search_child, -1);
if (generated) {
- pathtmp = data_filter_get_last_leaf(parent_node_name);
-
- AST_LIST_TRAVERSE(flist, fnode, next) {
- if (!strcasecmp(fnode->name, provider->name)) {
- AST_LIST_TRAVERSE(&(fnode->children), fnode2, next) {
- if (!strcasecmp(fnode2->name, generated->name)) {
- data_result_add_child(node, generated);
- found = 1;
- break;
- }
- }
-
- if (found) {
- break;
- }
- }
- }
-
+ pathtmp = data_filter_get_last_leaf(provider->name);
+ data_filter_add_result_child(flist, pathtmp, node, generated);
ao2_ref(generated, -1);
}
ao2_ref(provider, -1);
More information about the asterisk-commits
mailing list