channels: Allow updating variable value

When modifying an already defined variable in some channel drivers they
add a new variable with the same name to the list, but that value is
never used, only the first one found.

Introduce ast_variable_list_replace() and use it where appropriate.

ASTERISK-23756 #close
Patches:
  setvar-multiplie.patch submitted by Michael Goryainov

Change-Id: Ie1897a96c82b8945e752733612ee963686f32839
This commit is contained in:
Sean Bright
2019-09-11 16:58:29 -04:00
parent cb90d1cd7c
commit 518b6bfb5c
6 changed files with 55 additions and 11 deletions

View File

@@ -948,6 +948,24 @@ struct ast_variable *ast_variable_list_append_hint(struct ast_variable **head, s
struct ast_variable *new_var);
#define ast_variable_list_append(head, new_var) ast_variable_list_append_hint(head, NULL, new_var)
/*!
* \brief Replace a variable in the given list with a new value
* \since 13.30.0
*
* \param head A pointer to an ast_variable * of the existing variable list head. May NOT be NULL
* but the content may be to initialize a new list. If so, upon return, this parameter will be updated
* with a pointer to the new list head.
* \param replacement The variable that replaces another variable in the list with the
* same name.
*
* \retval 0 if a variable was replaced in the list
* \retval -1 if no replacement occured
*
* \note The variable name comparison is performed case-sensitively
* \note If a variable is replaced, its memory is freed.
*/
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement);
/*!
* \brief Update variable value within a config
*