From: Jaroslav Kysela Date: Fri, 9 Nov 2018 12:30:31 +0000 (+0100) Subject: htsmsg: add htsmsg_remove_string_from_list() function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6b3bc54c6be7bf7a20be049223dc6ac41eac184;p=thirdparty%2Ftvheadend.git htsmsg: add htsmsg_remove_string_from_list() function --- 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); + /** * */