json.c/strings.c - Add a couple of utility functions

Added 'ast_json_object_string_get' to the JSON wrapper in order to make it a
little easier to retrieve a string field from the JSON object.

Also added an 'ast_strings_equal' function that safely checks (checks for NULLs)
for equality between two strings.

Change-Id: I26f0a16d61537505eb41b4b05ef2e6d67fc2541b
This commit is contained in:
Kevin Harwell
2019-02-08 14:12:37 -06:00
parent b327b0bbda
commit e85f92f37a
3 changed files with 35 additions and 0 deletions

View File

@@ -236,6 +236,15 @@ char *ast_generate_random_string(char *buf, size_t size)
return buf;
}
int ast_strings_equal(const char *str1, const char *str2)
{
if (!str1 || !str2) {
return 0;
}
return str1 == str2 || !strcmp(str1, str2);
}
int ast_strings_match(const char *left, const char *op, const char *right)
{
char *internal_op = (char *)op;