[svn-commits] bbryant: branch group/data_api_gsoc2009 r204320 - in /team/group/data_api_gso...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jun 29 18:21:09 CDT 2009
Author: bbryant
Date: Mon Jun 29 18:21:06 2009
New Revision: 204320
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=204320
Log:
Fix some things mentioned on reviewboard by russelb.
Modified:
team/group/data_api_gsoc2009/include/asterisk/xml.h
team/group/data_api_gsoc2009/main/data.c
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=204320&r1=204319&r2=204320
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/xml.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/xml.h Mon Jun 29 18:21:06 2009
@@ -18,47 +18,53 @@
#define _ASTERISK_XML_H
/*! \file
- * \brief Asterisk XML abstraction layer
+ * \brief Asterisk XML abstraction layer
*/
struct ast_xml_node;
struct ast_xml_doc;
-/*! \brief Initialize the XML library implementation.
+/*!
+ * \brief Initialize the XML library implementation.
* This function is used to setup everything needed
* to start working with the xml implementation.
- * \retval 0 On success.
- * \retval 1 On error.
+ * \retval 0 On success.
+ * \retval 1 On error.
*/
int ast_xml_init(void);
-/*! \brief Cleanup library allocated global data.
- * \retval 0 On success.
- * \retval 1 On error.
+/*!
+ * \brief Cleanup library allocated global data.
+ * \retval 0 On success.
+ * \retval 1 On error.
*/
int ast_xml_finish(void);
-/*! \brief Open an XML document.
- * \param filename Document path.
- * \retval NULL on error.
- * \retval The ast_xml_doc reference to the open document.
+/*!
+ * \brief Open an XML document.
+ * \param filename Document path.
+ * \retval NULL on error.
+ * \retval The ast_xml_doc reference to the open document.
*/
struct ast_xml_doc *ast_xml_open(char *filename);
-/*! \brief Create a XML document.
- * \retval NULL on error.
- * \retval non-NULL The allocated document structure.
+/*!
+ * \brief Create a XML document.
+ * \retval NULL on error.
+ * \retval non-NULL The allocated document structure.
*/
struct ast_xml_doc *ast_xml_new(void);
-/*! \brief Create a XML node.
- * \param name The name of the node to be created.
- * \retval NULL on error.
- * \retval non-NULL The allocated node structe.
+/*!
+ * \brief Create a XML node.
+ * \param name The name of the node to be created.
+ * \retval NULL on error.
+ * \retval non-NULL The allocated node structe.
*/
struct ast_xml_node *ast_xml_new_node(const char *name);
-/*! \brief Add a child node inside a passed parent node.
+/*!
+ * \brief Add a child node inside a passed parent node.
* \param parent The pointer of the parent node.
* \param child_name The name of the child node to add.
* \retval NULL on error.
@@ -75,9 +81,10 @@
*/
struct ast_xml_node *ast_xml_add_child(struct ast_xml_node *parent, struct ast_xml_node *child);
-/*! \brief Close an already open document and free the used
+/*!
+ * \brief Close an already open document and free the used
* structure.
- * \retval doc The document reference.
+ * \retval doc The document reference.
*/
void ast_xml_close(struct ast_xml_doc *doc);
@@ -88,91 +95,107 @@
*/
void ast_xml_set_root(struct ast_xml_doc *doc, struct ast_xml_node *node);
-/*! \brief Get the document root node.
- * \param doc Document reference
- * \retval NULL on error
- * \retval The root node on success.
+/*!
+ * \brief Get the document root node.
+ * \param doc Document reference
+ * \retval NULL on error
+ * \retval The root node on success.
*/
struct ast_xml_node *ast_xml_get_root(struct ast_xml_doc *doc);
-/*! \brief Free node
- * \param node Node to be released.
+/*!
+ * \brief Free node
+ * \param node Node to be released.
*/
void ast_xml_free_node(struct ast_xml_node *node);
-/*! \brief Free an attribute returned by ast_xml_get_attribute()
- * \param data pointer to be freed.
+/*!
+ * \brief Free an attribute returned by ast_xml_get_attribute()
+ * \param data pointer to be freed.
*/
void ast_xml_free_attr(const char *attribute);
-/*! \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.
+/*!
+ * \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.
*/
struct ast_xml_doc *ast_xml_get_doc(struct ast_xml_node *node);
-/*! \brief Free a content element that was returned by ast_xml_get_text()
- * \param text text to be freed.
+/*!
+ * \brief Free a content element that was returned by ast_xml_get_text()
+ * \param text text to be freed.
*/
void ast_xml_free_text(const char *text);
-/*! \brief Get a node attribute by name
- * \param node Node where to search the attribute.
- * \param attrname Attribute name.
- * \retval NULL on error
- * \retval The attribute value on success.
+/*!
+ * \brief Get a node attribute by name
+ * \param node Node where to search the attribute.
+ * \param attrname Attribute name.
+ * \retval NULL on error
+ * \retval The attribute value on success.
*/
const char *ast_xml_get_attribute(struct ast_xml_node *node, const char *attrname);
-/*! \brief Set an attribute to a node.
- * \param node In which node we want to insert the attribute.
- * \param name The attribute name.
- * \param value The attribute value.
- * \retval 0 on success.
- * \retval -1 on error.
+/*!
+ * \brief Set an attribute to a node.
+ * \param node In which node we want to insert the attribute.
+ * \param name The attribute name.
+ * \param value The attribute value.
+ * \retval 0 on success.
+ * \retval -1 on error.
*/
int ast_xml_set_attribute(struct ast_xml_node *node, const char *name, const char *value);
-/*! \brief Find a node element by name.
- * \param node This is the node starting point.
- * \param name Node name to find.
- * \param attrname attribute name to match (if NULL it won't be matched).
- * \param attrvalue attribute value to match (if NULL it won't be matched).
- * \retval NULL if not found
- * \retval The node on success.
+/*!
+ * \brief Find a node element by name.
+ * \param node This is the node starting point.
+ * \param name Node name to find.
+ * \param attrname attribute name to match (if NULL it won't be matched).
+ * \param attrvalue attribute value to match (if NULL it won't be matched).
+ * \retval NULL if not found
+ * \retval The node on success.
*/
struct ast_xml_node *ast_xml_find_element(struct ast_xml_node *root_node, const char *name, const char *attrname, const char *attrvalue);
-/*! \brief Get an element content string.
- * \param node Node from where to get the string.
- * \retval NULL on error.
- * \retval The text content of node.
+/*!
+ * \brief Get an element content string.
+ * \param node Node from where to get the string.
+ * \retval NULL on error.
+ * \retval The text content of node.
*/
const char *ast_xml_get_text(struct ast_xml_node *node);
-/*! \brief Set an element content string.
- * \param node Node from where to set the content string.
- * \param content The text to insert in the node.
+/*!
+ * \brief Set an element content string.
+ * \param node Node from where to set the content string.
+ * \param content The text to insert in the node.
*/
void ast_xml_set_text(struct ast_xml_node *node, const char *content);
-/*! \brief Get the name of a node. */
+/*!
+ * \brief Get the name of a node. */
const char *ast_xml_node_get_name(struct ast_xml_node *node);
-/*! \brief Get the node's children. */
+/*!
+ * \brief Get the node's children. */
struct ast_xml_node *ast_xml_node_get_children(struct ast_xml_node *node);
-/*! \brief Get the next node in the same level. */
+/*!
+ * \brief Get the next node in the same level. */
struct ast_xml_node *ast_xml_node_get_next(struct ast_xml_node *node);
-/*! \brief Get the previous node in the same leve. */
+/*!
+ * \brief Get the previous node in the same leve. */
struct ast_xml_node *ast_xml_node_get_prev(struct ast_xml_node *node);
-/*! \brief Get the parent of a specified node. */
+/*!
+ * \brief Get the parent of a specified node. */
struct ast_xml_node *ast_xml_node_get_parent(struct ast_xml_node *node);
-/*! \brief Dump the specified document to a file. */
+/*!
+ * \brief Dump the specified document to a file. */
int ast_xml_doc_dump_file(FILE *output, struct ast_xml_doc *doc);
/* Features using ast_xml_ */
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=204320&r1=204319&r2=204320
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Mon Jun 29 18:21:06 2009
@@ -43,8 +43,8 @@
/*! \brief The node content. */
union {
- int sint;
- unsigned int uint;
+ int32_t sint;
+ uint32_t uint;
double dbl;
unsigned int boolean:1;
char *str;
@@ -104,7 +104,7 @@
static int data_provider_hash(const void *obj, const int flags)
{
const struct data_provider *node = obj;
- return ast_str_hash(node->name);
+ return ast_str_case_hash(node->name);
}
/*!
@@ -144,29 +144,20 @@
* \brief Lock the data registered handlers structure for writing.
* \see data_unlock
*/
-static inline void data_write_lock(void)
-{
- ast_rwlock_wrlock(&root_data_lock);
-}
+#define data_write_lock() ast_rwlock_wrlock(&root_data_lock)
/*!
* \internal
* \brief Lock the data registered handlers structure for reading.
* \see data_unlock
*/
-static inline void data_read_lock(void)
-{
- ast_rwlock_rdlock(&root_data_lock);
-}
+#define data_read_lock() ast_rwlock_rdlock(&root_data_lock)
/*!
* \internal
* \brief Unlock the data registered handlers structure.
*/
-static inline void data_unlock(void)
-{
- ast_rwlock_unlock(&root_data_lock);
-}
+#define data_unlock() ast_rwlock_unlock(&root_data_lock)
/*!
* \internal
@@ -182,7 +173,7 @@
do {
res = strsep(path, "/");
- } while (res && !strlen(res));
+ } while (res && ast_strlen_zero(res));
return res;
}
@@ -277,7 +268,7 @@
if (found && found->registrar && registrar) {
if (strcmp(found->registrar, registrar)) {
/* if the name doesn't match, do not return this node. */
- ast_log(LOG_DEBUG, "Registrar doesn't match, node was registered"
+ ast_debug(1, "Registrar doesn't match, node was registered"
" by '%s' and we are searching for '%s'\n",
found->registrar, registrar);
ao2_ref(found, -1);
@@ -384,10 +375,7 @@
char *rpath, *node_name;
struct data_provider *child, *ret = NULL;
- rpath = strdupa(path);
- if (!rpath) {
- return NULL;
- }
+ rpath = ast_strdupa(path);
node_name = next_node_name(&rpath);
if (!node_name) {
@@ -507,15 +495,13 @@
ast_free(root->payload.ptr);
break;
case AST_DATA_CONTAINER:
- i = ao2_iterator_init(root->children, 0);
-
- while ((child = ao2_iterator_next(&i))) {
- ao2_unlink(root->children, child);
- ao2_ref(child, -1);
- }
-
+ ao2_ref(root->children, -1);
break;
- default:
+ case AST_DATA_INTEGER:
+ case AST_DATA_UNSIGNED_INTEGER:
+ case AST_DATA_DOUBLE:
+ case AST_DATA_BOOLEAN:
+ case AST_DATA_IPADDR:
break;
}
}
@@ -592,11 +578,6 @@
}
savepath = ast_strdupa(path);
- if (!savepath) {
- ast_log(LOG_ERROR, "Unable to allocate memory to store "
- "the passed path\n");
- return NULL;
- }
child = data_result_find_child(node, next_node_name(&savepath));
if (!child) {
More information about the svn-commits
mailing list