mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
Geolocation: Base Asterisk Prereqs
* Added ast_variable_list_from_quoted_string() Parse a quoted string into an ast_variable list. * Added ast_str_substitute_variables_full2() Perform variable/function/expression substitution on an ast_str. * Added ast_strsep_quoted() Like ast_strsep except you can specify a specific quote character. Also added unit test. * Added ast_xml_find_child_element() Find a direct child element by name. * Added ast_xml_doc_dump_memory() Dump the specified document to a buffer * ast_datastore_free() now checks for a NULL datastore before attempting to destroy it. Change-Id: I5dcefed2f5f93a109e8b489e18d80d42e45244ec
This commit is contained in:
committed by
Friendly Automation
parent
740c773781
commit
5fe9887701
@@ -722,11 +722,12 @@ struct ast_str *ast_variable_list_join(const struct ast_variable *head, const ch
|
||||
return local_str;
|
||||
}
|
||||
|
||||
struct ast_variable *ast_variable_list_from_string(const char *input, const char *item_separator,
|
||||
const char *name_value_separator)
|
||||
struct ast_variable *ast_variable_list_from_quoted_string(const char *input, const char *item_separator,
|
||||
const char *name_value_separator, const char *quote_str)
|
||||
{
|
||||
char item_sep;
|
||||
char nv_sep;
|
||||
char quote;
|
||||
struct ast_variable *new_list = NULL;
|
||||
struct ast_variable *new_var = NULL;
|
||||
char *item_string;
|
||||
@@ -740,11 +741,22 @@ struct ast_variable *ast_variable_list_from_string(const char *input, const char
|
||||
|
||||
item_sep = ast_strlen_zero(item_separator) ? ',' : item_separator[0];
|
||||
nv_sep = ast_strlen_zero(name_value_separator) ? '=' : name_value_separator[0];
|
||||
quote = ast_strlen_zero(quote_str) ? '"' : quote_str[0];
|
||||
item_string = ast_strip(ast_strdupa(input));
|
||||
|
||||
while ((item = ast_strsep(&item_string, item_sep, AST_STRSEP_ALL))) {
|
||||
item_name = ast_strsep(&item, nv_sep, AST_STRSEP_ALL);
|
||||
item_value = ast_strsep(&item, nv_sep, AST_STRSEP_ALL);
|
||||
while ((item = ast_strsep_quoted(&item_string, item_sep, quote, AST_STRSEP_ALL))) {
|
||||
item_name = ast_strsep_quoted(&item, nv_sep, quote, AST_STRSEP_ALL);
|
||||
if (!item_name) {
|
||||
ast_variables_destroy(new_list);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item_value = ast_strsep_quoted(&item, nv_sep, quote, AST_STRSEP_ALL);
|
||||
if (!item_value) {
|
||||
ast_variables_destroy(new_list);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_var = ast_variable_new(item_name, item_value, "");
|
||||
if (!new_var) {
|
||||
ast_variables_destroy(new_list);
|
||||
@@ -755,6 +767,12 @@ struct ast_variable *ast_variable_list_from_string(const char *input, const char
|
||||
return new_list;
|
||||
}
|
||||
|
||||
struct ast_variable *ast_variable_list_from_string(const char *input, const char *item_separator,
|
||||
const char *name_value_separator)
|
||||
{
|
||||
return ast_variable_list_from_quoted_string(input, item_separator, name_value_separator, NULL);
|
||||
}
|
||||
|
||||
const char *ast_config_option(struct ast_config *cfg, const char *cat, const char *var)
|
||||
{
|
||||
const char *tmp;
|
||||
|
Reference in New Issue
Block a user