mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
xml.c, config,c: Add stylesheets and variable list string parsing
Added functions to open, close, and apply XML Stylesheets to XML documents. Although the presence of libxslt was already being checked by configure, it was only happening if xmldoc was enabled. Now it's checked regardless. Added ability to parse a string consisting of comma separated name/value pairs into an ast_variable list. The reverse of ast_variable_list_join(). Change-Id: I1e1d149be22165a1fb8e88e2903a36bba1a6cf2e
This commit is contained in:
@@ -722,6 +722,39 @@ 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)
|
||||
{
|
||||
char item_sep;
|
||||
char nv_sep;
|
||||
struct ast_variable *new_list = NULL;
|
||||
struct ast_variable *new_var = NULL;
|
||||
char *item_string;
|
||||
char *item;
|
||||
char *item_name;
|
||||
char *item_value;
|
||||
|
||||
if (ast_strlen_zero(input)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item_sep = ast_strlen_zero(item_separator) ? ',' : item_separator[0];
|
||||
nv_sep = ast_strlen_zero(name_value_separator) ? '=' : name_value_separator[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);
|
||||
new_var = ast_variable_new(item_name, item_value, "");
|
||||
if (!new_var) {
|
||||
ast_variables_destroy(new_list);
|
||||
return NULL;
|
||||
}
|
||||
ast_variable_list_append(&new_list, new_var);
|
||||
}
|
||||
return new_list;
|
||||
}
|
||||
|
||||
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