[asterisk-commits] eliel: branch eliel/data_api_providers_gsoc2010 r275146 - /team/eliel/data_ap...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jul 9 13:10:03 CDT 2010
Author: eliel
Date: Fri Jul 9 13:10:00 2010
New Revision: 275146
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=275146
Log:
When retrieving the tree in xml form, put the type of each node in an
attribute named "type".
Modified:
team/eliel/data_api_providers_gsoc2010/main/data.c
Modified: team/eliel/data_api_providers_gsoc2010/main/data.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/main/data.c?view=diff&rev=275146&r1=275145&r2=275146
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/main/data.c (original)
+++ team/eliel/data_api_providers_gsoc2010/main/data.c Fri Jul 9 13:10:00 2010
@@ -103,6 +103,28 @@
char name[0];
};
+/*!
+ * \brief Description of each data type.
+ */
+struct data_type_description {
+ enum ast_data_type type;
+ const char *description;
+} type_description[] = {
+ { AST_DATA_CONTAINER, "container" },
+ { AST_DATA_INTEGER, "integer" },
+ { AST_DATA_UNSIGNED_INTEGER, "unsigned integer" },
+ { AST_DATA_DOUBLE, "double" },
+ { AST_DATA_BOOLEAN, "boolean" },
+ { AST_DATA_STRING, "string" },
+ { AST_DATA_CHARACTER, "character" },
+ { AST_DATA_PASSWORD, "password" },
+ { AST_DATA_IPADDR, "ipaddr" },
+ { AST_DATA_TIMESTAMP, "timestamp" },
+ { AST_DATA_SECONDS, "seconds" },
+ { AST_DATA_MILLISECONDS, "milliseconds" },
+ { AST_DATA_POINTER, "pointer" }
+};
+
/*! \brief Type of comparisons allow in the search string. */
enum data_search_comparison {
DATA_CMP_UNKNOWN,
@@ -238,6 +260,23 @@
* \brief Unlock the data registered handlers structure.
*/
#define data_unlock() ast_rwlock_unlock(&root_data.lock)
+
+/*!
+ * \brief Return the string representing the data type.
+ * \param[in] type The data type to return the description.
+ */
+static const char *data_type2str(enum ast_data_type type)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_LEN(type_description); i++) {
+ if (type_description[i].type == type) {
+ return type_description[i].description;
+ }
+ }
+
+ return "unknown";
+}
/*!
* \internal
@@ -2165,6 +2204,7 @@
ast_xml_set_text(child_xml, node_content);
break;
}
+ ast_xml_set_attribute(child_xml, "type", data_type2str(node->type));
ast_xml_add_child(parent_xml, child_xml);
ao2_ref(node, -1);
More information about the asterisk-commits
mailing list