From 5918d8d4a1cf35b10e8c2d4612d327809da8ade3 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 10 Apr 2020 18:44:25 +0000 Subject: [PATCH] [core] add switch_filecmp --- src/include/switch_utils.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index ec361a9885..e5a794282a 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -1280,6 +1280,31 @@ static inline switch_bool_t switch_is_file_path(const char *file) return r ? SWITCH_TRUE : SWITCH_FALSE; } +static inline int switch_filecmp(const char *a, const char *b) +{ + const char *e; + + if (zstr(a) || zstr(b)) { + return -1; + } + + while(*a == '{') { + if ((e = switch_find_end_paren(a, '{', '}'))) { + a = e + 1; + while(*a == ' ') a++; + } + } + + while(*b == '{') { + if ((e = switch_find_end_paren(b, '{', '}'))) { + b = e + 1; + while(*b == ' ') b++; + } + } + + return strcmp(a, b); +} + static inline const char *switch_parse_audio_col(switch_audio_col_t col) {