[asterisk-commits] eliel: branch group/data_api_gsoc2009 r210861 - in /team/group/data_api_gsoc2...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 6 13:44:03 CDT 2009


Author: eliel
Date: Thu Aug  6 13:43:59 2009
New Revision: 210861

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=210861
Log:
Remove the "data test get" CLI command.


Modified:
    team/group/data_api_gsoc2009/include/asterisk/data.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=210861&r1=210860&r2=210861
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Thu Aug  6 13:43:59 2009
@@ -369,12 +369,6 @@
 #define ast_data_unregister(path) __ast_data_unregister(path, __FILE__)
 
 /*!
- * \brief Print out an ast_data tree to the console for debugging purposes.
- * \param[in] root The root node pointer of the data tree.
- */
-void ast_data_print_debug(const struct ast_data *root);
-
-/*!
  * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the
  *        current string value.
  *        .search = "somename=somestring"

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=210861&r1=210860&r2=210861
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Thu Aug  6 13:43:59 2009
@@ -147,7 +147,6 @@
 	ast_rwlock_t lock;
 } root_data;
 
-static void __ast_data_print_debug(const struct ast_data *root, uint32_t depth);
 static void __data_result_print_cli(int fd, const struct ast_data *root, uint32_t depth);
 
 /*!
@@ -571,106 +570,6 @@
 	return ret;
 }
 
-
-/*!
- * \internal
- * \brief Print a node to the console.
- * \param[in] node The node to print.
- * \param[in] depth The actual node depth in the tree.
- * \see __ast_data_print_debug, ast_data_print_debug
- */
-static void __ast_data_print_debug_node(const struct ast_data *node, uint32_t depth)
-{
-	int i;
-	struct ast_str *tabs;
-
-	tabs = ast_str_create(depth * 10 + 1);
-	if (!tabs) {
-		return;
-	}
-	ast_str_reset(tabs);
-	for (i = 0; i < depth; i++) {
-		ast_str_append(&tabs, 0, "\t");
-	}
-
-	switch (node->type) {
-	case AST_DATA_POINTER:
-		ast_debug(1, "%s%s (pointer): %p\n", ast_str_buffer(tabs),
-				node->name, node->payload.ptr);
-		break;
-	case AST_DATA_STRING:
-		ast_debug(1, "%s%s (string)[%u]: \"%s\"\n", ast_str_buffer(tabs),
-				node->name,
-				(unsigned int) strlen(node->payload.str),
-				node->payload.str);
-		break;
-	case AST_DATA_CONTAINER:
-		ast_debug(1, "%s%s (container)\n", ast_str_buffer(tabs),
-				node->name);
-		__ast_data_print_debug(node, depth + 1);
-		break;
-	case AST_DATA_INTEGER:
-		ast_debug(1, "%s%s (integer): %d\n", ast_str_buffer(tabs),
-				node->name,
-				node->payload.sint);
-		break;
-	case AST_DATA_UNSIGNED_INTEGER:
-		ast_debug(1, "%s%s (unsigned integer): %u\n", ast_str_buffer(tabs),
-				node->name,
-				node->payload.uint);
-		break;
-	case AST_DATA_DOUBLE:
-		ast_debug(1, "%s%s (double): %lf\n", ast_str_buffer(tabs),
-				node->name,
-				node->payload.dbl);
-		break;
-	case AST_DATA_BOOLEAN:
-		ast_debug(1, "%s%s (boolean): %s\n", ast_str_buffer(tabs),
-				node->name,
-				((node->payload.boolean) ? "True" : "False"));
-		break;
-	case AST_DATA_IPADDR:
-		ast_debug(1, "%s%s (ipaddr): %s\n", ast_str_buffer(tabs),
-				node->name,
-				ast_inet_ntoa(node->payload.ipaddr));
-		break;
-	}
-
-	ast_free(tabs);
-}
-
-/*!
- * \internal
- * \brief Print out an ast_data tree to the console for debugging purposes.
- * \see ast_data_print_debug
- */
-static void __ast_data_print_debug(const struct ast_data *root, uint32_t depth)
-{
-	struct ao2_iterator iter;
-	struct ast_data *node;
-
-	if (root->type == AST_DATA_CONTAINER) {
-		iter = ao2_iterator_init(root->children, 0);
-		while ((node = ao2_iterator_next(&iter))) {
-			__ast_data_print_debug_node(node, depth + 1);
-			ao2_ref(node, -1);
-		}
-	} else {
-		__ast_data_print_debug_node(root, depth);
-	}
-}
-
-/*!
- * \brief Print out an ast_data tree to the console for debugging purposes.
- * \param[in] root The root node pointer of the data tree.
- */
-void ast_data_print_debug(const struct ast_data *root)
-{
-	ast_debug(1, "\n");
-	__ast_data_print_debug(root, 0);
-}
-
-
 /*!
  * \internal
  * \brief Is a char used to specify a comparison?

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=210861&r1=210860&r2=210861
==============================================================================
--- team/group/data_api_gsoc2009/tests/test_data.c (original)
+++ team/group/data_api_gsoc2009/tests/test_data.c Thu Aug  6 13:43:59 2009
@@ -40,6 +40,11 @@
 #include "asterisk/cli.h"
 #include "asterisk/data.h"
 
+/*!
+ * \internal
+ * \brief Structure used to test how to add a complete structure,
+ *        and how to compare it.
+ */
 struct test_structure {
 	int a_int;
 	unsigned int b_bool:1;
@@ -47,6 +52,10 @@
 	unsigned int a_uint;
 };
 
+/*!
+ * \internal
+ * \brief test_structure mapping.
+ */
 #define DATA_EXPORT_TEST_STRUCTURE(MEMBER)				\
 	MEMBER(test_structure, a_int, AST_DATA_INTEGER)			\
 	MEMBER(test_structure, b_bool, AST_DATA_BOOLEAN)		\
@@ -55,6 +64,10 @@
 
 AST_DATA_STRUCTURE(test_structure, DATA_EXPORT_TEST_STRUCTURE);
 
+/*!
+ * \internal
+ * \brief Callback implementation.
+ */
 static int test_data_full_provider(const struct ast_data_search *search,
 	struct ast_data *root)
 {
@@ -72,27 +85,44 @@
 		return 0;
 	}
 
+	/* add the complete structure. */
 	ast_data_add_structure(test_structure, test_structure, &local_test_structure);
 
 	return 0;
 }
 
+/*!
+ * \internal
+ * \brief Simple callback implementation that does nothing.
+ */
 static int test_data_null_provider(const struct ast_data_search *search,
 	struct ast_data *root)
 {
 	return 0;
 }
 
+/*!
+ * \internal
+ * \brief Handler definition for the full provider.
+ */
 static const struct ast_data_handler full_provider = {
 	.version = AST_DATA_HANDLER_VERSION,
 	.get = test_data_full_provider
 };
 
+/*!
+ * \internal
+ * \brief Handler definition for the null provider.
+ */
 static const struct ast_data_handler null_provider = {
 	.version = AST_DATA_HANDLER_VERSION,
 	.get = test_data_null_provider
 };
 
+/*!
+ * \internal
+ * \brief Structure used to define multiple providers at once.
+ */
 static const struct ast_data_entry test_providers[] = {
 	AST_DATA_ENTRY("test/node1/node11/node111", &full_provider),
 	AST_DATA_ENTRY("test/node1/node12/node121", &full_provider),
@@ -104,6 +134,10 @@
 	AST_DATA_ENTRY("test/null/node1/node2/node3/node4/node5/node6", &null_provider),
 };
 
+/*!
+ * \internal
+ * \brief Handle CLI command "data test get benchmark".
+ */
 static char *handle_cli_data_get_bench(struct ast_cli_entry *e, int cmd,
 	struct ast_cli_args *a)
 {
@@ -150,6 +184,10 @@
 	return CLI_SUCCESS;
 }
 
+/*!
+ * \internal
+ * \brief Handle CLI command "data test get automatic"
+ */
 static char *handle_cli_data_get_automatic(struct ast_cli_entry *e, int cmd,
 	struct ast_cli_args *a)
 {
@@ -202,13 +240,15 @@
 	ast_cli(a->fd, "Finish iterating...\n");
 	ast_data_iterator_end(i);
 
-	ast_data_print_debug(res);
-
 	ast_data_free(res);
 
 	return CLI_SUCCESS;
 }
 
+/*!
+ * \internal
+ * \brief Handle CLI command "data test get dump".
+ */
 static char *handle_cli_data_get_dump(struct ast_cli_entry *e, int cmd,
 	struct ast_cli_args *a)
 {
@@ -251,52 +291,14 @@
 	return res;
 }
 
-static char *handle_cli_data_get(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	struct ast_data_query query = { .version = AST_DATA_QUERY_VERSION };
-	struct ast_data *tree;
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "data test get";
-		e->usage = "Usage: data test get <path> [<search>] [<filter>]\n"
-			   "   Dump data to the console\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-
-	if (a->argc < e->args + 1) {
-		return CLI_SHOWUSAGE;
-	}
-
-	query.path = (char *) a->argv[e->args];
-
-	if (a->argc > e->args + 1) {
-		query.search = (char *) a->argv[e->args + 1];
-	}
-
-	if (a->argc > e->args + 2) {
-		query.filter = (char *) a->argv[e->args + 2];
-	}
-
-	tree = ast_data_get(&query);
-	if (!tree) {
-		return CLI_FAILURE;
-	}
-
-	ast_data_print_debug(tree);
-
-	ast_data_free(tree);
-
-	return CLI_SUCCESS;
-}
-
+/*!
+ * \internal
+ * \brief Register every CLI command.
+ */
 static struct ast_cli_entry cli_data[] = {
 	AST_CLI_DEFINE(handle_cli_data_get_bench, "Benchmark ast_data get performance"),
 	AST_CLI_DEFINE(handle_cli_data_get_automatic, "Test data get"),
 	AST_CLI_DEFINE(handle_cli_data_get_dump, "Dump test data to xml"),
-	AST_CLI_DEFINE(handle_cli_data_get, "Get data from the tree")
 };
 
 static int unload_module(void)




More information about the asterisk-commits mailing list