[svn-commits] eliel: branch group/data_api_gsoc2009 r205665 - in /team/group/data_api_gsoc2...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 9 14:36:39 CDT 2009


Author: eliel
Date: Thu Jul  9 14:36:35 2009
New Revision: 205665

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=205665
Log:
Add more documentation.
Add more tests scenarios.
Fix a crash when no filtering string is specified.


Modified:
    team/group/data_api_gsoc2009/include/asterisk/data.h
    team/group/data_api_gsoc2009/include/asterisk/xml.h
    team/group/data_api_gsoc2009/main/data.c
    team/group/data_api_gsoc2009/tests/test_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=205665&r1=205664&r2=205665
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Thu Jul  9 14:36:35 2009
@@ -188,21 +188,27 @@
 #define ast_data_unregister(path) __ast_data_unregister(path, __FILE__)
 
 /*!
- * \internal
- * \brief
- * \param[in] root
- * \param[in] name
- * \param[in] value
+ * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the
+ *        current string value.
+ *        .search = "somename=somestring"
+ *        name = "somename"
+ *        value is the current value of something and will be evaluated against "10".
+ * \param[in] root The root node pointer of the search tree.
+ * \param[in] name The name of the specific.
+ * \param[in] value The value to compare.
  * \returns The strcmp return value.
  */
 int ast_data_search_cmp_string(const struct ast_data_search *root, const char *name, const char *value);
 
 /*!
- * \internal
- * \brief
- * \param[in] root
- * \param[in] name
- * \param[in] value
+ * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the
+ *        current signed integer value.
+ *        .search = "something=10"
+ *        name = "something"
+ *        value is the current value of something and will be evaluated against "10".
+ * \param[in] root The root node pointer of the search tree.
+ * \param[in] name The name of the specific.
+ * \param[in] value The value to compare.
  * \returns The strcmp return value.
  */
 int ast_data_search_cmp_sint(const struct ast_data_search *root, const char *name, int value);

Modified: team/group/data_api_gsoc2009/include/asterisk/xml.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/include/asterisk/xml.h?view=diff&rev=205665&r1=205664&r2=205665
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/xml.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/xml.h Thu Jul  9 14:36:35 2009
@@ -118,8 +118,7 @@
 /*!
  * \brief Get the document based on a node.
  * \param node A node that is part of the dom.
- * \retval NULL on error.
- * \retval The dom pointer where this node resides.
+ * \returns The dom pointer where this node resides.
  */
 struct ast_xml_doc *ast_xml_get_doc(struct ast_xml_node *node);
 

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=205665&r1=205664&r2=205665
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Thu Jul  9 14:36:35 2009
@@ -901,6 +901,10 @@
 	char *savepath;
 	struct ast_data_search *child;
 
+	if (!node) {
+		return NULL;
+	}
+
 	if (!path) {
 		return (struct ast_data_search *) node;
 	}
@@ -942,7 +946,6 @@
 
 	child = data_search_get_node(root, name);
 	if (!child) {
-		ast_log(LOG_ERROR, "Not found!!! %s->%s\n", root->name, name);
 		return 0;
 	}
 
@@ -1186,6 +1189,11 @@
 	int found = 0;
 	struct data_filter_node *fnode, *fnode2;
 
+	if (!flist) {
+		data_result_add_child(node, generated);
+		return 1;
+	}
+
 	AST_LIST_TRAVERSE(flist, fnode, next) {
 		if (!strcasecmp(fnode->name, pathroot)) {
 			AST_LIST_TRAVERSE(&(fnode->children), fnode2, next) {
@@ -1232,7 +1240,7 @@
 		return NULL;
 	}
 
-	if (!flist) {
+	if (!flist && query->filter) {
 		flist = data_filter_generate(query->filter);
 	}
 

Modified: team/group/data_api_gsoc2009/tests/test_data.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/tests/test_data.c?view=diff&rev=205665&r1=205664&r2=205665
==============================================================================
--- team/group/data_api_gsoc2009/tests/test_data.c (original)
+++ team/group/data_api_gsoc2009/tests/test_data.c Thu Jul  9 14:36:35 2009
@@ -45,7 +45,11 @@
 	struct ast_data *res, *internal;
 
 	if (!ast_data_search_cmp_sint(search, "root_test/data1", 10)) {
-		return NULL;
+		ast_debug(1, "root_test/data1 doesn't match\n");
+	}
+
+	if (!ast_data_search_cmp_sint(search, "root_test/data2", 20)) {
+		ast_debug(1, "root_test/data2 doesn't match\n");
 	}
 
 	res = ast_data_create("root_test");
@@ -56,6 +60,7 @@
 	ast_data_add_int(res, "data1", 10);
 	ast_data_add_dbl(res, "data2", 20);
 	ast_data_add_bool(res, "data3", 1);
+	ast_data_add_str(res, "name", "eliel");
 
 	internal = ast_data_add_node(res, "internal");
 	if (!internal) {
@@ -143,7 +148,7 @@
 	struct ast_data_query query = {
 		.version = AST_DATA_QUERY_VERSION,
 		.path = "test/node1/node11/node111",
-		.search = "node111/root_test/data1>=20"
+		.search = "node111/root_test/data1>=10,node111/root_test/data2<20"
 	};
 
 	switch (cmd) {




More information about the svn-commits mailing list