mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
core: Config and XML tweaks needed for geolocation
Added: Replace a variable in a list: int ast_variable_list_replace_variable(struct ast_variable **head, struct ast_variable *old, struct ast_variable *new); Added test as well. Create a "name=value" string from a variable list: 'name1="val1",name2="val2"', etc. struct ast_str *ast_variable_list_join( const struct ast_variable *head, const char *item_separator, const char *name_value_separator, const char *quote_char, struct ast_str **str); Added test as well. Allow the name of an XML element to be changed. void ast_xml_set_name(struct ast_xml_node *node, const char *name); Change-Id: I330a5f63dc0c218e0d8dfc0745948d2812141ccb
This commit is contained in:
committed by
Friendly Automation
parent
e29cd99975
commit
38df1c35ee
@@ -967,6 +967,44 @@ struct ast_variable *ast_variable_list_append_hint(struct ast_variable **head, s
|
||||
*/
|
||||
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement);
|
||||
|
||||
/*!
|
||||
* \brief Replace a variable in the given list with a new variable
|
||||
*
|
||||
* \param head A pointer to the current variable list head. Since the variable to be
|
||||
* replaced, this pointer may be updated with the new head.
|
||||
* \param old A pointer to the existing variable to be replaced.
|
||||
* \param new A pointer to the new variable that will replace the old one.
|
||||
*
|
||||
* \retval 0 if a variable was replaced in the list
|
||||
* \retval -1 if no replacement occured
|
||||
*
|
||||
* \note The search for the old variable is done simply on the pointer.
|
||||
* \note If a variable is replaced, its memory is freed.
|
||||
*/
|
||||
int ast_variable_list_replace_variable(struct ast_variable **head, struct ast_variable *old,
|
||||
struct ast_variable *new);
|
||||
|
||||
/*!
|
||||
* \brief Join an ast_variable list with specified separators and quoted values
|
||||
*
|
||||
* \param head A pointer to an ast_variable list head.
|
||||
* \param item_separator The string to use to separate the list items.
|
||||
* If NULL, "," will be used.
|
||||
* \param name_value_separator The string to use to separate each item's name and value.
|
||||
* If NULL, "=" will be used.
|
||||
* \param str A pointer to a pre-allocated ast_str in which to put the results.
|
||||
* If NULL, one will be allocated and returned.
|
||||
* \param quote_char The quote char to use for the values.
|
||||
* May be NULL or empty for no quoting.
|
||||
*
|
||||
* \retval A pointer to the result ast_str. This may NOT be the same as the pointer
|
||||
* passed in if the original ast_str wasn't large enough to hold the result.
|
||||
* Regardless, the pointer MUST be freed after use.
|
||||
* \retval NULL if there was an error.
|
||||
*/
|
||||
struct ast_str *ast_variable_list_join(const struct ast_variable *head, const char *item_separator,
|
||||
const char *name_value_separator, const char *quote_char, struct ast_str **str);
|
||||
|
||||
/*!
|
||||
* \brief Update variable value within a config
|
||||
*
|
||||
|
@@ -201,6 +201,13 @@ const char *ast_xml_get_text(struct ast_xml_node *node);
|
||||
*/
|
||||
void ast_xml_set_text(struct ast_xml_node *node, const char *content);
|
||||
|
||||
/*!
|
||||
* \brief Set or reset an element's name.
|
||||
* \param node Node whose name is to be set.
|
||||
* \param name New name.
|
||||
*/
|
||||
void ast_xml_set_name(struct ast_xml_node *node, const char *name);
|
||||
|
||||
/*!
|
||||
* \brief Get the name of a node. */
|
||||
const char *ast_xml_node_get_name(struct ast_xml_node *node);
|
||||
|
Reference in New Issue
Block a user