From d6b3bc54c6be7bf7a20be049223dc6ac41eac184 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 9 Nov 2018 13:30:31 +0100 Subject: [PATCH] htsmsg: add htsmsg_remove_string_from_list() function --- src/htsmsg.c | 23 +++++++++++++++++++++++ src/htsmsg.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/htsmsg.c b/src/htsmsg.c index 735aff7dd..b45dd929f 100644 --- a/src/htsmsg.c +++ b/src/htsmsg.c @@ -1543,3 +1543,26 @@ htsmsg_is_string_in_list(htsmsg_t *list, const char *str) } return 0; } + +/* + * + */ +int +htsmsg_remove_string_from_list(htsmsg_t *list, const char *str) +{ + const char *s; + htsmsg_field_t *f; + + if (list == NULL || !list->hm_islist) + return 0; + HTSMSG_FOREACH(f, list) { + s = htsmsg_field_get_str(f); + if (s == NULL) + continue; + if (!strcasecmp(s, str)) { + htsmsg_field_destroy(list, f); + return 1; + } + } + return 0; +} diff --git a/src/htsmsg.h b/src/htsmsg.h index e9dd2a8c5..5cdcaa486 100644 --- a/src/htsmsg.h +++ b/src/htsmsg.h @@ -512,6 +512,8 @@ htsmsg_t *htsmsg_create_key_val(const char *key, const char *val); int htsmsg_is_string_in_list(htsmsg_t *list, const char *str); +int htsmsg_remove_string_from_list(htsmsg_t *list, const char *str); + /** * */ -- 2.47.3