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:
George Joseph
2022-06-27 11:31:04 -06:00
parent 5761d7ab3b
commit d0ef2164d9
11 changed files with 358 additions and 20 deletions

View File

@@ -1859,6 +1859,67 @@ char *ast_strsep(char **iss, const char sep, uint32_t flags)
return st;
}
char *ast_strsep_quoted(char **iss, const char sep, const char quote, uint32_t flags)
{
char *st = *iss;
char *is;
int inquote = 0;
int found = 0;
char stack[8];
const char qstr[] = { quote };
if (ast_strlen_zero(st)) {
return NULL;
}
memset(stack, 0, sizeof(stack));
for(is = st; *is; is++) {
if (*is == '\\') {
if (*++is != '\0') {
is++;
} else {
break;
}
}
if (*is == quote) {
if (*is == stack[inquote]) {
stack[inquote--] = '\0';
} else {
if (++inquote >= sizeof(stack)) {
return NULL;
}
stack[inquote] = *is;
}
}
if (*is == sep && !inquote) {
*is = '\0';
found = 1;
*iss = is + 1;
break;
}
}
if (!found) {
*iss = NULL;
}
if (flags & AST_STRSEP_STRIP) {
st = ast_strip_quoted(st, qstr, qstr);
}
if (flags & AST_STRSEP_TRIM) {
st = ast_strip(st);
}
if (flags & AST_STRSEP_UNESCAPE) {
ast_unescape_quoted(st);
}
return st;
}
char *ast_unescape_semicolon(char *s)
{
char *e;