Index: include/asterisk/data.h =================================================================== --- include/asterisk/data.h (revision 208462) +++ include/asterisk/data.h (working copy) @@ -571,34 +571,68 @@ * \retval 0 on success. * \retval <0 on error. */ -int ast_data_retrieve(struct ast_data *tree, const char *path, struct ast_data_retrieve *content); +int ast_data_retrieve_literal(struct ast_data *tree, const char *path, struct ast_data_retrieve *content); /*! + * \brief Retrieve node for the indicated path + * \param[in] tree The structure returned by a call to ast_data_get. + * \param[in] path Location within the tree + * \retval NULL on error + * \return node for the indicated path + */ +struct ast_data *ast_data_get_node(struct ast_data *tree, const char *path) + +/*! + * \brief Retrieve a value from a node in the tree. + * \param[in] tree The structure returned by a call to ast_data_get. + * \param[in] nodepath The node structure for the path. + * \param[out] content The node content. + * \retval 0 on success. + * \retval <0 on error. + */ +int ast_data_retrieve(struct ast_data *tree, const struct ast_data *nodepath, struct ast_data_retrieve *content); + +/*! * \brief Retrieve the integer value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ -static inline int ast_data_retrieve_int(struct ast_data *tree, const char *path) +static inline int ast_data_retrieve_int_literal(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; - ast_data_retrieve(tree, path, &ret); + ast_data_retrieve_literal(tree, path, &ret); return ret.value.AST_DATA_INTEGER; } /*! + * \brief Retrieve the integer value of a node. + * \param[in] tree The tree from where to get the value. + * \param[in] nodepath The node name or path. + * \returns The value of the node. + */ +static inline int ast_data_retrieve_int_literal(struct ast_data *tree, const struct ast_data *nodepath) +{ + struct ast_data_retrieve ret; + + ast_data_retrieve(tree, nodepath, &ret); + + return ret.value.AST_DATA_INTEGER; +} + +/*! * \brief Retrieve the boolean value of a node. * \param[in] tree The tree from where to get the value. * \param[in] path The node name or path. * \returns The value of the node. */ -static inline unsigned int ast_data_retrieve_bool(struct ast_data *tree, const char *path) +static inline unsigned int ast_data_retrieve_bool_literal(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; - ast_data_retrieve(tree, path, &ret); + ast_data_retrieve_literal(tree, path, &ret); return ret.value.AST_DATA_BOOLEAN; } @@ -609,11 +643,11 @@ * \param[in] path The node name or path. * \returns The value of the node. */ -static inline unsigned int ast_data_retrieve_uint(struct ast_data *tree, const char *path) +static inline unsigned int ast_data_retrieve_uint_literal(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; - ast_data_retrieve(tree, path, &ret); + ast_data_retrieve_literal(tree, path, &ret); return ret.value.AST_DATA_UNSIGNED_INTEGER; } @@ -624,11 +658,11 @@ * \param[in] path The node name or path. * \returns The value of the node. */ -static inline const char *ast_data_retrieve_string(struct ast_data *tree, const char *path) +static inline const char *ast_data_retrieve_string_literal(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; - ast_data_retrieve(tree, path, &ret); + ast_data_retrieve_literal(tree, path, &ret); return ret.value.AST_DATA_STRING; } @@ -639,11 +673,11 @@ * \param[in] path The node name or path. * \returns The value of the node. */ -static inline void *ast_data_retrieve_ptr(struct ast_data *tree, const char *path) +static inline void *ast_data_retrieve_ptr_literal(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; - ast_data_retrieve(tree, path, &ret); + ast_data_retrieve_literal(tree, path, &ret); return ret.value.AST_DATA_POINTER; } @@ -654,11 +688,11 @@ * \param[in] path The node name or path. * \returns The value of the node. */ -static inline double ast_data_retrieve_dbl(struct ast_data *tree, const char *path) +static inline double ast_data_retrieve_dbl_literal(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; - ast_data_retrieve(tree, path, &ret); + ast_data_retrieve_literal(tree, path, &ret); return ret.value.AST_DATA_DOUBLE; } @@ -669,11 +703,11 @@ * \param[in] path The node name or path. * \returns The value of the node. */ -static inline struct in_addr ast_data_retrieve_ipaddr(struct ast_data *tree, const char *path) +static inline struct in_addr ast_data_retrieve_ipaddr_literal(struct ast_data *tree, const char *path) { struct ast_data_retrieve ret; - ast_data_retrieve(tree, path, &ret); + ast_data_retrieve_literal(tree, path, &ret); return ret.value.AST_DATA_IPADDR; } Index: main/data.c =================================================================== --- main/data.c (revision 208462) +++ main/data.c (working copy) @@ -1357,24 +1357,23 @@ * \retval NULL if the internal node is not found. * \retval non-NULL the internal node with path 'path'. */ -static struct ast_data *data_result_get_node(struct ast_data *node, - const char *path) +const struct ast_data *ast_data_get_node(struct ast_data *tree, const char *path) { char *savepath; struct ast_data *child; if (!path) { - return node; + return tree; } savepath = ast_strdupa(path); - child = data_result_find_child(node, next_node_name(&savepath)); + child = data_result_find_child(tree, next_node_name(&savepath)); if (!child) { return NULL; } - return data_result_get_node(child, savepath); + return ast_data_get_node(child, savepath); } /*! @@ -1812,7 +1811,7 @@ { struct ast_data *internal; - internal = data_result_get_node(node, path); + internal = ast_data_get_node(node, path); if (!internal) { return -1; } @@ -2007,7 +2006,7 @@ ptr = strrchr(path, '/'); if (ptr) { *ptr = '\0'; - internal = data_result_get_node(tree, path); + internal = ast_data_get_node(tree, path); if (!internal) { return NULL; } @@ -2082,7 +2081,7 @@ return res; } -int ast_data_retrieve(struct ast_data *tree, const char *path, struct ast_data_retrieve *content) +int ast_data_retrieve_literal(struct ast_data *tree, const char *path, struct ast_data_retrieve *content) { struct ast_data *node; @@ -2090,7 +2089,7 @@ return -1; } - node = data_result_get_node(tree, path); + node = ast_data_get_node(tree, path); if (!node) { ast_log(LOG_ERROR, "Invalid internal node %s\n", path); return -1;