Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
0eb27e19
Commit
0eb27e19
authored
6 years ago
by
George Joseph
Committed by
Gerrit Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "json.c/strings.c - Add a couple of utility functions"
parents
de64949f
8f1b3edd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/asterisk/json.h
+11
-0
11 additions, 0 deletions
include/asterisk/json.h
include/asterisk/strings.h
+15
-0
15 additions, 0 deletions
include/asterisk/strings.h
main/strings.c
+9
-0
9 additions, 0 deletions
main/strings.c
with
35 additions
and
0 deletions
include/asterisk/json.h
+
11
−
0
View file @
0eb27e19
...
...
@@ -561,6 +561,17 @@ size_t ast_json_object_size(struct ast_json *object);
*/
struct
ast_json
*
ast_json_object_get
(
struct
ast_json
*
object
,
const
char
*
key
);
/*!
* \brief Get a string field from a JSON object.
* \since 16.3.0
*
* \param object JSON object.
* \param key Key of string field to look up.
* \return String value of given \a key.
* \return \c NULL on error, or key value is not a string.
*/
#define ast_json_object_string_get(object, key) ast_json_string_get(ast_json_object_get(object, key))
/*!
* \brief Set a field in a JSON object.
* \since 12.0.0
...
...
This diff is collapsed.
Click to expand it.
include/asterisk/strings.h
+
15
−
0
View file @
0eb27e19
...
...
@@ -1297,6 +1297,21 @@ void ast_str_container_remove(struct ao2_container *str_container, const char *r
*/
char
*
ast_generate_random_string
(
char
*
buf
,
size_t
size
);
/*!
* \brief Compare strings for equality checking for NULL.
* \since 16.3.0
*
* This function considers NULL values as non-strings, thus a false condition.
* This means that it will return false if one, or both of the given values are
* NULL (i.e. two NULLs are not equal strings).
*
* \param str1 The string to compare to str2
* \param str2 The string to compare to str1
*
* \return true if valid strings and equal, false otherwise.
*/
int
ast_strings_equal
(
const
char
*
str1
,
const
char
*
str2
);
/*!
* \brief Compares 2 strings using realtime-style operators
* \since 13.9.0
...
...
This diff is collapsed.
Click to expand it.
main/strings.c
+
9
−
0
View file @
0eb27e19
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment