[asterisk-commits] bbryant: branch group/data_api_gsoc2009 r205975 - in /team/group/data_api_gso...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 10 14:57:37 CDT 2009


Author: bbryant
Date: Fri Jul 10 14:57:34 2009
New Revision: 205975

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=205975
Log:
Add ast_data_print_debug for printing the data tree to the console for debugging purposes.

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=205975&r1=205974&r2=205975
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Fri Jul 10 14:57:34 2009
@@ -217,6 +217,13 @@
 })
 
 /*!
+ * \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=205975&r1=205974&r2=205975
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Fri Jul 10 14:57:34 2009
@@ -553,6 +553,70 @@
 
 	return ret;
 }
+
+/*!
+ * \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)
+{
+	int i;
+	struct ao2_iterator iter;
+	struct ast_data *node;
+
+	ast_debug(1, "%s (container)\n", root->name);
+	depth = depth + 1;
+
+	iter = ao2_iterator_init(root->children, 0);
+	while ((node = ao2_iterator_next(&iter))) {
+		/* XXX compare every member of the structure */
+		for (i = 0; i < depth; i++)
+			ast_debug(1, "\t>> ");
+
+		ast_debug(1, "%s ", node->name);
+
+		switch (root->type) {
+			case AST_DATA_POINTER:
+				ast_debug(1, " (pointer): %p\n", node->payload.ptr);
+				break;
+			case AST_DATA_CHAR:
+			case AST_DATA_STRING:
+				ast_debug(1, " (string)[%u]: \"%s\"", (unsigned int)strlen(node->payload.str), node->payload.str);
+				break;
+			case AST_DATA_CONTAINER:
+				__ast_data_print_debug(node, depth);
+				break;
+			case AST_DATA_INTEGER:
+				ast_debug(1, " (integer): %d\n", node->payload.sint);
+				break;
+			case AST_DATA_UNSIGNED_INTEGER:
+				ast_debug(1, " (unsigned integer): %u\n", node->payload.uint);
+				break;
+			case AST_DATA_DOUBLE:
+				ast_debug(1, " (double): %lf\n", node->payload.dbl);
+				break;
+			case AST_DATA_BOOLEAN:
+				ast_debug(1, " (boolean): %s\n", ((node->payload.boolean) ? "True" : "False"));
+				break;
+			case AST_DATA_IPADDR:
+				ast_debug(1, " (ipaddr): %s\n", ast_inet_ntoa(node->payload.ipaddr));
+				break;
+		}
+
+		ao2_ref(node, -1);
+	}
+}
+
+/*!
+ * \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_data_print_debug(root, 0);
+}
+
 
 /*!
  * \internal




More information about the asterisk-commits mailing list