mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-11 12:28:27 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user